Skip to content
Snippets Groups Projects
Commit 3dcfa3a4 authored by Goik Martin's avatar Goik Martin
Browse files

Simplified JQuery

parent b5636ff4
No related branches found
No related tags found
No related merge requests found
jQuery.fn.extend({
toggleVisibilityState: function() {
var ATT_TOGGLE_VALUES = [
// attribute, closed state , open state
['value', '+', '-'],
['title', 'open solution (Did you try hard enough yourself?)', 'Close solution']
];
var nextIndex;
switch(this.attr(ATT_TOGGLE_VALUES[0][0])) { // First attribute defines reference
case ATT_TOGGLE_VALUES[0][1]:
nextIndex = 2; break;
switch(this.attr('value')) { // »value« attribute defines state
case '+':
this.attr('value', '-');
this.attr('title', 'Close solution');
break;
default:
nextIndex = 1; break;
}
for (var r in ATT_TOGGLE_VALUES) {
this.attr(ATT_TOGGLE_VALUES[r][0], ATT_TOGGLE_VALUES[r][nextIndex]);
this.attr('value', '+');
this.attr('title', 'open solution (Did you try hard enough yourself?)');
break;
}
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment