1 |
503b3f7b
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
85ad3d82
|
Assos Assos
|
|
5 |
503b3f7b
|
Assos Assos
|
|
6 |
|
|
|
7 |
85ad3d82
|
Assos Assos
|
|
8 |
|
|
|
9 |
503b3f7b
|
Assos Assos
|
|
10 |
85ad3d82
|
Assos Assos
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
(function( $, undefined ) {
|
16 |
|
|
|
17 |
503b3f7b
|
Assos Assos
|
var lastActive, startXPos, startYPos, clickDragged,
|
18 |
85ad3d82
|
Assos Assos
|
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
|
19 |
|
|
stateClasses = "ui-state-hover ui-state-active ",
|
20 |
|
|
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
|
21 |
503b3f7b
|
Assos Assos
|
formResetHandler = function() {
|
22 |
|
|
var buttons = $( this ).find( ":ui-button" );
|
23 |
|
|
setTimeout(function() {
|
24 |
|
|
buttons.button( "refresh" );
|
25 |
|
|
}, 1 );
|
26 |
85ad3d82
|
Assos Assos
|
},
|
27 |
|
|
radioGroup = function( radio ) {
|
28 |
|
|
var name = radio.name,
|
29 |
|
|
form = radio.form,
|
30 |
|
|
radios = $( [] );
|
31 |
|
|
if ( name ) {
|
32 |
503b3f7b
|
Assos Assos
|
name = name.replace( /'/g, "\\'" );
|
33 |
85ad3d82
|
Assos Assos
|
if ( form ) {
|
34 |
|
|
radios = $( form ).find( "[name='" + name + "']" );
|
35 |
|
|
} else {
|
36 |
|
|
radios = $( "[name='" + name + "']", radio.ownerDocument )
|
37 |
|
|
.filter(function() {
|
38 |
|
|
return !this.form;
|
39 |
|
|
});
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
return radios;
|
43 |
|
|
};
|
44 |
|
|
|
45 |
|
|
$.widget( "ui.button", {
|
46 |
503b3f7b
|
Assos Assos
|
version: "1.10.2",
|
47 |
|
|
defaultElement: "<button>",
|
48 |
85ad3d82
|
Assos Assos
|
options: {
|
49 |
|
|
disabled: null,
|
50 |
|
|
text: true,
|
51 |
|
|
label: null,
|
52 |
|
|
icons: {
|
53 |
|
|
primary: null,
|
54 |
|
|
secondary: null
|
55 |
|
|
}
|
56 |
|
|
},
|
57 |
|
|
_create: function() {
|
58 |
|
|
this.element.closest( "form" )
|
59 |
503b3f7b
|
Assos Assos
|
.unbind( "reset" + this.eventNamespace )
|
60 |
|
|
.bind( "reset" + this.eventNamespace, formResetHandler );
|
61 |
85ad3d82
|
Assos Assos
|
|
62 |
|
|
if ( typeof this.options.disabled !== "boolean" ) {
|
63 |
503b3f7b
|
Assos Assos
|
this.options.disabled = !!this.element.prop( "disabled" );
|
64 |
|
|
} else {
|
65 |
|
|
this.element.prop( "disabled", this.options.disabled );
|
66 |
85ad3d82
|
Assos Assos
|
}
|
67 |
|
|
|
68 |
|
|
this._determineButtonType();
|
69 |
|
|
this.hasTitle = !!this.buttonElement.attr( "title" );
|
70 |
|
|
|
71 |
503b3f7b
|
Assos Assos
|
var that = this,
|
72 |
85ad3d82
|
Assos Assos
|
options = this.options,
|
73 |
|
|
toggleButton = this.type === "checkbox" || this.type === "radio",
|
74 |
503b3f7b
|
Assos Assos
|
activeClass = !toggleButton ? "ui-state-active" : "",
|
75 |
85ad3d82
|
Assos Assos
|
focusClass = "ui-state-focus";
|
76 |
|
|
|
77 |
|
|
if ( options.label === null ) {
|
78 |
503b3f7b
|
Assos Assos
|
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
|
79 |
85ad3d82
|
Assos Assos
|
}
|
80 |
|
|
|
81 |
503b3f7b
|
Assos Assos
|
this._hoverable( this.buttonElement );
|
82 |
85ad3d82
|
Assos Assos
|
|
83 |
|
|
this.buttonElement
|
84 |
|
|
.addClass( baseClasses )
|
85 |
|
|
.attr( "role", "button" )
|
86 |
503b3f7b
|
Assos Assos
|
.bind( "mouseenter" + this.eventNamespace, function() {
|
87 |
85ad3d82
|
Assos Assos
|
if ( options.disabled ) {
|
88 |
|
|
return;
|
89 |
|
|
}
|
90 |
|
|
if ( this === lastActive ) {
|
91 |
|
|
$( this ).addClass( "ui-state-active" );
|
92 |
|
|
}
|
93 |
|
|
})
|
94 |
503b3f7b
|
Assos Assos
|
.bind( "mouseleave" + this.eventNamespace, function() {
|
95 |
85ad3d82
|
Assos Assos
|
if ( options.disabled ) {
|
96 |
|
|
return;
|
97 |
|
|
}
|
98 |
503b3f7b
|
Assos Assos
|
$( this ).removeClass( activeClass );
|
99 |
85ad3d82
|
Assos Assos
|
})
|
100 |
503b3f7b
|
Assos Assos
|
.bind( "click" + this.eventNamespace, function( event ) {
|
101 |
|
|
if ( options.disabled ) {
|
102 |
|
|
event.preventDefault();
|
103 |
|
|
event.stopImmediatePropagation();
|
104 |
|
|
}
|
105 |
|
|
});
|
106 |
|
|
|
107 |
|
|
this.element
|
108 |
|
|
.bind( "focus" + this.eventNamespace, function() {
|
109 |
85ad3d82
|
Assos Assos
|
|
110 |
503b3f7b
|
Assos Assos
|
that.buttonElement.addClass( focusClass );
|
111 |
85ad3d82
|
Assos Assos
|
})
|
112 |
503b3f7b
|
Assos Assos
|
.bind( "blur" + this.eventNamespace, function() {
|
113 |
|
|
that.buttonElement.removeClass( focusClass );
|
114 |
85ad3d82
|
Assos Assos
|
});
|
115 |
|
|
|
116 |
|
|
if ( toggleButton ) {
|
117 |
503b3f7b
|
Assos Assos
|
this.element.bind( "change" + this.eventNamespace, function() {
|
118 |
|
|
if ( clickDragged ) {
|
119 |
|
|
return;
|
120 |
|
|
}
|
121 |
|
|
that.refresh();
|
122 |
|
|
});
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
this.buttonElement
|
127 |
|
|
.bind( "mousedown" + this.eventNamespace, function( event ) {
|
128 |
|
|
if ( options.disabled ) {
|
129 |
|
|
return;
|
130 |
|
|
}
|
131 |
|
|
clickDragged = false;
|
132 |
|
|
startXPos = event.pageX;
|
133 |
|
|
startYPos = event.pageY;
|
134 |
|
|
})
|
135 |
|
|
.bind( "mouseup" + this.eventNamespace, function( event ) {
|
136 |
|
|
if ( options.disabled ) {
|
137 |
|
|
return;
|
138 |
|
|
}
|
139 |
|
|
if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
|
140 |
|
|
clickDragged = true;
|
141 |
|
|
}
|
142 |
85ad3d82
|
Assos Assos
|
});
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
if ( this.type === "checkbox" ) {
|
146 |
503b3f7b
|
Assos Assos
|
this.buttonElement.bind( "click" + this.eventNamespace, function() {
|
147 |
|
|
if ( options.disabled || clickDragged ) {
|
148 |
85ad3d82
|
Assos Assos
|
return false;
|
149 |
|
|
}
|
150 |
|
|
});
|
151 |
|
|
} else if ( this.type === "radio" ) {
|
152 |
503b3f7b
|
Assos Assos
|
this.buttonElement.bind( "click" + this.eventNamespace, function() {
|
153 |
|
|
if ( options.disabled || clickDragged ) {
|
154 |
85ad3d82
|
Assos Assos
|
return false;
|
155 |
|
|
}
|
156 |
|
|
$( this ).addClass( "ui-state-active" );
|
157 |
503b3f7b
|
Assos Assos
|
that.buttonElement.attr( "aria-pressed", "true" );
|
158 |
85ad3d82
|
Assos Assos
|
|
159 |
503b3f7b
|
Assos Assos
|
var radio = that.element[ 0 ];
|
160 |
85ad3d82
|
Assos Assos
|
radioGroup( radio )
|
161 |
|
|
.not( radio )
|
162 |
|
|
.map(function() {
|
163 |
|
|
return $( this ).button( "widget" )[ 0 ];
|
164 |
|
|
})
|
165 |
|
|
.removeClass( "ui-state-active" )
|
166 |
503b3f7b
|
Assos Assos
|
.attr( "aria-pressed", "false" );
|
167 |
85ad3d82
|
Assos Assos
|
});
|
168 |
|
|
} else {
|
169 |
|
|
this.buttonElement
|
170 |
503b3f7b
|
Assos Assos
|
.bind( "mousedown" + this.eventNamespace, function() {
|
171 |
85ad3d82
|
Assos Assos
|
if ( options.disabled ) {
|
172 |
|
|
return false;
|
173 |
|
|
}
|
174 |
|
|
$( this ).addClass( "ui-state-active" );
|
175 |
|
|
lastActive = this;
|
176 |
503b3f7b
|
Assos Assos
|
that.document.one( "mouseup", function() {
|
177 |
85ad3d82
|
Assos Assos
|
lastActive = null;
|
178 |
|
|
});
|
179 |
|
|
})
|
180 |
503b3f7b
|
Assos Assos
|
.bind( "mouseup" + this.eventNamespace, function() {
|
181 |
85ad3d82
|
Assos Assos
|
if ( options.disabled ) {
|
182 |
|
|
return false;
|
183 |
|
|
}
|
184 |
|
|
$( this ).removeClass( "ui-state-active" );
|
185 |
|
|
})
|
186 |
503b3f7b
|
Assos Assos
|
.bind( "keydown" + this.eventNamespace, function(event) {
|
187 |
85ad3d82
|
Assos Assos
|
if ( options.disabled ) {
|
188 |
|
|
return false;
|
189 |
|
|
}
|
190 |
503b3f7b
|
Assos Assos
|
if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
|
191 |
85ad3d82
|
Assos Assos
|
$( this ).addClass( "ui-state-active" );
|
192 |
|
|
}
|
193 |
|
|
})
|
194 |
503b3f7b
|
Assos Assos
|
|
195 |
|
|
|
196 |
|
|
.bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
|
197 |
85ad3d82
|
Assos Assos
|
$( this ).removeClass( "ui-state-active" );
|
198 |
|
|
});
|
199 |
|
|
|
200 |
|
|
if ( this.buttonElement.is("a") ) {
|
201 |
|
|
this.buttonElement.keyup(function(event) {
|
202 |
|
|
if ( event.keyCode === $.ui.keyCode.SPACE ) {
|
203 |
|
|
|
204 |
|
|
$( this ).click();
|
205 |
|
|
}
|
206 |
|
|
});
|
207 |
|
|
}
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
this._setOption( "disabled", options.disabled );
|
214 |
503b3f7b
|
Assos Assos
|
this._resetButton();
|
215 |
85ad3d82
|
Assos Assos
|
},
|
216 |
|
|
|
217 |
|
|
_determineButtonType: function() {
|
218 |
503b3f7b
|
Assos Assos
|
var ancestor, labelSelector, checked;
|
219 |
|
|
|
220 |
|
|
if ( this.element.is("[type=checkbox]") ) {
|
221 |
85ad3d82
|
Assos Assos
|
this.type = "checkbox";
|
222 |
503b3f7b
|
Assos Assos
|
} else if ( this.element.is("[type=radio]") ) {
|
223 |
|
|
this.type = "radio";
|
224 |
|
|
} else if ( this.element.is("input") ) {
|
225 |
|
|
this.type = "input";
|
226 |
85ad3d82
|
Assos Assos
|
} else {
|
227 |
503b3f7b
|
Assos Assos
|
this.type = "button";
|
228 |
85ad3d82
|
Assos Assos
|
}
|
229 |
503b3f7b
|
Assos Assos
|
|
230 |
85ad3d82
|
Assos Assos
|
if ( this.type === "checkbox" || this.type === "radio" ) {
|
231 |
|
|
|
232 |
|
|
|
233 |
503b3f7b
|
Assos Assos
|
ancestor = this.element.parents().last();
|
234 |
|
|
labelSelector = "label[for='" + this.element.attr("id") + "']";
|
235 |
85ad3d82
|
Assos Assos
|
this.buttonElement = ancestor.find( labelSelector );
|
236 |
|
|
if ( !this.buttonElement.length ) {
|
237 |
|
|
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
|
238 |
|
|
this.buttonElement = ancestor.filter( labelSelector );
|
239 |
|
|
if ( !this.buttonElement.length ) {
|
240 |
|
|
this.buttonElement = ancestor.find( labelSelector );
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
this.element.addClass( "ui-helper-hidden-accessible" );
|
244 |
|
|
|
245 |
503b3f7b
|
Assos Assos
|
checked = this.element.is( ":checked" );
|
246 |
85ad3d82
|
Assos Assos
|
if ( checked ) {
|
247 |
|
|
this.buttonElement.addClass( "ui-state-active" );
|
248 |
|
|
}
|
249 |
503b3f7b
|
Assos Assos
|
this.buttonElement.prop( "aria-pressed", checked );
|
250 |
85ad3d82
|
Assos Assos
|
} else {
|
251 |
|
|
this.buttonElement = this.element;
|
252 |
|
|
}
|
253 |
|
|
},
|
254 |
|
|
|
255 |
|
|
widget: function() {
|
256 |
|
|
return this.buttonElement;
|
257 |
|
|
},
|
258 |
|
|
|
259 |
503b3f7b
|
Assos Assos
|
_destroy: function() {
|
260 |
85ad3d82
|
Assos Assos
|
this.element
|
261 |
|
|
.removeClass( "ui-helper-hidden-accessible" );
|
262 |
|
|
this.buttonElement
|
263 |
|
|
.removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
|
264 |
|
|
.removeAttr( "role" )
|
265 |
|
|
.removeAttr( "aria-pressed" )
|
266 |
|
|
.html( this.buttonElement.find(".ui-button-text").html() );
|
267 |
|
|
|
268 |
|
|
if ( !this.hasTitle ) {
|
269 |
|
|
this.buttonElement.removeAttr( "title" );
|
270 |
|
|
}
|
271 |
|
|
},
|
272 |
|
|
|
273 |
|
|
_setOption: function( key, value ) {
|
274 |
503b3f7b
|
Assos Assos
|
this._super( key, value );
|
275 |
85ad3d82
|
Assos Assos
|
if ( key === "disabled" ) {
|
276 |
|
|
if ( value ) {
|
277 |
503b3f7b
|
Assos Assos
|
this.element.prop( "disabled", true );
|
278 |
85ad3d82
|
Assos Assos
|
} else {
|
279 |
503b3f7b
|
Assos Assos
|
this.element.prop( "disabled", false );
|
280 |
85ad3d82
|
Assos Assos
|
}
|
281 |
503b3f7b
|
Assos Assos
|
return;
|
282 |
85ad3d82
|
Assos Assos
|
}
|
283 |
|
|
this._resetButton();
|
284 |
|
|
},
|
285 |
|
|
|
286 |
|
|
refresh: function() {
|
287 |
503b3f7b
|
Assos Assos
|
|
288 |
|
|
var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
|
289 |
|
|
|
290 |
85ad3d82
|
Assos Assos
|
if ( isDisabled !== this.options.disabled ) {
|
291 |
|
|
this._setOption( "disabled", isDisabled );
|
292 |
|
|
}
|
293 |
|
|
if ( this.type === "radio" ) {
|
294 |
|
|
radioGroup( this.element[0] ).each(function() {
|
295 |
|
|
if ( $( this ).is( ":checked" ) ) {
|
296 |
|
|
$( this ).button( "widget" )
|
297 |
|
|
.addClass( "ui-state-active" )
|
298 |
503b3f7b
|
Assos Assos
|
.attr( "aria-pressed", "true" );
|
299 |
85ad3d82
|
Assos Assos
|
} else {
|
300 |
|
|
$( this ).button( "widget" )
|
301 |
|
|
.removeClass( "ui-state-active" )
|
302 |
503b3f7b
|
Assos Assos
|
.attr( "aria-pressed", "false" );
|
303 |
85ad3d82
|
Assos Assos
|
}
|
304 |
|
|
});
|
305 |
|
|
} else if ( this.type === "checkbox" ) {
|
306 |
|
|
if ( this.element.is( ":checked" ) ) {
|
307 |
|
|
this.buttonElement
|
308 |
|
|
.addClass( "ui-state-active" )
|
309 |
503b3f7b
|
Assos Assos
|
.attr( "aria-pressed", "true" );
|
310 |
85ad3d82
|
Assos Assos
|
} else {
|
311 |
|
|
this.buttonElement
|
312 |
|
|
.removeClass( "ui-state-active" )
|
313 |
503b3f7b
|
Assos Assos
|
.attr( "aria-pressed", "false" );
|
314 |
85ad3d82
|
Assos Assos
|
}
|
315 |
|
|
}
|
316 |
|
|
},
|
317 |
|
|
|
318 |
|
|
_resetButton: function() {
|
319 |
|
|
if ( this.type === "input" ) {
|
320 |
|
|
if ( this.options.label ) {
|
321 |
|
|
this.element.val( this.options.label );
|
322 |
|
|
}
|
323 |
|
|
return;
|
324 |
|
|
}
|
325 |
|
|
var buttonElement = this.buttonElement.removeClass( typeClasses ),
|
326 |
503b3f7b
|
Assos Assos
|
buttonText = $( "<span></span>", this.document[0] )
|
327 |
85ad3d82
|
Assos Assos
|
.addClass( "ui-button-text" )
|
328 |
|
|
.html( this.options.label )
|
329 |
|
|
.appendTo( buttonElement.empty() )
|
330 |
|
|
.text(),
|
331 |
|
|
icons = this.options.icons,
|
332 |
|
|
multipleIcons = icons.primary && icons.secondary,
|
333 |
503b3f7b
|
Assos Assos
|
buttonClasses = [];
|
334 |
85ad3d82
|
Assos Assos
|
|
335 |
|
|
if ( icons.primary || icons.secondary ) {
|
336 |
|
|
if ( this.options.text ) {
|
337 |
|
|
buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
|
338 |
|
|
}
|
339 |
|
|
|
340 |
|
|
if ( icons.primary ) {
|
341 |
|
|
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
if ( icons.secondary ) {
|
345 |
|
|
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
if ( !this.options.text ) {
|
349 |
|
|
buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
|
350 |
|
|
|
351 |
|
|
if ( !this.hasTitle ) {
|
352 |
503b3f7b
|
Assos Assos
|
buttonElement.attr( "title", $.trim( buttonText ) );
|
353 |
85ad3d82
|
Assos Assos
|
}
|
354 |
|
|
}
|
355 |
|
|
} else {
|
356 |
|
|
buttonClasses.push( "ui-button-text-only" );
|
357 |
|
|
}
|
358 |
|
|
buttonElement.addClass( buttonClasses.join( " " ) );
|
359 |
|
|
}
|
360 |
|
|
});
|
361 |
|
|
|
362 |
|
|
$.widget( "ui.buttonset", {
|
363 |
503b3f7b
|
Assos Assos
|
version: "1.10.2",
|
364 |
85ad3d82
|
Assos Assos
|
options: {
|
365 |
503b3f7b
|
Assos Assos
|
items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
|
366 |
85ad3d82
|
Assos Assos
|
},
|
367 |
|
|
|
368 |
|
|
_create: function() {
|
369 |
|
|
this.element.addClass( "ui-buttonset" );
|
370 |
|
|
},
|
371 |
503b3f7b
|
Assos Assos
|
|
372 |
85ad3d82
|
Assos Assos
|
_init: function() {
|
373 |
|
|
this.refresh();
|
374 |
|
|
},
|
375 |
|
|
|
376 |
|
|
_setOption: function( key, value ) {
|
377 |
|
|
if ( key === "disabled" ) {
|
378 |
|
|
this.buttons.button( "option", key, value );
|
379 |
|
|
}
|
380 |
|
|
|
381 |
503b3f7b
|
Assos Assos
|
this._super( key, value );
|
382 |
85ad3d82
|
Assos Assos
|
},
|
383 |
503b3f7b
|
Assos Assos
|
|
384 |
85ad3d82
|
Assos Assos
|
refresh: function() {
|
385 |
503b3f7b
|
Assos Assos
|
var rtl = this.element.css( "direction" ) === "rtl";
|
386 |
|
|
|
387 |
85ad3d82
|
Assos Assos
|
this.buttons = this.element.find( this.options.items )
|
388 |
|
|
.filter( ":ui-button" )
|
389 |
|
|
.button( "refresh" )
|
390 |
|
|
.end()
|
391 |
|
|
.not( ":ui-button" )
|
392 |
|
|
.button()
|
393 |
|
|
.end()
|
394 |
|
|
.map(function() {
|
395 |
|
|
return $( this ).button( "widget" )[ 0 ];
|
396 |
|
|
})
|
397 |
|
|
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
|
398 |
|
|
.filter( ":first" )
|
399 |
503b3f7b
|
Assos Assos
|
.addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
|
400 |
85ad3d82
|
Assos Assos
|
.end()
|
401 |
|
|
.filter( ":last" )
|
402 |
503b3f7b
|
Assos Assos
|
.addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
|
403 |
85ad3d82
|
Assos Assos
|
.end()
|
404 |
|
|
.end();
|
405 |
|
|
},
|
406 |
|
|
|
407 |
503b3f7b
|
Assos Assos
|
_destroy: function() {
|
408 |
85ad3d82
|
Assos Assos
|
this.element.removeClass( "ui-buttonset" );
|
409 |
|
|
this.buttons
|
410 |
|
|
.map(function() {
|
411 |
|
|
return $( this ).button( "widget" )[ 0 ];
|
412 |
|
|
})
|
413 |
|
|
.removeClass( "ui-corner-left ui-corner-right" )
|
414 |
|
|
.end()
|
415 |
|
|
.button( "destroy" );
|
416 |
|
|
}
|
417 |
|
|
});
|
418 |
|
|
|
419 |
|
|
}( jQuery ) ); |