|
1 /*! |
|
2 * jQuery UI 1.8.1 |
|
3 * |
|
4 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
5 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
6 * and GPL (GPL-LICENSE.txt) licenses. |
|
7 * |
|
8 * http://docs.jquery.com/UI |
|
9 */ |
|
10 ;jQuery.ui || (function($) { |
|
11 |
|
12 //Helper functions and ui object |
|
13 $.ui = { |
|
14 version: "1.8.1", |
|
15 |
|
16 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
|
17 plugin: { |
|
18 add: function(module, option, set) { |
|
19 var proto = $.ui[module].prototype; |
|
20 for(var i in set) { |
|
21 proto.plugins[i] = proto.plugins[i] || []; |
|
22 proto.plugins[i].push([option, set[i]]); |
|
23 } |
|
24 }, |
|
25 call: function(instance, name, args) { |
|
26 var set = instance.plugins[name]; |
|
27 if(!set || !instance.element[0].parentNode) { return; } |
|
28 |
|
29 for (var i = 0; i < set.length; i++) { |
|
30 if (instance.options[set[i][0]]) { |
|
31 set[i][1].apply(instance.element, args); |
|
32 } |
|
33 } |
|
34 } |
|
35 }, |
|
36 |
|
37 contains: function(a, b) { |
|
38 return document.compareDocumentPosition |
|
39 ? a.compareDocumentPosition(b) & 16 |
|
40 : a !== b && a.contains(b); |
|
41 }, |
|
42 |
|
43 hasScroll: function(el, a) { |
|
44 |
|
45 //If overflow is hidden, the element might have extra content, but the user wants to hide it |
|
46 if ($(el).css('overflow') == 'hidden') { return false; } |
|
47 |
|
48 var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', |
|
49 has = false; |
|
50 |
|
51 if (el[scroll] > 0) { return true; } |
|
52 |
|
53 // TODO: determine which cases actually cause this to happen |
|
54 // if the element doesn't have the scroll set, see if it's possible to |
|
55 // set the scroll |
|
56 el[scroll] = 1; |
|
57 has = (el[scroll] > 0); |
|
58 el[scroll] = 0; |
|
59 return has; |
|
60 }, |
|
61 |
|
62 isOverAxis: function(x, reference, size) { |
|
63 //Determines when x coordinate is over "b" element axis |
|
64 return (x > reference) && (x < (reference + size)); |
|
65 }, |
|
66 |
|
67 isOver: function(y, x, top, left, height, width) { |
|
68 //Determines when x, y coordinates is over "b" element |
|
69 return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); |
|
70 }, |
|
71 |
|
72 keyCode: { |
|
73 ALT: 18, |
|
74 BACKSPACE: 8, |
|
75 CAPS_LOCK: 20, |
|
76 COMMA: 188, |
|
77 CONTROL: 17, |
|
78 DELETE: 46, |
|
79 DOWN: 40, |
|
80 END: 35, |
|
81 ENTER: 13, |
|
82 ESCAPE: 27, |
|
83 HOME: 36, |
|
84 INSERT: 45, |
|
85 LEFT: 37, |
|
86 NUMPAD_ADD: 107, |
|
87 NUMPAD_DECIMAL: 110, |
|
88 NUMPAD_DIVIDE: 111, |
|
89 NUMPAD_ENTER: 108, |
|
90 NUMPAD_MULTIPLY: 106, |
|
91 NUMPAD_SUBTRACT: 109, |
|
92 PAGE_DOWN: 34, |
|
93 PAGE_UP: 33, |
|
94 PERIOD: 190, |
|
95 RIGHT: 39, |
|
96 SHIFT: 16, |
|
97 SPACE: 32, |
|
98 TAB: 9, |
|
99 UP: 38 |
|
100 } |
|
101 }; |
|
102 |
|
103 //jQuery plugins |
|
104 $.fn.extend({ |
|
105 _focus: $.fn.focus, |
|
106 focus: function(delay, fn) { |
|
107 return typeof delay === 'number' |
|
108 ? this.each(function() { |
|
109 var elem = this; |
|
110 setTimeout(function() { |
|
111 $(elem).focus(); |
|
112 (fn && fn.call(elem)); |
|
113 }, delay); |
|
114 }) |
|
115 : this._focus.apply(this, arguments); |
|
116 }, |
|
117 |
|
118 enableSelection: function() { |
|
119 return this |
|
120 .attr('unselectable', 'off') |
|
121 .css('MozUserSelect', ''); |
|
122 }, |
|
123 |
|
124 disableSelection: function() { |
|
125 return this |
|
126 .attr('unselectable', 'on') |
|
127 .css('MozUserSelect', 'none'); |
|
128 }, |
|
129 |
|
130 scrollParent: function() { |
|
131 var scrollParent; |
|
132 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
|
133 scrollParent = this.parents().filter(function() { |
|
134 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
|
135 }).eq(0); |
|
136 } else { |
|
137 scrollParent = this.parents().filter(function() { |
|
138 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
|
139 }).eq(0); |
|
140 } |
|
141 |
|
142 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
|
143 }, |
|
144 |
|
145 zIndex: function(zIndex) { |
|
146 if (zIndex !== undefined) { |
|
147 return this.css('zIndex', zIndex); |
|
148 } |
|
149 |
|
150 if (this.length) { |
|
151 var elem = $(this[0]), position, value; |
|
152 while (elem.length && elem[0] !== document) { |
|
153 // Ignore z-index if position is set to a value where z-index is ignored by the browser |
|
154 // This makes behavior of this function consistent across browsers |
|
155 // WebKit always returns auto if the element is positioned |
|
156 position = elem.css('position'); |
|
157 if (position == 'absolute' || position == 'relative' || position == 'fixed') |
|
158 { |
|
159 // IE returns 0 when zIndex is not specified |
|
160 // other browsers return a string |
|
161 // we ignore the case of nested elements with an explicit value of 0 |
|
162 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> |
|
163 value = parseInt(elem.css('zIndex')); |
|
164 if (!isNaN(value) && value != 0) { |
|
165 return value; |
|
166 } |
|
167 } |
|
168 elem = elem.parent(); |
|
169 } |
|
170 } |
|
171 |
|
172 return 0; |
|
173 } |
|
174 }); |
|
175 |
|
176 |
|
177 //Additional selectors |
|
178 $.extend($.expr[':'], { |
|
179 data: function(elem, i, match) { |
|
180 return !!$.data(elem, match[3]); |
|
181 }, |
|
182 |
|
183 focusable: function(element) { |
|
184 var nodeName = element.nodeName.toLowerCase(), |
|
185 tabIndex = $.attr(element, 'tabindex'); |
|
186 return (/input|select|textarea|button|object/.test(nodeName) |
|
187 ? !element.disabled |
|
188 : 'a' == nodeName || 'area' == nodeName |
|
189 ? element.href || !isNaN(tabIndex) |
|
190 : !isNaN(tabIndex)) |
|
191 // the element and all of its ancestors must be visible |
|
192 // the browser may report that the area is hidden |
|
193 && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; |
|
194 }, |
|
195 |
|
196 tabbable: function(element) { |
|
197 var tabIndex = $.attr(element, 'tabindex'); |
|
198 return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); |
|
199 } |
|
200 }); |
|
201 |
|
202 })(jQuery); |
|
203 /*! |
|
204 * jQuery UI Widget 1.8.1 |
|
205 * |
|
206 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
207 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
208 * and GPL (GPL-LICENSE.txt) licenses. |
|
209 * |
|
210 * http://docs.jquery.com/UI/Widget |
|
211 */ |
|
212 (function( $ ) { |
|
213 |
|
214 var _remove = $.fn.remove; |
|
215 |
|
216 $.fn.remove = function( selector, keepData ) { |
|
217 return this.each(function() { |
|
218 if ( !keepData ) { |
|
219 if ( !selector || $.filter( selector, [ this ] ).length ) { |
|
220 $( "*", this ).add( this ).each(function() { |
|
221 $( this ).triggerHandler( "remove" ); |
|
222 }); |
|
223 } |
|
224 } |
|
225 return _remove.call( $(this), selector, keepData ); |
|
226 }); |
|
227 }; |
|
228 |
|
229 $.widget = function( name, base, prototype ) { |
|
230 var namespace = name.split( "." )[ 0 ], |
|
231 fullName; |
|
232 name = name.split( "." )[ 1 ]; |
|
233 fullName = namespace + "-" + name; |
|
234 |
|
235 if ( !prototype ) { |
|
236 prototype = base; |
|
237 base = $.Widget; |
|
238 } |
|
239 |
|
240 // create selector for plugin |
|
241 $.expr[ ":" ][ fullName ] = function( elem ) { |
|
242 return !!$.data( elem, name ); |
|
243 }; |
|
244 |
|
245 $[ namespace ] = $[ namespace ] || {}; |
|
246 $[ namespace ][ name ] = function( options, element ) { |
|
247 // allow instantiation without initializing for simple inheritance |
|
248 if ( arguments.length ) { |
|
249 this._createWidget( options, element ); |
|
250 } |
|
251 }; |
|
252 |
|
253 var basePrototype = new base(); |
|
254 // we need to make the options hash a property directly on the new instance |
|
255 // otherwise we'll modify the options hash on the prototype that we're |
|
256 // inheriting from |
|
257 // $.each( basePrototype, function( key, val ) { |
|
258 // if ( $.isPlainObject(val) ) { |
|
259 // basePrototype[ key ] = $.extend( {}, val ); |
|
260 // } |
|
261 // }); |
|
262 basePrototype.options = $.extend( {}, basePrototype.options ); |
|
263 $[ namespace ][ name ].prototype = $.extend( true, basePrototype, { |
|
264 namespace: namespace, |
|
265 widgetName: name, |
|
266 widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name, |
|
267 widgetBaseClass: fullName |
|
268 }, prototype ); |
|
269 |
|
270 $.widget.bridge( name, $[ namespace ][ name ] ); |
|
271 }; |
|
272 |
|
273 $.widget.bridge = function( name, object ) { |
|
274 $.fn[ name ] = function( options ) { |
|
275 var isMethodCall = typeof options === "string", |
|
276 args = Array.prototype.slice.call( arguments, 1 ), |
|
277 returnValue = this; |
|
278 |
|
279 // allow multiple hashes to be passed on init |
|
280 options = !isMethodCall && args.length ? |
|
281 $.extend.apply( null, [ true, options ].concat(args) ) : |
|
282 options; |
|
283 |
|
284 // prevent calls to internal methods |
|
285 if ( isMethodCall && options.substring( 0, 1 ) === "_" ) { |
|
286 return returnValue; |
|
287 } |
|
288 |
|
289 if ( isMethodCall ) { |
|
290 this.each(function() { |
|
291 var instance = $.data( this, name ), |
|
292 methodValue = instance && $.isFunction( instance[options] ) ? |
|
293 instance[ options ].apply( instance, args ) : |
|
294 instance; |
|
295 if ( methodValue !== instance && methodValue !== undefined ) { |
|
296 returnValue = methodValue; |
|
297 return false; |
|
298 } |
|
299 }); |
|
300 } else { |
|
301 this.each(function() { |
|
302 var instance = $.data( this, name ); |
|
303 if ( instance ) { |
|
304 if ( options ) { |
|
305 instance.option( options ); |
|
306 } |
|
307 instance._init(); |
|
308 } else { |
|
309 $.data( this, name, new object( options, this ) ); |
|
310 } |
|
311 }); |
|
312 } |
|
313 |
|
314 return returnValue; |
|
315 }; |
|
316 }; |
|
317 |
|
318 $.Widget = function( options, element ) { |
|
319 // allow instantiation without initializing for simple inheritance |
|
320 if ( arguments.length ) { |
|
321 this._createWidget( options, element ); |
|
322 } |
|
323 }; |
|
324 |
|
325 $.Widget.prototype = { |
|
326 widgetName: "widget", |
|
327 widgetEventPrefix: "", |
|
328 options: { |
|
329 disabled: false |
|
330 }, |
|
331 _createWidget: function( options, element ) { |
|
332 // $.widget.bridge stores the plugin instance, but we do it anyway |
|
333 // so that it's stored even before the _create function runs |
|
334 this.element = $( element ).data( this.widgetName, this ); |
|
335 this.options = $.extend( true, {}, |
|
336 this.options, |
|
337 $.metadata && $.metadata.get( element )[ this.widgetName ], |
|
338 options ); |
|
339 |
|
340 var self = this; |
|
341 this.element.bind( "remove." + this.widgetName, function() { |
|
342 self.destroy(); |
|
343 }); |
|
344 |
|
345 this._create(); |
|
346 this._init(); |
|
347 }, |
|
348 _create: function() {}, |
|
349 _init: function() {}, |
|
350 |
|
351 destroy: function() { |
|
352 this.element |
|
353 .unbind( "." + this.widgetName ) |
|
354 .removeData( this.widgetName ); |
|
355 this.widget() |
|
356 .unbind( "." + this.widgetName ) |
|
357 .removeAttr( "aria-disabled" ) |
|
358 .removeClass( |
|
359 this.widgetBaseClass + "-disabled " + |
|
360 "ui-state-disabled" ); |
|
361 }, |
|
362 |
|
363 widget: function() { |
|
364 return this.element; |
|
365 }, |
|
366 |
|
367 option: function( key, value ) { |
|
368 var options = key, |
|
369 self = this; |
|
370 |
|
371 if ( arguments.length === 0 ) { |
|
372 // don't return a reference to the internal hash |
|
373 return $.extend( {}, self.options ); |
|
374 } |
|
375 |
|
376 if (typeof key === "string" ) { |
|
377 if ( value === undefined ) { |
|
378 return this.options[ key ]; |
|
379 } |
|
380 options = {}; |
|
381 options[ key ] = value; |
|
382 } |
|
383 |
|
384 $.each( options, function( key, value ) { |
|
385 self._setOption( key, value ); |
|
386 }); |
|
387 |
|
388 return self; |
|
389 }, |
|
390 _setOption: function( key, value ) { |
|
391 this.options[ key ] = value; |
|
392 |
|
393 if ( key === "disabled" ) { |
|
394 this.widget() |
|
395 [ value ? "addClass" : "removeClass"]( |
|
396 this.widgetBaseClass + "-disabled" + " " + |
|
397 "ui-state-disabled" ) |
|
398 .attr( "aria-disabled", value ); |
|
399 } |
|
400 |
|
401 return this; |
|
402 }, |
|
403 |
|
404 enable: function() { |
|
405 return this._setOption( "disabled", false ); |
|
406 }, |
|
407 disable: function() { |
|
408 return this._setOption( "disabled", true ); |
|
409 }, |
|
410 |
|
411 _trigger: function( type, event, data ) { |
|
412 var callback = this.options[ type ]; |
|
413 |
|
414 event = $.Event( event ); |
|
415 event.type = ( type === this.widgetEventPrefix ? |
|
416 type : |
|
417 this.widgetEventPrefix + type ).toLowerCase(); |
|
418 data = data || {}; |
|
419 |
|
420 // copy original event properties over to the new event |
|
421 // this would happen if we could call $.event.fix instead of $.Event |
|
422 // but we don't have a way to force an event to be fixed multiple times |
|
423 if ( event.originalEvent ) { |
|
424 for ( var i = $.event.props.length, prop; i; ) { |
|
425 prop = $.event.props[ --i ]; |
|
426 event[ prop ] = event.originalEvent[ prop ]; |
|
427 } |
|
428 } |
|
429 |
|
430 this.element.trigger( event, data ); |
|
431 |
|
432 return !( $.isFunction(callback) && |
|
433 callback.call( this.element[0], event, data ) === false || |
|
434 event.isDefaultPrevented() ); |
|
435 } |
|
436 }; |
|
437 |
|
438 })( jQuery ); |
|
439 /*! |
|
440 * jQuery UI Mouse 1.8.1 |
|
441 * |
|
442 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
443 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
444 * and GPL (GPL-LICENSE.txt) licenses. |
|
445 * |
|
446 * http://docs.jquery.com/UI/Mouse |
|
447 * |
|
448 * Depends: |
|
449 * jquery.ui.widget.js |
|
450 */ |
|
451 (function($) { |
|
452 |
|
453 $.widget("ui.mouse", { |
|
454 options: { |
|
455 cancel: ':input,option', |
|
456 distance: 1, |
|
457 delay: 0 |
|
458 }, |
|
459 _mouseInit: function() { |
|
460 var self = this; |
|
461 |
|
462 this.element |
|
463 .bind('mousedown.'+this.widgetName, function(event) { |
|
464 return self._mouseDown(event); |
|
465 }) |
|
466 .bind('click.'+this.widgetName, function(event) { |
|
467 if(self._preventClickEvent) { |
|
468 self._preventClickEvent = false; |
|
469 event.stopImmediatePropagation(); |
|
470 return false; |
|
471 } |
|
472 }); |
|
473 |
|
474 this.started = false; |
|
475 }, |
|
476 |
|
477 // TODO: make sure destroying one instance of mouse doesn't mess with |
|
478 // other instances of mouse |
|
479 _mouseDestroy: function() { |
|
480 this.element.unbind('.'+this.widgetName); |
|
481 }, |
|
482 |
|
483 _mouseDown: function(event) { |
|
484 // don't let more than one widget handle mouseStart |
|
485 // TODO: figure out why we have to use originalEvent |
|
486 event.originalEvent = event.originalEvent || {}; |
|
487 if (event.originalEvent.mouseHandled) { return; } |
|
488 |
|
489 // we may have missed mouseup (out of window) |
|
490 (this._mouseStarted && this._mouseUp(event)); |
|
491 |
|
492 this._mouseDownEvent = event; |
|
493 |
|
494 var self = this, |
|
495 btnIsLeft = (event.which == 1), |
|
496 elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); |
|
497 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { |
|
498 return true; |
|
499 } |
|
500 |
|
501 this.mouseDelayMet = !this.options.delay; |
|
502 if (!this.mouseDelayMet) { |
|
503 this._mouseDelayTimer = setTimeout(function() { |
|
504 self.mouseDelayMet = true; |
|
505 }, this.options.delay); |
|
506 } |
|
507 |
|
508 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
|
509 this._mouseStarted = (this._mouseStart(event) !== false); |
|
510 if (!this._mouseStarted) { |
|
511 event.preventDefault(); |
|
512 return true; |
|
513 } |
|
514 } |
|
515 |
|
516 // these delegates are required to keep context |
|
517 this._mouseMoveDelegate = function(event) { |
|
518 return self._mouseMove(event); |
|
519 }; |
|
520 this._mouseUpDelegate = function(event) { |
|
521 return self._mouseUp(event); |
|
522 }; |
|
523 $(document) |
|
524 .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
|
525 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
|
526 |
|
527 // preventDefault() is used to prevent the selection of text here - |
|
528 // however, in Safari, this causes select boxes not to be selectable |
|
529 // anymore, so this fix is needed |
|
530 ($.browser.safari || event.preventDefault()); |
|
531 |
|
532 event.originalEvent.mouseHandled = true; |
|
533 return true; |
|
534 }, |
|
535 |
|
536 _mouseMove: function(event) { |
|
537 // IE mouseup check - mouseup happened when mouse was out of window |
|
538 if ($.browser.msie && !event.button) { |
|
539 return this._mouseUp(event); |
|
540 } |
|
541 |
|
542 if (this._mouseStarted) { |
|
543 this._mouseDrag(event); |
|
544 return event.preventDefault(); |
|
545 } |
|
546 |
|
547 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
|
548 this._mouseStarted = |
|
549 (this._mouseStart(this._mouseDownEvent, event) !== false); |
|
550 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); |
|
551 } |
|
552 |
|
553 return !this._mouseStarted; |
|
554 }, |
|
555 |
|
556 _mouseUp: function(event) { |
|
557 $(document) |
|
558 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
|
559 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
|
560 |
|
561 if (this._mouseStarted) { |
|
562 this._mouseStarted = false; |
|
563 this._preventClickEvent = (event.target == this._mouseDownEvent.target); |
|
564 this._mouseStop(event); |
|
565 } |
|
566 |
|
567 return false; |
|
568 }, |
|
569 |
|
570 _mouseDistanceMet: function(event) { |
|
571 return (Math.max( |
|
572 Math.abs(this._mouseDownEvent.pageX - event.pageX), |
|
573 Math.abs(this._mouseDownEvent.pageY - event.pageY) |
|
574 ) >= this.options.distance |
|
575 ); |
|
576 }, |
|
577 |
|
578 _mouseDelayMet: function(event) { |
|
579 return this.mouseDelayMet; |
|
580 }, |
|
581 |
|
582 // These are placeholder methods, to be overriden by extending plugin |
|
583 _mouseStart: function(event) {}, |
|
584 _mouseDrag: function(event) {}, |
|
585 _mouseStop: function(event) {}, |
|
586 _mouseCapture: function(event) { return true; } |
|
587 }); |
|
588 |
|
589 })(jQuery); |
|
590 /* |
|
591 * jQuery UI Position 1.8.1 |
|
592 * |
|
593 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
594 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
595 * and GPL (GPL-LICENSE.txt) licenses. |
|
596 * |
|
597 * http://docs.jquery.com/UI/Position |
|
598 */ |
|
599 (function( $ ) { |
|
600 |
|
601 $.ui = $.ui || {}; |
|
602 |
|
603 var horizontalPositions = /left|center|right/, |
|
604 horizontalDefault = "center", |
|
605 verticalPositions = /top|center|bottom/, |
|
606 verticalDefault = "center", |
|
607 _position = $.fn.position, |
|
608 _offset = $.fn.offset; |
|
609 |
|
610 $.fn.position = function( options ) { |
|
611 if ( !options || !options.of ) { |
|
612 return _position.apply( this, arguments ); |
|
613 } |
|
614 |
|
615 // make a copy, we don't want to modify arguments |
|
616 options = $.extend( {}, options ); |
|
617 |
|
618 var target = $( options.of ), |
|
619 collision = ( options.collision || "flip" ).split( " " ), |
|
620 offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ], |
|
621 targetWidth, |
|
622 targetHeight, |
|
623 basePosition; |
|
624 |
|
625 if ( options.of.nodeType === 9 ) { |
|
626 targetWidth = target.width(); |
|
627 targetHeight = target.height(); |
|
628 basePosition = { top: 0, left: 0 }; |
|
629 } else if ( options.of.scrollTo && options.of.document ) { |
|
630 targetWidth = target.width(); |
|
631 targetHeight = target.height(); |
|
632 basePosition = { top: target.scrollTop(), left: target.scrollLeft() }; |
|
633 } else if ( options.of.preventDefault ) { |
|
634 // force left top to allow flipping |
|
635 options.at = "left top"; |
|
636 targetWidth = targetHeight = 0; |
|
637 basePosition = { top: options.of.pageY, left: options.of.pageX }; |
|
638 } else { |
|
639 targetWidth = target.outerWidth(); |
|
640 targetHeight = target.outerHeight(); |
|
641 basePosition = target.offset(); |
|
642 } |
|
643 |
|
644 // force my and at to have valid horizontal and veritcal positions |
|
645 // if a value is missing or invalid, it will be converted to center |
|
646 $.each( [ "my", "at" ], function() { |
|
647 var pos = ( options[this] || "" ).split( " " ); |
|
648 if ( pos.length === 1) { |
|
649 pos = horizontalPositions.test( pos[0] ) ? |
|
650 pos.concat( [verticalDefault] ) : |
|
651 verticalPositions.test( pos[0] ) ? |
|
652 [ horizontalDefault ].concat( pos ) : |
|
653 [ horizontalDefault, verticalDefault ]; |
|
654 } |
|
655 pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : horizontalDefault; |
|
656 pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : verticalDefault; |
|
657 options[ this ] = pos; |
|
658 }); |
|
659 |
|
660 // normalize collision option |
|
661 if ( collision.length === 1 ) { |
|
662 collision[ 1 ] = collision[ 0 ]; |
|
663 } |
|
664 |
|
665 // normalize offset option |
|
666 offset[ 0 ] = parseInt( offset[0], 10 ) || 0; |
|
667 if ( offset.length === 1 ) { |
|
668 offset[ 1 ] = offset[ 0 ]; |
|
669 } |
|
670 offset[ 1 ] = parseInt( offset[1], 10 ) || 0; |
|
671 |
|
672 if ( options.at[0] === "right" ) { |
|
673 basePosition.left += targetWidth; |
|
674 } else if (options.at[0] === horizontalDefault ) { |
|
675 basePosition.left += targetWidth / 2; |
|
676 } |
|
677 |
|
678 if ( options.at[1] === "bottom" ) { |
|
679 basePosition.top += targetHeight; |
|
680 } else if ( options.at[1] === verticalDefault ) { |
|
681 basePosition.top += targetHeight / 2; |
|
682 } |
|
683 |
|
684 basePosition.left += offset[ 0 ]; |
|
685 basePosition.top += offset[ 1 ]; |
|
686 |
|
687 return this.each(function() { |
|
688 var elem = $( this ), |
|
689 elemWidth = elem.outerWidth(), |
|
690 elemHeight = elem.outerHeight(), |
|
691 position = $.extend( {}, basePosition ); |
|
692 |
|
693 if ( options.my[0] === "right" ) { |
|
694 position.left -= elemWidth; |
|
695 } else if ( options.my[0] === horizontalDefault ) { |
|
696 position.left -= elemWidth / 2; |
|
697 } |
|
698 |
|
699 if ( options.my[1] === "bottom" ) { |
|
700 position.top -= elemHeight; |
|
701 } else if ( options.my[1] === verticalDefault ) { |
|
702 position.top -= elemHeight / 2; |
|
703 } |
|
704 |
|
705 // prevent fractions (see #5280) |
|
706 position.left = parseInt( position.left ); |
|
707 position.top = parseInt( position.top ); |
|
708 |
|
709 $.each( [ "left", "top" ], function( i, dir ) { |
|
710 if ( $.ui.position[ collision[i] ] ) { |
|
711 $.ui.position[ collision[i] ][ dir ]( position, { |
|
712 targetWidth: targetWidth, |
|
713 targetHeight: targetHeight, |
|
714 elemWidth: elemWidth, |
|
715 elemHeight: elemHeight, |
|
716 offset: offset, |
|
717 my: options.my, |
|
718 at: options.at |
|
719 }); |
|
720 } |
|
721 }); |
|
722 |
|
723 if ( $.fn.bgiframe ) { |
|
724 elem.bgiframe(); |
|
725 } |
|
726 elem.offset( $.extend( position, { using: options.using } ) ); |
|
727 }); |
|
728 }; |
|
729 |
|
730 $.ui.position = { |
|
731 fit: { |
|
732 left: function( position, data ) { |
|
733 var win = $( window ), |
|
734 over = position.left + data.elemWidth - win.width() - win.scrollLeft(); |
|
735 position.left = over > 0 ? position.left - over : Math.max( 0, position.left ); |
|
736 }, |
|
737 top: function( position, data ) { |
|
738 var win = $( window ), |
|
739 over = position.top + data.elemHeight - win.height() - win.scrollTop(); |
|
740 position.top = over > 0 ? position.top - over : Math.max( 0, position.top ); |
|
741 } |
|
742 }, |
|
743 |
|
744 flip: { |
|
745 left: function( position, data ) { |
|
746 if ( data.at[0] === "center" ) { |
|
747 return; |
|
748 } |
|
749 var win = $( window ), |
|
750 over = position.left + data.elemWidth - win.width() - win.scrollLeft(), |
|
751 myOffset = data.my[ 0 ] === "left" ? |
|
752 -data.elemWidth : |
|
753 data.my[ 0 ] === "right" ? |
|
754 data.elemWidth : |
|
755 0, |
|
756 offset = -2 * data.offset[ 0 ]; |
|
757 position.left += position.left < 0 ? |
|
758 myOffset + data.targetWidth + offset : |
|
759 over > 0 ? |
|
760 myOffset - data.targetWidth + offset : |
|
761 0; |
|
762 }, |
|
763 top: function( position, data ) { |
|
764 if ( data.at[1] === "center" ) { |
|
765 return; |
|
766 } |
|
767 var win = $( window ), |
|
768 over = position.top + data.elemHeight - win.height() - win.scrollTop(), |
|
769 myOffset = data.my[ 1 ] === "top" ? |
|
770 -data.elemHeight : |
|
771 data.my[ 1 ] === "bottom" ? |
|
772 data.elemHeight : |
|
773 0, |
|
774 atOffset = data.at[ 1 ] === "top" ? |
|
775 data.targetHeight : |
|
776 -data.targetHeight, |
|
777 offset = -2 * data.offset[ 1 ]; |
|
778 position.top += position.top < 0 ? |
|
779 myOffset + data.targetHeight + offset : |
|
780 over > 0 ? |
|
781 myOffset + atOffset + offset : |
|
782 0; |
|
783 } |
|
784 } |
|
785 }; |
|
786 |
|
787 // offset setter from jQuery 1.4 |
|
788 if ( !$.offset.setOffset ) { |
|
789 $.offset.setOffset = function( elem, options ) { |
|
790 // set position first, in-case top/left are set even on static elem |
|
791 if ( /static/.test( $.curCSS( elem, "position" ) ) ) { |
|
792 elem.style.position = "relative"; |
|
793 } |
|
794 var curElem = $( elem ), |
|
795 curOffset = curElem.offset(), |
|
796 curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0, |
|
797 curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0, |
|
798 props = { |
|
799 top: (options.top - curOffset.top) + curTop, |
|
800 left: (options.left - curOffset.left) + curLeft |
|
801 }; |
|
802 |
|
803 if ( 'using' in options ) { |
|
804 options.using.call( elem, props ); |
|
805 } else { |
|
806 curElem.css( props ); |
|
807 } |
|
808 }; |
|
809 |
|
810 $.fn.offset = function( options ) { |
|
811 var elem = this[ 0 ]; |
|
812 if ( !elem || !elem.ownerDocument ) { return null; } |
|
813 if ( options ) { |
|
814 return this.each(function() { |
|
815 $.offset.setOffset( this, options ); |
|
816 }); |
|
817 } |
|
818 return _offset.call( this ); |
|
819 }; |
|
820 } |
|
821 |
|
822 }( jQuery )); |
|
823 /* |
|
824 * jQuery UI Draggable 1.8.1 |
|
825 * |
|
826 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
827 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
828 * and GPL (GPL-LICENSE.txt) licenses. |
|
829 * |
|
830 * http://docs.jquery.com/UI/Draggables |
|
831 * |
|
832 * Depends: |
|
833 * jquery.ui.core.js |
|
834 * jquery.ui.mouse.js |
|
835 * jquery.ui.widget.js |
|
836 */ |
|
837 (function($) { |
|
838 |
|
839 $.widget("ui.draggable", $.ui.mouse, { |
|
840 widgetEventPrefix: "drag", |
|
841 options: { |
|
842 addClasses: true, |
|
843 appendTo: "parent", |
|
844 axis: false, |
|
845 connectToSortable: false, |
|
846 containment: false, |
|
847 cursor: "auto", |
|
848 cursorAt: false, |
|
849 grid: false, |
|
850 handle: false, |
|
851 helper: "original", |
|
852 iframeFix: false, |
|
853 opacity: false, |
|
854 refreshPositions: false, |
|
855 revert: false, |
|
856 revertDuration: 500, |
|
857 scope: "default", |
|
858 scroll: true, |
|
859 scrollSensitivity: 20, |
|
860 scrollSpeed: 20, |
|
861 snap: false, |
|
862 snapMode: "both", |
|
863 snapTolerance: 20, |
|
864 stack: false, |
|
865 zIndex: false |
|
866 }, |
|
867 _create: function() { |
|
868 |
|
869 if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) |
|
870 this.element[0].style.position = 'relative'; |
|
871 |
|
872 (this.options.addClasses && this.element.addClass("ui-draggable")); |
|
873 (this.options.disabled && this.element.addClass("ui-draggable-disabled")); |
|
874 |
|
875 this._mouseInit(); |
|
876 |
|
877 }, |
|
878 |
|
879 destroy: function() { |
|
880 if(!this.element.data('draggable')) return; |
|
881 this.element |
|
882 .removeData("draggable") |
|
883 .unbind(".draggable") |
|
884 .removeClass("ui-draggable" |
|
885 + " ui-draggable-dragging" |
|
886 + " ui-draggable-disabled"); |
|
887 this._mouseDestroy(); |
|
888 |
|
889 return this; |
|
890 }, |
|
891 |
|
892 _mouseCapture: function(event) { |
|
893 |
|
894 var o = this.options; |
|
895 |
|
896 // among others, prevent a drag on a resizable-handle |
|
897 if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) |
|
898 return false; |
|
899 |
|
900 //Quit if we're not on a valid handle |
|
901 this.handle = this._getHandle(event); |
|
902 if (!this.handle) |
|
903 return false; |
|
904 |
|
905 return true; |
|
906 |
|
907 }, |
|
908 |
|
909 _mouseStart: function(event) { |
|
910 |
|
911 var o = this.options; |
|
912 |
|
913 //Create and append the visible helper |
|
914 this.helper = this._createHelper(event); |
|
915 |
|
916 //Cache the helper size |
|
917 this._cacheHelperProportions(); |
|
918 |
|
919 //If ddmanager is used for droppables, set the global draggable |
|
920 if($.ui.ddmanager) |
|
921 $.ui.ddmanager.current = this; |
|
922 |
|
923 /* |
|
924 * - Position generation - |
|
925 * This block generates everything position related - it's the core of draggables. |
|
926 */ |
|
927 |
|
928 //Cache the margins of the original element |
|
929 this._cacheMargins(); |
|
930 |
|
931 //Store the helper's css position |
|
932 this.cssPosition = this.helper.css("position"); |
|
933 this.scrollParent = this.helper.scrollParent(); |
|
934 |
|
935 //The element's absolute position on the page minus margins |
|
936 this.offset = this.positionAbs = this.element.offset(); |
|
937 this.offset = { |
|
938 top: this.offset.top - this.margins.top, |
|
939 left: this.offset.left - this.margins.left |
|
940 }; |
|
941 |
|
942 $.extend(this.offset, { |
|
943 click: { //Where the click happened, relative to the element |
|
944 left: event.pageX - this.offset.left, |
|
945 top: event.pageY - this.offset.top |
|
946 }, |
|
947 parent: this._getParentOffset(), |
|
948 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
949 }); |
|
950 |
|
951 //Generate the original position |
|
952 this.originalPosition = this.position = this._generatePosition(event); |
|
953 this.originalPageX = event.pageX; |
|
954 this.originalPageY = event.pageY; |
|
955 |
|
956 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
|
957 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
958 |
|
959 //Set a containment if given in the options |
|
960 if(o.containment) |
|
961 this._setContainment(); |
|
962 |
|
963 //Trigger event + callbacks |
|
964 if(this._trigger("start", event) === false) { |
|
965 this._clear(); |
|
966 return false; |
|
967 } |
|
968 |
|
969 //Recache the helper size |
|
970 this._cacheHelperProportions(); |
|
971 |
|
972 //Prepare the droppable offsets |
|
973 if ($.ui.ddmanager && !o.dropBehaviour) |
|
974 $.ui.ddmanager.prepareOffsets(this, event); |
|
975 |
|
976 this.helper.addClass("ui-draggable-dragging"); |
|
977 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
978 return true; |
|
979 }, |
|
980 |
|
981 _mouseDrag: function(event, noPropagation) { |
|
982 |
|
983 //Compute the helpers position |
|
984 this.position = this._generatePosition(event); |
|
985 this.positionAbs = this._convertPositionTo("absolute"); |
|
986 |
|
987 //Call plugins and callbacks and use the resulting position if something is returned |
|
988 if (!noPropagation) { |
|
989 var ui = this._uiHash(); |
|
990 if(this._trigger('drag', event, ui) === false) { |
|
991 this._mouseUp({}); |
|
992 return false; |
|
993 } |
|
994 this.position = ui.position; |
|
995 } |
|
996 |
|
997 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
|
998 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
|
999 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
|
1000 |
|
1001 return false; |
|
1002 }, |
|
1003 |
|
1004 _mouseStop: function(event) { |
|
1005 |
|
1006 //If we are using droppables, inform the manager about the drop |
|
1007 var dropped = false; |
|
1008 if ($.ui.ddmanager && !this.options.dropBehaviour) |
|
1009 dropped = $.ui.ddmanager.drop(this, event); |
|
1010 |
|
1011 //if a drop comes from outside (a sortable) |
|
1012 if(this.dropped) { |
|
1013 dropped = this.dropped; |
|
1014 this.dropped = false; |
|
1015 } |
|
1016 |
|
1017 //if the original element is removed, don't bother to continue |
|
1018 if(!this.element[0] || !this.element[0].parentNode) |
|
1019 return false; |
|
1020 |
|
1021 if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
1022 var self = this; |
|
1023 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
|
1024 if(self._trigger("stop", event) !== false) { |
|
1025 self._clear(); |
|
1026 } |
|
1027 }); |
|
1028 } else { |
|
1029 if(this._trigger("stop", event) !== false) { |
|
1030 this._clear(); |
|
1031 } |
|
1032 } |
|
1033 |
|
1034 return false; |
|
1035 }, |
|
1036 |
|
1037 cancel: function() { |
|
1038 |
|
1039 if(this.helper.is(".ui-draggable-dragging")) { |
|
1040 this._mouseUp({}); |
|
1041 } else { |
|
1042 this._clear(); |
|
1043 } |
|
1044 |
|
1045 return this; |
|
1046 |
|
1047 }, |
|
1048 |
|
1049 _getHandle: function(event) { |
|
1050 |
|
1051 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; |
|
1052 $(this.options.handle, this.element) |
|
1053 .find("*") |
|
1054 .andSelf() |
|
1055 .each(function() { |
|
1056 if(this == event.target) handle = true; |
|
1057 }); |
|
1058 |
|
1059 return handle; |
|
1060 |
|
1061 }, |
|
1062 |
|
1063 _createHelper: function(event) { |
|
1064 |
|
1065 var o = this.options; |
|
1066 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); |
|
1067 |
|
1068 if(!helper.parents('body').length) |
|
1069 helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); |
|
1070 |
|
1071 if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) |
|
1072 helper.css("position", "absolute"); |
|
1073 |
|
1074 return helper; |
|
1075 |
|
1076 }, |
|
1077 |
|
1078 _adjustOffsetFromHelper: function(obj) { |
|
1079 if (typeof obj == 'string') { |
|
1080 obj = obj.split(' '); |
|
1081 } |
|
1082 if ($.isArray(obj)) { |
|
1083 obj = {left: +obj[0], top: +obj[1] || 0}; |
|
1084 } |
|
1085 if ('left' in obj) { |
|
1086 this.offset.click.left = obj.left + this.margins.left; |
|
1087 } |
|
1088 if ('right' in obj) { |
|
1089 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
1090 } |
|
1091 if ('top' in obj) { |
|
1092 this.offset.click.top = obj.top + this.margins.top; |
|
1093 } |
|
1094 if ('bottom' in obj) { |
|
1095 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
1096 } |
|
1097 }, |
|
1098 |
|
1099 _getParentOffset: function() { |
|
1100 |
|
1101 //Get the offsetParent and cache its position |
|
1102 this.offsetParent = this.helper.offsetParent(); |
|
1103 var po = this.offsetParent.offset(); |
|
1104 |
|
1105 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
1106 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
1107 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
1108 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
1109 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
1110 po.left += this.scrollParent.scrollLeft(); |
|
1111 po.top += this.scrollParent.scrollTop(); |
|
1112 } |
|
1113 |
|
1114 if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
1115 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
|
1116 po = { top: 0, left: 0 }; |
|
1117 |
|
1118 return { |
|
1119 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
1120 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
1121 }; |
|
1122 |
|
1123 }, |
|
1124 |
|
1125 _getRelativeOffset: function() { |
|
1126 |
|
1127 if(this.cssPosition == "relative") { |
|
1128 var p = this.element.position(); |
|
1129 return { |
|
1130 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
1131 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
1132 }; |
|
1133 } else { |
|
1134 return { top: 0, left: 0 }; |
|
1135 } |
|
1136 |
|
1137 }, |
|
1138 |
|
1139 _cacheMargins: function() { |
|
1140 this.margins = { |
|
1141 left: (parseInt(this.element.css("marginLeft"),10) || 0), |
|
1142 top: (parseInt(this.element.css("marginTop"),10) || 0) |
|
1143 }; |
|
1144 }, |
|
1145 |
|
1146 _cacheHelperProportions: function() { |
|
1147 this.helperProportions = { |
|
1148 width: this.helper.outerWidth(), |
|
1149 height: this.helper.outerHeight() |
|
1150 }; |
|
1151 }, |
|
1152 |
|
1153 _setContainment: function() { |
|
1154 |
|
1155 var o = this.options; |
|
1156 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|
1157 if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
|
1158 0 - this.offset.relative.left - this.offset.parent.left, |
|
1159 0 - this.offset.relative.top - this.offset.parent.top, |
|
1160 $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
1161 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
1162 ]; |
|
1163 |
|
1164 if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { |
|
1165 var ce = $(o.containment)[0]; if(!ce) return; |
|
1166 var co = $(o.containment).offset(); |
|
1167 var over = ($(ce).css("overflow") != 'hidden'); |
|
1168 |
|
1169 this.containment = [ |
|
1170 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
1171 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
1172 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
1173 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
1174 ]; |
|
1175 } else if(o.containment.constructor == Array) { |
|
1176 this.containment = o.containment; |
|
1177 } |
|
1178 |
|
1179 }, |
|
1180 |
|
1181 _convertPositionTo: function(d, pos) { |
|
1182 |
|
1183 if(!pos) pos = this.position; |
|
1184 var mod = d == "absolute" ? 1 : -1; |
|
1185 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
1186 |
|
1187 return { |
|
1188 top: ( |
|
1189 pos.top // The absolute mouse position |
|
1190 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1191 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
|
1192 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) |
|
1193 ), |
|
1194 left: ( |
|
1195 pos.left // The absolute mouse position |
|
1196 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1197 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
|
1198 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) |
|
1199 ) |
|
1200 }; |
|
1201 |
|
1202 }, |
|
1203 |
|
1204 _generatePosition: function(event) { |
|
1205 |
|
1206 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
1207 var pageX = event.pageX; |
|
1208 var pageY = event.pageY; |
|
1209 |
|
1210 /* |
|
1211 * - Position constraining - |
|
1212 * Constrain the position to a mix of grid, containment. |
|
1213 */ |
|
1214 |
|
1215 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
1216 |
|
1217 if(this.containment) { |
|
1218 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
|
1219 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
|
1220 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
|
1221 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
|
1222 } |
|
1223 |
|
1224 if(o.grid) { |
|
1225 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
1226 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
1227 |
|
1228 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
1229 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
1230 } |
|
1231 |
|
1232 } |
|
1233 |
|
1234 return { |
|
1235 top: ( |
|
1236 pageY // The absolute mouse position |
|
1237 - this.offset.click.top // Click offset (relative to the element) |
|
1238 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1239 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
|
1240 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) |
|
1241 ), |
|
1242 left: ( |
|
1243 pageX // The absolute mouse position |
|
1244 - this.offset.click.left // Click offset (relative to the element) |
|
1245 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1246 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
|
1247 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) |
|
1248 ) |
|
1249 }; |
|
1250 |
|
1251 }, |
|
1252 |
|
1253 _clear: function() { |
|
1254 this.helper.removeClass("ui-draggable-dragging"); |
|
1255 if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); |
|
1256 //if($.ui.ddmanager) $.ui.ddmanager.current = null; |
|
1257 this.helper = null; |
|
1258 this.cancelHelperRemoval = false; |
|
1259 }, |
|
1260 |
|
1261 // From now on bulk stuff - mainly helpers |
|
1262 |
|
1263 _trigger: function(type, event, ui) { |
|
1264 ui = ui || this._uiHash(); |
|
1265 $.ui.plugin.call(this, type, [event, ui]); |
|
1266 if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins |
|
1267 return $.Widget.prototype._trigger.call(this, type, event, ui); |
|
1268 }, |
|
1269 |
|
1270 plugins: {}, |
|
1271 |
|
1272 _uiHash: function(event) { |
|
1273 return { |
|
1274 helper: this.helper, |
|
1275 position: this.position, |
|
1276 originalPosition: this.originalPosition, |
|
1277 offset: this.positionAbs |
|
1278 }; |
|
1279 } |
|
1280 |
|
1281 }); |
|
1282 |
|
1283 $.extend($.ui.draggable, { |
|
1284 version: "1.8.1" |
|
1285 }); |
|
1286 |
|
1287 $.ui.plugin.add("draggable", "connectToSortable", { |
|
1288 start: function(event, ui) { |
|
1289 |
|
1290 var inst = $(this).data("draggable"), o = inst.options, |
|
1291 uiSortable = $.extend({}, ui, { item: inst.element }); |
|
1292 inst.sortables = []; |
|
1293 $(o.connectToSortable).each(function() { |
|
1294 var sortable = $.data(this, 'sortable'); |
|
1295 if (sortable && !sortable.options.disabled) { |
|
1296 inst.sortables.push({ |
|
1297 instance: sortable, |
|
1298 shouldRevert: sortable.options.revert |
|
1299 }); |
|
1300 sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache |
|
1301 sortable._trigger("activate", event, uiSortable); |
|
1302 } |
|
1303 }); |
|
1304 |
|
1305 }, |
|
1306 stop: function(event, ui) { |
|
1307 |
|
1308 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
|
1309 var inst = $(this).data("draggable"), |
|
1310 uiSortable = $.extend({}, ui, { item: inst.element }); |
|
1311 |
|
1312 $.each(inst.sortables, function() { |
|
1313 if(this.instance.isOver) { |
|
1314 |
|
1315 this.instance.isOver = 0; |
|
1316 |
|
1317 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
|
1318 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
|
1319 |
|
1320 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' |
|
1321 if(this.shouldRevert) this.instance.options.revert = true; |
|
1322 |
|
1323 //Trigger the stop of the sortable |
|
1324 this.instance._mouseStop(event); |
|
1325 |
|
1326 this.instance.options.helper = this.instance.options._helper; |
|
1327 |
|
1328 //If the helper has been the original item, restore properties in the sortable |
|
1329 if(inst.options.helper == 'original') |
|
1330 this.instance.currentItem.css({ top: 'auto', left: 'auto' }); |
|
1331 |
|
1332 } else { |
|
1333 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
|
1334 this.instance._trigger("deactivate", event, uiSortable); |
|
1335 } |
|
1336 |
|
1337 }); |
|
1338 |
|
1339 }, |
|
1340 drag: function(event, ui) { |
|
1341 |
|
1342 var inst = $(this).data("draggable"), self = this; |
|
1343 |
|
1344 var checkPos = function(o) { |
|
1345 var dyClick = this.offset.click.top, dxClick = this.offset.click.left; |
|
1346 var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; |
|
1347 var itemHeight = o.height, itemWidth = o.width; |
|
1348 var itemTop = o.top, itemLeft = o.left; |
|
1349 |
|
1350 return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); |
|
1351 }; |
|
1352 |
|
1353 $.each(inst.sortables, function(i) { |
|
1354 |
|
1355 //Copy over some variables to allow calling the sortable's native _intersectsWith |
|
1356 this.instance.positionAbs = inst.positionAbs; |
|
1357 this.instance.helperProportions = inst.helperProportions; |
|
1358 this.instance.offset.click = inst.offset.click; |
|
1359 |
|
1360 if(this.instance._intersectsWith(this.instance.containerCache)) { |
|
1361 |
|
1362 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
|
1363 if(!this.instance.isOver) { |
|
1364 |
|
1365 this.instance.isOver = 1; |
|
1366 //Now we fake the start of dragging for the sortable instance, |
|
1367 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
|
1368 //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) |
|
1369 this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); |
|
1370 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
|
1371 this.instance.options.helper = function() { return ui.helper[0]; }; |
|
1372 |
|
1373 event.target = this.instance.currentItem[0]; |
|
1374 this.instance._mouseCapture(event, true); |
|
1375 this.instance._mouseStart(event, true, true); |
|
1376 |
|
1377 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes |
|
1378 this.instance.offset.click.top = inst.offset.click.top; |
|
1379 this.instance.offset.click.left = inst.offset.click.left; |
|
1380 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; |
|
1381 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; |
|
1382 |
|
1383 inst._trigger("toSortable", event); |
|
1384 inst.dropped = this.instance.element; //draggable revert needs that |
|
1385 //hack so receive/update callbacks work (mostly) |
|
1386 inst.currentItem = inst.element; |
|
1387 this.instance.fromOutside = inst; |
|
1388 |
|
1389 } |
|
1390 |
|
1391 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable |
|
1392 if(this.instance.currentItem) this.instance._mouseDrag(event); |
|
1393 |
|
1394 } else { |
|
1395 |
|
1396 //If it doesn't intersect with the sortable, and it intersected before, |
|
1397 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval |
|
1398 if(this.instance.isOver) { |
|
1399 |
|
1400 this.instance.isOver = 0; |
|
1401 this.instance.cancelHelperRemoval = true; |
|
1402 |
|
1403 //Prevent reverting on this forced stop |
|
1404 this.instance.options.revert = false; |
|
1405 |
|
1406 // The out event needs to be triggered independently |
|
1407 this.instance._trigger('out', event, this.instance._uiHash(this.instance)); |
|
1408 |
|
1409 this.instance._mouseStop(event, true); |
|
1410 this.instance.options.helper = this.instance.options._helper; |
|
1411 |
|
1412 //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
|
1413 this.instance.currentItem.remove(); |
|
1414 if(this.instance.placeholder) this.instance.placeholder.remove(); |
|
1415 |
|
1416 inst._trigger("fromSortable", event); |
|
1417 inst.dropped = false; //draggable revert needs that |
|
1418 } |
|
1419 |
|
1420 }; |
|
1421 |
|
1422 }); |
|
1423 |
|
1424 } |
|
1425 }); |
|
1426 |
|
1427 $.ui.plugin.add("draggable", "cursor", { |
|
1428 start: function(event, ui) { |
|
1429 var t = $('body'), o = $(this).data('draggable').options; |
|
1430 if (t.css("cursor")) o._cursor = t.css("cursor"); |
|
1431 t.css("cursor", o.cursor); |
|
1432 }, |
|
1433 stop: function(event, ui) { |
|
1434 var o = $(this).data('draggable').options; |
|
1435 if (o._cursor) $('body').css("cursor", o._cursor); |
|
1436 } |
|
1437 }); |
|
1438 |
|
1439 $.ui.plugin.add("draggable", "iframeFix", { |
|
1440 start: function(event, ui) { |
|
1441 var o = $(this).data('draggable').options; |
|
1442 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
|
1443 $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>') |
|
1444 .css({ |
|
1445 width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
|
1446 position: "absolute", opacity: "0.001", zIndex: 1000 |
|
1447 }) |
|
1448 .css($(this).offset()) |
|
1449 .appendTo("body"); |
|
1450 }); |
|
1451 }, |
|
1452 stop: function(event, ui) { |
|
1453 $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers |
|
1454 } |
|
1455 }); |
|
1456 |
|
1457 $.ui.plugin.add("draggable", "opacity", { |
|
1458 start: function(event, ui) { |
|
1459 var t = $(ui.helper), o = $(this).data('draggable').options; |
|
1460 if(t.css("opacity")) o._opacity = t.css("opacity"); |
|
1461 t.css('opacity', o.opacity); |
|
1462 }, |
|
1463 stop: function(event, ui) { |
|
1464 var o = $(this).data('draggable').options; |
|
1465 if(o._opacity) $(ui.helper).css('opacity', o._opacity); |
|
1466 } |
|
1467 }); |
|
1468 |
|
1469 $.ui.plugin.add("draggable", "scroll", { |
|
1470 start: function(event, ui) { |
|
1471 var i = $(this).data("draggable"); |
|
1472 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); |
|
1473 }, |
|
1474 drag: function(event, ui) { |
|
1475 |
|
1476 var i = $(this).data("draggable"), o = i.options, scrolled = false; |
|
1477 |
|
1478 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { |
|
1479 |
|
1480 if(!o.axis || o.axis != 'x') { |
|
1481 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
|
1482 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
|
1483 else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) |
|
1484 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
|
1485 } |
|
1486 |
|
1487 if(!o.axis || o.axis != 'y') { |
|
1488 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
|
1489 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
1490 else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) |
|
1491 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
1492 } |
|
1493 |
|
1494 } else { |
|
1495 |
|
1496 if(!o.axis || o.axis != 'x') { |
|
1497 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
|
1498 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
1499 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
|
1500 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
1501 } |
|
1502 |
|
1503 if(!o.axis || o.axis != 'y') { |
|
1504 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
|
1505 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
1506 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
|
1507 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
1508 } |
|
1509 |
|
1510 } |
|
1511 |
|
1512 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
|
1513 $.ui.ddmanager.prepareOffsets(i, event); |
|
1514 |
|
1515 } |
|
1516 }); |
|
1517 |
|
1518 $.ui.plugin.add("draggable", "snap", { |
|
1519 start: function(event, ui) { |
|
1520 |
|
1521 var i = $(this).data("draggable"), o = i.options; |
|
1522 i.snapElements = []; |
|
1523 |
|
1524 $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { |
|
1525 var $t = $(this); var $o = $t.offset(); |
|
1526 if(this != i.element[0]) i.snapElements.push({ |
|
1527 item: this, |
|
1528 width: $t.outerWidth(), height: $t.outerHeight(), |
|
1529 top: $o.top, left: $o.left |
|
1530 }); |
|
1531 }); |
|
1532 |
|
1533 }, |
|
1534 drag: function(event, ui) { |
|
1535 |
|
1536 var inst = $(this).data("draggable"), o = inst.options; |
|
1537 var d = o.snapTolerance; |
|
1538 |
|
1539 var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
|
1540 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; |
|
1541 |
|
1542 for (var i = inst.snapElements.length - 1; i >= 0; i--){ |
|
1543 |
|
1544 var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, |
|
1545 t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; |
|
1546 |
|
1547 //Yes, I know, this is insane ;) |
|
1548 if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { |
|
1549 if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1550 inst.snapElements[i].snapping = false; |
|
1551 continue; |
|
1552 } |
|
1553 |
|
1554 if(o.snapMode != 'inner') { |
|
1555 var ts = Math.abs(t - y2) <= d; |
|
1556 var bs = Math.abs(b - y1) <= d; |
|
1557 var ls = Math.abs(l - x2) <= d; |
|
1558 var rs = Math.abs(r - x1) <= d; |
|
1559 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1560 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
|
1561 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
|
1562 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
|
1563 } |
|
1564 |
|
1565 var first = (ts || bs || ls || rs); |
|
1566 |
|
1567 if(o.snapMode != 'outer') { |
|
1568 var ts = Math.abs(t - y1) <= d; |
|
1569 var bs = Math.abs(b - y2) <= d; |
|
1570 var ls = Math.abs(l - x1) <= d; |
|
1571 var rs = Math.abs(r - x2) <= d; |
|
1572 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
|
1573 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1574 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
|
1575 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
|
1576 } |
|
1577 |
|
1578 if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) |
|
1579 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1580 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
|
1581 |
|
1582 }; |
|
1583 |
|
1584 } |
|
1585 }); |
|
1586 |
|
1587 $.ui.plugin.add("draggable", "stack", { |
|
1588 start: function(event, ui) { |
|
1589 |
|
1590 var o = $(this).data("draggable").options; |
|
1591 |
|
1592 var group = $.makeArray($(o.stack)).sort(function(a,b) { |
|
1593 return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); |
|
1594 }); |
|
1595 if (!group.length) { return; } |
|
1596 |
|
1597 var min = parseInt(group[0].style.zIndex) || 0; |
|
1598 $(group).each(function(i) { |
|
1599 this.style.zIndex = min + i; |
|
1600 }); |
|
1601 |
|
1602 this[0].style.zIndex = min + group.length; |
|
1603 |
|
1604 } |
|
1605 }); |
|
1606 |
|
1607 $.ui.plugin.add("draggable", "zIndex", { |
|
1608 start: function(event, ui) { |
|
1609 var t = $(ui.helper), o = $(this).data("draggable").options; |
|
1610 if(t.css("zIndex")) o._zIndex = t.css("zIndex"); |
|
1611 t.css('zIndex', o.zIndex); |
|
1612 }, |
|
1613 stop: function(event, ui) { |
|
1614 var o = $(this).data("draggable").options; |
|
1615 if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); |
|
1616 } |
|
1617 }); |
|
1618 |
|
1619 })(jQuery); |
|
1620 /* |
|
1621 * jQuery UI Droppable 1.8.1 |
|
1622 * |
|
1623 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
1624 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
1625 * and GPL (GPL-LICENSE.txt) licenses. |
|
1626 * |
|
1627 * http://docs.jquery.com/UI/Droppables |
|
1628 * |
|
1629 * Depends: |
|
1630 * jquery.ui.core.js |
|
1631 * jquery.ui.widget.js |
|
1632 * jquery.ui.mouse.js |
|
1633 * jquery.ui.draggable.js |
|
1634 */ |
|
1635 (function($) { |
|
1636 |
|
1637 $.widget("ui.droppable", { |
|
1638 widgetEventPrefix: "drop", |
|
1639 options: { |
|
1640 accept: '*', |
|
1641 activeClass: false, |
|
1642 addClasses: true, |
|
1643 greedy: false, |
|
1644 hoverClass: false, |
|
1645 scope: 'default', |
|
1646 tolerance: 'intersect' |
|
1647 }, |
|
1648 _create: function() { |
|
1649 |
|
1650 var o = this.options, accept = o.accept; |
|
1651 this.isover = 0; this.isout = 1; |
|
1652 |
|
1653 this.accept = $.isFunction(accept) ? accept : function(d) { |
|
1654 return d.is(accept); |
|
1655 }; |
|
1656 |
|
1657 //Store the droppable's proportions |
|
1658 this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; |
|
1659 |
|
1660 // Add the reference and positions to the manager |
|
1661 $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || []; |
|
1662 $.ui.ddmanager.droppables[o.scope].push(this); |
|
1663 |
|
1664 (o.addClasses && this.element.addClass("ui-droppable")); |
|
1665 |
|
1666 }, |
|
1667 |
|
1668 destroy: function() { |
|
1669 var drop = $.ui.ddmanager.droppables[this.options.scope]; |
|
1670 for ( var i = 0; i < drop.length; i++ ) |
|
1671 if ( drop[i] == this ) |
|
1672 drop.splice(i, 1); |
|
1673 |
|
1674 this.element |
|
1675 .removeClass("ui-droppable ui-droppable-disabled") |
|
1676 .removeData("droppable") |
|
1677 .unbind(".droppable"); |
|
1678 |
|
1679 return this; |
|
1680 }, |
|
1681 |
|
1682 _setOption: function(key, value) { |
|
1683 |
|
1684 if(key == 'accept') { |
|
1685 this.accept = $.isFunction(value) ? value : function(d) { |
|
1686 return d.is(value); |
|
1687 }; |
|
1688 } |
|
1689 $.Widget.prototype._setOption.apply(this, arguments); |
|
1690 }, |
|
1691 |
|
1692 _activate: function(event) { |
|
1693 var draggable = $.ui.ddmanager.current; |
|
1694 if(this.options.activeClass) this.element.addClass(this.options.activeClass); |
|
1695 (draggable && this._trigger('activate', event, this.ui(draggable))); |
|
1696 }, |
|
1697 |
|
1698 _deactivate: function(event) { |
|
1699 var draggable = $.ui.ddmanager.current; |
|
1700 if(this.options.activeClass) this.element.removeClass(this.options.activeClass); |
|
1701 (draggable && this._trigger('deactivate', event, this.ui(draggable))); |
|
1702 }, |
|
1703 |
|
1704 _over: function(event) { |
|
1705 |
|
1706 var draggable = $.ui.ddmanager.current; |
|
1707 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element |
|
1708 |
|
1709 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1710 if(this.options.hoverClass) this.element.addClass(this.options.hoverClass); |
|
1711 this._trigger('over', event, this.ui(draggable)); |
|
1712 } |
|
1713 |
|
1714 }, |
|
1715 |
|
1716 _out: function(event) { |
|
1717 |
|
1718 var draggable = $.ui.ddmanager.current; |
|
1719 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element |
|
1720 |
|
1721 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1722 if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); |
|
1723 this._trigger('out', event, this.ui(draggable)); |
|
1724 } |
|
1725 |
|
1726 }, |
|
1727 |
|
1728 _drop: function(event,custom) { |
|
1729 |
|
1730 var draggable = custom || $.ui.ddmanager.current; |
|
1731 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element |
|
1732 |
|
1733 var childrenIntersection = false; |
|
1734 this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() { |
|
1735 var inst = $.data(this, 'droppable'); |
|
1736 if( |
|
1737 inst.options.greedy |
|
1738 && !inst.options.disabled |
|
1739 && inst.options.scope == draggable.options.scope |
|
1740 && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) |
|
1741 && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance) |
|
1742 ) { childrenIntersection = true; return false; } |
|
1743 }); |
|
1744 if(childrenIntersection) return false; |
|
1745 |
|
1746 if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1747 if(this.options.activeClass) this.element.removeClass(this.options.activeClass); |
|
1748 if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); |
|
1749 this._trigger('drop', event, this.ui(draggable)); |
|
1750 return this.element; |
|
1751 } |
|
1752 |
|
1753 return false; |
|
1754 |
|
1755 }, |
|
1756 |
|
1757 ui: function(c) { |
|
1758 return { |
|
1759 draggable: (c.currentItem || c.element), |
|
1760 helper: c.helper, |
|
1761 position: c.position, |
|
1762 offset: c.positionAbs |
|
1763 }; |
|
1764 } |
|
1765 |
|
1766 }); |
|
1767 |
|
1768 $.extend($.ui.droppable, { |
|
1769 version: "1.8.1" |
|
1770 }); |
|
1771 |
|
1772 $.ui.intersect = function(draggable, droppable, toleranceMode) { |
|
1773 |
|
1774 if (!droppable.offset) return false; |
|
1775 |
|
1776 var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, |
|
1777 y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height; |
|
1778 var l = droppable.offset.left, r = l + droppable.proportions.width, |
|
1779 t = droppable.offset.top, b = t + droppable.proportions.height; |
|
1780 |
|
1781 switch (toleranceMode) { |
|
1782 case 'fit': |
|
1783 return (l < x1 && x2 < r |
|
1784 && t < y1 && y2 < b); |
|
1785 break; |
|
1786 case 'intersect': |
|
1787 return (l < x1 + (draggable.helperProportions.width / 2) // Right Half |
|
1788 && x2 - (draggable.helperProportions.width / 2) < r // Left Half |
|
1789 && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half |
|
1790 && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half |
|
1791 break; |
|
1792 case 'pointer': |
|
1793 var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left), |
|
1794 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top), |
|
1795 isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width); |
|
1796 return isOver; |
|
1797 break; |
|
1798 case 'touch': |
|
1799 return ( |
|
1800 (y1 >= t && y1 <= b) || // Top edge touching |
|
1801 (y2 >= t && y2 <= b) || // Bottom edge touching |
|
1802 (y1 < t && y2 > b) // Surrounded vertically |
|
1803 ) && ( |
|
1804 (x1 >= l && x1 <= r) || // Left edge touching |
|
1805 (x2 >= l && x2 <= r) || // Right edge touching |
|
1806 (x1 < l && x2 > r) // Surrounded horizontally |
|
1807 ); |
|
1808 break; |
|
1809 default: |
|
1810 return false; |
|
1811 break; |
|
1812 } |
|
1813 |
|
1814 }; |
|
1815 |
|
1816 /* |
|
1817 This manager tracks offsets of draggables and droppables |
|
1818 */ |
|
1819 $.ui.ddmanager = { |
|
1820 current: null, |
|
1821 droppables: { 'default': [] }, |
|
1822 prepareOffsets: function(t, event) { |
|
1823 |
|
1824 var m = $.ui.ddmanager.droppables[t.options.scope] || []; |
|
1825 var type = event ? event.type : null; // workaround for #2317 |
|
1826 var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); |
|
1827 |
|
1828 droppablesLoop: for (var i = 0; i < m.length; i++) { |
|
1829 |
|
1830 if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted |
|
1831 for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item |
|
1832 m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue |
|
1833 |
|
1834 m[i].offset = m[i].element.offset(); |
|
1835 m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; |
|
1836 |
|
1837 if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables |
|
1838 |
|
1839 } |
|
1840 |
|
1841 }, |
|
1842 drop: function(draggable, event) { |
|
1843 |
|
1844 var dropped = false; |
|
1845 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { |
|
1846 |
|
1847 if(!this.options) return; |
|
1848 if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) |
|
1849 dropped = dropped || this._drop.call(this, event); |
|
1850 |
|
1851 if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1852 this.isout = 1; this.isover = 0; |
|
1853 this._deactivate.call(this, event); |
|
1854 } |
|
1855 |
|
1856 }); |
|
1857 return dropped; |
|
1858 |
|
1859 }, |
|
1860 drag: function(draggable, event) { |
|
1861 |
|
1862 //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. |
|
1863 if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event); |
|
1864 |
|
1865 //Run through all droppables and check their positions based on specific tolerance options |
|
1866 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { |
|
1867 |
|
1868 if(this.options.disabled || this.greedyChild || !this.visible) return; |
|
1869 var intersects = $.ui.intersect(draggable, this, this.options.tolerance); |
|
1870 |
|
1871 var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null); |
|
1872 if(!c) return; |
|
1873 |
|
1874 var parentInstance; |
|
1875 if (this.options.greedy) { |
|
1876 var parent = this.element.parents(':data(droppable):eq(0)'); |
|
1877 if (parent.length) { |
|
1878 parentInstance = $.data(parent[0], 'droppable'); |
|
1879 parentInstance.greedyChild = (c == 'isover' ? 1 : 0); |
|
1880 } |
|
1881 } |
|
1882 |
|
1883 // we just moved into a greedy child |
|
1884 if (parentInstance && c == 'isover') { |
|
1885 parentInstance['isover'] = 0; |
|
1886 parentInstance['isout'] = 1; |
|
1887 parentInstance._out.call(parentInstance, event); |
|
1888 } |
|
1889 |
|
1890 this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; |
|
1891 this[c == "isover" ? "_over" : "_out"].call(this, event); |
|
1892 |
|
1893 // we just moved out of a greedy child |
|
1894 if (parentInstance && c == 'isout') { |
|
1895 parentInstance['isout'] = 0; |
|
1896 parentInstance['isover'] = 1; |
|
1897 parentInstance._over.call(parentInstance, event); |
|
1898 } |
|
1899 }); |
|
1900 |
|
1901 } |
|
1902 }; |
|
1903 |
|
1904 })(jQuery); |
|
1905 /* |
|
1906 * jQuery UI Resizable 1.8.1 |
|
1907 * |
|
1908 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
1909 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
1910 * and GPL (GPL-LICENSE.txt) licenses. |
|
1911 * |
|
1912 * http://docs.jquery.com/UI/Resizables |
|
1913 * |
|
1914 * Depends: |
|
1915 * jquery.ui.core.js |
|
1916 * jquery.ui.mouse.js |
|
1917 * jquery.ui.widget.js |
|
1918 */ |
|
1919 (function($) { |
|
1920 |
|
1921 $.widget("ui.resizable", $.ui.mouse, { |
|
1922 widgetEventPrefix: "resize", |
|
1923 options: { |
|
1924 alsoResize: false, |
|
1925 animate: false, |
|
1926 animateDuration: "slow", |
|
1927 animateEasing: "swing", |
|
1928 aspectRatio: false, |
|
1929 autoHide: false, |
|
1930 containment: false, |
|
1931 ghost: false, |
|
1932 grid: false, |
|
1933 handles: "e,s,se", |
|
1934 helper: false, |
|
1935 maxHeight: null, |
|
1936 maxWidth: null, |
|
1937 minHeight: 10, |
|
1938 minWidth: 10, |
|
1939 zIndex: 1000 |
|
1940 }, |
|
1941 _create: function() { |
|
1942 |
|
1943 var self = this, o = this.options; |
|
1944 this.element.addClass("ui-resizable"); |
|
1945 |
|
1946 $.extend(this, { |
|
1947 _aspectRatio: !!(o.aspectRatio), |
|
1948 aspectRatio: o.aspectRatio, |
|
1949 originalElement: this.element, |
|
1950 _proportionallyResizeElements: [], |
|
1951 _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null |
|
1952 }); |
|
1953 |
|
1954 //Wrap the element if it cannot hold child nodes |
|
1955 if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { |
|
1956 |
|
1957 //Opera fix for relative positioning |
|
1958 if (/relative/.test(this.element.css('position')) && $.browser.opera) |
|
1959 this.element.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
1960 |
|
1961 //Create a wrapper element and set the wrapper to the new current internal element |
|
1962 this.element.wrap( |
|
1963 $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({ |
|
1964 position: this.element.css('position'), |
|
1965 width: this.element.outerWidth(), |
|
1966 height: this.element.outerHeight(), |
|
1967 top: this.element.css('top'), |
|
1968 left: this.element.css('left') |
|
1969 }) |
|
1970 ); |
|
1971 |
|
1972 //Overwrite the original this.element |
|
1973 this.element = this.element.parent().data( |
|
1974 "resizable", this.element.data('resizable') |
|
1975 ); |
|
1976 |
|
1977 this.elementIsWrapper = true; |
|
1978 |
|
1979 //Move margins to the wrapper |
|
1980 this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") }); |
|
1981 this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); |
|
1982 |
|
1983 //Prevent Safari textarea resize |
|
1984 this.originalResizeStyle = this.originalElement.css('resize'); |
|
1985 this.originalElement.css('resize', 'none'); |
|
1986 |
|
1987 //Push the actual element to our proportionallyResize internal array |
|
1988 this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' })); |
|
1989 |
|
1990 // avoid IE jump (hard set the margin) |
|
1991 this.originalElement.css({ margin: this.originalElement.css('margin') }); |
|
1992 |
|
1993 // fix handlers offset |
|
1994 this._proportionallyResize(); |
|
1995 |
|
1996 } |
|
1997 |
|
1998 this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }); |
|
1999 if(this.handles.constructor == String) { |
|
2000 |
|
2001 if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw'; |
|
2002 var n = this.handles.split(","); this.handles = {}; |
|
2003 |
|
2004 for(var i = 0; i < n.length; i++) { |
|
2005 |
|
2006 var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle; |
|
2007 var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>'); |
|
2008 |
|
2009 // increase zIndex of sw, se, ne, nw axis |
|
2010 //TODO : this modifies original option |
|
2011 if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex }); |
|
2012 |
|
2013 //TODO : What's going on here? |
|
2014 if ('se' == handle) { |
|
2015 axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se'); |
|
2016 }; |
|
2017 |
|
2018 //Insert into internal handles object and append to element |
|
2019 this.handles[handle] = '.ui-resizable-'+handle; |
|
2020 this.element.append(axis); |
|
2021 } |
|
2022 |
|
2023 } |
|
2024 |
|
2025 this._renderAxis = function(target) { |
|
2026 |
|
2027 target = target || this.element; |
|
2028 |
|
2029 for(var i in this.handles) { |
|
2030 |
|
2031 if(this.handles[i].constructor == String) |
|
2032 this.handles[i] = $(this.handles[i], this.element).show(); |
|
2033 |
|
2034 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) |
|
2035 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { |
|
2036 |
|
2037 var axis = $(this.handles[i], this.element), padWrapper = 0; |
|
2038 |
|
2039 //Checking the correct pad and border |
|
2040 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
|
2041 |
|
2042 //The padding type i have to apply... |
|
2043 var padPos = [ 'padding', |
|
2044 /ne|nw|n/.test(i) ? 'Top' : |
|
2045 /se|sw|s/.test(i) ? 'Bottom' : |
|
2046 /^e$/.test(i) ? 'Right' : 'Left' ].join(""); |
|
2047 |
|
2048 target.css(padPos, padWrapper); |
|
2049 |
|
2050 this._proportionallyResize(); |
|
2051 |
|
2052 } |
|
2053 |
|
2054 //TODO: What's that good for? There's not anything to be executed left |
|
2055 if(!$(this.handles[i]).length) |
|
2056 continue; |
|
2057 |
|
2058 } |
|
2059 }; |
|
2060 |
|
2061 //TODO: make renderAxis a prototype function |
|
2062 this._renderAxis(this.element); |
|
2063 |
|
2064 this._handles = $('.ui-resizable-handle', this.element) |
|
2065 .disableSelection(); |
|
2066 |
|
2067 //Matching axis name |
|
2068 this._handles.mouseover(function() { |
|
2069 if (!self.resizing) { |
|
2070 if (this.className) |
|
2071 var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
2072 //Axis, default = se |
|
2073 self.axis = axis && axis[1] ? axis[1] : 'se'; |
|
2074 } |
|
2075 }); |
|
2076 |
|
2077 //If we want to auto hide the elements |
|
2078 if (o.autoHide) { |
|
2079 this._handles.hide(); |
|
2080 $(this.element) |
|
2081 .addClass("ui-resizable-autohide") |
|
2082 .hover(function() { |
|
2083 $(this).removeClass("ui-resizable-autohide"); |
|
2084 self._handles.show(); |
|
2085 }, |
|
2086 function(){ |
|
2087 if (!self.resizing) { |
|
2088 $(this).addClass("ui-resizable-autohide"); |
|
2089 self._handles.hide(); |
|
2090 } |
|
2091 }); |
|
2092 } |
|
2093 |
|
2094 //Initialize the mouse interaction |
|
2095 this._mouseInit(); |
|
2096 |
|
2097 }, |
|
2098 |
|
2099 destroy: function() { |
|
2100 |
|
2101 this._mouseDestroy(); |
|
2102 |
|
2103 var _destroy = function(exp) { |
|
2104 $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
|
2105 .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); |
|
2106 }; |
|
2107 |
|
2108 //TODO: Unwrap at same DOM position |
|
2109 if (this.elementIsWrapper) { |
|
2110 _destroy(this.element); |
|
2111 var wrapper = this.element; |
|
2112 wrapper.after( |
|
2113 this.originalElement.css({ |
|
2114 position: wrapper.css('position'), |
|
2115 width: wrapper.outerWidth(), |
|
2116 height: wrapper.outerHeight(), |
|
2117 top: wrapper.css('top'), |
|
2118 left: wrapper.css('left') |
|
2119 }) |
|
2120 ).remove(); |
|
2121 } |
|
2122 |
|
2123 this.originalElement.css('resize', this.originalResizeStyle); |
|
2124 _destroy(this.originalElement); |
|
2125 |
|
2126 return this; |
|
2127 }, |
|
2128 |
|
2129 _mouseCapture: function(event) { |
|
2130 var handle = false; |
|
2131 for (var i in this.handles) { |
|
2132 if ($(this.handles[i])[0] == event.target) { |
|
2133 handle = true; |
|
2134 } |
|
2135 } |
|
2136 |
|
2137 return !this.options.disabled && handle; |
|
2138 }, |
|
2139 |
|
2140 _mouseStart: function(event) { |
|
2141 |
|
2142 var o = this.options, iniPos = this.element.position(), el = this.element; |
|
2143 |
|
2144 this.resizing = true; |
|
2145 this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; |
|
2146 |
|
2147 // bugfix for http://dev.jquery.com/ticket/1749 |
|
2148 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { |
|
2149 el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left }); |
|
2150 } |
|
2151 |
|
2152 //Opera fixing relative position |
|
2153 if ($.browser.opera && (/relative/).test(el.css('position'))) |
|
2154 el.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
2155 |
|
2156 this._renderProxy(); |
|
2157 |
|
2158 var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); |
|
2159 |
|
2160 if (o.containment) { |
|
2161 curleft += $(o.containment).scrollLeft() || 0; |
|
2162 curtop += $(o.containment).scrollTop() || 0; |
|
2163 } |
|
2164 |
|
2165 //Store needed variables |
|
2166 this.offset = this.helper.offset(); |
|
2167 this.position = { left: curleft, top: curtop }; |
|
2168 this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
2169 this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
2170 this.originalPosition = { left: curleft, top: curtop }; |
|
2171 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; |
|
2172 this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
|
2173 |
|
2174 //Aspect Ratio |
|
2175 this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); |
|
2176 |
|
2177 var cursor = $('.ui-resizable-' + this.axis).css('cursor'); |
|
2178 $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor); |
|
2179 |
|
2180 el.addClass("ui-resizable-resizing"); |
|
2181 this._propagate("start", event); |
|
2182 return true; |
|
2183 }, |
|
2184 |
|
2185 _mouseDrag: function(event) { |
|
2186 |
|
2187 //Increase performance, avoid regex |
|
2188 var el = this.helper, o = this.options, props = {}, |
|
2189 self = this, smp = this.originalMousePosition, a = this.axis; |
|
2190 |
|
2191 var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; |
|
2192 var trigger = this._change[a]; |
|
2193 if (!trigger) return false; |
|
2194 |
|
2195 // Calculate the attrs that will be change |
|
2196 var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; |
|
2197 |
|
2198 if (this._aspectRatio || event.shiftKey) |
|
2199 data = this._updateRatio(data, event); |
|
2200 |
|
2201 data = this._respectSize(data, event); |
|
2202 |
|
2203 // plugins callbacks need to be called first |
|
2204 this._propagate("resize", event); |
|
2205 |
|
2206 el.css({ |
|
2207 top: this.position.top + "px", left: this.position.left + "px", |
|
2208 width: this.size.width + "px", height: this.size.height + "px" |
|
2209 }); |
|
2210 |
|
2211 if (!this._helper && this._proportionallyResizeElements.length) |
|
2212 this._proportionallyResize(); |
|
2213 |
|
2214 this._updateCache(data); |
|
2215 |
|
2216 // calling the user callback at the end |
|
2217 this._trigger('resize', event, this.ui()); |
|
2218 |
|
2219 return false; |
|
2220 }, |
|
2221 |
|
2222 _mouseStop: function(event) { |
|
2223 |
|
2224 this.resizing = false; |
|
2225 var o = this.options, self = this; |
|
2226 |
|
2227 if(this._helper) { |
|
2228 var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
2229 soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
|
2230 soffsetw = ista ? 0 : self.sizeDiff.width; |
|
2231 |
|
2232 var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
|
2233 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
|
2234 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
|
2235 |
|
2236 if (!o.animate) |
|
2237 this.element.css($.extend(s, { top: top, left: left })); |
|
2238 |
|
2239 self.helper.height(self.size.height); |
|
2240 self.helper.width(self.size.width); |
|
2241 |
|
2242 if (this._helper && !o.animate) this._proportionallyResize(); |
|
2243 } |
|
2244 |
|
2245 $('body').css('cursor', 'auto'); |
|
2246 |
|
2247 this.element.removeClass("ui-resizable-resizing"); |
|
2248 |
|
2249 this._propagate("stop", event); |
|
2250 |
|
2251 if (this._helper) this.helper.remove(); |
|
2252 return false; |
|
2253 |
|
2254 }, |
|
2255 |
|
2256 _updateCache: function(data) { |
|
2257 var o = this.options; |
|
2258 this.offset = this.helper.offset(); |
|
2259 if (isNumber(data.left)) this.position.left = data.left; |
|
2260 if (isNumber(data.top)) this.position.top = data.top; |
|
2261 if (isNumber(data.height)) this.size.height = data.height; |
|
2262 if (isNumber(data.width)) this.size.width = data.width; |
|
2263 }, |
|
2264 |
|
2265 _updateRatio: function(data, event) { |
|
2266 |
|
2267 var o = this.options, cpos = this.position, csize = this.size, a = this.axis; |
|
2268 |
|
2269 if (data.height) data.width = (csize.height * this.aspectRatio); |
|
2270 else if (data.width) data.height = (csize.width / this.aspectRatio); |
|
2271 |
|
2272 if (a == 'sw') { |
|
2273 data.left = cpos.left + (csize.width - data.width); |
|
2274 data.top = null; |
|
2275 } |
|
2276 if (a == 'nw') { |
|
2277 data.top = cpos.top + (csize.height - data.height); |
|
2278 data.left = cpos.left + (csize.width - data.width); |
|
2279 } |
|
2280 |
|
2281 return data; |
|
2282 }, |
|
2283 |
|
2284 _respectSize: function(data, event) { |
|
2285 |
|
2286 var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, |
|
2287 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
2288 isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); |
|
2289 |
|
2290 if (isminw) data.width = o.minWidth; |
|
2291 if (isminh) data.height = o.minHeight; |
|
2292 if (ismaxw) data.width = o.maxWidth; |
|
2293 if (ismaxh) data.height = o.maxHeight; |
|
2294 |
|
2295 var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; |
|
2296 var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
2297 |
|
2298 if (isminw && cw) data.left = dw - o.minWidth; |
|
2299 if (ismaxw && cw) data.left = dw - o.maxWidth; |
|
2300 if (isminh && ch) data.top = dh - o.minHeight; |
|
2301 if (ismaxh && ch) data.top = dh - o.maxHeight; |
|
2302 |
|
2303 // fixing jump error on top/left - bug #2330 |
|
2304 var isNotwh = !data.width && !data.height; |
|
2305 if (isNotwh && !data.left && data.top) data.top = null; |
|
2306 else if (isNotwh && !data.top && data.left) data.left = null; |
|
2307 |
|
2308 return data; |
|
2309 }, |
|
2310 |
|
2311 _proportionallyResize: function() { |
|
2312 |
|
2313 var o = this.options; |
|
2314 if (!this._proportionallyResizeElements.length) return; |
|
2315 var element = this.helper || this.element; |
|
2316 |
|
2317 for (var i=0; i < this._proportionallyResizeElements.length; i++) { |
|
2318 |
|
2319 var prel = this._proportionallyResizeElements[i]; |
|
2320 |
|
2321 if (!this.borderDif) { |
|
2322 var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], |
|
2323 p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; |
|
2324 |
|
2325 this.borderDif = $.map(b, function(v, i) { |
|
2326 var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; |
|
2327 return border + padding; |
|
2328 }); |
|
2329 } |
|
2330 |
|
2331 if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) |
|
2332 continue; |
|
2333 |
|
2334 prel.css({ |
|
2335 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, |
|
2336 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 |
|
2337 }); |
|
2338 |
|
2339 }; |
|
2340 |
|
2341 }, |
|
2342 |
|
2343 _renderProxy: function() { |
|
2344 |
|
2345 var el = this.element, o = this.options; |
|
2346 this.elementOffset = el.offset(); |
|
2347 |
|
2348 if(this._helper) { |
|
2349 |
|
2350 this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); |
|
2351 |
|
2352 // fix ie6 offset TODO: This seems broken |
|
2353 var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), |
|
2354 pxyoffset = ( ie6 ? 2 : -1 ); |
|
2355 |
|
2356 this.helper.addClass(this._helper).css({ |
|
2357 width: this.element.outerWidth() + pxyoffset, |
|
2358 height: this.element.outerHeight() + pxyoffset, |
|
2359 position: 'absolute', |
|
2360 left: this.elementOffset.left - ie6offset +'px', |
|
2361 top: this.elementOffset.top - ie6offset +'px', |
|
2362 zIndex: ++o.zIndex //TODO: Don't modify option |
|
2363 }); |
|
2364 |
|
2365 this.helper |
|
2366 .appendTo("body") |
|
2367 .disableSelection(); |
|
2368 |
|
2369 } else { |
|
2370 this.helper = this.element; |
|
2371 } |
|
2372 |
|
2373 }, |
|
2374 |
|
2375 _change: { |
|
2376 e: function(event, dx, dy) { |
|
2377 return { width: this.originalSize.width + dx }; |
|
2378 }, |
|
2379 w: function(event, dx, dy) { |
|
2380 var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
|
2381 return { left: sp.left + dx, width: cs.width - dx }; |
|
2382 }, |
|
2383 n: function(event, dx, dy) { |
|
2384 var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
|
2385 return { top: sp.top + dy, height: cs.height - dy }; |
|
2386 }, |
|
2387 s: function(event, dx, dy) { |
|
2388 return { height: this.originalSize.height + dy }; |
|
2389 }, |
|
2390 se: function(event, dx, dy) { |
|
2391 return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2392 }, |
|
2393 sw: function(event, dx, dy) { |
|
2394 return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2395 }, |
|
2396 ne: function(event, dx, dy) { |
|
2397 return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2398 }, |
|
2399 nw: function(event, dx, dy) { |
|
2400 return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2401 } |
|
2402 }, |
|
2403 |
|
2404 _propagate: function(n, event) { |
|
2405 $.ui.plugin.call(this, n, [event, this.ui()]); |
|
2406 (n != "resize" && this._trigger(n, event, this.ui())); |
|
2407 }, |
|
2408 |
|
2409 plugins: {}, |
|
2410 |
|
2411 ui: function() { |
|
2412 return { |
|
2413 originalElement: this.originalElement, |
|
2414 element: this.element, |
|
2415 helper: this.helper, |
|
2416 position: this.position, |
|
2417 size: this.size, |
|
2418 originalSize: this.originalSize, |
|
2419 originalPosition: this.originalPosition |
|
2420 }; |
|
2421 } |
|
2422 |
|
2423 }); |
|
2424 |
|
2425 $.extend($.ui.resizable, { |
|
2426 version: "1.8.1" |
|
2427 }); |
|
2428 |
|
2429 /* |
|
2430 * Resizable Extensions |
|
2431 */ |
|
2432 |
|
2433 $.ui.plugin.add("resizable", "alsoResize", { |
|
2434 |
|
2435 start: function(event, ui) { |
|
2436 |
|
2437 var self = $(this).data("resizable"), o = self.options; |
|
2438 |
|
2439 var _store = function(exp) { |
|
2440 $(exp).each(function() { |
|
2441 $(this).data("resizable-alsoresize", { |
|
2442 width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), |
|
2443 left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) |
|
2444 }); |
|
2445 }); |
|
2446 }; |
|
2447 |
|
2448 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { |
|
2449 if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
|
2450 else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } |
|
2451 }else{ |
|
2452 _store(o.alsoResize); |
|
2453 } |
|
2454 }, |
|
2455 |
|
2456 resize: function(event, ui){ |
|
2457 var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; |
|
2458 |
|
2459 var delta = { |
|
2460 height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, |
|
2461 top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 |
|
2462 }, |
|
2463 |
|
2464 _alsoResize = function(exp, c) { |
|
2465 $(exp).each(function() { |
|
2466 var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; |
|
2467 |
|
2468 $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { |
|
2469 var sum = (start[prop]||0) + (delta[prop]||0); |
|
2470 if (sum && sum >= 0) |
|
2471 style[prop] = sum || null; |
|
2472 }); |
|
2473 |
|
2474 //Opera fixing relative position |
|
2475 if (/relative/.test(el.css('position')) && $.browser.opera) { |
|
2476 self._revertToRelativePosition = true; |
|
2477 el.css({ position: 'absolute', top: 'auto', left: 'auto' }); |
|
2478 } |
|
2479 |
|
2480 el.css(style); |
|
2481 }); |
|
2482 }; |
|
2483 |
|
2484 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { |
|
2485 $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); |
|
2486 }else{ |
|
2487 _alsoResize(o.alsoResize); |
|
2488 } |
|
2489 }, |
|
2490 |
|
2491 stop: function(event, ui){ |
|
2492 var self = $(this).data("resizable"); |
|
2493 |
|
2494 //Opera fixing relative position |
|
2495 if (self._revertToRelativePosition && $.browser.opera) { |
|
2496 self._revertToRelativePosition = false; |
|
2497 el.css({ position: 'relative' }); |
|
2498 } |
|
2499 |
|
2500 $(this).removeData("resizable-alsoresize-start"); |
|
2501 } |
|
2502 }); |
|
2503 |
|
2504 $.ui.plugin.add("resizable", "animate", { |
|
2505 |
|
2506 stop: function(event, ui) { |
|
2507 var self = $(this).data("resizable"), o = self.options; |
|
2508 |
|
2509 var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
2510 soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
|
2511 soffsetw = ista ? 0 : self.sizeDiff.width; |
|
2512 |
|
2513 var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
|
2514 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
|
2515 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
|
2516 |
|
2517 self.element.animate( |
|
2518 $.extend(style, top && left ? { top: top, left: left } : {}), { |
|
2519 duration: o.animateDuration, |
|
2520 easing: o.animateEasing, |
|
2521 step: function() { |
|
2522 |
|
2523 var data = { |
|
2524 width: parseInt(self.element.css('width'), 10), |
|
2525 height: parseInt(self.element.css('height'), 10), |
|
2526 top: parseInt(self.element.css('top'), 10), |
|
2527 left: parseInt(self.element.css('left'), 10) |
|
2528 }; |
|
2529 |
|
2530 if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height }); |
|
2531 |
|
2532 // propagating resize, and updating values for each animation step |
|
2533 self._updateCache(data); |
|
2534 self._propagate("resize", event); |
|
2535 |
|
2536 } |
|
2537 } |
|
2538 ); |
|
2539 } |
|
2540 |
|
2541 }); |
|
2542 |
|
2543 $.ui.plugin.add("resizable", "containment", { |
|
2544 |
|
2545 start: function(event, ui) { |
|
2546 var self = $(this).data("resizable"), o = self.options, el = self.element; |
|
2547 var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
|
2548 if (!ce) return; |
|
2549 |
|
2550 self.containerElement = $(ce); |
|
2551 |
|
2552 if (/document/.test(oc) || oc == document) { |
|
2553 self.containerOffset = { left: 0, top: 0 }; |
|
2554 self.containerPosition = { left: 0, top: 0 }; |
|
2555 |
|
2556 self.parentData = { |
|
2557 element: $(document), left: 0, top: 0, |
|
2558 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight |
|
2559 }; |
|
2560 } |
|
2561 |
|
2562 // i'm a node, so compute top, left, right, bottom |
|
2563 else { |
|
2564 var element = $(ce), p = []; |
|
2565 $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); |
|
2566 |
|
2567 self.containerOffset = element.offset(); |
|
2568 self.containerPosition = element.position(); |
|
2569 self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; |
|
2570 |
|
2571 var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, |
|
2572 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
|
2573 |
|
2574 self.parentData = { |
|
2575 element: ce, left: co.left, top: co.top, width: width, height: height |
|
2576 }; |
|
2577 } |
|
2578 }, |
|
2579 |
|
2580 resize: function(event, ui) { |
|
2581 var self = $(this).data("resizable"), o = self.options, |
|
2582 ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, |
|
2583 pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; |
|
2584 |
|
2585 if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; |
|
2586 |
|
2587 if (cp.left < (self._helper ? co.left : 0)) { |
|
2588 self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left)); |
|
2589 if (pRatio) self.size.height = self.size.width / o.aspectRatio; |
|
2590 self.position.left = o.helper ? co.left : 0; |
|
2591 } |
|
2592 |
|
2593 if (cp.top < (self._helper ? co.top : 0)) { |
|
2594 self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top); |
|
2595 if (pRatio) self.size.width = self.size.height * o.aspectRatio; |
|
2596 self.position.top = self._helper ? co.top : 0; |
|
2597 } |
|
2598 |
|
2599 self.offset.left = self.parentData.left+self.position.left; |
|
2600 self.offset.top = self.parentData.top+self.position.top; |
|
2601 |
|
2602 var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ), |
|
2603 hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height ); |
|
2604 |
|
2605 var isParent = self.containerElement.get(0) == self.element.parent().get(0), |
|
2606 isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position')); |
|
2607 |
|
2608 if(isParent && isOffsetRelative) woset -= self.parentData.left; |
|
2609 |
|
2610 if (woset + self.size.width >= self.parentData.width) { |
|
2611 self.size.width = self.parentData.width - woset; |
|
2612 if (pRatio) self.size.height = self.size.width / self.aspectRatio; |
|
2613 } |
|
2614 |
|
2615 if (hoset + self.size.height >= self.parentData.height) { |
|
2616 self.size.height = self.parentData.height - hoset; |
|
2617 if (pRatio) self.size.width = self.size.height * self.aspectRatio; |
|
2618 } |
|
2619 }, |
|
2620 |
|
2621 stop: function(event, ui){ |
|
2622 var self = $(this).data("resizable"), o = self.options, cp = self.position, |
|
2623 co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; |
|
2624 |
|
2625 var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; |
|
2626 |
|
2627 if (self._helper && !o.animate && (/relative/).test(ce.css('position'))) |
|
2628 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
2629 |
|
2630 if (self._helper && !o.animate && (/static/).test(ce.css('position'))) |
|
2631 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
2632 |
|
2633 } |
|
2634 }); |
|
2635 |
|
2636 $.ui.plugin.add("resizable", "ghost", { |
|
2637 |
|
2638 start: function(event, ui) { |
|
2639 |
|
2640 var self = $(this).data("resizable"), o = self.options, cs = self.size; |
|
2641 |
|
2642 self.ghost = self.originalElement.clone(); |
|
2643 self.ghost |
|
2644 .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }) |
|
2645 .addClass('ui-resizable-ghost') |
|
2646 .addClass(typeof o.ghost == 'string' ? o.ghost : ''); |
|
2647 |
|
2648 self.ghost.appendTo(self.helper); |
|
2649 |
|
2650 }, |
|
2651 |
|
2652 resize: function(event, ui){ |
|
2653 var self = $(this).data("resizable"), o = self.options; |
|
2654 if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); |
|
2655 }, |
|
2656 |
|
2657 stop: function(event, ui){ |
|
2658 var self = $(this).data("resizable"), o = self.options; |
|
2659 if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); |
|
2660 } |
|
2661 |
|
2662 }); |
|
2663 |
|
2664 $.ui.plugin.add("resizable", "grid", { |
|
2665 |
|
2666 resize: function(event, ui) { |
|
2667 var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; |
|
2668 o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; |
|
2669 var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); |
|
2670 |
|
2671 if (/^(se|s|e)$/.test(a)) { |
|
2672 self.size.width = os.width + ox; |
|
2673 self.size.height = os.height + oy; |
|
2674 } |
|
2675 else if (/^(ne)$/.test(a)) { |
|
2676 self.size.width = os.width + ox; |
|
2677 self.size.height = os.height + oy; |
|
2678 self.position.top = op.top - oy; |
|
2679 } |
|
2680 else if (/^(sw)$/.test(a)) { |
|
2681 self.size.width = os.width + ox; |
|
2682 self.size.height = os.height + oy; |
|
2683 self.position.left = op.left - ox; |
|
2684 } |
|
2685 else { |
|
2686 self.size.width = os.width + ox; |
|
2687 self.size.height = os.height + oy; |
|
2688 self.position.top = op.top - oy; |
|
2689 self.position.left = op.left - ox; |
|
2690 } |
|
2691 } |
|
2692 |
|
2693 }); |
|
2694 |
|
2695 var num = function(v) { |
|
2696 return parseInt(v, 10) || 0; |
|
2697 }; |
|
2698 |
|
2699 var isNumber = function(value) { |
|
2700 return !isNaN(parseInt(value, 10)); |
|
2701 }; |
|
2702 |
|
2703 })(jQuery); |
|
2704 /* |
|
2705 * jQuery UI Selectable 1.8.1 |
|
2706 * |
|
2707 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
2708 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
2709 * and GPL (GPL-LICENSE.txt) licenses. |
|
2710 * |
|
2711 * http://docs.jquery.com/UI/Selectables |
|
2712 * |
|
2713 * Depends: |
|
2714 * jquery.ui.core.js |
|
2715 * jquery.ui.mouse.js |
|
2716 * jquery.ui.widget.js |
|
2717 */ |
|
2718 (function($) { |
|
2719 |
|
2720 $.widget("ui.selectable", $.ui.mouse, { |
|
2721 options: { |
|
2722 appendTo: 'body', |
|
2723 autoRefresh: true, |
|
2724 distance: 0, |
|
2725 filter: '*', |
|
2726 tolerance: 'touch' |
|
2727 }, |
|
2728 _create: function() { |
|
2729 var self = this; |
|
2730 |
|
2731 this.element.addClass("ui-selectable"); |
|
2732 |
|
2733 this.dragged = false; |
|
2734 |
|
2735 // cache selectee children based on filter |
|
2736 var selectees; |
|
2737 this.refresh = function() { |
|
2738 selectees = $(self.options.filter, self.element[0]); |
|
2739 selectees.each(function() { |
|
2740 var $this = $(this); |
|
2741 var pos = $this.offset(); |
|
2742 $.data(this, "selectable-item", { |
|
2743 element: this, |
|
2744 $element: $this, |
|
2745 left: pos.left, |
|
2746 top: pos.top, |
|
2747 right: pos.left + $this.outerWidth(), |
|
2748 bottom: pos.top + $this.outerHeight(), |
|
2749 startselected: false, |
|
2750 selected: $this.hasClass('ui-selected'), |
|
2751 selecting: $this.hasClass('ui-selecting'), |
|
2752 unselecting: $this.hasClass('ui-unselecting') |
|
2753 }); |
|
2754 }); |
|
2755 }; |
|
2756 this.refresh(); |
|
2757 |
|
2758 this.selectees = selectees.addClass("ui-selectee"); |
|
2759 |
|
2760 this._mouseInit(); |
|
2761 |
|
2762 this.helper = $(document.createElement('div')) |
|
2763 .css({border:'1px dotted black'}) |
|
2764 .addClass("ui-selectable-helper"); |
|
2765 }, |
|
2766 |
|
2767 destroy: function() { |
|
2768 this.selectees |
|
2769 .removeClass("ui-selectee") |
|
2770 .removeData("selectable-item"); |
|
2771 this.element |
|
2772 .removeClass("ui-selectable ui-selectable-disabled") |
|
2773 .removeData("selectable") |
|
2774 .unbind(".selectable"); |
|
2775 this._mouseDestroy(); |
|
2776 |
|
2777 return this; |
|
2778 }, |
|
2779 |
|
2780 _mouseStart: function(event) { |
|
2781 var self = this; |
|
2782 |
|
2783 this.opos = [event.pageX, event.pageY]; |
|
2784 |
|
2785 if (this.options.disabled) |
|
2786 return; |
|
2787 |
|
2788 var options = this.options; |
|
2789 |
|
2790 this.selectees = $(options.filter, this.element[0]); |
|
2791 |
|
2792 this._trigger("start", event); |
|
2793 |
|
2794 $(options.appendTo).append(this.helper); |
|
2795 // position helper (lasso) |
|
2796 this.helper.css({ |
|
2797 "z-index": 100, |
|
2798 "position": "absolute", |
|
2799 "left": event.clientX, |
|
2800 "top": event.clientY, |
|
2801 "width": 0, |
|
2802 "height": 0 |
|
2803 }); |
|
2804 |
|
2805 if (options.autoRefresh) { |
|
2806 this.refresh(); |
|
2807 } |
|
2808 |
|
2809 this.selectees.filter('.ui-selected').each(function() { |
|
2810 var selectee = $.data(this, "selectable-item"); |
|
2811 selectee.startselected = true; |
|
2812 if (!event.metaKey) { |
|
2813 selectee.$element.removeClass('ui-selected'); |
|
2814 selectee.selected = false; |
|
2815 selectee.$element.addClass('ui-unselecting'); |
|
2816 selectee.unselecting = true; |
|
2817 // selectable UNSELECTING callback |
|
2818 self._trigger("unselecting", event, { |
|
2819 unselecting: selectee.element |
|
2820 }); |
|
2821 } |
|
2822 }); |
|
2823 |
|
2824 $(event.target).parents().andSelf().each(function() { |
|
2825 var selectee = $.data(this, "selectable-item"); |
|
2826 if (selectee) { |
|
2827 selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting'); |
|
2828 selectee.unselecting = false; |
|
2829 selectee.selecting = true; |
|
2830 selectee.selected = true; |
|
2831 // selectable SELECTING callback |
|
2832 self._trigger("selecting", event, { |
|
2833 selecting: selectee.element |
|
2834 }); |
|
2835 return false; |
|
2836 } |
|
2837 }); |
|
2838 |
|
2839 }, |
|
2840 |
|
2841 _mouseDrag: function(event) { |
|
2842 var self = this; |
|
2843 this.dragged = true; |
|
2844 |
|
2845 if (this.options.disabled) |
|
2846 return; |
|
2847 |
|
2848 var options = this.options; |
|
2849 |
|
2850 var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY; |
|
2851 if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; } |
|
2852 if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; } |
|
2853 this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); |
|
2854 |
|
2855 this.selectees.each(function() { |
|
2856 var selectee = $.data(this, "selectable-item"); |
|
2857 //prevent helper from being selected if appendTo: selectable |
|
2858 if (!selectee || selectee.element == self.element[0]) |
|
2859 return; |
|
2860 var hit = false; |
|
2861 if (options.tolerance == 'touch') { |
|
2862 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) ); |
|
2863 } else if (options.tolerance == 'fit') { |
|
2864 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); |
|
2865 } |
|
2866 |
|
2867 if (hit) { |
|
2868 // SELECT |
|
2869 if (selectee.selected) { |
|
2870 selectee.$element.removeClass('ui-selected'); |
|
2871 selectee.selected = false; |
|
2872 } |
|
2873 if (selectee.unselecting) { |
|
2874 selectee.$element.removeClass('ui-unselecting'); |
|
2875 selectee.unselecting = false; |
|
2876 } |
|
2877 if (!selectee.selecting) { |
|
2878 selectee.$element.addClass('ui-selecting'); |
|
2879 selectee.selecting = true; |
|
2880 // selectable SELECTING callback |
|
2881 self._trigger("selecting", event, { |
|
2882 selecting: selectee.element |
|
2883 }); |
|
2884 } |
|
2885 } else { |
|
2886 // UNSELECT |
|
2887 if (selectee.selecting) { |
|
2888 if (event.metaKey && selectee.startselected) { |
|
2889 selectee.$element.removeClass('ui-selecting'); |
|
2890 selectee.selecting = false; |
|
2891 selectee.$element.addClass('ui-selected'); |
|
2892 selectee.selected = true; |
|
2893 } else { |
|
2894 selectee.$element.removeClass('ui-selecting'); |
|
2895 selectee.selecting = false; |
|
2896 if (selectee.startselected) { |
|
2897 selectee.$element.addClass('ui-unselecting'); |
|
2898 selectee.unselecting = true; |
|
2899 } |
|
2900 // selectable UNSELECTING callback |
|
2901 self._trigger("unselecting", event, { |
|
2902 unselecting: selectee.element |
|
2903 }); |
|
2904 } |
|
2905 } |
|
2906 if (selectee.selected) { |
|
2907 if (!event.metaKey && !selectee.startselected) { |
|
2908 selectee.$element.removeClass('ui-selected'); |
|
2909 selectee.selected = false; |
|
2910 |
|
2911 selectee.$element.addClass('ui-unselecting'); |
|
2912 selectee.unselecting = true; |
|
2913 // selectable UNSELECTING callback |
|
2914 self._trigger("unselecting", event, { |
|
2915 unselecting: selectee.element |
|
2916 }); |
|
2917 } |
|
2918 } |
|
2919 } |
|
2920 }); |
|
2921 |
|
2922 return false; |
|
2923 }, |
|
2924 |
|
2925 _mouseStop: function(event) { |
|
2926 var self = this; |
|
2927 |
|
2928 this.dragged = false; |
|
2929 |
|
2930 var options = this.options; |
|
2931 |
|
2932 $('.ui-unselecting', this.element[0]).each(function() { |
|
2933 var selectee = $.data(this, "selectable-item"); |
|
2934 selectee.$element.removeClass('ui-unselecting'); |
|
2935 selectee.unselecting = false; |
|
2936 selectee.startselected = false; |
|
2937 self._trigger("unselected", event, { |
|
2938 unselected: selectee.element |
|
2939 }); |
|
2940 }); |
|
2941 $('.ui-selecting', this.element[0]).each(function() { |
|
2942 var selectee = $.data(this, "selectable-item"); |
|
2943 selectee.$element.removeClass('ui-selecting').addClass('ui-selected'); |
|
2944 selectee.selecting = false; |
|
2945 selectee.selected = true; |
|
2946 selectee.startselected = true; |
|
2947 self._trigger("selected", event, { |
|
2948 selected: selectee.element |
|
2949 }); |
|
2950 }); |
|
2951 this._trigger("stop", event); |
|
2952 |
|
2953 this.helper.remove(); |
|
2954 |
|
2955 return false; |
|
2956 } |
|
2957 |
|
2958 }); |
|
2959 |
|
2960 $.extend($.ui.selectable, { |
|
2961 version: "1.8.1" |
|
2962 }); |
|
2963 |
|
2964 })(jQuery); |
|
2965 /* |
|
2966 * jQuery UI Sortable 1.8.1 |
|
2967 * |
|
2968 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
2969 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
2970 * and GPL (GPL-LICENSE.txt) licenses. |
|
2971 * |
|
2972 * http://docs.jquery.com/UI/Sortables |
|
2973 * |
|
2974 * Depends: |
|
2975 * jquery.ui.core.js |
|
2976 * jquery.ui.mouse.js |
|
2977 * jquery.ui.widget.js |
|
2978 */ |
|
2979 (function($) { |
|
2980 |
|
2981 $.widget("ui.sortable", $.ui.mouse, { |
|
2982 widgetEventPrefix: "sort", |
|
2983 options: { |
|
2984 appendTo: "parent", |
|
2985 axis: false, |
|
2986 connectWith: false, |
|
2987 containment: false, |
|
2988 cursor: 'auto', |
|
2989 cursorAt: false, |
|
2990 dropOnEmpty: true, |
|
2991 forcePlaceholderSize: false, |
|
2992 forceHelperSize: false, |
|
2993 grid: false, |
|
2994 handle: false, |
|
2995 helper: "original", |
|
2996 items: '> *', |
|
2997 opacity: false, |
|
2998 placeholder: false, |
|
2999 revert: false, |
|
3000 scroll: true, |
|
3001 scrollSensitivity: 20, |
|
3002 scrollSpeed: 20, |
|
3003 scope: "default", |
|
3004 tolerance: "intersect", |
|
3005 zIndex: 1000 |
|
3006 }, |
|
3007 _create: function() { |
|
3008 |
|
3009 var o = this.options; |
|
3010 this.containerCache = {}; |
|
3011 this.element.addClass("ui-sortable"); |
|
3012 |
|
3013 //Get the items |
|
3014 this.refresh(); |
|
3015 |
|
3016 //Let's determine if the items are floating |
|
3017 this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; |
|
3018 |
|
3019 //Let's determine the parent's offset |
|
3020 this.offset = this.element.offset(); |
|
3021 |
|
3022 //Initialize mouse events for interaction |
|
3023 this._mouseInit(); |
|
3024 |
|
3025 }, |
|
3026 |
|
3027 destroy: function() { |
|
3028 this.element |
|
3029 .removeClass("ui-sortable ui-sortable-disabled") |
|
3030 .removeData("sortable") |
|
3031 .unbind(".sortable"); |
|
3032 this._mouseDestroy(); |
|
3033 |
|
3034 for ( var i = this.items.length - 1; i >= 0; i-- ) |
|
3035 this.items[i].item.removeData("sortable-item"); |
|
3036 |
|
3037 return this; |
|
3038 }, |
|
3039 |
|
3040 _setOption: function(key, value){ |
|
3041 if ( key === "disabled" ) { |
|
3042 this.options[ key ] = value; |
|
3043 |
|
3044 this.widget() |
|
3045 [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" ); |
|
3046 } else { |
|
3047 // Don't call widget base _setOption for disable as it adds ui-state-disabled class |
|
3048 $.Widget.prototype._setOption.apply(self, arguments); |
|
3049 } |
|
3050 }, |
|
3051 |
|
3052 _mouseCapture: function(event, overrideHandle) { |
|
3053 |
|
3054 if (this.reverting) { |
|
3055 return false; |
|
3056 } |
|
3057 |
|
3058 if(this.options.disabled || this.options.type == 'static') return false; |
|
3059 |
|
3060 //We have to refresh the items data once first |
|
3061 this._refreshItems(event); |
|
3062 |
|
3063 //Find out if the clicked node (or one of its parents) is a actual item in this.items |
|
3064 var currentItem = null, self = this, nodes = $(event.target).parents().each(function() { |
|
3065 if($.data(this, 'sortable-item') == self) { |
|
3066 currentItem = $(this); |
|
3067 return false; |
|
3068 } |
|
3069 }); |
|
3070 if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target); |
|
3071 |
|
3072 if(!currentItem) return false; |
|
3073 if(this.options.handle && !overrideHandle) { |
|
3074 var validHandle = false; |
|
3075 |
|
3076 $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; }); |
|
3077 if(!validHandle) return false; |
|
3078 } |
|
3079 |
|
3080 this.currentItem = currentItem; |
|
3081 this._removeCurrentsFromItems(); |
|
3082 return true; |
|
3083 |
|
3084 }, |
|
3085 |
|
3086 _mouseStart: function(event, overrideHandle, noActivation) { |
|
3087 |
|
3088 var o = this.options, self = this; |
|
3089 this.currentContainer = this; |
|
3090 |
|
3091 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture |
|
3092 this.refreshPositions(); |
|
3093 |
|
3094 //Create and append the visible helper |
|
3095 this.helper = this._createHelper(event); |
|
3096 |
|
3097 //Cache the helper size |
|
3098 this._cacheHelperProportions(); |
|
3099 |
|
3100 /* |
|
3101 * - Position generation - |
|
3102 * This block generates everything position related - it's the core of draggables. |
|
3103 */ |
|
3104 |
|
3105 //Cache the margins of the original element |
|
3106 this._cacheMargins(); |
|
3107 |
|
3108 //Get the next scrolling parent |
|
3109 this.scrollParent = this.helper.scrollParent(); |
|
3110 |
|
3111 //The element's absolute position on the page minus margins |
|
3112 this.offset = this.currentItem.offset(); |
|
3113 this.offset = { |
|
3114 top: this.offset.top - this.margins.top, |
|
3115 left: this.offset.left - this.margins.left |
|
3116 }; |
|
3117 |
|
3118 // Only after we got the offset, we can change the helper's position to absolute |
|
3119 // TODO: Still need to figure out a way to make relative sorting possible |
|
3120 this.helper.css("position", "absolute"); |
|
3121 this.cssPosition = this.helper.css("position"); |
|
3122 |
|
3123 $.extend(this.offset, { |
|
3124 click: { //Where the click happened, relative to the element |
|
3125 left: event.pageX - this.offset.left, |
|
3126 top: event.pageY - this.offset.top |
|
3127 }, |
|
3128 parent: this._getParentOffset(), |
|
3129 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
3130 }); |
|
3131 |
|
3132 //Generate the original position |
|
3133 this.originalPosition = this._generatePosition(event); |
|
3134 this.originalPageX = event.pageX; |
|
3135 this.originalPageY = event.pageY; |
|
3136 |
|
3137 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
|
3138 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
3139 |
|
3140 //Cache the former DOM position |
|
3141 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; |
|
3142 |
|
3143 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way |
|
3144 if(this.helper[0] != this.currentItem[0]) { |
|
3145 this.currentItem.hide(); |
|
3146 } |
|
3147 |
|
3148 //Create the placeholder |
|
3149 this._createPlaceholder(); |
|
3150 |
|
3151 //Set a containment if given in the options |
|
3152 if(o.containment) |
|
3153 this._setContainment(); |
|
3154 |
|
3155 if(o.cursor) { // cursor option |
|
3156 if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor"); |
|
3157 $('body').css("cursor", o.cursor); |
|
3158 } |
|
3159 |
|
3160 if(o.opacity) { // opacity option |
|
3161 if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity"); |
|
3162 this.helper.css("opacity", o.opacity); |
|
3163 } |
|
3164 |
|
3165 if(o.zIndex) { // zIndex option |
|
3166 if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex"); |
|
3167 this.helper.css("zIndex", o.zIndex); |
|
3168 } |
|
3169 |
|
3170 //Prepare scrolling |
|
3171 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') |
|
3172 this.overflowOffset = this.scrollParent.offset(); |
|
3173 |
|
3174 //Call callbacks |
|
3175 this._trigger("start", event, this._uiHash()); |
|
3176 |
|
3177 //Recache the helper size |
|
3178 if(!this._preserveHelperProportions) |
|
3179 this._cacheHelperProportions(); |
|
3180 |
|
3181 |
|
3182 //Post 'activate' events to possible containers |
|
3183 if(!noActivation) { |
|
3184 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); } |
|
3185 } |
|
3186 |
|
3187 //Prepare possible droppables |
|
3188 if($.ui.ddmanager) |
|
3189 $.ui.ddmanager.current = this; |
|
3190 |
|
3191 if ($.ui.ddmanager && !o.dropBehaviour) |
|
3192 $.ui.ddmanager.prepareOffsets(this, event); |
|
3193 |
|
3194 this.dragging = true; |
|
3195 |
|
3196 this.helper.addClass("ui-sortable-helper"); |
|
3197 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
3198 return true; |
|
3199 |
|
3200 }, |
|
3201 |
|
3202 _mouseDrag: function(event) { |
|
3203 |
|
3204 //Compute the helpers position |
|
3205 this.position = this._generatePosition(event); |
|
3206 this.positionAbs = this._convertPositionTo("absolute"); |
|
3207 |
|
3208 if (!this.lastPositionAbs) { |
|
3209 this.lastPositionAbs = this.positionAbs; |
|
3210 } |
|
3211 |
|
3212 //Do scrolling |
|
3213 if(this.options.scroll) { |
|
3214 var o = this.options, scrolled = false; |
|
3215 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { |
|
3216 |
|
3217 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
|
3218 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; |
|
3219 else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) |
|
3220 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; |
|
3221 |
|
3222 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
|
3223 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
3224 else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) |
|
3225 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
3226 |
|
3227 } else { |
|
3228 |
|
3229 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
|
3230 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
3231 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
|
3232 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
3233 |
|
3234 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
|
3235 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
3236 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
|
3237 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
3238 |
|
3239 } |
|
3240 |
|
3241 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
|
3242 $.ui.ddmanager.prepareOffsets(this, event); |
|
3243 } |
|
3244 |
|
3245 //Regenerate the absolute position used for position checks |
|
3246 this.positionAbs = this._convertPositionTo("absolute"); |
|
3247 |
|
3248 //Set the helper position |
|
3249 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
|
3250 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
|
3251 |
|
3252 //Rearrange |
|
3253 for (var i = this.items.length - 1; i >= 0; i--) { |
|
3254 |
|
3255 //Cache variables and intersection, continue if no intersection |
|
3256 var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); |
|
3257 if (!intersection) continue; |
|
3258 |
|
3259 if(itemElement != this.currentItem[0] //cannot intersect with itself |
|
3260 && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before |
|
3261 && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked |
|
3262 && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true) |
|
3263 //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container |
|
3264 ) { |
|
3265 |
|
3266 this.direction = intersection == 1 ? "down" : "up"; |
|
3267 |
|
3268 if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { |
|
3269 this._rearrange(event, item); |
|
3270 } else { |
|
3271 break; |
|
3272 } |
|
3273 |
|
3274 this._trigger("change", event, this._uiHash()); |
|
3275 break; |
|
3276 } |
|
3277 } |
|
3278 |
|
3279 //Post events to containers |
|
3280 this._contactContainers(event); |
|
3281 |
|
3282 //Interconnect with droppables |
|
3283 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
|
3284 |
|
3285 //Call callbacks |
|
3286 this._trigger('sort', event, this._uiHash()); |
|
3287 |
|
3288 this.lastPositionAbs = this.positionAbs; |
|
3289 return false; |
|
3290 |
|
3291 }, |
|
3292 |
|
3293 _mouseStop: function(event, noPropagation) { |
|
3294 |
|
3295 if(!event) return; |
|
3296 |
|
3297 //If we are using droppables, inform the manager about the drop |
|
3298 if ($.ui.ddmanager && !this.options.dropBehaviour) |
|
3299 $.ui.ddmanager.drop(this, event); |
|
3300 |
|
3301 if(this.options.revert) { |
|
3302 var self = this; |
|
3303 var cur = self.placeholder.offset(); |
|
3304 |
|
3305 self.reverting = true; |
|
3306 |
|
3307 $(this.helper).animate({ |
|
3308 left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), |
|
3309 top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) |
|
3310 }, parseInt(this.options.revert, 10) || 500, function() { |
|
3311 self._clear(event); |
|
3312 }); |
|
3313 } else { |
|
3314 this._clear(event, noPropagation); |
|
3315 } |
|
3316 |
|
3317 return false; |
|
3318 |
|
3319 }, |
|
3320 |
|
3321 cancel: function() { |
|
3322 |
|
3323 var self = this; |
|
3324 |
|
3325 if(this.dragging) { |
|
3326 |
|
3327 this._mouseUp(); |
|
3328 |
|
3329 if(this.options.helper == "original") |
|
3330 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
3331 else |
|
3332 this.currentItem.show(); |
|
3333 |
|
3334 //Post deactivating events to containers |
|
3335 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3336 this.containers[i]._trigger("deactivate", null, self._uiHash(this)); |
|
3337 if(this.containers[i].containerCache.over) { |
|
3338 this.containers[i]._trigger("out", null, self._uiHash(this)); |
|
3339 this.containers[i].containerCache.over = 0; |
|
3340 } |
|
3341 } |
|
3342 |
|
3343 } |
|
3344 |
|
3345 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
3346 if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
3347 if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); |
|
3348 |
|
3349 $.extend(this, { |
|
3350 helper: null, |
|
3351 dragging: false, |
|
3352 reverting: false, |
|
3353 _noFinalSort: null |
|
3354 }); |
|
3355 |
|
3356 if(this.domPosition.prev) { |
|
3357 $(this.domPosition.prev).after(this.currentItem); |
|
3358 } else { |
|
3359 $(this.domPosition.parent).prepend(this.currentItem); |
|
3360 } |
|
3361 |
|
3362 return this; |
|
3363 |
|
3364 }, |
|
3365 |
|
3366 serialize: function(o) { |
|
3367 |
|
3368 var items = this._getItemsAsjQuery(o && o.connected); |
|
3369 var str = []; o = o || {}; |
|
3370 |
|
3371 $(items).each(function() { |
|
3372 var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); |
|
3373 if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); |
|
3374 }); |
|
3375 |
|
3376 return str.join('&'); |
|
3377 |
|
3378 }, |
|
3379 |
|
3380 toArray: function(o) { |
|
3381 |
|
3382 var items = this._getItemsAsjQuery(o && o.connected); |
|
3383 var ret = []; o = o || {}; |
|
3384 |
|
3385 items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); }); |
|
3386 return ret; |
|
3387 |
|
3388 }, |
|
3389 |
|
3390 /* Be careful with the following core functions */ |
|
3391 _intersectsWith: function(item) { |
|
3392 |
|
3393 var x1 = this.positionAbs.left, |
|
3394 x2 = x1 + this.helperProportions.width, |
|
3395 y1 = this.positionAbs.top, |
|
3396 y2 = y1 + this.helperProportions.height; |
|
3397 |
|
3398 var l = item.left, |
|
3399 r = l + item.width, |
|
3400 t = item.top, |
|
3401 b = t + item.height; |
|
3402 |
|
3403 var dyClick = this.offset.click.top, |
|
3404 dxClick = this.offset.click.left; |
|
3405 |
|
3406 var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; |
|
3407 |
|
3408 if( this.options.tolerance == "pointer" |
|
3409 || this.options.forcePointerForContainers |
|
3410 || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height']) |
|
3411 ) { |
|
3412 return isOverElement; |
|
3413 } else { |
|
3414 |
|
3415 return (l < x1 + (this.helperProportions.width / 2) // Right Half |
|
3416 && x2 - (this.helperProportions.width / 2) < r // Left Half |
|
3417 && t < y1 + (this.helperProportions.height / 2) // Bottom Half |
|
3418 && y2 - (this.helperProportions.height / 2) < b ); // Top Half |
|
3419 |
|
3420 } |
|
3421 }, |
|
3422 |
|
3423 _intersectsWithPointer: function(item) { |
|
3424 |
|
3425 var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), |
|
3426 isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), |
|
3427 isOverElement = isOverElementHeight && isOverElementWidth, |
|
3428 verticalDirection = this._getDragVerticalDirection(), |
|
3429 horizontalDirection = this._getDragHorizontalDirection(); |
|
3430 |
|
3431 if (!isOverElement) |
|
3432 return false; |
|
3433 |
|
3434 return this.floating ? |
|
3435 ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 ) |
|
3436 : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) ); |
|
3437 |
|
3438 }, |
|
3439 |
|
3440 _intersectsWithSides: function(item) { |
|
3441 |
|
3442 var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), |
|
3443 isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), |
|
3444 verticalDirection = this._getDragVerticalDirection(), |
|
3445 horizontalDirection = this._getDragHorizontalDirection(); |
|
3446 |
|
3447 if (this.floating && horizontalDirection) { |
|
3448 return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf)); |
|
3449 } else { |
|
3450 return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf)); |
|
3451 } |
|
3452 |
|
3453 }, |
|
3454 |
|
3455 _getDragVerticalDirection: function() { |
|
3456 var delta = this.positionAbs.top - this.lastPositionAbs.top; |
|
3457 return delta != 0 && (delta > 0 ? "down" : "up"); |
|
3458 }, |
|
3459 |
|
3460 _getDragHorizontalDirection: function() { |
|
3461 var delta = this.positionAbs.left - this.lastPositionAbs.left; |
|
3462 return delta != 0 && (delta > 0 ? "right" : "left"); |
|
3463 }, |
|
3464 |
|
3465 refresh: function(event) { |
|
3466 this._refreshItems(event); |
|
3467 this.refreshPositions(); |
|
3468 return this; |
|
3469 }, |
|
3470 |
|
3471 _connectWith: function() { |
|
3472 var options = this.options; |
|
3473 return options.connectWith.constructor == String |
|
3474 ? [options.connectWith] |
|
3475 : options.connectWith; |
|
3476 }, |
|
3477 |
|
3478 _getItemsAsjQuery: function(connected) { |
|
3479 |
|
3480 var self = this; |
|
3481 var items = []; |
|
3482 var queries = []; |
|
3483 var connectWith = this._connectWith(); |
|
3484 |
|
3485 if(connectWith && connected) { |
|
3486 for (var i = connectWith.length - 1; i >= 0; i--){ |
|
3487 var cur = $(connectWith[i]); |
|
3488 for (var j = cur.length - 1; j >= 0; j--){ |
|
3489 var inst = $.data(cur[j], 'sortable'); |
|
3490 if(inst && inst != this && !inst.options.disabled) { |
|
3491 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]); |
|
3492 } |
|
3493 }; |
|
3494 }; |
|
3495 } |
|
3496 |
|
3497 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), this]); |
|
3498 |
|
3499 for (var i = queries.length - 1; i >= 0; i--){ |
|
3500 queries[i][0].each(function() { |
|
3501 items.push(this); |
|
3502 }); |
|
3503 }; |
|
3504 |
|
3505 return $(items); |
|
3506 |
|
3507 }, |
|
3508 |
|
3509 _removeCurrentsFromItems: function() { |
|
3510 |
|
3511 var list = this.currentItem.find(":data(sortable-item)"); |
|
3512 |
|
3513 for (var i=0; i < this.items.length; i++) { |
|
3514 |
|
3515 for (var j=0; j < list.length; j++) { |
|
3516 if(list[j] == this.items[i].item[0]) |
|
3517 this.items.splice(i,1); |
|
3518 }; |
|
3519 |
|
3520 }; |
|
3521 |
|
3522 }, |
|
3523 |
|
3524 _refreshItems: function(event) { |
|
3525 |
|
3526 this.items = []; |
|
3527 this.containers = [this]; |
|
3528 var items = this.items; |
|
3529 var self = this; |
|
3530 var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; |
|
3531 var connectWith = this._connectWith(); |
|
3532 |
|
3533 if(connectWith) { |
|
3534 for (var i = connectWith.length - 1; i >= 0; i--){ |
|
3535 var cur = $(connectWith[i]); |
|
3536 for (var j = cur.length - 1; j >= 0; j--){ |
|
3537 var inst = $.data(cur[j], 'sortable'); |
|
3538 if(inst && inst != this && !inst.options.disabled) { |
|
3539 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); |
|
3540 this.containers.push(inst); |
|
3541 } |
|
3542 }; |
|
3543 }; |
|
3544 } |
|
3545 |
|
3546 for (var i = queries.length - 1; i >= 0; i--) { |
|
3547 var targetData = queries[i][1]; |
|
3548 var _queries = queries[i][0]; |
|
3549 |
|
3550 for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) { |
|
3551 var item = $(_queries[j]); |
|
3552 |
|
3553 item.data('sortable-item', targetData); // Data for target checking (mouse manager) |
|
3554 |
|
3555 items.push({ |
|
3556 item: item, |
|
3557 instance: targetData, |
|
3558 width: 0, height: 0, |
|
3559 left: 0, top: 0 |
|
3560 }); |
|
3561 }; |
|
3562 }; |
|
3563 |
|
3564 }, |
|
3565 |
|
3566 refreshPositions: function(fast) { |
|
3567 |
|
3568 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change |
|
3569 if(this.offsetParent && this.helper) { |
|
3570 this.offset.parent = this._getParentOffset(); |
|
3571 } |
|
3572 |
|
3573 for (var i = this.items.length - 1; i >= 0; i--){ |
|
3574 var item = this.items[i]; |
|
3575 |
|
3576 var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; |
|
3577 |
|
3578 if (!fast) { |
|
3579 item.width = t.outerWidth(); |
|
3580 item.height = t.outerHeight(); |
|
3581 } |
|
3582 |
|
3583 var p = t.offset(); |
|
3584 item.left = p.left; |
|
3585 item.top = p.top; |
|
3586 }; |
|
3587 |
|
3588 if(this.options.custom && this.options.custom.refreshContainers) { |
|
3589 this.options.custom.refreshContainers.call(this); |
|
3590 } else { |
|
3591 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3592 var p = this.containers[i].element.offset(); |
|
3593 this.containers[i].containerCache.left = p.left; |
|
3594 this.containers[i].containerCache.top = p.top; |
|
3595 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
|
3596 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
|
3597 }; |
|
3598 } |
|
3599 |
|
3600 return this; |
|
3601 }, |
|
3602 |
|
3603 _createPlaceholder: function(that) { |
|
3604 |
|
3605 var self = that || this, o = self.options; |
|
3606 |
|
3607 if(!o.placeholder || o.placeholder.constructor == String) { |
|
3608 var className = o.placeholder; |
|
3609 o.placeholder = { |
|
3610 element: function() { |
|
3611 |
|
3612 var el = $(document.createElement(self.currentItem[0].nodeName)) |
|
3613 .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder") |
|
3614 .removeClass("ui-sortable-helper")[0]; |
|
3615 |
|
3616 if(!className) |
|
3617 el.style.visibility = "hidden"; |
|
3618 |
|
3619 return el; |
|
3620 }, |
|
3621 update: function(container, p) { |
|
3622 |
|
3623 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that |
|
3624 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified |
|
3625 if(className && !o.forcePlaceholderSize) return; |
|
3626 |
|
3627 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item |
|
3628 if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); }; |
|
3629 if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); }; |
|
3630 } |
|
3631 }; |
|
3632 } |
|
3633 |
|
3634 //Create the placeholder |
|
3635 self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)); |
|
3636 |
|
3637 //Append it after the actual current item |
|
3638 self.currentItem.after(self.placeholder); |
|
3639 |
|
3640 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) |
|
3641 o.placeholder.update(self, self.placeholder); |
|
3642 |
|
3643 }, |
|
3644 |
|
3645 _contactContainers: function(event) { |
|
3646 |
|
3647 // get innermost container that intersects with item |
|
3648 var innermostContainer = null, innermostIndex = null; |
|
3649 |
|
3650 |
|
3651 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3652 |
|
3653 // never consider a container that's located within the item itself |
|
3654 if($.ui.contains(this.currentItem[0], this.containers[i].element[0])) |
|
3655 continue; |
|
3656 |
|
3657 if(this._intersectsWith(this.containers[i].containerCache)) { |
|
3658 |
|
3659 // if we've already found a container and it's more "inner" than this, then continue |
|
3660 if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0])) |
|
3661 continue; |
|
3662 |
|
3663 innermostContainer = this.containers[i]; |
|
3664 innermostIndex = i; |
|
3665 |
|
3666 } else { |
|
3667 // container doesn't intersect. trigger "out" event if necessary |
|
3668 if(this.containers[i].containerCache.over) { |
|
3669 this.containers[i]._trigger("out", event, this._uiHash(this)); |
|
3670 this.containers[i].containerCache.over = 0; |
|
3671 } |
|
3672 } |
|
3673 |
|
3674 } |
|
3675 |
|
3676 // if no intersecting containers found, return |
|
3677 if(!innermostContainer) return; |
|
3678 |
|
3679 // move the item into the container if it's not there already |
|
3680 if(this.containers.length === 1) { |
|
3681 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
3682 this.containers[innermostIndex].containerCache.over = 1; |
|
3683 } else if(this.currentContainer != this.containers[innermostIndex]) { |
|
3684 |
|
3685 //When entering a new container, we will find the item with the least distance and append our item near it |
|
3686 var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top']; |
|
3687 for (var j = this.items.length - 1; j >= 0; j--) { |
|
3688 if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue; |
|
3689 var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top']; |
|
3690 if(Math.abs(cur - base) < dist) { |
|
3691 dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; |
|
3692 } |
|
3693 } |
|
3694 |
|
3695 if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled |
|
3696 return; |
|
3697 |
|
3698 this.currentContainer = this.containers[innermostIndex]; |
|
3699 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); |
|
3700 this._trigger("change", event, this._uiHash()); |
|
3701 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); |
|
3702 |
|
3703 //Update the placeholder |
|
3704 this.options.placeholder.update(this.currentContainer, this.placeholder); |
|
3705 |
|
3706 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
3707 this.containers[innermostIndex].containerCache.over = 1; |
|
3708 } |
|
3709 |
|
3710 |
|
3711 }, |
|
3712 |
|
3713 _createHelper: function(event) { |
|
3714 |
|
3715 var o = this.options; |
|
3716 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem); |
|
3717 |
|
3718 if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already |
|
3719 $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); |
|
3720 |
|
3721 if(helper[0] == this.currentItem[0]) |
|
3722 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; |
|
3723 |
|
3724 if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width()); |
|
3725 if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height()); |
|
3726 |
|
3727 return helper; |
|
3728 |
|
3729 }, |
|
3730 |
|
3731 _adjustOffsetFromHelper: function(obj) { |
|
3732 if (typeof obj == 'string') { |
|
3733 obj = obj.split(' '); |
|
3734 } |
|
3735 if ($.isArray(obj)) { |
|
3736 obj = {left: +obj[0], top: +obj[1] || 0}; |
|
3737 } |
|
3738 if ('left' in obj) { |
|
3739 this.offset.click.left = obj.left + this.margins.left; |
|
3740 } |
|
3741 if ('right' in obj) { |
|
3742 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
3743 } |
|
3744 if ('top' in obj) { |
|
3745 this.offset.click.top = obj.top + this.margins.top; |
|
3746 } |
|
3747 if ('bottom' in obj) { |
|
3748 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
3749 } |
|
3750 }, |
|
3751 |
|
3752 _getParentOffset: function() { |
|
3753 |
|
3754 |
|
3755 //Get the offsetParent and cache its position |
|
3756 this.offsetParent = this.helper.offsetParent(); |
|
3757 var po = this.offsetParent.offset(); |
|
3758 |
|
3759 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
3760 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
3761 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
3762 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
3763 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
3764 po.left += this.scrollParent.scrollLeft(); |
|
3765 po.top += this.scrollParent.scrollTop(); |
|
3766 } |
|
3767 |
|
3768 if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
3769 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
|
3770 po = { top: 0, left: 0 }; |
|
3771 |
|
3772 return { |
|
3773 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
3774 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
3775 }; |
|
3776 |
|
3777 }, |
|
3778 |
|
3779 _getRelativeOffset: function() { |
|
3780 |
|
3781 if(this.cssPosition == "relative") { |
|
3782 var p = this.currentItem.position(); |
|
3783 return { |
|
3784 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
3785 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
3786 }; |
|
3787 } else { |
|
3788 return { top: 0, left: 0 }; |
|
3789 } |
|
3790 |
|
3791 }, |
|
3792 |
|
3793 _cacheMargins: function() { |
|
3794 this.margins = { |
|
3795 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
|
3796 top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
|
3797 }; |
|
3798 }, |
|
3799 |
|
3800 _cacheHelperProportions: function() { |
|
3801 this.helperProportions = { |
|
3802 width: this.helper.outerWidth(), |
|
3803 height: this.helper.outerHeight() |
|
3804 }; |
|
3805 }, |
|
3806 |
|
3807 _setContainment: function() { |
|
3808 |
|
3809 var o = this.options; |
|
3810 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|
3811 if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
|
3812 0 - this.offset.relative.left - this.offset.parent.left, |
|
3813 0 - this.offset.relative.top - this.offset.parent.top, |
|
3814 $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
3815 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
3816 ]; |
|
3817 |
|
3818 if(!(/^(document|window|parent)$/).test(o.containment)) { |
|
3819 var ce = $(o.containment)[0]; |
|
3820 var co = $(o.containment).offset(); |
|
3821 var over = ($(ce).css("overflow") != 'hidden'); |
|
3822 |
|
3823 this.containment = [ |
|
3824 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
3825 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
3826 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
3827 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
3828 ]; |
|
3829 } |
|
3830 |
|
3831 }, |
|
3832 |
|
3833 _convertPositionTo: function(d, pos) { |
|
3834 |
|
3835 if(!pos) pos = this.position; |
|
3836 var mod = d == "absolute" ? 1 : -1; |
|
3837 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
3838 |
|
3839 return { |
|
3840 top: ( |
|
3841 pos.top // The absolute mouse position |
|
3842 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3843 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
|
3844 - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) |
|
3845 ), |
|
3846 left: ( |
|
3847 pos.left // The absolute mouse position |
|
3848 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3849 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
|
3850 - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) |
|
3851 ) |
|
3852 }; |
|
3853 |
|
3854 }, |
|
3855 |
|
3856 _generatePosition: function(event) { |
|
3857 |
|
3858 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
3859 |
|
3860 // This is another very weird special case that only happens for relative elements: |
|
3861 // 1. If the css position is relative |
|
3862 // 2. and the scroll parent is the document or similar to the offset parent |
|
3863 // we have to refresh the relative offset during the scroll so there are no jumps |
|
3864 if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) { |
|
3865 this.offset.relative = this._getRelativeOffset(); |
|
3866 } |
|
3867 |
|
3868 var pageX = event.pageX; |
|
3869 var pageY = event.pageY; |
|
3870 |
|
3871 /* |
|
3872 * - Position constraining - |
|
3873 * Constrain the position to a mix of grid, containment. |
|
3874 */ |
|
3875 |
|
3876 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
3877 |
|
3878 if(this.containment) { |
|
3879 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
|
3880 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
|
3881 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
|
3882 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
|
3883 } |
|
3884 |
|
3885 if(o.grid) { |
|
3886 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
3887 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
3888 |
|
3889 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
3890 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
3891 } |
|
3892 |
|
3893 } |
|
3894 |
|
3895 return { |
|
3896 top: ( |
|
3897 pageY // The absolute mouse position |
|
3898 - this.offset.click.top // Click offset (relative to the element) |
|
3899 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3900 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
|
3901 + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) |
|
3902 ), |
|
3903 left: ( |
|
3904 pageX // The absolute mouse position |
|
3905 - this.offset.click.left // Click offset (relative to the element) |
|
3906 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3907 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
|
3908 + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) |
|
3909 ) |
|
3910 }; |
|
3911 |
|
3912 }, |
|
3913 |
|
3914 _rearrange: function(event, i, a, hardRefresh) { |
|
3915 |
|
3916 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling)); |
|
3917 |
|
3918 //Various things done here to improve the performance: |
|
3919 // 1. we create a setTimeout, that calls refreshPositions |
|
3920 // 2. on the instance, we have a counter variable, that get's higher after every append |
|
3921 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same |
|
3922 // 4. this lets only the last addition to the timeout stack through |
|
3923 this.counter = this.counter ? ++this.counter : 1; |
|
3924 var self = this, counter = this.counter; |
|
3925 |
|
3926 window.setTimeout(function() { |
|
3927 if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove |
|
3928 },0); |
|
3929 |
|
3930 }, |
|
3931 |
|
3932 _clear: function(event, noPropagation) { |
|
3933 |
|
3934 this.reverting = false; |
|
3935 // We delay all events that have to be triggered to after the point where the placeholder has been removed and |
|
3936 // everything else normalized again |
|
3937 var delayedTriggers = [], self = this; |
|
3938 |
|
3939 // We first have to update the dom position of the actual currentItem |
|
3940 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) |
|
3941 if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem); |
|
3942 this._noFinalSort = null; |
|
3943 |
|
3944 if(this.helper[0] == this.currentItem[0]) { |
|
3945 for(var i in this._storedCSS) { |
|
3946 if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = ''; |
|
3947 } |
|
3948 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
3949 } else { |
|
3950 this.currentItem.show(); |
|
3951 } |
|
3952 |
|
3953 if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); |
|
3954 if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed |
|
3955 if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element |
|
3956 if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); |
|
3957 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3958 if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) { |
|
3959 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3960 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3961 } |
|
3962 }; |
|
3963 }; |
|
3964 |
|
3965 //Post events to containers |
|
3966 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3967 if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3968 if(this.containers[i].containerCache.over) { |
|
3969 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3970 this.containers[i].containerCache.over = 0; |
|
3971 } |
|
3972 } |
|
3973 |
|
3974 //Do what was originally in plugins |
|
3975 if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor |
|
3976 if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity |
|
3977 if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index |
|
3978 |
|
3979 this.dragging = false; |
|
3980 if(this.cancelHelperRemoval) { |
|
3981 if(!noPropagation) { |
|
3982 this._trigger("beforeStop", event, this._uiHash()); |
|
3983 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events |
|
3984 this._trigger("stop", event, this._uiHash()); |
|
3985 } |
|
3986 return false; |
|
3987 } |
|
3988 |
|
3989 if(!noPropagation) this._trigger("beforeStop", event, this._uiHash()); |
|
3990 |
|
3991 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
3992 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
3993 |
|
3994 if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null; |
|
3995 |
|
3996 if(!noPropagation) { |
|
3997 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events |
|
3998 this._trigger("stop", event, this._uiHash()); |
|
3999 } |
|
4000 |
|
4001 this.fromOutside = false; |
|
4002 return true; |
|
4003 |
|
4004 }, |
|
4005 |
|
4006 _trigger: function() { |
|
4007 if ($.Widget.prototype._trigger.apply(this, arguments) === false) { |
|
4008 this.cancel(); |
|
4009 } |
|
4010 }, |
|
4011 |
|
4012 _uiHash: function(inst) { |
|
4013 var self = inst || this; |
|
4014 return { |
|
4015 helper: self.helper, |
|
4016 placeholder: self.placeholder || $([]), |
|
4017 position: self.position, |
|
4018 originalPosition: self.originalPosition, |
|
4019 offset: self.positionAbs, |
|
4020 item: self.currentItem, |
|
4021 sender: inst ? inst.element : null |
|
4022 }; |
|
4023 } |
|
4024 |
|
4025 }); |
|
4026 |
|
4027 $.extend($.ui.sortable, { |
|
4028 version: "1.8.1" |
|
4029 }); |
|
4030 |
|
4031 })(jQuery); |
|
4032 /* |
|
4033 * jQuery UI Accordion 1.8.1 |
|
4034 * |
|
4035 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
4036 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
4037 * and GPL (GPL-LICENSE.txt) licenses. |
|
4038 * |
|
4039 * http://docs.jquery.com/UI/Accordion |
|
4040 * |
|
4041 * Depends: |
|
4042 * jquery.ui.core.js |
|
4043 * jquery.ui.widget.js |
|
4044 */ |
|
4045 (function($) { |
|
4046 |
|
4047 $.widget("ui.accordion", { |
|
4048 options: { |
|
4049 active: 0, |
|
4050 animated: 'slide', |
|
4051 autoHeight: true, |
|
4052 clearStyle: false, |
|
4053 collapsible: false, |
|
4054 event: "click", |
|
4055 fillSpace: false, |
|
4056 header: "> li > :first-child,> :not(li):even", |
|
4057 icons: { |
|
4058 header: "ui-icon-triangle-1-e", |
|
4059 headerSelected: "ui-icon-triangle-1-s" |
|
4060 }, |
|
4061 navigation: false, |
|
4062 navigationFilter: function() { |
|
4063 return this.href.toLowerCase() == location.href.toLowerCase(); |
|
4064 } |
|
4065 }, |
|
4066 _create: function() { |
|
4067 |
|
4068 var o = this.options, self = this; |
|
4069 this.running = 0; |
|
4070 |
|
4071 this.element.addClass("ui-accordion ui-widget ui-helper-reset"); |
|
4072 |
|
4073 // in lack of child-selectors in CSS we need to mark top-LIs in a UL-accordion for some IE-fix |
|
4074 if (this.element[0].nodeName == "UL") { |
|
4075 this.element.children("li").addClass("ui-accordion-li-fix"); |
|
4076 } |
|
4077 |
|
4078 this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all") |
|
4079 .bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); }) |
|
4080 .bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); }) |
|
4081 .bind("focus.accordion", function(){ $(this).addClass('ui-state-focus'); }) |
|
4082 .bind("blur.accordion", function(){ $(this).removeClass('ui-state-focus'); }); |
|
4083 |
|
4084 this.headers |
|
4085 .next() |
|
4086 .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); |
|
4087 |
|
4088 if ( o.navigation ) { |
|
4089 var current = this.element.find("a").filter(o.navigationFilter); |
|
4090 if ( current.length ) { |
|
4091 var header = current.closest(".ui-accordion-header"); |
|
4092 if ( header.length ) { |
|
4093 // anchor within header |
|
4094 this.active = header; |
|
4095 } else { |
|
4096 // anchor within content |
|
4097 this.active = current.closest(".ui-accordion-content").prev(); |
|
4098 } |
|
4099 } |
|
4100 } |
|
4101 |
|
4102 this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"); |
|
4103 this.active.next().addClass('ui-accordion-content-active'); |
|
4104 |
|
4105 //Append icon elements |
|
4106 this._createIcons(); |
|
4107 |
|
4108 this.resize(); |
|
4109 |
|
4110 //ARIA |
|
4111 this.element.attr('role','tablist'); |
|
4112 |
|
4113 this.headers |
|
4114 .attr('role','tab') |
|
4115 .bind('keydown', function(event) { return self._keydown(event); }) |
|
4116 .next() |
|
4117 .attr('role','tabpanel'); |
|
4118 |
|
4119 this.headers |
|
4120 .not(this.active || "") |
|
4121 .attr('aria-expanded','false') |
|
4122 .attr("tabIndex", "-1") |
|
4123 .next() |
|
4124 .hide(); |
|
4125 |
|
4126 // make sure at least one header is in the tab order |
|
4127 if (!this.active.length) { |
|
4128 this.headers.eq(0).attr('tabIndex','0'); |
|
4129 } else { |
|
4130 this.active |
|
4131 .attr('aria-expanded','true') |
|
4132 .attr('tabIndex', '0'); |
|
4133 } |
|
4134 |
|
4135 // only need links in taborder for Safari |
|
4136 if (!$.browser.safari) |
|
4137 this.headers.find('a').attr('tabIndex','-1'); |
|
4138 |
|
4139 if (o.event) { |
|
4140 this.headers.bind((o.event) + ".accordion", function(event) { |
|
4141 self._clickHandler.call(self, event, this); |
|
4142 event.preventDefault(); |
|
4143 }); |
|
4144 } |
|
4145 |
|
4146 }, |
|
4147 |
|
4148 _createIcons: function() { |
|
4149 var o = this.options; |
|
4150 if (o.icons) { |
|
4151 $("<span/>").addClass("ui-icon " + o.icons.header).prependTo(this.headers); |
|
4152 this.active.find(".ui-icon").toggleClass(o.icons.header).toggleClass(o.icons.headerSelected); |
|
4153 this.element.addClass("ui-accordion-icons"); |
|
4154 } |
|
4155 }, |
|
4156 |
|
4157 _destroyIcons: function() { |
|
4158 this.headers.children(".ui-icon").remove(); |
|
4159 this.element.removeClass("ui-accordion-icons"); |
|
4160 }, |
|
4161 |
|
4162 destroy: function() { |
|
4163 var o = this.options; |
|
4164 |
|
4165 this.element |
|
4166 .removeClass("ui-accordion ui-widget ui-helper-reset") |
|
4167 .removeAttr("role") |
|
4168 .unbind('.accordion') |
|
4169 .removeData('accordion'); |
|
4170 |
|
4171 this.headers |
|
4172 .unbind(".accordion") |
|
4173 .removeClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-corner-top") |
|
4174 .removeAttr("role").removeAttr("aria-expanded").removeAttr("tabIndex"); |
|
4175 |
|
4176 this.headers.find("a").removeAttr("tabIndex"); |
|
4177 this._destroyIcons(); |
|
4178 var contents = this.headers.next().css("display", "").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active"); |
|
4179 if (o.autoHeight || o.fillHeight) { |
|
4180 contents.css("height", ""); |
|
4181 } |
|
4182 |
|
4183 return this; |
|
4184 }, |
|
4185 |
|
4186 _setOption: function(key, value) { |
|
4187 $.Widget.prototype._setOption.apply(this, arguments); |
|
4188 |
|
4189 if (key == "active") { |
|
4190 this.activate(value); |
|
4191 } |
|
4192 if (key == "icons") { |
|
4193 this._destroyIcons(); |
|
4194 if (value) { |
|
4195 this._createIcons(); |
|
4196 } |
|
4197 } |
|
4198 |
|
4199 }, |
|
4200 |
|
4201 _keydown: function(event) { |
|
4202 |
|
4203 var o = this.options, keyCode = $.ui.keyCode; |
|
4204 |
|
4205 if (o.disabled || event.altKey || event.ctrlKey) |
|
4206 return; |
|
4207 |
|
4208 var length = this.headers.length; |
|
4209 var currentIndex = this.headers.index(event.target); |
|
4210 var toFocus = false; |
|
4211 |
|
4212 switch(event.keyCode) { |
|
4213 case keyCode.RIGHT: |
|
4214 case keyCode.DOWN: |
|
4215 toFocus = this.headers[(currentIndex + 1) % length]; |
|
4216 break; |
|
4217 case keyCode.LEFT: |
|
4218 case keyCode.UP: |
|
4219 toFocus = this.headers[(currentIndex - 1 + length) % length]; |
|
4220 break; |
|
4221 case keyCode.SPACE: |
|
4222 case keyCode.ENTER: |
|
4223 this._clickHandler({ target: event.target }, event.target); |
|
4224 event.preventDefault(); |
|
4225 } |
|
4226 |
|
4227 if (toFocus) { |
|
4228 $(event.target).attr('tabIndex','-1'); |
|
4229 $(toFocus).attr('tabIndex','0'); |
|
4230 toFocus.focus(); |
|
4231 return false; |
|
4232 } |
|
4233 |
|
4234 return true; |
|
4235 |
|
4236 }, |
|
4237 |
|
4238 resize: function() { |
|
4239 |
|
4240 var o = this.options, maxHeight; |
|
4241 |
|
4242 if (o.fillSpace) { |
|
4243 |
|
4244 if($.browser.msie) { var defOverflow = this.element.parent().css('overflow'); this.element.parent().css('overflow', 'hidden'); } |
|
4245 maxHeight = this.element.parent().height(); |
|
4246 if($.browser.msie) { this.element.parent().css('overflow', defOverflow); } |
|
4247 |
|
4248 this.headers.each(function() { |
|
4249 maxHeight -= $(this).outerHeight(true); |
|
4250 }); |
|
4251 |
|
4252 this.headers.next().each(function() { |
|
4253 $(this).height(Math.max(0, maxHeight - $(this).innerHeight() + $(this).height())); |
|
4254 }).css('overflow', 'auto'); |
|
4255 |
|
4256 } else if ( o.autoHeight ) { |
|
4257 maxHeight = 0; |
|
4258 this.headers.next().each(function() { |
|
4259 maxHeight = Math.max(maxHeight, $(this).height()); |
|
4260 }).height(maxHeight); |
|
4261 } |
|
4262 |
|
4263 return this; |
|
4264 }, |
|
4265 |
|
4266 activate: function(index) { |
|
4267 // TODO this gets called on init, changing the option without an explicit call for that |
|
4268 this.options.active = index; |
|
4269 // call clickHandler with custom event |
|
4270 var active = this._findActive(index)[0]; |
|
4271 this._clickHandler({ target: active }, active); |
|
4272 |
|
4273 return this; |
|
4274 }, |
|
4275 |
|
4276 _findActive: function(selector) { |
|
4277 return selector |
|
4278 ? typeof selector == "number" |
|
4279 ? this.headers.filter(":eq(" + selector + ")") |
|
4280 : this.headers.not(this.headers.not(selector)) |
|
4281 : selector === false |
|
4282 ? $([]) |
|
4283 : this.headers.filter(":eq(0)"); |
|
4284 }, |
|
4285 |
|
4286 // TODO isn't event.target enough? why the seperate target argument? |
|
4287 _clickHandler: function(event, target) { |
|
4288 |
|
4289 var o = this.options; |
|
4290 if (o.disabled) |
|
4291 return; |
|
4292 |
|
4293 // called only when using activate(false) to close all parts programmatically |
|
4294 if (!event.target) { |
|
4295 if (!o.collapsible) |
|
4296 return; |
|
4297 this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") |
|
4298 .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); |
|
4299 this.active.next().addClass('ui-accordion-content-active'); |
|
4300 var toHide = this.active.next(), |
|
4301 data = { |
|
4302 options: o, |
|
4303 newHeader: $([]), |
|
4304 oldHeader: o.active, |
|
4305 newContent: $([]), |
|
4306 oldContent: toHide |
|
4307 }, |
|
4308 toShow = (this.active = $([])); |
|
4309 this._toggle(toShow, toHide, data); |
|
4310 return; |
|
4311 } |
|
4312 |
|
4313 // get the click target |
|
4314 var clicked = $(event.currentTarget || target); |
|
4315 var clickedIsActive = clicked[0] == this.active[0]; |
|
4316 |
|
4317 // TODO the option is changed, is that correct? |
|
4318 // TODO if it is correct, shouldn't that happen after determining that the click is valid? |
|
4319 o.active = o.collapsible && clickedIsActive ? false : $('.ui-accordion-header', this.element).index(clicked); |
|
4320 |
|
4321 // if animations are still active, or the active header is the target, ignore click |
|
4322 if (this.running || (!o.collapsible && clickedIsActive)) { |
|
4323 return; |
|
4324 } |
|
4325 |
|
4326 // switch classes |
|
4327 this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") |
|
4328 .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); |
|
4329 if (!clickedIsActive) { |
|
4330 clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top") |
|
4331 .find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected); |
|
4332 clicked.next().addClass('ui-accordion-content-active'); |
|
4333 } |
|
4334 |
|
4335 // find elements to show and hide |
|
4336 var toShow = clicked.next(), |
|
4337 toHide = this.active.next(), |
|
4338 data = { |
|
4339 options: o, |
|
4340 newHeader: clickedIsActive && o.collapsible ? $([]) : clicked, |
|
4341 oldHeader: this.active, |
|
4342 newContent: clickedIsActive && o.collapsible ? $([]) : toShow, |
|
4343 oldContent: toHide |
|
4344 }, |
|
4345 down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] ); |
|
4346 |
|
4347 this.active = clickedIsActive ? $([]) : clicked; |
|
4348 this._toggle(toShow, toHide, data, clickedIsActive, down); |
|
4349 |
|
4350 return; |
|
4351 |
|
4352 }, |
|
4353 |
|
4354 _toggle: function(toShow, toHide, data, clickedIsActive, down) { |
|
4355 |
|
4356 var o = this.options, self = this; |
|
4357 |
|
4358 this.toShow = toShow; |
|
4359 this.toHide = toHide; |
|
4360 this.data = data; |
|
4361 |
|
4362 var complete = function() { if(!self) return; return self._completed.apply(self, arguments); }; |
|
4363 |
|
4364 // trigger changestart event |
|
4365 this._trigger("changestart", null, this.data); |
|
4366 |
|
4367 // count elements to animate |
|
4368 this.running = toHide.size() === 0 ? toShow.size() : toHide.size(); |
|
4369 |
|
4370 if (o.animated) { |
|
4371 |
|
4372 var animOptions = {}; |
|
4373 |
|
4374 if ( o.collapsible && clickedIsActive ) { |
|
4375 animOptions = { |
|
4376 toShow: $([]), |
|
4377 toHide: toHide, |
|
4378 complete: complete, |
|
4379 down: down, |
|
4380 autoHeight: o.autoHeight || o.fillSpace |
|
4381 }; |
|
4382 } else { |
|
4383 animOptions = { |
|
4384 toShow: toShow, |
|
4385 toHide: toHide, |
|
4386 complete: complete, |
|
4387 down: down, |
|
4388 autoHeight: o.autoHeight || o.fillSpace |
|
4389 }; |
|
4390 } |
|
4391 |
|
4392 if (!o.proxied) { |
|
4393 o.proxied = o.animated; |
|
4394 } |
|
4395 |
|
4396 if (!o.proxiedDuration) { |
|
4397 o.proxiedDuration = o.duration; |
|
4398 } |
|
4399 |
|
4400 o.animated = $.isFunction(o.proxied) ? |
|
4401 o.proxied(animOptions) : o.proxied; |
|
4402 |
|
4403 o.duration = $.isFunction(o.proxiedDuration) ? |
|
4404 o.proxiedDuration(animOptions) : o.proxiedDuration; |
|
4405 |
|
4406 var animations = $.ui.accordion.animations, |
|
4407 duration = o.duration, |
|
4408 easing = o.animated; |
|
4409 |
|
4410 if (easing && !animations[easing] && !$.easing[easing]) { |
|
4411 easing = 'slide'; |
|
4412 } |
|
4413 if (!animations[easing]) { |
|
4414 animations[easing] = function(options) { |
|
4415 this.slide(options, { |
|
4416 easing: easing, |
|
4417 duration: duration || 700 |
|
4418 }); |
|
4419 }; |
|
4420 } |
|
4421 |
|
4422 animations[easing](animOptions); |
|
4423 |
|
4424 } else { |
|
4425 |
|
4426 if (o.collapsible && clickedIsActive) { |
|
4427 toShow.toggle(); |
|
4428 } else { |
|
4429 toHide.hide(); |
|
4430 toShow.show(); |
|
4431 } |
|
4432 |
|
4433 complete(true); |
|
4434 |
|
4435 } |
|
4436 |
|
4437 // TODO assert that the blur and focus triggers are really necessary, remove otherwise |
|
4438 toHide.prev().attr('aria-expanded','false').attr("tabIndex", "-1").blur(); |
|
4439 toShow.prev().attr('aria-expanded','true').attr("tabIndex", "0").focus(); |
|
4440 |
|
4441 }, |
|
4442 |
|
4443 _completed: function(cancel) { |
|
4444 |
|
4445 var o = this.options; |
|
4446 |
|
4447 this.running = cancel ? 0 : --this.running; |
|
4448 if (this.running) return; |
|
4449 |
|
4450 if (o.clearStyle) { |
|
4451 this.toShow.add(this.toHide).css({ |
|
4452 height: "", |
|
4453 overflow: "" |
|
4454 }); |
|
4455 } |
|
4456 |
|
4457 // other classes are removed before the animation; this one needs to stay until completed |
|
4458 this.toHide.removeClass("ui-accordion-content-active"); |
|
4459 |
|
4460 this._trigger('change', null, this.data); |
|
4461 } |
|
4462 |
|
4463 }); |
|
4464 |
|
4465 |
|
4466 $.extend($.ui.accordion, { |
|
4467 version: "1.8.1", |
|
4468 animations: { |
|
4469 slide: function(options, additions) { |
|
4470 options = $.extend({ |
|
4471 easing: "swing", |
|
4472 duration: 300 |
|
4473 }, options, additions); |
|
4474 if ( !options.toHide.size() ) { |
|
4475 options.toShow.animate({height: "show"}, options); |
|
4476 return; |
|
4477 } |
|
4478 if ( !options.toShow.size() ) { |
|
4479 options.toHide.animate({height: "hide"}, options); |
|
4480 return; |
|
4481 } |
|
4482 var overflow = options.toShow.css('overflow'), |
|
4483 percentDone = 0, |
|
4484 showProps = {}, |
|
4485 hideProps = {}, |
|
4486 fxAttrs = [ "height", "paddingTop", "paddingBottom" ], |
|
4487 originalWidth; |
|
4488 // fix width before calculating height of hidden element |
|
4489 var s = options.toShow; |
|
4490 originalWidth = s[0].style.width; |
|
4491 s.width( parseInt(s.parent().width(),10) - parseInt(s.css("paddingLeft"),10) - parseInt(s.css("paddingRight"),10) - (parseInt(s.css("borderLeftWidth"),10) || 0) - (parseInt(s.css("borderRightWidth"),10) || 0) ); |
|
4492 |
|
4493 $.each(fxAttrs, function(i, prop) { |
|
4494 hideProps[prop] = 'hide'; |
|
4495 |
|
4496 var parts = ('' + $.css(options.toShow[0], prop)).match(/^([\d+-.]+)(.*)$/); |
|
4497 showProps[prop] = { |
|
4498 value: parts[1], |
|
4499 unit: parts[2] || 'px' |
|
4500 }; |
|
4501 }); |
|
4502 options.toShow.css({ height: 0, overflow: 'hidden' }).show(); |
|
4503 options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{ |
|
4504 step: function(now, settings) { |
|
4505 // only calculate the percent when animating height |
|
4506 // IE gets very inconsistent results when animating elements |
|
4507 // with small values, which is common for padding |
|
4508 if (settings.prop == 'height') { |
|
4509 percentDone = ( settings.end - settings.start === 0 ) ? 0 : |
|
4510 (settings.now - settings.start) / (settings.end - settings.start); |
|
4511 } |
|
4512 |
|
4513 options.toShow[0].style[settings.prop] = |
|
4514 (percentDone * showProps[settings.prop].value) + showProps[settings.prop].unit; |
|
4515 }, |
|
4516 duration: options.duration, |
|
4517 easing: options.easing, |
|
4518 complete: function() { |
|
4519 if ( !options.autoHeight ) { |
|
4520 options.toShow.css("height", ""); |
|
4521 } |
|
4522 options.toShow.css("width", originalWidth); |
|
4523 options.toShow.css({overflow: overflow}); |
|
4524 options.complete(); |
|
4525 } |
|
4526 }); |
|
4527 }, |
|
4528 bounceslide: function(options) { |
|
4529 this.slide(options, { |
|
4530 easing: options.down ? "easeOutBounce" : "swing", |
|
4531 duration: options.down ? 1000 : 200 |
|
4532 }); |
|
4533 } |
|
4534 } |
|
4535 }); |
|
4536 |
|
4537 })(jQuery); |
|
4538 /* |
|
4539 * jQuery UI Autocomplete 1.8.1 |
|
4540 * |
|
4541 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
4542 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
4543 * and GPL (GPL-LICENSE.txt) licenses. |
|
4544 * |
|
4545 * http://docs.jquery.com/UI/Autocomplete |
|
4546 * |
|
4547 * Depends: |
|
4548 * jquery.ui.core.js |
|
4549 * jquery.ui.widget.js |
|
4550 * jquery.ui.position.js |
|
4551 */ |
|
4552 (function( $ ) { |
|
4553 |
|
4554 $.widget( "ui.autocomplete", { |
|
4555 options: { |
|
4556 minLength: 1, |
|
4557 delay: 300 |
|
4558 }, |
|
4559 _create: function() { |
|
4560 var self = this, |
|
4561 doc = this.element[ 0 ].ownerDocument; |
|
4562 this.element |
|
4563 .addClass( "ui-autocomplete-input" ) |
|
4564 .attr( "autocomplete", "off" ) |
|
4565 // TODO verify these actually work as intended |
|
4566 .attr({ |
|
4567 role: "textbox", |
|
4568 "aria-autocomplete": "list", |
|
4569 "aria-haspopup": "true" |
|
4570 }) |
|
4571 .bind( "keydown.autocomplete", function( event ) { |
|
4572 var keyCode = $.ui.keyCode; |
|
4573 switch( event.keyCode ) { |
|
4574 case keyCode.PAGE_UP: |
|
4575 self._move( "previousPage", event ); |
|
4576 break; |
|
4577 case keyCode.PAGE_DOWN: |
|
4578 self._move( "nextPage", event ); |
|
4579 break; |
|
4580 case keyCode.UP: |
|
4581 self._move( "previous", event ); |
|
4582 // prevent moving cursor to beginning of text field in some browsers |
|
4583 event.preventDefault(); |
|
4584 break; |
|
4585 case keyCode.DOWN: |
|
4586 self._move( "next", event ); |
|
4587 // prevent moving cursor to end of text field in some browsers |
|
4588 event.preventDefault(); |
|
4589 break; |
|
4590 case keyCode.ENTER: |
|
4591 // when menu is open or has focus |
|
4592 if ( self.menu.active ) { |
|
4593 event.preventDefault(); |
|
4594 } |
|
4595 //passthrough - ENTER and TAB both select the current element |
|
4596 case keyCode.TAB: |
|
4597 if ( !self.menu.active ) { |
|
4598 return; |
|
4599 } |
|
4600 self.menu.select( event ); |
|
4601 break; |
|
4602 case keyCode.ESCAPE: |
|
4603 self.element.val( self.term ); |
|
4604 self.close( event ); |
|
4605 break; |
|
4606 case keyCode.LEFT: |
|
4607 case keyCode.RIGHT: |
|
4608 case keyCode.SHIFT: |
|
4609 case keyCode.CONTROL: |
|
4610 case keyCode.ALT: |
|
4611 // ignore metakeys (shift, ctrl, alt) |
|
4612 break; |
|
4613 default: |
|
4614 // keypress is triggered before the input value is changed |
|
4615 clearTimeout( self.searching ); |
|
4616 self.searching = setTimeout(function() { |
|
4617 self.search( null, event ); |
|
4618 }, self.options.delay ); |
|
4619 break; |
|
4620 } |
|
4621 }) |
|
4622 .bind( "focus.autocomplete", function() { |
|
4623 self.selectedItem = null; |
|
4624 self.previous = self.element.val(); |
|
4625 }) |
|
4626 .bind( "blur.autocomplete", function( event ) { |
|
4627 clearTimeout( self.searching ); |
|
4628 // clicks on the menu (or a button to trigger a search) will cause a blur event |
|
4629 // TODO try to implement this without a timeout, see clearTimeout in search() |
|
4630 self.closing = setTimeout(function() { |
|
4631 self.close( event ); |
|
4632 self._change( event ); |
|
4633 }, 150 ); |
|
4634 }); |
|
4635 this._initSource(); |
|
4636 this.response = function() { |
|
4637 return self._response.apply( self, arguments ); |
|
4638 }; |
|
4639 this.menu = $( "<ul></ul>" ) |
|
4640 .addClass( "ui-autocomplete" ) |
|
4641 .appendTo( "body", doc ) |
|
4642 .menu({ |
|
4643 focus: function( event, ui ) { |
|
4644 var item = ui.item.data( "item.autocomplete" ); |
|
4645 if ( false !== self._trigger( "focus", null, { item: item } ) ) { |
|
4646 // use value to match what will end up in the input, if it was a key event |
|
4647 if ( /^key/.test(event.originalEvent.type) ) { |
|
4648 self.element.val( item.value ); |
|
4649 } |
|
4650 } |
|
4651 }, |
|
4652 selected: function( event, ui ) { |
|
4653 var item = ui.item.data( "item.autocomplete" ); |
|
4654 if ( false !== self._trigger( "select", event, { item: item } ) ) { |
|
4655 self.element.val( item.value ); |
|
4656 } |
|
4657 self.close( event ); |
|
4658 // only trigger when focus was lost (click on menu) |
|
4659 var previous = self.previous; |
|
4660 if ( self.element[0] !== doc.activeElement ) { |
|
4661 self.element.focus(); |
|
4662 self.previous = previous; |
|
4663 } |
|
4664 self.selectedItem = item; |
|
4665 }, |
|
4666 blur: function( event, ui ) { |
|
4667 if ( self.menu.element.is(":visible") ) { |
|
4668 self.element.val( self.term ); |
|
4669 } |
|
4670 } |
|
4671 }) |
|
4672 .zIndex( this.element.zIndex() + 1 ) |
|
4673 // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781 |
|
4674 .css({ top: 0, left: 0 }) |
|
4675 .hide() |
|
4676 .data( "menu" ); |
|
4677 if ( $.fn.bgiframe ) { |
|
4678 this.menu.element.bgiframe(); |
|
4679 } |
|
4680 }, |
|
4681 |
|
4682 destroy: function() { |
|
4683 this.element |
|
4684 .removeClass( "ui-autocomplete-input" ) |
|
4685 .removeAttr( "autocomplete" ) |
|
4686 .removeAttr( "role" ) |
|
4687 .removeAttr( "aria-autocomplete" ) |
|
4688 .removeAttr( "aria-haspopup" ); |
|
4689 this.menu.element.remove(); |
|
4690 $.Widget.prototype.destroy.call( this ); |
|
4691 }, |
|
4692 |
|
4693 _setOption: function( key ) { |
|
4694 $.Widget.prototype._setOption.apply( this, arguments ); |
|
4695 if ( key === "source" ) { |
|
4696 this._initSource(); |
|
4697 } |
|
4698 }, |
|
4699 |
|
4700 _initSource: function() { |
|
4701 var array, |
|
4702 url; |
|
4703 if ( $.isArray(this.options.source) ) { |
|
4704 array = this.options.source; |
|
4705 this.source = function( request, response ) { |
|
4706 response( $.ui.autocomplete.filter(array, request.term) ); |
|
4707 }; |
|
4708 } else if ( typeof this.options.source === "string" ) { |
|
4709 url = this.options.source; |
|
4710 this.source = function( request, response ) { |
|
4711 $.getJSON( url, request, response ); |
|
4712 }; |
|
4713 } else { |
|
4714 this.source = this.options.source; |
|
4715 } |
|
4716 }, |
|
4717 |
|
4718 search: function( value, event ) { |
|
4719 value = value != null ? value : this.element.val(); |
|
4720 if ( value.length < this.options.minLength ) { |
|
4721 return this.close( event ); |
|
4722 } |
|
4723 |
|
4724 clearTimeout( this.closing ); |
|
4725 if ( this._trigger("search") === false ) { |
|
4726 return; |
|
4727 } |
|
4728 |
|
4729 return this._search( value ); |
|
4730 }, |
|
4731 |
|
4732 _search: function( value ) { |
|
4733 this.term = this.element |
|
4734 .addClass( "ui-autocomplete-loading" ) |
|
4735 // always save the actual value, not the one passed as an argument |
|
4736 .val(); |
|
4737 |
|
4738 this.source( { term: value }, this.response ); |
|
4739 }, |
|
4740 |
|
4741 _response: function( content ) { |
|
4742 if ( content.length ) { |
|
4743 content = this._normalize( content ); |
|
4744 this._suggest( content ); |
|
4745 this._trigger( "open" ); |
|
4746 } else { |
|
4747 this.close(); |
|
4748 } |
|
4749 this.element.removeClass( "ui-autocomplete-loading" ); |
|
4750 }, |
|
4751 |
|
4752 close: function( event ) { |
|
4753 clearTimeout( this.closing ); |
|
4754 if ( this.menu.element.is(":visible") ) { |
|
4755 this._trigger( "close", event ); |
|
4756 this.menu.element.hide(); |
|
4757 this.menu.deactivate(); |
|
4758 } |
|
4759 }, |
|
4760 |
|
4761 _change: function( event ) { |
|
4762 if ( this.previous !== this.element.val() ) { |
|
4763 this._trigger( "change", event, { item: this.selectedItem } ); |
|
4764 } |
|
4765 }, |
|
4766 |
|
4767 _normalize: function( items ) { |
|
4768 // assume all items have the right format when the first item is complete |
|
4769 if ( items.length && items[0].label && items[0].value ) { |
|
4770 return items; |
|
4771 } |
|
4772 return $.map( items, function(item) { |
|
4773 if ( typeof item === "string" ) { |
|
4774 return { |
|
4775 label: item, |
|
4776 value: item |
|
4777 }; |
|
4778 } |
|
4779 return $.extend({ |
|
4780 label: item.label || item.value, |
|
4781 value: item.value || item.label |
|
4782 }, item ); |
|
4783 }); |
|
4784 }, |
|
4785 |
|
4786 _suggest: function( items ) { |
|
4787 var ul = this.menu.element |
|
4788 .empty() |
|
4789 .zIndex( this.element.zIndex() + 1 ), |
|
4790 menuWidth, |
|
4791 textWidth; |
|
4792 this._renderMenu( ul, items ); |
|
4793 // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate |
|
4794 this.menu.deactivate(); |
|
4795 this.menu.refresh(); |
|
4796 this.menu.element.show().position({ |
|
4797 my: "left top", |
|
4798 at: "left bottom", |
|
4799 of: this.element, |
|
4800 collision: "none" |
|
4801 }); |
|
4802 |
|
4803 menuWidth = ul.width( "" ).width(); |
|
4804 textWidth = this.element.width(); |
|
4805 ul.width( Math.max( menuWidth, textWidth ) ); |
|
4806 }, |
|
4807 |
|
4808 _renderMenu: function( ul, items ) { |
|
4809 var self = this; |
|
4810 $.each( items, function( index, item ) { |
|
4811 self._renderItem( ul, item ); |
|
4812 }); |
|
4813 }, |
|
4814 |
|
4815 _renderItem: function( ul, item) { |
|
4816 return $( "<li></li>" ) |
|
4817 .data( "item.autocomplete", item ) |
|
4818 .append( "<a>" + item.label + "</a>" ) |
|
4819 .appendTo( ul ); |
|
4820 }, |
|
4821 |
|
4822 _move: function( direction, event ) { |
|
4823 if ( !this.menu.element.is(":visible") ) { |
|
4824 this.search( null, event ); |
|
4825 return; |
|
4826 } |
|
4827 if ( this.menu.first() && /^previous/.test(direction) || |
|
4828 this.menu.last() && /^next/.test(direction) ) { |
|
4829 this.element.val( this.term ); |
|
4830 this.menu.deactivate(); |
|
4831 return; |
|
4832 } |
|
4833 this.menu[ direction ]( event ); |
|
4834 }, |
|
4835 |
|
4836 widget: function() { |
|
4837 return this.menu.element; |
|
4838 } |
|
4839 }); |
|
4840 |
|
4841 $.extend( $.ui.autocomplete, { |
|
4842 escapeRegex: function( value ) { |
|
4843 return value.replace( /([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1" ); |
|
4844 }, |
|
4845 filter: function(array, term) { |
|
4846 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" ); |
|
4847 return $.grep( array, function(value) { |
|
4848 return matcher.test( value.label || value.value || value ); |
|
4849 }); |
|
4850 } |
|
4851 }); |
|
4852 |
|
4853 }( jQuery )); |
|
4854 |
|
4855 /* |
|
4856 * jQuery UI Menu (not officially released) |
|
4857 * |
|
4858 * This widget isn't yet finished and the API is subject to change. We plan to finish |
|
4859 * it for the next release. You're welcome to give it a try anyway and give us feedback, |
|
4860 * as long as you're okay with migrating your code later on. We can help with that, too. |
|
4861 * |
|
4862 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
4863 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
4864 * and GPL (GPL-LICENSE.txt) licenses. |
|
4865 * |
|
4866 * http://docs.jquery.com/UI/Menu |
|
4867 * |
|
4868 * Depends: |
|
4869 * jquery.ui.core.js |
|
4870 * jquery.ui.widget.js |
|
4871 */ |
|
4872 (function($) { |
|
4873 |
|
4874 $.widget("ui.menu", { |
|
4875 _create: function() { |
|
4876 var self = this; |
|
4877 this.element |
|
4878 .addClass("ui-menu ui-widget ui-widget-content ui-corner-all") |
|
4879 .attr({ |
|
4880 role: "listbox", |
|
4881 "aria-activedescendant": "ui-active-menuitem" |
|
4882 }) |
|
4883 .click(function( event ) { |
|
4884 if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) { |
|
4885 return; |
|
4886 } |
|
4887 // temporary |
|
4888 event.preventDefault(); |
|
4889 self.select( event ); |
|
4890 }); |
|
4891 this.refresh(); |
|
4892 }, |
|
4893 |
|
4894 refresh: function() { |
|
4895 var self = this; |
|
4896 |
|
4897 // don't refresh list items that are already adapted |
|
4898 var items = this.element.children("li:not(.ui-menu-item):has(a)") |
|
4899 .addClass("ui-menu-item") |
|
4900 .attr("role", "menuitem"); |
|
4901 |
|
4902 items.children("a") |
|
4903 .addClass("ui-corner-all") |
|
4904 .attr("tabindex", -1) |
|
4905 // mouseenter doesn't work with event delegation |
|
4906 .mouseenter(function( event ) { |
|
4907 self.activate( event, $(this).parent() ); |
|
4908 }) |
|
4909 .mouseleave(function() { |
|
4910 self.deactivate(); |
|
4911 }); |
|
4912 }, |
|
4913 |
|
4914 activate: function( event, item ) { |
|
4915 this.deactivate(); |
|
4916 if (this.hasScroll()) { |
|
4917 var offset = item.offset().top - this.element.offset().top, |
|
4918 scroll = this.element.attr("scrollTop"), |
|
4919 elementHeight = this.element.height(); |
|
4920 if (offset < 0) { |
|
4921 this.element.attr("scrollTop", scroll + offset); |
|
4922 } else if (offset > elementHeight) { |
|
4923 this.element.attr("scrollTop", scroll + offset - elementHeight + item.height()); |
|
4924 } |
|
4925 } |
|
4926 this.active = item.eq(0) |
|
4927 .children("a") |
|
4928 .addClass("ui-state-hover") |
|
4929 .attr("id", "ui-active-menuitem") |
|
4930 .end(); |
|
4931 this._trigger("focus", event, { item: item }); |
|
4932 }, |
|
4933 |
|
4934 deactivate: function() { |
|
4935 if (!this.active) { return; } |
|
4936 |
|
4937 this.active.children("a") |
|
4938 .removeClass("ui-state-hover") |
|
4939 .removeAttr("id"); |
|
4940 this._trigger("blur"); |
|
4941 this.active = null; |
|
4942 }, |
|
4943 |
|
4944 next: function(event) { |
|
4945 this.move("next", ".ui-menu-item:first", event); |
|
4946 }, |
|
4947 |
|
4948 previous: function(event) { |
|
4949 this.move("prev", ".ui-menu-item:last", event); |
|
4950 }, |
|
4951 |
|
4952 first: function() { |
|
4953 return this.active && !this.active.prev().length; |
|
4954 }, |
|
4955 |
|
4956 last: function() { |
|
4957 return this.active && !this.active.next().length; |
|
4958 }, |
|
4959 |
|
4960 move: function(direction, edge, event) { |
|
4961 if (!this.active) { |
|
4962 this.activate(event, this.element.children(edge)); |
|
4963 return; |
|
4964 } |
|
4965 var next = this.active[direction + "All"](".ui-menu-item").eq(0); |
|
4966 if (next.length) { |
|
4967 this.activate(event, next); |
|
4968 } else { |
|
4969 this.activate(event, this.element.children(edge)); |
|
4970 } |
|
4971 }, |
|
4972 |
|
4973 // TODO merge with previousPage |
|
4974 nextPage: function(event) { |
|
4975 if (this.hasScroll()) { |
|
4976 // TODO merge with no-scroll-else |
|
4977 if (!this.active || this.last()) { |
|
4978 this.activate(event, this.element.children(":first")); |
|
4979 return; |
|
4980 } |
|
4981 var base = this.active.offset().top, |
|
4982 height = this.element.height(), |
|
4983 result = this.element.children("li").filter(function() { |
|
4984 var close = $(this).offset().top - base - height + $(this).height(); |
|
4985 // TODO improve approximation |
|
4986 return close < 10 && close > -10; |
|
4987 }); |
|
4988 |
|
4989 // TODO try to catch this earlier when scrollTop indicates the last page anyway |
|
4990 if (!result.length) { |
|
4991 result = this.element.children(":last"); |
|
4992 } |
|
4993 this.activate(event, result); |
|
4994 } else { |
|
4995 this.activate(event, this.element.children(!this.active || this.last() ? ":first" : ":last")); |
|
4996 } |
|
4997 }, |
|
4998 |
|
4999 // TODO merge with nextPage |
|
5000 previousPage: function(event) { |
|
5001 if (this.hasScroll()) { |
|
5002 // TODO merge with no-scroll-else |
|
5003 if (!this.active || this.first()) { |
|
5004 this.activate(event, this.element.children(":last")); |
|
5005 return; |
|
5006 } |
|
5007 |
|
5008 var base = this.active.offset().top, |
|
5009 height = this.element.height(); |
|
5010 result = this.element.children("li").filter(function() { |
|
5011 var close = $(this).offset().top - base + height - $(this).height(); |
|
5012 // TODO improve approximation |
|
5013 return close < 10 && close > -10; |
|
5014 }); |
|
5015 |
|
5016 // TODO try to catch this earlier when scrollTop indicates the last page anyway |
|
5017 if (!result.length) { |
|
5018 result = this.element.children(":first"); |
|
5019 } |
|
5020 this.activate(event, result); |
|
5021 } else { |
|
5022 this.activate(event, this.element.children(!this.active || this.first() ? ":last" : ":first")); |
|
5023 } |
|
5024 }, |
|
5025 |
|
5026 hasScroll: function() { |
|
5027 return this.element.height() < this.element.attr("scrollHeight"); |
|
5028 }, |
|
5029 |
|
5030 select: function( event ) { |
|
5031 this._trigger("selected", event, { item: this.active }); |
|
5032 } |
|
5033 }); |
|
5034 |
|
5035 }(jQuery)); |
|
5036 /* |
|
5037 * jQuery UI Button 1.8.1 |
|
5038 * |
|
5039 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
5040 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
5041 * and GPL (GPL-LICENSE.txt) licenses. |
|
5042 * |
|
5043 * http://docs.jquery.com/UI/Button |
|
5044 * |
|
5045 * Depends: |
|
5046 * jquery.ui.core.js |
|
5047 * jquery.ui.widget.js |
|
5048 */ |
|
5049 (function( $ ) { |
|
5050 |
|
5051 var lastActive, |
|
5052 baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", |
|
5053 otherClasses = "ui-state-hover ui-state-active " + |
|
5054 "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon ui-button-text-only", |
|
5055 formResetHandler = function( event ) { |
|
5056 $( ":ui-button", event.target.form ).each(function() { |
|
5057 var inst = $( this ).data( "button" ); |
|
5058 setTimeout(function() { |
|
5059 inst.refresh(); |
|
5060 }, 1 ); |
|
5061 }); |
|
5062 }, |
|
5063 radioGroup = function( radio ) { |
|
5064 var name = radio.name, |
|
5065 form = radio.form, |
|
5066 radios = $( [] ); |
|
5067 if ( name ) { |
|
5068 if ( form ) { |
|
5069 radios = $( form ).find( "[name='" + name + "']" ); |
|
5070 } else { |
|
5071 radios = $( "[name='" + name + "']", radio.ownerDocument ) |
|
5072 .filter(function() { |
|
5073 return !this.form; |
|
5074 }); |
|
5075 } |
|
5076 } |
|
5077 return radios; |
|
5078 }; |
|
5079 |
|
5080 $.widget( "ui.button", { |
|
5081 options: { |
|
5082 text: true, |
|
5083 label: null, |
|
5084 icons: { |
|
5085 primary: null, |
|
5086 secondary: null |
|
5087 } |
|
5088 }, |
|
5089 _create: function() { |
|
5090 this.element.closest( "form" ) |
|
5091 .unbind( "reset.button" ) |
|
5092 .bind( "reset.button", formResetHandler ); |
|
5093 |
|
5094 this._determineButtonType(); |
|
5095 this.hasTitle = !!this.buttonElement.attr( "title" ); |
|
5096 |
|
5097 var self = this, |
|
5098 options = this.options, |
|
5099 toggleButton = this.type === "checkbox" || this.type === "radio", |
|
5100 hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ), |
|
5101 focusClass = "ui-state-focus"; |
|
5102 |
|
5103 if ( options.label === null ) { |
|
5104 options.label = this.buttonElement.html(); |
|
5105 } |
|
5106 |
|
5107 if ( this.element.is( ":disabled" ) ) { |
|
5108 options.disabled = true; |
|
5109 } |
|
5110 |
|
5111 this.buttonElement |
|
5112 .addClass( baseClasses ) |
|
5113 .attr( "role", "button" ) |
|
5114 .bind( "mouseenter.button", function() { |
|
5115 if ( options.disabled ) { |
|
5116 return; |
|
5117 } |
|
5118 $( this ).addClass( "ui-state-hover" ); |
|
5119 if ( this === lastActive ) { |
|
5120 $( this ).addClass( "ui-state-active" ); |
|
5121 } |
|
5122 }) |
|
5123 .bind( "mouseleave.button", function() { |
|
5124 if ( options.disabled ) { |
|
5125 return; |
|
5126 } |
|
5127 $( this ).removeClass( hoverClass ); |
|
5128 }) |
|
5129 .bind( "focus.button", function() { |
|
5130 // no need to check disabled, focus won't be triggered anyway |
|
5131 $( this ).addClass( focusClass ); |
|
5132 }) |
|
5133 .bind( "blur.button", function() { |
|
5134 $( this ).removeClass( focusClass ); |
|
5135 }); |
|
5136 |
|
5137 if ( toggleButton ) { |
|
5138 this.element.bind( "change.button", function() { |
|
5139 self.refresh(); |
|
5140 }); |
|
5141 } |
|
5142 |
|
5143 if ( this.type === "checkbox" ) { |
|
5144 this.buttonElement.bind( "click.button", function() { |
|
5145 if ( options.disabled ) { |
|
5146 return false; |
|
5147 } |
|
5148 $( this ).toggleClass( "ui-state-active" ); |
|
5149 self.buttonElement.attr( "aria-pressed", self.element[0].checked ); |
|
5150 }); |
|
5151 } else if ( this.type === "radio" ) { |
|
5152 this.buttonElement.bind( "click.button", function() { |
|
5153 if ( options.disabled ) { |
|
5154 return false; |
|
5155 } |
|
5156 $( this ).addClass( "ui-state-active" ); |
|
5157 self.buttonElement.attr( "aria-pressed", true ); |
|
5158 |
|
5159 var radio = self.element[ 0 ]; |
|
5160 radioGroup( radio ) |
|
5161 .not( radio ) |
|
5162 .map(function() { |
|
5163 return $( this ).button( "widget" )[ 0 ]; |
|
5164 }) |
|
5165 .removeClass( "ui-state-active" ) |
|
5166 .attr( "aria-pressed", false ); |
|
5167 }); |
|
5168 } else { |
|
5169 this.buttonElement |
|
5170 .bind( "mousedown.button", function() { |
|
5171 if ( options.disabled ) { |
|
5172 return false; |
|
5173 } |
|
5174 $( this ).addClass( "ui-state-active" ); |
|
5175 lastActive = this; |
|
5176 $( document ).one( "mouseup", function() { |
|
5177 lastActive = null; |
|
5178 }); |
|
5179 }) |
|
5180 .bind( "mouseup.button", function() { |
|
5181 if ( options.disabled ) { |
|
5182 return false; |
|
5183 } |
|
5184 $( this ).removeClass( "ui-state-active" ); |
|
5185 }) |
|
5186 .bind( "keydown.button", function(event) { |
|
5187 if ( options.disabled ) { |
|
5188 return false; |
|
5189 } |
|
5190 if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) { |
|
5191 $( this ).addClass( "ui-state-active" ); |
|
5192 } |
|
5193 }) |
|
5194 .bind( "keyup.button", function() { |
|
5195 $( this ).removeClass( "ui-state-active" ); |
|
5196 }); |
|
5197 |
|
5198 if ( this.buttonElement.is("a") ) { |
|
5199 this.buttonElement.keyup(function(event) { |
|
5200 if ( event.keyCode === $.ui.keyCode.SPACE ) { |
|
5201 // TODO pass through original event correctly (just as 2nd argument doesn't work) |
|
5202 $( this ).click(); |
|
5203 } |
|
5204 }); |
|
5205 } |
|
5206 } |
|
5207 |
|
5208 // TODO: pull out $.Widget's handling for the disabled option into |
|
5209 // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can |
|
5210 // be overridden by individual plugins |
|
5211 this._setOption( "disabled", options.disabled ); |
|
5212 }, |
|
5213 |
|
5214 _determineButtonType: function() { |
|
5215 |
|
5216 if ( this.element.is(":checkbox") ) { |
|
5217 this.type = "checkbox"; |
|
5218 } else { |
|
5219 if ( this.element.is(":radio") ) { |
|
5220 this.type = "radio"; |
|
5221 } else { |
|
5222 if ( this.element.is("input") ) { |
|
5223 this.type = "input"; |
|
5224 } else { |
|
5225 this.type = "button"; |
|
5226 } |
|
5227 } |
|
5228 } |
|
5229 |
|
5230 if ( this.type === "checkbox" || this.type === "radio" ) { |
|
5231 // we don't search against the document in case the element |
|
5232 // is disconnected from the DOM |
|
5233 this.buttonElement = this.element.parents().last() |
|
5234 .find( "[for=" + this.element.attr("id") + "]" ); |
|
5235 this.element.addClass( "ui-helper-hidden-accessible" ); |
|
5236 |
|
5237 var checked = this.element.is( ":checked" ); |
|
5238 if ( checked ) { |
|
5239 this.buttonElement.addClass( "ui-state-active" ); |
|
5240 } |
|
5241 this.buttonElement.attr( "aria-pressed", checked ); |
|
5242 } else { |
|
5243 this.buttonElement = this.element; |
|
5244 } |
|
5245 }, |
|
5246 |
|
5247 widget: function() { |
|
5248 return this.buttonElement; |
|
5249 }, |
|
5250 |
|
5251 destroy: function() { |
|
5252 this.element |
|
5253 .removeClass( "ui-helper-hidden-accessible" ); |
|
5254 this.buttonElement |
|
5255 .removeClass( baseClasses + " " + otherClasses ) |
|
5256 .removeAttr( "role" ) |
|
5257 .removeAttr( "aria-pressed" ) |
|
5258 .html( this.buttonElement.find(".ui-button-text").html() ); |
|
5259 |
|
5260 if ( !this.hasTitle ) { |
|
5261 this.buttonElement.removeAttr( "title" ); |
|
5262 } |
|
5263 |
|
5264 $.Widget.prototype.destroy.call( this ); |
|
5265 }, |
|
5266 |
|
5267 _setOption: function( key, value ) { |
|
5268 $.Widget.prototype._setOption.apply( this, arguments ); |
|
5269 if ( key === "disabled" ) { |
|
5270 if ( value ) { |
|
5271 this.element.attr( "disabled", true ); |
|
5272 } else { |
|
5273 this.element.removeAttr( "disabled" ); |
|
5274 } |
|
5275 } |
|
5276 this._resetButton(); |
|
5277 }, |
|
5278 |
|
5279 refresh: function() { |
|
5280 var isDisabled = this.element.is( ":disabled" ); |
|
5281 if ( isDisabled !== this.options.disabled ) { |
|
5282 this._setOption( "disabled", isDisabled ); |
|
5283 } |
|
5284 if ( this.type === "radio" ) { |
|
5285 radioGroup( this.element[0] ).each(function() { |
|
5286 if ( $( this ).is( ":checked" ) ) { |
|
5287 $( this ).button( "widget" ) |
|
5288 .addClass( "ui-state-active" ) |
|
5289 .attr( "aria-pressed", true ); |
|
5290 } else { |
|
5291 $( this ).button( "widget" ) |
|
5292 .removeClass( "ui-state-active" ) |
|
5293 .attr( "aria-pressed", false ); |
|
5294 } |
|
5295 }); |
|
5296 } else if ( this.type === "checkbox" ) { |
|
5297 if ( this.element.is( ":checked" ) ) { |
|
5298 this.buttonElement |
|
5299 .addClass( "ui-state-active" ) |
|
5300 .attr( "aria-pressed", true ); |
|
5301 } else { |
|
5302 this.buttonElement |
|
5303 .removeClass( "ui-state-active" ) |
|
5304 .attr( "aria-pressed", false ); |
|
5305 } |
|
5306 } |
|
5307 }, |
|
5308 |
|
5309 _resetButton: function() { |
|
5310 if ( this.type === "input" ) { |
|
5311 if ( this.options.label ) { |
|
5312 this.element.val( this.options.label ); |
|
5313 } |
|
5314 return; |
|
5315 } |
|
5316 var buttonElement = this.buttonElement, |
|
5317 buttonText = $( "<span></span>" ) |
|
5318 .addClass( "ui-button-text" ) |
|
5319 .html( this.options.label ) |
|
5320 .appendTo( buttonElement.empty() ) |
|
5321 .text(), |
|
5322 icons = this.options.icons, |
|
5323 multipleIcons = icons.primary && icons.secondary; |
|
5324 if ( icons.primary || icons.secondary ) { |
|
5325 buttonElement.addClass( "ui-button-text-icon" + |
|
5326 ( multipleIcons ? "s" : "" ) ); |
|
5327 if ( icons.primary ) { |
|
5328 buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" ); |
|
5329 } |
|
5330 if ( icons.secondary ) { |
|
5331 buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" ); |
|
5332 } |
|
5333 if ( !this.options.text ) { |
|
5334 buttonElement |
|
5335 .addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" ) |
|
5336 .removeClass( "ui-button-text-icons ui-button-text-icon" ); |
|
5337 if ( !this.hasTitle ) { |
|
5338 buttonElement.attr( "title", buttonText ); |
|
5339 } |
|
5340 } |
|
5341 } else { |
|
5342 buttonElement.addClass( "ui-button-text-only" ); |
|
5343 } |
|
5344 } |
|
5345 }); |
|
5346 |
|
5347 $.widget( "ui.buttonset", { |
|
5348 _create: function() { |
|
5349 this.element.addClass( "ui-buttonset" ); |
|
5350 this._init(); |
|
5351 }, |
|
5352 |
|
5353 _init: function() { |
|
5354 this.refresh(); |
|
5355 }, |
|
5356 |
|
5357 _setOption: function( key, value ) { |
|
5358 if ( key === "disabled" ) { |
|
5359 this.buttons.button( "option", key, value ); |
|
5360 } |
|
5361 |
|
5362 $.Widget.prototype._setOption.apply( this, arguments ); |
|
5363 }, |
|
5364 |
|
5365 refresh: function() { |
|
5366 this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" ) |
|
5367 .filter( ":ui-button" ) |
|
5368 .button( "refresh" ) |
|
5369 .end() |
|
5370 .not( ":ui-button" ) |
|
5371 .button() |
|
5372 .end() |
|
5373 .map(function() { |
|
5374 return $( this ).button( "widget" )[ 0 ]; |
|
5375 }) |
|
5376 .removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) |
|
5377 .filter( ":first" ) |
|
5378 .addClass( "ui-corner-left" ) |
|
5379 .end() |
|
5380 .filter( ":last" ) |
|
5381 .addClass( "ui-corner-right" ) |
|
5382 .end() |
|
5383 .end(); |
|
5384 }, |
|
5385 |
|
5386 destroy: function() { |
|
5387 this.element.removeClass( "ui-buttonset" ); |
|
5388 this.buttons |
|
5389 .map(function() { |
|
5390 return $( this ).button( "widget" )[ 0 ]; |
|
5391 }) |
|
5392 .removeClass( "ui-corner-left ui-corner-right" ) |
|
5393 .end() |
|
5394 .button( "destroy" ) |
|
5395 |
|
5396 $.Widget.prototype.destroy.call( this ); |
|
5397 } |
|
5398 }); |
|
5399 |
|
5400 }( jQuery ) ); |
|
5401 /* |
|
5402 * jQuery UI Dialog 1.8.1 |
|
5403 * |
|
5404 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
5405 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
5406 * and GPL (GPL-LICENSE.txt) licenses. |
|
5407 * |
|
5408 * http://docs.jquery.com/UI/Dialog |
|
5409 * |
|
5410 * Depends: |
|
5411 * jquery.ui.core.js |
|
5412 * jquery.ui.widget.js |
|
5413 * jquery.ui.button.js |
|
5414 * jquery.ui.draggable.js |
|
5415 * jquery.ui.mouse.js |
|
5416 * jquery.ui.position.js |
|
5417 * jquery.ui.resizable.js |
|
5418 */ |
|
5419 (function($) { |
|
5420 |
|
5421 var uiDialogClasses = |
|
5422 'ui-dialog ' + |
|
5423 'ui-widget ' + |
|
5424 'ui-widget-content ' + |
|
5425 'ui-corner-all '; |
|
5426 |
|
5427 $.widget("ui.dialog", { |
|
5428 options: { |
|
5429 autoOpen: true, |
|
5430 buttons: {}, |
|
5431 closeOnEscape: true, |
|
5432 closeText: 'close', |
|
5433 dialogClass: '', |
|
5434 draggable: true, |
|
5435 hide: null, |
|
5436 height: 'auto', |
|
5437 maxHeight: false, |
|
5438 maxWidth: false, |
|
5439 minHeight: 150, |
|
5440 minWidth: 150, |
|
5441 modal: false, |
|
5442 position: 'center', |
|
5443 resizable: true, |
|
5444 show: null, |
|
5445 stack: true, |
|
5446 title: '', |
|
5447 width: 300, |
|
5448 zIndex: 1000 |
|
5449 }, |
|
5450 _create: function() { |
|
5451 this.originalTitle = this.element.attr('title'); |
|
5452 |
|
5453 var self = this, |
|
5454 options = self.options, |
|
5455 |
|
5456 title = options.title || self.originalTitle || ' ', |
|
5457 titleId = $.ui.dialog.getTitleId(self.element), |
|
5458 |
|
5459 uiDialog = (self.uiDialog = $('<div></div>')) |
|
5460 .appendTo(document.body) |
|
5461 .hide() |
|
5462 .addClass(uiDialogClasses + options.dialogClass) |
|
5463 .css({ |
|
5464 zIndex: options.zIndex |
|
5465 }) |
|
5466 // setting tabIndex makes the div focusable |
|
5467 // setting outline to 0 prevents a border on focus in Mozilla |
|
5468 .attr('tabIndex', -1).css('outline', 0).keydown(function(event) { |
|
5469 if (options.closeOnEscape && event.keyCode && |
|
5470 event.keyCode === $.ui.keyCode.ESCAPE) { |
|
5471 |
|
5472 self.close(event); |
|
5473 event.preventDefault(); |
|
5474 } |
|
5475 }) |
|
5476 .attr({ |
|
5477 role: 'dialog', |
|
5478 'aria-labelledby': titleId |
|
5479 }) |
|
5480 .mousedown(function(event) { |
|
5481 self.moveToTop(false, event); |
|
5482 }), |
|
5483 |
|
5484 uiDialogContent = self.element |
|
5485 .show() |
|
5486 .removeAttr('title') |
|
5487 .addClass( |
|
5488 'ui-dialog-content ' + |
|
5489 'ui-widget-content') |
|
5490 .appendTo(uiDialog), |
|
5491 |
|
5492 uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>')) |
|
5493 .addClass( |
|
5494 'ui-dialog-titlebar ' + |
|
5495 'ui-widget-header ' + |
|
5496 'ui-corner-all ' + |
|
5497 'ui-helper-clearfix' |
|
5498 ) |
|
5499 .prependTo(uiDialog), |
|
5500 |
|
5501 uiDialogTitlebarClose = $('<a href="#"></a>') |
|
5502 .addClass( |
|
5503 'ui-dialog-titlebar-close ' + |
|
5504 'ui-corner-all' |
|
5505 ) |
|
5506 .attr('role', 'button') |
|
5507 .hover( |
|
5508 function() { |
|
5509 uiDialogTitlebarClose.addClass('ui-state-hover'); |
|
5510 }, |
|
5511 function() { |
|
5512 uiDialogTitlebarClose.removeClass('ui-state-hover'); |
|
5513 } |
|
5514 ) |
|
5515 .focus(function() { |
|
5516 uiDialogTitlebarClose.addClass('ui-state-focus'); |
|
5517 }) |
|
5518 .blur(function() { |
|
5519 uiDialogTitlebarClose.removeClass('ui-state-focus'); |
|
5520 }) |
|
5521 .click(function(event) { |
|
5522 self.close(event); |
|
5523 return false; |
|
5524 }) |
|
5525 .appendTo(uiDialogTitlebar), |
|
5526 |
|
5527 uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>')) |
|
5528 .addClass( |
|
5529 'ui-icon ' + |
|
5530 'ui-icon-closethick' |
|
5531 ) |
|
5532 .text(options.closeText) |
|
5533 .appendTo(uiDialogTitlebarClose), |
|
5534 |
|
5535 uiDialogTitle = $('<span></span>') |
|
5536 .addClass('ui-dialog-title') |
|
5537 .attr('id', titleId) |
|
5538 .html(title) |
|
5539 .prependTo(uiDialogTitlebar); |
|
5540 |
|
5541 //handling of deprecated beforeclose (vs beforeClose) option |
|
5542 //Ticket #4669 http://dev.jqueryui.com/ticket/4669 |
|
5543 //TODO: remove in 1.9pre |
|
5544 if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) { |
|
5545 options.beforeClose = options.beforeclose; |
|
5546 } |
|
5547 |
|
5548 uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); |
|
5549 |
|
5550 if (options.draggable && $.fn.draggable) { |
|
5551 self._makeDraggable(); |
|
5552 } |
|
5553 if (options.resizable && $.fn.resizable) { |
|
5554 self._makeResizable(); |
|
5555 } |
|
5556 |
|
5557 self._createButtons(options.buttons); |
|
5558 self._isOpen = false; |
|
5559 |
|
5560 if ($.fn.bgiframe) { |
|
5561 uiDialog.bgiframe(); |
|
5562 } |
|
5563 }, |
|
5564 _init: function() { |
|
5565 if ( this.options.autoOpen ) { |
|
5566 this.open(); |
|
5567 } |
|
5568 }, |
|
5569 |
|
5570 destroy: function() { |
|
5571 var self = this; |
|
5572 |
|
5573 if (self.overlay) { |
|
5574 self.overlay.destroy(); |
|
5575 } |
|
5576 self.uiDialog.hide(); |
|
5577 self.element |
|
5578 .unbind('.dialog') |
|
5579 .removeData('dialog') |
|
5580 .removeClass('ui-dialog-content ui-widget-content') |
|
5581 .hide().appendTo('body'); |
|
5582 self.uiDialog.remove(); |
|
5583 |
|
5584 if (self.originalTitle) { |
|
5585 self.element.attr('title', self.originalTitle); |
|
5586 } |
|
5587 |
|
5588 return self; |
|
5589 }, |
|
5590 |
|
5591 widget: function() { |
|
5592 return this.uiDialog; |
|
5593 }, |
|
5594 |
|
5595 close: function(event) { |
|
5596 var self = this, |
|
5597 maxZ; |
|
5598 |
|
5599 if (false === self._trigger('beforeClose', event)) { |
|
5600 return; |
|
5601 } |
|
5602 |
|
5603 if (self.overlay) { |
|
5604 self.overlay.destroy(); |
|
5605 } |
|
5606 self.uiDialog.unbind('keypress.ui-dialog'); |
|
5607 |
|
5608 self._isOpen = false; |
|
5609 |
|
5610 if (self.options.hide) { |
|
5611 self.uiDialog.hide(self.options.hide, function() { |
|
5612 self._trigger('close', event); |
|
5613 }); |
|
5614 } else { |
|
5615 self.uiDialog.hide(); |
|
5616 self._trigger('close', event); |
|
5617 } |
|
5618 |
|
5619 $.ui.dialog.overlay.resize(); |
|
5620 |
|
5621 // adjust the maxZ to allow other modal dialogs to continue to work (see #4309) |
|
5622 if (self.options.modal) { |
|
5623 maxZ = 0; |
|
5624 $('.ui-dialog').each(function() { |
|
5625 if (this !== self.uiDialog[0]) { |
|
5626 maxZ = Math.max(maxZ, $(this).css('z-index')); |
|
5627 } |
|
5628 }); |
|
5629 $.ui.dialog.maxZ = maxZ; |
|
5630 } |
|
5631 |
|
5632 return self; |
|
5633 }, |
|
5634 |
|
5635 isOpen: function() { |
|
5636 return this._isOpen; |
|
5637 }, |
|
5638 |
|
5639 // the force parameter allows us to move modal dialogs to their correct |
|
5640 // position on open |
|
5641 moveToTop: function(force, event) { |
|
5642 var self = this, |
|
5643 options = self.options, |
|
5644 saveScroll; |
|
5645 |
|
5646 if ((options.modal && !force) || |
|
5647 (!options.stack && !options.modal)) { |
|
5648 return self._trigger('focus', event); |
|
5649 } |
|
5650 |
|
5651 if (options.zIndex > $.ui.dialog.maxZ) { |
|
5652 $.ui.dialog.maxZ = options.zIndex; |
|
5653 } |
|
5654 if (self.overlay) { |
|
5655 $.ui.dialog.maxZ += 1; |
|
5656 self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ); |
|
5657 } |
|
5658 |
|
5659 //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. |
|
5660 // http://ui.jquery.com/bugs/ticket/3193 |
|
5661 saveScroll = { scrollTop: self.element.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') }; |
|
5662 $.ui.dialog.maxZ += 1; |
|
5663 self.uiDialog.css('z-index', $.ui.dialog.maxZ); |
|
5664 self.element.attr(saveScroll); |
|
5665 self._trigger('focus', event); |
|
5666 |
|
5667 return self; |
|
5668 }, |
|
5669 |
|
5670 open: function() { |
|
5671 if (this._isOpen) { return; } |
|
5672 |
|
5673 var self = this, |
|
5674 options = self.options, |
|
5675 uiDialog = self.uiDialog; |
|
5676 |
|
5677 self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null; |
|
5678 if (uiDialog.next().length) { |
|
5679 uiDialog.appendTo('body'); |
|
5680 } |
|
5681 self._size(); |
|
5682 self._position(options.position); |
|
5683 uiDialog.show(options.show); |
|
5684 self.moveToTop(true); |
|
5685 |
|
5686 // prevent tabbing out of modal dialogs |
|
5687 if (options.modal) { |
|
5688 uiDialog.bind('keypress.ui-dialog', function(event) { |
|
5689 if (event.keyCode !== $.ui.keyCode.TAB) { |
|
5690 return; |
|
5691 } |
|
5692 |
|
5693 var tabbables = $(':tabbable', this), |
|
5694 first = tabbables.filter(':first'), |
|
5695 last = tabbables.filter(':last'); |
|
5696 |
|
5697 if (event.target === last[0] && !event.shiftKey) { |
|
5698 first.focus(1); |
|
5699 return false; |
|
5700 } else if (event.target === first[0] && event.shiftKey) { |
|
5701 last.focus(1); |
|
5702 return false; |
|
5703 } |
|
5704 }); |
|
5705 } |
|
5706 |
|
5707 // set focus to the first tabbable element in the content area or the first button |
|
5708 // if there are no tabbable elements, set focus on the dialog itself |
|
5709 $([]) |
|
5710 .add(uiDialog.find('.ui-dialog-content :tabbable:first')) |
|
5711 .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) |
|
5712 .add(uiDialog) |
|
5713 .filter(':first') |
|
5714 .focus(); |
|
5715 |
|
5716 self._trigger('open'); |
|
5717 self._isOpen = true; |
|
5718 |
|
5719 return self; |
|
5720 }, |
|
5721 |
|
5722 _createButtons: function(buttons) { |
|
5723 var self = this, |
|
5724 hasButtons = false, |
|
5725 uiDialogButtonPane = $('<div></div>') |
|
5726 .addClass( |
|
5727 'ui-dialog-buttonpane ' + |
|
5728 'ui-widget-content ' + |
|
5729 'ui-helper-clearfix' |
|
5730 ); |
|
5731 |
|
5732 // if we already have a button pane, remove it |
|
5733 self.uiDialog.find('.ui-dialog-buttonpane').remove(); |
|
5734 |
|
5735 if (typeof buttons === 'object' && buttons !== null) { |
|
5736 $.each(buttons, function() { |
|
5737 return !(hasButtons = true); |
|
5738 }); |
|
5739 } |
|
5740 if (hasButtons) { |
|
5741 $.each(buttons, function(name, fn) { |
|
5742 var button = $('<button type="button"></button>') |
|
5743 .text(name) |
|
5744 .click(function() { fn.apply(self.element[0], arguments); }) |
|
5745 .appendTo(uiDialogButtonPane); |
|
5746 if ($.fn.button) { |
|
5747 button.button(); |
|
5748 } |
|
5749 }); |
|
5750 uiDialogButtonPane.appendTo(self.uiDialog); |
|
5751 } |
|
5752 }, |
|
5753 |
|
5754 _makeDraggable: function() { |
|
5755 var self = this, |
|
5756 options = self.options, |
|
5757 doc = $(document), |
|
5758 heightBeforeDrag; |
|
5759 |
|
5760 function filteredUi(ui) { |
|
5761 return { |
|
5762 position: ui.position, |
|
5763 offset: ui.offset |
|
5764 }; |
|
5765 } |
|
5766 |
|
5767 self.uiDialog.draggable({ |
|
5768 cancel: '.ui-dialog-content, .ui-dialog-titlebar-close', |
|
5769 handle: '.ui-dialog-titlebar', |
|
5770 containment: 'document', |
|
5771 start: function(event, ui) { |
|
5772 heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height(); |
|
5773 $(this).height($(this).height()).addClass("ui-dialog-dragging"); |
|
5774 self._trigger('dragStart', event, filteredUi(ui)); |
|
5775 }, |
|
5776 drag: function(event, ui) { |
|
5777 self._trigger('drag', event, filteredUi(ui)); |
|
5778 }, |
|
5779 stop: function(event, ui) { |
|
5780 options.position = [ui.position.left - doc.scrollLeft(), |
|
5781 ui.position.top - doc.scrollTop()]; |
|
5782 $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag); |
|
5783 self._trigger('dragStop', event, filteredUi(ui)); |
|
5784 $.ui.dialog.overlay.resize(); |
|
5785 } |
|
5786 }); |
|
5787 }, |
|
5788 |
|
5789 _makeResizable: function(handles) { |
|
5790 handles = (handles === undefined ? this.options.resizable : handles); |
|
5791 var self = this, |
|
5792 options = self.options, |
|
5793 // .ui-resizable has position: relative defined in the stylesheet |
|
5794 // but dialogs have to use absolute or fixed positioning |
|
5795 position = self.uiDialog.css('position'), |
|
5796 resizeHandles = (typeof handles === 'string' ? |
|
5797 handles : |
|
5798 'n,e,s,w,se,sw,ne,nw' |
|
5799 ); |
|
5800 |
|
5801 function filteredUi(ui) { |
|
5802 return { |
|
5803 originalPosition: ui.originalPosition, |
|
5804 originalSize: ui.originalSize, |
|
5805 position: ui.position, |
|
5806 size: ui.size |
|
5807 }; |
|
5808 } |
|
5809 |
|
5810 self.uiDialog.resizable({ |
|
5811 cancel: '.ui-dialog-content', |
|
5812 containment: 'document', |
|
5813 alsoResize: self.element, |
|
5814 maxWidth: options.maxWidth, |
|
5815 maxHeight: options.maxHeight, |
|
5816 minWidth: options.minWidth, |
|
5817 minHeight: self._minHeight(), |
|
5818 handles: resizeHandles, |
|
5819 start: function(event, ui) { |
|
5820 $(this).addClass("ui-dialog-resizing"); |
|
5821 self._trigger('resizeStart', event, filteredUi(ui)); |
|
5822 }, |
|
5823 resize: function(event, ui) { |
|
5824 self._trigger('resize', event, filteredUi(ui)); |
|
5825 }, |
|
5826 stop: function(event, ui) { |
|
5827 $(this).removeClass("ui-dialog-resizing"); |
|
5828 options.height = $(this).height(); |
|
5829 options.width = $(this).width(); |
|
5830 self._trigger('resizeStop', event, filteredUi(ui)); |
|
5831 $.ui.dialog.overlay.resize(); |
|
5832 } |
|
5833 }) |
|
5834 .css('position', position) |
|
5835 .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se'); |
|
5836 }, |
|
5837 |
|
5838 _minHeight: function() { |
|
5839 var options = this.options; |
|
5840 |
|
5841 if (options.height === 'auto') { |
|
5842 return options.minHeight; |
|
5843 } else { |
|
5844 return Math.min(options.minHeight, options.height); |
|
5845 } |
|
5846 }, |
|
5847 |
|
5848 _position: function(position) { |
|
5849 var myAt = [], |
|
5850 offset = [0, 0], |
|
5851 isVisible; |
|
5852 |
|
5853 position = position || $.ui.dialog.prototype.options.position; |
|
5854 |
|
5855 // deep extending converts arrays to objects in jQuery <= 1.3.2 :-( |
|
5856 // if (typeof position == 'string' || $.isArray(position)) { |
|
5857 // myAt = $.isArray(position) ? position : position.split(' '); |
|
5858 |
|
5859 if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) { |
|
5860 myAt = position.split ? position.split(' ') : [position[0], position[1]]; |
|
5861 if (myAt.length === 1) { |
|
5862 myAt[1] = myAt[0]; |
|
5863 } |
|
5864 |
|
5865 $.each(['left', 'top'], function(i, offsetPosition) { |
|
5866 if (+myAt[i] === myAt[i]) { |
|
5867 offset[i] = myAt[i]; |
|
5868 myAt[i] = offsetPosition; |
|
5869 } |
|
5870 }); |
|
5871 } else if (typeof position === 'object') { |
|
5872 if ('left' in position) { |
|
5873 myAt[0] = 'left'; |
|
5874 offset[0] = position.left; |
|
5875 } else if ('right' in position) { |
|
5876 myAt[0] = 'right'; |
|
5877 offset[0] = -position.right; |
|
5878 } |
|
5879 |
|
5880 if ('top' in position) { |
|
5881 myAt[1] = 'top'; |
|
5882 offset[1] = position.top; |
|
5883 } else if ('bottom' in position) { |
|
5884 myAt[1] = 'bottom'; |
|
5885 offset[1] = -position.bottom; |
|
5886 } |
|
5887 } |
|
5888 |
|
5889 // need to show the dialog to get the actual offset in the position plugin |
|
5890 isVisible = this.uiDialog.is(':visible'); |
|
5891 if (!isVisible) { |
|
5892 this.uiDialog.show(); |
|
5893 } |
|
5894 this.uiDialog |
|
5895 // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781 |
|
5896 .css({ top: 0, left: 0 }) |
|
5897 .position({ |
|
5898 my: myAt.join(' '), |
|
5899 at: myAt.join(' '), |
|
5900 offset: offset.join(' '), |
|
5901 of: window, |
|
5902 collision: 'fit', |
|
5903 // ensure that the titlebar is never outside the document |
|
5904 using: function(pos) { |
|
5905 var topOffset = $(this).css(pos).offset().top; |
|
5906 if (topOffset < 0) { |
|
5907 $(this).css('top', pos.top - topOffset); |
|
5908 } |
|
5909 } |
|
5910 }); |
|
5911 if (!isVisible) { |
|
5912 this.uiDialog.hide(); |
|
5913 } |
|
5914 }, |
|
5915 |
|
5916 _setOption: function(key, value){ |
|
5917 var self = this, |
|
5918 uiDialog = self.uiDialog, |
|
5919 isResizable = uiDialog.is(':data(resizable)'), |
|
5920 resize = false; |
|
5921 |
|
5922 switch (key) { |
|
5923 //handling of deprecated beforeclose (vs beforeClose) option |
|
5924 //Ticket #4669 http://dev.jqueryui.com/ticket/4669 |
|
5925 //TODO: remove in 1.9pre |
|
5926 case "beforeclose": |
|
5927 key = "beforeClose"; |
|
5928 break; |
|
5929 case "buttons": |
|
5930 self._createButtons(value); |
|
5931 break; |
|
5932 case "closeText": |
|
5933 // convert whatever was passed in to a string, for text() to not throw up |
|
5934 self.uiDialogTitlebarCloseText.text("" + value); |
|
5935 break; |
|
5936 case "dialogClass": |
|
5937 uiDialog |
|
5938 .removeClass(self.options.dialogClass) |
|
5939 .addClass(uiDialogClasses + value); |
|
5940 break; |
|
5941 case "disabled": |
|
5942 if (value) { |
|
5943 uiDialog.addClass('ui-dialog-disabled'); |
|
5944 } else { |
|
5945 uiDialog.removeClass('ui-dialog-disabled'); |
|
5946 } |
|
5947 break; |
|
5948 case "draggable": |
|
5949 if (value) { |
|
5950 self._makeDraggable(); |
|
5951 } else { |
|
5952 uiDialog.draggable('destroy'); |
|
5953 } |
|
5954 break; |
|
5955 case "height": |
|
5956 resize = true; |
|
5957 break; |
|
5958 case "maxHeight": |
|
5959 if (isResizable) { |
|
5960 uiDialog.resizable('option', 'maxHeight', value); |
|
5961 } |
|
5962 resize = true; |
|
5963 break; |
|
5964 case "maxWidth": |
|
5965 if (isResizable) { |
|
5966 uiDialog.resizable('option', 'maxWidth', value); |
|
5967 } |
|
5968 resize = true; |
|
5969 break; |
|
5970 case "minHeight": |
|
5971 if (isResizable) { |
|
5972 uiDialog.resizable('option', 'minHeight', value); |
|
5973 } |
|
5974 resize = true; |
|
5975 break; |
|
5976 case "minWidth": |
|
5977 if (isResizable) { |
|
5978 uiDialog.resizable('option', 'minWidth', value); |
|
5979 } |
|
5980 resize = true; |
|
5981 break; |
|
5982 case "position": |
|
5983 self._position(value); |
|
5984 break; |
|
5985 case "resizable": |
|
5986 // currently resizable, becoming non-resizable |
|
5987 if (isResizable && !value) { |
|
5988 uiDialog.resizable('destroy'); |
|
5989 } |
|
5990 |
|
5991 // currently resizable, changing handles |
|
5992 if (isResizable && typeof value === 'string') { |
|
5993 uiDialog.resizable('option', 'handles', value); |
|
5994 } |
|
5995 |
|
5996 // currently non-resizable, becoming resizable |
|
5997 if (!isResizable && value !== false) { |
|
5998 self._makeResizable(value); |
|
5999 } |
|
6000 break; |
|
6001 case "title": |
|
6002 // convert whatever was passed in o a string, for html() to not throw up |
|
6003 $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || ' ')); |
|
6004 break; |
|
6005 case "width": |
|
6006 resize = true; |
|
6007 break; |
|
6008 } |
|
6009 |
|
6010 $.Widget.prototype._setOption.apply(self, arguments); |
|
6011 if (resize) { |
|
6012 self._size(); |
|
6013 } |
|
6014 }, |
|
6015 |
|
6016 _size: function() { |
|
6017 /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content |
|
6018 * divs will both have width and height set, so we need to reset them |
|
6019 */ |
|
6020 var options = this.options, |
|
6021 nonContentHeight; |
|
6022 |
|
6023 // reset content sizing |
|
6024 // hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350) |
|
6025 this.element.css({ |
|
6026 width: 'auto', |
|
6027 minHeight: 0, |
|
6028 height: 0 |
|
6029 }); |
|
6030 |
|
6031 // reset wrapper sizing |
|
6032 // determine the height of all the non-content elements |
|
6033 nonContentHeight = this.uiDialog.css({ |
|
6034 height: 'auto', |
|
6035 width: options.width |
|
6036 }) |
|
6037 .height(); |
|
6038 |
|
6039 this.element |
|
6040 .css(options.height === 'auto' ? { |
|
6041 minHeight: Math.max(options.minHeight - nonContentHeight, 0), |
|
6042 height: 'auto' |
|
6043 } : { |
|
6044 minHeight: 0, |
|
6045 height: Math.max(options.height - nonContentHeight, 0) |
|
6046 }) |
|
6047 .show(); |
|
6048 |
|
6049 if (this.uiDialog.is(':data(resizable)')) { |
|
6050 this.uiDialog.resizable('option', 'minHeight', this._minHeight()); |
|
6051 } |
|
6052 } |
|
6053 }); |
|
6054 |
|
6055 $.extend($.ui.dialog, { |
|
6056 version: "1.8.1", |
|
6057 |
|
6058 uuid: 0, |
|
6059 maxZ: 0, |
|
6060 |
|
6061 getTitleId: function($el) { |
|
6062 var id = $el.attr('id'); |
|
6063 if (!id) { |
|
6064 this.uuid += 1; |
|
6065 id = this.uuid; |
|
6066 } |
|
6067 return 'ui-dialog-title-' + id; |
|
6068 }, |
|
6069 |
|
6070 overlay: function(dialog) { |
|
6071 this.$el = $.ui.dialog.overlay.create(dialog); |
|
6072 } |
|
6073 }); |
|
6074 |
|
6075 $.extend($.ui.dialog.overlay, { |
|
6076 instances: [], |
|
6077 // reuse old instances due to IE memory leak with alpha transparency (see #5185) |
|
6078 oldInstances: [], |
|
6079 maxZ: 0, |
|
6080 events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), |
|
6081 function(event) { return event + '.dialog-overlay'; }).join(' '), |
|
6082 create: function(dialog) { |
|
6083 if (this.instances.length === 0) { |
|
6084 // prevent use of anchors and inputs |
|
6085 // we use a setTimeout in case the overlay is created from an |
|
6086 // event that we're going to be cancelling (see #2804) |
|
6087 setTimeout(function() { |
|
6088 // handle $(el).dialog().dialog('close') (see #4065) |
|
6089 if ($.ui.dialog.overlay.instances.length) { |
|
6090 $(document).bind($.ui.dialog.overlay.events, function(event) { |
|
6091 // stop events if the z-index of the target is < the z-index of the overlay |
|
6092 return ($(event.target).zIndex() >= $.ui.dialog.overlay.maxZ); |
|
6093 }); |
|
6094 } |
|
6095 }, 1); |
|
6096 |
|
6097 // allow closing by pressing the escape key |
|
6098 $(document).bind('keydown.dialog-overlay', function(event) { |
|
6099 if (dialog.options.closeOnEscape && event.keyCode && |
|
6100 event.keyCode === $.ui.keyCode.ESCAPE) { |
|
6101 |
|
6102 dialog.close(event); |
|
6103 event.preventDefault(); |
|
6104 } |
|
6105 }); |
|
6106 |
|
6107 // handle window resize |
|
6108 $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); |
|
6109 } |
|
6110 |
|
6111 var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay')) |
|
6112 .appendTo(document.body) |
|
6113 .css({ |
|
6114 width: this.width(), |
|
6115 height: this.height() |
|
6116 }); |
|
6117 |
|
6118 if ($.fn.bgiframe) { |
|
6119 $el.bgiframe(); |
|
6120 } |
|
6121 |
|
6122 this.instances.push($el); |
|
6123 return $el; |
|
6124 }, |
|
6125 |
|
6126 destroy: function($el) { |
|
6127 this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]); |
|
6128 |
|
6129 if (this.instances.length === 0) { |
|
6130 $([document, window]).unbind('.dialog-overlay'); |
|
6131 } |
|
6132 |
|
6133 $el.remove(); |
|
6134 |
|
6135 // adjust the maxZ to allow other modal dialogs to continue to work (see #4309) |
|
6136 var maxZ = 0; |
|
6137 $.each(this.instances, function() { |
|
6138 maxZ = Math.max(maxZ, this.css('z-index')); |
|
6139 }); |
|
6140 this.maxZ = maxZ; |
|
6141 }, |
|
6142 |
|
6143 height: function() { |
|
6144 var scrollHeight, |
|
6145 offsetHeight; |
|
6146 // handle IE 6 |
|
6147 if ($.browser.msie && $.browser.version < 7) { |
|
6148 scrollHeight = Math.max( |
|
6149 document.documentElement.scrollHeight, |
|
6150 document.body.scrollHeight |
|
6151 ); |
|
6152 offsetHeight = Math.max( |
|
6153 document.documentElement.offsetHeight, |
|
6154 document.body.offsetHeight |
|
6155 ); |
|
6156 |
|
6157 if (scrollHeight < offsetHeight) { |
|
6158 return $(window).height() + 'px'; |
|
6159 } else { |
|
6160 return scrollHeight + 'px'; |
|
6161 } |
|
6162 // handle "good" browsers |
|
6163 } else { |
|
6164 return $(document).height() + 'px'; |
|
6165 } |
|
6166 }, |
|
6167 |
|
6168 width: function() { |
|
6169 var scrollWidth, |
|
6170 offsetWidth; |
|
6171 // handle IE 6 |
|
6172 if ($.browser.msie && $.browser.version < 7) { |
|
6173 scrollWidth = Math.max( |
|
6174 document.documentElement.scrollWidth, |
|
6175 document.body.scrollWidth |
|
6176 ); |
|
6177 offsetWidth = Math.max( |
|
6178 document.documentElement.offsetWidth, |
|
6179 document.body.offsetWidth |
|
6180 ); |
|
6181 |
|
6182 if (scrollWidth < offsetWidth) { |
|
6183 return $(window).width() + 'px'; |
|
6184 } else { |
|
6185 return scrollWidth + 'px'; |
|
6186 } |
|
6187 // handle "good" browsers |
|
6188 } else { |
|
6189 return $(document).width() + 'px'; |
|
6190 } |
|
6191 }, |
|
6192 |
|
6193 resize: function() { |
|
6194 /* If the dialog is draggable and the user drags it past the |
|
6195 * right edge of the window, the document becomes wider so we |
|
6196 * need to stretch the overlay. If the user then drags the |
|
6197 * dialog back to the left, the document will become narrower, |
|
6198 * so we need to shrink the overlay to the appropriate size. |
|
6199 * This is handled by shrinking the overlay before setting it |
|
6200 * to the full document size. |
|
6201 */ |
|
6202 var $overlays = $([]); |
|
6203 $.each($.ui.dialog.overlay.instances, function() { |
|
6204 $overlays = $overlays.add(this); |
|
6205 }); |
|
6206 |
|
6207 $overlays.css({ |
|
6208 width: 0, |
|
6209 height: 0 |
|
6210 }).css({ |
|
6211 width: $.ui.dialog.overlay.width(), |
|
6212 height: $.ui.dialog.overlay.height() |
|
6213 }); |
|
6214 } |
|
6215 }); |
|
6216 |
|
6217 $.extend($.ui.dialog.overlay.prototype, { |
|
6218 destroy: function() { |
|
6219 $.ui.dialog.overlay.destroy(this.$el); |
|
6220 } |
|
6221 }); |
|
6222 |
|
6223 }(jQuery)); |
|
6224 /* |
|
6225 * jQuery UI Slider 1.8.1 |
|
6226 * |
|
6227 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
6228 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
6229 * and GPL (GPL-LICENSE.txt) licenses. |
|
6230 * |
|
6231 * http://docs.jquery.com/UI/Slider |
|
6232 * |
|
6233 * Depends: |
|
6234 * jquery.ui.core.js |
|
6235 * jquery.ui.mouse.js |
|
6236 * jquery.ui.widget.js |
|
6237 */ |
|
6238 |
|
6239 (function( $ ) { |
|
6240 |
|
6241 // number of pages in a slider |
|
6242 // (how many times can you page up/down to go through the whole range) |
|
6243 var numPages = 5; |
|
6244 |
|
6245 $.widget( "ui.slider", $.ui.mouse, { |
|
6246 |
|
6247 widgetEventPrefix: "slide", |
|
6248 |
|
6249 options: { |
|
6250 animate: false, |
|
6251 distance: 0, |
|
6252 max: 100, |
|
6253 min: 0, |
|
6254 orientation: "horizontal", |
|
6255 range: false, |
|
6256 step: 1, |
|
6257 value: 0, |
|
6258 values: null |
|
6259 }, |
|
6260 |
|
6261 _create: function() { |
|
6262 var self = this, |
|
6263 o = this.options; |
|
6264 |
|
6265 this._keySliding = false; |
|
6266 this._mouseSliding = false; |
|
6267 this._animateOff = true; |
|
6268 this._handleIndex = null; |
|
6269 this._detectOrientation(); |
|
6270 this._mouseInit(); |
|
6271 |
|
6272 this.element |
|
6273 .addClass( "ui-slider" + |
|
6274 " ui-slider-" + this.orientation + |
|
6275 " ui-widget" + |
|
6276 " ui-widget-content" + |
|
6277 " ui-corner-all" ); |
|
6278 |
|
6279 if ( o.disabled ) { |
|
6280 this.element.addClass( "ui-slider-disabled ui-disabled" ); |
|
6281 } |
|
6282 |
|
6283 this.range = $([]); |
|
6284 |
|
6285 if ( o.range ) { |
|
6286 if ( o.range === true ) { |
|
6287 this.range = $( "<div></div>" ); |
|
6288 if ( !o.values ) { |
|
6289 o.values = [ this._valueMin(), this._valueMin() ]; |
|
6290 } |
|
6291 if ( o.values.length && o.values.length !== 2 ) { |
|
6292 o.values = [ o.values[0], o.values[0] ]; |
|
6293 } |
|
6294 } else { |
|
6295 this.range = $( "<div></div>" ); |
|
6296 } |
|
6297 |
|
6298 this.range |
|
6299 .appendTo( this.element ) |
|
6300 .addClass( "ui-slider-range" ); |
|
6301 |
|
6302 if ( o.range === "min" || o.range === "max" ) { |
|
6303 this.range.addClass( "ui-slider-range-" + o.range ); |
|
6304 } |
|
6305 |
|
6306 // note: this isn't the most fittingly semantic framework class for this element, |
|
6307 // but worked best visually with a variety of themes |
|
6308 this.range.addClass( "ui-widget-header" ); |
|
6309 } |
|
6310 |
|
6311 if ( $( ".ui-slider-handle", this.element ).length === 0 ) { |
|
6312 $( "<a href='#'></a>" ) |
|
6313 .appendTo( this.element ) |
|
6314 .addClass( "ui-slider-handle" ); |
|
6315 } |
|
6316 |
|
6317 if ( o.values && o.values.length ) { |
|
6318 while ( $(".ui-slider-handle", this.element).length < o.values.length ) { |
|
6319 $( "<a href='#'></a>" ) |
|
6320 .appendTo( this.element ) |
|
6321 .addClass( "ui-slider-handle" ); |
|
6322 } |
|
6323 } |
|
6324 |
|
6325 this.handles = $( ".ui-slider-handle", this.element ) |
|
6326 .addClass( "ui-state-default" + |
|
6327 " ui-corner-all" ); |
|
6328 |
|
6329 this.handle = this.handles.eq( 0 ); |
|
6330 |
|
6331 this.handles.add( this.range ).filter( "a" ) |
|
6332 .click(function( event ) { |
|
6333 event.preventDefault(); |
|
6334 }) |
|
6335 .hover(function() { |
|
6336 if ( !o.disabled ) { |
|
6337 $( this ).addClass( "ui-state-hover" ); |
|
6338 } |
|
6339 }, function() { |
|
6340 $( this ).removeClass( "ui-state-hover" ); |
|
6341 }) |
|
6342 .focus(function() { |
|
6343 if ( !o.disabled ) { |
|
6344 $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" ); |
|
6345 $( this ).addClass( "ui-state-focus" ); |
|
6346 } else { |
|
6347 $( this ).blur(); |
|
6348 } |
|
6349 }) |
|
6350 .blur(function() { |
|
6351 $( this ).removeClass( "ui-state-focus" ); |
|
6352 }); |
|
6353 |
|
6354 this.handles.each(function( i ) { |
|
6355 $( this ).data( "index.ui-slider-handle", i ); |
|
6356 }); |
|
6357 |
|
6358 this.handles |
|
6359 .keydown(function( event ) { |
|
6360 var ret = true, |
|
6361 index = $( this ).data( "index.ui-slider-handle" ), |
|
6362 allowed, |
|
6363 curVal, |
|
6364 newVal, |
|
6365 step; |
|
6366 |
|
6367 if ( self.options.disabled ) { |
|
6368 return; |
|
6369 } |
|
6370 |
|
6371 switch ( event.keyCode ) { |
|
6372 case $.ui.keyCode.HOME: |
|
6373 case $.ui.keyCode.END: |
|
6374 case $.ui.keyCode.PAGE_UP: |
|
6375 case $.ui.keyCode.PAGE_DOWN: |
|
6376 case $.ui.keyCode.UP: |
|
6377 case $.ui.keyCode.RIGHT: |
|
6378 case $.ui.keyCode.DOWN: |
|
6379 case $.ui.keyCode.LEFT: |
|
6380 ret = false; |
|
6381 if ( !self._keySliding ) { |
|
6382 self._keySliding = true; |
|
6383 $( this ).addClass( "ui-state-active" ); |
|
6384 allowed = self._start( event, index ); |
|
6385 if ( allowed === false ) { |
|
6386 return; |
|
6387 } |
|
6388 } |
|
6389 break; |
|
6390 } |
|
6391 |
|
6392 step = self.options.step; |
|
6393 if ( self.options.values && self.options.values.length ) { |
|
6394 curVal = newVal = self.values( index ); |
|
6395 } else { |
|
6396 curVal = newVal = self.value(); |
|
6397 } |
|
6398 |
|
6399 switch ( event.keyCode ) { |
|
6400 case $.ui.keyCode.HOME: |
|
6401 newVal = self._valueMin(); |
|
6402 break; |
|
6403 case $.ui.keyCode.END: |
|
6404 newVal = self._valueMax(); |
|
6405 break; |
|
6406 case $.ui.keyCode.PAGE_UP: |
|
6407 newVal = curVal + ( (self._valueMax() - self._valueMin()) / numPages ); |
|
6408 break; |
|
6409 case $.ui.keyCode.PAGE_DOWN: |
|
6410 newVal = curVal - ( (self._valueMax() - self._valueMin()) / numPages ); |
|
6411 break; |
|
6412 case $.ui.keyCode.UP: |
|
6413 case $.ui.keyCode.RIGHT: |
|
6414 if ( curVal === self._valueMax() ) { |
|
6415 return; |
|
6416 } |
|
6417 newVal = curVal + step; |
|
6418 break; |
|
6419 case $.ui.keyCode.DOWN: |
|
6420 case $.ui.keyCode.LEFT: |
|
6421 if ( curVal === self._valueMin() ) { |
|
6422 return; |
|
6423 } |
|
6424 newVal = curVal - step; |
|
6425 break; |
|
6426 } |
|
6427 |
|
6428 self._slide( event, index, newVal ); |
|
6429 |
|
6430 return ret; |
|
6431 |
|
6432 }) |
|
6433 .keyup(function( event ) { |
|
6434 var index = $( this ).data( "index.ui-slider-handle" ); |
|
6435 |
|
6436 if ( self._keySliding ) { |
|
6437 self._keySliding = false; |
|
6438 self._stop( event, index ); |
|
6439 self._change( event, index ); |
|
6440 $( this ).removeClass( "ui-state-active" ); |
|
6441 } |
|
6442 |
|
6443 }); |
|
6444 |
|
6445 this._refreshValue(); |
|
6446 |
|
6447 this._animateOff = false; |
|
6448 }, |
|
6449 |
|
6450 destroy: function() { |
|
6451 this.handles.remove(); |
|
6452 this.range.remove(); |
|
6453 |
|
6454 this.element |
|
6455 .removeClass( "ui-slider" + |
|
6456 " ui-slider-horizontal" + |
|
6457 " ui-slider-vertical" + |
|
6458 " ui-slider-disabled" + |
|
6459 " ui-widget" + |
|
6460 " ui-widget-content" + |
|
6461 " ui-corner-all" ) |
|
6462 .removeData( "slider" ) |
|
6463 .unbind( ".slider" ); |
|
6464 |
|
6465 this._mouseDestroy(); |
|
6466 |
|
6467 return this; |
|
6468 }, |
|
6469 |
|
6470 _mouseCapture: function( event ) { |
|
6471 var o = this.options, |
|
6472 position, |
|
6473 normValue, |
|
6474 distance, |
|
6475 closestHandle, |
|
6476 self, |
|
6477 index, |
|
6478 allowed, |
|
6479 offset, |
|
6480 mouseOverHandle; |
|
6481 |
|
6482 if ( o.disabled ) { |
|
6483 return false; |
|
6484 } |
|
6485 |
|
6486 this.elementSize = { |
|
6487 width: this.element.outerWidth(), |
|
6488 height: this.element.outerHeight() |
|
6489 }; |
|
6490 this.elementOffset = this.element.offset(); |
|
6491 |
|
6492 position = { x: event.pageX, y: event.pageY }; |
|
6493 normValue = this._normValueFromMouse( position ); |
|
6494 distance = this._valueMax() - this._valueMin() + 1; |
|
6495 self = this; |
|
6496 this.handles.each(function( i ) { |
|
6497 var thisDistance = Math.abs( normValue - self.values(i) ); |
|
6498 if ( distance > thisDistance ) { |
|
6499 distance = thisDistance; |
|
6500 closestHandle = $( this ); |
|
6501 index = i; |
|
6502 } |
|
6503 }); |
|
6504 |
|
6505 // workaround for bug #3736 (if both handles of a range are at 0, |
|
6506 // the first is always used as the one with least distance, |
|
6507 // and moving it is obviously prevented by preventing negative ranges) |
|
6508 if( o.range === true && this.values(1) === o.min ) { |
|
6509 index += 1; |
|
6510 closestHandle = $( this.handles[index] ); |
|
6511 } |
|
6512 |
|
6513 allowed = this._start( event, index ); |
|
6514 if ( allowed === false ) { |
|
6515 return false; |
|
6516 } |
|
6517 this._mouseSliding = true; |
|
6518 |
|
6519 self._handleIndex = index; |
|
6520 |
|
6521 closestHandle |
|
6522 .addClass( "ui-state-active" ) |
|
6523 .focus(); |
|
6524 |
|
6525 offset = closestHandle.offset(); |
|
6526 mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" ); |
|
6527 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { |
|
6528 left: event.pageX - offset.left - ( closestHandle.width() / 2 ), |
|
6529 top: event.pageY - offset.top - |
|
6530 ( closestHandle.height() / 2 ) - |
|
6531 ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) - |
|
6532 ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) + |
|
6533 ( parseInt( closestHandle.css("marginTop"), 10 ) || 0) |
|
6534 }; |
|
6535 |
|
6536 normValue = this._normValueFromMouse( position ); |
|
6537 this._slide( event, index, normValue ); |
|
6538 this._animateOff = true; |
|
6539 return true; |
|
6540 }, |
|
6541 |
|
6542 _mouseStart: function( event ) { |
|
6543 return true; |
|
6544 }, |
|
6545 |
|
6546 _mouseDrag: function( event ) { |
|
6547 var position = { x: event.pageX, y: event.pageY }, |
|
6548 normValue = this._normValueFromMouse( position ); |
|
6549 |
|
6550 this._slide( event, this._handleIndex, normValue ); |
|
6551 |
|
6552 return false; |
|
6553 }, |
|
6554 |
|
6555 _mouseStop: function( event ) { |
|
6556 this.handles.removeClass( "ui-state-active" ); |
|
6557 this._mouseSliding = false; |
|
6558 |
|
6559 this._stop( event, this._handleIndex ); |
|
6560 this._change( event, this._handleIndex ); |
|
6561 |
|
6562 this._handleIndex = null; |
|
6563 this._clickOffset = null; |
|
6564 this._animateOff = false; |
|
6565 |
|
6566 return false; |
|
6567 }, |
|
6568 |
|
6569 _detectOrientation: function() { |
|
6570 this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; |
|
6571 }, |
|
6572 |
|
6573 _normValueFromMouse: function( position ) { |
|
6574 var pixelTotal, |
|
6575 pixelMouse, |
|
6576 percentMouse, |
|
6577 valueTotal, |
|
6578 valueMouse; |
|
6579 |
|
6580 if ( this.orientation === "horizontal" ) { |
|
6581 pixelTotal = this.elementSize.width; |
|
6582 pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 ); |
|
6583 } else { |
|
6584 pixelTotal = this.elementSize.height; |
|
6585 pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 ); |
|
6586 } |
|
6587 |
|
6588 percentMouse = ( pixelMouse / pixelTotal ); |
|
6589 if ( percentMouse > 1 ) { |
|
6590 percentMouse = 1; |
|
6591 } |
|
6592 if ( percentMouse < 0 ) { |
|
6593 percentMouse = 0; |
|
6594 } |
|
6595 if ( this.orientation === "vertical" ) { |
|
6596 percentMouse = 1 - percentMouse; |
|
6597 } |
|
6598 |
|
6599 valueTotal = this._valueMax() - this._valueMin(); |
|
6600 valueMouse = this._valueMin() + percentMouse * valueTotal; |
|
6601 |
|
6602 return this._trimAlignValue( valueMouse ); |
|
6603 }, |
|
6604 |
|
6605 _start: function( event, index ) { |
|
6606 var uiHash = { |
|
6607 handle: this.handles[ index ], |
|
6608 value: this.value() |
|
6609 }; |
|
6610 if ( this.options.values && this.options.values.length ) { |
|
6611 uiHash.value = this.values( index ); |
|
6612 uiHash.values = this.values(); |
|
6613 } |
|
6614 return this._trigger( "start", event, uiHash ); |
|
6615 }, |
|
6616 |
|
6617 _slide: function( event, index, newVal ) { |
|
6618 var otherVal, |
|
6619 newValues, |
|
6620 allowed; |
|
6621 |
|
6622 if ( this.options.values && this.options.values.length ) { |
|
6623 otherVal = this.values( index ? 0 : 1 ); |
|
6624 |
|
6625 if ( ( this.options.values.length === 2 && this.options.range === true ) && |
|
6626 ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) ) |
|
6627 ) { |
|
6628 newVal = otherVal; |
|
6629 } |
|
6630 |
|
6631 if ( newVal !== this.values( index ) ) { |
|
6632 newValues = this.values(); |
|
6633 newValues[ index ] = newVal; |
|
6634 // A slide can be canceled by returning false from the slide callback |
|
6635 allowed = this._trigger( "slide", event, { |
|
6636 handle: this.handles[ index ], |
|
6637 value: newVal, |
|
6638 values: newValues |
|
6639 } ); |
|
6640 otherVal = this.values( index ? 0 : 1 ); |
|
6641 if ( allowed !== false ) { |
|
6642 this.values( index, newVal, true ); |
|
6643 } |
|
6644 } |
|
6645 } else { |
|
6646 if ( newVal !== this.value() ) { |
|
6647 // A slide can be canceled by returning false from the slide callback |
|
6648 allowed = this._trigger( "slide", event, { |
|
6649 handle: this.handles[ index ], |
|
6650 value: newVal |
|
6651 } ); |
|
6652 if ( allowed !== false ) { |
|
6653 this.value( newVal ); |
|
6654 } |
|
6655 } |
|
6656 } |
|
6657 }, |
|
6658 |
|
6659 _stop: function( event, index ) { |
|
6660 var uiHash = { |
|
6661 handle: this.handles[ index ], |
|
6662 value: this.value() |
|
6663 }; |
|
6664 if ( this.options.values && this.options.values.length ) { |
|
6665 uiHash.value = this.values( index ); |
|
6666 uiHash.values = this.values(); |
|
6667 } |
|
6668 |
|
6669 this._trigger( "stop", event, uiHash ); |
|
6670 }, |
|
6671 |
|
6672 _change: function( event, index ) { |
|
6673 if ( !this._keySliding && !this._mouseSliding ) { |
|
6674 var uiHash = { |
|
6675 handle: this.handles[ index ], |
|
6676 value: this.value() |
|
6677 }; |
|
6678 if ( this.options.values && this.options.values.length ) { |
|
6679 uiHash.value = this.values( index ); |
|
6680 uiHash.values = this.values(); |
|
6681 } |
|
6682 |
|
6683 this._trigger( "change", event, uiHash ); |
|
6684 } |
|
6685 }, |
|
6686 |
|
6687 value: function( newValue ) { |
|
6688 if ( arguments.length ) { |
|
6689 this.options.value = this._trimAlignValue( newValue ); |
|
6690 this._refreshValue(); |
|
6691 this._change( null, 0 ); |
|
6692 } |
|
6693 |
|
6694 return this._value(); |
|
6695 }, |
|
6696 |
|
6697 values: function( index, newValue ) { |
|
6698 var vals, |
|
6699 newValues, |
|
6700 i; |
|
6701 |
|
6702 if ( arguments.length > 1 ) { |
|
6703 this.options.values[ index ] = this._trimAlignValue( newValue ); |
|
6704 this._refreshValue(); |
|
6705 this._change( null, index ); |
|
6706 } |
|
6707 |
|
6708 if ( arguments.length ) { |
|
6709 if ( $.isArray( arguments[ 0 ] ) ) { |
|
6710 vals = this.options.values; |
|
6711 newValues = arguments[ 0 ]; |
|
6712 for ( i = 0; i < vals.length; i += 1 ) { |
|
6713 vals[ i ] = this._trimAlignValue( newValues[ i ] ); |
|
6714 this._change( null, i ); |
|
6715 } |
|
6716 this._refreshValue(); |
|
6717 } else { |
|
6718 if ( this.options.values && this.options.values.length ) { |
|
6719 return this._values( index ); |
|
6720 } else { |
|
6721 return this.value(); |
|
6722 } |
|
6723 } |
|
6724 } else { |
|
6725 return this._values(); |
|
6726 } |
|
6727 }, |
|
6728 |
|
6729 _setOption: function( key, value ) { |
|
6730 var i, |
|
6731 valsLength = 0; |
|
6732 |
|
6733 if ( $.isArray( this.options.values ) ) { |
|
6734 valsLength = this.options.values.length; |
|
6735 } |
|
6736 |
|
6737 $.Widget.prototype._setOption.apply( this, arguments ); |
|
6738 |
|
6739 switch ( key ) { |
|
6740 case "disabled": |
|
6741 if ( value ) { |
|
6742 this.handles.filter( ".ui-state-focus" ).blur(); |
|
6743 this.handles.removeClass( "ui-state-hover" ); |
|
6744 this.handles.attr( "disabled", "disabled" ); |
|
6745 this.element.addClass( "ui-disabled" ); |
|
6746 } else { |
|
6747 this.handles.removeAttr( "disabled" ); |
|
6748 this.element.removeClass( "ui-disabled" ); |
|
6749 } |
|
6750 break; |
|
6751 case "orientation": |
|
6752 this._detectOrientation(); |
|
6753 this.element |
|
6754 .removeClass( "ui-slider-horizontal ui-slider-vertical" ) |
|
6755 .addClass( "ui-slider-" + this.orientation ); |
|
6756 this._refreshValue(); |
|
6757 break; |
|
6758 case "value": |
|
6759 this._animateOff = true; |
|
6760 this._refreshValue(); |
|
6761 this._change( null, 0 ); |
|
6762 this._animateOff = false; |
|
6763 break; |
|
6764 case "values": |
|
6765 this._animateOff = true; |
|
6766 this._refreshValue(); |
|
6767 for ( i = 0; i < valsLength; i += 1 ) { |
|
6768 this._change( null, i ); |
|
6769 } |
|
6770 this._animateOff = false; |
|
6771 break; |
|
6772 } |
|
6773 }, |
|
6774 |
|
6775 //internal value getter |
|
6776 // _value() returns value trimmed by min and max, aligned by step |
|
6777 _value: function() { |
|
6778 var val = this.options.value; |
|
6779 val = this._trimAlignValue( val ); |
|
6780 |
|
6781 return val; |
|
6782 }, |
|
6783 |
|
6784 //internal values getter |
|
6785 // _values() returns array of values trimmed by min and max, aligned by step |
|
6786 // _values( index ) returns single value trimmed by min and max, aligned by step |
|
6787 _values: function( index ) { |
|
6788 var val, |
|
6789 vals, |
|
6790 i; |
|
6791 |
|
6792 if ( arguments.length ) { |
|
6793 val = this.options.values[ index ]; |
|
6794 val = this._trimAlignValue( val ); |
|
6795 |
|
6796 return val; |
|
6797 } else { |
|
6798 // .slice() creates a copy of the array |
|
6799 // this copy gets trimmed by min and max and then returned |
|
6800 vals = this.options.values.slice(); |
|
6801 for ( i = 0; i < vals.length; i+= 1) { |
|
6802 vals[ i ] = this._trimAlignValue( vals[ i ] ); |
|
6803 } |
|
6804 |
|
6805 return vals; |
|
6806 } |
|
6807 }, |
|
6808 |
|
6809 // returns the step-aligned value that val is closest to, between (inclusive) min and max |
|
6810 _trimAlignValue: function( val ) { |
|
6811 if ( val < this._valueMin() ) { |
|
6812 return this._valueMin(); |
|
6813 } |
|
6814 if ( val > this._valueMax() ) { |
|
6815 return this._valueMax(); |
|
6816 } |
|
6817 var step = this.options.step, |
|
6818 valModStep = val % step, |
|
6819 alignValue = val - valModStep; |
|
6820 |
|
6821 if ( valModStep >= ( step / 2 ) ) { |
|
6822 alignValue += step; |
|
6823 } |
|
6824 |
|
6825 // Since JavaScript has problems with large floats, round |
|
6826 // the final value to 5 digits after the decimal point (see #4124) |
|
6827 return parseFloat( alignValue.toFixed(5) ); |
|
6828 }, |
|
6829 |
|
6830 _valueMin: function() { |
|
6831 return this.options.min; |
|
6832 }, |
|
6833 |
|
6834 _valueMax: function() { |
|
6835 return this.options.max; |
|
6836 }, |
|
6837 |
|
6838 _refreshValue: function() { |
|
6839 var oRange = this.options.range, |
|
6840 o = this.options, |
|
6841 self = this, |
|
6842 animate = ( !this._animateOff ) ? o.animate : false, |
|
6843 valPercent, |
|
6844 _set = {}, |
|
6845 lastValPercent, |
|
6846 value, |
|
6847 valueMin, |
|
6848 valueMax; |
|
6849 |
|
6850 if ( this.options.values && this.options.values.length ) { |
|
6851 this.handles.each(function( i, j ) { |
|
6852 valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100; |
|
6853 _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; |
|
6854 $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); |
|
6855 if ( self.options.range === true ) { |
|
6856 if ( self.orientation === "horizontal" ) { |
|
6857 if ( i === 0 ) { |
|
6858 self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate ); |
|
6859 } |
|
6860 if ( i === 1 ) { |
|
6861 self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); |
|
6862 } |
|
6863 } else { |
|
6864 if ( i === 0 ) { |
|
6865 self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate ); |
|
6866 } |
|
6867 if ( i === 1 ) { |
|
6868 self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); |
|
6869 } |
|
6870 } |
|
6871 } |
|
6872 lastValPercent = valPercent; |
|
6873 }); |
|
6874 } else { |
|
6875 value = this.value(); |
|
6876 valueMin = this._valueMin(); |
|
6877 valueMax = this._valueMax(); |
|
6878 valPercent = ( valueMax !== valueMin ) ? |
|
6879 ( value - valueMin ) / ( valueMax - valueMin ) * 100 : |
|
6880 0; |
|
6881 _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; |
|
6882 this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); |
|
6883 |
|
6884 if ( oRange === "min" && this.orientation === "horizontal" ) { |
|
6885 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate ); |
|
6886 } |
|
6887 if ( oRange === "max" && this.orientation === "horizontal" ) { |
|
6888 this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); |
|
6889 } |
|
6890 if ( oRange === "min" && this.orientation === "vertical" ) { |
|
6891 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate ); |
|
6892 } |
|
6893 if ( oRange === "max" && this.orientation === "vertical" ) { |
|
6894 this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); |
|
6895 } |
|
6896 } |
|
6897 } |
|
6898 |
|
6899 }); |
|
6900 |
|
6901 $.extend( $.ui.slider, { |
|
6902 version: "1.8.1" |
|
6903 }); |
|
6904 |
|
6905 }(jQuery)); |
|
6906 /* |
|
6907 * jQuery UI Tabs 1.8.1 |
|
6908 * |
|
6909 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
6910 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
6911 * and GPL (GPL-LICENSE.txt) licenses. |
|
6912 * |
|
6913 * http://docs.jquery.com/UI/Tabs |
|
6914 * |
|
6915 * Depends: |
|
6916 * jquery.ui.core.js |
|
6917 * jquery.ui.widget.js |
|
6918 */ |
|
6919 (function($) { |
|
6920 |
|
6921 var tabId = 0, |
|
6922 listId = 0; |
|
6923 |
|
6924 $.widget("ui.tabs", { |
|
6925 options: { |
|
6926 add: null, |
|
6927 ajaxOptions: null, |
|
6928 cache: false, |
|
6929 cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true } |
|
6930 collapsible: false, |
|
6931 disable: null, |
|
6932 disabled: [], |
|
6933 enable: null, |
|
6934 event: 'click', |
|
6935 fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 } |
|
6936 idPrefix: 'ui-tabs-', |
|
6937 load: null, |
|
6938 panelTemplate: '<div></div>', |
|
6939 remove: null, |
|
6940 select: null, |
|
6941 show: null, |
|
6942 spinner: '<em>Loading…</em>', |
|
6943 tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>' |
|
6944 }, |
|
6945 _create: function() { |
|
6946 this._tabify(true); |
|
6947 }, |
|
6948 |
|
6949 _setOption: function(key, value) { |
|
6950 if (key == 'selected') { |
|
6951 if (this.options.collapsible && value == this.options.selected) { |
|
6952 return; |
|
6953 } |
|
6954 this.select(value); |
|
6955 } |
|
6956 else { |
|
6957 this.options[key] = value; |
|
6958 this._tabify(); |
|
6959 } |
|
6960 }, |
|
6961 |
|
6962 _tabId: function(a) { |
|
6963 return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') || |
|
6964 this.options.idPrefix + (++tabId); |
|
6965 }, |
|
6966 |
|
6967 _sanitizeSelector: function(hash) { |
|
6968 return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":" |
|
6969 }, |
|
6970 |
|
6971 _cookie: function() { |
|
6972 var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + (++listId)); |
|
6973 return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); |
|
6974 }, |
|
6975 |
|
6976 _ui: function(tab, panel) { |
|
6977 return { |
|
6978 tab: tab, |
|
6979 panel: panel, |
|
6980 index: this.anchors.index(tab) |
|
6981 }; |
|
6982 }, |
|
6983 |
|
6984 _cleanup: function() { |
|
6985 // restore all former loading tabs labels |
|
6986 this.lis.filter('.ui-state-processing').removeClass('ui-state-processing') |
|
6987 .find('span:data(label.tabs)') |
|
6988 .each(function() { |
|
6989 var el = $(this); |
|
6990 el.html(el.data('label.tabs')).removeData('label.tabs'); |
|
6991 }); |
|
6992 }, |
|
6993 |
|
6994 _tabify: function(init) { |
|
6995 |
|
6996 this.list = this.element.find('ol,ul').eq(0); |
|
6997 this.lis = $('li:has(a[href])', this.list); |
|
6998 this.anchors = this.lis.map(function() { return $('a', this)[0]; }); |
|
6999 this.panels = $([]); |
|
7000 |
|
7001 var self = this, o = this.options; |
|
7002 |
|
7003 var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash |
|
7004 this.anchors.each(function(i, a) { |
|
7005 var href = $(a).attr('href'); |
|
7006 |
|
7007 // For dynamically created HTML that contains a hash as href IE < 8 expands |
|
7008 // such href to the full page url with hash and then misinterprets tab as ajax. |
|
7009 // Same consideration applies for an added tab with a fragment identifier |
|
7010 // since a[href=#fragment-identifier] does unexpectedly not match. |
|
7011 // Thus normalize href attribute... |
|
7012 var hrefBase = href.split('#')[0], baseEl; |
|
7013 if (hrefBase && (hrefBase === location.toString().split('#')[0] || |
|
7014 (baseEl = $('base')[0]) && hrefBase === baseEl.href)) { |
|
7015 href = a.hash; |
|
7016 a.href = href; |
|
7017 } |
|
7018 |
|
7019 // inline tab |
|
7020 if (fragmentId.test(href)) { |
|
7021 self.panels = self.panels.add(self._sanitizeSelector(href)); |
|
7022 } |
|
7023 |
|
7024 // remote tab |
|
7025 else if (href != '#') { // prevent loading the page itself if href is just "#" |
|
7026 $.data(a, 'href.tabs', href); // required for restore on destroy |
|
7027 |
|
7028 // TODO until #3808 is fixed strip fragment identifier from url |
|
7029 // (IE fails to load from such url) |
|
7030 $.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data |
|
7031 |
|
7032 var id = self._tabId(a); |
|
7033 a.href = '#' + id; |
|
7034 var $panel = $('#' + id); |
|
7035 if (!$panel.length) { |
|
7036 $panel = $(o.panelTemplate).attr('id', id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom') |
|
7037 .insertAfter(self.panels[i - 1] || self.list); |
|
7038 $panel.data('destroy.tabs', true); |
|
7039 } |
|
7040 self.panels = self.panels.add($panel); |
|
7041 } |
|
7042 |
|
7043 // invalid tab href |
|
7044 else { |
|
7045 o.disabled.push(i); |
|
7046 } |
|
7047 }); |
|
7048 |
|
7049 // initialization from scratch |
|
7050 if (init) { |
|
7051 |
|
7052 // attach necessary classes for styling |
|
7053 this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all'); |
|
7054 this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); |
|
7055 this.lis.addClass('ui-state-default ui-corner-top'); |
|
7056 this.panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom'); |
|
7057 |
|
7058 // Selected tab |
|
7059 // use "selected" option or try to retrieve: |
|
7060 // 1. from fragment identifier in url |
|
7061 // 2. from cookie |
|
7062 // 3. from selected class attribute on <li> |
|
7063 if (o.selected === undefined) { |
|
7064 if (location.hash) { |
|
7065 this.anchors.each(function(i, a) { |
|
7066 if (a.hash == location.hash) { |
|
7067 o.selected = i; |
|
7068 return false; // break |
|
7069 } |
|
7070 }); |
|
7071 } |
|
7072 if (typeof o.selected != 'number' && o.cookie) { |
|
7073 o.selected = parseInt(self._cookie(), 10); |
|
7074 } |
|
7075 if (typeof o.selected != 'number' && this.lis.filter('.ui-tabs-selected').length) { |
|
7076 o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected')); |
|
7077 } |
|
7078 o.selected = o.selected || (this.lis.length ? 0 : -1); |
|
7079 } |
|
7080 else if (o.selected === null) { // usage of null is deprecated, TODO remove in next release |
|
7081 o.selected = -1; |
|
7082 } |
|
7083 |
|
7084 // sanity check - default to first tab... |
|
7085 o.selected = ((o.selected >= 0 && this.anchors[o.selected]) || o.selected < 0) ? o.selected : 0; |
|
7086 |
|
7087 // Take disabling tabs via class attribute from HTML |
|
7088 // into account and update option properly. |
|
7089 // A selected tab cannot become disabled. |
|
7090 o.disabled = $.unique(o.disabled.concat( |
|
7091 $.map(this.lis.filter('.ui-state-disabled'), |
|
7092 function(n, i) { return self.lis.index(n); } ) |
|
7093 )).sort(); |
|
7094 |
|
7095 if ($.inArray(o.selected, o.disabled) != -1) { |
|
7096 o.disabled.splice($.inArray(o.selected, o.disabled), 1); |
|
7097 } |
|
7098 |
|
7099 // highlight selected tab |
|
7100 this.panels.addClass('ui-tabs-hide'); |
|
7101 this.lis.removeClass('ui-tabs-selected ui-state-active'); |
|
7102 if (o.selected >= 0 && this.anchors.length) { // check for length avoids error when initializing empty list |
|
7103 this.panels.eq(o.selected).removeClass('ui-tabs-hide'); |
|
7104 this.lis.eq(o.selected).addClass('ui-tabs-selected ui-state-active'); |
|
7105 |
|
7106 // seems to be expected behavior that the show callback is fired |
|
7107 self.element.queue("tabs", function() { |
|
7108 self._trigger('show', null, self._ui(self.anchors[o.selected], self.panels[o.selected])); |
|
7109 }); |
|
7110 |
|
7111 this.load(o.selected); |
|
7112 } |
|
7113 |
|
7114 // clean up to avoid memory leaks in certain versions of IE 6 |
|
7115 $(window).bind('unload', function() { |
|
7116 self.lis.add(self.anchors).unbind('.tabs'); |
|
7117 self.lis = self.anchors = self.panels = null; |
|
7118 }); |
|
7119 |
|
7120 } |
|
7121 // update selected after add/remove |
|
7122 else { |
|
7123 o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected')); |
|
7124 } |
|
7125 |
|
7126 // update collapsible |
|
7127 this.element[o.collapsible ? 'addClass' : 'removeClass']('ui-tabs-collapsible'); |
|
7128 |
|
7129 // set or update cookie after init and add/remove respectively |
|
7130 if (o.cookie) { |
|
7131 this._cookie(o.selected, o.cookie); |
|
7132 } |
|
7133 |
|
7134 // disable tabs |
|
7135 for (var i = 0, li; (li = this.lis[i]); i++) { |
|
7136 $(li)[$.inArray(i, o.disabled) != -1 && |
|
7137 !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled'); |
|
7138 } |
|
7139 |
|
7140 // reset cache if switching from cached to not cached |
|
7141 if (o.cache === false) { |
|
7142 this.anchors.removeData('cache.tabs'); |
|
7143 } |
|
7144 |
|
7145 // remove all handlers before, tabify may run on existing tabs after add or option change |
|
7146 this.lis.add(this.anchors).unbind('.tabs'); |
|
7147 |
|
7148 if (o.event != 'mouseover') { |
|
7149 var addState = function(state, el) { |
|
7150 if (el.is(':not(.ui-state-disabled)')) { |
|
7151 el.addClass('ui-state-' + state); |
|
7152 } |
|
7153 }; |
|
7154 var removeState = function(state, el) { |
|
7155 el.removeClass('ui-state-' + state); |
|
7156 }; |
|
7157 this.lis.bind('mouseover.tabs', function() { |
|
7158 addState('hover', $(this)); |
|
7159 }); |
|
7160 this.lis.bind('mouseout.tabs', function() { |
|
7161 removeState('hover', $(this)); |
|
7162 }); |
|
7163 this.anchors.bind('focus.tabs', function() { |
|
7164 addState('focus', $(this).closest('li')); |
|
7165 }); |
|
7166 this.anchors.bind('blur.tabs', function() { |
|
7167 removeState('focus', $(this).closest('li')); |
|
7168 }); |
|
7169 } |
|
7170 |
|
7171 // set up animations |
|
7172 var hideFx, showFx; |
|
7173 if (o.fx) { |
|
7174 if ($.isArray(o.fx)) { |
|
7175 hideFx = o.fx[0]; |
|
7176 showFx = o.fx[1]; |
|
7177 } |
|
7178 else { |
|
7179 hideFx = showFx = o.fx; |
|
7180 } |
|
7181 } |
|
7182 |
|
7183 // Reset certain styles left over from animation |
|
7184 // and prevent IE's ClearType bug... |
|
7185 function resetStyle($el, fx) { |
|
7186 $el.css({ display: '' }); |
|
7187 if (!$.support.opacity && fx.opacity) { |
|
7188 $el[0].style.removeAttribute('filter'); |
|
7189 } |
|
7190 } |
|
7191 |
|
7192 // Show a tab... |
|
7193 var showTab = showFx ? |
|
7194 function(clicked, $show) { |
|
7195 $(clicked).closest('li').addClass('ui-tabs-selected ui-state-active'); |
|
7196 $show.hide().removeClass('ui-tabs-hide') // avoid flicker that way |
|
7197 .animate(showFx, showFx.duration || 'normal', function() { |
|
7198 resetStyle($show, showFx); |
|
7199 self._trigger('show', null, self._ui(clicked, $show[0])); |
|
7200 }); |
|
7201 } : |
|
7202 function(clicked, $show) { |
|
7203 $(clicked).closest('li').addClass('ui-tabs-selected ui-state-active'); |
|
7204 $show.removeClass('ui-tabs-hide'); |
|
7205 self._trigger('show', null, self._ui(clicked, $show[0])); |
|
7206 }; |
|
7207 |
|
7208 // Hide a tab, $show is optional... |
|
7209 var hideTab = hideFx ? |
|
7210 function(clicked, $hide) { |
|
7211 $hide.animate(hideFx, hideFx.duration || 'normal', function() { |
|
7212 self.lis.removeClass('ui-tabs-selected ui-state-active'); |
|
7213 $hide.addClass('ui-tabs-hide'); |
|
7214 resetStyle($hide, hideFx); |
|
7215 self.element.dequeue("tabs"); |
|
7216 }); |
|
7217 } : |
|
7218 function(clicked, $hide, $show) { |
|
7219 self.lis.removeClass('ui-tabs-selected ui-state-active'); |
|
7220 $hide.addClass('ui-tabs-hide'); |
|
7221 self.element.dequeue("tabs"); |
|
7222 }; |
|
7223 |
|
7224 // attach tab event handler, unbind to avoid duplicates from former tabifying... |
|
7225 this.anchors.bind(o.event + '.tabs', function() { |
|
7226 var el = this, $li = $(this).closest('li'), $hide = self.panels.filter(':not(.ui-tabs-hide)'), |
|
7227 $show = $(self._sanitizeSelector(this.hash)); |
|
7228 |
|
7229 // If tab is already selected and not collapsible or tab disabled or |
|
7230 // or is already loading or click callback returns false stop here. |
|
7231 // Check if click handler returns false last so that it is not executed |
|
7232 // for a disabled or loading tab! |
|
7233 if (($li.hasClass('ui-tabs-selected') && !o.collapsible) || |
|
7234 $li.hasClass('ui-state-disabled') || |
|
7235 $li.hasClass('ui-state-processing') || |
|
7236 self._trigger('select', null, self._ui(this, $show[0])) === false) { |
|
7237 this.blur(); |
|
7238 return false; |
|
7239 } |
|
7240 |
|
7241 o.selected = self.anchors.index(this); |
|
7242 |
|
7243 self.abort(); |
|
7244 |
|
7245 // if tab may be closed |
|
7246 if (o.collapsible) { |
|
7247 if ($li.hasClass('ui-tabs-selected')) { |
|
7248 o.selected = -1; |
|
7249 |
|
7250 if (o.cookie) { |
|
7251 self._cookie(o.selected, o.cookie); |
|
7252 } |
|
7253 |
|
7254 self.element.queue("tabs", function() { |
|
7255 hideTab(el, $hide); |
|
7256 }).dequeue("tabs"); |
|
7257 |
|
7258 this.blur(); |
|
7259 return false; |
|
7260 } |
|
7261 else if (!$hide.length) { |
|
7262 if (o.cookie) { |
|
7263 self._cookie(o.selected, o.cookie); |
|
7264 } |
|
7265 |
|
7266 self.element.queue("tabs", function() { |
|
7267 showTab(el, $show); |
|
7268 }); |
|
7269 |
|
7270 self.load(self.anchors.index(this)); // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 |
|
7271 |
|
7272 this.blur(); |
|
7273 return false; |
|
7274 } |
|
7275 } |
|
7276 |
|
7277 if (o.cookie) { |
|
7278 self._cookie(o.selected, o.cookie); |
|
7279 } |
|
7280 |
|
7281 // show new tab |
|
7282 if ($show.length) { |
|
7283 if ($hide.length) { |
|
7284 self.element.queue("tabs", function() { |
|
7285 hideTab(el, $hide); |
|
7286 }); |
|
7287 } |
|
7288 self.element.queue("tabs", function() { |
|
7289 showTab(el, $show); |
|
7290 }); |
|
7291 |
|
7292 self.load(self.anchors.index(this)); |
|
7293 } |
|
7294 else { |
|
7295 throw 'jQuery UI Tabs: Mismatching fragment identifier.'; |
|
7296 } |
|
7297 |
|
7298 // Prevent IE from keeping other link focussed when using the back button |
|
7299 // and remove dotted border from clicked link. This is controlled via CSS |
|
7300 // in modern browsers; blur() removes focus from address bar in Firefox |
|
7301 // which can become a usability and annoying problem with tabs('rotate'). |
|
7302 if ($.browser.msie) { |
|
7303 this.blur(); |
|
7304 } |
|
7305 |
|
7306 }); |
|
7307 |
|
7308 // disable click in any case |
|
7309 this.anchors.bind('click.tabs', function(){return false;}); |
|
7310 |
|
7311 }, |
|
7312 |
|
7313 destroy: function() { |
|
7314 var o = this.options; |
|
7315 |
|
7316 this.abort(); |
|
7317 |
|
7318 this.element.unbind('.tabs') |
|
7319 .removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible') |
|
7320 .removeData('tabs'); |
|
7321 |
|
7322 this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); |
|
7323 |
|
7324 this.anchors.each(function() { |
|
7325 var href = $.data(this, 'href.tabs'); |
|
7326 if (href) { |
|
7327 this.href = href; |
|
7328 } |
|
7329 var $this = $(this).unbind('.tabs'); |
|
7330 $.each(['href', 'load', 'cache'], function(i, prefix) { |
|
7331 $this.removeData(prefix + '.tabs'); |
|
7332 }); |
|
7333 }); |
|
7334 |
|
7335 this.lis.unbind('.tabs').add(this.panels).each(function() { |
|
7336 if ($.data(this, 'destroy.tabs')) { |
|
7337 $(this).remove(); |
|
7338 } |
|
7339 else { |
|
7340 $(this).removeClass([ |
|
7341 'ui-state-default', |
|
7342 'ui-corner-top', |
|
7343 'ui-tabs-selected', |
|
7344 'ui-state-active', |
|
7345 'ui-state-hover', |
|
7346 'ui-state-focus', |
|
7347 'ui-state-disabled', |
|
7348 'ui-tabs-panel', |
|
7349 'ui-widget-content', |
|
7350 'ui-corner-bottom', |
|
7351 'ui-tabs-hide' |
|
7352 ].join(' ')); |
|
7353 } |
|
7354 }); |
|
7355 |
|
7356 if (o.cookie) { |
|
7357 this._cookie(null, o.cookie); |
|
7358 } |
|
7359 |
|
7360 return this; |
|
7361 }, |
|
7362 |
|
7363 add: function(url, label, index) { |
|
7364 if (index === undefined) { |
|
7365 index = this.anchors.length; // append by default |
|
7366 } |
|
7367 |
|
7368 var self = this, o = this.options, |
|
7369 $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)), |
|
7370 id = !url.indexOf('#') ? url.replace('#', '') : this._tabId($('a', $li)[0]); |
|
7371 |
|
7372 $li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true); |
|
7373 |
|
7374 // try to find an existing element before creating a new one |
|
7375 var $panel = $('#' + id); |
|
7376 if (!$panel.length) { |
|
7377 $panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true); |
|
7378 } |
|
7379 $panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide'); |
|
7380 |
|
7381 if (index >= this.lis.length) { |
|
7382 $li.appendTo(this.list); |
|
7383 $panel.appendTo(this.list[0].parentNode); |
|
7384 } |
|
7385 else { |
|
7386 $li.insertBefore(this.lis[index]); |
|
7387 $panel.insertBefore(this.panels[index]); |
|
7388 } |
|
7389 |
|
7390 o.disabled = $.map(o.disabled, |
|
7391 function(n, i) { return n >= index ? ++n : n; }); |
|
7392 |
|
7393 this._tabify(); |
|
7394 |
|
7395 if (this.anchors.length == 1) { // after tabify |
|
7396 o.selected = 0; |
|
7397 $li.addClass('ui-tabs-selected ui-state-active'); |
|
7398 $panel.removeClass('ui-tabs-hide'); |
|
7399 this.element.queue("tabs", function() { |
|
7400 self._trigger('show', null, self._ui(self.anchors[0], self.panels[0])); |
|
7401 }); |
|
7402 |
|
7403 this.load(0); |
|
7404 } |
|
7405 |
|
7406 // callback |
|
7407 this._trigger('add', null, this._ui(this.anchors[index], this.panels[index])); |
|
7408 return this; |
|
7409 }, |
|
7410 |
|
7411 remove: function(index) { |
|
7412 var o = this.options, $li = this.lis.eq(index).remove(), |
|
7413 $panel = this.panels.eq(index).remove(); |
|
7414 |
|
7415 // If selected tab was removed focus tab to the right or |
|
7416 // in case the last tab was removed the tab to the left. |
|
7417 if ($li.hasClass('ui-tabs-selected') && this.anchors.length > 1) { |
|
7418 this.select(index + (index + 1 < this.anchors.length ? 1 : -1)); |
|
7419 } |
|
7420 |
|
7421 o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }), |
|
7422 function(n, i) { return n >= index ? --n : n; }); |
|
7423 |
|
7424 this._tabify(); |
|
7425 |
|
7426 // callback |
|
7427 this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0])); |
|
7428 return this; |
|
7429 }, |
|
7430 |
|
7431 enable: function(index) { |
|
7432 var o = this.options; |
|
7433 if ($.inArray(index, o.disabled) == -1) { |
|
7434 return; |
|
7435 } |
|
7436 |
|
7437 this.lis.eq(index).removeClass('ui-state-disabled'); |
|
7438 o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); |
|
7439 |
|
7440 // callback |
|
7441 this._trigger('enable', null, this._ui(this.anchors[index], this.panels[index])); |
|
7442 return this; |
|
7443 }, |
|
7444 |
|
7445 disable: function(index) { |
|
7446 var self = this, o = this.options; |
|
7447 if (index != o.selected) { // cannot disable already selected tab |
|
7448 this.lis.eq(index).addClass('ui-state-disabled'); |
|
7449 |
|
7450 o.disabled.push(index); |
|
7451 o.disabled.sort(); |
|
7452 |
|
7453 // callback |
|
7454 this._trigger('disable', null, this._ui(this.anchors[index], this.panels[index])); |
|
7455 } |
|
7456 |
|
7457 return this; |
|
7458 }, |
|
7459 |
|
7460 select: function(index) { |
|
7461 if (typeof index == 'string') { |
|
7462 index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); |
|
7463 } |
|
7464 else if (index === null) { // usage of null is deprecated, TODO remove in next release |
|
7465 index = -1; |
|
7466 } |
|
7467 if (index == -1 && this.options.collapsible) { |
|
7468 index = this.options.selected; |
|
7469 } |
|
7470 |
|
7471 this.anchors.eq(index).trigger(this.options.event + '.tabs'); |
|
7472 return this; |
|
7473 }, |
|
7474 |
|
7475 load: function(index) { |
|
7476 var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs'); |
|
7477 |
|
7478 this.abort(); |
|
7479 |
|
7480 // not remote or from cache |
|
7481 if (!url || this.element.queue("tabs").length !== 0 && $.data(a, 'cache.tabs')) { |
|
7482 this.element.dequeue("tabs"); |
|
7483 return; |
|
7484 } |
|
7485 |
|
7486 // load remote from here on |
|
7487 this.lis.eq(index).addClass('ui-state-processing'); |
|
7488 |
|
7489 if (o.spinner) { |
|
7490 var span = $('span', a); |
|
7491 span.data('label.tabs', span.html()).html(o.spinner); |
|
7492 } |
|
7493 |
|
7494 this.xhr = $.ajax($.extend({}, o.ajaxOptions, { |
|
7495 url: url, |
|
7496 success: function(r, s) { |
|
7497 $(self._sanitizeSelector(a.hash)).html(r); |
|
7498 |
|
7499 // take care of tab labels |
|
7500 self._cleanup(); |
|
7501 |
|
7502 if (o.cache) { |
|
7503 $.data(a, 'cache.tabs', true); // if loaded once do not load them again |
|
7504 } |
|
7505 |
|
7506 // callbacks |
|
7507 self._trigger('load', null, self._ui(self.anchors[index], self.panels[index])); |
|
7508 try { |
|
7509 o.ajaxOptions.success(r, s); |
|
7510 } |
|
7511 catch (e) {} |
|
7512 }, |
|
7513 error: function(xhr, s, e) { |
|
7514 // take care of tab labels |
|
7515 self._cleanup(); |
|
7516 |
|
7517 // callbacks |
|
7518 self._trigger('load', null, self._ui(self.anchors[index], self.panels[index])); |
|
7519 try { |
|
7520 // Passing index avoid a race condition when this method is |
|
7521 // called after the user has selected another tab. |
|
7522 // Pass the anchor that initiated this request allows |
|
7523 // loadError to manipulate the tab content panel via $(a.hash) |
|
7524 o.ajaxOptions.error(xhr, s, index, a); |
|
7525 } |
|
7526 catch (e) {} |
|
7527 } |
|
7528 })); |
|
7529 |
|
7530 // last, so that load event is fired before show... |
|
7531 self.element.dequeue("tabs"); |
|
7532 |
|
7533 return this; |
|
7534 }, |
|
7535 |
|
7536 abort: function() { |
|
7537 // stop possibly running animations |
|
7538 this.element.queue([]); |
|
7539 this.panels.stop(false, true); |
|
7540 |
|
7541 // "tabs" queue must not contain more than two elements, |
|
7542 // which are the callbacks for the latest clicked tab... |
|
7543 this.element.queue("tabs", this.element.queue("tabs").splice(-2, 2)); |
|
7544 |
|
7545 // terminate pending requests from other tabs |
|
7546 if (this.xhr) { |
|
7547 this.xhr.abort(); |
|
7548 delete this.xhr; |
|
7549 } |
|
7550 |
|
7551 // take care of tab labels |
|
7552 this._cleanup(); |
|
7553 return this; |
|
7554 }, |
|
7555 |
|
7556 url: function(index, url) { |
|
7557 this.anchors.eq(index).removeData('cache.tabs').data('load.tabs', url); |
|
7558 return this; |
|
7559 }, |
|
7560 |
|
7561 length: function() { |
|
7562 return this.anchors.length; |
|
7563 } |
|
7564 |
|
7565 }); |
|
7566 |
|
7567 $.extend($.ui.tabs, { |
|
7568 version: '1.8.1' |
|
7569 }); |
|
7570 |
|
7571 /* |
|
7572 * Tabs Extensions |
|
7573 */ |
|
7574 |
|
7575 /* |
|
7576 * Rotate |
|
7577 */ |
|
7578 $.extend($.ui.tabs.prototype, { |
|
7579 rotation: null, |
|
7580 rotate: function(ms, continuing) { |
|
7581 |
|
7582 var self = this, o = this.options; |
|
7583 |
|
7584 var rotate = self._rotate || (self._rotate = function(e) { |
|
7585 clearTimeout(self.rotation); |
|
7586 self.rotation = setTimeout(function() { |
|
7587 var t = o.selected; |
|
7588 self.select( ++t < self.anchors.length ? t : 0 ); |
|
7589 }, ms); |
|
7590 |
|
7591 if (e) { |
|
7592 e.stopPropagation(); |
|
7593 } |
|
7594 }); |
|
7595 |
|
7596 var stop = self._unrotate || (self._unrotate = !continuing ? |
|
7597 function(e) { |
|
7598 if (e.clientX) { // in case of a true click |
|
7599 self.rotate(null); |
|
7600 } |
|
7601 } : |
|
7602 function(e) { |
|
7603 t = o.selected; |
|
7604 rotate(); |
|
7605 }); |
|
7606 |
|
7607 // start rotation |
|
7608 if (ms) { |
|
7609 this.element.bind('tabsshow', rotate); |
|
7610 this.anchors.bind(o.event + '.tabs', stop); |
|
7611 rotate(); |
|
7612 } |
|
7613 // stop rotation |
|
7614 else { |
|
7615 clearTimeout(self.rotation); |
|
7616 this.element.unbind('tabsshow', rotate); |
|
7617 this.anchors.unbind(o.event + '.tabs', stop); |
|
7618 delete this._rotate; |
|
7619 delete this._unrotate; |
|
7620 } |
|
7621 |
|
7622 return this; |
|
7623 } |
|
7624 }); |
|
7625 |
|
7626 })(jQuery); |
|
7627 /* |
|
7628 * jQuery UI Datepicker 1.8.1 |
|
7629 * |
|
7630 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
7631 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
7632 * and GPL (GPL-LICENSE.txt) licenses. |
|
7633 * |
|
7634 * http://docs.jquery.com/UI/Datepicker |
|
7635 * |
|
7636 * Depends: |
|
7637 * jquery.ui.core.js |
|
7638 */ |
|
7639 |
|
7640 (function($) { // hide the namespace |
|
7641 |
|
7642 $.extend($.ui, { datepicker: { version: "1.8.1" } }); |
|
7643 |
|
7644 var PROP_NAME = 'datepicker'; |
|
7645 var dpuuid = new Date().getTime(); |
|
7646 |
|
7647 /* Date picker manager. |
|
7648 Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
|
7649 Settings for (groups of) date pickers are maintained in an instance object, |
|
7650 allowing multiple different settings on the same page. */ |
|
7651 |
|
7652 function Datepicker() { |
|
7653 this.debug = false; // Change this to true to start debugging |
|
7654 this._curInst = null; // The current instance in use |
|
7655 this._keyEvent = false; // If the last event was a key event |
|
7656 this._disabledInputs = []; // List of date picker inputs that have been disabled |
|
7657 this._datepickerShowing = false; // True if the popup picker is showing , false if not |
|
7658 this._inDialog = false; // True if showing within a "dialog", false if not |
|
7659 this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division |
|
7660 this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class |
|
7661 this._appendClass = 'ui-datepicker-append'; // The name of the append marker class |
|
7662 this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class |
|
7663 this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class |
|
7664 this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class |
|
7665 this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class |
|
7666 this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class |
|
7667 this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class |
|
7668 this.regional = []; // Available regional settings, indexed by language code |
|
7669 this.regional[''] = { // Default regional settings |
|
7670 closeText: 'Done', // Display text for close link |
|
7671 prevText: 'Prev', // Display text for previous month link |
|
7672 nextText: 'Next', // Display text for next month link |
|
7673 currentText: 'Today', // Display text for current month link |
|
7674 monthNames: ['January','February','March','April','May','June', |
|
7675 'July','August','September','October','November','December'], // Names of months for drop-down and formatting |
|
7676 monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting |
|
7677 dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting |
|
7678 dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting |
|
7679 dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday |
|
7680 weekHeader: 'Wk', // Column header for week of the year |
|
7681 dateFormat: 'mm/dd/yy', // See format options on parseDate |
|
7682 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
|
7683 isRTL: false, // True if right-to-left language, false if left-to-right |
|
7684 showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
|
7685 yearSuffix: '' // Additional text to append to the year in the month headers |
|
7686 }; |
|
7687 this._defaults = { // Global defaults for all the date picker instances |
|
7688 showOn: 'focus', // 'focus' for popup on focus, |
|
7689 // 'button' for trigger button, or 'both' for either |
|
7690 showAnim: 'show', // Name of jQuery animation for popup |
|
7691 showOptions: {}, // Options for enhanced animations |
|
7692 defaultDate: null, // Used when field is blank: actual date, |
|
7693 // +/-number for offset from today, null for today |
|
7694 appendText: '', // Display text following the input box, e.g. showing the format |
|
7695 buttonText: '...', // Text for trigger button |
|
7696 buttonImage: '', // URL for trigger button image |
|
7697 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
|
7698 hideIfNoPrevNext: false, // True to hide next/previous month links |
|
7699 // if not applicable, false to just disable them |
|
7700 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links |
|
7701 gotoCurrent: false, // True if today link goes back to current selection instead |
|
7702 changeMonth: false, // True if month can be selected directly, false if only prev/next |
|
7703 changeYear: false, // True if year can be selected directly, false if only prev/next |
|
7704 yearRange: 'c-10:c+10', // Range of years to display in drop-down, |
|
7705 // either relative to today's year (-nn:+nn), relative to currently displayed year |
|
7706 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) |
|
7707 showOtherMonths: false, // True to show dates in other months, false to leave blank |
|
7708 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable |
|
7709 showWeek: false, // True to show week of the year, false to not show it |
|
7710 calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
|
7711 // takes a Date and returns the number of the week for it |
|
7712 shortYearCutoff: '+10', // Short year values < this are in the current century, |
|
7713 // > this are in the previous century, |
|
7714 // string value starting with '+' for current year + value |
|
7715 minDate: null, // The earliest selectable date, or null for no limit |
|
7716 maxDate: null, // The latest selectable date, or null for no limit |
|
7717 duration: '_default', // Duration of display/closure |
|
7718 beforeShowDay: null, // Function that takes a date and returns an array with |
|
7719 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', |
|
7720 // [2] = cell title (optional), e.g. $.datepicker.noWeekends |
|
7721 beforeShow: null, // Function that takes an input field and |
|
7722 // returns a set of custom settings for the date picker |
|
7723 onSelect: null, // Define a callback function when a date is selected |
|
7724 onChangeMonthYear: null, // Define a callback function when the month or year is changed |
|
7725 onClose: null, // Define a callback function when the datepicker is closed |
|
7726 numberOfMonths: 1, // Number of months to show at a time |
|
7727 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
|
7728 stepMonths: 1, // Number of months to step back/forward |
|
7729 stepBigMonths: 12, // Number of months to step back/forward for the big links |
|
7730 altField: '', // Selector for an alternate field to store selected dates into |
|
7731 altFormat: '', // The date format to use for the alternate field |
|
7732 constrainInput: true, // The input is constrained by the current date format |
|
7733 showButtonPanel: false, // True to show button panel, false to not show it |
|
7734 autoSize: false // True to size the input for the date format, false to leave as is |
|
7735 }; |
|
7736 $.extend(this._defaults, this.regional['']); |
|
7737 this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>'); |
|
7738 } |
|
7739 |
|
7740 $.extend(Datepicker.prototype, { |
|
7741 /* Class name added to elements to indicate already configured with a date picker. */ |
|
7742 markerClassName: 'hasDatepicker', |
|
7743 |
|
7744 /* Debug logging (if enabled). */ |
|
7745 log: function () { |
|
7746 if (this.debug) |
|
7747 console.log.apply('', arguments); |
|
7748 }, |
|
7749 |
|
7750 // TODO rename to "widget" when switching to widget factory |
|
7751 _widgetDatepicker: function() { |
|
7752 return this.dpDiv; |
|
7753 }, |
|
7754 |
|
7755 /* Override the default settings for all instances of the date picker. |
|
7756 @param settings object - the new settings to use as defaults (anonymous object) |
|
7757 @return the manager object */ |
|
7758 setDefaults: function(settings) { |
|
7759 extendRemove(this._defaults, settings || {}); |
|
7760 return this; |
|
7761 }, |
|
7762 |
|
7763 /* Attach the date picker to a jQuery selection. |
|
7764 @param target element - the target input field or division or span |
|
7765 @param settings object - the new settings to use for this date picker instance (anonymous) */ |
|
7766 _attachDatepicker: function(target, settings) { |
|
7767 // check for settings on the control itself - in namespace 'date:' |
|
7768 var inlineSettings = null; |
|
7769 for (var attrName in this._defaults) { |
|
7770 var attrValue = target.getAttribute('date:' + attrName); |
|
7771 if (attrValue) { |
|
7772 inlineSettings = inlineSettings || {}; |
|
7773 try { |
|
7774 inlineSettings[attrName] = eval(attrValue); |
|
7775 } catch (err) { |
|
7776 inlineSettings[attrName] = attrValue; |
|
7777 } |
|
7778 } |
|
7779 } |
|
7780 var nodeName = target.nodeName.toLowerCase(); |
|
7781 var inline = (nodeName == 'div' || nodeName == 'span'); |
|
7782 if (!target.id) |
|
7783 target.id = 'dp' + (++this.uuid); |
|
7784 var inst = this._newInst($(target), inline); |
|
7785 inst.settings = $.extend({}, settings || {}, inlineSettings || {}); |
|
7786 if (nodeName == 'input') { |
|
7787 this._connectDatepicker(target, inst); |
|
7788 } else if (inline) { |
|
7789 this._inlineDatepicker(target, inst); |
|
7790 } |
|
7791 }, |
|
7792 |
|
7793 /* Create a new instance object. */ |
|
7794 _newInst: function(target, inline) { |
|
7795 var id = target[0].id.replace(/([^A-Za-z0-9_])/g, '\\\\$1'); // escape jQuery meta chars |
|
7796 return {id: id, input: target, // associated target |
|
7797 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
|
7798 drawMonth: 0, drawYear: 0, // month being drawn |
|
7799 inline: inline, // is datepicker inline or not |
|
7800 dpDiv: (!inline ? this.dpDiv : // presentation div |
|
7801 $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}; |
|
7802 }, |
|
7803 |
|
7804 /* Attach the date picker to an input field. */ |
|
7805 _connectDatepicker: function(target, inst) { |
|
7806 var input = $(target); |
|
7807 inst.append = $([]); |
|
7808 inst.trigger = $([]); |
|
7809 if (input.hasClass(this.markerClassName)) |
|
7810 return; |
|
7811 this._attachments(input, inst); |
|
7812 input.addClass(this.markerClassName).keydown(this._doKeyDown). |
|
7813 keypress(this._doKeyPress).keyup(this._doKeyUp). |
|
7814 bind("setData.datepicker", function(event, key, value) { |
|
7815 inst.settings[key] = value; |
|
7816 }).bind("getData.datepicker", function(event, key) { |
|
7817 return this._get(inst, key); |
|
7818 }); |
|
7819 this._autoSize(inst); |
|
7820 $.data(target, PROP_NAME, inst); |
|
7821 }, |
|
7822 |
|
7823 /* Make attachments based on settings. */ |
|
7824 _attachments: function(input, inst) { |
|
7825 var appendText = this._get(inst, 'appendText'); |
|
7826 var isRTL = this._get(inst, 'isRTL'); |
|
7827 if (inst.append) |
|
7828 inst.append.remove(); |
|
7829 if (appendText) { |
|
7830 inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>'); |
|
7831 input[isRTL ? 'before' : 'after'](inst.append); |
|
7832 } |
|
7833 input.unbind('focus', this._showDatepicker); |
|
7834 if (inst.trigger) |
|
7835 inst.trigger.remove(); |
|
7836 var showOn = this._get(inst, 'showOn'); |
|
7837 if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field |
|
7838 input.focus(this._showDatepicker); |
|
7839 if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked |
|
7840 var buttonText = this._get(inst, 'buttonText'); |
|
7841 var buttonImage = this._get(inst, 'buttonImage'); |
|
7842 inst.trigger = $(this._get(inst, 'buttonImageOnly') ? |
|
7843 $('<img/>').addClass(this._triggerClass). |
|
7844 attr({ src: buttonImage, alt: buttonText, title: buttonText }) : |
|
7845 $('<button type="button"></button>').addClass(this._triggerClass). |
|
7846 html(buttonImage == '' ? buttonText : $('<img/>').attr( |
|
7847 { src:buttonImage, alt:buttonText, title:buttonText }))); |
|
7848 input[isRTL ? 'before' : 'after'](inst.trigger); |
|
7849 inst.trigger.click(function() { |
|
7850 if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0]) |
|
7851 $.datepicker._hideDatepicker(); |
|
7852 else |
|
7853 $.datepicker._showDatepicker(input[0]); |
|
7854 return false; |
|
7855 }); |
|
7856 } |
|
7857 }, |
|
7858 |
|
7859 /* Apply the maximum length for the date format. */ |
|
7860 _autoSize: function(inst) { |
|
7861 if (this._get(inst, 'autoSize') && !inst.inline) { |
|
7862 var date = new Date(2009, 12 - 1, 20); // Ensure double digits |
|
7863 var dateFormat = this._get(inst, 'dateFormat'); |
|
7864 if (dateFormat.match(/[DM]/)) { |
|
7865 var findMax = function(names) { |
|
7866 var max = 0; |
|
7867 var maxI = 0; |
|
7868 for (var i = 0; i < names.length; i++) { |
|
7869 if (names[i].length > max) { |
|
7870 max = names[i].length; |
|
7871 maxI = i; |
|
7872 } |
|
7873 } |
|
7874 return maxI; |
|
7875 }; |
|
7876 date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ? |
|
7877 'monthNames' : 'monthNamesShort')))); |
|
7878 date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ? |
|
7879 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay()); |
|
7880 } |
|
7881 inst.input.attr('size', this._formatDate(inst, date).length); |
|
7882 } |
|
7883 }, |
|
7884 |
|
7885 /* Attach an inline date picker to a div. */ |
|
7886 _inlineDatepicker: function(target, inst) { |
|
7887 var divSpan = $(target); |
|
7888 if (divSpan.hasClass(this.markerClassName)) |
|
7889 return; |
|
7890 divSpan.addClass(this.markerClassName).append(inst.dpDiv). |
|
7891 bind("setData.datepicker", function(event, key, value){ |
|
7892 inst.settings[key] = value; |
|
7893 }).bind("getData.datepicker", function(event, key){ |
|
7894 return this._get(inst, key); |
|
7895 }); |
|
7896 $.data(target, PROP_NAME, inst); |
|
7897 this._setDate(inst, this._getDefaultDate(inst), true); |
|
7898 this._updateDatepicker(inst); |
|
7899 this._updateAlternate(inst); |
|
7900 }, |
|
7901 |
|
7902 /* Pop-up the date picker in a "dialog" box. |
|
7903 @param input element - ignored |
|
7904 @param date string or Date - the initial date to display |
|
7905 @param onSelect function - the function to call when a date is selected |
|
7906 @param settings object - update the dialog date picker instance's settings (anonymous object) |
|
7907 @param pos int[2] - coordinates for the dialog's position within the screen or |
|
7908 event - with x/y coordinates or |
|
7909 leave empty for default (screen centre) |
|
7910 @return the manager object */ |
|
7911 _dialogDatepicker: function(input, date, onSelect, settings, pos) { |
|
7912 var inst = this._dialogInst; // internal instance |
|
7913 if (!inst) { |
|
7914 var id = 'dp' + (++this.uuid); |
|
7915 this._dialogInput = $('<input type="text" id="' + id + |
|
7916 '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>'); |
|
7917 this._dialogInput.keydown(this._doKeyDown); |
|
7918 $('body').append(this._dialogInput); |
|
7919 inst = this._dialogInst = this._newInst(this._dialogInput, false); |
|
7920 inst.settings = {}; |
|
7921 $.data(this._dialogInput[0], PROP_NAME, inst); |
|
7922 } |
|
7923 extendRemove(inst.settings, settings || {}); |
|
7924 date = (date && date.constructor == Date ? this._formatDate(inst, date) : date); |
|
7925 this._dialogInput.val(date); |
|
7926 |
|
7927 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); |
|
7928 if (!this._pos) { |
|
7929 var browserWidth = document.documentElement.clientWidth; |
|
7930 var browserHeight = document.documentElement.clientHeight; |
|
7931 var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; |
|
7932 var scrollY = document.documentElement.scrollTop || document.body.scrollTop; |
|
7933 this._pos = // should use actual width/height below |
|
7934 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; |
|
7935 } |
|
7936 |
|
7937 // move input on screen for focus, but hidden behind dialog |
|
7938 this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px'); |
|
7939 inst.settings.onSelect = onSelect; |
|
7940 this._inDialog = true; |
|
7941 this.dpDiv.addClass(this._dialogClass); |
|
7942 this._showDatepicker(this._dialogInput[0]); |
|
7943 if ($.blockUI) |
|
7944 $.blockUI(this.dpDiv); |
|
7945 $.data(this._dialogInput[0], PROP_NAME, inst); |
|
7946 return this; |
|
7947 }, |
|
7948 |
|
7949 /* Detach a datepicker from its control. |
|
7950 @param target element - the target input field or division or span */ |
|
7951 _destroyDatepicker: function(target) { |
|
7952 var $target = $(target); |
|
7953 var inst = $.data(target, PROP_NAME); |
|
7954 if (!$target.hasClass(this.markerClassName)) { |
|
7955 return; |
|
7956 } |
|
7957 var nodeName = target.nodeName.toLowerCase(); |
|
7958 $.removeData(target, PROP_NAME); |
|
7959 if (nodeName == 'input') { |
|
7960 inst.append.remove(); |
|
7961 inst.trigger.remove(); |
|
7962 $target.removeClass(this.markerClassName). |
|
7963 unbind('focus', this._showDatepicker). |
|
7964 unbind('keydown', this._doKeyDown). |
|
7965 unbind('keypress', this._doKeyPress). |
|
7966 unbind('keyup', this._doKeyUp); |
|
7967 } else if (nodeName == 'div' || nodeName == 'span') |
|
7968 $target.removeClass(this.markerClassName).empty(); |
|
7969 }, |
|
7970 |
|
7971 /* Enable the date picker to a jQuery selection. |
|
7972 @param target element - the target input field or division or span */ |
|
7973 _enableDatepicker: function(target) { |
|
7974 var $target = $(target); |
|
7975 var inst = $.data(target, PROP_NAME); |
|
7976 if (!$target.hasClass(this.markerClassName)) { |
|
7977 return; |
|
7978 } |
|
7979 var nodeName = target.nodeName.toLowerCase(); |
|
7980 if (nodeName == 'input') { |
|
7981 target.disabled = false; |
|
7982 inst.trigger.filter('button'). |
|
7983 each(function() { this.disabled = false; }).end(). |
|
7984 filter('img').css({opacity: '1.0', cursor: ''}); |
|
7985 } |
|
7986 else if (nodeName == 'div' || nodeName == 'span') { |
|
7987 var inline = $target.children('.' + this._inlineClass); |
|
7988 inline.children().removeClass('ui-state-disabled'); |
|
7989 } |
|
7990 this._disabledInputs = $.map(this._disabledInputs, |
|
7991 function(value) { return (value == target ? null : value); }); // delete entry |
|
7992 }, |
|
7993 |
|
7994 /* Disable the date picker to a jQuery selection. |
|
7995 @param target element - the target input field or division or span */ |
|
7996 _disableDatepicker: function(target) { |
|
7997 var $target = $(target); |
|
7998 var inst = $.data(target, PROP_NAME); |
|
7999 if (!$target.hasClass(this.markerClassName)) { |
|
8000 return; |
|
8001 } |
|
8002 var nodeName = target.nodeName.toLowerCase(); |
|
8003 if (nodeName == 'input') { |
|
8004 target.disabled = true; |
|
8005 inst.trigger.filter('button'). |
|
8006 each(function() { this.disabled = true; }).end(). |
|
8007 filter('img').css({opacity: '0.5', cursor: 'default'}); |
|
8008 } |
|
8009 else if (nodeName == 'div' || nodeName == 'span') { |
|
8010 var inline = $target.children('.' + this._inlineClass); |
|
8011 inline.children().addClass('ui-state-disabled'); |
|
8012 } |
|
8013 this._disabledInputs = $.map(this._disabledInputs, |
|
8014 function(value) { return (value == target ? null : value); }); // delete entry |
|
8015 this._disabledInputs[this._disabledInputs.length] = target; |
|
8016 }, |
|
8017 |
|
8018 /* Is the first field in a jQuery collection disabled as a datepicker? |
|
8019 @param target element - the target input field or division or span |
|
8020 @return boolean - true if disabled, false if enabled */ |
|
8021 _isDisabledDatepicker: function(target) { |
|
8022 if (!target) { |
|
8023 return false; |
|
8024 } |
|
8025 for (var i = 0; i < this._disabledInputs.length; i++) { |
|
8026 if (this._disabledInputs[i] == target) |
|
8027 return true; |
|
8028 } |
|
8029 return false; |
|
8030 }, |
|
8031 |
|
8032 /* Retrieve the instance data for the target control. |
|
8033 @param target element - the target input field or division or span |
|
8034 @return object - the associated instance data |
|
8035 @throws error if a jQuery problem getting data */ |
|
8036 _getInst: function(target) { |
|
8037 try { |
|
8038 return $.data(target, PROP_NAME); |
|
8039 } |
|
8040 catch (err) { |
|
8041 throw 'Missing instance data for this datepicker'; |
|
8042 } |
|
8043 }, |
|
8044 |
|
8045 /* Update or retrieve the settings for a date picker attached to an input field or division. |
|
8046 @param target element - the target input field or division or span |
|
8047 @param name object - the new settings to update or |
|
8048 string - the name of the setting to change or retrieve, |
|
8049 when retrieving also 'all' for all instance settings or |
|
8050 'defaults' for all global defaults |
|
8051 @param value any - the new value for the setting |
|
8052 (omit if above is an object or to retrieve a value) */ |
|
8053 _optionDatepicker: function(target, name, value) { |
|
8054 var inst = this._getInst(target); |
|
8055 if (arguments.length == 2 && typeof name == 'string') { |
|
8056 return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) : |
|
8057 (inst ? (name == 'all' ? $.extend({}, inst.settings) : |
|
8058 this._get(inst, name)) : null)); |
|
8059 } |
|
8060 var settings = name || {}; |
|
8061 if (typeof name == 'string') { |
|
8062 settings = {}; |
|
8063 settings[name] = value; |
|
8064 } |
|
8065 if (inst) { |
|
8066 if (this._curInst == inst) { |
|
8067 this._hideDatepicker(); |
|
8068 } |
|
8069 var date = this._getDateDatepicker(target, true); |
|
8070 extendRemove(inst.settings, settings); |
|
8071 this._attachments($(target), inst); |
|
8072 this._autoSize(inst); |
|
8073 this._setDateDatepicker(target, date); |
|
8074 this._updateDatepicker(inst); |
|
8075 } |
|
8076 }, |
|
8077 |
|
8078 // change method deprecated |
|
8079 _changeDatepicker: function(target, name, value) { |
|
8080 this._optionDatepicker(target, name, value); |
|
8081 }, |
|
8082 |
|
8083 /* Redraw the date picker attached to an input field or division. |
|
8084 @param target element - the target input field or division or span */ |
|
8085 _refreshDatepicker: function(target) { |
|
8086 var inst = this._getInst(target); |
|
8087 if (inst) { |
|
8088 this._updateDatepicker(inst); |
|
8089 } |
|
8090 }, |
|
8091 |
|
8092 /* Set the dates for a jQuery selection. |
|
8093 @param target element - the target input field or division or span |
|
8094 @param date Date - the new date */ |
|
8095 _setDateDatepicker: function(target, date) { |
|
8096 var inst = this._getInst(target); |
|
8097 if (inst) { |
|
8098 this._setDate(inst, date); |
|
8099 this._updateDatepicker(inst); |
|
8100 this._updateAlternate(inst); |
|
8101 } |
|
8102 }, |
|
8103 |
|
8104 /* Get the date(s) for the first entry in a jQuery selection. |
|
8105 @param target element - the target input field or division or span |
|
8106 @param noDefault boolean - true if no default date is to be used |
|
8107 @return Date - the current date */ |
|
8108 _getDateDatepicker: function(target, noDefault) { |
|
8109 var inst = this._getInst(target); |
|
8110 if (inst && !inst.inline) |
|
8111 this._setDateFromField(inst, noDefault); |
|
8112 return (inst ? this._getDate(inst) : null); |
|
8113 }, |
|
8114 |
|
8115 /* Handle keystrokes. */ |
|
8116 _doKeyDown: function(event) { |
|
8117 var inst = $.datepicker._getInst(event.target); |
|
8118 var handled = true; |
|
8119 var isRTL = inst.dpDiv.is('.ui-datepicker-rtl'); |
|
8120 inst._keyEvent = true; |
|
8121 if ($.datepicker._datepickerShowing) |
|
8122 switch (event.keyCode) { |
|
8123 case 9: $.datepicker._hideDatepicker(); |
|
8124 handled = false; |
|
8125 break; // hide on tab out |
|
8126 case 13: var sel = $('td.' + $.datepicker._dayOverClass, inst.dpDiv). |
|
8127 add($('td.' + $.datepicker._currentClass, inst.dpDiv)); |
|
8128 if (sel[0]) |
|
8129 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); |
|
8130 else |
|
8131 $.datepicker._hideDatepicker(); |
|
8132 return false; // don't submit the form |
|
8133 break; // select the value on enter |
|
8134 case 27: $.datepicker._hideDatepicker(); |
|
8135 break; // hide on escape |
|
8136 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
8137 -$.datepicker._get(inst, 'stepBigMonths') : |
|
8138 -$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
8139 break; // previous month/year on page up/+ ctrl |
|
8140 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
8141 +$.datepicker._get(inst, 'stepBigMonths') : |
|
8142 +$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
8143 break; // next month/year on page down/+ ctrl |
|
8144 case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target); |
|
8145 handled = event.ctrlKey || event.metaKey; |
|
8146 break; // clear on ctrl or command +end |
|
8147 case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target); |
|
8148 handled = event.ctrlKey || event.metaKey; |
|
8149 break; // current on ctrl or command +home |
|
8150 case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D'); |
|
8151 handled = event.ctrlKey || event.metaKey; |
|
8152 // -1 day on ctrl or command +left |
|
8153 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
8154 -$.datepicker._get(inst, 'stepBigMonths') : |
|
8155 -$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
8156 // next month/year on alt +left on Mac |
|
8157 break; |
|
8158 case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D'); |
|
8159 handled = event.ctrlKey || event.metaKey; |
|
8160 break; // -1 week on ctrl or command +up |
|
8161 case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D'); |
|
8162 handled = event.ctrlKey || event.metaKey; |
|
8163 // +1 day on ctrl or command +right |
|
8164 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
8165 +$.datepicker._get(inst, 'stepBigMonths') : |
|
8166 +$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
8167 // next month/year on alt +right |
|
8168 break; |
|
8169 case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D'); |
|
8170 handled = event.ctrlKey || event.metaKey; |
|
8171 break; // +1 week on ctrl or command +down |
|
8172 default: handled = false; |
|
8173 } |
|
8174 else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home |
|
8175 $.datepicker._showDatepicker(this); |
|
8176 else { |
|
8177 handled = false; |
|
8178 } |
|
8179 if (handled) { |
|
8180 event.preventDefault(); |
|
8181 event.stopPropagation(); |
|
8182 } |
|
8183 }, |
|
8184 |
|
8185 /* Filter entered characters - based on date format. */ |
|
8186 _doKeyPress: function(event) { |
|
8187 var inst = $.datepicker._getInst(event.target); |
|
8188 if ($.datepicker._get(inst, 'constrainInput')) { |
|
8189 var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); |
|
8190 var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode); |
|
8191 return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
|
8192 } |
|
8193 }, |
|
8194 |
|
8195 /* Synchronise manual entry and field/alternate field. */ |
|
8196 _doKeyUp: function(event) { |
|
8197 var inst = $.datepicker._getInst(event.target); |
|
8198 if (inst.input.val() != inst.lastVal) { |
|
8199 try { |
|
8200 var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'), |
|
8201 (inst.input ? inst.input.val() : null), |
|
8202 $.datepicker._getFormatConfig(inst)); |
|
8203 if (date) { // only if valid |
|
8204 $.datepicker._setDateFromField(inst); |
|
8205 $.datepicker._updateAlternate(inst); |
|
8206 $.datepicker._updateDatepicker(inst); |
|
8207 } |
|
8208 } |
|
8209 catch (event) { |
|
8210 $.datepicker.log(event); |
|
8211 } |
|
8212 } |
|
8213 return true; |
|
8214 }, |
|
8215 |
|
8216 /* Pop-up the date picker for a given input field. |
|
8217 @param input element - the input field attached to the date picker or |
|
8218 event - if triggered by focus */ |
|
8219 _showDatepicker: function(input) { |
|
8220 input = input.target || input; |
|
8221 if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger |
|
8222 input = $('input', input.parentNode)[0]; |
|
8223 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here |
|
8224 return; |
|
8225 var inst = $.datepicker._getInst(input); |
|
8226 if ($.datepicker._curInst && $.datepicker._curInst != inst) { |
|
8227 $.datepicker._curInst.dpDiv.stop(true, true); |
|
8228 } |
|
8229 var beforeShow = $.datepicker._get(inst, 'beforeShow'); |
|
8230 extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); |
|
8231 inst.lastVal = null; |
|
8232 $.datepicker._lastInput = input; |
|
8233 $.datepicker._setDateFromField(inst); |
|
8234 if ($.datepicker._inDialog) // hide cursor |
|
8235 input.value = ''; |
|
8236 if (!$.datepicker._pos) { // position below input |
|
8237 $.datepicker._pos = $.datepicker._findPos(input); |
|
8238 $.datepicker._pos[1] += input.offsetHeight; // add the height |
|
8239 } |
|
8240 var isFixed = false; |
|
8241 $(input).parents().each(function() { |
|
8242 isFixed |= $(this).css('position') == 'fixed'; |
|
8243 return !isFixed; |
|
8244 }); |
|
8245 if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled |
|
8246 $.datepicker._pos[0] -= document.documentElement.scrollLeft; |
|
8247 $.datepicker._pos[1] -= document.documentElement.scrollTop; |
|
8248 } |
|
8249 var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; |
|
8250 $.datepicker._pos = null; |
|
8251 // determine sizing offscreen |
|
8252 inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'}); |
|
8253 $.datepicker._updateDatepicker(inst); |
|
8254 // fix width for dynamic number of date pickers |
|
8255 // and adjust position before showing |
|
8256 offset = $.datepicker._checkOffset(inst, offset, isFixed); |
|
8257 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? |
|
8258 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', |
|
8259 left: offset.left + 'px', top: offset.top + 'px'}); |
|
8260 if (!inst.inline) { |
|
8261 var showAnim = $.datepicker._get(inst, 'showAnim'); |
|
8262 var duration = $.datepicker._get(inst, 'duration'); |
|
8263 var postProcess = function() { |
|
8264 $.datepicker._datepickerShowing = true; |
|
8265 var borders = $.datepicker._getBorders(inst.dpDiv); |
|
8266 inst.dpDiv.find('iframe.ui-datepicker-cover'). // IE6- only |
|
8267 css({left: -borders[0], top: -borders[1], |
|
8268 width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}); |
|
8269 }; |
|
8270 inst.dpDiv.zIndex($(input).zIndex()+1); |
|
8271 if ($.effects && $.effects[showAnim]) |
|
8272 inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
|
8273 else |
|
8274 inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess); |
|
8275 if (!showAnim || !duration) |
|
8276 postProcess(); |
|
8277 if (inst.input.is(':visible') && !inst.input.is(':disabled')) |
|
8278 inst.input.focus(); |
|
8279 $.datepicker._curInst = inst; |
|
8280 } |
|
8281 }, |
|
8282 |
|
8283 /* Generate the date picker content. */ |
|
8284 _updateDatepicker: function(inst) { |
|
8285 var self = this; |
|
8286 var borders = $.datepicker._getBorders(inst.dpDiv); |
|
8287 inst.dpDiv.empty().append(this._generateHTML(inst)) |
|
8288 .find('iframe.ui-datepicker-cover') // IE6- only |
|
8289 .css({left: -borders[0], top: -borders[1], |
|
8290 width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}) |
|
8291 .end() |
|
8292 .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') |
|
8293 .bind('mouseout', function(){ |
|
8294 $(this).removeClass('ui-state-hover'); |
|
8295 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); |
|
8296 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); |
|
8297 }) |
|
8298 .bind('mouseover', function(){ |
|
8299 if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) { |
|
8300 $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); |
|
8301 $(this).addClass('ui-state-hover'); |
|
8302 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); |
|
8303 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); |
|
8304 } |
|
8305 }) |
|
8306 .end() |
|
8307 .find('.' + this._dayOverClass + ' a') |
|
8308 .trigger('mouseover') |
|
8309 .end(); |
|
8310 var numMonths = this._getNumberOfMonths(inst); |
|
8311 var cols = numMonths[1]; |
|
8312 var width = 17; |
|
8313 if (cols > 1) |
|
8314 inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); |
|
8315 else |
|
8316 inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); |
|
8317 inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + |
|
8318 'Class']('ui-datepicker-multi'); |
|
8319 inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + |
|
8320 'Class']('ui-datepicker-rtl'); |
|
8321 if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && |
|
8322 inst.input.is(':visible') && !inst.input.is(':disabled')) |
|
8323 inst.input.focus(); |
|
8324 }, |
|
8325 |
|
8326 /* Retrieve the size of left and top borders for an element. |
|
8327 @param elem (jQuery object) the element of interest |
|
8328 @return (number[2]) the left and top borders */ |
|
8329 _getBorders: function(elem) { |
|
8330 var convert = function(value) { |
|
8331 return {thin: 1, medium: 2, thick: 3}[value] || value; |
|
8332 }; |
|
8333 return [parseFloat(convert(elem.css('border-left-width'))), |
|
8334 parseFloat(convert(elem.css('border-top-width')))]; |
|
8335 }, |
|
8336 |
|
8337 /* Check positioning to remain on screen. */ |
|
8338 _checkOffset: function(inst, offset, isFixed) { |
|
8339 var dpWidth = inst.dpDiv.outerWidth(); |
|
8340 var dpHeight = inst.dpDiv.outerHeight(); |
|
8341 var inputWidth = inst.input ? inst.input.outerWidth() : 0; |
|
8342 var inputHeight = inst.input ? inst.input.outerHeight() : 0; |
|
8343 var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft(); |
|
8344 var viewHeight = document.documentElement.clientHeight + $(document).scrollTop(); |
|
8345 |
|
8346 offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0); |
|
8347 offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0; |
|
8348 offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; |
|
8349 |
|
8350 // now check if datepicker is showing outside window viewport - move to a better place if so. |
|
8351 offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? |
|
8352 Math.abs(offset.left + dpWidth - viewWidth) : 0); |
|
8353 offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? |
|
8354 Math.abs(dpHeight + inputHeight) : 0); |
|
8355 |
|
8356 return offset; |
|
8357 }, |
|
8358 |
|
8359 /* Find an object's position on the screen. */ |
|
8360 _findPos: function(obj) { |
|
8361 var inst = this._getInst(obj); |
|
8362 var isRTL = this._get(inst, 'isRTL'); |
|
8363 while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { |
|
8364 obj = obj[isRTL ? 'previousSibling' : 'nextSibling']; |
|
8365 } |
|
8366 var position = $(obj).offset(); |
|
8367 return [position.left, position.top]; |
|
8368 }, |
|
8369 |
|
8370 /* Hide the date picker from view. |
|
8371 @param input element - the input field attached to the date picker */ |
|
8372 _hideDatepicker: function(input) { |
|
8373 var inst = this._curInst; |
|
8374 if (!inst || (input && inst != $.data(input, PROP_NAME))) |
|
8375 return; |
|
8376 if (this._datepickerShowing) { |
|
8377 var showAnim = this._get(inst, 'showAnim'); |
|
8378 var duration = this._get(inst, 'duration'); |
|
8379 var postProcess = function() { |
|
8380 $.datepicker._tidyDialog(inst); |
|
8381 this._curInst = null; |
|
8382 }; |
|
8383 if ($.effects && $.effects[showAnim]) |
|
8384 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
|
8385 else |
|
8386 inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' : |
|
8387 (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess); |
|
8388 if (!showAnim) |
|
8389 postProcess(); |
|
8390 var onClose = this._get(inst, 'onClose'); |
|
8391 if (onClose) |
|
8392 onClose.apply((inst.input ? inst.input[0] : null), |
|
8393 [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback |
|
8394 this._datepickerShowing = false; |
|
8395 this._lastInput = null; |
|
8396 if (this._inDialog) { |
|
8397 this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' }); |
|
8398 if ($.blockUI) { |
|
8399 $.unblockUI(); |
|
8400 $('body').append(this.dpDiv); |
|
8401 } |
|
8402 } |
|
8403 this._inDialog = false; |
|
8404 } |
|
8405 }, |
|
8406 |
|
8407 /* Tidy up after a dialog display. */ |
|
8408 _tidyDialog: function(inst) { |
|
8409 inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar'); |
|
8410 }, |
|
8411 |
|
8412 /* Close date picker if clicked elsewhere. */ |
|
8413 _checkExternalClick: function(event) { |
|
8414 if (!$.datepicker._curInst) |
|
8415 return; |
|
8416 var $target = $(event.target); |
|
8417 if ($target[0].id != $.datepicker._mainDivId && |
|
8418 $target.parents('#' + $.datepicker._mainDivId).length == 0 && |
|
8419 !$target.hasClass($.datepicker.markerClassName) && |
|
8420 !$target.hasClass($.datepicker._triggerClass) && |
|
8421 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) |
|
8422 $.datepicker._hideDatepicker(); |
|
8423 }, |
|
8424 |
|
8425 /* Adjust one of the date sub-fields. */ |
|
8426 _adjustDate: function(id, offset, period) { |
|
8427 var target = $(id); |
|
8428 var inst = this._getInst(target[0]); |
|
8429 if (this._isDisabledDatepicker(target[0])) { |
|
8430 return; |
|
8431 } |
|
8432 this._adjustInstDate(inst, offset + |
|
8433 (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning |
|
8434 period); |
|
8435 this._updateDatepicker(inst); |
|
8436 }, |
|
8437 |
|
8438 /* Action for current link. */ |
|
8439 _gotoToday: function(id) { |
|
8440 var target = $(id); |
|
8441 var inst = this._getInst(target[0]); |
|
8442 if (this._get(inst, 'gotoCurrent') && inst.currentDay) { |
|
8443 inst.selectedDay = inst.currentDay; |
|
8444 inst.drawMonth = inst.selectedMonth = inst.currentMonth; |
|
8445 inst.drawYear = inst.selectedYear = inst.currentYear; |
|
8446 } |
|
8447 else { |
|
8448 var date = new Date(); |
|
8449 inst.selectedDay = date.getDate(); |
|
8450 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
8451 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
8452 } |
|
8453 this._notifyChange(inst); |
|
8454 this._adjustDate(target); |
|
8455 }, |
|
8456 |
|
8457 /* Action for selecting a new month/year. */ |
|
8458 _selectMonthYear: function(id, select, period) { |
|
8459 var target = $(id); |
|
8460 var inst = this._getInst(target[0]); |
|
8461 inst._selectingMonthYear = false; |
|
8462 inst['selected' + (period == 'M' ? 'Month' : 'Year')] = |
|
8463 inst['draw' + (period == 'M' ? 'Month' : 'Year')] = |
|
8464 parseInt(select.options[select.selectedIndex].value,10); |
|
8465 this._notifyChange(inst); |
|
8466 this._adjustDate(target); |
|
8467 }, |
|
8468 |
|
8469 /* Restore input focus after not changing month/year. */ |
|
8470 _clickMonthYear: function(id) { |
|
8471 var target = $(id); |
|
8472 var inst = this._getInst(target[0]); |
|
8473 if (inst.input && inst._selectingMonthYear && !$.browser.msie) |
|
8474 inst.input.focus(); |
|
8475 inst._selectingMonthYear = !inst._selectingMonthYear; |
|
8476 }, |
|
8477 |
|
8478 /* Action for selecting a day. */ |
|
8479 _selectDay: function(id, month, year, td) { |
|
8480 var target = $(id); |
|
8481 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { |
|
8482 return; |
|
8483 } |
|
8484 var inst = this._getInst(target[0]); |
|
8485 inst.selectedDay = inst.currentDay = $('a', td).html(); |
|
8486 inst.selectedMonth = inst.currentMonth = month; |
|
8487 inst.selectedYear = inst.currentYear = year; |
|
8488 this._selectDate(id, this._formatDate(inst, |
|
8489 inst.currentDay, inst.currentMonth, inst.currentYear)); |
|
8490 }, |
|
8491 |
|
8492 /* Erase the input field and hide the date picker. */ |
|
8493 _clearDate: function(id) { |
|
8494 var target = $(id); |
|
8495 var inst = this._getInst(target[0]); |
|
8496 this._selectDate(target, ''); |
|
8497 }, |
|
8498 |
|
8499 /* Update the input field with the selected date. */ |
|
8500 _selectDate: function(id, dateStr) { |
|
8501 var target = $(id); |
|
8502 var inst = this._getInst(target[0]); |
|
8503 dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); |
|
8504 if (inst.input) |
|
8505 inst.input.val(dateStr); |
|
8506 this._updateAlternate(inst); |
|
8507 var onSelect = this._get(inst, 'onSelect'); |
|
8508 if (onSelect) |
|
8509 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback |
|
8510 else if (inst.input) |
|
8511 inst.input.trigger('change'); // fire the change event |
|
8512 if (inst.inline) |
|
8513 this._updateDatepicker(inst); |
|
8514 else { |
|
8515 this._hideDatepicker(); |
|
8516 this._lastInput = inst.input[0]; |
|
8517 if (typeof(inst.input[0]) != 'object') |
|
8518 inst.input.focus(); // restore focus |
|
8519 this._lastInput = null; |
|
8520 } |
|
8521 }, |
|
8522 |
|
8523 /* Update any alternate field to synchronise with the main field. */ |
|
8524 _updateAlternate: function(inst) { |
|
8525 var altField = this._get(inst, 'altField'); |
|
8526 if (altField) { // update alternate field too |
|
8527 var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat'); |
|
8528 var date = this._getDate(inst); |
|
8529 var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); |
|
8530 $(altField).each(function() { $(this).val(dateStr); }); |
|
8531 } |
|
8532 }, |
|
8533 |
|
8534 /* Set as beforeShowDay function to prevent selection of weekends. |
|
8535 @param date Date - the date to customise |
|
8536 @return [boolean, string] - is this date selectable?, what is its CSS class? */ |
|
8537 noWeekends: function(date) { |
|
8538 var day = date.getDay(); |
|
8539 return [(day > 0 && day < 6), '']; |
|
8540 }, |
|
8541 |
|
8542 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. |
|
8543 @param date Date - the date to get the week for |
|
8544 @return number - the number of the week within the year that contains this date */ |
|
8545 iso8601Week: function(date) { |
|
8546 var checkDate = new Date(date.getTime()); |
|
8547 // Find Thursday of this week starting on Monday |
|
8548 checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); |
|
8549 var time = checkDate.getTime(); |
|
8550 checkDate.setMonth(0); // Compare with Jan 1 |
|
8551 checkDate.setDate(1); |
|
8552 return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; |
|
8553 }, |
|
8554 |
|
8555 /* Parse a string value into a date object. |
|
8556 See formatDate below for the possible formats. |
|
8557 |
|
8558 @param format string - the expected format of the date |
|
8559 @param value string - the date in the above format |
|
8560 @param settings Object - attributes include: |
|
8561 shortYearCutoff number - the cutoff year for determining the century (optional) |
|
8562 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
8563 dayNames string[7] - names of the days from Sunday (optional) |
|
8564 monthNamesShort string[12] - abbreviated names of the months (optional) |
|
8565 monthNames string[12] - names of the months (optional) |
|
8566 @return Date - the extracted date value or null if value is blank */ |
|
8567 parseDate: function (format, value, settings) { |
|
8568 if (format == null || value == null) |
|
8569 throw 'Invalid arguments'; |
|
8570 value = (typeof value == 'object' ? value.toString() : value + ''); |
|
8571 if (value == '') |
|
8572 return null; |
|
8573 var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff; |
|
8574 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
|
8575 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
|
8576 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
|
8577 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
|
8578 var year = -1; |
|
8579 var month = -1; |
|
8580 var day = -1; |
|
8581 var doy = -1; |
|
8582 var literal = false; |
|
8583 // Check whether a format character is doubled |
|
8584 var lookAhead = function(match) { |
|
8585 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
|
8586 if (matches) |
|
8587 iFormat++; |
|
8588 return matches; |
|
8589 }; |
|
8590 // Extract a number from the string value |
|
8591 var getNumber = function(match) { |
|
8592 lookAhead(match); |
|
8593 var size = (match == '@' ? 14 : (match == '!' ? 20 : |
|
8594 (match == 'y' ? 4 : (match == 'o' ? 3 : 2)))); |
|
8595 var digits = new RegExp('^\\d{1,' + size + '}'); |
|
8596 var num = value.substring(iValue).match(digits); |
|
8597 if (!num) |
|
8598 throw 'Missing number at position ' + iValue; |
|
8599 iValue += num[0].length; |
|
8600 return parseInt(num[0], 10); |
|
8601 }; |
|
8602 // Extract a name from the string value and convert to an index |
|
8603 var getName = function(match, shortNames, longNames) { |
|
8604 var names = (lookAhead(match) ? longNames : shortNames); |
|
8605 for (var i = 0; i < names.length; i++) { |
|
8606 if (value.substr(iValue, names[i].length) == names[i]) { |
|
8607 iValue += names[i].length; |
|
8608 return i + 1; |
|
8609 } |
|
8610 } |
|
8611 throw 'Unknown name at position ' + iValue; |
|
8612 }; |
|
8613 // Confirm that a literal character matches the string value |
|
8614 var checkLiteral = function() { |
|
8615 if (value.charAt(iValue) != format.charAt(iFormat)) |
|
8616 throw 'Unexpected literal at position ' + iValue; |
|
8617 iValue++; |
|
8618 }; |
|
8619 var iValue = 0; |
|
8620 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
|
8621 if (literal) |
|
8622 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
8623 literal = false; |
|
8624 else |
|
8625 checkLiteral(); |
|
8626 else |
|
8627 switch (format.charAt(iFormat)) { |
|
8628 case 'd': |
|
8629 day = getNumber('d'); |
|
8630 break; |
|
8631 case 'D': |
|
8632 getName('D', dayNamesShort, dayNames); |
|
8633 break; |
|
8634 case 'o': |
|
8635 doy = getNumber('o'); |
|
8636 break; |
|
8637 case 'm': |
|
8638 month = getNumber('m'); |
|
8639 break; |
|
8640 case 'M': |
|
8641 month = getName('M', monthNamesShort, monthNames); |
|
8642 break; |
|
8643 case 'y': |
|
8644 year = getNumber('y'); |
|
8645 break; |
|
8646 case '@': |
|
8647 var date = new Date(getNumber('@')); |
|
8648 year = date.getFullYear(); |
|
8649 month = date.getMonth() + 1; |
|
8650 day = date.getDate(); |
|
8651 break; |
|
8652 case '!': |
|
8653 var date = new Date((getNumber('!') - this._ticksTo1970) / 10000); |
|
8654 year = date.getFullYear(); |
|
8655 month = date.getMonth() + 1; |
|
8656 day = date.getDate(); |
|
8657 break; |
|
8658 case "'": |
|
8659 if (lookAhead("'")) |
|
8660 checkLiteral(); |
|
8661 else |
|
8662 literal = true; |
|
8663 break; |
|
8664 default: |
|
8665 checkLiteral(); |
|
8666 } |
|
8667 } |
|
8668 if (year == -1) |
|
8669 year = new Date().getFullYear(); |
|
8670 else if (year < 100) |
|
8671 year += new Date().getFullYear() - new Date().getFullYear() % 100 + |
|
8672 (year <= shortYearCutoff ? 0 : -100); |
|
8673 if (doy > -1) { |
|
8674 month = 1; |
|
8675 day = doy; |
|
8676 do { |
|
8677 var dim = this._getDaysInMonth(year, month - 1); |
|
8678 if (day <= dim) |
|
8679 break; |
|
8680 month++; |
|
8681 day -= dim; |
|
8682 } while (true); |
|
8683 } |
|
8684 var date = this._daylightSavingAdjust(new Date(year, month - 1, day)); |
|
8685 if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) |
|
8686 throw 'Invalid date'; // E.g. 31/02/* |
|
8687 return date; |
|
8688 }, |
|
8689 |
|
8690 /* Standard date formats. */ |
|
8691 ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601) |
|
8692 COOKIE: 'D, dd M yy', |
|
8693 ISO_8601: 'yy-mm-dd', |
|
8694 RFC_822: 'D, d M y', |
|
8695 RFC_850: 'DD, dd-M-y', |
|
8696 RFC_1036: 'D, d M y', |
|
8697 RFC_1123: 'D, d M yy', |
|
8698 RFC_2822: 'D, d M yy', |
|
8699 RSS: 'D, d M y', // RFC 822 |
|
8700 TICKS: '!', |
|
8701 TIMESTAMP: '@', |
|
8702 W3C: 'yy-mm-dd', // ISO 8601 |
|
8703 |
|
8704 _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + |
|
8705 Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000), |
|
8706 |
|
8707 /* Format a date object into a string value. |
|
8708 The format can be combinations of the following: |
|
8709 d - day of month (no leading zero) |
|
8710 dd - day of month (two digit) |
|
8711 o - day of year (no leading zeros) |
|
8712 oo - day of year (three digit) |
|
8713 D - day name short |
|
8714 DD - day name long |
|
8715 m - month of year (no leading zero) |
|
8716 mm - month of year (two digit) |
|
8717 M - month name short |
|
8718 MM - month name long |
|
8719 y - year (two digit) |
|
8720 yy - year (four digit) |
|
8721 @ - Unix timestamp (ms since 01/01/1970) |
|
8722 ! - Windows ticks (100ns since 01/01/0001) |
|
8723 '...' - literal text |
|
8724 '' - single quote |
|
8725 |
|
8726 @param format string - the desired format of the date |
|
8727 @param date Date - the date value to format |
|
8728 @param settings Object - attributes include: |
|
8729 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
8730 dayNames string[7] - names of the days from Sunday (optional) |
|
8731 monthNamesShort string[12] - abbreviated names of the months (optional) |
|
8732 monthNames string[12] - names of the months (optional) |
|
8733 @return string - the date in the above format */ |
|
8734 formatDate: function (format, date, settings) { |
|
8735 if (!date) |
|
8736 return ''; |
|
8737 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
|
8738 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
|
8739 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
|
8740 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
|
8741 // Check whether a format character is doubled |
|
8742 var lookAhead = function(match) { |
|
8743 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
|
8744 if (matches) |
|
8745 iFormat++; |
|
8746 return matches; |
|
8747 }; |
|
8748 // Format a number, with leading zero if necessary |
|
8749 var formatNumber = function(match, value, len) { |
|
8750 var num = '' + value; |
|
8751 if (lookAhead(match)) |
|
8752 while (num.length < len) |
|
8753 num = '0' + num; |
|
8754 return num; |
|
8755 }; |
|
8756 // Format a name, short or long as requested |
|
8757 var formatName = function(match, value, shortNames, longNames) { |
|
8758 return (lookAhead(match) ? longNames[value] : shortNames[value]); |
|
8759 }; |
|
8760 var output = ''; |
|
8761 var literal = false; |
|
8762 if (date) |
|
8763 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
|
8764 if (literal) |
|
8765 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
8766 literal = false; |
|
8767 else |
|
8768 output += format.charAt(iFormat); |
|
8769 else |
|
8770 switch (format.charAt(iFormat)) { |
|
8771 case 'd': |
|
8772 output += formatNumber('d', date.getDate(), 2); |
|
8773 break; |
|
8774 case 'D': |
|
8775 output += formatName('D', date.getDay(), dayNamesShort, dayNames); |
|
8776 break; |
|
8777 case 'o': |
|
8778 output += formatNumber('o', |
|
8779 (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3); |
|
8780 break; |
|
8781 case 'm': |
|
8782 output += formatNumber('m', date.getMonth() + 1, 2); |
|
8783 break; |
|
8784 case 'M': |
|
8785 output += formatName('M', date.getMonth(), monthNamesShort, monthNames); |
|
8786 break; |
|
8787 case 'y': |
|
8788 output += (lookAhead('y') ? date.getFullYear() : |
|
8789 (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); |
|
8790 break; |
|
8791 case '@': |
|
8792 output += date.getTime(); |
|
8793 break; |
|
8794 case '!': |
|
8795 output += date.getTime() * 10000 + this._ticksTo1970; |
|
8796 break; |
|
8797 case "'": |
|
8798 if (lookAhead("'")) |
|
8799 output += "'"; |
|
8800 else |
|
8801 literal = true; |
|
8802 break; |
|
8803 default: |
|
8804 output += format.charAt(iFormat); |
|
8805 } |
|
8806 } |
|
8807 return output; |
|
8808 }, |
|
8809 |
|
8810 /* Extract all possible characters from the date format. */ |
|
8811 _possibleChars: function (format) { |
|
8812 var chars = ''; |
|
8813 var literal = false; |
|
8814 // Check whether a format character is doubled |
|
8815 var lookAhead = function(match) { |
|
8816 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
|
8817 if (matches) |
|
8818 iFormat++; |
|
8819 return matches; |
|
8820 }; |
|
8821 for (var iFormat = 0; iFormat < format.length; iFormat++) |
|
8822 if (literal) |
|
8823 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
8824 literal = false; |
|
8825 else |
|
8826 chars += format.charAt(iFormat); |
|
8827 else |
|
8828 switch (format.charAt(iFormat)) { |
|
8829 case 'd': case 'm': case 'y': case '@': |
|
8830 chars += '0123456789'; |
|
8831 break; |
|
8832 case 'D': case 'M': |
|
8833 return null; // Accept anything |
|
8834 case "'": |
|
8835 if (lookAhead("'")) |
|
8836 chars += "'"; |
|
8837 else |
|
8838 literal = true; |
|
8839 break; |
|
8840 default: |
|
8841 chars += format.charAt(iFormat); |
|
8842 } |
|
8843 return chars; |
|
8844 }, |
|
8845 |
|
8846 /* Get a setting value, defaulting if necessary. */ |
|
8847 _get: function(inst, name) { |
|
8848 return inst.settings[name] !== undefined ? |
|
8849 inst.settings[name] : this._defaults[name]; |
|
8850 }, |
|
8851 |
|
8852 /* Parse existing date and initialise date picker. */ |
|
8853 _setDateFromField: function(inst, noDefault) { |
|
8854 if (inst.input.val() == inst.lastVal) { |
|
8855 return; |
|
8856 } |
|
8857 var dateFormat = this._get(inst, 'dateFormat'); |
|
8858 var dates = inst.lastVal = inst.input ? inst.input.val() : null; |
|
8859 var date, defaultDate; |
|
8860 date = defaultDate = this._getDefaultDate(inst); |
|
8861 var settings = this._getFormatConfig(inst); |
|
8862 try { |
|
8863 date = this.parseDate(dateFormat, dates, settings) || defaultDate; |
|
8864 } catch (event) { |
|
8865 this.log(event); |
|
8866 dates = (noDefault ? '' : dates); |
|
8867 } |
|
8868 inst.selectedDay = date.getDate(); |
|
8869 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
8870 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
8871 inst.currentDay = (dates ? date.getDate() : 0); |
|
8872 inst.currentMonth = (dates ? date.getMonth() : 0); |
|
8873 inst.currentYear = (dates ? date.getFullYear() : 0); |
|
8874 this._adjustInstDate(inst); |
|
8875 }, |
|
8876 |
|
8877 /* Retrieve the default date shown on opening. */ |
|
8878 _getDefaultDate: function(inst) { |
|
8879 return this._restrictMinMax(inst, |
|
8880 this._determineDate(inst, this._get(inst, 'defaultDate'), new Date())); |
|
8881 }, |
|
8882 |
|
8883 /* A date may be specified as an exact value or a relative one. */ |
|
8884 _determineDate: function(inst, date, defaultDate) { |
|
8885 var offsetNumeric = function(offset) { |
|
8886 var date = new Date(); |
|
8887 date.setDate(date.getDate() + offset); |
|
8888 return date; |
|
8889 }; |
|
8890 var offsetString = function(offset) { |
|
8891 try { |
|
8892 return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'), |
|
8893 offset, $.datepicker._getFormatConfig(inst)); |
|
8894 } |
|
8895 catch (e) { |
|
8896 // Ignore |
|
8897 } |
|
8898 var date = (offset.toLowerCase().match(/^c/) ? |
|
8899 $.datepicker._getDate(inst) : null) || new Date(); |
|
8900 var year = date.getFullYear(); |
|
8901 var month = date.getMonth(); |
|
8902 var day = date.getDate(); |
|
8903 var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g; |
|
8904 var matches = pattern.exec(offset); |
|
8905 while (matches) { |
|
8906 switch (matches[2] || 'd') { |
|
8907 case 'd' : case 'D' : |
|
8908 day += parseInt(matches[1],10); break; |
|
8909 case 'w' : case 'W' : |
|
8910 day += parseInt(matches[1],10) * 7; break; |
|
8911 case 'm' : case 'M' : |
|
8912 month += parseInt(matches[1],10); |
|
8913 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); |
|
8914 break; |
|
8915 case 'y': case 'Y' : |
|
8916 year += parseInt(matches[1],10); |
|
8917 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); |
|
8918 break; |
|
8919 } |
|
8920 matches = pattern.exec(offset); |
|
8921 } |
|
8922 return new Date(year, month, day); |
|
8923 }; |
|
8924 date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) : |
|
8925 (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date))); |
|
8926 date = (date && date.toString() == 'Invalid Date' ? defaultDate : date); |
|
8927 if (date) { |
|
8928 date.setHours(0); |
|
8929 date.setMinutes(0); |
|
8930 date.setSeconds(0); |
|
8931 date.setMilliseconds(0); |
|
8932 } |
|
8933 return this._daylightSavingAdjust(date); |
|
8934 }, |
|
8935 |
|
8936 /* Handle switch to/from daylight saving. |
|
8937 Hours may be non-zero on daylight saving cut-over: |
|
8938 > 12 when midnight changeover, but then cannot generate |
|
8939 midnight datetime, so jump to 1AM, otherwise reset. |
|
8940 @param date (Date) the date to check |
|
8941 @return (Date) the corrected date */ |
|
8942 _daylightSavingAdjust: function(date) { |
|
8943 if (!date) return null; |
|
8944 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); |
|
8945 return date; |
|
8946 }, |
|
8947 |
|
8948 /* Set the date(s) directly. */ |
|
8949 _setDate: function(inst, date, noChange) { |
|
8950 var clear = !(date); |
|
8951 var origMonth = inst.selectedMonth; |
|
8952 var origYear = inst.selectedYear; |
|
8953 date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); |
|
8954 inst.selectedDay = inst.currentDay = date.getDate(); |
|
8955 inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth(); |
|
8956 inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear(); |
|
8957 if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange) |
|
8958 this._notifyChange(inst); |
|
8959 this._adjustInstDate(inst); |
|
8960 if (inst.input) { |
|
8961 inst.input.val(clear ? '' : this._formatDate(inst)); |
|
8962 } |
|
8963 }, |
|
8964 |
|
8965 /* Retrieve the date(s) directly. */ |
|
8966 _getDate: function(inst) { |
|
8967 var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : |
|
8968 this._daylightSavingAdjust(new Date( |
|
8969 inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
8970 return startDate; |
|
8971 }, |
|
8972 |
|
8973 /* Generate the HTML for the current state of the date picker. */ |
|
8974 _generateHTML: function(inst) { |
|
8975 var today = new Date(); |
|
8976 today = this._daylightSavingAdjust( |
|
8977 new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time |
|
8978 var isRTL = this._get(inst, 'isRTL'); |
|
8979 var showButtonPanel = this._get(inst, 'showButtonPanel'); |
|
8980 var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext'); |
|
8981 var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat'); |
|
8982 var numMonths = this._getNumberOfMonths(inst); |
|
8983 var showCurrentAtPos = this._get(inst, 'showCurrentAtPos'); |
|
8984 var stepMonths = this._get(inst, 'stepMonths'); |
|
8985 var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1); |
|
8986 var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : |
|
8987 new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
8988 var minDate = this._getMinMaxDate(inst, 'min'); |
|
8989 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
8990 var drawMonth = inst.drawMonth - showCurrentAtPos; |
|
8991 var drawYear = inst.drawYear; |
|
8992 if (drawMonth < 0) { |
|
8993 drawMonth += 12; |
|
8994 drawYear--; |
|
8995 } |
|
8996 if (maxDate) { |
|
8997 var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), |
|
8998 maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate())); |
|
8999 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); |
|
9000 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { |
|
9001 drawMonth--; |
|
9002 if (drawMonth < 0) { |
|
9003 drawMonth = 11; |
|
9004 drawYear--; |
|
9005 } |
|
9006 } |
|
9007 } |
|
9008 inst.drawMonth = drawMonth; |
|
9009 inst.drawYear = drawYear; |
|
9010 var prevText = this._get(inst, 'prevText'); |
|
9011 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, |
|
9012 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), |
|
9013 this._getFormatConfig(inst))); |
|
9014 var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? |
|
9015 '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid + |
|
9016 '.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' + |
|
9017 ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' : |
|
9018 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>')); |
|
9019 var nextText = this._get(inst, 'nextText'); |
|
9020 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, |
|
9021 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), |
|
9022 this._getFormatConfig(inst))); |
|
9023 var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? |
|
9024 '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid + |
|
9025 '.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' + |
|
9026 ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' : |
|
9027 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>')); |
|
9028 var currentText = this._get(inst, 'currentText'); |
|
9029 var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); |
|
9030 currentText = (!navigationAsDateFormat ? currentText : |
|
9031 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); |
|
9032 var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid + |
|
9033 '.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : ''); |
|
9034 var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') + |
|
9035 (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid + |
|
9036 '.datepicker._gotoToday(\'#' + inst.id + '\');"' + |
|
9037 '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : ''; |
|
9038 var firstDay = parseInt(this._get(inst, 'firstDay'),10); |
|
9039 firstDay = (isNaN(firstDay) ? 0 : firstDay); |
|
9040 var showWeek = this._get(inst, 'showWeek'); |
|
9041 var dayNames = this._get(inst, 'dayNames'); |
|
9042 var dayNamesShort = this._get(inst, 'dayNamesShort'); |
|
9043 var dayNamesMin = this._get(inst, 'dayNamesMin'); |
|
9044 var monthNames = this._get(inst, 'monthNames'); |
|
9045 var monthNamesShort = this._get(inst, 'monthNamesShort'); |
|
9046 var beforeShowDay = this._get(inst, 'beforeShowDay'); |
|
9047 var showOtherMonths = this._get(inst, 'showOtherMonths'); |
|
9048 var selectOtherMonths = this._get(inst, 'selectOtherMonths'); |
|
9049 var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week; |
|
9050 var defaultDate = this._getDefaultDate(inst); |
|
9051 var html = ''; |
|
9052 for (var row = 0; row < numMonths[0]; row++) { |
|
9053 var group = ''; |
|
9054 for (var col = 0; col < numMonths[1]; col++) { |
|
9055 var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); |
|
9056 var cornerClass = ' ui-corner-all'; |
|
9057 var calender = ''; |
|
9058 if (isMultiMonth) { |
|
9059 calender += '<div class="ui-datepicker-group'; |
|
9060 if (numMonths[1] > 1) |
|
9061 switch (col) { |
|
9062 case 0: calender += ' ui-datepicker-group-first'; |
|
9063 cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break; |
|
9064 case numMonths[1]-1: calender += ' ui-datepicker-group-last'; |
|
9065 cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break; |
|
9066 default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break; |
|
9067 } |
|
9068 calender += '">'; |
|
9069 } |
|
9070 calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' + |
|
9071 (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') + |
|
9072 (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') + |
|
9073 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, |
|
9074 row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers |
|
9075 '</div><table class="ui-datepicker-calendar"><thead>' + |
|
9076 '<tr>'; |
|
9077 var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : ''); |
|
9078 for (var dow = 0; dow < 7; dow++) { // days of the week |
|
9079 var day = (dow + firstDay) % 7; |
|
9080 thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' + |
|
9081 '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>'; |
|
9082 } |
|
9083 calender += thead + '</tr></thead><tbody>'; |
|
9084 var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); |
|
9085 if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) |
|
9086 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); |
|
9087 var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; |
|
9088 var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate |
|
9089 var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); |
|
9090 for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows |
|
9091 calender += '<tr>'; |
|
9092 var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' + |
|
9093 this._get(inst, 'calculateWeek')(printDate) + '</td>'); |
|
9094 for (var dow = 0; dow < 7; dow++) { // create date picker days |
|
9095 var daySettings = (beforeShowDay ? |
|
9096 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']); |
|
9097 var otherMonth = (printDate.getMonth() != drawMonth); |
|
9098 var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] || |
|
9099 (minDate && printDate < minDate) || (maxDate && printDate > maxDate); |
|
9100 tbody += '<td class="' + |
|
9101 ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends |
|
9102 (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months |
|
9103 ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key |
|
9104 (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ? |
|
9105 // or defaultDate is current printedDate and defaultDate is selectedDate |
|
9106 ' ' + this._dayOverClass : '') + // highlight selected day |
|
9107 (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days |
|
9108 (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates |
|
9109 (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day |
|
9110 (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different) |
|
9111 ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title |
|
9112 (unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' + |
|
9113 inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions |
|
9114 (otherMonth && !showOtherMonths ? ' ' : // display for other months |
|
9115 (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' + |
|
9116 (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + |
|
9117 (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day |
|
9118 (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months |
|
9119 '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date |
|
9120 printDate.setDate(printDate.getDate() + 1); |
|
9121 printDate = this._daylightSavingAdjust(printDate); |
|
9122 } |
|
9123 calender += tbody + '</tr>'; |
|
9124 } |
|
9125 drawMonth++; |
|
9126 if (drawMonth > 11) { |
|
9127 drawMonth = 0; |
|
9128 drawYear++; |
|
9129 } |
|
9130 calender += '</tbody></table>' + (isMultiMonth ? '</div>' + |
|
9131 ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : ''); |
|
9132 group += calender; |
|
9133 } |
|
9134 html += group; |
|
9135 } |
|
9136 html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? |
|
9137 '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : ''); |
|
9138 inst._keyEvent = false; |
|
9139 return html; |
|
9140 }, |
|
9141 |
|
9142 /* Generate the month and year header. */ |
|
9143 _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, |
|
9144 secondary, monthNames, monthNamesShort) { |
|
9145 var changeMonth = this._get(inst, 'changeMonth'); |
|
9146 var changeYear = this._get(inst, 'changeYear'); |
|
9147 var showMonthAfterYear = this._get(inst, 'showMonthAfterYear'); |
|
9148 var html = '<div class="ui-datepicker-title">'; |
|
9149 var monthHtml = ''; |
|
9150 // month selection |
|
9151 if (secondary || !changeMonth) |
|
9152 monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>'; |
|
9153 else { |
|
9154 var inMinYear = (minDate && minDate.getFullYear() == drawYear); |
|
9155 var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); |
|
9156 monthHtml += '<select class="ui-datepicker-month" ' + |
|
9157 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + |
|
9158 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
|
9159 '>'; |
|
9160 for (var month = 0; month < 12; month++) { |
|
9161 if ((!inMinYear || month >= minDate.getMonth()) && |
|
9162 (!inMaxYear || month <= maxDate.getMonth())) |
|
9163 monthHtml += '<option value="' + month + '"' + |
|
9164 (month == drawMonth ? ' selected="selected"' : '') + |
|
9165 '>' + monthNamesShort[month] + '</option>'; |
|
9166 } |
|
9167 monthHtml += '</select>'; |
|
9168 } |
|
9169 if (!showMonthAfterYear) |
|
9170 html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : ''); |
|
9171 // year selection |
|
9172 if (secondary || !changeYear) |
|
9173 html += '<span class="ui-datepicker-year">' + drawYear + '</span>'; |
|
9174 else { |
|
9175 // determine range of years to display |
|
9176 var years = this._get(inst, 'yearRange').split(':'); |
|
9177 var thisYear = new Date().getFullYear(); |
|
9178 var determineYear = function(value) { |
|
9179 var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) : |
|
9180 (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) : |
|
9181 parseInt(value, 10))); |
|
9182 return (isNaN(year) ? thisYear : year); |
|
9183 }; |
|
9184 var year = determineYear(years[0]); |
|
9185 var endYear = Math.max(year, determineYear(years[1] || '')); |
|
9186 year = (minDate ? Math.max(year, minDate.getFullYear()) : year); |
|
9187 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); |
|
9188 html += '<select class="ui-datepicker-year" ' + |
|
9189 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + |
|
9190 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
|
9191 '>'; |
|
9192 for (; year <= endYear; year++) { |
|
9193 html += '<option value="' + year + '"' + |
|
9194 (year == drawYear ? ' selected="selected"' : '') + |
|
9195 '>' + year + '</option>'; |
|
9196 } |
|
9197 html += '</select>'; |
|
9198 } |
|
9199 html += this._get(inst, 'yearSuffix'); |
|
9200 if (showMonthAfterYear) |
|
9201 html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml; |
|
9202 html += '</div>'; // Close datepicker_header |
|
9203 return html; |
|
9204 }, |
|
9205 |
|
9206 /* Adjust one of the date sub-fields. */ |
|
9207 _adjustInstDate: function(inst, offset, period) { |
|
9208 var year = inst.drawYear + (period == 'Y' ? offset : 0); |
|
9209 var month = inst.drawMonth + (period == 'M' ? offset : 0); |
|
9210 var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + |
|
9211 (period == 'D' ? offset : 0); |
|
9212 var date = this._restrictMinMax(inst, |
|
9213 this._daylightSavingAdjust(new Date(year, month, day))); |
|
9214 inst.selectedDay = date.getDate(); |
|
9215 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
9216 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
9217 if (period == 'M' || period == 'Y') |
|
9218 this._notifyChange(inst); |
|
9219 }, |
|
9220 |
|
9221 /* Ensure a date is within any min/max bounds. */ |
|
9222 _restrictMinMax: function(inst, date) { |
|
9223 var minDate = this._getMinMaxDate(inst, 'min'); |
|
9224 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
9225 date = (minDate && date < minDate ? minDate : date); |
|
9226 date = (maxDate && date > maxDate ? maxDate : date); |
|
9227 return date; |
|
9228 }, |
|
9229 |
|
9230 /* Notify change of month/year. */ |
|
9231 _notifyChange: function(inst) { |
|
9232 var onChange = this._get(inst, 'onChangeMonthYear'); |
|
9233 if (onChange) |
|
9234 onChange.apply((inst.input ? inst.input[0] : null), |
|
9235 [inst.selectedYear, inst.selectedMonth + 1, inst]); |
|
9236 }, |
|
9237 |
|
9238 /* Determine the number of months to show. */ |
|
9239 _getNumberOfMonths: function(inst) { |
|
9240 var numMonths = this._get(inst, 'numberOfMonths'); |
|
9241 return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); |
|
9242 }, |
|
9243 |
|
9244 /* Determine the current maximum date - ensure no time components are set. */ |
|
9245 _getMinMaxDate: function(inst, minMax) { |
|
9246 return this._determineDate(inst, this._get(inst, minMax + 'Date'), null); |
|
9247 }, |
|
9248 |
|
9249 /* Find the number of days in a given month. */ |
|
9250 _getDaysInMonth: function(year, month) { |
|
9251 return 32 - new Date(year, month, 32).getDate(); |
|
9252 }, |
|
9253 |
|
9254 /* Find the day of the week of the first of a month. */ |
|
9255 _getFirstDayOfMonth: function(year, month) { |
|
9256 return new Date(year, month, 1).getDay(); |
|
9257 }, |
|
9258 |
|
9259 /* Determines if we should allow a "next/prev" month display change. */ |
|
9260 _canAdjustMonth: function(inst, offset, curYear, curMonth) { |
|
9261 var numMonths = this._getNumberOfMonths(inst); |
|
9262 var date = this._daylightSavingAdjust(new Date(curYear, |
|
9263 curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1)); |
|
9264 if (offset < 0) |
|
9265 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); |
|
9266 return this._isInRange(inst, date); |
|
9267 }, |
|
9268 |
|
9269 /* Is the given date in the accepted range? */ |
|
9270 _isInRange: function(inst, date) { |
|
9271 var minDate = this._getMinMaxDate(inst, 'min'); |
|
9272 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
9273 return ((!minDate || date.getTime() >= minDate.getTime()) && |
|
9274 (!maxDate || date.getTime() <= maxDate.getTime())); |
|
9275 }, |
|
9276 |
|
9277 /* Provide the configuration settings for formatting/parsing. */ |
|
9278 _getFormatConfig: function(inst) { |
|
9279 var shortYearCutoff = this._get(inst, 'shortYearCutoff'); |
|
9280 shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : |
|
9281 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); |
|
9282 return {shortYearCutoff: shortYearCutoff, |
|
9283 dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), |
|
9284 monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; |
|
9285 }, |
|
9286 |
|
9287 /* Format the given date for display. */ |
|
9288 _formatDate: function(inst, day, month, year) { |
|
9289 if (!day) { |
|
9290 inst.currentDay = inst.selectedDay; |
|
9291 inst.currentMonth = inst.selectedMonth; |
|
9292 inst.currentYear = inst.selectedYear; |
|
9293 } |
|
9294 var date = (day ? (typeof day == 'object' ? day : |
|
9295 this._daylightSavingAdjust(new Date(year, month, day))) : |
|
9296 this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
9297 return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst)); |
|
9298 } |
|
9299 }); |
|
9300 |
|
9301 /* jQuery extend now ignores nulls! */ |
|
9302 function extendRemove(target, props) { |
|
9303 $.extend(target, props); |
|
9304 for (var name in props) |
|
9305 if (props[name] == null || props[name] == undefined) |
|
9306 target[name] = props[name]; |
|
9307 return target; |
|
9308 }; |
|
9309 |
|
9310 /* Determine whether an object is an array. */ |
|
9311 function isArray(a) { |
|
9312 return (a && (($.browser.safari && typeof a == 'object' && a.length) || |
|
9313 (a.constructor && a.constructor.toString().match(/\Array\(\)/)))); |
|
9314 }; |
|
9315 |
|
9316 /* Invoke the datepicker functionality. |
|
9317 @param options string - a command, optionally followed by additional parameters or |
|
9318 Object - settings for attaching new datepicker functionality |
|
9319 @return jQuery object */ |
|
9320 $.fn.datepicker = function(options){ |
|
9321 |
|
9322 /* Initialise the date picker. */ |
|
9323 if (!$.datepicker.initialized) { |
|
9324 $(document).mousedown($.datepicker._checkExternalClick). |
|
9325 find('body').append($.datepicker.dpDiv); |
|
9326 $.datepicker.initialized = true; |
|
9327 } |
|
9328 |
|
9329 var otherArgs = Array.prototype.slice.call(arguments, 1); |
|
9330 if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget')) |
|
9331 return $.datepicker['_' + options + 'Datepicker']. |
|
9332 apply($.datepicker, [this[0]].concat(otherArgs)); |
|
9333 if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string') |
|
9334 return $.datepicker['_' + options + 'Datepicker']. |
|
9335 apply($.datepicker, [this[0]].concat(otherArgs)); |
|
9336 return this.each(function() { |
|
9337 typeof options == 'string' ? |
|
9338 $.datepicker['_' + options + 'Datepicker']. |
|
9339 apply($.datepicker, [this].concat(otherArgs)) : |
|
9340 $.datepicker._attachDatepicker(this, options); |
|
9341 }); |
|
9342 }; |
|
9343 |
|
9344 $.datepicker = new Datepicker(); // singleton instance |
|
9345 $.datepicker.initialized = false; |
|
9346 $.datepicker.uuid = new Date().getTime(); |
|
9347 $.datepicker.version = "1.8.1"; |
|
9348 |
|
9349 // Workaround for #4055 |
|
9350 // Add another global to avoid noConflict issues with inline event handlers |
|
9351 window['DP_jQuery_' + dpuuid] = $; |
|
9352 |
|
9353 })(jQuery); |
|
9354 /* |
|
9355 * jQuery UI Progressbar 1.8.1 |
|
9356 * |
|
9357 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
9358 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
9359 * and GPL (GPL-LICENSE.txt) licenses. |
|
9360 * |
|
9361 * http://docs.jquery.com/UI/Progressbar |
|
9362 * |
|
9363 * Depends: |
|
9364 * jquery.ui.core.js |
|
9365 * jquery.ui.widget.js |
|
9366 */ |
|
9367 (function( $ ) { |
|
9368 |
|
9369 $.widget( "ui.progressbar", { |
|
9370 options: { |
|
9371 value: 0 |
|
9372 }, |
|
9373 _create: function() { |
|
9374 this.element |
|
9375 .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) |
|
9376 .attr({ |
|
9377 role: "progressbar", |
|
9378 "aria-valuemin": this._valueMin(), |
|
9379 "aria-valuemax": this._valueMax(), |
|
9380 "aria-valuenow": this._value() |
|
9381 }); |
|
9382 |
|
9383 this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" ) |
|
9384 .appendTo( this.element ); |
|
9385 |
|
9386 this._refreshValue(); |
|
9387 }, |
|
9388 |
|
9389 destroy: function() { |
|
9390 this.element |
|
9391 .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) |
|
9392 .removeAttr( "role" ) |
|
9393 .removeAttr( "aria-valuemin" ) |
|
9394 .removeAttr( "aria-valuemax" ) |
|
9395 .removeAttr( "aria-valuenow" ); |
|
9396 |
|
9397 this.valueDiv.remove(); |
|
9398 |
|
9399 $.Widget.prototype.destroy.apply( this, arguments ); |
|
9400 }, |
|
9401 |
|
9402 value: function( newValue ) { |
|
9403 if ( newValue === undefined ) { |
|
9404 return this._value(); |
|
9405 } |
|
9406 |
|
9407 this._setOption( "value", newValue ); |
|
9408 return this; |
|
9409 }, |
|
9410 |
|
9411 _setOption: function( key, value ) { |
|
9412 switch ( key ) { |
|
9413 case "value": |
|
9414 this.options.value = value; |
|
9415 this._refreshValue(); |
|
9416 this._trigger( "change" ); |
|
9417 break; |
|
9418 } |
|
9419 |
|
9420 $.Widget.prototype._setOption.apply( this, arguments ); |
|
9421 }, |
|
9422 |
|
9423 _value: function() { |
|
9424 var val = this.options.value; |
|
9425 // normalize invalid value |
|
9426 if ( typeof val !== "number" ) { |
|
9427 val = 0; |
|
9428 } |
|
9429 if ( val < this._valueMin() ) { |
|
9430 val = this._valueMin(); |
|
9431 } |
|
9432 if ( val > this._valueMax() ) { |
|
9433 val = this._valueMax(); |
|
9434 } |
|
9435 |
|
9436 return val; |
|
9437 }, |
|
9438 |
|
9439 _valueMin: function() { |
|
9440 return 0; |
|
9441 }, |
|
9442 |
|
9443 _valueMax: function() { |
|
9444 return 100; |
|
9445 }, |
|
9446 |
|
9447 _refreshValue: function() { |
|
9448 var value = this.value(); |
|
9449 this.valueDiv |
|
9450 [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" ) |
|
9451 .width( value + "%" ); |
|
9452 this.element.attr( "aria-valuenow", value ); |
|
9453 } |
|
9454 }); |
|
9455 |
|
9456 $.extend( $.ui.progressbar, { |
|
9457 version: "1.8.1" |
|
9458 }); |
|
9459 |
|
9460 })( jQuery ); |
|
9461 /* |
|
9462 * jQuery UI Effects 1.8.1 |
|
9463 * |
|
9464 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
9465 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
9466 * and GPL (GPL-LICENSE.txt) licenses. |
|
9467 * |
|
9468 * http://docs.jquery.com/UI/Effects/ |
|
9469 */ |
|
9470 ;jQuery.effects || (function($) { |
|
9471 |
|
9472 $.effects = {}; |
|
9473 |
|
9474 |
|
9475 |
|
9476 /******************************************************************************/ |
|
9477 /****************************** COLOR ANIMATIONS ******************************/ |
|
9478 /******************************************************************************/ |
|
9479 |
|
9480 // override the animation for color styles |
|
9481 $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', |
|
9482 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], |
|
9483 function(i, attr) { |
|
9484 $.fx.step[attr] = function(fx) { |
|
9485 if (!fx.colorInit) { |
|
9486 fx.start = getColor(fx.elem, attr); |
|
9487 fx.end = getRGB(fx.end); |
|
9488 fx.colorInit = true; |
|
9489 } |
|
9490 |
|
9491 fx.elem.style[attr] = 'rgb(' + |
|
9492 Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' + |
|
9493 Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' + |
|
9494 Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')'; |
|
9495 }; |
|
9496 }); |
|
9497 |
|
9498 // Color Conversion functions from highlightFade |
|
9499 // By Blair Mitchelmore |
|
9500 // http://jquery.offput.ca/highlightFade/ |
|
9501 |
|
9502 // Parse strings looking for color tuples [255,255,255] |
|
9503 function getRGB(color) { |
|
9504 var result; |
|
9505 |
|
9506 // Check if we're already dealing with an array of colors |
|
9507 if ( color && color.constructor == Array && color.length == 3 ) |
|
9508 return color; |
|
9509 |
|
9510 // Look for rgb(num,num,num) |
|
9511 if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) |
|
9512 return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; |
|
9513 |
|
9514 // Look for rgb(num%,num%,num%) |
|
9515 if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) |
|
9516 return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; |
|
9517 |
|
9518 // Look for #a0b1c2 |
|
9519 if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) |
|
9520 return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; |
|
9521 |
|
9522 // Look for #fff |
|
9523 if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) |
|
9524 return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; |
|
9525 |
|
9526 // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 |
|
9527 if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) |
|
9528 return colors['transparent']; |
|
9529 |
|
9530 // Otherwise, we're most likely dealing with a named color |
|
9531 return colors[$.trim(color).toLowerCase()]; |
|
9532 } |
|
9533 |
|
9534 function getColor(elem, attr) { |
|
9535 var color; |
|
9536 |
|
9537 do { |
|
9538 color = $.curCSS(elem, attr); |
|
9539 |
|
9540 // Keep going until we find an element that has color, or we hit the body |
|
9541 if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") ) |
|
9542 break; |
|
9543 |
|
9544 attr = "backgroundColor"; |
|
9545 } while ( elem = elem.parentNode ); |
|
9546 |
|
9547 return getRGB(color); |
|
9548 }; |
|
9549 |
|
9550 // Some named colors to work with |
|
9551 // From Interface by Stefan Petre |
|
9552 // http://interface.eyecon.ro/ |
|
9553 |
|
9554 var colors = { |
|
9555 aqua:[0,255,255], |
|
9556 azure:[240,255,255], |
|
9557 beige:[245,245,220], |
|
9558 black:[0,0,0], |
|
9559 blue:[0,0,255], |
|
9560 brown:[165,42,42], |
|
9561 cyan:[0,255,255], |
|
9562 darkblue:[0,0,139], |
|
9563 darkcyan:[0,139,139], |
|
9564 darkgrey:[169,169,169], |
|
9565 darkgreen:[0,100,0], |
|
9566 darkkhaki:[189,183,107], |
|
9567 darkmagenta:[139,0,139], |
|
9568 darkolivegreen:[85,107,47], |
|
9569 darkorange:[255,140,0], |
|
9570 darkorchid:[153,50,204], |
|
9571 darkred:[139,0,0], |
|
9572 darksalmon:[233,150,122], |
|
9573 darkviolet:[148,0,211], |
|
9574 fuchsia:[255,0,255], |
|
9575 gold:[255,215,0], |
|
9576 green:[0,128,0], |
|
9577 indigo:[75,0,130], |
|
9578 khaki:[240,230,140], |
|
9579 lightblue:[173,216,230], |
|
9580 lightcyan:[224,255,255], |
|
9581 lightgreen:[144,238,144], |
|
9582 lightgrey:[211,211,211], |
|
9583 lightpink:[255,182,193], |
|
9584 lightyellow:[255,255,224], |
|
9585 lime:[0,255,0], |
|
9586 magenta:[255,0,255], |
|
9587 maroon:[128,0,0], |
|
9588 navy:[0,0,128], |
|
9589 olive:[128,128,0], |
|
9590 orange:[255,165,0], |
|
9591 pink:[255,192,203], |
|
9592 purple:[128,0,128], |
|
9593 violet:[128,0,128], |
|
9594 red:[255,0,0], |
|
9595 silver:[192,192,192], |
|
9596 white:[255,255,255], |
|
9597 yellow:[255,255,0], |
|
9598 transparent: [255,255,255] |
|
9599 }; |
|
9600 |
|
9601 |
|
9602 |
|
9603 /******************************************************************************/ |
|
9604 /****************************** CLASS ANIMATIONS ******************************/ |
|
9605 /******************************************************************************/ |
|
9606 |
|
9607 var classAnimationActions = ['add', 'remove', 'toggle'], |
|
9608 shorthandStyles = { |
|
9609 border: 1, |
|
9610 borderBottom: 1, |
|
9611 borderColor: 1, |
|
9612 borderLeft: 1, |
|
9613 borderRight: 1, |
|
9614 borderTop: 1, |
|
9615 borderWidth: 1, |
|
9616 margin: 1, |
|
9617 padding: 1 |
|
9618 }; |
|
9619 |
|
9620 function getElementStyles() { |
|
9621 var style = document.defaultView |
|
9622 ? document.defaultView.getComputedStyle(this, null) |
|
9623 : this.currentStyle, |
|
9624 newStyle = {}, |
|
9625 key, |
|
9626 camelCase; |
|
9627 |
|
9628 // webkit enumerates style porperties |
|
9629 if (style && style.length && style[0] && style[style[0]]) { |
|
9630 var len = style.length; |
|
9631 while (len--) { |
|
9632 key = style[len]; |
|
9633 if (typeof style[key] == 'string') { |
|
9634 camelCase = key.replace(/\-(\w)/g, function(all, letter){ |
|
9635 return letter.toUpperCase(); |
|
9636 }); |
|
9637 newStyle[camelCase] = style[key]; |
|
9638 } |
|
9639 } |
|
9640 } else { |
|
9641 for (key in style) { |
|
9642 if (typeof style[key] === 'string') { |
|
9643 newStyle[key] = style[key]; |
|
9644 } |
|
9645 } |
|
9646 } |
|
9647 |
|
9648 return newStyle; |
|
9649 } |
|
9650 |
|
9651 function filterStyles(styles) { |
|
9652 var name, value; |
|
9653 for (name in styles) { |
|
9654 value = styles[name]; |
|
9655 if ( |
|
9656 // ignore null and undefined values |
|
9657 value == null || |
|
9658 // ignore functions (when does this occur?) |
|
9659 $.isFunction(value) || |
|
9660 // shorthand styles that need to be expanded |
|
9661 name in shorthandStyles || |
|
9662 // ignore scrollbars (break in IE) |
|
9663 (/scrollbar/).test(name) || |
|
9664 |
|
9665 // only colors or values that can be converted to numbers |
|
9666 (!(/color/i).test(name) && isNaN(parseFloat(value))) |
|
9667 ) { |
|
9668 delete styles[name]; |
|
9669 } |
|
9670 } |
|
9671 |
|
9672 return styles; |
|
9673 } |
|
9674 |
|
9675 function styleDifference(oldStyle, newStyle) { |
|
9676 var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459 |
|
9677 name; |
|
9678 |
|
9679 for (name in newStyle) { |
|
9680 if (oldStyle[name] != newStyle[name]) { |
|
9681 diff[name] = newStyle[name]; |
|
9682 } |
|
9683 } |
|
9684 |
|
9685 return diff; |
|
9686 } |
|
9687 |
|
9688 $.effects.animateClass = function(value, duration, easing, callback) { |
|
9689 if ($.isFunction(easing)) { |
|
9690 callback = easing; |
|
9691 easing = null; |
|
9692 } |
|
9693 |
|
9694 return this.each(function() { |
|
9695 |
|
9696 var that = $(this), |
|
9697 originalStyleAttr = that.attr('style') || ' ', |
|
9698 originalStyle = filterStyles(getElementStyles.call(this)), |
|
9699 newStyle, |
|
9700 className = that.attr('className'); |
|
9701 |
|
9702 $.each(classAnimationActions, function(i, action) { |
|
9703 if (value[action]) { |
|
9704 that[action + 'Class'](value[action]); |
|
9705 } |
|
9706 }); |
|
9707 newStyle = filterStyles(getElementStyles.call(this)); |
|
9708 that.attr('className', className); |
|
9709 |
|
9710 that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() { |
|
9711 $.each(classAnimationActions, function(i, action) { |
|
9712 if (value[action]) { that[action + 'Class'](value[action]); } |
|
9713 }); |
|
9714 // work around bug in IE by clearing the cssText before setting it |
|
9715 if (typeof that.attr('style') == 'object') { |
|
9716 that.attr('style').cssText = ''; |
|
9717 that.attr('style').cssText = originalStyleAttr; |
|
9718 } else { |
|
9719 that.attr('style', originalStyleAttr); |
|
9720 } |
|
9721 if (callback) { callback.apply(this, arguments); } |
|
9722 }); |
|
9723 }); |
|
9724 }; |
|
9725 |
|
9726 $.fn.extend({ |
|
9727 _addClass: $.fn.addClass, |
|
9728 addClass: function(classNames, speed, easing, callback) { |
|
9729 return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); |
|
9730 }, |
|
9731 |
|
9732 _removeClass: $.fn.removeClass, |
|
9733 removeClass: function(classNames,speed,easing,callback) { |
|
9734 return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); |
|
9735 }, |
|
9736 |
|
9737 _toggleClass: $.fn.toggleClass, |
|
9738 toggleClass: function(classNames, force, speed, easing, callback) { |
|
9739 if ( typeof force == "boolean" || force === undefined ) { |
|
9740 if ( !speed ) { |
|
9741 // without speed parameter; |
|
9742 return this._toggleClass(classNames, force); |
|
9743 } else { |
|
9744 return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]); |
|
9745 } |
|
9746 } else { |
|
9747 // without switch parameter; |
|
9748 return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]); |
|
9749 } |
|
9750 }, |
|
9751 |
|
9752 switchClass: function(remove,add,speed,easing,callback) { |
|
9753 return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); |
|
9754 } |
|
9755 }); |
|
9756 |
|
9757 |
|
9758 |
|
9759 /******************************************************************************/ |
|
9760 /*********************************** EFFECTS **********************************/ |
|
9761 /******************************************************************************/ |
|
9762 |
|
9763 $.extend($.effects, { |
|
9764 version: "1.8.1", |
|
9765 |
|
9766 // Saves a set of properties in a data storage |
|
9767 save: function(element, set) { |
|
9768 for(var i=0; i < set.length; i++) { |
|
9769 if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); |
|
9770 } |
|
9771 }, |
|
9772 |
|
9773 // Restores a set of previously saved properties from a data storage |
|
9774 restore: function(element, set) { |
|
9775 for(var i=0; i < set.length; i++) { |
|
9776 if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); |
|
9777 } |
|
9778 }, |
|
9779 |
|
9780 setMode: function(el, mode) { |
|
9781 if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle |
|
9782 return mode; |
|
9783 }, |
|
9784 |
|
9785 getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value |
|
9786 // this should be a little more flexible in the future to handle a string & hash |
|
9787 var y, x; |
|
9788 switch (origin[0]) { |
|
9789 case 'top': y = 0; break; |
|
9790 case 'middle': y = 0.5; break; |
|
9791 case 'bottom': y = 1; break; |
|
9792 default: y = origin[0] / original.height; |
|
9793 }; |
|
9794 switch (origin[1]) { |
|
9795 case 'left': x = 0; break; |
|
9796 case 'center': x = 0.5; break; |
|
9797 case 'right': x = 1; break; |
|
9798 default: x = origin[1] / original.width; |
|
9799 }; |
|
9800 return {x: x, y: y}; |
|
9801 }, |
|
9802 |
|
9803 // Wraps the element around a wrapper that copies position properties |
|
9804 createWrapper: function(element) { |
|
9805 |
|
9806 // if the element is already wrapped, return it |
|
9807 if (element.parent().is('.ui-effects-wrapper')) { |
|
9808 return element.parent(); |
|
9809 } |
|
9810 |
|
9811 // wrap the element |
|
9812 var props = { |
|
9813 width: element.outerWidth(true), |
|
9814 height: element.outerHeight(true), |
|
9815 'float': element.css('float') |
|
9816 }, |
|
9817 wrapper = $('<div></div>') |
|
9818 .addClass('ui-effects-wrapper') |
|
9819 .css({ |
|
9820 fontSize: '100%', |
|
9821 background: 'transparent', |
|
9822 border: 'none', |
|
9823 margin: 0, |
|
9824 padding: 0 |
|
9825 }); |
|
9826 |
|
9827 element.wrap(wrapper); |
|
9828 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element |
|
9829 |
|
9830 // transfer positioning properties to the wrapper |
|
9831 if (element.css('position') == 'static') { |
|
9832 wrapper.css({ position: 'relative' }); |
|
9833 element.css({ position: 'relative' }); |
|
9834 } else { |
|
9835 $.extend(props, { |
|
9836 position: element.css('position'), |
|
9837 zIndex: element.css('z-index') |
|
9838 }); |
|
9839 $.each(['top', 'left', 'bottom', 'right'], function(i, pos) { |
|
9840 props[pos] = element.css(pos); |
|
9841 if (isNaN(parseInt(props[pos], 10))) { |
|
9842 props[pos] = 'auto'; |
|
9843 } |
|
9844 }); |
|
9845 element.css({position: 'relative', top: 0, left: 0 }); |
|
9846 } |
|
9847 |
|
9848 return wrapper.css(props).show(); |
|
9849 }, |
|
9850 |
|
9851 removeWrapper: function(element) { |
|
9852 if (element.parent().is('.ui-effects-wrapper')) |
|
9853 return element.parent().replaceWith(element); |
|
9854 return element; |
|
9855 }, |
|
9856 |
|
9857 setTransition: function(element, list, factor, value) { |
|
9858 value = value || {}; |
|
9859 $.each(list, function(i, x){ |
|
9860 unit = element.cssUnit(x); |
|
9861 if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; |
|
9862 }); |
|
9863 return value; |
|
9864 } |
|
9865 }); |
|
9866 |
|
9867 |
|
9868 function _normalizeArguments(effect, options, speed, callback) { |
|
9869 // shift params for method overloading |
|
9870 if (typeof effect == 'object') { |
|
9871 callback = options; |
|
9872 speed = null; |
|
9873 options = effect; |
|
9874 effect = options.effect; |
|
9875 } |
|
9876 if ($.isFunction(options)) { |
|
9877 callback = options; |
|
9878 speed = null; |
|
9879 options = {}; |
|
9880 } |
|
9881 if ($.isFunction(speed)) { |
|
9882 callback = speed; |
|
9883 speed = null; |
|
9884 } |
|
9885 if (typeof options == 'number' || $.fx.speeds[options]) { |
|
9886 callback = speed; |
|
9887 speed = options; |
|
9888 options = {}; |
|
9889 } |
|
9890 |
|
9891 options = options || {}; |
|
9892 |
|
9893 speed = speed || options.duration; |
|
9894 speed = $.fx.off ? 0 : typeof speed == 'number' |
|
9895 ? speed : $.fx.speeds[speed] || $.fx.speeds._default; |
|
9896 |
|
9897 callback = callback || options.complete; |
|
9898 |
|
9899 return [effect, options, speed, callback]; |
|
9900 } |
|
9901 |
|
9902 $.fn.extend({ |
|
9903 effect: function(effect, options, speed, callback) { |
|
9904 var args = _normalizeArguments.apply(this, arguments), |
|
9905 // TODO: make effects takes actual parameters instead of a hash |
|
9906 args2 = { |
|
9907 options: args[1], |
|
9908 duration: args[2], |
|
9909 callback: args[3] |
|
9910 }, |
|
9911 effectMethod = $.effects[effect]; |
|
9912 |
|
9913 return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this; |
|
9914 }, |
|
9915 |
|
9916 _show: $.fn.show, |
|
9917 show: function(speed) { |
|
9918 if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) { |
|
9919 return this._show.apply(this, arguments); |
|
9920 } else { |
|
9921 var args = _normalizeArguments.apply(this, arguments); |
|
9922 args[1].mode = 'show'; |
|
9923 return this.effect.apply(this, args); |
|
9924 } |
|
9925 }, |
|
9926 |
|
9927 _hide: $.fn.hide, |
|
9928 hide: function(speed) { |
|
9929 if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) { |
|
9930 return this._hide.apply(this, arguments); |
|
9931 } else { |
|
9932 var args = _normalizeArguments.apply(this, arguments); |
|
9933 args[1].mode = 'hide'; |
|
9934 return this.effect.apply(this, args); |
|
9935 } |
|
9936 }, |
|
9937 |
|
9938 // jQuery core overloads toggle and create _toggle |
|
9939 __toggle: $.fn.toggle, |
|
9940 toggle: function(speed) { |
|
9941 if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || |
|
9942 typeof speed == 'boolean' || $.isFunction(speed)) { |
|
9943 return this.__toggle.apply(this, arguments); |
|
9944 } else { |
|
9945 var args = _normalizeArguments.apply(this, arguments); |
|
9946 args[1].mode = 'toggle'; |
|
9947 return this.effect.apply(this, args); |
|
9948 } |
|
9949 }, |
|
9950 |
|
9951 // helper functions |
|
9952 cssUnit: function(key) { |
|
9953 var style = this.css(key), val = []; |
|
9954 $.each( ['em','px','%','pt'], function(i, unit){ |
|
9955 if(style.indexOf(unit) > 0) |
|
9956 val = [parseFloat(style), unit]; |
|
9957 }); |
|
9958 return val; |
|
9959 } |
|
9960 }); |
|
9961 |
|
9962 |
|
9963 |
|
9964 /******************************************************************************/ |
|
9965 /*********************************** EASING ***********************************/ |
|
9966 /******************************************************************************/ |
|
9967 |
|
9968 /* |
|
9969 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ |
|
9970 * |
|
9971 * Uses the built in easing capabilities added In jQuery 1.1 |
|
9972 * to offer multiple easing options |
|
9973 * |
|
9974 * TERMS OF USE - jQuery Easing |
|
9975 * |
|
9976 * Open source under the BSD License. |
|
9977 * |
|
9978 * Copyright 2008 George McGinley Smith |
|
9979 * All rights reserved. |
|
9980 * |
|
9981 * Redistribution and use in source and binary forms, with or without modification, |
|
9982 * are permitted provided that the following conditions are met: |
|
9983 * |
|
9984 * Redistributions of source code must retain the above copyright notice, this list of |
|
9985 * conditions and the following disclaimer. |
|
9986 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
9987 * of conditions and the following disclaimer in the documentation and/or other materials |
|
9988 * provided with the distribution. |
|
9989 * |
|
9990 * Neither the name of the author nor the names of contributors may be used to endorse |
|
9991 * or promote products derived from this software without specific prior written permission. |
|
9992 * |
|
9993 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
9994 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
9995 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
9996 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
9997 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
9998 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
9999 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
10000 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
10001 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
10002 * |
|
10003 */ |
|
10004 |
|
10005 // t: current time, b: begInnIng value, c: change In value, d: duration |
|
10006 $.easing.jswing = $.easing.swing; |
|
10007 |
|
10008 $.extend($.easing, |
|
10009 { |
|
10010 def: 'easeOutQuad', |
|
10011 swing: function (x, t, b, c, d) { |
|
10012 //alert($.easing.default); |
|
10013 return $.easing[$.easing.def](x, t, b, c, d); |
|
10014 }, |
|
10015 easeInQuad: function (x, t, b, c, d) { |
|
10016 return c*(t/=d)*t + b; |
|
10017 }, |
|
10018 easeOutQuad: function (x, t, b, c, d) { |
|
10019 return -c *(t/=d)*(t-2) + b; |
|
10020 }, |
|
10021 easeInOutQuad: function (x, t, b, c, d) { |
|
10022 if ((t/=d/2) < 1) return c/2*t*t + b; |
|
10023 return -c/2 * ((--t)*(t-2) - 1) + b; |
|
10024 }, |
|
10025 easeInCubic: function (x, t, b, c, d) { |
|
10026 return c*(t/=d)*t*t + b; |
|
10027 }, |
|
10028 easeOutCubic: function (x, t, b, c, d) { |
|
10029 return c*((t=t/d-1)*t*t + 1) + b; |
|
10030 }, |
|
10031 easeInOutCubic: function (x, t, b, c, d) { |
|
10032 if ((t/=d/2) < 1) return c/2*t*t*t + b; |
|
10033 return c/2*((t-=2)*t*t + 2) + b; |
|
10034 }, |
|
10035 easeInQuart: function (x, t, b, c, d) { |
|
10036 return c*(t/=d)*t*t*t + b; |
|
10037 }, |
|
10038 easeOutQuart: function (x, t, b, c, d) { |
|
10039 return -c * ((t=t/d-1)*t*t*t - 1) + b; |
|
10040 }, |
|
10041 easeInOutQuart: function (x, t, b, c, d) { |
|
10042 if ((t/=d/2) < 1) return c/2*t*t*t*t + b; |
|
10043 return -c/2 * ((t-=2)*t*t*t - 2) + b; |
|
10044 }, |
|
10045 easeInQuint: function (x, t, b, c, d) { |
|
10046 return c*(t/=d)*t*t*t*t + b; |
|
10047 }, |
|
10048 easeOutQuint: function (x, t, b, c, d) { |
|
10049 return c*((t=t/d-1)*t*t*t*t + 1) + b; |
|
10050 }, |
|
10051 easeInOutQuint: function (x, t, b, c, d) { |
|
10052 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; |
|
10053 return c/2*((t-=2)*t*t*t*t + 2) + b; |
|
10054 }, |
|
10055 easeInSine: function (x, t, b, c, d) { |
|
10056 return -c * Math.cos(t/d * (Math.PI/2)) + c + b; |
|
10057 }, |
|
10058 easeOutSine: function (x, t, b, c, d) { |
|
10059 return c * Math.sin(t/d * (Math.PI/2)) + b; |
|
10060 }, |
|
10061 easeInOutSine: function (x, t, b, c, d) { |
|
10062 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; |
|
10063 }, |
|
10064 easeInExpo: function (x, t, b, c, d) { |
|
10065 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; |
|
10066 }, |
|
10067 easeOutExpo: function (x, t, b, c, d) { |
|
10068 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; |
|
10069 }, |
|
10070 easeInOutExpo: function (x, t, b, c, d) { |
|
10071 if (t==0) return b; |
|
10072 if (t==d) return b+c; |
|
10073 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; |
|
10074 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; |
|
10075 }, |
|
10076 easeInCirc: function (x, t, b, c, d) { |
|
10077 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; |
|
10078 }, |
|
10079 easeOutCirc: function (x, t, b, c, d) { |
|
10080 return c * Math.sqrt(1 - (t=t/d-1)*t) + b; |
|
10081 }, |
|
10082 easeInOutCirc: function (x, t, b, c, d) { |
|
10083 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; |
|
10084 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; |
|
10085 }, |
|
10086 easeInElastic: function (x, t, b, c, d) { |
|
10087 var s=1.70158;var p=0;var a=c; |
|
10088 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
10089 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
10090 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
10091 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
10092 }, |
|
10093 easeOutElastic: function (x, t, b, c, d) { |
|
10094 var s=1.70158;var p=0;var a=c; |
|
10095 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
10096 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
10097 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
10098 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; |
|
10099 }, |
|
10100 easeInOutElastic: function (x, t, b, c, d) { |
|
10101 var s=1.70158;var p=0;var a=c; |
|
10102 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); |
|
10103 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
10104 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
10105 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
10106 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; |
|
10107 }, |
|
10108 easeInBack: function (x, t, b, c, d, s) { |
|
10109 if (s == undefined) s = 1.70158; |
|
10110 return c*(t/=d)*t*((s+1)*t - s) + b; |
|
10111 }, |
|
10112 easeOutBack: function (x, t, b, c, d, s) { |
|
10113 if (s == undefined) s = 1.70158; |
|
10114 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; |
|
10115 }, |
|
10116 easeInOutBack: function (x, t, b, c, d, s) { |
|
10117 if (s == undefined) s = 1.70158; |
|
10118 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; |
|
10119 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; |
|
10120 }, |
|
10121 easeInBounce: function (x, t, b, c, d) { |
|
10122 return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; |
|
10123 }, |
|
10124 easeOutBounce: function (x, t, b, c, d) { |
|
10125 if ((t/=d) < (1/2.75)) { |
|
10126 return c*(7.5625*t*t) + b; |
|
10127 } else if (t < (2/2.75)) { |
|
10128 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; |
|
10129 } else if (t < (2.5/2.75)) { |
|
10130 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; |
|
10131 } else { |
|
10132 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; |
|
10133 } |
|
10134 }, |
|
10135 easeInOutBounce: function (x, t, b, c, d) { |
|
10136 if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; |
|
10137 return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; |
|
10138 } |
|
10139 }); |
|
10140 |
|
10141 /* |
|
10142 * |
|
10143 * TERMS OF USE - EASING EQUATIONS |
|
10144 * |
|
10145 * Open source under the BSD License. |
|
10146 * |
|
10147 * Copyright 2001 Robert Penner |
|
10148 * All rights reserved. |
|
10149 * |
|
10150 * Redistribution and use in source and binary forms, with or without modification, |
|
10151 * are permitted provided that the following conditions are met: |
|
10152 * |
|
10153 * Redistributions of source code must retain the above copyright notice, this list of |
|
10154 * conditions and the following disclaimer. |
|
10155 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
10156 * of conditions and the following disclaimer in the documentation and/or other materials |
|
10157 * provided with the distribution. |
|
10158 * |
|
10159 * Neither the name of the author nor the names of contributors may be used to endorse |
|
10160 * or promote products derived from this software without specific prior written permission. |
|
10161 * |
|
10162 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
10163 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
10164 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
10165 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
10166 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
10167 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
10168 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
10169 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
10170 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
10171 * |
|
10172 */ |
|
10173 |
|
10174 })(jQuery); |
|
10175 /* |
|
10176 * jQuery UI Effects Blind 1.8.1 |
|
10177 * |
|
10178 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10179 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10180 * and GPL (GPL-LICENSE.txt) licenses. |
|
10181 * |
|
10182 * http://docs.jquery.com/UI/Effects/Blind |
|
10183 * |
|
10184 * Depends: |
|
10185 * jquery.effects.core.js |
|
10186 */ |
|
10187 (function($) { |
|
10188 |
|
10189 $.effects.blind = function(o) { |
|
10190 |
|
10191 return this.queue(function() { |
|
10192 |
|
10193 // Create element |
|
10194 var el = $(this), props = ['position','top','left']; |
|
10195 |
|
10196 // Set options |
|
10197 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
10198 var direction = o.options.direction || 'vertical'; // Default direction |
|
10199 |
|
10200 // Adjust |
|
10201 $.effects.save(el, props); el.show(); // Save & Show |
|
10202 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
10203 var ref = (direction == 'vertical') ? 'height' : 'width'; |
|
10204 var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); |
|
10205 if(mode == 'show') wrapper.css(ref, 0); // Shift |
|
10206 |
|
10207 // Animation |
|
10208 var animation = {}; |
|
10209 animation[ref] = mode == 'show' ? distance : 0; |
|
10210 |
|
10211 // Animate |
|
10212 wrapper.animate(animation, o.duration, o.options.easing, function() { |
|
10213 if(mode == 'hide') el.hide(); // Hide |
|
10214 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10215 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
10216 el.dequeue(); |
|
10217 }); |
|
10218 |
|
10219 }); |
|
10220 |
|
10221 }; |
|
10222 |
|
10223 })(jQuery); |
|
10224 /* |
|
10225 * jQuery UI Effects Bounce 1.8.1 |
|
10226 * |
|
10227 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10228 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10229 * and GPL (GPL-LICENSE.txt) licenses. |
|
10230 * |
|
10231 * http://docs.jquery.com/UI/Effects/Bounce |
|
10232 * |
|
10233 * Depends: |
|
10234 * jquery.effects.core.js |
|
10235 */ |
|
10236 (function($) { |
|
10237 |
|
10238 $.effects.bounce = function(o) { |
|
10239 |
|
10240 return this.queue(function() { |
|
10241 |
|
10242 // Create element |
|
10243 var el = $(this), props = ['position','top','left']; |
|
10244 |
|
10245 // Set options |
|
10246 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
10247 var direction = o.options.direction || 'up'; // Default direction |
|
10248 var distance = o.options.distance || 20; // Default distance |
|
10249 var times = o.options.times || 5; // Default # of times |
|
10250 var speed = o.duration || 250; // Default speed per bounce |
|
10251 if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE |
|
10252 |
|
10253 // Adjust |
|
10254 $.effects.save(el, props); el.show(); // Save & Show |
|
10255 $.effects.createWrapper(el); // Create Wrapper |
|
10256 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
10257 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
10258 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3); |
|
10259 if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
10260 if (mode == 'hide') distance = distance / (times * 2); |
|
10261 if (mode != 'hide') times--; |
|
10262 |
|
10263 // Animate |
|
10264 if (mode == 'show') { // Show Bounce |
|
10265 var animation = {opacity: 1}; |
|
10266 animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
10267 el.animate(animation, speed / 2, o.options.easing); |
|
10268 distance = distance / 2; |
|
10269 times--; |
|
10270 }; |
|
10271 for (var i = 0; i < times; i++) { // Bounces |
|
10272 var animation1 = {}, animation2 = {}; |
|
10273 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
10274 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
10275 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing); |
|
10276 distance = (mode == 'hide') ? distance * 2 : distance / 2; |
|
10277 }; |
|
10278 if (mode == 'hide') { // Last Bounce |
|
10279 var animation = {opacity: 0}; |
|
10280 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
10281 el.animate(animation, speed / 2, o.options.easing, function(){ |
|
10282 el.hide(); // Hide |
|
10283 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10284 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10285 }); |
|
10286 } else { |
|
10287 var animation1 = {}, animation2 = {}; |
|
10288 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
10289 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
10290 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){ |
|
10291 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10292 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10293 }); |
|
10294 }; |
|
10295 el.queue('fx', function() { el.dequeue(); }); |
|
10296 el.dequeue(); |
|
10297 }); |
|
10298 |
|
10299 }; |
|
10300 |
|
10301 })(jQuery); |
|
10302 /* |
|
10303 * jQuery UI Effects Clip 1.8.1 |
|
10304 * |
|
10305 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10306 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10307 * and GPL (GPL-LICENSE.txt) licenses. |
|
10308 * |
|
10309 * http://docs.jquery.com/UI/Effects/Clip |
|
10310 * |
|
10311 * Depends: |
|
10312 * jquery.effects.core.js |
|
10313 */ |
|
10314 (function($) { |
|
10315 |
|
10316 $.effects.clip = function(o) { |
|
10317 |
|
10318 return this.queue(function() { |
|
10319 |
|
10320 // Create element |
|
10321 var el = $(this), props = ['position','top','left','height','width']; |
|
10322 |
|
10323 // Set options |
|
10324 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
10325 var direction = o.options.direction || 'vertical'; // Default direction |
|
10326 |
|
10327 // Adjust |
|
10328 $.effects.save(el, props); el.show(); // Save & Show |
|
10329 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
10330 var animate = el[0].tagName == 'IMG' ? wrapper : el; |
|
10331 var ref = { |
|
10332 size: (direction == 'vertical') ? 'height' : 'width', |
|
10333 position: (direction == 'vertical') ? 'top' : 'left' |
|
10334 }; |
|
10335 var distance = (direction == 'vertical') ? animate.height() : animate.width(); |
|
10336 if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift |
|
10337 |
|
10338 // Animation |
|
10339 var animation = {}; |
|
10340 animation[ref.size] = mode == 'show' ? distance : 0; |
|
10341 animation[ref.position] = mode == 'show' ? 0 : distance / 2; |
|
10342 |
|
10343 // Animate |
|
10344 animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
10345 if(mode == 'hide') el.hide(); // Hide |
|
10346 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10347 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
10348 el.dequeue(); |
|
10349 }}); |
|
10350 |
|
10351 }); |
|
10352 |
|
10353 }; |
|
10354 |
|
10355 })(jQuery); |
|
10356 /* |
|
10357 * jQuery UI Effects Drop 1.8.1 |
|
10358 * |
|
10359 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10360 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10361 * and GPL (GPL-LICENSE.txt) licenses. |
|
10362 * |
|
10363 * http://docs.jquery.com/UI/Effects/Drop |
|
10364 * |
|
10365 * Depends: |
|
10366 * jquery.effects.core.js |
|
10367 */ |
|
10368 (function($) { |
|
10369 |
|
10370 $.effects.drop = function(o) { |
|
10371 |
|
10372 return this.queue(function() { |
|
10373 |
|
10374 // Create element |
|
10375 var el = $(this), props = ['position','top','left','opacity']; |
|
10376 |
|
10377 // Set options |
|
10378 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
10379 var direction = o.options.direction || 'left'; // Default Direction |
|
10380 |
|
10381 // Adjust |
|
10382 $.effects.save(el, props); el.show(); // Save & Show |
|
10383 $.effects.createWrapper(el); // Create Wrapper |
|
10384 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
10385 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
10386 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2); |
|
10387 if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
10388 |
|
10389 // Animation |
|
10390 var animation = {opacity: mode == 'show' ? 1 : 0}; |
|
10391 animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; |
|
10392 |
|
10393 // Animate |
|
10394 el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
10395 if(mode == 'hide') el.hide(); // Hide |
|
10396 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10397 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10398 el.dequeue(); |
|
10399 }}); |
|
10400 |
|
10401 }); |
|
10402 |
|
10403 }; |
|
10404 |
|
10405 })(jQuery); |
|
10406 /* |
|
10407 * jQuery UI Effects Explode 1.8.1 |
|
10408 * |
|
10409 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10410 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10411 * and GPL (GPL-LICENSE.txt) licenses. |
|
10412 * |
|
10413 * http://docs.jquery.com/UI/Effects/Explode |
|
10414 * |
|
10415 * Depends: |
|
10416 * jquery.effects.core.js |
|
10417 */ |
|
10418 (function($) { |
|
10419 |
|
10420 $.effects.explode = function(o) { |
|
10421 |
|
10422 return this.queue(function() { |
|
10423 |
|
10424 var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; |
|
10425 var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; |
|
10426 |
|
10427 o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode; |
|
10428 var el = $(this).show().css('visibility', 'hidden'); |
|
10429 var offset = el.offset(); |
|
10430 |
|
10431 //Substract the margins - not fixing the problem yet. |
|
10432 offset.top -= parseInt(el.css("marginTop"),10) || 0; |
|
10433 offset.left -= parseInt(el.css("marginLeft"),10) || 0; |
|
10434 |
|
10435 var width = el.outerWidth(true); |
|
10436 var height = el.outerHeight(true); |
|
10437 |
|
10438 for(var i=0;i<rows;i++) { // = |
|
10439 for(var j=0;j<cells;j++) { // || |
|
10440 el |
|
10441 .clone() |
|
10442 .appendTo('body') |
|
10443 .wrap('<div></div>') |
|
10444 .css({ |
|
10445 position: 'absolute', |
|
10446 visibility: 'visible', |
|
10447 left: -j*(width/cells), |
|
10448 top: -i*(height/rows) |
|
10449 }) |
|
10450 .parent() |
|
10451 .addClass('ui-effects-explode') |
|
10452 .css({ |
|
10453 position: 'absolute', |
|
10454 overflow: 'hidden', |
|
10455 width: width/cells, |
|
10456 height: height/rows, |
|
10457 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0), |
|
10458 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0), |
|
10459 opacity: o.options.mode == 'show' ? 0 : 1 |
|
10460 }).animate({ |
|
10461 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)), |
|
10462 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)), |
|
10463 opacity: o.options.mode == 'show' ? 1 : 0 |
|
10464 }, o.duration || 500); |
|
10465 } |
|
10466 } |
|
10467 |
|
10468 // Set a timeout, to call the callback approx. when the other animations have finished |
|
10469 setTimeout(function() { |
|
10470 |
|
10471 o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide(); |
|
10472 if(o.callback) o.callback.apply(el[0]); // Callback |
|
10473 el.dequeue(); |
|
10474 |
|
10475 $('div.ui-effects-explode').remove(); |
|
10476 |
|
10477 }, o.duration || 500); |
|
10478 |
|
10479 |
|
10480 }); |
|
10481 |
|
10482 }; |
|
10483 |
|
10484 })(jQuery); |
|
10485 /* |
|
10486 * jQuery UI Effects Fold 1.8.1 |
|
10487 * |
|
10488 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10489 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10490 * and GPL (GPL-LICENSE.txt) licenses. |
|
10491 * |
|
10492 * http://docs.jquery.com/UI/Effects/Fold |
|
10493 * |
|
10494 * Depends: |
|
10495 * jquery.effects.core.js |
|
10496 */ |
|
10497 (function($) { |
|
10498 |
|
10499 $.effects.fold = function(o) { |
|
10500 |
|
10501 return this.queue(function() { |
|
10502 |
|
10503 // Create element |
|
10504 var el = $(this), props = ['position','top','left']; |
|
10505 |
|
10506 // Set options |
|
10507 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
10508 var size = o.options.size || 15; // Default fold size |
|
10509 var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value |
|
10510 var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2; |
|
10511 |
|
10512 // Adjust |
|
10513 $.effects.save(el, props); el.show(); // Save & Show |
|
10514 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
10515 var widthFirst = ((mode == 'show') != horizFirst); |
|
10516 var ref = widthFirst ? ['width', 'height'] : ['height', 'width']; |
|
10517 var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; |
|
10518 var percent = /([0-9]+)%/.exec(size); |
|
10519 if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1]; |
|
10520 if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift |
|
10521 |
|
10522 // Animation |
|
10523 var animation1 = {}, animation2 = {}; |
|
10524 animation1[ref[0]] = mode == 'show' ? distance[0] : size; |
|
10525 animation2[ref[1]] = mode == 'show' ? distance[1] : 0; |
|
10526 |
|
10527 // Animate |
|
10528 wrapper.animate(animation1, duration, o.options.easing) |
|
10529 .animate(animation2, duration, o.options.easing, function() { |
|
10530 if(mode == 'hide') el.hide(); // Hide |
|
10531 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10532 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
10533 el.dequeue(); |
|
10534 }); |
|
10535 |
|
10536 }); |
|
10537 |
|
10538 }; |
|
10539 |
|
10540 })(jQuery); |
|
10541 /* |
|
10542 * jQuery UI Effects Highlight 1.8.1 |
|
10543 * |
|
10544 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10545 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10546 * and GPL (GPL-LICENSE.txt) licenses. |
|
10547 * |
|
10548 * http://docs.jquery.com/UI/Effects/Highlight |
|
10549 * |
|
10550 * Depends: |
|
10551 * jquery.effects.core.js |
|
10552 */ |
|
10553 (function($) { |
|
10554 |
|
10555 $.effects.highlight = function(o) { |
|
10556 return this.queue(function() { |
|
10557 var elem = $(this), |
|
10558 props = ['backgroundImage', 'backgroundColor', 'opacity'], |
|
10559 mode = $.effects.setMode(elem, o.options.mode || 'show'), |
|
10560 animation = { |
|
10561 backgroundColor: elem.css('backgroundColor') |
|
10562 }; |
|
10563 |
|
10564 if (mode == 'hide') { |
|
10565 animation.opacity = 0; |
|
10566 } |
|
10567 |
|
10568 $.effects.save(elem, props); |
|
10569 elem |
|
10570 .show() |
|
10571 .css({ |
|
10572 backgroundImage: 'none', |
|
10573 backgroundColor: o.options.color || '#ffff99' |
|
10574 }) |
|
10575 .animate(animation, { |
|
10576 queue: false, |
|
10577 duration: o.duration, |
|
10578 easing: o.options.easing, |
|
10579 complete: function() { |
|
10580 (mode == 'hide' && elem.hide()); |
|
10581 $.effects.restore(elem, props); |
|
10582 (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter')); |
|
10583 (o.callback && o.callback.apply(this, arguments)); |
|
10584 elem.dequeue(); |
|
10585 } |
|
10586 }); |
|
10587 }); |
|
10588 }; |
|
10589 |
|
10590 })(jQuery); |
|
10591 /* |
|
10592 * jQuery UI Effects Pulsate 1.8.1 |
|
10593 * |
|
10594 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10595 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10596 * and GPL (GPL-LICENSE.txt) licenses. |
|
10597 * |
|
10598 * http://docs.jquery.com/UI/Effects/Pulsate |
|
10599 * |
|
10600 * Depends: |
|
10601 * jquery.effects.core.js |
|
10602 */ |
|
10603 (function($) { |
|
10604 |
|
10605 $.effects.pulsate = function(o) { |
|
10606 return this.queue(function() { |
|
10607 var elem = $(this), |
|
10608 mode = $.effects.setMode(elem, o.options.mode || 'show'); |
|
10609 times = ((o.options.times || 5) * 2) - 1; |
|
10610 duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2, |
|
10611 isVisible = elem.is(':visible'), |
|
10612 animateTo = 0; |
|
10613 |
|
10614 if (!isVisible) { |
|
10615 elem.css('opacity', 0).show(); |
|
10616 animateTo = 1; |
|
10617 } |
|
10618 |
|
10619 if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) { |
|
10620 times--; |
|
10621 } |
|
10622 |
|
10623 for (var i = 0; i < times; i++) { |
|
10624 elem.animate({ opacity: animateTo }, duration, o.options.easing); |
|
10625 animateTo = (animateTo + 1) % 2; |
|
10626 } |
|
10627 |
|
10628 elem.animate({ opacity: animateTo }, duration, o.options.easing, function() { |
|
10629 if (animateTo == 0) { |
|
10630 elem.hide(); |
|
10631 } |
|
10632 (o.callback && o.callback.apply(this, arguments)); |
|
10633 }); |
|
10634 |
|
10635 elem |
|
10636 .queue('fx', function() { elem.dequeue(); }) |
|
10637 .dequeue(); |
|
10638 }); |
|
10639 }; |
|
10640 |
|
10641 })(jQuery); |
|
10642 /* |
|
10643 * jQuery UI Effects Scale 1.8.1 |
|
10644 * |
|
10645 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10646 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10647 * and GPL (GPL-LICENSE.txt) licenses. |
|
10648 * |
|
10649 * http://docs.jquery.com/UI/Effects/Scale |
|
10650 * |
|
10651 * Depends: |
|
10652 * jquery.effects.core.js |
|
10653 */ |
|
10654 (function($) { |
|
10655 |
|
10656 $.effects.puff = function(o) { |
|
10657 return this.queue(function() { |
|
10658 var elem = $(this), |
|
10659 mode = $.effects.setMode(elem, o.options.mode || 'hide'), |
|
10660 percent = parseInt(o.options.percent, 10) || 150, |
|
10661 factor = percent / 100, |
|
10662 original = { height: elem.height(), width: elem.width() }; |
|
10663 |
|
10664 $.extend(o.options, { |
|
10665 fade: true, |
|
10666 mode: mode, |
|
10667 percent: mode == 'hide' ? percent : 100, |
|
10668 from: mode == 'hide' |
|
10669 ? original |
|
10670 : { |
|
10671 height: original.height * factor, |
|
10672 width: original.width * factor |
|
10673 } |
|
10674 }); |
|
10675 |
|
10676 elem.effect('scale', o.options, o.duration, o.callback); |
|
10677 elem.dequeue(); |
|
10678 }); |
|
10679 }; |
|
10680 |
|
10681 $.effects.scale = function(o) { |
|
10682 |
|
10683 return this.queue(function() { |
|
10684 |
|
10685 // Create element |
|
10686 var el = $(this); |
|
10687 |
|
10688 // Set options |
|
10689 var options = $.extend(true, {}, o.options); |
|
10690 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
10691 var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent |
|
10692 var direction = o.options.direction || 'both'; // Set default axis |
|
10693 var origin = o.options.origin; // The origin of the scaling |
|
10694 if (mode != 'effect') { // Set default origin and restore for show/hide |
|
10695 options.origin = origin || ['middle','center']; |
|
10696 options.restore = true; |
|
10697 } |
|
10698 var original = {height: el.height(), width: el.width()}; // Save original |
|
10699 el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state |
|
10700 |
|
10701 // Adjust |
|
10702 var factor = { // Set scaling factor |
|
10703 y: direction != 'horizontal' ? (percent / 100) : 1, |
|
10704 x: direction != 'vertical' ? (percent / 100) : 1 |
|
10705 }; |
|
10706 el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state |
|
10707 |
|
10708 if (o.options.fade) { // Fade option to support puff |
|
10709 if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; |
|
10710 if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; |
|
10711 }; |
|
10712 |
|
10713 // Animation |
|
10714 options.from = el.from; options.to = el.to; options.mode = mode; |
|
10715 |
|
10716 // Animate |
|
10717 el.effect('size', options, o.duration, o.callback); |
|
10718 el.dequeue(); |
|
10719 }); |
|
10720 |
|
10721 }; |
|
10722 |
|
10723 $.effects.size = function(o) { |
|
10724 |
|
10725 return this.queue(function() { |
|
10726 |
|
10727 // Create element |
|
10728 var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; |
|
10729 var props1 = ['position','top','left','overflow','opacity']; // Always restore |
|
10730 var props2 = ['width','height','overflow']; // Copy for children |
|
10731 var cProps = ['fontSize']; |
|
10732 var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; |
|
10733 var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; |
|
10734 |
|
10735 // Set options |
|
10736 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
10737 var restore = o.options.restore || false; // Default restore |
|
10738 var scale = o.options.scale || 'both'; // Default scale mode |
|
10739 var origin = o.options.origin; // The origin of the sizing |
|
10740 var original = {height: el.height(), width: el.width()}; // Save original |
|
10741 el.from = o.options.from || original; // Default from state |
|
10742 el.to = o.options.to || original; // Default to state |
|
10743 // Adjust |
|
10744 if (origin) { // Calculate baseline shifts |
|
10745 var baseline = $.effects.getBaseline(origin, original); |
|
10746 el.from.top = (original.height - el.from.height) * baseline.y; |
|
10747 el.from.left = (original.width - el.from.width) * baseline.x; |
|
10748 el.to.top = (original.height - el.to.height) * baseline.y; |
|
10749 el.to.left = (original.width - el.to.width) * baseline.x; |
|
10750 }; |
|
10751 var factor = { // Set scaling factor |
|
10752 from: {y: el.from.height / original.height, x: el.from.width / original.width}, |
|
10753 to: {y: el.to.height / original.height, x: el.to.width / original.width} |
|
10754 }; |
|
10755 if (scale == 'box' || scale == 'both') { // Scale the css box |
|
10756 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
10757 props = props.concat(vProps); |
|
10758 el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from); |
|
10759 el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to); |
|
10760 }; |
|
10761 if (factor.from.x != factor.to.x) { // Horizontal props scaling |
|
10762 props = props.concat(hProps); |
|
10763 el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from); |
|
10764 el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to); |
|
10765 }; |
|
10766 }; |
|
10767 if (scale == 'content' || scale == 'both') { // Scale the content |
|
10768 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
10769 props = props.concat(cProps); |
|
10770 el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from); |
|
10771 el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to); |
|
10772 }; |
|
10773 }; |
|
10774 $.effects.save(el, restore ? props : props1); el.show(); // Save & Show |
|
10775 $.effects.createWrapper(el); // Create Wrapper |
|
10776 el.css('overflow','hidden').css(el.from); // Shift |
|
10777 |
|
10778 // Animate |
|
10779 if (scale == 'content' || scale == 'both') { // Scale the children |
|
10780 vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size |
|
10781 hProps = hProps.concat(['marginLeft','marginRight']); // Add margins |
|
10782 props2 = props.concat(vProps).concat(hProps); // Concat |
|
10783 el.find("*[width]").each(function(){ |
|
10784 child = $(this); |
|
10785 if (restore) $.effects.save(child, props2); |
|
10786 var c_original = {height: child.height(), width: child.width()}; // Save original |
|
10787 child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x}; |
|
10788 child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x}; |
|
10789 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
10790 child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from); |
|
10791 child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to); |
|
10792 }; |
|
10793 if (factor.from.x != factor.to.x) { // Horizontal props scaling |
|
10794 child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from); |
|
10795 child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to); |
|
10796 }; |
|
10797 child.css(child.from); // Shift children |
|
10798 child.animate(child.to, o.duration, o.options.easing, function(){ |
|
10799 if (restore) $.effects.restore(child, props2); // Restore children |
|
10800 }); // Animate children |
|
10801 }); |
|
10802 }; |
|
10803 |
|
10804 // Animate |
|
10805 el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
10806 if (el.to.opacity === 0) { |
|
10807 el.css('opacity', el.from.opacity); |
|
10808 } |
|
10809 if(mode == 'hide') el.hide(); // Hide |
|
10810 $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore |
|
10811 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10812 el.dequeue(); |
|
10813 }}); |
|
10814 |
|
10815 }); |
|
10816 |
|
10817 }; |
|
10818 |
|
10819 })(jQuery); |
|
10820 /* |
|
10821 * jQuery UI Effects Shake 1.8.1 |
|
10822 * |
|
10823 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10824 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10825 * and GPL (GPL-LICENSE.txt) licenses. |
|
10826 * |
|
10827 * http://docs.jquery.com/UI/Effects/Shake |
|
10828 * |
|
10829 * Depends: |
|
10830 * jquery.effects.core.js |
|
10831 */ |
|
10832 (function($) { |
|
10833 |
|
10834 $.effects.shake = function(o) { |
|
10835 |
|
10836 return this.queue(function() { |
|
10837 |
|
10838 // Create element |
|
10839 var el = $(this), props = ['position','top','left']; |
|
10840 |
|
10841 // Set options |
|
10842 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
10843 var direction = o.options.direction || 'left'; // Default direction |
|
10844 var distance = o.options.distance || 20; // Default distance |
|
10845 var times = o.options.times || 3; // Default # of times |
|
10846 var speed = o.duration || o.options.duration || 140; // Default speed per shake |
|
10847 |
|
10848 // Adjust |
|
10849 $.effects.save(el, props); el.show(); // Save & Show |
|
10850 $.effects.createWrapper(el); // Create Wrapper |
|
10851 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
10852 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
10853 |
|
10854 // Animation |
|
10855 var animation = {}, animation1 = {}, animation2 = {}; |
|
10856 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
10857 animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2; |
|
10858 animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2; |
|
10859 |
|
10860 // Animate |
|
10861 el.animate(animation, speed, o.options.easing); |
|
10862 for (var i = 1; i < times; i++) { // Shakes |
|
10863 el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing); |
|
10864 }; |
|
10865 el.animate(animation1, speed, o.options.easing). |
|
10866 animate(animation, speed / 2, o.options.easing, function(){ // Last shake |
|
10867 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10868 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10869 }); |
|
10870 el.queue('fx', function() { el.dequeue(); }); |
|
10871 el.dequeue(); |
|
10872 }); |
|
10873 |
|
10874 }; |
|
10875 |
|
10876 })(jQuery); |
|
10877 /* |
|
10878 * jQuery UI Effects Slide 1.8.1 |
|
10879 * |
|
10880 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10881 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10882 * and GPL (GPL-LICENSE.txt) licenses. |
|
10883 * |
|
10884 * http://docs.jquery.com/UI/Effects/Slide |
|
10885 * |
|
10886 * Depends: |
|
10887 * jquery.effects.core.js |
|
10888 */ |
|
10889 (function($) { |
|
10890 |
|
10891 $.effects.slide = function(o) { |
|
10892 |
|
10893 return this.queue(function() { |
|
10894 |
|
10895 // Create element |
|
10896 var el = $(this), props = ['position','top','left']; |
|
10897 |
|
10898 // Set options |
|
10899 var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode |
|
10900 var direction = o.options.direction || 'left'; // Default Direction |
|
10901 |
|
10902 // Adjust |
|
10903 $.effects.save(el, props); el.show(); // Save & Show |
|
10904 $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
10905 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
10906 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
10907 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true})); |
|
10908 if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
10909 |
|
10910 // Animation |
|
10911 var animation = {}; |
|
10912 animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; |
|
10913 |
|
10914 // Animate |
|
10915 el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
10916 if(mode == 'hide') el.hide(); // Hide |
|
10917 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
10918 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
10919 el.dequeue(); |
|
10920 }}); |
|
10921 |
|
10922 }); |
|
10923 |
|
10924 }; |
|
10925 |
|
10926 })(jQuery); |
|
10927 /* |
|
10928 * jQuery UI Effects Transfer 1.8.1 |
|
10929 * |
|
10930 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) |
|
10931 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
10932 * and GPL (GPL-LICENSE.txt) licenses. |
|
10933 * |
|
10934 * http://docs.jquery.com/UI/Effects/Transfer |
|
10935 * |
|
10936 * Depends: |
|
10937 * jquery.effects.core.js |
|
10938 */ |
|
10939 (function($) { |
|
10940 |
|
10941 $.effects.transfer = function(o) { |
|
10942 return this.queue(function() { |
|
10943 var elem = $(this), |
|
10944 target = $(o.options.to), |
|
10945 endPosition = target.offset(), |
|
10946 animation = { |
|
10947 top: endPosition.top, |
|
10948 left: endPosition.left, |
|
10949 height: target.innerHeight(), |
|
10950 width: target.innerWidth() |
|
10951 }, |
|
10952 startPosition = elem.offset(), |
|
10953 transfer = $('<div class="ui-effects-transfer"></div>') |
|
10954 .appendTo(document.body) |
|
10955 .addClass(o.options.className) |
|
10956 .css({ |
|
10957 top: startPosition.top, |
|
10958 left: startPosition.left, |
|
10959 height: elem.innerHeight(), |
|
10960 width: elem.innerWidth(), |
|
10961 position: 'absolute' |
|
10962 }) |
|
10963 .animate(animation, o.duration, o.options.easing, function() { |
|
10964 transfer.remove(); |
|
10965 (o.callback && o.callback.apply(elem[0], arguments)); |
|
10966 elem.dequeue(); |
|
10967 }); |
|
10968 }); |
|
10969 }; |
|
10970 |
|
10971 })(jQuery); |