Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1,4 +1,5053 @@ |
2 | 2 | /* |
| 3 | + * jQuery UI 1.7.1 |
| 4 | + * |
| 5 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 6 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 7 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 8 | + * |
| 9 | + * http://docs.jquery.com/UI |
| 10 | + */ |
| 11 | +;jQuery.ui || (function($) { |
| 12 | + |
| 13 | +var _remove = $.fn.remove, |
| 14 | + isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); |
| 15 | + |
| 16 | +//Helper functions and ui object |
| 17 | +$.ui = { |
| 18 | + version: "1.7.1", |
| 19 | + |
| 20 | + // $.ui.plugin is deprecated. Use the proxy pattern instead. |
| 21 | + plugin: { |
| 22 | + add: function(module, option, set) { |
| 23 | + var proto = $.ui[module].prototype; |
| 24 | + for(var i in set) { |
| 25 | + proto.plugins[i] = proto.plugins[i] || []; |
| 26 | + proto.plugins[i].push([option, set[i]]); |
| 27 | + } |
| 28 | + }, |
| 29 | + call: function(instance, name, args) { |
| 30 | + var set = instance.plugins[name]; |
| 31 | + if(!set || !instance.element[0].parentNode) { return; } |
| 32 | + |
| 33 | + for (var i = 0; i < set.length; i++) { |
| 34 | + if (instance.options[set[i][0]]) { |
| 35 | + set[i][1].apply(instance.element, args); |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + }, |
| 40 | + |
| 41 | + contains: function(a, b) { |
| 42 | + return document.compareDocumentPosition |
| 43 | + ? a.compareDocumentPosition(b) & 16 |
| 44 | + : a !== b && a.contains(b); |
| 45 | + }, |
| 46 | + |
| 47 | + hasScroll: function(el, a) { |
| 48 | + |
| 49 | + //If overflow is hidden, the element might have extra content, but the user wants to hide it |
| 50 | + if ($(el).css('overflow') == 'hidden') { return false; } |
| 51 | + |
| 52 | + var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', |
| 53 | + has = false; |
| 54 | + |
| 55 | + if (el[scroll] > 0) { return true; } |
| 56 | + |
| 57 | + // TODO: determine which cases actually cause this to happen |
| 58 | + // if the element doesn't have the scroll set, see if it's possible to |
| 59 | + // set the scroll |
| 60 | + el[scroll] = 1; |
| 61 | + has = (el[scroll] > 0); |
| 62 | + el[scroll] = 0; |
| 63 | + return has; |
| 64 | + }, |
| 65 | + |
| 66 | + isOverAxis: function(x, reference, size) { |
| 67 | + //Determines when x coordinate is over "b" element axis |
| 68 | + return (x > reference) && (x < (reference + size)); |
| 69 | + }, |
| 70 | + |
| 71 | + isOver: function(y, x, top, left, height, width) { |
| 72 | + //Determines when x, y coordinates is over "b" element |
| 73 | + return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); |
| 74 | + }, |
| 75 | + |
| 76 | + keyCode: { |
| 77 | + BACKSPACE: 8, |
| 78 | + CAPS_LOCK: 20, |
| 79 | + COMMA: 188, |
| 80 | + CONTROL: 17, |
| 81 | + DELETE: 46, |
| 82 | + DOWN: 40, |
| 83 | + END: 35, |
| 84 | + ENTER: 13, |
| 85 | + ESCAPE: 27, |
| 86 | + HOME: 36, |
| 87 | + INSERT: 45, |
| 88 | + LEFT: 37, |
| 89 | + NUMPAD_ADD: 107, |
| 90 | + NUMPAD_DECIMAL: 110, |
| 91 | + NUMPAD_DIVIDE: 111, |
| 92 | + NUMPAD_ENTER: 108, |
| 93 | + NUMPAD_MULTIPLY: 106, |
| 94 | + NUMPAD_SUBTRACT: 109, |
| 95 | + PAGE_DOWN: 34, |
| 96 | + PAGE_UP: 33, |
| 97 | + PERIOD: 190, |
| 98 | + RIGHT: 39, |
| 99 | + SHIFT: 16, |
| 100 | + SPACE: 32, |
| 101 | + TAB: 9, |
| 102 | + UP: 38 |
| 103 | + } |
| 104 | +}; |
| 105 | + |
| 106 | +// WAI-ARIA normalization |
| 107 | +if (isFF2) { |
| 108 | + var attr = $.attr, |
| 109 | + removeAttr = $.fn.removeAttr, |
| 110 | + ariaNS = "http://www.w3.org/2005/07/aaa", |
| 111 | + ariaState = /^aria-/, |
| 112 | + ariaRole = /^wairole:/; |
| 113 | + |
| 114 | + $.attr = function(elem, name, value) { |
| 115 | + var set = value !== undefined; |
| 116 | + |
| 117 | + return (name == 'role' |
| 118 | + ? (set |
| 119 | + ? attr.call(this, elem, name, "wairole:" + value) |
| 120 | + : (attr.apply(this, arguments) || "").replace(ariaRole, "")) |
| 121 | + : (ariaState.test(name) |
| 122 | + ? (set |
| 123 | + ? elem.setAttributeNS(ariaNS, |
| 124 | + name.replace(ariaState, "aaa:"), value) |
| 125 | + : attr.call(this, elem, name.replace(ariaState, "aaa:"))) |
| 126 | + : attr.apply(this, arguments))); |
| 127 | + }; |
| 128 | + |
| 129 | + $.fn.removeAttr = function(name) { |
| 130 | + return (ariaState.test(name) |
| 131 | + ? this.each(function() { |
| 132 | + this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); |
| 133 | + }) : removeAttr.call(this, name)); |
| 134 | + }; |
| 135 | +} |
| 136 | + |
| 137 | +//jQuery plugins |
| 138 | +$.fn.extend({ |
| 139 | + remove: function() { |
| 140 | + // Safari has a native remove event which actually removes DOM elements, |
| 141 | + // so we have to use triggerHandler instead of trigger (#3037). |
| 142 | + $("*", this).add(this).each(function() { |
| 143 | + $(this).triggerHandler("remove"); |
| 144 | + }); |
| 145 | + return _remove.apply(this, arguments ); |
| 146 | + }, |
| 147 | + |
| 148 | + enableSelection: function() { |
| 149 | + return this |
| 150 | + .attr('unselectable', 'off') |
| 151 | + .css('MozUserSelect', '') |
| 152 | + .unbind('selectstart.ui'); |
| 153 | + }, |
| 154 | + |
| 155 | + disableSelection: function() { |
| 156 | + return this |
| 157 | + .attr('unselectable', 'on') |
| 158 | + .css('MozUserSelect', 'none') |
| 159 | + .bind('selectstart.ui', function() { return false; }); |
| 160 | + }, |
| 161 | + |
| 162 | + scrollParent: function() { |
| 163 | + var scrollParent; |
| 164 | + if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
| 165 | + scrollParent = this.parents().filter(function() { |
| 166 | + 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)); |
| 167 | + }).eq(0); |
| 168 | + } else { |
| 169 | + scrollParent = this.parents().filter(function() { |
| 170 | + return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
| 171 | + }).eq(0); |
| 172 | + } |
| 173 | + |
| 174 | + return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
| 175 | + } |
| 176 | +}); |
| 177 | + |
| 178 | + |
| 179 | +//Additional selectors |
| 180 | +$.extend($.expr[':'], { |
| 181 | + data: function(elem, i, match) { |
| 182 | + return !!$.data(elem, match[3]); |
| 183 | + }, |
| 184 | + |
| 185 | + focusable: function(element) { |
| 186 | + var nodeName = element.nodeName.toLowerCase(), |
| 187 | + tabIndex = $.attr(element, 'tabindex'); |
| 188 | + return (/input|select|textarea|button|object/.test(nodeName) |
| 189 | + ? !element.disabled |
| 190 | + : 'a' == nodeName || 'area' == nodeName |
| 191 | + ? element.href || !isNaN(tabIndex) |
| 192 | + : !isNaN(tabIndex)) |
| 193 | + // the element and all of its ancestors must be visible |
| 194 | + // the browser may report that the area is hidden |
| 195 | + && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; |
| 196 | + }, |
| 197 | + |
| 198 | + tabbable: function(element) { |
| 199 | + var tabIndex = $.attr(element, 'tabindex'); |
| 200 | + return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); |
| 201 | + } |
| 202 | +}); |
| 203 | + |
| 204 | + |
| 205 | +// $.widget is a factory to create jQuery plugins |
| 206 | +// taking some boilerplate code out of the plugin code |
| 207 | +function getter(namespace, plugin, method, args) { |
| 208 | + function getMethods(type) { |
| 209 | + var methods = $[namespace][plugin][type] || []; |
| 210 | + return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); |
| 211 | + } |
| 212 | + |
| 213 | + var methods = getMethods('getter'); |
| 214 | + if (args.length == 1 && typeof args[0] == 'string') { |
| 215 | + methods = methods.concat(getMethods('getterSetter')); |
| 216 | + } |
| 217 | + return ($.inArray(method, methods) != -1); |
| 218 | +} |
| 219 | + |
| 220 | +$.widget = function(name, prototype) { |
| 221 | + var namespace = name.split(".")[0]; |
| 222 | + name = name.split(".")[1]; |
| 223 | + |
| 224 | + // create plugin method |
| 225 | + $.fn[name] = function(options) { |
| 226 | + var isMethodCall = (typeof options == 'string'), |
| 227 | + args = Array.prototype.slice.call(arguments, 1); |
| 228 | + |
| 229 | + // prevent calls to internal methods |
| 230 | + if (isMethodCall && options.substring(0, 1) == '_') { |
| 231 | + return this; |
| 232 | + } |
| 233 | + |
| 234 | + // handle getter methods |
| 235 | + if (isMethodCall && getter(namespace, name, options, args)) { |
| 236 | + var instance = $.data(this[0], name); |
| 237 | + return (instance ? instance[options].apply(instance, args) |
| 238 | + : undefined); |
| 239 | + } |
| 240 | + |
| 241 | + // handle initialization and non-getter methods |
| 242 | + return this.each(function() { |
| 243 | + var instance = $.data(this, name); |
| 244 | + |
| 245 | + // constructor |
| 246 | + (!instance && !isMethodCall && |
| 247 | + $.data(this, name, new $[namespace][name](this, options))._init()); |
| 248 | + |
| 249 | + // method call |
| 250 | + (instance && isMethodCall && $.isFunction(instance[options]) && |
| 251 | + instance[options].apply(instance, args)); |
| 252 | + }); |
| 253 | + }; |
| 254 | + |
| 255 | + // create widget constructor |
| 256 | + $[namespace] = $[namespace] || {}; |
| 257 | + $[namespace][name] = function(element, options) { |
| 258 | + var self = this; |
| 259 | + |
| 260 | + this.namespace = namespace; |
| 261 | + this.widgetName = name; |
| 262 | + this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
| 263 | + this.widgetBaseClass = namespace + '-' + name; |
| 264 | + |
| 265 | + this.options = $.extend({}, |
| 266 | + $.widget.defaults, |
| 267 | + $[namespace][name].defaults, |
| 268 | + $.metadata && $.metadata.get(element)[name], |
| 269 | + options); |
| 270 | + |
| 271 | + this.element = $(element) |
| 272 | + .bind('setData.' + name, function(event, key, value) { |
| 273 | + if (event.target == element) { |
| 274 | + return self._setData(key, value); |
| 275 | + } |
| 276 | + }) |
| 277 | + .bind('getData.' + name, function(event, key) { |
| 278 | + if (event.target == element) { |
| 279 | + return self._getData(key); |
| 280 | + } |
| 281 | + }) |
| 282 | + .bind('remove', function() { |
| 283 | + return self.destroy(); |
| 284 | + }); |
| 285 | + }; |
| 286 | + |
| 287 | + // add widget prototype |
| 288 | + $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); |
| 289 | + |
| 290 | + // TODO: merge getter and getterSetter properties from widget prototype |
| 291 | + // and plugin prototype |
| 292 | + $[namespace][name].getterSetter = 'option'; |
| 293 | +}; |
| 294 | + |
| 295 | +$.widget.prototype = { |
| 296 | + _init: function() {}, |
| 297 | + destroy: function() { |
| 298 | + this.element.removeData(this.widgetName) |
| 299 | + .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') |
| 300 | + .removeAttr('aria-disabled'); |
| 301 | + }, |
| 302 | + |
| 303 | + option: function(key, value) { |
| 304 | + var options = key, |
| 305 | + self = this; |
| 306 | + |
| 307 | + if (typeof key == "string") { |
| 308 | + if (value === undefined) { |
| 309 | + return this._getData(key); |
| 310 | + } |
| 311 | + options = {}; |
| 312 | + options[key] = value; |
| 313 | + } |
| 314 | + |
| 315 | + $.each(options, function(key, value) { |
| 316 | + self._setData(key, value); |
| 317 | + }); |
| 318 | + }, |
| 319 | + _getData: function(key) { |
| 320 | + return this.options[key]; |
| 321 | + }, |
| 322 | + _setData: function(key, value) { |
| 323 | + this.options[key] = value; |
| 324 | + |
| 325 | + if (key == 'disabled') { |
| 326 | + this.element |
| 327 | + [value ? 'addClass' : 'removeClass']( |
| 328 | + this.widgetBaseClass + '-disabled' + ' ' + |
| 329 | + this.namespace + '-state-disabled') |
| 330 | + .attr("aria-disabled", value); |
| 331 | + } |
| 332 | + }, |
| 333 | + |
| 334 | + enable: function() { |
| 335 | + this._setData('disabled', false); |
| 336 | + }, |
| 337 | + disable: function() { |
| 338 | + this._setData('disabled', true); |
| 339 | + }, |
| 340 | + |
| 341 | + _trigger: function(type, event, data) { |
| 342 | + var callback = this.options[type], |
| 343 | + eventName = (type == this.widgetEventPrefix |
| 344 | + ? type : this.widgetEventPrefix + type); |
| 345 | + |
| 346 | + event = $.Event(event); |
| 347 | + event.type = eventName; |
| 348 | + |
| 349 | + // copy original event properties over to the new event |
| 350 | + // this would happen if we could call $.event.fix instead of $.Event |
| 351 | + // but we don't have a way to force an event to be fixed multiple times |
| 352 | + if (event.originalEvent) { |
| 353 | + for (var i = $.event.props.length, prop; i;) { |
| 354 | + prop = $.event.props[--i]; |
| 355 | + event[prop] = event.originalEvent[prop]; |
| 356 | + } |
| 357 | + } |
| 358 | + |
| 359 | + this.element.trigger(event, data); |
| 360 | + |
| 361 | + return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false |
| 362 | + || event.isDefaultPrevented()); |
| 363 | + } |
| 364 | +}; |
| 365 | + |
| 366 | +$.widget.defaults = { |
| 367 | + disabled: false |
| 368 | +}; |
| 369 | + |
| 370 | + |
| 371 | +/** Mouse Interaction Plugin **/ |
| 372 | + |
| 373 | +$.ui.mouse = { |
| 374 | + _mouseInit: function() { |
| 375 | + var self = this; |
| 376 | + |
| 377 | + this.element |
| 378 | + .bind('mousedown.'+this.widgetName, function(event) { |
| 379 | + return self._mouseDown(event); |
| 380 | + }) |
| 381 | + .bind('click.'+this.widgetName, function(event) { |
| 382 | + if(self._preventClickEvent) { |
| 383 | + self._preventClickEvent = false; |
| 384 | + event.stopImmediatePropagation(); |
| 385 | + return false; |
| 386 | + } |
| 387 | + }); |
| 388 | + |
| 389 | + // Prevent text selection in IE |
| 390 | + if ($.browser.msie) { |
| 391 | + this._mouseUnselectable = this.element.attr('unselectable'); |
| 392 | + this.element.attr('unselectable', 'on'); |
| 393 | + } |
| 394 | + |
| 395 | + this.started = false; |
| 396 | + }, |
| 397 | + |
| 398 | + // TODO: make sure destroying one instance of mouse doesn't mess with |
| 399 | + // other instances of mouse |
| 400 | + _mouseDestroy: function() { |
| 401 | + this.element.unbind('.'+this.widgetName); |
| 402 | + |
| 403 | + // Restore text selection in IE |
| 404 | + ($.browser.msie |
| 405 | + && this.element.attr('unselectable', this._mouseUnselectable)); |
| 406 | + }, |
| 407 | + |
| 408 | + _mouseDown: function(event) { |
| 409 | + // don't let more than one widget handle mouseStart |
| 410 | + // TODO: figure out why we have to use originalEvent |
| 411 | + event.originalEvent = event.originalEvent || {}; |
| 412 | + if (event.originalEvent.mouseHandled) { return; } |
| 413 | + |
| 414 | + // we may have missed mouseup (out of window) |
| 415 | + (this._mouseStarted && this._mouseUp(event)); |
| 416 | + |
| 417 | + this._mouseDownEvent = event; |
| 418 | + |
| 419 | + var self = this, |
| 420 | + btnIsLeft = (event.which == 1), |
| 421 | + elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); |
| 422 | + if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { |
| 423 | + return true; |
| 424 | + } |
| 425 | + |
| 426 | + this.mouseDelayMet = !this.options.delay; |
| 427 | + if (!this.mouseDelayMet) { |
| 428 | + this._mouseDelayTimer = setTimeout(function() { |
| 429 | + self.mouseDelayMet = true; |
| 430 | + }, this.options.delay); |
| 431 | + } |
| 432 | + |
| 433 | + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
| 434 | + this._mouseStarted = (this._mouseStart(event) !== false); |
| 435 | + if (!this._mouseStarted) { |
| 436 | + event.preventDefault(); |
| 437 | + return true; |
| 438 | + } |
| 439 | + } |
| 440 | + |
| 441 | + // these delegates are required to keep context |
| 442 | + this._mouseMoveDelegate = function(event) { |
| 443 | + return self._mouseMove(event); |
| 444 | + }; |
| 445 | + this._mouseUpDelegate = function(event) { |
| 446 | + return self._mouseUp(event); |
| 447 | + }; |
| 448 | + $(document) |
| 449 | + .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
| 450 | + .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
| 451 | + |
| 452 | + // preventDefault() is used to prevent the selection of text here - |
| 453 | + // however, in Safari, this causes select boxes not to be selectable |
| 454 | + // anymore, so this fix is needed |
| 455 | + ($.browser.safari || event.preventDefault()); |
| 456 | + |
| 457 | + event.originalEvent.mouseHandled = true; |
| 458 | + return true; |
| 459 | + }, |
| 460 | + |
| 461 | + _mouseMove: function(event) { |
| 462 | + // IE mouseup check - mouseup happened when mouse was out of window |
| 463 | + if ($.browser.msie && !event.button) { |
| 464 | + return this._mouseUp(event); |
| 465 | + } |
| 466 | + |
| 467 | + if (this._mouseStarted) { |
| 468 | + this._mouseDrag(event); |
| 469 | + return event.preventDefault(); |
| 470 | + } |
| 471 | + |
| 472 | + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
| 473 | + this._mouseStarted = |
| 474 | + (this._mouseStart(this._mouseDownEvent, event) !== false); |
| 475 | + (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); |
| 476 | + } |
| 477 | + |
| 478 | + return !this._mouseStarted; |
| 479 | + }, |
| 480 | + |
| 481 | + _mouseUp: function(event) { |
| 482 | + $(document) |
| 483 | + .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
| 484 | + .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
| 485 | + |
| 486 | + if (this._mouseStarted) { |
| 487 | + this._mouseStarted = false; |
| 488 | + this._preventClickEvent = (event.target == this._mouseDownEvent.target); |
| 489 | + this._mouseStop(event); |
| 490 | + } |
| 491 | + |
| 492 | + return false; |
| 493 | + }, |
| 494 | + |
| 495 | + _mouseDistanceMet: function(event) { |
| 496 | + return (Math.max( |
| 497 | + Math.abs(this._mouseDownEvent.pageX - event.pageX), |
| 498 | + Math.abs(this._mouseDownEvent.pageY - event.pageY) |
| 499 | + ) >= this.options.distance |
| 500 | + ); |
| 501 | + }, |
| 502 | + |
| 503 | + _mouseDelayMet: function(event) { |
| 504 | + return this.mouseDelayMet; |
| 505 | + }, |
| 506 | + |
| 507 | + // These are placeholder methods, to be overriden by extending plugin |
| 508 | + _mouseStart: function(event) {}, |
| 509 | + _mouseDrag: function(event) {}, |
| 510 | + _mouseStop: function(event) {}, |
| 511 | + _mouseCapture: function(event) { return true; } |
| 512 | +}; |
| 513 | + |
| 514 | +$.ui.mouse.defaults = { |
| 515 | + cancel: null, |
| 516 | + distance: 1, |
| 517 | + delay: 0 |
| 518 | +}; |
| 519 | + |
| 520 | +})(jQuery);/* |
| 521 | + * jQuery UI Datepicker 1.7.1 |
| 522 | + * |
| 523 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 524 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 525 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 526 | + * |
| 527 | + * http://docs.jquery.com/UI/Datepicker |
| 528 | + * |
| 529 | + * Depends: |
| 530 | + * ui.core.js |
| 531 | + */ |
| 532 | + |
| 533 | +(function($) { // hide the namespace |
| 534 | + |
| 535 | +$.extend($.ui, { datepicker: { version: "1.7.1" } }); |
| 536 | + |
| 537 | +var PROP_NAME = 'datepicker'; |
| 538 | + |
| 539 | +/* Date picker manager. |
| 540 | + Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
| 541 | + Settings for (groups of) date pickers are maintained in an instance object, |
| 542 | + allowing multiple different settings on the same page. */ |
| 543 | + |
| 544 | +function Datepicker() { |
| 545 | + this.debug = false; // Change this to true to start debugging |
| 546 | + this._curInst = null; // The current instance in use |
| 547 | + this._keyEvent = false; // If the last event was a key event |
| 548 | + this._disabledInputs = []; // List of date picker inputs that have been disabled |
| 549 | + this._datepickerShowing = false; // True if the popup picker is showing , false if not |
| 550 | + this._inDialog = false; // True if showing within a "dialog", false if not |
| 551 | + this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division |
| 552 | + this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class |
| 553 | + this._appendClass = 'ui-datepicker-append'; // The name of the append marker class |
| 554 | + this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class |
| 555 | + this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class |
| 556 | + this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class |
| 557 | + this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class |
| 558 | + this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class |
| 559 | + this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class |
| 560 | + this.regional = []; // Available regional settings, indexed by language code |
| 561 | + this.regional[''] = { // Default regional settings |
| 562 | + closeText: 'Done', // Display text for close link |
| 563 | + prevText: 'Prev', // Display text for previous month link |
| 564 | + nextText: 'Next', // Display text for next month link |
| 565 | + currentText: 'Today', // Display text for current month link |
| 566 | + monthNames: ['January','February','March','April','May','June', |
| 567 | + 'July','August','September','October','November','December'], // Names of months for drop-down and formatting |
| 568 | + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting |
| 569 | + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting |
| 570 | + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting |
| 571 | + dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday |
| 572 | + dateFormat: 'mm/dd/yy', // See format options on parseDate |
| 573 | + firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
| 574 | + isRTL: false // True if right-to-left language, false if left-to-right |
| 575 | + }; |
| 576 | + this._defaults = { // Global defaults for all the date picker instances |
| 577 | + showOn: 'focus', // 'focus' for popup on focus, |
| 578 | + // 'button' for trigger button, or 'both' for either |
| 579 | + showAnim: 'show', // Name of jQuery animation for popup |
| 580 | + showOptions: {}, // Options for enhanced animations |
| 581 | + defaultDate: null, // Used when field is blank: actual date, |
| 582 | + // +/-number for offset from today, null for today |
| 583 | + appendText: '', // Display text following the input box, e.g. showing the format |
| 584 | + buttonText: '...', // Text for trigger button |
| 585 | + buttonImage: '', // URL for trigger button image |
| 586 | + buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
| 587 | + hideIfNoPrevNext: false, // True to hide next/previous month links |
| 588 | + // if not applicable, false to just disable them |
| 589 | + navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links |
| 590 | + gotoCurrent: false, // True if today link goes back to current selection instead |
| 591 | + changeMonth: false, // True if month can be selected directly, false if only prev/next |
| 592 | + changeYear: false, // True if year can be selected directly, false if only prev/next |
| 593 | + showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
| 594 | + yearRange: '-10:+10', // Range of years to display in drop-down, |
| 595 | + // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) |
| 596 | + showOtherMonths: false, // True to show dates in other months, false to leave blank |
| 597 | + calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
| 598 | + // takes a Date and returns the number of the week for it |
| 599 | + shortYearCutoff: '+10', // Short year values < this are in the current century, |
| 600 | + // > this are in the previous century, |
| 601 | + // string value starting with '+' for current year + value |
| 602 | + minDate: null, // The earliest selectable date, or null for no limit |
| 603 | + maxDate: null, // The latest selectable date, or null for no limit |
| 604 | + duration: 'normal', // Duration of display/closure |
| 605 | + beforeShowDay: null, // Function that takes a date and returns an array with |
| 606 | + // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', |
| 607 | + // [2] = cell title (optional), e.g. $.datepicker.noWeekends |
| 608 | + beforeShow: null, // Function that takes an input field and |
| 609 | + // returns a set of custom settings for the date picker |
| 610 | + onSelect: null, // Define a callback function when a date is selected |
| 611 | + onChangeMonthYear: null, // Define a callback function when the month or year is changed |
| 612 | + onClose: null, // Define a callback function when the datepicker is closed |
| 613 | + numberOfMonths: 1, // Number of months to show at a time |
| 614 | + showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
| 615 | + stepMonths: 1, // Number of months to step back/forward |
| 616 | + stepBigMonths: 12, // Number of months to step back/forward for the big links |
| 617 | + altField: '', // Selector for an alternate field to store selected dates into |
| 618 | + altFormat: '', // The date format to use for the alternate field |
| 619 | + constrainInput: true, // The input is constrained by the current date format |
| 620 | + showButtonPanel: false // True to show button panel, false to not show it |
| 621 | + }; |
| 622 | + $.extend(this._defaults, this.regional['']); |
| 623 | + 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>'); |
| 624 | +} |
| 625 | + |
| 626 | +$.extend(Datepicker.prototype, { |
| 627 | + /* Class name added to elements to indicate already configured with a date picker. */ |
| 628 | + markerClassName: 'hasDatepicker', |
| 629 | + |
| 630 | + /* Debug logging (if enabled). */ |
| 631 | + log: function () { |
| 632 | + if (this.debug) |
| 633 | + console.log.apply('', arguments); |
| 634 | + }, |
| 635 | + |
| 636 | + /* Override the default settings for all instances of the date picker. |
| 637 | + @param settings object - the new settings to use as defaults (anonymous object) |
| 638 | + @return the manager object */ |
| 639 | + setDefaults: function(settings) { |
| 640 | + extendRemove(this._defaults, settings || {}); |
| 641 | + return this; |
| 642 | + }, |
| 643 | + |
| 644 | + /* Attach the date picker to a jQuery selection. |
| 645 | + @param target element - the target input field or division or span |
| 646 | + @param settings object - the new settings to use for this date picker instance (anonymous) */ |
| 647 | + _attachDatepicker: function(target, settings) { |
| 648 | + // check for settings on the control itself - in namespace 'date:' |
| 649 | + var inlineSettings = null; |
| 650 | + for (var attrName in this._defaults) { |
| 651 | + var attrValue = target.getAttribute('date:' + attrName); |
| 652 | + if (attrValue) { |
| 653 | + inlineSettings = inlineSettings || {}; |
| 654 | + try { |
| 655 | + inlineSettings[attrName] = eval(attrValue); |
| 656 | + } catch (err) { |
| 657 | + inlineSettings[attrName] = attrValue; |
| 658 | + } |
| 659 | + } |
| 660 | + } |
| 661 | + var nodeName = target.nodeName.toLowerCase(); |
| 662 | + var inline = (nodeName == 'div' || nodeName == 'span'); |
| 663 | + if (!target.id) |
| 664 | + target.id = 'dp' + (++this.uuid); |
| 665 | + var inst = this._newInst($(target), inline); |
| 666 | + inst.settings = $.extend({}, settings || {}, inlineSettings || {}); |
| 667 | + if (nodeName == 'input') { |
| 668 | + this._connectDatepicker(target, inst); |
| 669 | + } else if (inline) { |
| 670 | + this._inlineDatepicker(target, inst); |
| 671 | + } |
| 672 | + }, |
| 673 | + |
| 674 | + /* Create a new instance object. */ |
| 675 | + _newInst: function(target, inline) { |
| 676 | + var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars |
| 677 | + return {id: id, input: target, // associated target |
| 678 | + selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
| 679 | + drawMonth: 0, drawYear: 0, // month being drawn |
| 680 | + inline: inline, // is datepicker inline or not |
| 681 | + dpDiv: (!inline ? this.dpDiv : // presentation div |
| 682 | + $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}; |
| 683 | + }, |
| 684 | + |
| 685 | + /* Attach the date picker to an input field. */ |
| 686 | + _connectDatepicker: function(target, inst) { |
| 687 | + var input = $(target); |
| 688 | + inst.trigger = $([]); |
| 689 | + if (input.hasClass(this.markerClassName)) |
| 690 | + return; |
| 691 | + var appendText = this._get(inst, 'appendText'); |
| 692 | + var isRTL = this._get(inst, 'isRTL'); |
| 693 | + if (appendText) |
| 694 | + input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>'); |
| 695 | + var showOn = this._get(inst, 'showOn'); |
| 696 | + if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field |
| 697 | + input.focus(this._showDatepicker); |
| 698 | + if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked |
| 699 | + var buttonText = this._get(inst, 'buttonText'); |
| 700 | + var buttonImage = this._get(inst, 'buttonImage'); |
| 701 | + inst.trigger = $(this._get(inst, 'buttonImageOnly') ? |
| 702 | + $('<img/>').addClass(this._triggerClass). |
| 703 | + attr({ src: buttonImage, alt: buttonText, title: buttonText }) : |
| 704 | + $('<button type="button"></button>').addClass(this._triggerClass). |
| 705 | + html(buttonImage == '' ? buttonText : $('<img/>').attr( |
| 706 | + { src:buttonImage, alt:buttonText, title:buttonText }))); |
| 707 | + input[isRTL ? 'before' : 'after'](inst.trigger); |
| 708 | + inst.trigger.click(function() { |
| 709 | + if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target) |
| 710 | + $.datepicker._hideDatepicker(); |
| 711 | + else |
| 712 | + $.datepicker._showDatepicker(target); |
| 713 | + return false; |
| 714 | + }); |
| 715 | + } |
| 716 | + input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress). |
| 717 | + bind("setData.datepicker", function(event, key, value) { |
| 718 | + inst.settings[key] = value; |
| 719 | + }).bind("getData.datepicker", function(event, key) { |
| 720 | + return this._get(inst, key); |
| 721 | + }); |
| 722 | + $.data(target, PROP_NAME, inst); |
| 723 | + }, |
| 724 | + |
| 725 | + /* Attach an inline date picker to a div. */ |
| 726 | + _inlineDatepicker: function(target, inst) { |
| 727 | + var divSpan = $(target); |
| 728 | + if (divSpan.hasClass(this.markerClassName)) |
| 729 | + return; |
| 730 | + divSpan.addClass(this.markerClassName).append(inst.dpDiv). |
| 731 | + bind("setData.datepicker", function(event, key, value){ |
| 732 | + inst.settings[key] = value; |
| 733 | + }).bind("getData.datepicker", function(event, key){ |
| 734 | + return this._get(inst, key); |
| 735 | + }); |
| 736 | + $.data(target, PROP_NAME, inst); |
| 737 | + this._setDate(inst, this._getDefaultDate(inst)); |
| 738 | + this._updateDatepicker(inst); |
| 739 | + this._updateAlternate(inst); |
| 740 | + }, |
| 741 | + |
| 742 | + /* Pop-up the date picker in a "dialog" box. |
| 743 | + @param input element - ignored |
| 744 | + @param dateText string - the initial date to display (in the current format) |
| 745 | + @param onSelect function - the function(dateText) to call when a date is selected |
| 746 | + @param settings object - update the dialog date picker instance's settings (anonymous object) |
| 747 | + @param pos int[2] - coordinates for the dialog's position within the screen or |
| 748 | + event - with x/y coordinates or |
| 749 | + leave empty for default (screen centre) |
| 750 | + @return the manager object */ |
| 751 | + _dialogDatepicker: function(input, dateText, onSelect, settings, pos) { |
| 752 | + var inst = this._dialogInst; // internal instance |
| 753 | + if (!inst) { |
| 754 | + var id = 'dp' + (++this.uuid); |
| 755 | + this._dialogInput = $('<input type="text" id="' + id + |
| 756 | + '" size="1" style="position: absolute; top: -100px;"/>'); |
| 757 | + this._dialogInput.keydown(this._doKeyDown); |
| 758 | + $('body').append(this._dialogInput); |
| 759 | + inst = this._dialogInst = this._newInst(this._dialogInput, false); |
| 760 | + inst.settings = {}; |
| 761 | + $.data(this._dialogInput[0], PROP_NAME, inst); |
| 762 | + } |
| 763 | + extendRemove(inst.settings, settings || {}); |
| 764 | + this._dialogInput.val(dateText); |
| 765 | + |
| 766 | + this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); |
| 767 | + if (!this._pos) { |
| 768 | + var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; |
| 769 | + var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; |
| 770 | + var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; |
| 771 | + var scrollY = document.documentElement.scrollTop || document.body.scrollTop; |
| 772 | + this._pos = // should use actual width/height below |
| 773 | + [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; |
| 774 | + } |
| 775 | + |
| 776 | + // move input on screen for focus, but hidden behind dialog |
| 777 | + this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); |
| 778 | + inst.settings.onSelect = onSelect; |
| 779 | + this._inDialog = true; |
| 780 | + this.dpDiv.addClass(this._dialogClass); |
| 781 | + this._showDatepicker(this._dialogInput[0]); |
| 782 | + if ($.blockUI) |
| 783 | + $.blockUI(this.dpDiv); |
| 784 | + $.data(this._dialogInput[0], PROP_NAME, inst); |
| 785 | + return this; |
| 786 | + }, |
| 787 | + |
| 788 | + /* Detach a datepicker from its control. |
| 789 | + @param target element - the target input field or division or span */ |
| 790 | + _destroyDatepicker: function(target) { |
| 791 | + var $target = $(target); |
| 792 | + var inst = $.data(target, PROP_NAME); |
| 793 | + if (!$target.hasClass(this.markerClassName)) { |
| 794 | + return; |
| 795 | + } |
| 796 | + var nodeName = target.nodeName.toLowerCase(); |
| 797 | + $.removeData(target, PROP_NAME); |
| 798 | + if (nodeName == 'input') { |
| 799 | + inst.trigger.remove(); |
| 800 | + $target.siblings('.' + this._appendClass).remove().end(). |
| 801 | + removeClass(this.markerClassName). |
| 802 | + unbind('focus', this._showDatepicker). |
| 803 | + unbind('keydown', this._doKeyDown). |
| 804 | + unbind('keypress', this._doKeyPress); |
| 805 | + } else if (nodeName == 'div' || nodeName == 'span') |
| 806 | + $target.removeClass(this.markerClassName).empty(); |
| 807 | + }, |
| 808 | + |
| 809 | + /* Enable the date picker to a jQuery selection. |
| 810 | + @param target element - the target input field or division or span */ |
| 811 | + _enableDatepicker: function(target) { |
| 812 | + var $target = $(target); |
| 813 | + var inst = $.data(target, PROP_NAME); |
| 814 | + if (!$target.hasClass(this.markerClassName)) { |
| 815 | + return; |
| 816 | + } |
| 817 | + var nodeName = target.nodeName.toLowerCase(); |
| 818 | + if (nodeName == 'input') { |
| 819 | + target.disabled = false; |
| 820 | + inst.trigger.filter("button"). |
| 821 | + each(function() { this.disabled = false; }).end(). |
| 822 | + filter("img"). |
| 823 | + css({opacity: '1.0', cursor: ''}); |
| 824 | + } |
| 825 | + else if (nodeName == 'div' || nodeName == 'span') { |
| 826 | + var inline = $target.children('.' + this._inlineClass); |
| 827 | + inline.children().removeClass('ui-state-disabled'); |
| 828 | + } |
| 829 | + this._disabledInputs = $.map(this._disabledInputs, |
| 830 | + function(value) { return (value == target ? null : value); }); // delete entry |
| 831 | + }, |
| 832 | + |
| 833 | + /* Disable the date picker to a jQuery selection. |
| 834 | + @param target element - the target input field or division or span */ |
| 835 | + _disableDatepicker: function(target) { |
| 836 | + var $target = $(target); |
| 837 | + var inst = $.data(target, PROP_NAME); |
| 838 | + if (!$target.hasClass(this.markerClassName)) { |
| 839 | + return; |
| 840 | + } |
| 841 | + var nodeName = target.nodeName.toLowerCase(); |
| 842 | + if (nodeName == 'input') { |
| 843 | + target.disabled = true; |
| 844 | + inst.trigger.filter("button"). |
| 845 | + each(function() { this.disabled = true; }).end(). |
| 846 | + filter("img"). |
| 847 | + css({opacity: '0.5', cursor: 'default'}); |
| 848 | + } |
| 849 | + else if (nodeName == 'div' || nodeName == 'span') { |
| 850 | + var inline = $target.children('.' + this._inlineClass); |
| 851 | + inline.children().addClass('ui-state-disabled'); |
| 852 | + } |
| 853 | + this._disabledInputs = $.map(this._disabledInputs, |
| 854 | + function(value) { return (value == target ? null : value); }); // delete entry |
| 855 | + this._disabledInputs[this._disabledInputs.length] = target; |
| 856 | + }, |
| 857 | + |
| 858 | + /* Is the first field in a jQuery collection disabled as a datepicker? |
| 859 | + @param target element - the target input field or division or span |
| 860 | + @return boolean - true if disabled, false if enabled */ |
| 861 | + _isDisabledDatepicker: function(target) { |
| 862 | + if (!target) { |
| 863 | + return false; |
| 864 | + } |
| 865 | + for (var i = 0; i < this._disabledInputs.length; i++) { |
| 866 | + if (this._disabledInputs[i] == target) |
| 867 | + return true; |
| 868 | + } |
| 869 | + return false; |
| 870 | + }, |
| 871 | + |
| 872 | + /* Retrieve the instance data for the target control. |
| 873 | + @param target element - the target input field or division or span |
| 874 | + @return object - the associated instance data |
| 875 | + @throws error if a jQuery problem getting data */ |
| 876 | + _getInst: function(target) { |
| 877 | + try { |
| 878 | + return $.data(target, PROP_NAME); |
| 879 | + } |
| 880 | + catch (err) { |
| 881 | + throw 'Missing instance data for this datepicker'; |
| 882 | + } |
| 883 | + }, |
| 884 | + |
| 885 | + /* Update the settings for a date picker attached to an input field or division. |
| 886 | + @param target element - the target input field or division or span |
| 887 | + @param name object - the new settings to update or |
| 888 | + string - the name of the setting to change or |
| 889 | + @param value any - the new value for the setting (omit if above is an object) */ |
| 890 | + _optionDatepicker: function(target, name, value) { |
| 891 | + var settings = name || {}; |
| 892 | + if (typeof name == 'string') { |
| 893 | + settings = {}; |
| 894 | + settings[name] = value; |
| 895 | + } |
| 896 | + var inst = this._getInst(target); |
| 897 | + if (inst) { |
| 898 | + if (this._curInst == inst) { |
| 899 | + this._hideDatepicker(null); |
| 900 | + } |
| 901 | + extendRemove(inst.settings, settings); |
| 902 | + var date = new Date(); |
| 903 | + extendRemove(inst, {rangeStart: null, // start of range |
| 904 | + endDay: null, endMonth: null, endYear: null, // end of range |
| 905 | + selectedDay: date.getDate(), selectedMonth: date.getMonth(), |
| 906 | + selectedYear: date.getFullYear(), // starting point |
| 907 | + currentDay: date.getDate(), currentMonth: date.getMonth(), |
| 908 | + currentYear: date.getFullYear(), // current selection |
| 909 | + drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month being drawn |
| 910 | + this._updateDatepicker(inst); |
| 911 | + } |
| 912 | + }, |
| 913 | + |
| 914 | + // change method deprecated |
| 915 | + _changeDatepicker: function(target, name, value) { |
| 916 | + this._optionDatepicker(target, name, value); |
| 917 | + }, |
| 918 | + |
| 919 | + /* Redraw the date picker attached to an input field or division. |
| 920 | + @param target element - the target input field or division or span */ |
| 921 | + _refreshDatepicker: function(target) { |
| 922 | + var inst = this._getInst(target); |
| 923 | + if (inst) { |
| 924 | + this._updateDatepicker(inst); |
| 925 | + } |
| 926 | + }, |
| 927 | + |
| 928 | + /* Set the dates for a jQuery selection. |
| 929 | + @param target element - the target input field or division or span |
| 930 | + @param date Date - the new date |
| 931 | + @param endDate Date - the new end date for a range (optional) */ |
| 932 | + _setDateDatepicker: function(target, date, endDate) { |
| 933 | + var inst = this._getInst(target); |
| 934 | + if (inst) { |
| 935 | + this._setDate(inst, date, endDate); |
| 936 | + this._updateDatepicker(inst); |
| 937 | + this._updateAlternate(inst); |
| 938 | + } |
| 939 | + }, |
| 940 | + |
| 941 | + /* Get the date(s) for the first entry in a jQuery selection. |
| 942 | + @param target element - the target input field or division or span |
| 943 | + @return Date - the current date or |
| 944 | + Date[2] - the current dates for a range */ |
| 945 | + _getDateDatepicker: function(target) { |
| 946 | + var inst = this._getInst(target); |
| 947 | + if (inst && !inst.inline) |
| 948 | + this._setDateFromField(inst); |
| 949 | + return (inst ? this._getDate(inst) : null); |
| 950 | + }, |
| 951 | + |
| 952 | + /* Handle keystrokes. */ |
| 953 | + _doKeyDown: function(event) { |
| 954 | + var inst = $.datepicker._getInst(event.target); |
| 955 | + var handled = true; |
| 956 | + var isRTL = inst.dpDiv.is('.ui-datepicker-rtl'); |
| 957 | + inst._keyEvent = true; |
| 958 | + if ($.datepicker._datepickerShowing) |
| 959 | + switch (event.keyCode) { |
| 960 | + case 9: $.datepicker._hideDatepicker(null, ''); |
| 961 | + break; // hide on tab out |
| 962 | + case 13: var sel = $('td.' + $.datepicker._dayOverClass + |
| 963 | + ', td.' + $.datepicker._currentClass, inst.dpDiv); |
| 964 | + if (sel[0]) |
| 965 | + $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); |
| 966 | + else |
| 967 | + $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration')); |
| 968 | + return false; // don't submit the form |
| 969 | + break; // select the value on enter |
| 970 | + case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration')); |
| 971 | + break; // hide on escape |
| 972 | + case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
| 973 | + -$.datepicker._get(inst, 'stepBigMonths') : |
| 974 | + -$.datepicker._get(inst, 'stepMonths')), 'M'); |
| 975 | + break; // previous month/year on page up/+ ctrl |
| 976 | + case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
| 977 | + +$.datepicker._get(inst, 'stepBigMonths') : |
| 978 | + +$.datepicker._get(inst, 'stepMonths')), 'M'); |
| 979 | + break; // next month/year on page down/+ ctrl |
| 980 | + case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target); |
| 981 | + handled = event.ctrlKey || event.metaKey; |
| 982 | + break; // clear on ctrl or command +end |
| 983 | + case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target); |
| 984 | + handled = event.ctrlKey || event.metaKey; |
| 985 | + break; // current on ctrl or command +home |
| 986 | + case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D'); |
| 987 | + handled = event.ctrlKey || event.metaKey; |
| 988 | + // -1 day on ctrl or command +left |
| 989 | + if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
| 990 | + -$.datepicker._get(inst, 'stepBigMonths') : |
| 991 | + -$.datepicker._get(inst, 'stepMonths')), 'M'); |
| 992 | + // next month/year on alt +left on Mac |
| 993 | + break; |
| 994 | + case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D'); |
| 995 | + handled = event.ctrlKey || event.metaKey; |
| 996 | + break; // -1 week on ctrl or command +up |
| 997 | + case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D'); |
| 998 | + handled = event.ctrlKey || event.metaKey; |
| 999 | + // +1 day on ctrl or command +right |
| 1000 | + if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
| 1001 | + +$.datepicker._get(inst, 'stepBigMonths') : |
| 1002 | + +$.datepicker._get(inst, 'stepMonths')), 'M'); |
| 1003 | + // next month/year on alt +right |
| 1004 | + break; |
| 1005 | + case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D'); |
| 1006 | + handled = event.ctrlKey || event.metaKey; |
| 1007 | + break; // +1 week on ctrl or command +down |
| 1008 | + default: handled = false; |
| 1009 | + } |
| 1010 | + else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home |
| 1011 | + $.datepicker._showDatepicker(this); |
| 1012 | + else { |
| 1013 | + handled = false; |
| 1014 | + } |
| 1015 | + if (handled) { |
| 1016 | + event.preventDefault(); |
| 1017 | + event.stopPropagation(); |
| 1018 | + } |
| 1019 | + }, |
| 1020 | + |
| 1021 | + /* Filter entered characters - based on date format. */ |
| 1022 | + _doKeyPress: function(event) { |
| 1023 | + var inst = $.datepicker._getInst(event.target); |
| 1024 | + if ($.datepicker._get(inst, 'constrainInput')) { |
| 1025 | + var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); |
| 1026 | + var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode); |
| 1027 | + return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
| 1028 | + } |
| 1029 | + }, |
| 1030 | + |
| 1031 | + /* Pop-up the date picker for a given input field. |
| 1032 | + @param input element - the input field attached to the date picker or |
| 1033 | + event - if triggered by focus */ |
| 1034 | + _showDatepicker: function(input) { |
| 1035 | + input = input.target || input; |
| 1036 | + if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger |
| 1037 | + input = $('input', input.parentNode)[0]; |
| 1038 | + if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here |
| 1039 | + return; |
| 1040 | + var inst = $.datepicker._getInst(input); |
| 1041 | + var beforeShow = $.datepicker._get(inst, 'beforeShow'); |
| 1042 | + extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); |
| 1043 | + $.datepicker._hideDatepicker(null, ''); |
| 1044 | + $.datepicker._lastInput = input; |
| 1045 | + $.datepicker._setDateFromField(inst); |
| 1046 | + if ($.datepicker._inDialog) // hide cursor |
| 1047 | + input.value = ''; |
| 1048 | + if (!$.datepicker._pos) { // position below input |
| 1049 | + $.datepicker._pos = $.datepicker._findPos(input); |
| 1050 | + $.datepicker._pos[1] += input.offsetHeight; // add the height |
| 1051 | + } |
| 1052 | + var isFixed = false; |
| 1053 | + $(input).parents().each(function() { |
| 1054 | + isFixed |= $(this).css('position') == 'fixed'; |
| 1055 | + return !isFixed; |
| 1056 | + }); |
| 1057 | + if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled |
| 1058 | + $.datepicker._pos[0] -= document.documentElement.scrollLeft; |
| 1059 | + $.datepicker._pos[1] -= document.documentElement.scrollTop; |
| 1060 | + } |
| 1061 | + var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; |
| 1062 | + $.datepicker._pos = null; |
| 1063 | + inst.rangeStart = null; |
| 1064 | + // determine sizing offscreen |
| 1065 | + inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'}); |
| 1066 | + $.datepicker._updateDatepicker(inst); |
| 1067 | + // fix width for dynamic number of date pickers |
| 1068 | + // and adjust position before showing |
| 1069 | + offset = $.datepicker._checkOffset(inst, offset, isFixed); |
| 1070 | + inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? |
| 1071 | + 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', |
| 1072 | + left: offset.left + 'px', top: offset.top + 'px'}); |
| 1073 | + if (!inst.inline) { |
| 1074 | + var showAnim = $.datepicker._get(inst, 'showAnim') || 'show'; |
| 1075 | + var duration = $.datepicker._get(inst, 'duration'); |
| 1076 | + var postProcess = function() { |
| 1077 | + $.datepicker._datepickerShowing = true; |
| 1078 | + if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems |
| 1079 | + $('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4, |
| 1080 | + height: inst.dpDiv.height() + 4}); |
| 1081 | + }; |
| 1082 | + if ($.effects && $.effects[showAnim]) |
| 1083 | + inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
| 1084 | + else |
| 1085 | + inst.dpDiv[showAnim](duration, postProcess); |
| 1086 | + if (duration == '') |
| 1087 | + postProcess(); |
| 1088 | + if (inst.input[0].type != 'hidden') |
| 1089 | + inst.input[0].focus(); |
| 1090 | + $.datepicker._curInst = inst; |
| 1091 | + } |
| 1092 | + }, |
| 1093 | + |
| 1094 | + /* Generate the date picker content. */ |
| 1095 | + _updateDatepicker: function(inst) { |
| 1096 | + var dims = {width: inst.dpDiv.width() + 4, |
| 1097 | + height: inst.dpDiv.height() + 4}; |
| 1098 | + var self = this; |
| 1099 | + inst.dpDiv.empty().append(this._generateHTML(inst)) |
| 1100 | + .find('iframe.ui-datepicker-cover'). |
| 1101 | + css({width: dims.width, height: dims.height}) |
| 1102 | + .end() |
| 1103 | + .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') |
| 1104 | + .bind('mouseout', function(){ |
| 1105 | + $(this).removeClass('ui-state-hover'); |
| 1106 | + if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); |
| 1107 | + if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); |
| 1108 | + }) |
| 1109 | + .bind('mouseover', function(){ |
| 1110 | + if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) { |
| 1111 | + $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); |
| 1112 | + $(this).addClass('ui-state-hover'); |
| 1113 | + if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); |
| 1114 | + if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); |
| 1115 | + } |
| 1116 | + }) |
| 1117 | + .end() |
| 1118 | + .find('.' + this._dayOverClass + ' a') |
| 1119 | + .trigger('mouseover') |
| 1120 | + .end(); |
| 1121 | + var numMonths = this._getNumberOfMonths(inst); |
| 1122 | + var cols = numMonths[1]; |
| 1123 | + var width = 17; |
| 1124 | + if (cols > 1) { |
| 1125 | + inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); |
| 1126 | + } else { |
| 1127 | + inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); |
| 1128 | + } |
| 1129 | + inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + |
| 1130 | + 'Class']('ui-datepicker-multi'); |
| 1131 | + inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + |
| 1132 | + 'Class']('ui-datepicker-rtl'); |
| 1133 | + if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst) |
| 1134 | + $(inst.input[0]).focus(); |
| 1135 | + }, |
| 1136 | + |
| 1137 | + /* Check positioning to remain on screen. */ |
| 1138 | + _checkOffset: function(inst, offset, isFixed) { |
| 1139 | + var dpWidth = inst.dpDiv.outerWidth(); |
| 1140 | + var dpHeight = inst.dpDiv.outerHeight(); |
| 1141 | + var inputWidth = inst.input ? inst.input.outerWidth() : 0; |
| 1142 | + var inputHeight = inst.input ? inst.input.outerHeight() : 0; |
| 1143 | + var viewWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) + $(document).scrollLeft(); |
| 1144 | + var viewHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) + $(document).scrollTop(); |
| 1145 | + |
| 1146 | + offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0); |
| 1147 | + offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0; |
| 1148 | + offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; |
| 1149 | + |
| 1150 | + // now check if datepicker is showing outside window viewport - move to a better place if so. |
| 1151 | + offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0; |
| 1152 | + offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0; |
| 1153 | + |
| 1154 | + return offset; |
| 1155 | + }, |
| 1156 | + |
| 1157 | + /* Find an object's position on the screen. */ |
| 1158 | + _findPos: function(obj) { |
| 1159 | + while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { |
| 1160 | + obj = obj.nextSibling; |
| 1161 | + } |
| 1162 | + var position = $(obj).offset(); |
| 1163 | + return [position.left, position.top]; |
| 1164 | + }, |
| 1165 | + |
| 1166 | + /* Hide the date picker from view. |
| 1167 | + @param input element - the input field attached to the date picker |
| 1168 | + @param duration string - the duration over which to close the date picker */ |
| 1169 | + _hideDatepicker: function(input, duration) { |
| 1170 | + var inst = this._curInst; |
| 1171 | + if (!inst || (input && inst != $.data(input, PROP_NAME))) |
| 1172 | + return; |
| 1173 | + if (inst.stayOpen) |
| 1174 | + this._selectDate('#' + inst.id, this._formatDate(inst, |
| 1175 | + inst.currentDay, inst.currentMonth, inst.currentYear)); |
| 1176 | + inst.stayOpen = false; |
| 1177 | + if (this._datepickerShowing) { |
| 1178 | + duration = (duration != null ? duration : this._get(inst, 'duration')); |
| 1179 | + var showAnim = this._get(inst, 'showAnim'); |
| 1180 | + var postProcess = function() { |
| 1181 | + $.datepicker._tidyDialog(inst); |
| 1182 | + }; |
| 1183 | + if (duration != '' && $.effects && $.effects[showAnim]) |
| 1184 | + inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), |
| 1185 | + duration, postProcess); |
| 1186 | + else |
| 1187 | + inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' : |
| 1188 | + (showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess); |
| 1189 | + if (duration == '') |
| 1190 | + this._tidyDialog(inst); |
| 1191 | + var onClose = this._get(inst, 'onClose'); |
| 1192 | + if (onClose) |
| 1193 | + onClose.apply((inst.input ? inst.input[0] : null), |
| 1194 | + [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback |
| 1195 | + this._datepickerShowing = false; |
| 1196 | + this._lastInput = null; |
| 1197 | + if (this._inDialog) { |
| 1198 | + this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' }); |
| 1199 | + if ($.blockUI) { |
| 1200 | + $.unblockUI(); |
| 1201 | + $('body').append(this.dpDiv); |
| 1202 | + } |
| 1203 | + } |
| 1204 | + this._inDialog = false; |
| 1205 | + } |
| 1206 | + this._curInst = null; |
| 1207 | + }, |
| 1208 | + |
| 1209 | + /* Tidy up after a dialog display. */ |
| 1210 | + _tidyDialog: function(inst) { |
| 1211 | + inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar'); |
| 1212 | + }, |
| 1213 | + |
| 1214 | + /* Close date picker if clicked elsewhere. */ |
| 1215 | + _checkExternalClick: function(event) { |
| 1216 | + if (!$.datepicker._curInst) |
| 1217 | + return; |
| 1218 | + var $target = $(event.target); |
| 1219 | + if (($target.parents('#' + $.datepicker._mainDivId).length == 0) && |
| 1220 | + !$target.hasClass($.datepicker.markerClassName) && |
| 1221 | + !$target.hasClass($.datepicker._triggerClass) && |
| 1222 | + $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) |
| 1223 | + $.datepicker._hideDatepicker(null, ''); |
| 1224 | + }, |
| 1225 | + |
| 1226 | + /* Adjust one of the date sub-fields. */ |
| 1227 | + _adjustDate: function(id, offset, period) { |
| 1228 | + var target = $(id); |
| 1229 | + var inst = this._getInst(target[0]); |
| 1230 | + if (this._isDisabledDatepicker(target[0])) { |
| 1231 | + return; |
| 1232 | + } |
| 1233 | + this._adjustInstDate(inst, offset + |
| 1234 | + (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning |
| 1235 | + period); |
| 1236 | + this._updateDatepicker(inst); |
| 1237 | + }, |
| 1238 | + |
| 1239 | + /* Action for current link. */ |
| 1240 | + _gotoToday: function(id) { |
| 1241 | + var target = $(id); |
| 1242 | + var inst = this._getInst(target[0]); |
| 1243 | + if (this._get(inst, 'gotoCurrent') && inst.currentDay) { |
| 1244 | + inst.selectedDay = inst.currentDay; |
| 1245 | + inst.drawMonth = inst.selectedMonth = inst.currentMonth; |
| 1246 | + inst.drawYear = inst.selectedYear = inst.currentYear; |
| 1247 | + } |
| 1248 | + else { |
| 1249 | + var date = new Date(); |
| 1250 | + inst.selectedDay = date.getDate(); |
| 1251 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); |
| 1252 | + inst.drawYear = inst.selectedYear = date.getFullYear(); |
| 1253 | + } |
| 1254 | + this._notifyChange(inst); |
| 1255 | + this._adjustDate(target); |
| 1256 | + }, |
| 1257 | + |
| 1258 | + /* Action for selecting a new month/year. */ |
| 1259 | + _selectMonthYear: function(id, select, period) { |
| 1260 | + var target = $(id); |
| 1261 | + var inst = this._getInst(target[0]); |
| 1262 | + inst._selectingMonthYear = false; |
| 1263 | + inst['selected' + (period == 'M' ? 'Month' : 'Year')] = |
| 1264 | + inst['draw' + (period == 'M' ? 'Month' : 'Year')] = |
| 1265 | + parseInt(select.options[select.selectedIndex].value,10); |
| 1266 | + this._notifyChange(inst); |
| 1267 | + this._adjustDate(target); |
| 1268 | + }, |
| 1269 | + |
| 1270 | + /* Restore input focus after not changing month/year. */ |
| 1271 | + _clickMonthYear: function(id) { |
| 1272 | + var target = $(id); |
| 1273 | + var inst = this._getInst(target[0]); |
| 1274 | + if (inst.input && inst._selectingMonthYear && !$.browser.msie) |
| 1275 | + inst.input[0].focus(); |
| 1276 | + inst._selectingMonthYear = !inst._selectingMonthYear; |
| 1277 | + }, |
| 1278 | + |
| 1279 | + /* Action for selecting a day. */ |
| 1280 | + _selectDay: function(id, month, year, td) { |
| 1281 | + var target = $(id); |
| 1282 | + if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { |
| 1283 | + return; |
| 1284 | + } |
| 1285 | + var inst = this._getInst(target[0]); |
| 1286 | + inst.selectedDay = inst.currentDay = $('a', td).html(); |
| 1287 | + inst.selectedMonth = inst.currentMonth = month; |
| 1288 | + inst.selectedYear = inst.currentYear = year; |
| 1289 | + if (inst.stayOpen) { |
| 1290 | + inst.endDay = inst.endMonth = inst.endYear = null; |
| 1291 | + } |
| 1292 | + this._selectDate(id, this._formatDate(inst, |
| 1293 | + inst.currentDay, inst.currentMonth, inst.currentYear)); |
| 1294 | + if (inst.stayOpen) { |
| 1295 | + inst.rangeStart = this._daylightSavingAdjust( |
| 1296 | + new Date(inst.currentYear, inst.currentMonth, inst.currentDay)); |
| 1297 | + this._updateDatepicker(inst); |
| 1298 | + } |
| 1299 | + }, |
| 1300 | + |
| 1301 | + /* Erase the input field and hide the date picker. */ |
| 1302 | + _clearDate: function(id) { |
| 1303 | + var target = $(id); |
| 1304 | + var inst = this._getInst(target[0]); |
| 1305 | + inst.stayOpen = false; |
| 1306 | + inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null; |
| 1307 | + this._selectDate(target, ''); |
| 1308 | + }, |
| 1309 | + |
| 1310 | + /* Update the input field with the selected date. */ |
| 1311 | + _selectDate: function(id, dateStr) { |
| 1312 | + var target = $(id); |
| 1313 | + var inst = this._getInst(target[0]); |
| 1314 | + dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); |
| 1315 | + if (inst.input) |
| 1316 | + inst.input.val(dateStr); |
| 1317 | + this._updateAlternate(inst); |
| 1318 | + var onSelect = this._get(inst, 'onSelect'); |
| 1319 | + if (onSelect) |
| 1320 | + onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback |
| 1321 | + else if (inst.input) |
| 1322 | + inst.input.trigger('change'); // fire the change event |
| 1323 | + if (inst.inline) |
| 1324 | + this._updateDatepicker(inst); |
| 1325 | + else if (!inst.stayOpen) { |
| 1326 | + this._hideDatepicker(null, this._get(inst, 'duration')); |
| 1327 | + this._lastInput = inst.input[0]; |
| 1328 | + if (typeof(inst.input[0]) != 'object') |
| 1329 | + inst.input[0].focus(); // restore focus |
| 1330 | + this._lastInput = null; |
| 1331 | + } |
| 1332 | + }, |
| 1333 | + |
| 1334 | + /* Update any alternate field to synchronise with the main field. */ |
| 1335 | + _updateAlternate: function(inst) { |
| 1336 | + var altField = this._get(inst, 'altField'); |
| 1337 | + if (altField) { // update alternate field too |
| 1338 | + var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat'); |
| 1339 | + var date = this._getDate(inst); |
| 1340 | + dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); |
| 1341 | + $(altField).each(function() { $(this).val(dateStr); }); |
| 1342 | + } |
| 1343 | + }, |
| 1344 | + |
| 1345 | + /* Set as beforeShowDay function to prevent selection of weekends. |
| 1346 | + @param date Date - the date to customise |
| 1347 | + @return [boolean, string] - is this date selectable?, what is its CSS class? */ |
| 1348 | + noWeekends: function(date) { |
| 1349 | + var day = date.getDay(); |
| 1350 | + return [(day > 0 && day < 6), '']; |
| 1351 | + }, |
| 1352 | + |
| 1353 | + /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. |
| 1354 | + @param date Date - the date to get the week for |
| 1355 | + @return number - the number of the week within the year that contains this date */ |
| 1356 | + iso8601Week: function(date) { |
| 1357 | + var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); |
| 1358 | + var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan |
| 1359 | + var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 |
| 1360 | + firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday |
| 1361 | + if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary |
| 1362 | + checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year |
| 1363 | + return $.datepicker.iso8601Week(checkDate); |
| 1364 | + } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year |
| 1365 | + firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; |
| 1366 | + if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary |
| 1367 | + return 1; |
| 1368 | + } |
| 1369 | + } |
| 1370 | + return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date |
| 1371 | + }, |
| 1372 | + |
| 1373 | + /* Parse a string value into a date object. |
| 1374 | + See formatDate below for the possible formats. |
| 1375 | + |
| 1376 | + @param format string - the expected format of the date |
| 1377 | + @param value string - the date in the above format |
| 1378 | + @param settings Object - attributes include: |
| 1379 | + shortYearCutoff number - the cutoff year for determining the century (optional) |
| 1380 | + dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
| 1381 | + dayNames string[7] - names of the days from Sunday (optional) |
| 1382 | + monthNamesShort string[12] - abbreviated names of the months (optional) |
| 1383 | + monthNames string[12] - names of the months (optional) |
| 1384 | + @return Date - the extracted date value or null if value is blank */ |
| 1385 | + parseDate: function (format, value, settings) { |
| 1386 | + if (format == null || value == null) |
| 1387 | + throw 'Invalid arguments'; |
| 1388 | + value = (typeof value == 'object' ? value.toString() : value + ''); |
| 1389 | + if (value == '') |
| 1390 | + return null; |
| 1391 | + var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff; |
| 1392 | + var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
| 1393 | + var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
| 1394 | + var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
| 1395 | + var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
| 1396 | + var year = -1; |
| 1397 | + var month = -1; |
| 1398 | + var day = -1; |
| 1399 | + var doy = -1; |
| 1400 | + var literal = false; |
| 1401 | + // Check whether a format character is doubled |
| 1402 | + var lookAhead = function(match) { |
| 1403 | + var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
| 1404 | + if (matches) |
| 1405 | + iFormat++; |
| 1406 | + return matches; |
| 1407 | + }; |
| 1408 | + // Extract a number from the string value |
| 1409 | + var getNumber = function(match) { |
| 1410 | + lookAhead(match); |
| 1411 | + var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2))); |
| 1412 | + var size = origSize; |
| 1413 | + var num = 0; |
| 1414 | + while (size > 0 && iValue < value.length && |
| 1415 | + value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { |
| 1416 | + num = num * 10 + parseInt(value.charAt(iValue++),10); |
| 1417 | + size--; |
| 1418 | + } |
| 1419 | + if (size == origSize) |
| 1420 | + throw 'Missing number at position ' + iValue; |
| 1421 | + return num; |
| 1422 | + }; |
| 1423 | + // Extract a name from the string value and convert to an index |
| 1424 | + var getName = function(match, shortNames, longNames) { |
| 1425 | + var names = (lookAhead(match) ? longNames : shortNames); |
| 1426 | + var size = 0; |
| 1427 | + for (var j = 0; j < names.length; j++) |
| 1428 | + size = Math.max(size, names[j].length); |
| 1429 | + var name = ''; |
| 1430 | + var iInit = iValue; |
| 1431 | + while (size > 0 && iValue < value.length) { |
| 1432 | + name += value.charAt(iValue++); |
| 1433 | + for (var i = 0; i < names.length; i++) |
| 1434 | + if (name == names[i]) |
| 1435 | + return i + 1; |
| 1436 | + size--; |
| 1437 | + } |
| 1438 | + throw 'Unknown name at position ' + iInit; |
| 1439 | + }; |
| 1440 | + // Confirm that a literal character matches the string value |
| 1441 | + var checkLiteral = function() { |
| 1442 | + if (value.charAt(iValue) != format.charAt(iFormat)) |
| 1443 | + throw 'Unexpected literal at position ' + iValue; |
| 1444 | + iValue++; |
| 1445 | + }; |
| 1446 | + var iValue = 0; |
| 1447 | + for (var iFormat = 0; iFormat < format.length; iFormat++) { |
| 1448 | + if (literal) |
| 1449 | + if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
| 1450 | + literal = false; |
| 1451 | + else |
| 1452 | + checkLiteral(); |
| 1453 | + else |
| 1454 | + switch (format.charAt(iFormat)) { |
| 1455 | + case 'd': |
| 1456 | + day = getNumber('d'); |
| 1457 | + break; |
| 1458 | + case 'D': |
| 1459 | + getName('D', dayNamesShort, dayNames); |
| 1460 | + break; |
| 1461 | + case 'o': |
| 1462 | + doy = getNumber('o'); |
| 1463 | + break; |
| 1464 | + case 'm': |
| 1465 | + month = getNumber('m'); |
| 1466 | + break; |
| 1467 | + case 'M': |
| 1468 | + month = getName('M', monthNamesShort, monthNames); |
| 1469 | + break; |
| 1470 | + case 'y': |
| 1471 | + year = getNumber('y'); |
| 1472 | + break; |
| 1473 | + case '@': |
| 1474 | + var date = new Date(getNumber('@')); |
| 1475 | + year = date.getFullYear(); |
| 1476 | + month = date.getMonth() + 1; |
| 1477 | + day = date.getDate(); |
| 1478 | + break; |
| 1479 | + case "'": |
| 1480 | + if (lookAhead("'")) |
| 1481 | + checkLiteral(); |
| 1482 | + else |
| 1483 | + literal = true; |
| 1484 | + break; |
| 1485 | + default: |
| 1486 | + checkLiteral(); |
| 1487 | + } |
| 1488 | + } |
| 1489 | + if (year == -1) |
| 1490 | + year = new Date().getFullYear(); |
| 1491 | + else if (year < 100) |
| 1492 | + year += new Date().getFullYear() - new Date().getFullYear() % 100 + |
| 1493 | + (year <= shortYearCutoff ? 0 : -100); |
| 1494 | + if (doy > -1) { |
| 1495 | + month = 1; |
| 1496 | + day = doy; |
| 1497 | + do { |
| 1498 | + var dim = this._getDaysInMonth(year, month - 1); |
| 1499 | + if (day <= dim) |
| 1500 | + break; |
| 1501 | + month++; |
| 1502 | + day -= dim; |
| 1503 | + } while (true); |
| 1504 | + } |
| 1505 | + var date = this._daylightSavingAdjust(new Date(year, month - 1, day)); |
| 1506 | + if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) |
| 1507 | + throw 'Invalid date'; // E.g. 31/02/* |
| 1508 | + return date; |
| 1509 | + }, |
| 1510 | + |
| 1511 | + /* Standard date formats. */ |
| 1512 | + ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601) |
| 1513 | + COOKIE: 'D, dd M yy', |
| 1514 | + ISO_8601: 'yy-mm-dd', |
| 1515 | + RFC_822: 'D, d M y', |
| 1516 | + RFC_850: 'DD, dd-M-y', |
| 1517 | + RFC_1036: 'D, d M y', |
| 1518 | + RFC_1123: 'D, d M yy', |
| 1519 | + RFC_2822: 'D, d M yy', |
| 1520 | + RSS: 'D, d M y', // RFC 822 |
| 1521 | + TIMESTAMP: '@', |
| 1522 | + W3C: 'yy-mm-dd', // ISO 8601 |
| 1523 | + |
| 1524 | + /* Format a date object into a string value. |
| 1525 | + The format can be combinations of the following: |
| 1526 | + d - day of month (no leading zero) |
| 1527 | + dd - day of month (two digit) |
| 1528 | + o - day of year (no leading zeros) |
| 1529 | + oo - day of year (three digit) |
| 1530 | + D - day name short |
| 1531 | + DD - day name long |
| 1532 | + m - month of year (no leading zero) |
| 1533 | + mm - month of year (two digit) |
| 1534 | + M - month name short |
| 1535 | + MM - month name long |
| 1536 | + y - year (two digit) |
| 1537 | + yy - year (four digit) |
| 1538 | + @ - Unix timestamp (ms since 01/01/1970) |
| 1539 | + '...' - literal text |
| 1540 | + '' - single quote |
| 1541 | + |
| 1542 | + @param format string - the desired format of the date |
| 1543 | + @param date Date - the date value to format |
| 1544 | + @param settings Object - attributes include: |
| 1545 | + dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
| 1546 | + dayNames string[7] - names of the days from Sunday (optional) |
| 1547 | + monthNamesShort string[12] - abbreviated names of the months (optional) |
| 1548 | + monthNames string[12] - names of the months (optional) |
| 1549 | + @return string - the date in the above format */ |
| 1550 | + formatDate: function (format, date, settings) { |
| 1551 | + if (!date) |
| 1552 | + return ''; |
| 1553 | + var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
| 1554 | + var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
| 1555 | + var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
| 1556 | + var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
| 1557 | + // Check whether a format character is doubled |
| 1558 | + var lookAhead = function(match) { |
| 1559 | + var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
| 1560 | + if (matches) |
| 1561 | + iFormat++; |
| 1562 | + return matches; |
| 1563 | + }; |
| 1564 | + // Format a number, with leading zero if necessary |
| 1565 | + var formatNumber = function(match, value, len) { |
| 1566 | + var num = '' + value; |
| 1567 | + if (lookAhead(match)) |
| 1568 | + while (num.length < len) |
| 1569 | + num = '0' + num; |
| 1570 | + return num; |
| 1571 | + }; |
| 1572 | + // Format a name, short or long as requested |
| 1573 | + var formatName = function(match, value, shortNames, longNames) { |
| 1574 | + return (lookAhead(match) ? longNames[value] : shortNames[value]); |
| 1575 | + }; |
| 1576 | + var output = ''; |
| 1577 | + var literal = false; |
| 1578 | + if (date) |
| 1579 | + for (var iFormat = 0; iFormat < format.length; iFormat++) { |
| 1580 | + if (literal) |
| 1581 | + if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
| 1582 | + literal = false; |
| 1583 | + else |
| 1584 | + output += format.charAt(iFormat); |
| 1585 | + else |
| 1586 | + switch (format.charAt(iFormat)) { |
| 1587 | + case 'd': |
| 1588 | + output += formatNumber('d', date.getDate(), 2); |
| 1589 | + break; |
| 1590 | + case 'D': |
| 1591 | + output += formatName('D', date.getDay(), dayNamesShort, dayNames); |
| 1592 | + break; |
| 1593 | + case 'o': |
| 1594 | + var doy = date.getDate(); |
| 1595 | + for (var m = date.getMonth() - 1; m >= 0; m--) |
| 1596 | + doy += this._getDaysInMonth(date.getFullYear(), m); |
| 1597 | + output += formatNumber('o', doy, 3); |
| 1598 | + break; |
| 1599 | + case 'm': |
| 1600 | + output += formatNumber('m', date.getMonth() + 1, 2); |
| 1601 | + break; |
| 1602 | + case 'M': |
| 1603 | + output += formatName('M', date.getMonth(), monthNamesShort, monthNames); |
| 1604 | + break; |
| 1605 | + case 'y': |
| 1606 | + output += (lookAhead('y') ? date.getFullYear() : |
| 1607 | + (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); |
| 1608 | + break; |
| 1609 | + case '@': |
| 1610 | + output += date.getTime(); |
| 1611 | + break; |
| 1612 | + case "'": |
| 1613 | + if (lookAhead("'")) |
| 1614 | + output += "'"; |
| 1615 | + else |
| 1616 | + literal = true; |
| 1617 | + break; |
| 1618 | + default: |
| 1619 | + output += format.charAt(iFormat); |
| 1620 | + } |
| 1621 | + } |
| 1622 | + return output; |
| 1623 | + }, |
| 1624 | + |
| 1625 | + /* Extract all possible characters from the date format. */ |
| 1626 | + _possibleChars: function (format) { |
| 1627 | + var chars = ''; |
| 1628 | + var literal = false; |
| 1629 | + for (var iFormat = 0; iFormat < format.length; iFormat++) |
| 1630 | + if (literal) |
| 1631 | + if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
| 1632 | + literal = false; |
| 1633 | + else |
| 1634 | + chars += format.charAt(iFormat); |
| 1635 | + else |
| 1636 | + switch (format.charAt(iFormat)) { |
| 1637 | + case 'd': case 'm': case 'y': case '@': |
| 1638 | + chars += '0123456789'; |
| 1639 | + break; |
| 1640 | + case 'D': case 'M': |
| 1641 | + return null; // Accept anything |
| 1642 | + case "'": |
| 1643 | + if (lookAhead("'")) |
| 1644 | + chars += "'"; |
| 1645 | + else |
| 1646 | + literal = true; |
| 1647 | + break; |
| 1648 | + default: |
| 1649 | + chars += format.charAt(iFormat); |
| 1650 | + } |
| 1651 | + return chars; |
| 1652 | + }, |
| 1653 | + |
| 1654 | + /* Get a setting value, defaulting if necessary. */ |
| 1655 | + _get: function(inst, name) { |
| 1656 | + return inst.settings[name] !== undefined ? |
| 1657 | + inst.settings[name] : this._defaults[name]; |
| 1658 | + }, |
| 1659 | + |
| 1660 | + /* Parse existing date and initialise date picker. */ |
| 1661 | + _setDateFromField: function(inst) { |
| 1662 | + var dateFormat = this._get(inst, 'dateFormat'); |
| 1663 | + var dates = inst.input ? inst.input.val() : null; |
| 1664 | + inst.endDay = inst.endMonth = inst.endYear = null; |
| 1665 | + var date = defaultDate = this._getDefaultDate(inst); |
| 1666 | + var settings = this._getFormatConfig(inst); |
| 1667 | + try { |
| 1668 | + date = this.parseDate(dateFormat, dates, settings) || defaultDate; |
| 1669 | + } catch (event) { |
| 1670 | + this.log(event); |
| 1671 | + date = defaultDate; |
| 1672 | + } |
| 1673 | + inst.selectedDay = date.getDate(); |
| 1674 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); |
| 1675 | + inst.drawYear = inst.selectedYear = date.getFullYear(); |
| 1676 | + inst.currentDay = (dates ? date.getDate() : 0); |
| 1677 | + inst.currentMonth = (dates ? date.getMonth() : 0); |
| 1678 | + inst.currentYear = (dates ? date.getFullYear() : 0); |
| 1679 | + this._adjustInstDate(inst); |
| 1680 | + }, |
| 1681 | + |
| 1682 | + /* Retrieve the default date shown on opening. */ |
| 1683 | + _getDefaultDate: function(inst) { |
| 1684 | + var date = this._determineDate(this._get(inst, 'defaultDate'), new Date()); |
| 1685 | + var minDate = this._getMinMaxDate(inst, 'min', true); |
| 1686 | + var maxDate = this._getMinMaxDate(inst, 'max'); |
| 1687 | + date = (minDate && date < minDate ? minDate : date); |
| 1688 | + date = (maxDate && date > maxDate ? maxDate : date); |
| 1689 | + return date; |
| 1690 | + }, |
| 1691 | + |
| 1692 | + /* A date may be specified as an exact value or a relative one. */ |
| 1693 | + _determineDate: function(date, defaultDate) { |
| 1694 | + var offsetNumeric = function(offset) { |
| 1695 | + var date = new Date(); |
| 1696 | + date.setDate(date.getDate() + offset); |
| 1697 | + return date; |
| 1698 | + }; |
| 1699 | + var offsetString = function(offset, getDaysInMonth) { |
| 1700 | + var date = new Date(); |
| 1701 | + var year = date.getFullYear(); |
| 1702 | + var month = date.getMonth(); |
| 1703 | + var day = date.getDate(); |
| 1704 | + var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g; |
| 1705 | + var matches = pattern.exec(offset); |
| 1706 | + while (matches) { |
| 1707 | + switch (matches[2] || 'd') { |
| 1708 | + case 'd' : case 'D' : |
| 1709 | + day += parseInt(matches[1],10); break; |
| 1710 | + case 'w' : case 'W' : |
| 1711 | + day += parseInt(matches[1],10) * 7; break; |
| 1712 | + case 'm' : case 'M' : |
| 1713 | + month += parseInt(matches[1],10); |
| 1714 | + day = Math.min(day, getDaysInMonth(year, month)); |
| 1715 | + break; |
| 1716 | + case 'y': case 'Y' : |
| 1717 | + year += parseInt(matches[1],10); |
| 1718 | + day = Math.min(day, getDaysInMonth(year, month)); |
| 1719 | + break; |
| 1720 | + } |
| 1721 | + matches = pattern.exec(offset); |
| 1722 | + } |
| 1723 | + return new Date(year, month, day); |
| 1724 | + }; |
| 1725 | + date = (date == null ? defaultDate : |
| 1726 | + (typeof date == 'string' ? offsetString(date, this._getDaysInMonth) : |
| 1727 | + (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date))); |
| 1728 | + date = (date && date.toString() == 'Invalid Date' ? defaultDate : date); |
| 1729 | + if (date) { |
| 1730 | + date.setHours(0); |
| 1731 | + date.setMinutes(0); |
| 1732 | + date.setSeconds(0); |
| 1733 | + date.setMilliseconds(0); |
| 1734 | + } |
| 1735 | + return this._daylightSavingAdjust(date); |
| 1736 | + }, |
| 1737 | + |
| 1738 | + /* Handle switch to/from daylight saving. |
| 1739 | + Hours may be non-zero on daylight saving cut-over: |
| 1740 | + > 12 when midnight changeover, but then cannot generate |
| 1741 | + midnight datetime, so jump to 1AM, otherwise reset. |
| 1742 | + @param date (Date) the date to check |
| 1743 | + @return (Date) the corrected date */ |
| 1744 | + _daylightSavingAdjust: function(date) { |
| 1745 | + if (!date) return null; |
| 1746 | + date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); |
| 1747 | + return date; |
| 1748 | + }, |
| 1749 | + |
| 1750 | + /* Set the date(s) directly. */ |
| 1751 | + _setDate: function(inst, date, endDate) { |
| 1752 | + var clear = !(date); |
| 1753 | + var origMonth = inst.selectedMonth; |
| 1754 | + var origYear = inst.selectedYear; |
| 1755 | + date = this._determineDate(date, new Date()); |
| 1756 | + inst.selectedDay = inst.currentDay = date.getDate(); |
| 1757 | + inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth(); |
| 1758 | + inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear(); |
| 1759 | + if (origMonth != inst.selectedMonth || origYear != inst.selectedYear) |
| 1760 | + this._notifyChange(inst); |
| 1761 | + this._adjustInstDate(inst); |
| 1762 | + if (inst.input) { |
| 1763 | + inst.input.val(clear ? '' : this._formatDate(inst)); |
| 1764 | + } |
| 1765 | + }, |
| 1766 | + |
| 1767 | + /* Retrieve the date(s) directly. */ |
| 1768 | + _getDate: function(inst) { |
| 1769 | + var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : |
| 1770 | + this._daylightSavingAdjust(new Date( |
| 1771 | + inst.currentYear, inst.currentMonth, inst.currentDay))); |
| 1772 | + return startDate; |
| 1773 | + }, |
| 1774 | + |
| 1775 | + /* Generate the HTML for the current state of the date picker. */ |
| 1776 | + _generateHTML: function(inst) { |
| 1777 | + var today = new Date(); |
| 1778 | + today = this._daylightSavingAdjust( |
| 1779 | + new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time |
| 1780 | + var isRTL = this._get(inst, 'isRTL'); |
| 1781 | + var showButtonPanel = this._get(inst, 'showButtonPanel'); |
| 1782 | + var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext'); |
| 1783 | + var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat'); |
| 1784 | + var numMonths = this._getNumberOfMonths(inst); |
| 1785 | + var showCurrentAtPos = this._get(inst, 'showCurrentAtPos'); |
| 1786 | + var stepMonths = this._get(inst, 'stepMonths'); |
| 1787 | + var stepBigMonths = this._get(inst, 'stepBigMonths'); |
| 1788 | + var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1); |
| 1789 | + var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : |
| 1790 | + new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
| 1791 | + var minDate = this._getMinMaxDate(inst, 'min', true); |
| 1792 | + var maxDate = this._getMinMaxDate(inst, 'max'); |
| 1793 | + var drawMonth = inst.drawMonth - showCurrentAtPos; |
| 1794 | + var drawYear = inst.drawYear; |
| 1795 | + if (drawMonth < 0) { |
| 1796 | + drawMonth += 12; |
| 1797 | + drawYear--; |
| 1798 | + } |
| 1799 | + if (maxDate) { |
| 1800 | + var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), |
| 1801 | + maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate())); |
| 1802 | + maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); |
| 1803 | + while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { |
| 1804 | + drawMonth--; |
| 1805 | + if (drawMonth < 0) { |
| 1806 | + drawMonth = 11; |
| 1807 | + drawYear--; |
| 1808 | + } |
| 1809 | + } |
| 1810 | + } |
| 1811 | + inst.drawMonth = drawMonth; |
| 1812 | + inst.drawYear = drawYear; |
| 1813 | + var prevText = this._get(inst, 'prevText'); |
| 1814 | + prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, |
| 1815 | + this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), |
| 1816 | + this._getFormatConfig(inst))); |
| 1817 | + var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? |
| 1818 | + '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' + |
| 1819 | + ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' : |
| 1820 | + (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>')); |
| 1821 | + var nextText = this._get(inst, 'nextText'); |
| 1822 | + nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, |
| 1823 | + this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), |
| 1824 | + this._getFormatConfig(inst))); |
| 1825 | + var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? |
| 1826 | + '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' + |
| 1827 | + ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' : |
| 1828 | + (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>')); |
| 1829 | + var currentText = this._get(inst, 'currentText'); |
| 1830 | + var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); |
| 1831 | + currentText = (!navigationAsDateFormat ? currentText : |
| 1832 | + this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); |
| 1833 | + var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : ''); |
| 1834 | + var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') + |
| 1835 | + (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' + |
| 1836 | + '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : ''; |
| 1837 | + var firstDay = parseInt(this._get(inst, 'firstDay'),10); |
| 1838 | + firstDay = (isNaN(firstDay) ? 0 : firstDay); |
| 1839 | + var dayNames = this._get(inst, 'dayNames'); |
| 1840 | + var dayNamesShort = this._get(inst, 'dayNamesShort'); |
| 1841 | + var dayNamesMin = this._get(inst, 'dayNamesMin'); |
| 1842 | + var monthNames = this._get(inst, 'monthNames'); |
| 1843 | + var monthNamesShort = this._get(inst, 'monthNamesShort'); |
| 1844 | + var beforeShowDay = this._get(inst, 'beforeShowDay'); |
| 1845 | + var showOtherMonths = this._get(inst, 'showOtherMonths'); |
| 1846 | + var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week; |
| 1847 | + var endDate = inst.endDay ? this._daylightSavingAdjust( |
| 1848 | + new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate; |
| 1849 | + var defaultDate = this._getDefaultDate(inst); |
| 1850 | + var html = ''; |
| 1851 | + for (var row = 0; row < numMonths[0]; row++) { |
| 1852 | + var group = ''; |
| 1853 | + for (var col = 0; col < numMonths[1]; col++) { |
| 1854 | + var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); |
| 1855 | + var cornerClass = ' ui-corner-all'; |
| 1856 | + var calender = ''; |
| 1857 | + if (isMultiMonth) { |
| 1858 | + calender += '<div class="ui-datepicker-group ui-datepicker-group-'; |
| 1859 | + switch (col) { |
| 1860 | + case 0: calender += 'first'; cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break; |
| 1861 | + case numMonths[1]-1: calender += 'last'; cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break; |
| 1862 | + default: calender += 'middle'; cornerClass = ''; break; |
| 1863 | + } |
| 1864 | + calender += '">'; |
| 1865 | + } |
| 1866 | + calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' + |
| 1867 | + (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') + |
| 1868 | + (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') + |
| 1869 | + this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, |
| 1870 | + selectedDate, row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers |
| 1871 | + '</div><table class="ui-datepicker-calendar"><thead>' + |
| 1872 | + '<tr>'; |
| 1873 | + var thead = ''; |
| 1874 | + for (var dow = 0; dow < 7; dow++) { // days of the week |
| 1875 | + var day = (dow + firstDay) % 7; |
| 1876 | + thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' + |
| 1877 | + '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>'; |
| 1878 | + } |
| 1879 | + calender += thead + '</tr></thead><tbody>'; |
| 1880 | + var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); |
| 1881 | + if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) |
| 1882 | + inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); |
| 1883 | + var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; |
| 1884 | + var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate |
| 1885 | + var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); |
| 1886 | + for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows |
| 1887 | + calender += '<tr>'; |
| 1888 | + var tbody = ''; |
| 1889 | + for (var dow = 0; dow < 7; dow++) { // create date picker days |
| 1890 | + var daySettings = (beforeShowDay ? |
| 1891 | + beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']); |
| 1892 | + var otherMonth = (printDate.getMonth() != drawMonth); |
| 1893 | + var unselectable = otherMonth || !daySettings[0] || |
| 1894 | + (minDate && printDate < minDate) || (maxDate && printDate > maxDate); |
| 1895 | + tbody += '<td class="' + |
| 1896 | + ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends |
| 1897 | + (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months |
| 1898 | + ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key |
| 1899 | + (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ? |
| 1900 | + // or defaultDate is current printedDate and defaultDate is selectedDate |
| 1901 | + ' ' + this._dayOverClass : '') + // highlight selected day |
| 1902 | + (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days |
| 1903 | + (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates |
| 1904 | + (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range |
| 1905 | + ' ' + this._currentClass : '') + // highlight selected day |
| 1906 | + (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different) |
| 1907 | + ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title |
| 1908 | + (unselectable ? '' : ' onclick="DP_jQuery.datepicker._selectDay(\'#' + |
| 1909 | + inst.id + '\',' + drawMonth + ',' + drawYear + ', this);return false;"') + '>' + // actions |
| 1910 | + (otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : // display for other months |
| 1911 | + (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' + |
| 1912 | + (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + |
| 1913 | + (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range |
| 1914 | + ' ui-state-active' : '') + // highlight selected day |
| 1915 | + '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display for this month |
| 1916 | + printDate.setDate(printDate.getDate() + 1); |
| 1917 | + printDate = this._daylightSavingAdjust(printDate); |
| 1918 | + } |
| 1919 | + calender += tbody + '</tr>'; |
| 1920 | + } |
| 1921 | + drawMonth++; |
| 1922 | + if (drawMonth > 11) { |
| 1923 | + drawMonth = 0; |
| 1924 | + drawYear++; |
| 1925 | + } |
| 1926 | + calender += '</tbody></table>' + (isMultiMonth ? '</div>' + |
| 1927 | + ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : ''); |
| 1928 | + group += calender; |
| 1929 | + } |
| 1930 | + html += group; |
| 1931 | + } |
| 1932 | + html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? |
| 1933 | + '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : ''); |
| 1934 | + inst._keyEvent = false; |
| 1935 | + return html; |
| 1936 | + }, |
| 1937 | + |
| 1938 | + /* Generate the month and year header. */ |
| 1939 | + _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, |
| 1940 | + selectedDate, secondary, monthNames, monthNamesShort) { |
| 1941 | + minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate); |
| 1942 | + var changeMonth = this._get(inst, 'changeMonth'); |
| 1943 | + var changeYear = this._get(inst, 'changeYear'); |
| 1944 | + var showMonthAfterYear = this._get(inst, 'showMonthAfterYear'); |
| 1945 | + var html = '<div class="ui-datepicker-title">'; |
| 1946 | + var monthHtml = ''; |
| 1947 | + // month selection |
| 1948 | + if (secondary || !changeMonth) |
| 1949 | + monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span> '; |
| 1950 | + else { |
| 1951 | + var inMinYear = (minDate && minDate.getFullYear() == drawYear); |
| 1952 | + var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); |
| 1953 | + monthHtml += '<select class="ui-datepicker-month" ' + |
| 1954 | + 'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + |
| 1955 | + 'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
| 1956 | + '>'; |
| 1957 | + for (var month = 0; month < 12; month++) { |
| 1958 | + if ((!inMinYear || month >= minDate.getMonth()) && |
| 1959 | + (!inMaxYear || month <= maxDate.getMonth())) |
| 1960 | + monthHtml += '<option value="' + month + '"' + |
| 1961 | + (month == drawMonth ? ' selected="selected"' : '') + |
| 1962 | + '>' + monthNamesShort[month] + '</option>'; |
| 1963 | + } |
| 1964 | + monthHtml += '</select>'; |
| 1965 | + } |
| 1966 | + if (!showMonthAfterYear) |
| 1967 | + html += monthHtml + ((secondary || changeMonth || changeYear) && (!(changeMonth && changeYear)) ? ' ' : ''); |
| 1968 | + // year selection |
| 1969 | + if (secondary || !changeYear) |
| 1970 | + html += '<span class="ui-datepicker-year">' + drawYear + '</span>'; |
| 1971 | + else { |
| 1972 | + // determine range of years to display |
| 1973 | + var years = this._get(inst, 'yearRange').split(':'); |
| 1974 | + var year = 0; |
| 1975 | + var endYear = 0; |
| 1976 | + if (years.length != 2) { |
| 1977 | + year = drawYear - 10; |
| 1978 | + endYear = drawYear + 10; |
| 1979 | + } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { |
| 1980 | + year = drawYear + parseInt(years[0], 10); |
| 1981 | + endYear = drawYear + parseInt(years[1], 10); |
| 1982 | + } else { |
| 1983 | + year = parseInt(years[0], 10); |
| 1984 | + endYear = parseInt(years[1], 10); |
| 1985 | + } |
| 1986 | + year = (minDate ? Math.max(year, minDate.getFullYear()) : year); |
| 1987 | + endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); |
| 1988 | + html += '<select class="ui-datepicker-year" ' + |
| 1989 | + 'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + |
| 1990 | + 'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
| 1991 | + '>'; |
| 1992 | + for (; year <= endYear; year++) { |
| 1993 | + html += '<option value="' + year + '"' + |
| 1994 | + (year == drawYear ? ' selected="selected"' : '') + |
| 1995 | + '>' + year + '</option>'; |
| 1996 | + } |
| 1997 | + html += '</select>'; |
| 1998 | + } |
| 1999 | + if (showMonthAfterYear) |
| 2000 | + html += (secondary || changeMonth || changeYear ? ' ' : '') + monthHtml; |
| 2001 | + html += '</div>'; // Close datepicker_header |
| 2002 | + return html; |
| 2003 | + }, |
| 2004 | + |
| 2005 | + /* Adjust one of the date sub-fields. */ |
| 2006 | + _adjustInstDate: function(inst, offset, period) { |
| 2007 | + var year = inst.drawYear + (period == 'Y' ? offset : 0); |
| 2008 | + var month = inst.drawMonth + (period == 'M' ? offset : 0); |
| 2009 | + var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + |
| 2010 | + (period == 'D' ? offset : 0); |
| 2011 | + var date = this._daylightSavingAdjust(new Date(year, month, day)); |
| 2012 | + // ensure it is within the bounds set |
| 2013 | + var minDate = this._getMinMaxDate(inst, 'min', true); |
| 2014 | + var maxDate = this._getMinMaxDate(inst, 'max'); |
| 2015 | + date = (minDate && date < minDate ? minDate : date); |
| 2016 | + date = (maxDate && date > maxDate ? maxDate : date); |
| 2017 | + inst.selectedDay = date.getDate(); |
| 2018 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); |
| 2019 | + inst.drawYear = inst.selectedYear = date.getFullYear(); |
| 2020 | + if (period == 'M' || period == 'Y') |
| 2021 | + this._notifyChange(inst); |
| 2022 | + }, |
| 2023 | + |
| 2024 | + /* Notify change of month/year. */ |
| 2025 | + _notifyChange: function(inst) { |
| 2026 | + var onChange = this._get(inst, 'onChangeMonthYear'); |
| 2027 | + if (onChange) |
| 2028 | + onChange.apply((inst.input ? inst.input[0] : null), |
| 2029 | + [inst.selectedYear, inst.selectedMonth + 1, inst]); |
| 2030 | + }, |
| 2031 | + |
| 2032 | + /* Determine the number of months to show. */ |
| 2033 | + _getNumberOfMonths: function(inst) { |
| 2034 | + var numMonths = this._get(inst, 'numberOfMonths'); |
| 2035 | + return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); |
| 2036 | + }, |
| 2037 | + |
| 2038 | + /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */ |
| 2039 | + _getMinMaxDate: function(inst, minMax, checkRange) { |
| 2040 | + var date = this._determineDate(this._get(inst, minMax + 'Date'), null); |
| 2041 | + return (!checkRange || !inst.rangeStart ? date : |
| 2042 | + (!date || inst.rangeStart > date ? inst.rangeStart : date)); |
| 2043 | + }, |
| 2044 | + |
| 2045 | + /* Find the number of days in a given month. */ |
| 2046 | + _getDaysInMonth: function(year, month) { |
| 2047 | + return 32 - new Date(year, month, 32).getDate(); |
| 2048 | + }, |
| 2049 | + |
| 2050 | + /* Find the day of the week of the first of a month. */ |
| 2051 | + _getFirstDayOfMonth: function(year, month) { |
| 2052 | + return new Date(year, month, 1).getDay(); |
| 2053 | + }, |
| 2054 | + |
| 2055 | + /* Determines if we should allow a "next/prev" month display change. */ |
| 2056 | + _canAdjustMonth: function(inst, offset, curYear, curMonth) { |
| 2057 | + var numMonths = this._getNumberOfMonths(inst); |
| 2058 | + var date = this._daylightSavingAdjust(new Date( |
| 2059 | + curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1)); |
| 2060 | + if (offset < 0) |
| 2061 | + date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); |
| 2062 | + return this._isInRange(inst, date); |
| 2063 | + }, |
| 2064 | + |
| 2065 | + /* Is the given date in the accepted range? */ |
| 2066 | + _isInRange: function(inst, date) { |
| 2067 | + // during range selection, use minimum of selected date and range start |
| 2068 | + var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust( |
| 2069 | + new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay))); |
| 2070 | + newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate); |
| 2071 | + var minDate = newMinDate || this._getMinMaxDate(inst, 'min'); |
| 2072 | + var maxDate = this._getMinMaxDate(inst, 'max'); |
| 2073 | + return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); |
| 2074 | + }, |
| 2075 | + |
| 2076 | + /* Provide the configuration settings for formatting/parsing. */ |
| 2077 | + _getFormatConfig: function(inst) { |
| 2078 | + var shortYearCutoff = this._get(inst, 'shortYearCutoff'); |
| 2079 | + shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : |
| 2080 | + new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); |
| 2081 | + return {shortYearCutoff: shortYearCutoff, |
| 2082 | + dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), |
| 2083 | + monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; |
| 2084 | + }, |
| 2085 | + |
| 2086 | + /* Format the given date for display. */ |
| 2087 | + _formatDate: function(inst, day, month, year) { |
| 2088 | + if (!day) { |
| 2089 | + inst.currentDay = inst.selectedDay; |
| 2090 | + inst.currentMonth = inst.selectedMonth; |
| 2091 | + inst.currentYear = inst.selectedYear; |
| 2092 | + } |
| 2093 | + var date = (day ? (typeof day == 'object' ? day : |
| 2094 | + this._daylightSavingAdjust(new Date(year, month, day))) : |
| 2095 | + this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
| 2096 | + return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst)); |
| 2097 | + } |
| 2098 | +}); |
| 2099 | + |
| 2100 | +/* jQuery extend now ignores nulls! */ |
| 2101 | +function extendRemove(target, props) { |
| 2102 | + $.extend(target, props); |
| 2103 | + for (var name in props) |
| 2104 | + if (props[name] == null || props[name] == undefined) |
| 2105 | + target[name] = props[name]; |
| 2106 | + return target; |
| 2107 | +}; |
| 2108 | + |
| 2109 | +/* Determine whether an object is an array. */ |
| 2110 | +function isArray(a) { |
| 2111 | + return (a && (($.browser.safari && typeof a == 'object' && a.length) || |
| 2112 | + (a.constructor && a.constructor.toString().match(/\Array\(\)/)))); |
| 2113 | +}; |
| 2114 | + |
| 2115 | +/* Invoke the datepicker functionality. |
| 2116 | + @param options string - a command, optionally followed by additional parameters or |
| 2117 | + Object - settings for attaching new datepicker functionality |
| 2118 | + @return jQuery object */ |
| 2119 | +$.fn.datepicker = function(options){ |
| 2120 | + |
| 2121 | + /* Initialise the date picker. */ |
| 2122 | + if (!$.datepicker.initialized) { |
| 2123 | + $(document).mousedown($.datepicker._checkExternalClick). |
| 2124 | + find('body').append($.datepicker.dpDiv); |
| 2125 | + $.datepicker.initialized = true; |
| 2126 | + } |
| 2127 | + |
| 2128 | + var otherArgs = Array.prototype.slice.call(arguments, 1); |
| 2129 | + if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate')) |
| 2130 | + return $.datepicker['_' + options + 'Datepicker']. |
| 2131 | + apply($.datepicker, [this[0]].concat(otherArgs)); |
| 2132 | + return this.each(function() { |
| 2133 | + typeof options == 'string' ? |
| 2134 | + $.datepicker['_' + options + 'Datepicker']. |
| 2135 | + apply($.datepicker, [this].concat(otherArgs)) : |
| 2136 | + $.datepicker._attachDatepicker(this, options); |
| 2137 | + }); |
| 2138 | +}; |
| 2139 | + |
| 2140 | +$.datepicker = new Datepicker(); // singleton instance |
| 2141 | +$.datepicker.initialized = false; |
| 2142 | +$.datepicker.uuid = new Date().getTime(); |
| 2143 | +$.datepicker.version = "1.7.1"; |
| 2144 | + |
| 2145 | +// Workaround for #4055 |
| 2146 | +// Add another global to avoid noConflict issues with inline event handlers |
| 2147 | +window.DP_jQuery = $; |
| 2148 | + |
| 2149 | +})(jQuery); |
| 2150 | +/* |
| 2151 | + * jQuery UI Dialog 1.7.1 |
| 2152 | + * |
| 2153 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 2154 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 2155 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 2156 | + * |
| 2157 | + * http://docs.jquery.com/UI/Dialog |
| 2158 | + * |
| 2159 | + * Depends: |
| 2160 | + * ui.core.js |
| 2161 | + * ui.draggable.js |
| 2162 | + * ui.resizable.js |
| 2163 | + */ |
| 2164 | +(function($) { |
| 2165 | + |
| 2166 | +var setDataSwitch = { |
| 2167 | + dragStart : "start.draggable", |
| 2168 | + drag : "drag.draggable", |
| 2169 | + dragStop : "stop.draggable", |
| 2170 | + maxHeight : "maxHeight.resizable", |
| 2171 | + minHeight : "minHeight.resizable", |
| 2172 | + maxWidth : "maxWidth.resizable", |
| 2173 | + minWidth : "minWidth.resizable", |
| 2174 | + resizeStart : "start.resizable", |
| 2175 | + resize : "drag.resizable", |
| 2176 | + resizeStop : "stop.resizable" |
| 2177 | + }, |
| 2178 | + |
| 2179 | + uiDialogClasses = |
| 2180 | + 'ui-dialog ' + |
| 2181 | + 'ui-widget ' + |
| 2182 | + 'ui-widget-content ' + |
| 2183 | + 'ui-corner-all '; |
| 2184 | + |
| 2185 | +$.widget("ui.dialog", { |
| 2186 | + |
| 2187 | + _init: function() { |
| 2188 | + this.originalTitle = this.element.attr('title'); |
| 2189 | + |
| 2190 | + var self = this, |
| 2191 | + options = this.options, |
| 2192 | + |
| 2193 | + title = options.title || this.originalTitle || ' ', |
| 2194 | + titleId = $.ui.dialog.getTitleId(this.element), |
| 2195 | + |
| 2196 | + uiDialog = (this.uiDialog = $('<div/>')) |
| 2197 | + .appendTo(document.body) |
| 2198 | + .hide() |
| 2199 | + .addClass(uiDialogClasses + options.dialogClass) |
| 2200 | + .css({ |
| 2201 | + position: 'absolute', |
| 2202 | + overflow: 'hidden', |
| 2203 | + zIndex: options.zIndex |
| 2204 | + }) |
| 2205 | + // setting tabIndex makes the div focusable |
| 2206 | + // setting outline to 0 prevents a border on focus in Mozilla |
| 2207 | + .attr('tabIndex', -1).css('outline', 0).keydown(function(event) { |
| 2208 | + (options.closeOnEscape && event.keyCode |
| 2209 | + && event.keyCode == $.ui.keyCode.ESCAPE && self.close(event)); |
| 2210 | + }) |
| 2211 | + .attr({ |
| 2212 | + role: 'dialog', |
| 2213 | + 'aria-labelledby': titleId |
| 2214 | + }) |
| 2215 | + .mousedown(function(event) { |
| 2216 | + self.moveToTop(false, event); |
| 2217 | + }), |
| 2218 | + |
| 2219 | + uiDialogContent = this.element |
| 2220 | + .show() |
| 2221 | + .removeAttr('title') |
| 2222 | + .addClass( |
| 2223 | + 'ui-dialog-content ' + |
| 2224 | + 'ui-widget-content') |
| 2225 | + .appendTo(uiDialog), |
| 2226 | + |
| 2227 | + uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>')) |
| 2228 | + .addClass( |
| 2229 | + 'ui-dialog-titlebar ' + |
| 2230 | + 'ui-widget-header ' + |
| 2231 | + 'ui-corner-all ' + |
| 2232 | + 'ui-helper-clearfix' |
| 2233 | + ) |
| 2234 | + .prependTo(uiDialog), |
| 2235 | + |
| 2236 | + uiDialogTitlebarClose = $('<a href="#"/>') |
| 2237 | + .addClass( |
| 2238 | + 'ui-dialog-titlebar-close ' + |
| 2239 | + 'ui-corner-all' |
| 2240 | + ) |
| 2241 | + .attr('role', 'button') |
| 2242 | + .hover( |
| 2243 | + function() { |
| 2244 | + uiDialogTitlebarClose.addClass('ui-state-hover'); |
| 2245 | + }, |
| 2246 | + function() { |
| 2247 | + uiDialogTitlebarClose.removeClass('ui-state-hover'); |
| 2248 | + } |
| 2249 | + ) |
| 2250 | + .focus(function() { |
| 2251 | + uiDialogTitlebarClose.addClass('ui-state-focus'); |
| 2252 | + }) |
| 2253 | + .blur(function() { |
| 2254 | + uiDialogTitlebarClose.removeClass('ui-state-focus'); |
| 2255 | + }) |
| 2256 | + .mousedown(function(ev) { |
| 2257 | + ev.stopPropagation(); |
| 2258 | + }) |
| 2259 | + .click(function(event) { |
| 2260 | + self.close(event); |
| 2261 | + return false; |
| 2262 | + }) |
| 2263 | + .appendTo(uiDialogTitlebar), |
| 2264 | + |
| 2265 | + uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>')) |
| 2266 | + .addClass( |
| 2267 | + 'ui-icon ' + |
| 2268 | + 'ui-icon-closethick' |
| 2269 | + ) |
| 2270 | + .text(options.closeText) |
| 2271 | + .appendTo(uiDialogTitlebarClose), |
| 2272 | + |
| 2273 | + uiDialogTitle = $('<span/>') |
| 2274 | + .addClass('ui-dialog-title') |
| 2275 | + .attr('id', titleId) |
| 2276 | + .html(title) |
| 2277 | + .prependTo(uiDialogTitlebar); |
| 2278 | + |
| 2279 | + uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); |
| 2280 | + |
| 2281 | + (options.draggable && $.fn.draggable && this._makeDraggable()); |
| 2282 | + (options.resizable && $.fn.resizable && this._makeResizable()); |
| 2283 | + |
| 2284 | + this._createButtons(options.buttons); |
| 2285 | + this._isOpen = false; |
| 2286 | + |
| 2287 | + (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe()); |
| 2288 | + (options.autoOpen && this.open()); |
| 2289 | + |
| 2290 | + }, |
| 2291 | + |
| 2292 | + destroy: function() { |
| 2293 | + (this.overlay && this.overlay.destroy()); |
| 2294 | + this.uiDialog.hide(); |
| 2295 | + this.element |
| 2296 | + .unbind('.dialog') |
| 2297 | + .removeData('dialog') |
| 2298 | + .removeClass('ui-dialog-content ui-widget-content') |
| 2299 | + .hide().appendTo('body'); |
| 2300 | + this.uiDialog.remove(); |
| 2301 | + |
| 2302 | + (this.originalTitle && this.element.attr('title', this.originalTitle)); |
| 2303 | + }, |
| 2304 | + |
| 2305 | + close: function(event) { |
| 2306 | + var self = this; |
| 2307 | + |
| 2308 | + if (false === self._trigger('beforeclose', event)) { |
| 2309 | + return; |
| 2310 | + } |
| 2311 | + |
| 2312 | + (self.overlay && self.overlay.destroy()); |
| 2313 | + self.uiDialog.unbind('keypress.ui-dialog'); |
| 2314 | + |
| 2315 | + (self.options.hide |
| 2316 | + ? self.uiDialog.hide(self.options.hide, function() { |
| 2317 | + self._trigger('close', event); |
| 2318 | + }) |
| 2319 | + : self.uiDialog.hide() && self._trigger('close', event)); |
| 2320 | + |
| 2321 | + $.ui.dialog.overlay.resize(); |
| 2322 | + |
| 2323 | + self._isOpen = false; |
| 2324 | + }, |
| 2325 | + |
| 2326 | + isOpen: function() { |
| 2327 | + return this._isOpen; |
| 2328 | + }, |
| 2329 | + |
| 2330 | + // the force parameter allows us to move modal dialogs to their correct |
| 2331 | + // position on open |
| 2332 | + moveToTop: function(force, event) { |
| 2333 | + |
| 2334 | + if ((this.options.modal && !force) |
| 2335 | + || (!this.options.stack && !this.options.modal)) { |
| 2336 | + return this._trigger('focus', event); |
| 2337 | + } |
| 2338 | + |
| 2339 | + if (this.options.zIndex > $.ui.dialog.maxZ) { |
| 2340 | + $.ui.dialog.maxZ = this.options.zIndex; |
| 2341 | + } |
| 2342 | + (this.overlay && this.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = ++$.ui.dialog.maxZ)); |
| 2343 | + |
| 2344 | + //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. |
| 2345 | + // http://ui.jquery.com/bugs/ticket/3193 |
| 2346 | + var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; |
| 2347 | + this.uiDialog.css('z-index', ++$.ui.dialog.maxZ); |
| 2348 | + this.element.attr(saveScroll); |
| 2349 | + this._trigger('focus', event); |
| 2350 | + }, |
| 2351 | + |
| 2352 | + open: function() { |
| 2353 | + if (this._isOpen) { return; } |
| 2354 | + |
| 2355 | + var options = this.options, |
| 2356 | + uiDialog = this.uiDialog; |
| 2357 | + |
| 2358 | + this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null; |
| 2359 | + (uiDialog.next().length && uiDialog.appendTo('body')); |
| 2360 | + this._size(); |
| 2361 | + this._position(options.position); |
| 2362 | + uiDialog.show(options.show); |
| 2363 | + this.moveToTop(true); |
| 2364 | + |
| 2365 | + // prevent tabbing out of modal dialogs |
| 2366 | + (options.modal && uiDialog.bind('keypress.ui-dialog', function(event) { |
| 2367 | + if (event.keyCode != $.ui.keyCode.TAB) { |
| 2368 | + return; |
| 2369 | + } |
| 2370 | + |
| 2371 | + var tabbables = $(':tabbable', this), |
| 2372 | + first = tabbables.filter(':first')[0], |
| 2373 | + last = tabbables.filter(':last')[0]; |
| 2374 | + |
| 2375 | + if (event.target == last && !event.shiftKey) { |
| 2376 | + setTimeout(function() { |
| 2377 | + first.focus(); |
| 2378 | + }, 1); |
| 2379 | + } else if (event.target == first && event.shiftKey) { |
| 2380 | + setTimeout(function() { |
| 2381 | + last.focus(); |
| 2382 | + }, 1); |
| 2383 | + } |
| 2384 | + })); |
| 2385 | + |
| 2386 | + // set focus to the first tabbable element in the content area or the first button |
| 2387 | + // if there are no tabbable elements, set focus on the dialog itself |
| 2388 | + $([]) |
| 2389 | + .add(uiDialog.find('.ui-dialog-content :tabbable:first')) |
| 2390 | + .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) |
| 2391 | + .add(uiDialog) |
| 2392 | + .filter(':first') |
| 2393 | + .focus(); |
| 2394 | + |
| 2395 | + this._trigger('open'); |
| 2396 | + this._isOpen = true; |
| 2397 | + }, |
| 2398 | + |
| 2399 | + _createButtons: function(buttons) { |
| 2400 | + var self = this, |
| 2401 | + hasButtons = false, |
| 2402 | + uiDialogButtonPane = $('<div></div>') |
| 2403 | + .addClass( |
| 2404 | + 'ui-dialog-buttonpane ' + |
| 2405 | + 'ui-widget-content ' + |
| 2406 | + 'ui-helper-clearfix' |
| 2407 | + ); |
| 2408 | + |
| 2409 | + // if we already have a button pane, remove it |
| 2410 | + this.uiDialog.find('.ui-dialog-buttonpane').remove(); |
| 2411 | + |
| 2412 | + (typeof buttons == 'object' && buttons !== null && |
| 2413 | + $.each(buttons, function() { return !(hasButtons = true); })); |
| 2414 | + if (hasButtons) { |
| 2415 | + $.each(buttons, function(name, fn) { |
| 2416 | + $('<button type="button"></button>') |
| 2417 | + .addClass( |
| 2418 | + 'ui-state-default ' + |
| 2419 | + 'ui-corner-all' |
| 2420 | + ) |
| 2421 | + .text(name) |
| 2422 | + .click(function() { fn.apply(self.element[0], arguments); }) |
| 2423 | + .hover( |
| 2424 | + function() { |
| 2425 | + $(this).addClass('ui-state-hover'); |
| 2426 | + }, |
| 2427 | + function() { |
| 2428 | + $(this).removeClass('ui-state-hover'); |
| 2429 | + } |
| 2430 | + ) |
| 2431 | + .focus(function() { |
| 2432 | + $(this).addClass('ui-state-focus'); |
| 2433 | + }) |
| 2434 | + .blur(function() { |
| 2435 | + $(this).removeClass('ui-state-focus'); |
| 2436 | + }) |
| 2437 | + .appendTo(uiDialogButtonPane); |
| 2438 | + }); |
| 2439 | + uiDialogButtonPane.appendTo(this.uiDialog); |
| 2440 | + } |
| 2441 | + }, |
| 2442 | + |
| 2443 | + _makeDraggable: function() { |
| 2444 | + var self = this, |
| 2445 | + options = this.options, |
| 2446 | + heightBeforeDrag; |
| 2447 | + |
| 2448 | + this.uiDialog.draggable({ |
| 2449 | + cancel: '.ui-dialog-content', |
| 2450 | + handle: '.ui-dialog-titlebar', |
| 2451 | + containment: 'document', |
| 2452 | + start: function() { |
| 2453 | + heightBeforeDrag = options.height; |
| 2454 | + $(this).height($(this).height()).addClass("ui-dialog-dragging"); |
| 2455 | + (options.dragStart && options.dragStart.apply(self.element[0], arguments)); |
| 2456 | + }, |
| 2457 | + drag: function() { |
| 2458 | + (options.drag && options.drag.apply(self.element[0], arguments)); |
| 2459 | + }, |
| 2460 | + stop: function() { |
| 2461 | + $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag); |
| 2462 | + (options.dragStop && options.dragStop.apply(self.element[0], arguments)); |
| 2463 | + $.ui.dialog.overlay.resize(); |
| 2464 | + } |
| 2465 | + }); |
| 2466 | + }, |
| 2467 | + |
| 2468 | + _makeResizable: function(handles) { |
| 2469 | + handles = (handles === undefined ? this.options.resizable : handles); |
| 2470 | + var self = this, |
| 2471 | + options = this.options, |
| 2472 | + resizeHandles = typeof handles == 'string' |
| 2473 | + ? handles |
| 2474 | + : 'n,e,s,w,se,sw,ne,nw'; |
| 2475 | + |
| 2476 | + this.uiDialog.resizable({ |
| 2477 | + cancel: '.ui-dialog-content', |
| 2478 | + alsoResize: this.element, |
| 2479 | + maxWidth: options.maxWidth, |
| 2480 | + maxHeight: options.maxHeight, |
| 2481 | + minWidth: options.minWidth, |
| 2482 | + minHeight: options.minHeight, |
| 2483 | + start: function() { |
| 2484 | + $(this).addClass("ui-dialog-resizing"); |
| 2485 | + (options.resizeStart && options.resizeStart.apply(self.element[0], arguments)); |
| 2486 | + }, |
| 2487 | + resize: function() { |
| 2488 | + (options.resize && options.resize.apply(self.element[0], arguments)); |
| 2489 | + }, |
| 2490 | + handles: resizeHandles, |
| 2491 | + stop: function() { |
| 2492 | + $(this).removeClass("ui-dialog-resizing"); |
| 2493 | + options.height = $(this).height(); |
| 2494 | + options.width = $(this).width(); |
| 2495 | + (options.resizeStop && options.resizeStop.apply(self.element[0], arguments)); |
| 2496 | + $.ui.dialog.overlay.resize(); |
| 2497 | + } |
| 2498 | + }) |
| 2499 | + .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se'); |
| 2500 | + }, |
| 2501 | + |
| 2502 | + _position: function(pos) { |
| 2503 | + var wnd = $(window), doc = $(document), |
| 2504 | + pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), |
| 2505 | + minTop = pTop; |
| 2506 | + |
| 2507 | + if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { |
| 2508 | + pos = [ |
| 2509 | + pos == 'right' || pos == 'left' ? pos : 'center', |
| 2510 | + pos == 'top' || pos == 'bottom' ? pos : 'middle' |
| 2511 | + ]; |
| 2512 | + } |
| 2513 | + if (pos.constructor != Array) { |
| 2514 | + pos = ['center', 'middle']; |
| 2515 | + } |
| 2516 | + if (pos[0].constructor == Number) { |
| 2517 | + pLeft += pos[0]; |
| 2518 | + } else { |
| 2519 | + switch (pos[0]) { |
| 2520 | + case 'left': |
| 2521 | + pLeft += 0; |
| 2522 | + break; |
| 2523 | + case 'right': |
| 2524 | + pLeft += wnd.width() - this.uiDialog.outerWidth(); |
| 2525 | + break; |
| 2526 | + default: |
| 2527 | + case 'center': |
| 2528 | + pLeft += (wnd.width() - this.uiDialog.outerWidth()) / 2; |
| 2529 | + } |
| 2530 | + } |
| 2531 | + if (pos[1].constructor == Number) { |
| 2532 | + pTop += pos[1]; |
| 2533 | + } else { |
| 2534 | + switch (pos[1]) { |
| 2535 | + case 'top': |
| 2536 | + pTop += 0; |
| 2537 | + break; |
| 2538 | + case 'bottom': |
| 2539 | + pTop += wnd.height() - this.uiDialog.outerHeight(); |
| 2540 | + break; |
| 2541 | + default: |
| 2542 | + case 'middle': |
| 2543 | + pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2; |
| 2544 | + } |
| 2545 | + } |
| 2546 | + |
| 2547 | + // prevent the dialog from being too high (make sure the titlebar |
| 2548 | + // is accessible) |
| 2549 | + pTop = Math.max(pTop, minTop); |
| 2550 | + this.uiDialog.css({top: pTop, left: pLeft}); |
| 2551 | + }, |
| 2552 | + |
| 2553 | + _setData: function(key, value){ |
| 2554 | + (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value)); |
| 2555 | + switch (key) { |
| 2556 | + case "buttons": |
| 2557 | + this._createButtons(value); |
| 2558 | + break; |
| 2559 | + case "closeText": |
| 2560 | + this.uiDialogTitlebarCloseText.text(value); |
| 2561 | + break; |
| 2562 | + case "dialogClass": |
| 2563 | + this.uiDialog |
| 2564 | + .removeClass(this.options.dialogClass) |
| 2565 | + .addClass(uiDialogClasses + value); |
| 2566 | + break; |
| 2567 | + case "draggable": |
| 2568 | + (value |
| 2569 | + ? this._makeDraggable() |
| 2570 | + : this.uiDialog.draggable('destroy')); |
| 2571 | + break; |
| 2572 | + case "height": |
| 2573 | + this.uiDialog.height(value); |
| 2574 | + break; |
| 2575 | + case "position": |
| 2576 | + this._position(value); |
| 2577 | + break; |
| 2578 | + case "resizable": |
| 2579 | + var uiDialog = this.uiDialog, |
| 2580 | + isResizable = this.uiDialog.is(':data(resizable)'); |
| 2581 | + |
| 2582 | + // currently resizable, becoming non-resizable |
| 2583 | + (isResizable && !value && uiDialog.resizable('destroy')); |
| 2584 | + |
| 2585 | + // currently resizable, changing handles |
| 2586 | + (isResizable && typeof value == 'string' && |
| 2587 | + uiDialog.resizable('option', 'handles', value)); |
| 2588 | + |
| 2589 | + // currently non-resizable, becoming resizable |
| 2590 | + (isResizable || this._makeResizable(value)); |
| 2591 | + break; |
| 2592 | + case "title": |
| 2593 | + $(".ui-dialog-title", this.uiDialogTitlebar).html(value || ' '); |
| 2594 | + break; |
| 2595 | + case "width": |
| 2596 | + this.uiDialog.width(value); |
| 2597 | + break; |
| 2598 | + } |
| 2599 | + |
| 2600 | + $.widget.prototype._setData.apply(this, arguments); |
| 2601 | + }, |
| 2602 | + |
| 2603 | + _size: function() { |
| 2604 | + /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content |
| 2605 | + * divs will both have width and height set, so we need to reset them |
| 2606 | + */ |
| 2607 | + var options = this.options; |
| 2608 | + |
| 2609 | + // reset content sizing |
| 2610 | + this.element.css({ |
| 2611 | + height: 0, |
| 2612 | + minHeight: 0, |
| 2613 | + width: 'auto' |
| 2614 | + }); |
| 2615 | + |
| 2616 | + // reset wrapper sizing |
| 2617 | + // determine the height of all the non-content elements |
| 2618 | + var nonContentHeight = this.uiDialog.css({ |
| 2619 | + height: 'auto', |
| 2620 | + width: options.width |
| 2621 | + }) |
| 2622 | + .height(); |
| 2623 | + |
| 2624 | + this.element |
| 2625 | + .css({ |
| 2626 | + minHeight: Math.max(options.minHeight - nonContentHeight, 0), |
| 2627 | + height: options.height == 'auto' |
| 2628 | + ? 'auto' |
| 2629 | + : Math.max(options.height - nonContentHeight, 0) |
| 2630 | + }); |
| 2631 | + } |
| 2632 | +}); |
| 2633 | + |
| 2634 | +$.extend($.ui.dialog, { |
| 2635 | + version: "1.7.1", |
| 2636 | + defaults: { |
| 2637 | + autoOpen: true, |
| 2638 | + bgiframe: false, |
| 2639 | + buttons: {}, |
| 2640 | + closeOnEscape: true, |
| 2641 | + closeText: 'close', |
| 2642 | + dialogClass: '', |
| 2643 | + draggable: true, |
| 2644 | + hide: null, |
| 2645 | + height: 'auto', |
| 2646 | + maxHeight: false, |
| 2647 | + maxWidth: false, |
| 2648 | + minHeight: 150, |
| 2649 | + minWidth: 150, |
| 2650 | + modal: false, |
| 2651 | + position: 'center', |
| 2652 | + resizable: true, |
| 2653 | + show: null, |
| 2654 | + stack: true, |
| 2655 | + title: '', |
| 2656 | + width: 300, |
| 2657 | + zIndex: 1000 |
| 2658 | + }, |
| 2659 | + |
| 2660 | + getter: 'isOpen', |
| 2661 | + |
| 2662 | + uuid: 0, |
| 2663 | + maxZ: 0, |
| 2664 | + |
| 2665 | + getTitleId: function($el) { |
| 2666 | + return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); |
| 2667 | + }, |
| 2668 | + |
| 2669 | + overlay: function(dialog) { |
| 2670 | + this.$el = $.ui.dialog.overlay.create(dialog); |
| 2671 | + } |
| 2672 | +}); |
| 2673 | + |
| 2674 | +$.extend($.ui.dialog.overlay, { |
| 2675 | + instances: [], |
| 2676 | + maxZ: 0, |
| 2677 | + events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), |
| 2678 | + function(event) { return event + '.dialog-overlay'; }).join(' '), |
| 2679 | + create: function(dialog) { |
| 2680 | + if (this.instances.length === 0) { |
| 2681 | + // prevent use of anchors and inputs |
| 2682 | + // we use a setTimeout in case the overlay is created from an |
| 2683 | + // event that we're going to be cancelling (see #2804) |
| 2684 | + setTimeout(function() { |
| 2685 | + $(document).bind($.ui.dialog.overlay.events, function(event) { |
| 2686 | + var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0; |
| 2687 | + return (dialogZ > $.ui.dialog.overlay.maxZ); |
| 2688 | + }); |
| 2689 | + }, 1); |
| 2690 | + |
| 2691 | + // allow closing by pressing the escape key |
| 2692 | + $(document).bind('keydown.dialog-overlay', function(event) { |
| 2693 | + (dialog.options.closeOnEscape && event.keyCode |
| 2694 | + && event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event)); |
| 2695 | + }); |
| 2696 | + |
| 2697 | + // handle window resize |
| 2698 | + $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); |
| 2699 | + } |
| 2700 | + |
| 2701 | + var $el = $('<div></div>').appendTo(document.body) |
| 2702 | + .addClass('ui-widget-overlay').css({ |
| 2703 | + width: this.width(), |
| 2704 | + height: this.height() |
| 2705 | + }); |
| 2706 | + |
| 2707 | + (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe()); |
| 2708 | + |
| 2709 | + this.instances.push($el); |
| 2710 | + return $el; |
| 2711 | + }, |
| 2712 | + |
| 2713 | + destroy: function($el) { |
| 2714 | + this.instances.splice($.inArray(this.instances, $el), 1); |
| 2715 | + |
| 2716 | + if (this.instances.length === 0) { |
| 2717 | + $([document, window]).unbind('.dialog-overlay'); |
| 2718 | + } |
| 2719 | + |
| 2720 | + $el.remove(); |
| 2721 | + }, |
| 2722 | + |
| 2723 | + height: function() { |
| 2724 | + // handle IE 6 |
| 2725 | + if ($.browser.msie && $.browser.version < 7) { |
| 2726 | + var scrollHeight = Math.max( |
| 2727 | + document.documentElement.scrollHeight, |
| 2728 | + document.body.scrollHeight |
| 2729 | + ); |
| 2730 | + var offsetHeight = Math.max( |
| 2731 | + document.documentElement.offsetHeight, |
| 2732 | + document.body.offsetHeight |
| 2733 | + ); |
| 2734 | + |
| 2735 | + if (scrollHeight < offsetHeight) { |
| 2736 | + return $(window).height() + 'px'; |
| 2737 | + } else { |
| 2738 | + return scrollHeight + 'px'; |
| 2739 | + } |
| 2740 | + // handle "good" browsers |
| 2741 | + } else { |
| 2742 | + return $(document).height() + 'px'; |
| 2743 | + } |
| 2744 | + }, |
| 2745 | + |
| 2746 | + width: function() { |
| 2747 | + // handle IE 6 |
| 2748 | + if ($.browser.msie && $.browser.version < 7) { |
| 2749 | + var scrollWidth = Math.max( |
| 2750 | + document.documentElement.scrollWidth, |
| 2751 | + document.body.scrollWidth |
| 2752 | + ); |
| 2753 | + var offsetWidth = Math.max( |
| 2754 | + document.documentElement.offsetWidth, |
| 2755 | + document.body.offsetWidth |
| 2756 | + ); |
| 2757 | + |
| 2758 | + if (scrollWidth < offsetWidth) { |
| 2759 | + return $(window).width() + 'px'; |
| 2760 | + } else { |
| 2761 | + return scrollWidth + 'px'; |
| 2762 | + } |
| 2763 | + // handle "good" browsers |
| 2764 | + } else { |
| 2765 | + return $(document).width() + 'px'; |
| 2766 | + } |
| 2767 | + }, |
| 2768 | + |
| 2769 | + resize: function() { |
| 2770 | + /* If the dialog is draggable and the user drags it past the |
| 2771 | + * right edge of the window, the document becomes wider so we |
| 2772 | + * need to stretch the overlay. If the user then drags the |
| 2773 | + * dialog back to the left, the document will become narrower, |
| 2774 | + * so we need to shrink the overlay to the appropriate size. |
| 2775 | + * This is handled by shrinking the overlay before setting it |
| 2776 | + * to the full document size. |
| 2777 | + */ |
| 2778 | + var $overlays = $([]); |
| 2779 | + $.each($.ui.dialog.overlay.instances, function() { |
| 2780 | + $overlays = $overlays.add(this); |
| 2781 | + }); |
| 2782 | + |
| 2783 | + $overlays.css({ |
| 2784 | + width: 0, |
| 2785 | + height: 0 |
| 2786 | + }).css({ |
| 2787 | + width: $.ui.dialog.overlay.width(), |
| 2788 | + height: $.ui.dialog.overlay.height() |
| 2789 | + }); |
| 2790 | + } |
| 2791 | +}); |
| 2792 | + |
| 2793 | +$.extend($.ui.dialog.overlay.prototype, { |
| 2794 | + destroy: function() { |
| 2795 | + $.ui.dialog.overlay.destroy(this.$el); |
| 2796 | + } |
| 2797 | +}); |
| 2798 | + |
| 2799 | +})(jQuery); |
| 2800 | +/* |
| 2801 | + * jQuery UI Draggable 1.7.1 |
| 2802 | + * |
| 2803 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 2804 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 2805 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 2806 | + * |
| 2807 | + * http://docs.jquery.com/UI/Draggables |
| 2808 | + * |
| 2809 | + * Depends: |
| 2810 | + * ui.core.js |
| 2811 | + */ |
| 2812 | +(function($) { |
| 2813 | + |
| 2814 | +$.widget("ui.draggable", $.extend({}, $.ui.mouse, { |
| 2815 | + |
| 2816 | + _init: function() { |
| 2817 | + |
| 2818 | + if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) |
| 2819 | + this.element[0].style.position = 'relative'; |
| 2820 | + |
| 2821 | + (this.options.addClasses && this.element.addClass("ui-draggable")); |
| 2822 | + (this.options.disabled && this.element.addClass("ui-draggable-disabled")); |
| 2823 | + |
| 2824 | + this._mouseInit(); |
| 2825 | + |
| 2826 | + }, |
| 2827 | + |
| 2828 | + destroy: function() { |
| 2829 | + if(!this.element.data('draggable')) return; |
| 2830 | + this.element |
| 2831 | + .removeData("draggable") |
| 2832 | + .unbind(".draggable") |
| 2833 | + .removeClass("ui-draggable" |
| 2834 | + + " ui-draggable-dragging" |
| 2835 | + + " ui-draggable-disabled"); |
| 2836 | + this._mouseDestroy(); |
| 2837 | + }, |
| 2838 | + |
| 2839 | + _mouseCapture: function(event) { |
| 2840 | + |
| 2841 | + var o = this.options; |
| 2842 | + |
| 2843 | + if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) |
| 2844 | + return false; |
| 2845 | + |
| 2846 | + //Quit if we're not on a valid handle |
| 2847 | + this.handle = this._getHandle(event); |
| 2848 | + if (!this.handle) |
| 2849 | + return false; |
| 2850 | + |
| 2851 | + return true; |
| 2852 | + |
| 2853 | + }, |
| 2854 | + |
| 2855 | + _mouseStart: function(event) { |
| 2856 | + |
| 2857 | + var o = this.options; |
| 2858 | + |
| 2859 | + //Create and append the visible helper |
| 2860 | + this.helper = this._createHelper(event); |
| 2861 | + |
| 2862 | + //Cache the helper size |
| 2863 | + this._cacheHelperProportions(); |
| 2864 | + |
| 2865 | + //If ddmanager is used for droppables, set the global draggable |
| 2866 | + if($.ui.ddmanager) |
| 2867 | + $.ui.ddmanager.current = this; |
| 2868 | + |
| 2869 | + /* |
| 2870 | + * - Position generation - |
| 2871 | + * This block generates everything position related - it's the core of draggables. |
| 2872 | + */ |
| 2873 | + |
| 2874 | + //Cache the margins of the original element |
| 2875 | + this._cacheMargins(); |
| 2876 | + |
| 2877 | + //Store the helper's css position |
| 2878 | + this.cssPosition = this.helper.css("position"); |
| 2879 | + this.scrollParent = this.helper.scrollParent(); |
| 2880 | + |
| 2881 | + //The element's absolute position on the page minus margins |
| 2882 | + this.offset = this.element.offset(); |
| 2883 | + this.offset = { |
| 2884 | + top: this.offset.top - this.margins.top, |
| 2885 | + left: this.offset.left - this.margins.left |
| 2886 | + }; |
| 2887 | + |
| 2888 | + $.extend(this.offset, { |
| 2889 | + click: { //Where the click happened, relative to the element |
| 2890 | + left: event.pageX - this.offset.left, |
| 2891 | + top: event.pageY - this.offset.top |
| 2892 | + }, |
| 2893 | + parent: this._getParentOffset(), |
| 2894 | + relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
| 2895 | + }); |
| 2896 | + |
| 2897 | + //Generate the original position |
| 2898 | + this.originalPosition = this._generatePosition(event); |
| 2899 | + this.originalPageX = event.pageX; |
| 2900 | + this.originalPageY = event.pageY; |
| 2901 | + |
| 2902 | + //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
| 2903 | + if(o.cursorAt) |
| 2904 | + this._adjustOffsetFromHelper(o.cursorAt); |
| 2905 | + |
| 2906 | + //Set a containment if given in the options |
| 2907 | + if(o.containment) |
| 2908 | + this._setContainment(); |
| 2909 | + |
| 2910 | + //Call plugins and callbacks |
| 2911 | + this._trigger("start", event); |
| 2912 | + |
| 2913 | + //Recache the helper size |
| 2914 | + this._cacheHelperProportions(); |
| 2915 | + |
| 2916 | + //Prepare the droppable offsets |
| 2917 | + if ($.ui.ddmanager && !o.dropBehaviour) |
| 2918 | + $.ui.ddmanager.prepareOffsets(this, event); |
| 2919 | + |
| 2920 | + this.helper.addClass("ui-draggable-dragging"); |
| 2921 | + this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
| 2922 | + return true; |
| 2923 | + }, |
| 2924 | + |
| 2925 | + _mouseDrag: function(event, noPropagation) { |
| 2926 | + |
| 2927 | + //Compute the helpers position |
| 2928 | + this.position = this._generatePosition(event); |
| 2929 | + this.positionAbs = this._convertPositionTo("absolute"); |
| 2930 | + |
| 2931 | + //Call plugins and callbacks and use the resulting position if something is returned |
| 2932 | + if (!noPropagation) { |
| 2933 | + var ui = this._uiHash(); |
| 2934 | + this._trigger('drag', event, ui); |
| 2935 | + this.position = ui.position; |
| 2936 | + } |
| 2937 | + |
| 2938 | + if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
| 2939 | + if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
| 2940 | + if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
| 2941 | + |
| 2942 | + return false; |
| 2943 | + }, |
| 2944 | + |
| 2945 | + _mouseStop: function(event) { |
| 2946 | + |
| 2947 | + //If we are using droppables, inform the manager about the drop |
| 2948 | + var dropped = false; |
| 2949 | + if ($.ui.ddmanager && !this.options.dropBehaviour) |
| 2950 | + dropped = $.ui.ddmanager.drop(this, event); |
| 2951 | + |
| 2952 | + //if a drop comes from outside (a sortable) |
| 2953 | + if(this.dropped) { |
| 2954 | + dropped = this.dropped; |
| 2955 | + this.dropped = false; |
| 2956 | + } |
| 2957 | + |
| 2958 | + 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))) { |
| 2959 | + var self = this; |
| 2960 | + $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
| 2961 | + self._trigger("stop", event); |
| 2962 | + self._clear(); |
| 2963 | + }); |
| 2964 | + } else { |
| 2965 | + this._trigger("stop", event); |
| 2966 | + this._clear(); |
| 2967 | + } |
| 2968 | + |
| 2969 | + return false; |
| 2970 | + }, |
| 2971 | + |
| 2972 | + _getHandle: function(event) { |
| 2973 | + |
| 2974 | + var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; |
| 2975 | + $(this.options.handle, this.element) |
| 2976 | + .find("*") |
| 2977 | + .andSelf() |
| 2978 | + .each(function() { |
| 2979 | + if(this == event.target) handle = true; |
| 2980 | + }); |
| 2981 | + |
| 2982 | + return handle; |
| 2983 | + |
| 2984 | + }, |
| 2985 | + |
| 2986 | + _createHelper: function(event) { |
| 2987 | + |
| 2988 | + var o = this.options; |
| 2989 | + var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); |
| 2990 | + |
| 2991 | + if(!helper.parents('body').length) |
| 2992 | + helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); |
| 2993 | + |
| 2994 | + if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) |
| 2995 | + helper.css("position", "absolute"); |
| 2996 | + |
| 2997 | + return helper; |
| 2998 | + |
| 2999 | + }, |
| 3000 | + |
| 3001 | + _adjustOffsetFromHelper: function(obj) { |
| 3002 | + if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left; |
| 3003 | + if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
| 3004 | + if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top; |
| 3005 | + if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
| 3006 | + }, |
| 3007 | + |
| 3008 | + _getParentOffset: function() { |
| 3009 | + |
| 3010 | + //Get the offsetParent and cache its position |
| 3011 | + this.offsetParent = this.helper.offsetParent(); |
| 3012 | + var po = this.offsetParent.offset(); |
| 3013 | + |
| 3014 | + // This is a special case where we need to modify a offset calculated on start, since the following happened: |
| 3015 | + // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
| 3016 | + // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
| 3017 | + // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
| 3018 | + if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { |
| 3019 | + po.left += this.scrollParent.scrollLeft(); |
| 3020 | + po.top += this.scrollParent.scrollTop(); |
| 3021 | + } |
| 3022 | + |
| 3023 | + if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information |
| 3024 | + || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
| 3025 | + po = { top: 0, left: 0 }; |
| 3026 | + |
| 3027 | + return { |
| 3028 | + top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
| 3029 | + left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
| 3030 | + }; |
| 3031 | + |
| 3032 | + }, |
| 3033 | + |
| 3034 | + _getRelativeOffset: function() { |
| 3035 | + |
| 3036 | + if(this.cssPosition == "relative") { |
| 3037 | + var p = this.element.position(); |
| 3038 | + return { |
| 3039 | + top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
| 3040 | + left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
| 3041 | + }; |
| 3042 | + } else { |
| 3043 | + return { top: 0, left: 0 }; |
| 3044 | + } |
| 3045 | + |
| 3046 | + }, |
| 3047 | + |
| 3048 | + _cacheMargins: function() { |
| 3049 | + this.margins = { |
| 3050 | + left: (parseInt(this.element.css("marginLeft"),10) || 0), |
| 3051 | + top: (parseInt(this.element.css("marginTop"),10) || 0) |
| 3052 | + }; |
| 3053 | + }, |
| 3054 | + |
| 3055 | + _cacheHelperProportions: function() { |
| 3056 | + this.helperProportions = { |
| 3057 | + width: this.helper.outerWidth(), |
| 3058 | + height: this.helper.outerHeight() |
| 3059 | + }; |
| 3060 | + }, |
| 3061 | + |
| 3062 | + _setContainment: function() { |
| 3063 | + |
| 3064 | + var o = this.options; |
| 3065 | + if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
| 3066 | + if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
| 3067 | + 0 - this.offset.relative.left - this.offset.parent.left, |
| 3068 | + 0 - this.offset.relative.top - this.offset.parent.top, |
| 3069 | + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
| 3070 | + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
| 3071 | + ]; |
| 3072 | + |
| 3073 | + if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { |
| 3074 | + var ce = $(o.containment)[0]; if(!ce) return; |
| 3075 | + var co = $(o.containment).offset(); |
| 3076 | + var over = ($(ce).css("overflow") != 'hidden'); |
| 3077 | + |
| 3078 | + this.containment = [ |
| 3079 | + co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
| 3080 | + co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
| 3081 | + 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, |
| 3082 | + 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 |
| 3083 | + ]; |
| 3084 | + } else if(o.containment.constructor == Array) { |
| 3085 | + this.containment = o.containment; |
| 3086 | + } |
| 3087 | + |
| 3088 | + }, |
| 3089 | + |
| 3090 | + _convertPositionTo: function(d, pos) { |
| 3091 | + |
| 3092 | + if(!pos) pos = this.position; |
| 3093 | + var mod = d == "absolute" ? 1 : -1; |
| 3094 | + 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); |
| 3095 | + |
| 3096 | + return { |
| 3097 | + top: ( |
| 3098 | + pos.top // The absolute mouse position |
| 3099 | + + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
| 3100 | + + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
| 3101 | + - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) |
| 3102 | + ), |
| 3103 | + left: ( |
| 3104 | + pos.left // The absolute mouse position |
| 3105 | + + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
| 3106 | + + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
| 3107 | + - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) |
| 3108 | + ) |
| 3109 | + }; |
| 3110 | + |
| 3111 | + }, |
| 3112 | + |
| 3113 | + _generatePosition: function(event) { |
| 3114 | + |
| 3115 | + 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); |
| 3116 | + |
| 3117 | + // This is another very weird special case that only happens for relative elements: |
| 3118 | + // 1. If the css position is relative |
| 3119 | + // 2. and the scroll parent is the document or similar to the offset parent |
| 3120 | + // we have to refresh the relative offset during the scroll so there are no jumps |
| 3121 | + if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) { |
| 3122 | + this.offset.relative = this._getRelativeOffset(); |
| 3123 | + } |
| 3124 | + |
| 3125 | + var pageX = event.pageX; |
| 3126 | + var pageY = event.pageY; |
| 3127 | + |
| 3128 | + /* |
| 3129 | + * - Position constraining - |
| 3130 | + * Constrain the position to a mix of grid, containment. |
| 3131 | + */ |
| 3132 | + |
| 3133 | + if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
| 3134 | + |
| 3135 | + if(this.containment) { |
| 3136 | + if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
| 3137 | + if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
| 3138 | + if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
| 3139 | + if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
| 3140 | + } |
| 3141 | + |
| 3142 | + if(o.grid) { |
| 3143 | + var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
| 3144 | + 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; |
| 3145 | + |
| 3146 | + var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
| 3147 | + 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; |
| 3148 | + } |
| 3149 | + |
| 3150 | + } |
| 3151 | + |
| 3152 | + return { |
| 3153 | + top: ( |
| 3154 | + pageY // The absolute mouse position |
| 3155 | + - this.offset.click.top // Click offset (relative to the element) |
| 3156 | + - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
| 3157 | + - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
| 3158 | + + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) |
| 3159 | + ), |
| 3160 | + left: ( |
| 3161 | + pageX // The absolute mouse position |
| 3162 | + - this.offset.click.left // Click offset (relative to the element) |
| 3163 | + - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
| 3164 | + - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
| 3165 | + + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) |
| 3166 | + ) |
| 3167 | + }; |
| 3168 | + |
| 3169 | + }, |
| 3170 | + |
| 3171 | + _clear: function() { |
| 3172 | + this.helper.removeClass("ui-draggable-dragging"); |
| 3173 | + if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); |
| 3174 | + //if($.ui.ddmanager) $.ui.ddmanager.current = null; |
| 3175 | + this.helper = null; |
| 3176 | + this.cancelHelperRemoval = false; |
| 3177 | + }, |
| 3178 | + |
| 3179 | + // From now on bulk stuff - mainly helpers |
| 3180 | + |
| 3181 | + _trigger: function(type, event, ui) { |
| 3182 | + ui = ui || this._uiHash(); |
| 3183 | + $.ui.plugin.call(this, type, [event, ui]); |
| 3184 | + if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins |
| 3185 | + return $.widget.prototype._trigger.call(this, type, event, ui); |
| 3186 | + }, |
| 3187 | + |
| 3188 | + plugins: {}, |
| 3189 | + |
| 3190 | + _uiHash: function(event) { |
| 3191 | + return { |
| 3192 | + helper: this.helper, |
| 3193 | + position: this.position, |
| 3194 | + absolutePosition: this.positionAbs, //deprecated |
| 3195 | + offset: this.positionAbs |
| 3196 | + }; |
| 3197 | + } |
| 3198 | + |
| 3199 | +})); |
| 3200 | + |
| 3201 | +$.extend($.ui.draggable, { |
| 3202 | + version: "1.7.1", |
| 3203 | + eventPrefix: "drag", |
| 3204 | + defaults: { |
| 3205 | + addClasses: true, |
| 3206 | + appendTo: "parent", |
| 3207 | + axis: false, |
| 3208 | + cancel: ":input,option", |
| 3209 | + connectToSortable: false, |
| 3210 | + containment: false, |
| 3211 | + cursor: "auto", |
| 3212 | + cursorAt: false, |
| 3213 | + delay: 0, |
| 3214 | + distance: 1, |
| 3215 | + grid: false, |
| 3216 | + handle: false, |
| 3217 | + helper: "original", |
| 3218 | + iframeFix: false, |
| 3219 | + opacity: false, |
| 3220 | + refreshPositions: false, |
| 3221 | + revert: false, |
| 3222 | + revertDuration: 500, |
| 3223 | + scope: "default", |
| 3224 | + scroll: true, |
| 3225 | + scrollSensitivity: 20, |
| 3226 | + scrollSpeed: 20, |
| 3227 | + snap: false, |
| 3228 | + snapMode: "both", |
| 3229 | + snapTolerance: 20, |
| 3230 | + stack: false, |
| 3231 | + zIndex: false |
| 3232 | + } |
| 3233 | +}); |
| 3234 | + |
| 3235 | +$.ui.plugin.add("draggable", "connectToSortable", { |
| 3236 | + start: function(event, ui) { |
| 3237 | + |
| 3238 | + var inst = $(this).data("draggable"), o = inst.options, |
| 3239 | + uiSortable = $.extend({}, ui, { item: inst.element }); |
| 3240 | + inst.sortables = []; |
| 3241 | + $(o.connectToSortable).each(function() { |
| 3242 | + var sortable = $.data(this, 'sortable'); |
| 3243 | + if (sortable && !sortable.options.disabled) { |
| 3244 | + inst.sortables.push({ |
| 3245 | + instance: sortable, |
| 3246 | + shouldRevert: sortable.options.revert |
| 3247 | + }); |
| 3248 | + sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache |
| 3249 | + sortable._trigger("activate", event, uiSortable); |
| 3250 | + } |
| 3251 | + }); |
| 3252 | + |
| 3253 | + }, |
| 3254 | + stop: function(event, ui) { |
| 3255 | + |
| 3256 | + //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
| 3257 | + var inst = $(this).data("draggable"), |
| 3258 | + uiSortable = $.extend({}, ui, { item: inst.element }); |
| 3259 | + |
| 3260 | + $.each(inst.sortables, function() { |
| 3261 | + if(this.instance.isOver) { |
| 3262 | + |
| 3263 | + this.instance.isOver = 0; |
| 3264 | + |
| 3265 | + inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
| 3266 | + this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
| 3267 | + |
| 3268 | + //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' |
| 3269 | + if(this.shouldRevert) this.instance.options.revert = true; |
| 3270 | + |
| 3271 | + //Trigger the stop of the sortable |
| 3272 | + this.instance._mouseStop(event); |
| 3273 | + |
| 3274 | + this.instance.options.helper = this.instance.options._helper; |
| 3275 | + |
| 3276 | + //If the helper has been the original item, restore properties in the sortable |
| 3277 | + if(inst.options.helper == 'original') |
| 3278 | + this.instance.currentItem.css({ top: 'auto', left: 'auto' }); |
| 3279 | + |
| 3280 | + } else { |
| 3281 | + this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
| 3282 | + this.instance._trigger("deactivate", event, uiSortable); |
| 3283 | + } |
| 3284 | + |
| 3285 | + }); |
| 3286 | + |
| 3287 | + }, |
| 3288 | + drag: function(event, ui) { |
| 3289 | + |
| 3290 | + var inst = $(this).data("draggable"), self = this; |
| 3291 | + |
| 3292 | + var checkPos = function(o) { |
| 3293 | + var dyClick = this.offset.click.top, dxClick = this.offset.click.left; |
| 3294 | + var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; |
| 3295 | + var itemHeight = o.height, itemWidth = o.width; |
| 3296 | + var itemTop = o.top, itemLeft = o.left; |
| 3297 | + |
| 3298 | + return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); |
| 3299 | + }; |
| 3300 | + |
| 3301 | + $.each(inst.sortables, function(i) { |
| 3302 | + |
| 3303 | + //Copy over some variables to allow calling the sortable's native _intersectsWith |
| 3304 | + this.instance.positionAbs = inst.positionAbs; |
| 3305 | + this.instance.helperProportions = inst.helperProportions; |
| 3306 | + this.instance.offset.click = inst.offset.click; |
| 3307 | + |
| 3308 | + if(this.instance._intersectsWith(this.instance.containerCache)) { |
| 3309 | + |
| 3310 | + //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
| 3311 | + if(!this.instance.isOver) { |
| 3312 | + |
| 3313 | + this.instance.isOver = 1; |
| 3314 | + //Now we fake the start of dragging for the sortable instance, |
| 3315 | + //by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
| 3316 | + //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) |
| 3317 | + this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); |
| 3318 | + this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
| 3319 | + this.instance.options.helper = function() { return ui.helper[0]; }; |
| 3320 | + |
| 3321 | + event.target = this.instance.currentItem[0]; |
| 3322 | + this.instance._mouseCapture(event, true); |
| 3323 | + this.instance._mouseStart(event, true, true); |
| 3324 | + |
| 3325 | + //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes |
| 3326 | + this.instance.offset.click.top = inst.offset.click.top; |
| 3327 | + this.instance.offset.click.left = inst.offset.click.left; |
| 3328 | + this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; |
| 3329 | + this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; |
| 3330 | + |
| 3331 | + inst._trigger("toSortable", event); |
| 3332 | + inst.dropped = this.instance.element; //draggable revert needs that |
| 3333 | + //hack so receive/update callbacks work (mostly) |
| 3334 | + inst.currentItem = inst.element; |
| 3335 | + this.instance.fromOutside = inst; |
| 3336 | + |
| 3337 | + } |
| 3338 | + |
| 3339 | + //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 |
| 3340 | + if(this.instance.currentItem) this.instance._mouseDrag(event); |
| 3341 | + |
| 3342 | + } else { |
| 3343 | + |
| 3344 | + //If it doesn't intersect with the sortable, and it intersected before, |
| 3345 | + //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval |
| 3346 | + if(this.instance.isOver) { |
| 3347 | + |
| 3348 | + this.instance.isOver = 0; |
| 3349 | + this.instance.cancelHelperRemoval = true; |
| 3350 | + |
| 3351 | + //Prevent reverting on this forced stop |
| 3352 | + this.instance.options.revert = false; |
| 3353 | + |
| 3354 | + // The out event needs to be triggered independently |
| 3355 | + this.instance._trigger('out', event, this.instance._uiHash(this.instance)); |
| 3356 | + |
| 3357 | + this.instance._mouseStop(event, true); |
| 3358 | + this.instance.options.helper = this.instance.options._helper; |
| 3359 | + |
| 3360 | + //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
| 3361 | + this.instance.currentItem.remove(); |
| 3362 | + if(this.instance.placeholder) this.instance.placeholder.remove(); |
| 3363 | + |
| 3364 | + inst._trigger("fromSortable", event); |
| 3365 | + inst.dropped = false; //draggable revert needs that |
| 3366 | + } |
| 3367 | + |
| 3368 | + }; |
| 3369 | + |
| 3370 | + }); |
| 3371 | + |
| 3372 | + } |
| 3373 | +}); |
| 3374 | + |
| 3375 | +$.ui.plugin.add("draggable", "cursor", { |
| 3376 | + start: function(event, ui) { |
| 3377 | + var t = $('body'), o = $(this).data('draggable').options; |
| 3378 | + if (t.css("cursor")) o._cursor = t.css("cursor"); |
| 3379 | + t.css("cursor", o.cursor); |
| 3380 | + }, |
| 3381 | + stop: function(event, ui) { |
| 3382 | + var o = $(this).data('draggable').options; |
| 3383 | + if (o._cursor) $('body').css("cursor", o._cursor); |
| 3384 | + } |
| 3385 | +}); |
| 3386 | + |
| 3387 | +$.ui.plugin.add("draggable", "iframeFix", { |
| 3388 | + start: function(event, ui) { |
| 3389 | + var o = $(this).data('draggable').options; |
| 3390 | + $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
| 3391 | + $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>') |
| 3392 | + .css({ |
| 3393 | + width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
| 3394 | + position: "absolute", opacity: "0.001", zIndex: 1000 |
| 3395 | + }) |
| 3396 | + .css($(this).offset()) |
| 3397 | + .appendTo("body"); |
| 3398 | + }); |
| 3399 | + }, |
| 3400 | + stop: function(event, ui) { |
| 3401 | + $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers |
| 3402 | + } |
| 3403 | +}); |
| 3404 | + |
| 3405 | +$.ui.plugin.add("draggable", "opacity", { |
| 3406 | + start: function(event, ui) { |
| 3407 | + var t = $(ui.helper), o = $(this).data('draggable').options; |
| 3408 | + if(t.css("opacity")) o._opacity = t.css("opacity"); |
| 3409 | + t.css('opacity', o.opacity); |
| 3410 | + }, |
| 3411 | + stop: function(event, ui) { |
| 3412 | + var o = $(this).data('draggable').options; |
| 3413 | + if(o._opacity) $(ui.helper).css('opacity', o._opacity); |
| 3414 | + } |
| 3415 | +}); |
| 3416 | + |
| 3417 | +$.ui.plugin.add("draggable", "scroll", { |
| 3418 | + start: function(event, ui) { |
| 3419 | + var i = $(this).data("draggable"); |
| 3420 | + if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); |
| 3421 | + }, |
| 3422 | + drag: function(event, ui) { |
| 3423 | + |
| 3424 | + var i = $(this).data("draggable"), o = i.options, scrolled = false; |
| 3425 | + |
| 3426 | + if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { |
| 3427 | + |
| 3428 | + if(!o.axis || o.axis != 'x') { |
| 3429 | + if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
| 3430 | + i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
| 3431 | + else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) |
| 3432 | + i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
| 3433 | + } |
| 3434 | + |
| 3435 | + if(!o.axis || o.axis != 'y') { |
| 3436 | + if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
| 3437 | + i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
| 3438 | + else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) |
| 3439 | + i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
| 3440 | + } |
| 3441 | + |
| 3442 | + } else { |
| 3443 | + |
| 3444 | + if(!o.axis || o.axis != 'x') { |
| 3445 | + if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
| 3446 | + scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
| 3447 | + else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
| 3448 | + scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
| 3449 | + } |
| 3450 | + |
| 3451 | + if(!o.axis || o.axis != 'y') { |
| 3452 | + if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
| 3453 | + scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
| 3454 | + else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
| 3455 | + scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
| 3456 | + } |
| 3457 | + |
| 3458 | + } |
| 3459 | + |
| 3460 | + if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
| 3461 | + $.ui.ddmanager.prepareOffsets(i, event); |
| 3462 | + |
| 3463 | + } |
| 3464 | +}); |
| 3465 | + |
| 3466 | +$.ui.plugin.add("draggable", "snap", { |
| 3467 | + start: function(event, ui) { |
| 3468 | + |
| 3469 | + var i = $(this).data("draggable"), o = i.options; |
| 3470 | + i.snapElements = []; |
| 3471 | + |
| 3472 | + $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { |
| 3473 | + var $t = $(this); var $o = $t.offset(); |
| 3474 | + if(this != i.element[0]) i.snapElements.push({ |
| 3475 | + item: this, |
| 3476 | + width: $t.outerWidth(), height: $t.outerHeight(), |
| 3477 | + top: $o.top, left: $o.left |
| 3478 | + }); |
| 3479 | + }); |
| 3480 | + |
| 3481 | + }, |
| 3482 | + drag: function(event, ui) { |
| 3483 | + |
| 3484 | + var inst = $(this).data("draggable"), o = inst.options; |
| 3485 | + var d = o.snapTolerance; |
| 3486 | + |
| 3487 | + var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
| 3488 | + y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; |
| 3489 | + |
| 3490 | + for (var i = inst.snapElements.length - 1; i >= 0; i--){ |
| 3491 | + |
| 3492 | + var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, |
| 3493 | + t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; |
| 3494 | + |
| 3495 | + //Yes, I know, this is insane ;) |
| 3496 | + 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))) { |
| 3497 | + 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 }))); |
| 3498 | + inst.snapElements[i].snapping = false; |
| 3499 | + continue; |
| 3500 | + } |
| 3501 | + |
| 3502 | + if(o.snapMode != 'inner') { |
| 3503 | + var ts = Math.abs(t - y2) <= d; |
| 3504 | + var bs = Math.abs(b - y1) <= d; |
| 3505 | + var ls = Math.abs(l - x2) <= d; |
| 3506 | + var rs = Math.abs(r - x1) <= d; |
| 3507 | + if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
| 3508 | + if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
| 3509 | + if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
| 3510 | + if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
| 3511 | + } |
| 3512 | + |
| 3513 | + var first = (ts || bs || ls || rs); |
| 3514 | + |
| 3515 | + if(o.snapMode != 'outer') { |
| 3516 | + var ts = Math.abs(t - y1) <= d; |
| 3517 | + var bs = Math.abs(b - y2) <= d; |
| 3518 | + var ls = Math.abs(l - x1) <= d; |
| 3519 | + var rs = Math.abs(r - x2) <= d; |
| 3520 | + if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
| 3521 | + if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
| 3522 | + if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
| 3523 | + if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
| 3524 | + } |
| 3525 | + |
| 3526 | + if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) |
| 3527 | + (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
| 3528 | + inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
| 3529 | + |
| 3530 | + }; |
| 3531 | + |
| 3532 | + } |
| 3533 | +}); |
| 3534 | + |
| 3535 | +$.ui.plugin.add("draggable", "stack", { |
| 3536 | + start: function(event, ui) { |
| 3537 | + |
| 3538 | + var o = $(this).data("draggable").options; |
| 3539 | + |
| 3540 | + var group = $.makeArray($(o.stack.group)).sort(function(a,b) { |
| 3541 | + return (parseInt($(a).css("zIndex"),10) || o.stack.min) - (parseInt($(b).css("zIndex"),10) || o.stack.min); |
| 3542 | + }); |
| 3543 | + |
| 3544 | + $(group).each(function(i) { |
| 3545 | + this.style.zIndex = o.stack.min + i; |
| 3546 | + }); |
| 3547 | + |
| 3548 | + this[0].style.zIndex = o.stack.min + group.length; |
| 3549 | + |
| 3550 | + } |
| 3551 | +}); |
| 3552 | + |
| 3553 | +$.ui.plugin.add("draggable", "zIndex", { |
| 3554 | + start: function(event, ui) { |
| 3555 | + var t = $(ui.helper), o = $(this).data("draggable").options; |
| 3556 | + if(t.css("zIndex")) o._zIndex = t.css("zIndex"); |
| 3557 | + t.css('zIndex', o.zIndex); |
| 3558 | + }, |
| 3559 | + stop: function(event, ui) { |
| 3560 | + var o = $(this).data("draggable").options; |
| 3561 | + if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); |
| 3562 | + } |
| 3563 | +}); |
| 3564 | + |
| 3565 | +})(jQuery); |
| 3566 | +/* |
| 3567 | + * jQuery UI Resizable 1.7.1 |
| 3568 | + * |
| 3569 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 3570 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 3571 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 3572 | + * |
| 3573 | + * http://docs.jquery.com/UI/Resizables |
| 3574 | + * |
| 3575 | + * Depends: |
| 3576 | + * ui.core.js |
| 3577 | + */ |
| 3578 | +(function($) { |
| 3579 | + |
| 3580 | +$.widget("ui.resizable", $.extend({}, $.ui.mouse, { |
| 3581 | + |
| 3582 | + _init: function() { |
| 3583 | + |
| 3584 | + var self = this, o = this.options; |
| 3585 | + this.element.addClass("ui-resizable"); |
| 3586 | + |
| 3587 | + $.extend(this, { |
| 3588 | + _aspectRatio: !!(o.aspectRatio), |
| 3589 | + aspectRatio: o.aspectRatio, |
| 3590 | + originalElement: this.element, |
| 3591 | + _proportionallyResizeElements: [], |
| 3592 | + _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null |
| 3593 | + }); |
| 3594 | + |
| 3595 | + //Wrap the element if it cannot hold child nodes |
| 3596 | + if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { |
| 3597 | + |
| 3598 | + //Opera fix for relative positioning |
| 3599 | + if (/relative/.test(this.element.css('position')) && $.browser.opera) |
| 3600 | + this.element.css({ position: 'relative', top: 'auto', left: 'auto' }); |
| 3601 | + |
| 3602 | + //Create a wrapper element and set the wrapper to the new current internal element |
| 3603 | + this.element.wrap( |
| 3604 | + $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({ |
| 3605 | + position: this.element.css('position'), |
| 3606 | + width: this.element.outerWidth(), |
| 3607 | + height: this.element.outerHeight(), |
| 3608 | + top: this.element.css('top'), |
| 3609 | + left: this.element.css('left') |
| 3610 | + }) |
| 3611 | + ); |
| 3612 | + |
| 3613 | + //Overwrite the original this.element |
| 3614 | + this.element = this.element.parent().data( |
| 3615 | + "resizable", this.element.data('resizable') |
| 3616 | + ); |
| 3617 | + |
| 3618 | + this.elementIsWrapper = true; |
| 3619 | + |
| 3620 | + //Move margins to the wrapper |
| 3621 | + this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") }); |
| 3622 | + this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); |
| 3623 | + |
| 3624 | + //Prevent Safari textarea resize |
| 3625 | + this.originalResizeStyle = this.originalElement.css('resize'); |
| 3626 | + this.originalElement.css('resize', 'none'); |
| 3627 | + |
| 3628 | + //Push the actual element to our proportionallyResize internal array |
| 3629 | + this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' })); |
| 3630 | + |
| 3631 | + // avoid IE jump (hard set the margin) |
| 3632 | + this.originalElement.css({ margin: this.originalElement.css('margin') }); |
| 3633 | + |
| 3634 | + // fix handlers offset |
| 3635 | + this._proportionallyResize(); |
| 3636 | + |
| 3637 | + } |
| 3638 | + |
| 3639 | + 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' }); |
| 3640 | + if(this.handles.constructor == String) { |
| 3641 | + |
| 3642 | + if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw'; |
| 3643 | + var n = this.handles.split(","); this.handles = {}; |
| 3644 | + |
| 3645 | + for(var i = 0; i < n.length; i++) { |
| 3646 | + |
| 3647 | + var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle; |
| 3648 | + var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>'); |
| 3649 | + |
| 3650 | + // increase zIndex of sw, se, ne, nw axis |
| 3651 | + //TODO : this modifies original option |
| 3652 | + if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex }); |
| 3653 | + |
| 3654 | + //TODO : What's going on here? |
| 3655 | + if ('se' == handle) { |
| 3656 | + axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se'); |
| 3657 | + }; |
| 3658 | + |
| 3659 | + //Insert into internal handles object and append to element |
| 3660 | + this.handles[handle] = '.ui-resizable-'+handle; |
| 3661 | + this.element.append(axis); |
| 3662 | + } |
| 3663 | + |
| 3664 | + } |
| 3665 | + |
| 3666 | + this._renderAxis = function(target) { |
| 3667 | + |
| 3668 | + target = target || this.element; |
| 3669 | + |
| 3670 | + for(var i in this.handles) { |
| 3671 | + |
| 3672 | + if(this.handles[i].constructor == String) |
| 3673 | + this.handles[i] = $(this.handles[i], this.element).show(); |
| 3674 | + |
| 3675 | + //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) |
| 3676 | + if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { |
| 3677 | + |
| 3678 | + var axis = $(this.handles[i], this.element), padWrapper = 0; |
| 3679 | + |
| 3680 | + //Checking the correct pad and border |
| 3681 | + padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
| 3682 | + |
| 3683 | + //The padding type i have to apply... |
| 3684 | + var padPos = [ 'padding', |
| 3685 | + /ne|nw|n/.test(i) ? 'Top' : |
| 3686 | + /se|sw|s/.test(i) ? 'Bottom' : |
| 3687 | + /^e$/.test(i) ? 'Right' : 'Left' ].join(""); |
| 3688 | + |
| 3689 | + target.css(padPos, padWrapper); |
| 3690 | + |
| 3691 | + this._proportionallyResize(); |
| 3692 | + |
| 3693 | + } |
| 3694 | + |
| 3695 | + //TODO: What's that good for? There's not anything to be executed left |
| 3696 | + if(!$(this.handles[i]).length) |
| 3697 | + continue; |
| 3698 | + |
| 3699 | + } |
| 3700 | + }; |
| 3701 | + |
| 3702 | + //TODO: make renderAxis a prototype function |
| 3703 | + this._renderAxis(this.element); |
| 3704 | + |
| 3705 | + this._handles = $('.ui-resizable-handle', this.element) |
| 3706 | + .disableSelection(); |
| 3707 | + |
| 3708 | + //Matching axis name |
| 3709 | + this._handles.mouseover(function() { |
| 3710 | + if (!self.resizing) { |
| 3711 | + if (this.className) |
| 3712 | + var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
| 3713 | + //Axis, default = se |
| 3714 | + self.axis = axis && axis[1] ? axis[1] : 'se'; |
| 3715 | + } |
| 3716 | + }); |
| 3717 | + |
| 3718 | + //If we want to auto hide the elements |
| 3719 | + if (o.autoHide) { |
| 3720 | + this._handles.hide(); |
| 3721 | + $(this.element) |
| 3722 | + .addClass("ui-resizable-autohide") |
| 3723 | + .hover(function() { |
| 3724 | + $(this).removeClass("ui-resizable-autohide"); |
| 3725 | + self._handles.show(); |
| 3726 | + }, |
| 3727 | + function(){ |
| 3728 | + if (!self.resizing) { |
| 3729 | + $(this).addClass("ui-resizable-autohide"); |
| 3730 | + self._handles.hide(); |
| 3731 | + } |
| 3732 | + }); |
| 3733 | + } |
| 3734 | + |
| 3735 | + //Initialize the mouse interaction |
| 3736 | + this._mouseInit(); |
| 3737 | + |
| 3738 | + }, |
| 3739 | + |
| 3740 | + destroy: function() { |
| 3741 | + |
| 3742 | + this._mouseDestroy(); |
| 3743 | + |
| 3744 | + var _destroy = function(exp) { |
| 3745 | + $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
| 3746 | + .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); |
| 3747 | + }; |
| 3748 | + |
| 3749 | + //TODO: Unwrap at same DOM position |
| 3750 | + if (this.elementIsWrapper) { |
| 3751 | + _destroy(this.element); |
| 3752 | + var wrapper = this.element; |
| 3753 | + wrapper.parent().append( |
| 3754 | + this.originalElement.css({ |
| 3755 | + position: wrapper.css('position'), |
| 3756 | + width: wrapper.outerWidth(), |
| 3757 | + height: wrapper.outerHeight(), |
| 3758 | + top: wrapper.css('top'), |
| 3759 | + left: wrapper.css('left') |
| 3760 | + }) |
| 3761 | + ).end().remove(); |
| 3762 | + } |
| 3763 | + |
| 3764 | + this.originalElement.css('resize', this.originalResizeStyle); |
| 3765 | + _destroy(this.originalElement); |
| 3766 | + |
| 3767 | + }, |
| 3768 | + |
| 3769 | + _mouseCapture: function(event) { |
| 3770 | + |
| 3771 | + var handle = false; |
| 3772 | + for(var i in this.handles) { |
| 3773 | + if($(this.handles[i])[0] == event.target) handle = true; |
| 3774 | + } |
| 3775 | + |
| 3776 | + return this.options.disabled || !!handle; |
| 3777 | + |
| 3778 | + }, |
| 3779 | + |
| 3780 | + _mouseStart: function(event) { |
| 3781 | + |
| 3782 | + var o = this.options, iniPos = this.element.position(), el = this.element; |
| 3783 | + |
| 3784 | + this.resizing = true; |
| 3785 | + this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; |
| 3786 | + |
| 3787 | + // bugfix for http://dev.jquery.com/ticket/1749 |
| 3788 | + if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { |
| 3789 | + el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left }); |
| 3790 | + } |
| 3791 | + |
| 3792 | + //Opera fixing relative position |
| 3793 | + if ($.browser.opera && (/relative/).test(el.css('position'))) |
| 3794 | + el.css({ position: 'relative', top: 'auto', left: 'auto' }); |
| 3795 | + |
| 3796 | + this._renderProxy(); |
| 3797 | + |
| 3798 | + var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); |
| 3799 | + |
| 3800 | + if (o.containment) { |
| 3801 | + curleft += $(o.containment).scrollLeft() || 0; |
| 3802 | + curtop += $(o.containment).scrollTop() || 0; |
| 3803 | + } |
| 3804 | + |
| 3805 | + //Store needed variables |
| 3806 | + this.offset = this.helper.offset(); |
| 3807 | + this.position = { left: curleft, top: curtop }; |
| 3808 | + this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
| 3809 | + this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
| 3810 | + this.originalPosition = { left: curleft, top: curtop }; |
| 3811 | + this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; |
| 3812 | + this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
| 3813 | + |
| 3814 | + //Aspect Ratio |
| 3815 | + this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); |
| 3816 | + |
| 3817 | + var cursor = $('.ui-resizable-' + this.axis).css('cursor'); |
| 3818 | + $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor); |
| 3819 | + |
| 3820 | + el.addClass("ui-resizable-resizing"); |
| 3821 | + this._propagate("start", event); |
| 3822 | + return true; |
| 3823 | + }, |
| 3824 | + |
| 3825 | + _mouseDrag: function(event) { |
| 3826 | + |
| 3827 | + //Increase performance, avoid regex |
| 3828 | + var el = this.helper, o = this.options, props = {}, |
| 3829 | + self = this, smp = this.originalMousePosition, a = this.axis; |
| 3830 | + |
| 3831 | + var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; |
| 3832 | + var trigger = this._change[a]; |
| 3833 | + if (!trigger) return false; |
| 3834 | + |
| 3835 | + // Calculate the attrs that will be change |
| 3836 | + var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; |
| 3837 | + |
| 3838 | + if (this._aspectRatio || event.shiftKey) |
| 3839 | + data = this._updateRatio(data, event); |
| 3840 | + |
| 3841 | + data = this._respectSize(data, event); |
| 3842 | + |
| 3843 | + // plugins callbacks need to be called first |
| 3844 | + this._propagate("resize", event); |
| 3845 | + |
| 3846 | + el.css({ |
| 3847 | + top: this.position.top + "px", left: this.position.left + "px", |
| 3848 | + width: this.size.width + "px", height: this.size.height + "px" |
| 3849 | + }); |
| 3850 | + |
| 3851 | + if (!this._helper && this._proportionallyResizeElements.length) |
| 3852 | + this._proportionallyResize(); |
| 3853 | + |
| 3854 | + this._updateCache(data); |
| 3855 | + |
| 3856 | + // calling the user callback at the end |
| 3857 | + this._trigger('resize', event, this.ui()); |
| 3858 | + |
| 3859 | + return false; |
| 3860 | + }, |
| 3861 | + |
| 3862 | + _mouseStop: function(event) { |
| 3863 | + |
| 3864 | + this.resizing = false; |
| 3865 | + var o = this.options, self = this; |
| 3866 | + |
| 3867 | + if(this._helper) { |
| 3868 | + var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
| 3869 | + soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
| 3870 | + soffsetw = ista ? 0 : self.sizeDiff.width; |
| 3871 | + |
| 3872 | + var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
| 3873 | + left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
| 3874 | + top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
| 3875 | + |
| 3876 | + if (!o.animate) |
| 3877 | + this.element.css($.extend(s, { top: top, left: left })); |
| 3878 | + |
| 3879 | + self.helper.height(self.size.height); |
| 3880 | + self.helper.width(self.size.width); |
| 3881 | + |
| 3882 | + if (this._helper && !o.animate) this._proportionallyResize(); |
| 3883 | + } |
| 3884 | + |
| 3885 | + $('body').css('cursor', 'auto'); |
| 3886 | + |
| 3887 | + this.element.removeClass("ui-resizable-resizing"); |
| 3888 | + |
| 3889 | + this._propagate("stop", event); |
| 3890 | + |
| 3891 | + if (this._helper) this.helper.remove(); |
| 3892 | + return false; |
| 3893 | + |
| 3894 | + }, |
| 3895 | + |
| 3896 | + _updateCache: function(data) { |
| 3897 | + var o = this.options; |
| 3898 | + this.offset = this.helper.offset(); |
| 3899 | + if (isNumber(data.left)) this.position.left = data.left; |
| 3900 | + if (isNumber(data.top)) this.position.top = data.top; |
| 3901 | + if (isNumber(data.height)) this.size.height = data.height; |
| 3902 | + if (isNumber(data.width)) this.size.width = data.width; |
| 3903 | + }, |
| 3904 | + |
| 3905 | + _updateRatio: function(data, event) { |
| 3906 | + |
| 3907 | + var o = this.options, cpos = this.position, csize = this.size, a = this.axis; |
| 3908 | + |
| 3909 | + if (data.height) data.width = (csize.height * this.aspectRatio); |
| 3910 | + else if (data.width) data.height = (csize.width / this.aspectRatio); |
| 3911 | + |
| 3912 | + if (a == 'sw') { |
| 3913 | + data.left = cpos.left + (csize.width - data.width); |
| 3914 | + data.top = null; |
| 3915 | + } |
| 3916 | + if (a == 'nw') { |
| 3917 | + data.top = cpos.top + (csize.height - data.height); |
| 3918 | + data.left = cpos.left + (csize.width - data.width); |
| 3919 | + } |
| 3920 | + |
| 3921 | + return data; |
| 3922 | + }, |
| 3923 | + |
| 3924 | + _respectSize: function(data, event) { |
| 3925 | + |
| 3926 | + var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, |
| 3927 | + ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
| 3928 | + isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); |
| 3929 | + |
| 3930 | + if (isminw) data.width = o.minWidth; |
| 3931 | + if (isminh) data.height = o.minHeight; |
| 3932 | + if (ismaxw) data.width = o.maxWidth; |
| 3933 | + if (ismaxh) data.height = o.maxHeight; |
| 3934 | + |
| 3935 | + var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; |
| 3936 | + var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
| 3937 | + |
| 3938 | + if (isminw && cw) data.left = dw - o.minWidth; |
| 3939 | + if (ismaxw && cw) data.left = dw - o.maxWidth; |
| 3940 | + if (isminh && ch) data.top = dh - o.minHeight; |
| 3941 | + if (ismaxh && ch) data.top = dh - o.maxHeight; |
| 3942 | + |
| 3943 | + // fixing jump error on top/left - bug #2330 |
| 3944 | + var isNotwh = !data.width && !data.height; |
| 3945 | + if (isNotwh && !data.left && data.top) data.top = null; |
| 3946 | + else if (isNotwh && !data.top && data.left) data.left = null; |
| 3947 | + |
| 3948 | + return data; |
| 3949 | + }, |
| 3950 | + |
| 3951 | + _proportionallyResize: function() { |
| 3952 | + |
| 3953 | + var o = this.options; |
| 3954 | + if (!this._proportionallyResizeElements.length) return; |
| 3955 | + var element = this.helper || this.element; |
| 3956 | + |
| 3957 | + for (var i=0; i < this._proportionallyResizeElements.length; i++) { |
| 3958 | + |
| 3959 | + var prel = this._proportionallyResizeElements[i]; |
| 3960 | + |
| 3961 | + if (!this.borderDif) { |
| 3962 | + var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], |
| 3963 | + p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; |
| 3964 | + |
| 3965 | + this.borderDif = $.map(b, function(v, i) { |
| 3966 | + var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; |
| 3967 | + return border + padding; |
| 3968 | + }); |
| 3969 | + } |
| 3970 | + |
| 3971 | + if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) |
| 3972 | + continue; |
| 3973 | + |
| 3974 | + prel.css({ |
| 3975 | + height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, |
| 3976 | + width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 |
| 3977 | + }); |
| 3978 | + |
| 3979 | + }; |
| 3980 | + |
| 3981 | + }, |
| 3982 | + |
| 3983 | + _renderProxy: function() { |
| 3984 | + |
| 3985 | + var el = this.element, o = this.options; |
| 3986 | + this.elementOffset = el.offset(); |
| 3987 | + |
| 3988 | + if(this._helper) { |
| 3989 | + |
| 3990 | + this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); |
| 3991 | + |
| 3992 | + // fix ie6 offset TODO: This seems broken |
| 3993 | + var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), |
| 3994 | + pxyoffset = ( ie6 ? 2 : -1 ); |
| 3995 | + |
| 3996 | + this.helper.addClass(this._helper).css({ |
| 3997 | + width: this.element.outerWidth() + pxyoffset, |
| 3998 | + height: this.element.outerHeight() + pxyoffset, |
| 3999 | + position: 'absolute', |
| 4000 | + left: this.elementOffset.left - ie6offset +'px', |
| 4001 | + top: this.elementOffset.top - ie6offset +'px', |
| 4002 | + zIndex: ++o.zIndex //TODO: Don't modify option |
| 4003 | + }); |
| 4004 | + |
| 4005 | + this.helper |
| 4006 | + .appendTo("body") |
| 4007 | + .disableSelection(); |
| 4008 | + |
| 4009 | + } else { |
| 4010 | + this.helper = this.element; |
| 4011 | + } |
| 4012 | + |
| 4013 | + }, |
| 4014 | + |
| 4015 | + _change: { |
| 4016 | + e: function(event, dx, dy) { |
| 4017 | + return { width: this.originalSize.width + dx }; |
| 4018 | + }, |
| 4019 | + w: function(event, dx, dy) { |
| 4020 | + var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
| 4021 | + return { left: sp.left + dx, width: cs.width - dx }; |
| 4022 | + }, |
| 4023 | + n: function(event, dx, dy) { |
| 4024 | + var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
| 4025 | + return { top: sp.top + dy, height: cs.height - dy }; |
| 4026 | + }, |
| 4027 | + s: function(event, dx, dy) { |
| 4028 | + return { height: this.originalSize.height + dy }; |
| 4029 | + }, |
| 4030 | + se: function(event, dx, dy) { |
| 4031 | + return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
| 4032 | + }, |
| 4033 | + sw: function(event, dx, dy) { |
| 4034 | + return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
| 4035 | + }, |
| 4036 | + ne: function(event, dx, dy) { |
| 4037 | + return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
| 4038 | + }, |
| 4039 | + nw: function(event, dx, dy) { |
| 4040 | + return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
| 4041 | + } |
| 4042 | + }, |
| 4043 | + |
| 4044 | + _propagate: function(n, event) { |
| 4045 | + $.ui.plugin.call(this, n, [event, this.ui()]); |
| 4046 | + (n != "resize" && this._trigger(n, event, this.ui())); |
| 4047 | + }, |
| 4048 | + |
| 4049 | + plugins: {}, |
| 4050 | + |
| 4051 | + ui: function() { |
| 4052 | + return { |
| 4053 | + originalElement: this.originalElement, |
| 4054 | + element: this.element, |
| 4055 | + helper: this.helper, |
| 4056 | + position: this.position, |
| 4057 | + size: this.size, |
| 4058 | + originalSize: this.originalSize, |
| 4059 | + originalPosition: this.originalPosition |
| 4060 | + }; |
| 4061 | + } |
| 4062 | + |
| 4063 | +})); |
| 4064 | + |
| 4065 | +$.extend($.ui.resizable, { |
| 4066 | + version: "1.7.1", |
| 4067 | + eventPrefix: "resize", |
| 4068 | + defaults: { |
| 4069 | + alsoResize: false, |
| 4070 | + animate: false, |
| 4071 | + animateDuration: "slow", |
| 4072 | + animateEasing: "swing", |
| 4073 | + aspectRatio: false, |
| 4074 | + autoHide: false, |
| 4075 | + cancel: ":input,option", |
| 4076 | + containment: false, |
| 4077 | + delay: 0, |
| 4078 | + distance: 1, |
| 4079 | + ghost: false, |
| 4080 | + grid: false, |
| 4081 | + handles: "e,s,se", |
| 4082 | + helper: false, |
| 4083 | + maxHeight: null, |
| 4084 | + maxWidth: null, |
| 4085 | + minHeight: 10, |
| 4086 | + minWidth: 10, |
| 4087 | + zIndex: 1000 |
| 4088 | + } |
| 4089 | +}); |
| 4090 | + |
| 4091 | +/* |
| 4092 | + * Resizable Extensions |
| 4093 | + */ |
| 4094 | + |
| 4095 | +$.ui.plugin.add("resizable", "alsoResize", { |
| 4096 | + |
| 4097 | + start: function(event, ui) { |
| 4098 | + |
| 4099 | + var self = $(this).data("resizable"), o = self.options; |
| 4100 | + |
| 4101 | + _store = function(exp) { |
| 4102 | + $(exp).each(function() { |
| 4103 | + $(this).data("resizable-alsoresize", { |
| 4104 | + width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), |
| 4105 | + left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) |
| 4106 | + }); |
| 4107 | + }); |
| 4108 | + }; |
| 4109 | + |
| 4110 | + if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { |
| 4111 | + if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
| 4112 | + else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } |
| 4113 | + }else{ |
| 4114 | + _store(o.alsoResize); |
| 4115 | + } |
| 4116 | + }, |
| 4117 | + |
| 4118 | + resize: function(event, ui){ |
| 4119 | + var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; |
| 4120 | + |
| 4121 | + var delta = { |
| 4122 | + height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, |
| 4123 | + top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 |
| 4124 | + }, |
| 4125 | + |
| 4126 | + _alsoResize = function(exp, c) { |
| 4127 | + $(exp).each(function() { |
| 4128 | + var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; |
| 4129 | + |
| 4130 | + $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { |
| 4131 | + var sum = (start[prop]||0) + (delta[prop]||0); |
| 4132 | + if (sum && sum >= 0) |
| 4133 | + style[prop] = sum || null; |
| 4134 | + }); |
| 4135 | + |
| 4136 | + //Opera fixing relative position |
| 4137 | + if (/relative/.test(el.css('position')) && $.browser.opera) { |
| 4138 | + self._revertToRelativePosition = true; |
| 4139 | + el.css({ position: 'absolute', top: 'auto', left: 'auto' }); |
| 4140 | + } |
| 4141 | + |
| 4142 | + el.css(style); |
| 4143 | + }); |
| 4144 | + }; |
| 4145 | + |
| 4146 | + if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { |
| 4147 | + $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); |
| 4148 | + }else{ |
| 4149 | + _alsoResize(o.alsoResize); |
| 4150 | + } |
| 4151 | + }, |
| 4152 | + |
| 4153 | + stop: function(event, ui){ |
| 4154 | + var self = $(this).data("resizable"); |
| 4155 | + |
| 4156 | + //Opera fixing relative position |
| 4157 | + if (self._revertToRelativePosition && $.browser.opera) { |
| 4158 | + self._revertToRelativePosition = false; |
| 4159 | + el.css({ position: 'relative' }); |
| 4160 | + } |
| 4161 | + |
| 4162 | + $(this).removeData("resizable-alsoresize-start"); |
| 4163 | + } |
| 4164 | +}); |
| 4165 | + |
| 4166 | +$.ui.plugin.add("resizable", "animate", { |
| 4167 | + |
| 4168 | + stop: function(event, ui) { |
| 4169 | + var self = $(this).data("resizable"), o = self.options; |
| 4170 | + |
| 4171 | + var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
| 4172 | + soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
| 4173 | + soffsetw = ista ? 0 : self.sizeDiff.width; |
| 4174 | + |
| 4175 | + var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
| 4176 | + left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
| 4177 | + top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
| 4178 | + |
| 4179 | + self.element.animate( |
| 4180 | + $.extend(style, top && left ? { top: top, left: left } : {}), { |
| 4181 | + duration: o.animateDuration, |
| 4182 | + easing: o.animateEasing, |
| 4183 | + step: function() { |
| 4184 | + |
| 4185 | + var data = { |
| 4186 | + width: parseInt(self.element.css('width'), 10), |
| 4187 | + height: parseInt(self.element.css('height'), 10), |
| 4188 | + top: parseInt(self.element.css('top'), 10), |
| 4189 | + left: parseInt(self.element.css('left'), 10) |
| 4190 | + }; |
| 4191 | + |
| 4192 | + if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height }); |
| 4193 | + |
| 4194 | + // propagating resize, and updating values for each animation step |
| 4195 | + self._updateCache(data); |
| 4196 | + self._propagate("resize", event); |
| 4197 | + |
| 4198 | + } |
| 4199 | + } |
| 4200 | + ); |
| 4201 | + } |
| 4202 | + |
| 4203 | +}); |
| 4204 | + |
| 4205 | +$.ui.plugin.add("resizable", "containment", { |
| 4206 | + |
| 4207 | + start: function(event, ui) { |
| 4208 | + var self = $(this).data("resizable"), o = self.options, el = self.element; |
| 4209 | + var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
| 4210 | + if (!ce) return; |
| 4211 | + |
| 4212 | + self.containerElement = $(ce); |
| 4213 | + |
| 4214 | + if (/document/.test(oc) || oc == document) { |
| 4215 | + self.containerOffset = { left: 0, top: 0 }; |
| 4216 | + self.containerPosition = { left: 0, top: 0 }; |
| 4217 | + |
| 4218 | + self.parentData = { |
| 4219 | + element: $(document), left: 0, top: 0, |
| 4220 | + width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight |
| 4221 | + }; |
| 4222 | + } |
| 4223 | + |
| 4224 | + // i'm a node, so compute top, left, right, bottom |
| 4225 | + else { |
| 4226 | + var element = $(ce), p = []; |
| 4227 | + $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); |
| 4228 | + |
| 4229 | + self.containerOffset = element.offset(); |
| 4230 | + self.containerPosition = element.position(); |
| 4231 | + self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; |
| 4232 | + |
| 4233 | + var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, |
| 4234 | + width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
| 4235 | + |
| 4236 | + self.parentData = { |
| 4237 | + element: ce, left: co.left, top: co.top, width: width, height: height |
| 4238 | + }; |
| 4239 | + } |
| 4240 | + }, |
| 4241 | + |
| 4242 | + resize: function(event, ui) { |
| 4243 | + var self = $(this).data("resizable"), o = self.options, |
| 4244 | + ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, |
| 4245 | + pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; |
| 4246 | + |
| 4247 | + if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; |
| 4248 | + |
| 4249 | + if (cp.left < (self._helper ? co.left : 0)) { |
| 4250 | + self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left)); |
| 4251 | + if (pRatio) self.size.height = self.size.width / o.aspectRatio; |
| 4252 | + self.position.left = o.helper ? co.left : 0; |
| 4253 | + } |
| 4254 | + |
| 4255 | + if (cp.top < (self._helper ? co.top : 0)) { |
| 4256 | + self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top); |
| 4257 | + if (pRatio) self.size.width = self.size.height * o.aspectRatio; |
| 4258 | + self.position.top = self._helper ? co.top : 0; |
| 4259 | + } |
| 4260 | + |
| 4261 | + self.offset.left = self.parentData.left+self.position.left; |
| 4262 | + self.offset.top = self.parentData.top+self.position.top; |
| 4263 | + |
| 4264 | + var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ), |
| 4265 | + hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height ); |
| 4266 | + |
| 4267 | + var isParent = self.containerElement.get(0) == self.element.parent().get(0), |
| 4268 | + isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position')); |
| 4269 | + |
| 4270 | + if(isParent && isOffsetRelative) woset -= self.parentData.left; |
| 4271 | + |
| 4272 | + if (woset + self.size.width >= self.parentData.width) { |
| 4273 | + self.size.width = self.parentData.width - woset; |
| 4274 | + if (pRatio) self.size.height = self.size.width / self.aspectRatio; |
| 4275 | + } |
| 4276 | + |
| 4277 | + if (hoset + self.size.height >= self.parentData.height) { |
| 4278 | + self.size.height = self.parentData.height - hoset; |
| 4279 | + if (pRatio) self.size.width = self.size.height * self.aspectRatio; |
| 4280 | + } |
| 4281 | + }, |
| 4282 | + |
| 4283 | + stop: function(event, ui){ |
| 4284 | + var self = $(this).data("resizable"), o = self.options, cp = self.position, |
| 4285 | + co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; |
| 4286 | + |
| 4287 | + var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; |
| 4288 | + |
| 4289 | + if (self._helper && !o.animate && (/relative/).test(ce.css('position'))) |
| 4290 | + $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
| 4291 | + |
| 4292 | + if (self._helper && !o.animate && (/static/).test(ce.css('position'))) |
| 4293 | + $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
| 4294 | + |
| 4295 | + } |
| 4296 | +}); |
| 4297 | + |
| 4298 | +$.ui.plugin.add("resizable", "ghost", { |
| 4299 | + |
| 4300 | + start: function(event, ui) { |
| 4301 | + |
| 4302 | + var self = $(this).data("resizable"), o = self.options, cs = self.size; |
| 4303 | + |
| 4304 | + self.ghost = self.originalElement.clone(); |
| 4305 | + self.ghost |
| 4306 | + .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }) |
| 4307 | + .addClass('ui-resizable-ghost') |
| 4308 | + .addClass(typeof o.ghost == 'string' ? o.ghost : ''); |
| 4309 | + |
| 4310 | + self.ghost.appendTo(self.helper); |
| 4311 | + |
| 4312 | + }, |
| 4313 | + |
| 4314 | + resize: function(event, ui){ |
| 4315 | + var self = $(this).data("resizable"), o = self.options; |
| 4316 | + if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); |
| 4317 | + }, |
| 4318 | + |
| 4319 | + stop: function(event, ui){ |
| 4320 | + var self = $(this).data("resizable"), o = self.options; |
| 4321 | + if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); |
| 4322 | + } |
| 4323 | + |
| 4324 | +}); |
| 4325 | + |
| 4326 | +$.ui.plugin.add("resizable", "grid", { |
| 4327 | + |
| 4328 | + resize: function(event, ui) { |
| 4329 | + 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; |
| 4330 | + o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; |
| 4331 | + 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); |
| 4332 | + |
| 4333 | + if (/^(se|s|e)$/.test(a)) { |
| 4334 | + self.size.width = os.width + ox; |
| 4335 | + self.size.height = os.height + oy; |
| 4336 | + } |
| 4337 | + else if (/^(ne)$/.test(a)) { |
| 4338 | + self.size.width = os.width + ox; |
| 4339 | + self.size.height = os.height + oy; |
| 4340 | + self.position.top = op.top - oy; |
| 4341 | + } |
| 4342 | + else if (/^(sw)$/.test(a)) { |
| 4343 | + self.size.width = os.width + ox; |
| 4344 | + self.size.height = os.height + oy; |
| 4345 | + self.position.left = op.left - ox; |
| 4346 | + } |
| 4347 | + else { |
| 4348 | + self.size.width = os.width + ox; |
| 4349 | + self.size.height = os.height + oy; |
| 4350 | + self.position.top = op.top - oy; |
| 4351 | + self.position.left = op.left - ox; |
| 4352 | + } |
| 4353 | + } |
| 4354 | + |
| 4355 | +}); |
| 4356 | + |
| 4357 | +var num = function(v) { |
| 4358 | + return parseInt(v, 10) || 0; |
| 4359 | +}; |
| 4360 | + |
| 4361 | +var isNumber = function(value) { |
| 4362 | + return !isNaN(parseInt(value, 10)); |
| 4363 | +}; |
| 4364 | + |
| 4365 | +})(jQuery); |
| 4366 | +/* |
| 4367 | + * jQuery UI Tabs 1.7.1 |
| 4368 | + * |
| 4369 | + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
| 4370 | + * Dual licensed under the MIT (MIT-LICENSE.txt) |
| 4371 | + * and GPL (GPL-LICENSE.txt) licenses. |
| 4372 | + * |
| 4373 | + * http://docs.jquery.com/UI/Tabs |
| 4374 | + * |
| 4375 | + * Depends: |
| 4376 | + * ui.core.js |
| 4377 | + */ |
| 4378 | +(function($) { |
| 4379 | + |
| 4380 | +$.widget("ui.tabs", { |
| 4381 | + |
| 4382 | + _init: function() { |
| 4383 | + if (this.options.deselectable !== undefined) { |
| 4384 | + this.options.collapsible = this.options.deselectable; |
| 4385 | + } |
| 4386 | + this._tabify(true); |
| 4387 | + }, |
| 4388 | + |
| 4389 | + _setData: function(key, value) { |
| 4390 | + if (key == 'selected') { |
| 4391 | + if (this.options.collapsible && value == this.options.selected) { |
| 4392 | + return; |
| 4393 | + } |
| 4394 | + this.select(value); |
| 4395 | + } |
| 4396 | + else { |
| 4397 | + this.options[key] = value; |
| 4398 | + if (key == 'deselectable') { |
| 4399 | + this.options.collapsible = value; |
| 4400 | + } |
| 4401 | + this._tabify(); |
| 4402 | + } |
| 4403 | + }, |
| 4404 | + |
| 4405 | + _tabId: function(a) { |
| 4406 | + return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') || |
| 4407 | + this.options.idPrefix + $.data(a); |
| 4408 | + }, |
| 4409 | + |
| 4410 | + _sanitizeSelector: function(hash) { |
| 4411 | + return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":" |
| 4412 | + }, |
| 4413 | + |
| 4414 | + _cookie: function() { |
| 4415 | + var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + $.data(this.list[0])); |
| 4416 | + return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); |
| 4417 | + }, |
| 4418 | + |
| 4419 | + _ui: function(tab, panel) { |
| 4420 | + return { |
| 4421 | + tab: tab, |
| 4422 | + panel: panel, |
| 4423 | + index: this.anchors.index(tab) |
| 4424 | + }; |
| 4425 | + }, |
| 4426 | + |
| 4427 | + _cleanup: function() { |
| 4428 | + // restore all former loading tabs labels |
| 4429 | + this.lis.filter('.ui-state-processing').removeClass('ui-state-processing') |
| 4430 | + .find('span:data(label.tabs)') |
| 4431 | + .each(function() { |
| 4432 | + var el = $(this); |
| 4433 | + el.html(el.data('label.tabs')).removeData('label.tabs'); |
| 4434 | + }); |
| 4435 | + }, |
| 4436 | + |
| 4437 | + _tabify: function(init) { |
| 4438 | + |
| 4439 | + this.list = this.element.children('ul:first'); |
| 4440 | + this.lis = $('li:has(a[href])', this.list); |
| 4441 | + this.anchors = this.lis.map(function() { return $('a', this)[0]; }); |
| 4442 | + this.panels = $([]); |
| 4443 | + |
| 4444 | + var self = this, o = this.options; |
| 4445 | + |
| 4446 | + var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash |
| 4447 | + this.anchors.each(function(i, a) { |
| 4448 | + var href = $(a).attr('href'); |
| 4449 | + |
| 4450 | + // For dynamically created HTML that contains a hash as href IE < 8 expands |
| 4451 | + // such href to the full page url with hash and then misinterprets tab as ajax. |
| 4452 | + // Same consideration applies for an added tab with a fragment identifier |
| 4453 | + // since a[href=#fragment-identifier] does unexpectedly not match. |
| 4454 | + // Thus normalize href attribute... |
| 4455 | + var hrefBase = href.split('#')[0], baseEl; |
| 4456 | + if (hrefBase && (hrefBase === location.toString().split('#')[0] || |
| 4457 | + (baseEl = $('base')[0]) && hrefBase === baseEl.href)) { |
| 4458 | + href = a.hash; |
| 4459 | + a.href = href; |
| 4460 | + } |
| 4461 | + |
| 4462 | + // inline tab |
| 4463 | + if (fragmentId.test(href)) { |
| 4464 | + self.panels = self.panels.add(self._sanitizeSelector(href)); |
| 4465 | + } |
| 4466 | + |
| 4467 | + // remote tab |
| 4468 | + else if (href != '#') { // prevent loading the page itself if href is just "#" |
| 4469 | + $.data(a, 'href.tabs', href); // required for restore on destroy |
| 4470 | + |
| 4471 | + // TODO until #3808 is fixed strip fragment identifier from url |
| 4472 | + // (IE fails to load from such url) |
| 4473 | + $.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data |
| 4474 | + |
| 4475 | + var id = self._tabId(a); |
| 4476 | + a.href = '#' + id; |
| 4477 | + var $panel = $('#' + id); |
| 4478 | + if (!$panel.length) { |
| 4479 | + $panel = $(o.panelTemplate).attr('id', id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom') |
| 4480 | + .insertAfter(self.panels[i - 1] || self.list); |
| 4481 | + $panel.data('destroy.tabs', true); |
| 4482 | + } |
| 4483 | + self.panels = self.panels.add($panel); |
| 4484 | + } |
| 4485 | + |
| 4486 | + // invalid tab href |
| 4487 | + else { |
| 4488 | + o.disabled.push(i); |
| 4489 | + } |
| 4490 | + }); |
| 4491 | + |
| 4492 | + // initialization from scratch |
| 4493 | + if (init) { |
| 4494 | + |
| 4495 | + // attach necessary classes for styling |
| 4496 | + this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all'); |
| 4497 | + this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); |
| 4498 | + this.lis.addClass('ui-state-default ui-corner-top'); |
| 4499 | + this.panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom'); |
| 4500 | + |
| 4501 | + // Selected tab |
| 4502 | + // use "selected" option or try to retrieve: |
| 4503 | + // 1. from fragment identifier in url |
| 4504 | + // 2. from cookie |
| 4505 | + // 3. from selected class attribute on <li> |
| 4506 | + if (o.selected === undefined) { |
| 4507 | + if (location.hash) { |
| 4508 | + this.anchors.each(function(i, a) { |
| 4509 | + if (a.hash == location.hash) { |
| 4510 | + o.selected = i; |
| 4511 | + return false; // break |
| 4512 | + } |
| 4513 | + }); |
| 4514 | + } |
| 4515 | + if (typeof o.selected != 'number' && o.cookie) { |
| 4516 | + o.selected = parseInt(self._cookie(), 10); |
| 4517 | + } |
| 4518 | + if (typeof o.selected != 'number' && this.lis.filter('.ui-tabs-selected').length) { |
| 4519 | + o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected')); |
| 4520 | + } |
| 4521 | + o.selected = o.selected || 0; |
| 4522 | + } |
| 4523 | + else if (o.selected === null) { // usage of null is deprecated, TODO remove in next release |
| 4524 | + o.selected = -1; |
| 4525 | + } |
| 4526 | + |
| 4527 | + // sanity check - default to first tab... |
| 4528 | + o.selected = ((o.selected >= 0 && this.anchors[o.selected]) || o.selected < 0) ? o.selected : 0; |
| 4529 | + |
| 4530 | + // Take disabling tabs via class attribute from HTML |
| 4531 | + // into account and update option properly. |
| 4532 | + // A selected tab cannot become disabled. |
| 4533 | + o.disabled = $.unique(o.disabled.concat( |
| 4534 | + $.map(this.lis.filter('.ui-state-disabled'), |
| 4535 | + function(n, i) { return self.lis.index(n); } ) |
| 4536 | + )).sort(); |
| 4537 | + |
| 4538 | + if ($.inArray(o.selected, o.disabled) != -1) { |
| 4539 | + o.disabled.splice($.inArray(o.selected, o.disabled), 1); |
| 4540 | + } |
| 4541 | + |
| 4542 | + // highlight selected tab |
| 4543 | + this.panels.addClass('ui-tabs-hide'); |
| 4544 | + this.lis.removeClass('ui-tabs-selected ui-state-active'); |
| 4545 | + if (o.selected >= 0 && this.anchors.length) { // check for length avoids error when initializing empty list |
| 4546 | + this.panels.eq(o.selected).removeClass('ui-tabs-hide'); |
| 4547 | + this.lis.eq(o.selected).addClass('ui-tabs-selected ui-state-active'); |
| 4548 | + |
| 4549 | + // seems to be expected behavior that the show callback is fired |
| 4550 | + self.element.queue("tabs", function() { |
| 4551 | + self._trigger('show', null, self._ui(self.anchors[o.selected], self.panels[o.selected])); |
| 4552 | + }); |
| 4553 | + |
| 4554 | + this.load(o.selected); |
| 4555 | + } |
| 4556 | + |
| 4557 | + // clean up to avoid memory leaks in certain versions of IE 6 |
| 4558 | + $(window).bind('unload', function() { |
| 4559 | + self.lis.add(self.anchors).unbind('.tabs'); |
| 4560 | + self.lis = self.anchors = self.panels = null; |
| 4561 | + }); |
| 4562 | + |
| 4563 | + } |
| 4564 | + // update selected after add/remove |
| 4565 | + else { |
| 4566 | + o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected')); |
| 4567 | + } |
| 4568 | + |
| 4569 | + // update collapsible |
| 4570 | + this.element[o.collapsible ? 'addClass' : 'removeClass']('ui-tabs-collapsible'); |
| 4571 | + |
| 4572 | + // set or update cookie after init and add/remove respectively |
| 4573 | + if (o.cookie) { |
| 4574 | + this._cookie(o.selected, o.cookie); |
| 4575 | + } |
| 4576 | + |
| 4577 | + // disable tabs |
| 4578 | + for (var i = 0, li; (li = this.lis[i]); i++) { |
| 4579 | + $(li)[$.inArray(i, o.disabled) != -1 && |
| 4580 | + !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled'); |
| 4581 | + } |
| 4582 | + |
| 4583 | + // reset cache if switching from cached to not cached |
| 4584 | + if (o.cache === false) { |
| 4585 | + this.anchors.removeData('cache.tabs'); |
| 4586 | + } |
| 4587 | + |
| 4588 | + // remove all handlers before, tabify may run on existing tabs after add or option change |
| 4589 | + this.lis.add(this.anchors).unbind('.tabs'); |
| 4590 | + |
| 4591 | + if (o.event != 'mouseover') { |
| 4592 | + var addState = function(state, el) { |
| 4593 | + if (el.is(':not(.ui-state-disabled)')) { |
| 4594 | + el.addClass('ui-state-' + state); |
| 4595 | + } |
| 4596 | + }; |
| 4597 | + var removeState = function(state, el) { |
| 4598 | + el.removeClass('ui-state-' + state); |
| 4599 | + }; |
| 4600 | + this.lis.bind('mouseover.tabs', function() { |
| 4601 | + addState('hover', $(this)); |
| 4602 | + }); |
| 4603 | + this.lis.bind('mouseout.tabs', function() { |
| 4604 | + removeState('hover', $(this)); |
| 4605 | + }); |
| 4606 | + this.anchors.bind('focus.tabs', function() { |
| 4607 | + addState('focus', $(this).closest('li')); |
| 4608 | + }); |
| 4609 | + this.anchors.bind('blur.tabs', function() { |
| 4610 | + removeState('focus', $(this).closest('li')); |
| 4611 | + }); |
| 4612 | + } |
| 4613 | + |
| 4614 | + // set up animations |
| 4615 | + var hideFx, showFx; |
| 4616 | + if (o.fx) { |
| 4617 | + if ($.isArray(o.fx)) { |
| 4618 | + hideFx = o.fx[0]; |
| 4619 | + showFx = o.fx[1]; |
| 4620 | + } |
| 4621 | + else { |
| 4622 | + hideFx = showFx = o.fx; |
| 4623 | + } |
| 4624 | + } |
| 4625 | + |
| 4626 | + // Reset certain styles left over from animation |
| 4627 | + // and prevent IE's ClearType bug... |
| 4628 | + function resetStyle($el, fx) { |
| 4629 | + $el.css({ display: '' }); |
| 4630 | + if ($.browser.msie && fx.opacity) { |
| 4631 | + $el[0].style.removeAttribute('filter'); |
| 4632 | + } |
| 4633 | + } |
| 4634 | + |
| 4635 | + // Show a tab... |
| 4636 | + var showTab = showFx ? |
| 4637 | + function(clicked, $show) { |
| 4638 | + $(clicked).closest('li').removeClass('ui-state-default').addClass('ui-tabs-selected ui-state-active'); |
| 4639 | + $show.hide().removeClass('ui-tabs-hide') // avoid flicker that way |
| 4640 | + .animate(showFx, showFx.duration || 'normal', function() { |
| 4641 | + resetStyle($show, showFx); |
| 4642 | + self._trigger('show', null, self._ui(clicked, $show[0])); |
| 4643 | + }); |
| 4644 | + } : |
| 4645 | + function(clicked, $show) { |
| 4646 | + $(clicked).closest('li').removeClass('ui-state-default').addClass('ui-tabs-selected ui-state-active'); |
| 4647 | + $show.removeClass('ui-tabs-hide'); |
| 4648 | + self._trigger('show', null, self._ui(clicked, $show[0])); |
| 4649 | + }; |
| 4650 | + |
| 4651 | + // Hide a tab, $show is optional... |
| 4652 | + var hideTab = hideFx ? |
| 4653 | + function(clicked, $hide) { |
| 4654 | + $hide.animate(hideFx, hideFx.duration || 'normal', function() { |
| 4655 | + self.lis.removeClass('ui-tabs-selected ui-state-active').addClass('ui-state-default'); |
| 4656 | + $hide.addClass('ui-tabs-hide'); |
| 4657 | + resetStyle($hide, hideFx); |
| 4658 | + self.element.dequeue("tabs"); |
| 4659 | + }); |
| 4660 | + } : |
| 4661 | + function(clicked, $hide, $show) { |
| 4662 | + self.lis.removeClass('ui-tabs-selected ui-state-active').addClass('ui-state-default'); |
| 4663 | + $hide.addClass('ui-tabs-hide'); |
| 4664 | + self.element.dequeue("tabs"); |
| 4665 | + }; |
| 4666 | + |
| 4667 | + // attach tab event handler, unbind to avoid duplicates from former tabifying... |
| 4668 | + this.anchors.bind(o.event + '.tabs', function() { |
| 4669 | + var el = this, $li = $(this).closest('li'), $hide = self.panels.filter(':not(.ui-tabs-hide)'), |
| 4670 | + $show = $(self._sanitizeSelector(this.hash)); |
| 4671 | + |
| 4672 | + // If tab is already selected and not collapsible or tab disabled or |
| 4673 | + // or is already loading or click callback returns false stop here. |
| 4674 | + // Check if click handler returns false last so that it is not executed |
| 4675 | + // for a disabled or loading tab! |
| 4676 | + if (($li.hasClass('ui-tabs-selected') && !o.collapsible) || |
| 4677 | + $li.hasClass('ui-state-disabled') || |
| 4678 | + $li.hasClass('ui-state-processing') || |
| 4679 | + self._trigger('select', null, self._ui(this, $show[0])) === false) { |
| 4680 | + this.blur(); |
| 4681 | + return false; |
| 4682 | + } |
| 4683 | + |
| 4684 | + o.selected = self.anchors.index(this); |
| 4685 | + |
| 4686 | + self.abort(); |
| 4687 | + |
| 4688 | + // if tab may be closed |
| 4689 | + if (o.collapsible) { |
| 4690 | + if ($li.hasClass('ui-tabs-selected')) { |
| 4691 | + o.selected = -1; |
| 4692 | + |
| 4693 | + if (o.cookie) { |
| 4694 | + self._cookie(o.selected, o.cookie); |
| 4695 | + } |
| 4696 | + |
| 4697 | + self.element.queue("tabs", function() { |
| 4698 | + hideTab(el, $hide); |
| 4699 | + }).dequeue("tabs"); |
| 4700 | + |
| 4701 | + this.blur(); |
| 4702 | + return false; |
| 4703 | + } |
| 4704 | + else if (!$hide.length) { |
| 4705 | + if (o.cookie) { |
| 4706 | + self._cookie(o.selected, o.cookie); |
| 4707 | + } |
| 4708 | + |
| 4709 | + self.element.queue("tabs", function() { |
| 4710 | + showTab(el, $show); |
| 4711 | + }); |
| 4712 | + |
| 4713 | + self.load(self.anchors.index(this)); // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 |
| 4714 | + |
| 4715 | + this.blur(); |
| 4716 | + return false; |
| 4717 | + } |
| 4718 | + } |
| 4719 | + |
| 4720 | + if (o.cookie) { |
| 4721 | + self._cookie(o.selected, o.cookie); |
| 4722 | + } |
| 4723 | + |
| 4724 | + // show new tab |
| 4725 | + if ($show.length) { |
| 4726 | + if ($hide.length) { |
| 4727 | + self.element.queue("tabs", function() { |
| 4728 | + hideTab(el, $hide); |
| 4729 | + }); |
| 4730 | + } |
| 4731 | + self.element.queue("tabs", function() { |
| 4732 | + showTab(el, $show); |
| 4733 | + }); |
| 4734 | + |
| 4735 | + self.load(self.anchors.index(this)); |
| 4736 | + } |
| 4737 | + else { |
| 4738 | + throw 'jQuery UI Tabs: Mismatching fragment identifier.'; |
| 4739 | + } |
| 4740 | + |
| 4741 | + // Prevent IE from keeping other link focussed when using the back button |
| 4742 | + // and remove dotted border from clicked link. This is controlled via CSS |
| 4743 | + // in modern browsers; blur() removes focus from address bar in Firefox |
| 4744 | + // which can become a usability and annoying problem with tabs('rotate'). |
| 4745 | + if ($.browser.msie) { |
| 4746 | + this.blur(); |
| 4747 | + } |
| 4748 | + |
| 4749 | + }); |
| 4750 | + |
| 4751 | + // disable click in any case |
| 4752 | + this.anchors.bind('click.tabs', function(){return false;}); |
| 4753 | + |
| 4754 | + }, |
| 4755 | + |
| 4756 | + destroy: function() { |
| 4757 | + var o = this.options; |
| 4758 | + |
| 4759 | + this.abort(); |
| 4760 | + |
| 4761 | + this.element.unbind('.tabs') |
| 4762 | + .removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible') |
| 4763 | + .removeData('tabs'); |
| 4764 | + |
| 4765 | + this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); |
| 4766 | + |
| 4767 | + this.anchors.each(function() { |
| 4768 | + var href = $.data(this, 'href.tabs'); |
| 4769 | + if (href) { |
| 4770 | + this.href = href; |
| 4771 | + } |
| 4772 | + var $this = $(this).unbind('.tabs'); |
| 4773 | + $.each(['href', 'load', 'cache'], function(i, prefix) { |
| 4774 | + $this.removeData(prefix + '.tabs'); |
| 4775 | + }); |
| 4776 | + }); |
| 4777 | + |
| 4778 | + this.lis.unbind('.tabs').add(this.panels).each(function() { |
| 4779 | + if ($.data(this, 'destroy.tabs')) { |
| 4780 | + $(this).remove(); |
| 4781 | + } |
| 4782 | + else { |
| 4783 | + $(this).removeClass([ |
| 4784 | + 'ui-state-default', |
| 4785 | + 'ui-corner-top', |
| 4786 | + 'ui-tabs-selected', |
| 4787 | + 'ui-state-active', |
| 4788 | + 'ui-state-hover', |
| 4789 | + 'ui-state-focus', |
| 4790 | + 'ui-state-disabled', |
| 4791 | + 'ui-tabs-panel', |
| 4792 | + 'ui-widget-content', |
| 4793 | + 'ui-corner-bottom', |
| 4794 | + 'ui-tabs-hide' |
| 4795 | + ].join(' ')); |
| 4796 | + } |
| 4797 | + }); |
| 4798 | + |
| 4799 | + if (o.cookie) { |
| 4800 | + this._cookie(null, o.cookie); |
| 4801 | + } |
| 4802 | + }, |
| 4803 | + |
| 4804 | + add: function(url, label, index) { |
| 4805 | + if (index === undefined) { |
| 4806 | + index = this.anchors.length; // append by default |
| 4807 | + } |
| 4808 | + |
| 4809 | + var self = this, o = this.options, |
| 4810 | + $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)), |
| 4811 | + id = !url.indexOf('#') ? url.replace('#', '') : this._tabId($('a', $li)[0]); |
| 4812 | + |
| 4813 | + $li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true); |
| 4814 | + |
| 4815 | + // try to find an existing element before creating a new one |
| 4816 | + var $panel = $('#' + id); |
| 4817 | + if (!$panel.length) { |
| 4818 | + $panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true); |
| 4819 | + } |
| 4820 | + $panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide'); |
| 4821 | + |
| 4822 | + if (index >= this.lis.length) { |
| 4823 | + $li.appendTo(this.list); |
| 4824 | + $panel.appendTo(this.list[0].parentNode); |
| 4825 | + } |
| 4826 | + else { |
| 4827 | + $li.insertBefore(this.lis[index]); |
| 4828 | + $panel.insertBefore(this.panels[index]); |
| 4829 | + } |
| 4830 | + |
| 4831 | + o.disabled = $.map(o.disabled, |
| 4832 | + function(n, i) { return n >= index ? ++n : n; }); |
| 4833 | + |
| 4834 | + this._tabify(); |
| 4835 | + |
| 4836 | + if (this.anchors.length == 1) { // after tabify |
| 4837 | + $li.addClass('ui-tabs-selected ui-state-active'); |
| 4838 | + $panel.removeClass('ui-tabs-hide'); |
| 4839 | + this.element.queue("tabs", function() { |
| 4840 | + self._trigger('show', null, self._ui(self.anchors[0], self.panels[0])); |
| 4841 | + }); |
| 4842 | + |
| 4843 | + this.load(0); |
| 4844 | + } |
| 4845 | + |
| 4846 | + // callback |
| 4847 | + this._trigger('add', null, this._ui(this.anchors[index], this.panels[index])); |
| 4848 | + }, |
| 4849 | + |
| 4850 | + remove: function(index) { |
| 4851 | + var o = this.options, $li = this.lis.eq(index).remove(), |
| 4852 | + $panel = this.panels.eq(index).remove(); |
| 4853 | + |
| 4854 | + // If selected tab was removed focus tab to the right or |
| 4855 | + // in case the last tab was removed the tab to the left. |
| 4856 | + if ($li.hasClass('ui-tabs-selected') && this.anchors.length > 1) { |
| 4857 | + this.select(index + (index + 1 < this.anchors.length ? 1 : -1)); |
| 4858 | + } |
| 4859 | + |
| 4860 | + o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }), |
| 4861 | + function(n, i) { return n >= index ? --n : n; }); |
| 4862 | + |
| 4863 | + this._tabify(); |
| 4864 | + |
| 4865 | + // callback |
| 4866 | + this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0])); |
| 4867 | + }, |
| 4868 | + |
| 4869 | + enable: function(index) { |
| 4870 | + var o = this.options; |
| 4871 | + if ($.inArray(index, o.disabled) == -1) { |
| 4872 | + return; |
| 4873 | + } |
| 4874 | + |
| 4875 | + this.lis.eq(index).removeClass('ui-state-disabled'); |
| 4876 | + o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); |
| 4877 | + |
| 4878 | + // callback |
| 4879 | + this._trigger('enable', null, this._ui(this.anchors[index], this.panels[index])); |
| 4880 | + }, |
| 4881 | + |
| 4882 | + disable: function(index) { |
| 4883 | + var self = this, o = this.options; |
| 4884 | + if (index != o.selected) { // cannot disable already selected tab |
| 4885 | + this.lis.eq(index).addClass('ui-state-disabled'); |
| 4886 | + |
| 4887 | + o.disabled.push(index); |
| 4888 | + o.disabled.sort(); |
| 4889 | + |
| 4890 | + // callback |
| 4891 | + this._trigger('disable', null, this._ui(this.anchors[index], this.panels[index])); |
| 4892 | + } |
| 4893 | + }, |
| 4894 | + |
| 4895 | + select: function(index) { |
| 4896 | + if (typeof index == 'string') { |
| 4897 | + index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); |
| 4898 | + } |
| 4899 | + else if (index === null) { // usage of null is deprecated, TODO remove in next release |
| 4900 | + index = -1; |
| 4901 | + } |
| 4902 | + if (index == -1 && this.options.collapsible) { |
| 4903 | + index = this.options.selected; |
| 4904 | + } |
| 4905 | + |
| 4906 | + this.anchors.eq(index).trigger(this.options.event + '.tabs'); |
| 4907 | + }, |
| 4908 | + |
| 4909 | + load: function(index) { |
| 4910 | + var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs'); |
| 4911 | + |
| 4912 | + this.abort(); |
| 4913 | + |
| 4914 | + // not remote or from cache |
| 4915 | + if (!url || this.element.queue("tabs").length !== 0 && $.data(a, 'cache.tabs')) { |
| 4916 | + this.element.dequeue("tabs"); |
| 4917 | + return; |
| 4918 | + } |
| 4919 | + |
| 4920 | + // load remote from here on |
| 4921 | + this.lis.eq(index).addClass('ui-state-processing'); |
| 4922 | + |
| 4923 | + if (o.spinner) { |
| 4924 | + var span = $('span', a); |
| 4925 | + span.data('label.tabs', span.html()).html(o.spinner); |
| 4926 | + } |
| 4927 | + |
| 4928 | + this.xhr = $.ajax($.extend({}, o.ajaxOptions, { |
| 4929 | + url: url, |
| 4930 | + success: function(r, s) { |
| 4931 | + $(self._sanitizeSelector(a.hash)).html(r); |
| 4932 | + |
| 4933 | + // take care of tab labels |
| 4934 | + self._cleanup(); |
| 4935 | + |
| 4936 | + if (o.cache) { |
| 4937 | + $.data(a, 'cache.tabs', true); // if loaded once do not load them again |
| 4938 | + } |
| 4939 | + |
| 4940 | + // callbacks |
| 4941 | + self._trigger('load', null, self._ui(self.anchors[index], self.panels[index])); |
| 4942 | + try { |
| 4943 | + o.ajaxOptions.success(r, s); |
| 4944 | + } |
| 4945 | + catch (e) {} |
| 4946 | + |
| 4947 | + // last, so that load event is fired before show... |
| 4948 | + self.element.dequeue("tabs"); |
| 4949 | + } |
| 4950 | + })); |
| 4951 | + }, |
| 4952 | + |
| 4953 | + abort: function() { |
| 4954 | + // stop possibly running animations |
| 4955 | + this.element.queue([]); |
| 4956 | + this.panels.stop(false, true); |
| 4957 | + |
| 4958 | + // terminate pending requests from other tabs |
| 4959 | + if (this.xhr) { |
| 4960 | + this.xhr.abort(); |
| 4961 | + delete this.xhr; |
| 4962 | + } |
| 4963 | + |
| 4964 | + // take care of tab labels |
| 4965 | + this._cleanup(); |
| 4966 | + |
| 4967 | + }, |
| 4968 | + |
| 4969 | + url: function(index, url) { |
| 4970 | + this.anchors.eq(index).removeData('cache.tabs').data('load.tabs', url); |
| 4971 | + }, |
| 4972 | + |
| 4973 | + length: function() { |
| 4974 | + return this.anchors.length; |
| 4975 | + } |
| 4976 | + |
| 4977 | +}); |
| 4978 | + |
| 4979 | +$.extend($.ui.tabs, { |
| 4980 | + version: '1.7.1', |
| 4981 | + getter: 'length', |
| 4982 | + defaults: { |
| 4983 | + ajaxOptions: null, |
| 4984 | + cache: false, |
| 4985 | + cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true } |
| 4986 | + collapsible: false, |
| 4987 | + disabled: [], |
| 4988 | + event: 'click', |
| 4989 | + fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 } |
| 4990 | + idPrefix: 'ui-tabs-', |
| 4991 | + panelTemplate: '<div></div>', |
| 4992 | + spinner: '<em>Loading…</em>', |
| 4993 | + tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>' |
| 4994 | + } |
| 4995 | +}); |
| 4996 | + |
| 4997 | +/* |
| 4998 | + * Tabs Extensions |
| 4999 | + */ |
| 5000 | + |
| 5001 | +/* |
| 5002 | + * Rotate |
| 5003 | + */ |
| 5004 | +$.extend($.ui.tabs.prototype, { |
| 5005 | + rotation: null, |
| 5006 | + rotate: function(ms, continuing) { |
| 5007 | + |
| 5008 | + var self = this, o = this.options; |
| 5009 | + |
| 5010 | + var rotate = self._rotate || (self._rotate = function(e) { |
| 5011 | + clearTimeout(self.rotation); |
| 5012 | + self.rotation = setTimeout(function() { |
| 5013 | + var t = o.selected; |
| 5014 | + self.select( ++t < self.anchors.length ? t : 0 ); |
| 5015 | + }, ms); |
| 5016 | + |
| 5017 | + if (e) { |
| 5018 | + e.stopPropagation(); |
| 5019 | + } |
| 5020 | + }); |
| 5021 | + |
| 5022 | + var stop = self._unrotate || (self._unrotate = !continuing ? |
| 5023 | + function(e) { |
| 5024 | + if (e.clientX) { // in case of a true click |
| 5025 | + self.rotate(null); |
| 5026 | + } |
| 5027 | + } : |
| 5028 | + function(e) { |
| 5029 | + t = o.selected; |
| 5030 | + rotate(); |
| 5031 | + }); |
| 5032 | + |
| 5033 | + // start rotation |
| 5034 | + if (ms) { |
| 5035 | + this.element.bind('tabsshow', rotate); |
| 5036 | + this.anchors.bind(o.event + '.tabs', stop); |
| 5037 | + rotate(); |
| 5038 | + } |
| 5039 | + // stop rotation |
| 5040 | + else { |
| 5041 | + clearTimeout(self.rotation); |
| 5042 | + this.element.unbind('tabsshow', rotate); |
| 5043 | + this.anchors.unbind(o.event + '.tabs', stop); |
| 5044 | + delete this._rotate; |
| 5045 | + delete this._unrotate; |
| 5046 | + } |
| 5047 | + } |
| 5048 | +}); |
| 5049 | + |
| 5050 | +})(jQuery); |
| 5051 | +/* |
3 | 5052 | * jQuery Asynchronous Plugin 1.0 |
4 | 5053 | * |
5 | 5054 | * Copyright (c) 2008 Vincent Robert (genezys.net) |
— | — | @@ -2239,6 +7288,15 @@ |
2240 | 7289 | } ) ); |
2241 | 7290 | */ |
2242 | 7291 | // Highlight stuff for the first time |
| 7292 | + |
| 7293 | + //IE8 runs this twice, the second time is valid |
| 7294 | + if( $.browser.msie && $.browser.version >= 8 ) { |
| 7295 | + if(!this.isSecondRun){ |
| 7296 | + this.isSecondRun = true; |
| 7297 | + return; |
| 7298 | + } |
| 7299 | + } |
| 7300 | + |
2243 | 7301 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
2244 | 7302 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
2245 | 7303 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -1,5 +1,348 @@ |
2 | | - |
3 | | -(function($){$.whileAsync=function(opts) |
| 2 | +;jQuery.ui||(function($){var _remove=$.fn.remove,isFF2=$.browser.mozilla&&(parseFloat($.browser.version)<1.9);$.ui={version:"1.7.1",plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return;} |
| 3 | +for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css('overflow')=='hidden'){return false;} |
| 4 | +var scroll=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(el[scroll]>0){return true;} |
| 5 | +el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(isFF2){var attr=$.attr,removeAttr=$.fn.removeAttr,ariaNS="http://www.w3.org/2005/07/aaa",ariaState=/^aria-/,ariaRole=/^wairole:/;$.attr=function(elem,name,value){var set=value!==undefined;return(name=='role'?(set?attr.call(this,elem,name,"wairole:"+value):(attr.apply(this,arguments)||"").replace(ariaRole,"")):(ariaState.test(name)?(set?elem.setAttributeNS(ariaNS,name.replace(ariaState,"aaa:"),value):attr.call(this,elem,name.replace(ariaState,"aaa:"))):attr.apply(this,arguments)));};$.fn.removeAttr=function(name){return(ariaState.test(name)?this.each(function(){this.removeAttributeNS(ariaNS,name.replace(ariaState,""));}):removeAttr.call(this,name));};} |
| 6 | +$.fn.extend({remove:function(){$("*",this).add(this).each(function(){$(this).triggerHandler("remove");});return _remove.apply(this,arguments);},enableSelection:function(){return this.attr('unselectable','off').css('MozUserSelect','').unbind('selectstart.ui');},disableSelection:function(){return this.attr('unselectable','on').css('MozUserSelect','none').bind('selectstart.ui',function(){return false;});},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){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));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);} |
| 7 | +return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent;}});$.extend($.expr[':'],{data:function(elem,i,match){return!!$.data(elem,match[3]);},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,'tabindex');return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:'a'==nodeName||'area'==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&!$(element)['area'==nodeName?'parents':'closest'](':hidden').length;},tabbable:function(element){var tabIndex=$.attr(element,'tabindex');return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(':focusable');}});function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);} |
| 8 | +var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));} |
| 9 | +return($.inArray(method,methods)!=-1);} |
| 10 | +$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=='_'){return this;} |
| 11 | +if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);} |
| 12 | +return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options))._init());(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace]=$[namespace]||{};$[namespace][name]=function(element,options){var self=this;this.namespace=namespace;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(event,key,value){if(event.target==element){return self._setData(key,value);}}).bind('getData.'+name,function(event,key){if(event.target==element){return self._getData(key);}}).bind('remove',function(){return self.destroy();});};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').removeAttr('aria-disabled');},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);} |
| 13 | +options={};options[key]=value;} |
| 14 | +$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element |
| 15 | +[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled'+' '+ |
| 16 | +this.namespace+'-state-disabled').attr("aria-disabled",value);}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,event,data){var callback=this.options[type],eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);event=$.Event(event);event.type=eventName;if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop];}} |
| 17 | +this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};$.widget.defaults={disabled:false};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(event){return self._mouseDown(event);}).bind('click.'+this.widgetName,function(event){if(self._preventClickEvent){self._preventClickEvent=false;event.stopImmediatePropagation();return false;}});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');} |
| 18 | +this.started=false;},_mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},_mouseDown:function(event){event.originalEvent=event.originalEvent||{};if(event.originalEvent.mouseHandled){return;} |
| 19 | +(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;} |
| 20 | +this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);} |
| 21 | +if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}} |
| 22 | +this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);} |
| 23 | +if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();} |
| 24 | +if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));} |
| 25 | +return!this._mouseStarted;},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);} |
| 26 | +return false;},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance);},_mouseDelayMet:function(event){return this.mouseDelayMet;},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function($){$.extend($.ui,{datepicker:{version:"1.7.1"}});var PROP_NAME='datepicker';function Datepicker(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this._mainDivId='ui-datepicker-div';this._inlineClass='ui-datepicker-inline';this._appendClass='ui-datepicker-append';this._triggerClass='ui-datepicker-trigger';this._dialogClass='ui-datepicker-dialog';this._disableClass='ui-datepicker-disabled';this._unselectableClass='ui-datepicker-unselectable';this._currentClass='ui-datepicker-current-day';this._dayOverClass='ui-datepicker-days-cell-over';this.regional=[];this.regional['']={closeText:'Done',prevText:'Prev',nextText:'Next',currentText:'Today',monthNames:['January','February','March','April','May','June','July','August','September','October','November','December'],monthNamesShort:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],dayNames:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],dayNamesShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],dayNamesMin:['Su','Mo','Tu','We','Th','Fr','Sa'],dateFormat:'mm/dd/yy',firstDay:0,isRTL:false};this._defaults={showOn:'focus',showAnim:'show',showOptions:{},defaultDate:null,appendText:'',buttonText:'...',buttonImage:'',buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,showMonthAfterYear:false,yearRange:'-10:+10',showOtherMonths:false,calculateWeek:this.iso8601Week,shortYearCutoff:'+10',minDate:null,maxDate:null,duration:'normal',beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:'',altFormat:'',constrainInput:true,showButtonPanel:false};$.extend(this._defaults,this.regional['']);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>');} |
| 27 | +$.extend(Datepicker.prototype,{markerClassName:'hasDatepicker',log:function(){if(this.debug) |
| 28 | +console.log.apply('',arguments);},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this;},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute('date:'+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue);}catch(err){inlineSettings[attrName]=attrValue;}}} |
| 29 | +var nodeName=target.nodeName.toLowerCase();var inline=(nodeName=='div'||nodeName=='span');if(!target.id) |
| 30 | +target.id='dp'+(++this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{});if(nodeName=='input'){this._connectDatepicker(target,inst);}else if(inline){this._inlineDatepicker(target,inst);}},_newInst:function(target,inline){var id=target[0].id.replace(/([:\[\]\.])/g,'\\\\$1');return{id:id,input:target,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:inline,dpDiv:(!inline?this.dpDiv:$('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};},_connectDatepicker:function(target,inst){var input=$(target);inst.trigger=$([]);if(input.hasClass(this.markerClassName)) |
| 31 | +return;var appendText=this._get(inst,'appendText');var isRTL=this._get(inst,'isRTL');if(appendText) |
| 32 | +input[isRTL?'before':'after']('<span class="'+this._appendClass+'">'+appendText+'</span>');var showOn=this._get(inst,'showOn');if(showOn=='focus'||showOn=='both') |
| 33 | +input.focus(this._showDatepicker);if(showOn=='button'||showOn=='both'){var buttonText=this._get(inst,'buttonText');var buttonImage=this._get(inst,'buttonImage');inst.trigger=$(this._get(inst,'buttonImageOnly')?$('<img/>').addClass(this._triggerClass).attr({src:buttonImage,alt:buttonText,title:buttonText}):$('<button type="button"></button>').addClass(this._triggerClass).html(buttonImage==''?buttonText:$('<img/>').attr({src:buttonImage,alt:buttonText,title:buttonText})));input[isRTL?'before':'after'](inst.trigger);inst.trigger.click(function(){if($.datepicker._datepickerShowing&&$.datepicker._lastInput==target) |
| 34 | +$.datepicker._hideDatepicker();else |
| 35 | +$.datepicker._showDatepicker(target);return false;});} |
| 36 | +input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).bind("setData.datepicker",function(event,key,value){inst.settings[key]=value;}).bind("getData.datepicker",function(event,key){return this._get(inst,key);});$.data(target,PROP_NAME,inst);},_inlineDatepicker:function(target,inst){var divSpan=$(target);if(divSpan.hasClass(this.markerClassName)) |
| 37 | +return;divSpan.addClass(this.markerClassName).append(inst.dpDiv).bind("setData.datepicker",function(event,key,value){inst.settings[key]=value;}).bind("getData.datepicker",function(event,key){return this._get(inst,key);});$.data(target,PROP_NAME,inst);this._setDate(inst,this._getDefaultDate(inst));this._updateDatepicker(inst);this._updateAlternate(inst);},_dialogDatepicker:function(input,dateText,onSelect,settings,pos){var inst=this._dialogInst;if(!inst){var id='dp'+(++this.uuid);this._dialogInput=$('<input type="text" id="'+id+'" size="1" style="position: absolute; top: -100px;"/>');this._dialogInput.keydown(this._doKeyDown);$('body').append(this._dialogInput);inst=this._dialogInst=this._newInst(this._dialogInput,false);inst.settings={};$.data(this._dialogInput[0],PROP_NAME,inst);} |
| 38 | +extendRemove(inst.settings,settings||{});this._dialogInput.val(dateText);this._pos=(pos?(pos.length?pos:[pos.pageX,pos.pageY]):null);if(!this._pos){var browserWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;var browserHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[(browserWidth/2)-100+scrollX,(browserHeight/2)-150+scrollY];} |
| 39 | +this._dialogInput.css('left',this._pos[0]+'px').css('top',this._pos[1]+'px');inst.settings.onSelect=onSelect;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);if($.blockUI) |
| 40 | +$.blockUI(this.dpDiv);$.data(this._dialogInput[0],PROP_NAME,inst);return this;},_destroyDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;} |
| 41 | +var nodeName=target.nodeName.toLowerCase();$.removeData(target,PROP_NAME);if(nodeName=='input'){inst.trigger.remove();$target.siblings('.'+this._appendClass).remove().end().removeClass(this.markerClassName).unbind('focus',this._showDatepicker).unbind('keydown',this._doKeyDown).unbind('keypress',this._doKeyPress);}else if(nodeName=='div'||nodeName=='span') |
| 42 | +$target.removeClass(this.markerClassName).empty();},_enableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;} |
| 43 | +var nodeName=target.nodeName.toLowerCase();if(nodeName=='input'){target.disabled=false;inst.trigger.filter("button").each(function(){this.disabled=false;}).end().filter("img").css({opacity:'1.0',cursor:''});} |
| 44 | +else if(nodeName=='div'||nodeName=='span'){var inline=$target.children('.'+this._inlineClass);inline.children().removeClass('ui-state-disabled');} |
| 45 | +this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});},_disableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;} |
| 46 | +var nodeName=target.nodeName.toLowerCase();if(nodeName=='input'){target.disabled=true;inst.trigger.filter("button").each(function(){this.disabled=true;}).end().filter("img").css({opacity:'0.5',cursor:'default'});} |
| 47 | +else if(nodeName=='div'||nodeName=='span'){var inline=$target.children('.'+this._inlineClass);inline.children().addClass('ui-state-disabled');} |
| 48 | +this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});this._disabledInputs[this._disabledInputs.length]=target;},_isDisabledDatepicker:function(target){if(!target){return false;} |
| 49 | +for(var i=0;i<this._disabledInputs.length;i++){if(this._disabledInputs[i]==target) |
| 50 | +return true;} |
| 51 | +return false;},_getInst:function(target){try{return $.data(target,PROP_NAME);} |
| 52 | +catch(err){throw'Missing instance data for this datepicker';}},_optionDatepicker:function(target,name,value){var settings=name||{};if(typeof name=='string'){settings={};settings[name]=value;} |
| 53 | +var inst=this._getInst(target);if(inst){if(this._curInst==inst){this._hideDatepicker(null);} |
| 54 | +extendRemove(inst.settings,settings);var date=new Date();extendRemove(inst,{rangeStart:null,endDay:null,endMonth:null,endYear:null,selectedDay:date.getDate(),selectedMonth:date.getMonth(),selectedYear:date.getFullYear(),currentDay:date.getDate(),currentMonth:date.getMonth(),currentYear:date.getFullYear(),drawMonth:date.getMonth(),drawYear:date.getFullYear()});this._updateDatepicker(inst);}},_changeDatepicker:function(target,name,value){this._optionDatepicker(target,name,value);},_refreshDatepicker:function(target){var inst=this._getInst(target);if(inst){this._updateDatepicker(inst);}},_setDateDatepicker:function(target,date,endDate){var inst=this._getInst(target);if(inst){this._setDate(inst,date,endDate);this._updateDatepicker(inst);this._updateAlternate(inst);}},_getDateDatepicker:function(target){var inst=this._getInst(target);if(inst&&!inst.inline) |
| 55 | +this._setDateFromField(inst);return(inst?this._getDate(inst):null);},_doKeyDown:function(event){var inst=$.datepicker._getInst(event.target);var handled=true;var isRTL=inst.dpDiv.is('.ui-datepicker-rtl');inst._keyEvent=true;if($.datepicker._datepickerShowing) |
| 56 | +switch(event.keyCode){case 9:$.datepicker._hideDatepicker(null,'');break;case 13:var sel=$('td.'+$.datepicker._dayOverClass+', td.'+$.datepicker._currentClass,inst.dpDiv);if(sel[0]) |
| 57 | +$.datepicker._selectDay(event.target,inst.selectedMonth,inst.selectedYear,sel[0]);else |
| 58 | +$.datepicker._hideDatepicker(null,$.datepicker._get(inst,'duration'));return false;break;case 27:$.datepicker._hideDatepicker(null,$.datepicker._get(inst,'duration'));break;case 33:$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,'stepBigMonths'):-$.datepicker._get(inst,'stepMonths')),'M');break;case 34:$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,'stepBigMonths'):+$.datepicker._get(inst,'stepMonths')),'M');break;case 35:if(event.ctrlKey||event.metaKey)$.datepicker._clearDate(event.target);handled=event.ctrlKey||event.metaKey;break;case 36:if(event.ctrlKey||event.metaKey)$.datepicker._gotoToday(event.target);handled=event.ctrlKey||event.metaKey;break;case 37:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,(isRTL?+1:-1),'D');handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey)$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,'stepBigMonths'):-$.datepicker._get(inst,'stepMonths')),'M');break;case 38:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,-7,'D');handled=event.ctrlKey||event.metaKey;break;case 39:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,(isRTL?-1:+1),'D');handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey)$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,'stepBigMonths'):+$.datepicker._get(inst,'stepMonths')),'M');break;case 40:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,+7,'D');handled=event.ctrlKey||event.metaKey;break;default:handled=false;} |
| 59 | +else if(event.keyCode==36&&event.ctrlKey) |
| 60 | +$.datepicker._showDatepicker(this);else{handled=false;} |
| 61 | +if(handled){event.preventDefault();event.stopPropagation();}},_doKeyPress:function(event){var inst=$.datepicker._getInst(event.target);if($.datepicker._get(inst,'constrainInput')){var chars=$.datepicker._possibleChars($.datepicker._get(inst,'dateFormat'));var chr=String.fromCharCode(event.charCode==undefined?event.keyCode:event.charCode);return event.ctrlKey||(chr<' '||!chars||chars.indexOf(chr)>-1);}},_showDatepicker:function(input){input=input.target||input;if(input.nodeName.toLowerCase()!='input') |
| 62 | +input=$('input',input.parentNode)[0];if($.datepicker._isDisabledDatepicker(input)||$.datepicker._lastInput==input) |
| 63 | +return;var inst=$.datepicker._getInst(input);var beforeShow=$.datepicker._get(inst,'beforeShow');extendRemove(inst.settings,(beforeShow?beforeShow.apply(input,[input,inst]):{}));$.datepicker._hideDatepicker(null,'');$.datepicker._lastInput=input;$.datepicker._setDateFromField(inst);if($.datepicker._inDialog) |
| 64 | +input.value='';if(!$.datepicker._pos){$.datepicker._pos=$.datepicker._findPos(input);$.datepicker._pos[1]+=input.offsetHeight;} |
| 65 | +var isFixed=false;$(input).parents().each(function(){isFixed|=$(this).css('position')=='fixed';return!isFixed;});if(isFixed&&$.browser.opera){$.datepicker._pos[0]-=document.documentElement.scrollLeft;$.datepicker._pos[1]-=document.documentElement.scrollTop;} |
| 66 | +var offset={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null;inst.rangeStart=null;inst.dpDiv.css({position:'absolute',display:'block',top:'-1000px'});$.datepicker._updateDatepicker(inst);offset=$.datepicker._checkOffset(inst,offset,isFixed);inst.dpDiv.css({position:($.datepicker._inDialog&&$.blockUI?'static':(isFixed?'fixed':'absolute')),display:'none',left:offset.left+'px',top:offset.top+'px'});if(!inst.inline){var showAnim=$.datepicker._get(inst,'showAnim')||'show';var duration=$.datepicker._get(inst,'duration');var postProcess=function(){$.datepicker._datepickerShowing=true;if($.browser.msie&&parseInt($.browser.version,10)<7) |
| 67 | +$('iframe.ui-datepicker-cover').css({width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4});};if($.effects&&$.effects[showAnim]) |
| 68 | +inst.dpDiv.show(showAnim,$.datepicker._get(inst,'showOptions'),duration,postProcess);else |
| 69 | +inst.dpDiv[showAnim](duration,postProcess);if(duration=='') |
| 70 | +postProcess();if(inst.input[0].type!='hidden') |
| 71 | +inst.input[0].focus();$.datepicker._curInst=inst;}},_updateDatepicker:function(inst){var dims={width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4};var self=this;inst.dpDiv.empty().append(this._generateHTML(inst)).find('iframe.ui-datepicker-cover').css({width:dims.width,height:dims.height}).end().find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a').bind('mouseout',function(){$(this).removeClass('ui-state-hover');if(this.className.indexOf('ui-datepicker-prev')!=-1)$(this).removeClass('ui-datepicker-prev-hover');if(this.className.indexOf('ui-datepicker-next')!=-1)$(this).removeClass('ui-datepicker-next-hover');}).bind('mouseover',function(){if(!self._isDisabledDatepicker(inst.inline?inst.dpDiv.parent()[0]:inst.input[0])){$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');$(this).addClass('ui-state-hover');if(this.className.indexOf('ui-datepicker-prev')!=-1)$(this).addClass('ui-datepicker-prev-hover');if(this.className.indexOf('ui-datepicker-next')!=-1)$(this).addClass('ui-datepicker-next-hover');}}).end().find('.'+this._dayOverClass+' a').trigger('mouseover').end();var numMonths=this._getNumberOfMonths(inst);var cols=numMonths[1];var width=17;if(cols>1){inst.dpDiv.addClass('ui-datepicker-multi-'+cols).css('width',(width*cols)+'em');}else{inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');} |
| 72 | +inst.dpDiv[(numMonths[0]!=1||numMonths[1]!=1?'add':'remove')+'Class']('ui-datepicker-multi');inst.dpDiv[(this._get(inst,'isRTL')?'add':'remove')+'Class']('ui-datepicker-rtl');if(inst.input&&inst.input[0].type!='hidden'&&inst==$.datepicker._curInst) |
| 73 | +$(inst.input[0]).focus();},_checkOffset:function(inst,offset,isFixed){var dpWidth=inst.dpDiv.outerWidth();var dpHeight=inst.dpDiv.outerHeight();var inputWidth=inst.input?inst.input.outerWidth():0;var inputHeight=inst.input?inst.input.outerHeight():0;var viewWidth=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)+$(document).scrollLeft();var viewHeight=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)+$(document).scrollTop();offset.left-=(this._get(inst,'isRTL')?(dpWidth-inputWidth):0);offset.left-=(isFixed&&offset.left==inst.input.offset().left)?$(document).scrollLeft():0;offset.top-=(isFixed&&offset.top==(inst.input.offset().top+inputHeight))?$(document).scrollTop():0;offset.left-=(offset.left+dpWidth>viewWidth&&viewWidth>dpWidth)?Math.abs(offset.left+dpWidth-viewWidth):0;offset.top-=(offset.top+dpHeight>viewHeight&&viewHeight>dpHeight)?Math.abs(offset.top+dpHeight+inputHeight*2-viewHeight):0;return offset;},_findPos:function(obj){while(obj&&(obj.type=='hidden'||obj.nodeType!=1)){obj=obj.nextSibling;} |
| 74 | +var position=$(obj).offset();return[position.left,position.top];},_hideDatepicker:function(input,duration){var inst=this._curInst;if(!inst||(input&&inst!=$.data(input,PROP_NAME))) |
| 75 | +return;if(inst.stayOpen) |
| 76 | +this._selectDate('#'+inst.id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear));inst.stayOpen=false;if(this._datepickerShowing){duration=(duration!=null?duration:this._get(inst,'duration'));var showAnim=this._get(inst,'showAnim');var postProcess=function(){$.datepicker._tidyDialog(inst);};if(duration!=''&&$.effects&&$.effects[showAnim]) |
| 77 | +inst.dpDiv.hide(showAnim,$.datepicker._get(inst,'showOptions'),duration,postProcess);else |
| 78 | +inst.dpDiv[(duration==''?'hide':(showAnim=='slideDown'?'slideUp':(showAnim=='fadeIn'?'fadeOut':'hide')))](duration,postProcess);if(duration=='') |
| 79 | +this._tidyDialog(inst);var onClose=this._get(inst,'onClose');if(onClose) |
| 80 | +onClose.apply((inst.input?inst.input[0]:null),[(inst.input?inst.input.val():''),inst]);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:'absolute',left:'0',top:'-100px'});if($.blockUI){$.unblockUI();$('body').append(this.dpDiv);}} |
| 81 | +this._inDialog=false;} |
| 82 | +this._curInst=null;},_tidyDialog:function(inst){inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');},_checkExternalClick:function(event){if(!$.datepicker._curInst) |
| 83 | +return;var $target=$(event.target);if(($target.parents('#'+$.datepicker._mainDivId).length==0)&&!$target.hasClass($.datepicker.markerClassName)&&!$target.hasClass($.datepicker._triggerClass)&&$.datepicker._datepickerShowing&&!($.datepicker._inDialog&&$.blockUI)) |
| 84 | +$.datepicker._hideDatepicker(null,'');},_adjustDate:function(id,offset,period){var target=$(id);var inst=this._getInst(target[0]);if(this._isDisabledDatepicker(target[0])){return;} |
| 85 | +this._adjustInstDate(inst,offset+ |
| 86 | +(period=='M'?this._get(inst,'showCurrentAtPos'):0),period);this._updateDatepicker(inst);},_gotoToday:function(id){var target=$(id);var inst=this._getInst(target[0]);if(this._get(inst,'gotoCurrent')&&inst.currentDay){inst.selectedDay=inst.currentDay;inst.drawMonth=inst.selectedMonth=inst.currentMonth;inst.drawYear=inst.selectedYear=inst.currentYear;} |
| 87 | +else{var date=new Date();inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();} |
| 88 | +this._notifyChange(inst);this._adjustDate(target);},_selectMonthYear:function(id,select,period){var target=$(id);var inst=this._getInst(target[0]);inst._selectingMonthYear=false;inst['selected'+(period=='M'?'Month':'Year')]=inst['draw'+(period=='M'?'Month':'Year')]=parseInt(select.options[select.selectedIndex].value,10);this._notifyChange(inst);this._adjustDate(target);},_clickMonthYear:function(id){var target=$(id);var inst=this._getInst(target[0]);if(inst.input&&inst._selectingMonthYear&&!$.browser.msie) |
| 89 | +inst.input[0].focus();inst._selectingMonthYear=!inst._selectingMonthYear;},_selectDay:function(id,month,year,td){var target=$(id);if($(td).hasClass(this._unselectableClass)||this._isDisabledDatepicker(target[0])){return;} |
| 90 | +var inst=this._getInst(target[0]);inst.selectedDay=inst.currentDay=$('a',td).html();inst.selectedMonth=inst.currentMonth=month;inst.selectedYear=inst.currentYear=year;if(inst.stayOpen){inst.endDay=inst.endMonth=inst.endYear=null;} |
| 91 | +this._selectDate(id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear));if(inst.stayOpen){inst.rangeStart=this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay));this._updateDatepicker(inst);}},_clearDate:function(id){var target=$(id);var inst=this._getInst(target[0]);inst.stayOpen=false;inst.endDay=inst.endMonth=inst.endYear=inst.rangeStart=null;this._selectDate(target,'');},_selectDate:function(id,dateStr){var target=$(id);var inst=this._getInst(target[0]);dateStr=(dateStr!=null?dateStr:this._formatDate(inst));if(inst.input) |
| 92 | +inst.input.val(dateStr);this._updateAlternate(inst);var onSelect=this._get(inst,'onSelect');if(onSelect) |
| 93 | +onSelect.apply((inst.input?inst.input[0]:null),[dateStr,inst]);else if(inst.input) |
| 94 | +inst.input.trigger('change');if(inst.inline) |
| 95 | +this._updateDatepicker(inst);else if(!inst.stayOpen){this._hideDatepicker(null,this._get(inst,'duration'));this._lastInput=inst.input[0];if(typeof(inst.input[0])!='object') |
| 96 | +inst.input[0].focus();this._lastInput=null;}},_updateAlternate:function(inst){var altField=this._get(inst,'altField');if(altField){var altFormat=this._get(inst,'altFormat')||this._get(inst,'dateFormat');var date=this._getDate(inst);dateStr=this.formatDate(altFormat,date,this._getFormatConfig(inst));$(altField).each(function(){$(this).val(dateStr);});}},noWeekends:function(date){var day=date.getDay();return[(day>0&&day<6),''];},iso8601Week:function(date){var checkDate=new Date(date.getFullYear(),date.getMonth(),date.getDate());var firstMon=new Date(checkDate.getFullYear(),1-1,4);var firstDay=firstMon.getDay()||7;firstMon.setDate(firstMon.getDate()+1-firstDay);if(firstDay<4&&checkDate<firstMon){checkDate.setDate(checkDate.getDate()-3);return $.datepicker.iso8601Week(checkDate);}else if(checkDate>new Date(checkDate.getFullYear(),12-1,28)){firstDay=new Date(checkDate.getFullYear()+1,1-1,4).getDay()||7;if(firstDay>4&&(checkDate.getDay()||7)<firstDay-3){return 1;}} |
| 97 | +return Math.floor(((checkDate-firstMon)/86400000)/7)+1;},parseDate:function(format,value,settings){if(format==null||value==null) |
| 98 | +throw'Invalid arguments';value=(typeof value=='object'?value.toString():value+'');if(value=='') |
| 99 | +return null;var shortYearCutoff=(settings?settings.shortYearCutoff:null)||this._defaults.shortYearCutoff;var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var year=-1;var month=-1;var day=-1;var doy=-1;var literal=false;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches) |
| 100 | +iFormat++;return matches;};var getNumber=function(match){lookAhead(match);var origSize=(match=='@'?14:(match=='y'?4:(match=='o'?3:2)));var size=origSize;var num=0;while(size>0&&iValue<value.length&&value.charAt(iValue)>='0'&&value.charAt(iValue)<='9'){num=num*10+parseInt(value.charAt(iValue++),10);size--;} |
| 101 | +if(size==origSize) |
| 102 | +throw'Missing number at position '+iValue;return num;};var getName=function(match,shortNames,longNames){var names=(lookAhead(match)?longNames:shortNames);var size=0;for(var j=0;j<names.length;j++) |
| 103 | +size=Math.max(size,names[j].length);var name='';var iInit=iValue;while(size>0&&iValue<value.length){name+=value.charAt(iValue++);for(var i=0;i<names.length;i++) |
| 104 | +if(name==names[i]) |
| 105 | +return i+1;size--;} |
| 106 | +throw'Unknown name at position '+iInit;};var checkLiteral=function(){if(value.charAt(iValue)!=format.charAt(iFormat)) |
| 107 | +throw'Unexpected literal at position '+iValue;iValue++;};var iValue=0;for(var iFormat=0;iFormat<format.length;iFormat++){if(literal) |
| 108 | +if(format.charAt(iFormat)=="'"&&!lookAhead("'")) |
| 109 | +literal=false;else |
| 110 | +checkLiteral();else |
| 111 | +switch(format.charAt(iFormat)){case'd':day=getNumber('d');break;case'D':getName('D',dayNamesShort,dayNames);break;case'o':doy=getNumber('o');break;case'm':month=getNumber('m');break;case'M':month=getName('M',monthNamesShort,monthNames);break;case'y':year=getNumber('y');break;case'@':var date=new Date(getNumber('@'));year=date.getFullYear();month=date.getMonth()+1;day=date.getDate();break;case"'":if(lookAhead("'")) |
| 112 | +checkLiteral();else |
| 113 | +literal=true;break;default:checkLiteral();}} |
| 114 | +if(year==-1) |
| 115 | +year=new Date().getFullYear();else if(year<100) |
| 116 | +year+=new Date().getFullYear()-new Date().getFullYear()%100+ |
| 117 | +(year<=shortYearCutoff?0:-100);if(doy>-1){month=1;day=doy;do{var dim=this._getDaysInMonth(year,month-1);if(day<=dim) |
| 118 | +break;month++;day-=dim;}while(true);} |
| 119 | +var date=this._daylightSavingAdjust(new Date(year,month-1,day));if(date.getFullYear()!=year||date.getMonth()+1!=month||date.getDate()!=day) |
| 120 | +throw'Invalid date';return date;},ATOM:'yy-mm-dd',COOKIE:'D, dd M yy',ISO_8601:'yy-mm-dd',RFC_822:'D, d M y',RFC_850:'DD, dd-M-y',RFC_1036:'D, d M y',RFC_1123:'D, d M yy',RFC_2822:'D, d M yy',RSS:'D, d M y',TIMESTAMP:'@',W3C:'yy-mm-dd',formatDate:function(format,date,settings){if(!date) |
| 121 | +return'';var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches) |
| 122 | +iFormat++;return matches;};var formatNumber=function(match,value,len){var num=''+value;if(lookAhead(match)) |
| 123 | +while(num.length<len) |
| 124 | +num='0'+num;return num;};var formatName=function(match,value,shortNames,longNames){return(lookAhead(match)?longNames[value]:shortNames[value]);};var output='';var literal=false;if(date) |
| 125 | +for(var iFormat=0;iFormat<format.length;iFormat++){if(literal) |
| 126 | +if(format.charAt(iFormat)=="'"&&!lookAhead("'")) |
| 127 | +literal=false;else |
| 128 | +output+=format.charAt(iFormat);else |
| 129 | +switch(format.charAt(iFormat)){case'd':output+=formatNumber('d',date.getDate(),2);break;case'D':output+=formatName('D',date.getDay(),dayNamesShort,dayNames);break;case'o':var doy=date.getDate();for(var m=date.getMonth()-1;m>=0;m--) |
| 130 | +doy+=this._getDaysInMonth(date.getFullYear(),m);output+=formatNumber('o',doy,3);break;case'm':output+=formatNumber('m',date.getMonth()+1,2);break;case'M':output+=formatName('M',date.getMonth(),monthNamesShort,monthNames);break;case'y':output+=(lookAhead('y')?date.getFullYear():(date.getYear()%100<10?'0':'')+date.getYear()%100);break;case'@':output+=date.getTime();break;case"'":if(lookAhead("'")) |
| 131 | +output+="'";else |
| 132 | +literal=true;break;default:output+=format.charAt(iFormat);}} |
| 133 | +return output;},_possibleChars:function(format){var chars='';var literal=false;for(var iFormat=0;iFormat<format.length;iFormat++) |
| 134 | +if(literal) |
| 135 | +if(format.charAt(iFormat)=="'"&&!lookAhead("'")) |
| 136 | +literal=false;else |
| 137 | +chars+=format.charAt(iFormat);else |
| 138 | +switch(format.charAt(iFormat)){case'd':case'm':case'y':case'@':chars+='0123456789';break;case'D':case'M':return null;case"'":if(lookAhead("'")) |
| 139 | +chars+="'";else |
| 140 | +literal=true;break;default:chars+=format.charAt(iFormat);} |
| 141 | +return chars;},_get:function(inst,name){return inst.settings[name]!==undefined?inst.settings[name]:this._defaults[name];},_setDateFromField:function(inst){var dateFormat=this._get(inst,'dateFormat');var dates=inst.input?inst.input.val():null;inst.endDay=inst.endMonth=inst.endYear=null;var date=defaultDate=this._getDefaultDate(inst);var settings=this._getFormatConfig(inst);try{date=this.parseDate(dateFormat,dates,settings)||defaultDate;}catch(event){this.log(event);date=defaultDate;} |
| 142 | +inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();inst.currentDay=(dates?date.getDate():0);inst.currentMonth=(dates?date.getMonth():0);inst.currentYear=(dates?date.getFullYear():0);this._adjustInstDate(inst);},_getDefaultDate:function(inst){var date=this._determineDate(this._get(inst,'defaultDate'),new Date());var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);return date;},_determineDate:function(date,defaultDate){var offsetNumeric=function(offset){var date=new Date();date.setDate(date.getDate()+offset);return date;};var offsetString=function(offset,getDaysInMonth){var date=new Date();var year=date.getFullYear();var month=date.getMonth();var day=date.getDate();var pattern=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;var matches=pattern.exec(offset);while(matches){switch(matches[2]||'d'){case'd':case'D':day+=parseInt(matches[1],10);break;case'w':case'W':day+=parseInt(matches[1],10)*7;break;case'm':case'M':month+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break;case'y':case'Y':year+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break;} |
| 143 | +matches=pattern.exec(offset);} |
| 144 | +return new Date(year,month,day);};date=(date==null?defaultDate:(typeof date=='string'?offsetString(date,this._getDaysInMonth):(typeof date=='number'?(isNaN(date)?defaultDate:offsetNumeric(date)):date)));date=(date&&date.toString()=='Invalid Date'?defaultDate:date);if(date){date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0);} |
| 145 | +return this._daylightSavingAdjust(date);},_daylightSavingAdjust:function(date){if(!date)return null;date.setHours(date.getHours()>12?date.getHours()+2:0);return date;},_setDate:function(inst,date,endDate){var clear=!(date);var origMonth=inst.selectedMonth;var origYear=inst.selectedYear;date=this._determineDate(date,new Date());inst.selectedDay=inst.currentDay=date.getDate();inst.drawMonth=inst.selectedMonth=inst.currentMonth=date.getMonth();inst.drawYear=inst.selectedYear=inst.currentYear=date.getFullYear();if(origMonth!=inst.selectedMonth||origYear!=inst.selectedYear) |
| 146 | +this._notifyChange(inst);this._adjustInstDate(inst);if(inst.input){inst.input.val(clear?'':this._formatDate(inst));}},_getDate:function(inst){var startDate=(!inst.currentYear||(inst.input&&inst.input.val()=='')?null:this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return startDate;},_generateHTML:function(inst){var today=new Date();today=this._daylightSavingAdjust(new Date(today.getFullYear(),today.getMonth(),today.getDate()));var isRTL=this._get(inst,'isRTL');var showButtonPanel=this._get(inst,'showButtonPanel');var hideIfNoPrevNext=this._get(inst,'hideIfNoPrevNext');var navigationAsDateFormat=this._get(inst,'navigationAsDateFormat');var numMonths=this._getNumberOfMonths(inst);var showCurrentAtPos=this._get(inst,'showCurrentAtPos');var stepMonths=this._get(inst,'stepMonths');var stepBigMonths=this._get(inst,'stepBigMonths');var isMultiMonth=(numMonths[0]!=1||numMonths[1]!=1);var currentDate=this._daylightSavingAdjust((!inst.currentDay?new Date(9999,9,9):new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');var drawMonth=inst.drawMonth-showCurrentAtPos;var drawYear=inst.drawYear;if(drawMonth<0){drawMonth+=12;drawYear--;} |
| 147 | +if(maxDate){var maxDraw=this._daylightSavingAdjust(new Date(maxDate.getFullYear(),maxDate.getMonth()-numMonths[1]+1,maxDate.getDate()));maxDraw=(minDate&&maxDraw<minDate?minDate:maxDraw);while(this._daylightSavingAdjust(new Date(drawYear,drawMonth,1))>maxDraw){drawMonth--;if(drawMonth<0){drawMonth=11;drawYear--;}}} |
| 148 | +inst.drawMonth=drawMonth;inst.drawYear=drawYear;var prevText=this._get(inst,'prevText');prevText=(!navigationAsDateFormat?prevText:this.formatDate(prevText,this._daylightSavingAdjust(new Date(drawYear,drawMonth-stepMonths,1)),this._getFormatConfig(inst)));var prev=(this._canAdjustMonth(inst,-1,drawYear,drawMonth)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+'\', -'+stepMonths+', \'M\');"'+' title="'+prevText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'e':'w')+'">'+prevText+'</span></a>':(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>'));var nextText=this._get(inst,'nextText');nextText=(!navigationAsDateFormat?nextText:this.formatDate(nextText,this._daylightSavingAdjust(new Date(drawYear,drawMonth+stepMonths,1)),this._getFormatConfig(inst)));var next=(this._canAdjustMonth(inst,+1,drawYear,drawMonth)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+'\', +'+stepMonths+', \'M\');"'+' title="'+nextText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'w':'e')+'">'+nextText+'</span></a>':(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>'));var currentText=this._get(inst,'currentText');var gotoDate=(this._get(inst,'gotoCurrent')&&inst.currentDay?currentDate:today);currentText=(!navigationAsDateFormat?currentText:this.formatDate(currentText,gotoDate,this._getFormatConfig(inst)));var controls=(!inst.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">'+this._get(inst,'closeText')+'</button>':'');var buttonPanel=(showButtonPanel)?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(isRTL?controls:'')+ |
| 149 | +(this._isInRange(inst,gotoDate)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#'+inst.id+'\');"'+'>'+currentText+'</button>':'')+(isRTL?'':controls)+'</div>':'';var firstDay=parseInt(this._get(inst,'firstDay'),10);firstDay=(isNaN(firstDay)?0:firstDay);var dayNames=this._get(inst,'dayNames');var dayNamesShort=this._get(inst,'dayNamesShort');var dayNamesMin=this._get(inst,'dayNamesMin');var monthNames=this._get(inst,'monthNames');var monthNamesShort=this._get(inst,'monthNamesShort');var beforeShowDay=this._get(inst,'beforeShowDay');var showOtherMonths=this._get(inst,'showOtherMonths');var calculateWeek=this._get(inst,'calculateWeek')||this.iso8601Week;var endDate=inst.endDay?this._daylightSavingAdjust(new Date(inst.endYear,inst.endMonth,inst.endDay)):currentDate;var defaultDate=this._getDefaultDate(inst);var html='';for(var row=0;row<numMonths[0];row++){var group='';for(var col=0;col<numMonths[1];col++){var selectedDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,inst.selectedDay));var cornerClass=' ui-corner-all';var calender='';if(isMultiMonth){calender+='<div class="ui-datepicker-group ui-datepicker-group-';switch(col){case 0:calender+='first';cornerClass=' ui-corner-'+(isRTL?'right':'left');break;case numMonths[1]-1:calender+='last';cornerClass=' ui-corner-'+(isRTL?'left':'right');break;default:calender+='middle';cornerClass='';break;} |
| 150 | +calender+='">';} |
| 151 | +calender+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+cornerClass+'">'+ |
| 152 | +(/all|left/.test(cornerClass)&&row==0?(isRTL?next:prev):'')+ |
| 153 | +(/all|right/.test(cornerClass)&&row==0?(isRTL?prev:next):'')+ |
| 154 | +this._generateMonthYearHeader(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,row>0||col>0,monthNames,monthNamesShort)+'</div><table class="ui-datepicker-calendar"><thead>'+'<tr>';var thead='';for(var dow=0;dow<7;dow++){var day=(dow+firstDay)%7;thead+='<th'+((dow+firstDay+6)%7>=5?' class="ui-datepicker-week-end"':'')+'>'+'<span title="'+dayNames[day]+'">'+dayNamesMin[day]+'</span></th>';} |
| 155 | +calender+=thead+'</tr></thead><tbody>';var daysInMonth=this._getDaysInMonth(drawYear,drawMonth);if(drawYear==inst.selectedYear&&drawMonth==inst.selectedMonth) |
| 156 | +inst.selectedDay=Math.min(inst.selectedDay,daysInMonth);var leadDays=(this._getFirstDayOfMonth(drawYear,drawMonth)-firstDay+7)%7;var numRows=(isMultiMonth?6:Math.ceil((leadDays+daysInMonth)/7));var printDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,1-leadDays));for(var dRow=0;dRow<numRows;dRow++){calender+='<tr>';var tbody='';for(var dow=0;dow<7;dow++){var daySettings=(beforeShowDay?beforeShowDay.apply((inst.input?inst.input[0]:null),[printDate]):[true,'']);var otherMonth=(printDate.getMonth()!=drawMonth);var unselectable=otherMonth||!daySettings[0]||(minDate&&printDate<minDate)||(maxDate&&printDate>maxDate);tbody+='<td class="'+ |
| 157 | +((dow+firstDay+6)%7>=5?' ui-datepicker-week-end':'')+ |
| 158 | +(otherMonth?' ui-datepicker-other-month':'')+ |
| 159 | +((printDate.getTime()==selectedDate.getTime()&&drawMonth==inst.selectedMonth&&inst._keyEvent)||(defaultDate.getTime()==printDate.getTime()&&defaultDate.getTime()==selectedDate.getTime())?' '+this._dayOverClass:'')+ |
| 160 | +(unselectable?' '+this._unselectableClass+' ui-state-disabled':'')+ |
| 161 | +(otherMonth&&!showOtherMonths?'':' '+daySettings[1]+ |
| 162 | +(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?' '+this._currentClass:'')+ |
| 163 | +(printDate.getTime()==today.getTime()?' ui-datepicker-today':''))+'"'+ |
| 164 | +((!otherMonth||showOtherMonths)&&daySettings[2]?' title="'+daySettings[2]+'"':'')+ |
| 165 | +(unselectable?'':' onclick="DP_jQuery.datepicker._selectDay(\'#'+ |
| 166 | +inst.id+'\','+drawMonth+','+drawYear+', this);return false;"')+'>'+ |
| 167 | +(otherMonth?(showOtherMonths?printDate.getDate():' '):(unselectable?'<span class="ui-state-default">'+printDate.getDate()+'</span>':'<a class="ui-state-default'+ |
| 168 | +(printDate.getTime()==today.getTime()?' ui-state-highlight':'')+ |
| 169 | +(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?' ui-state-active':'')+'" href="#">'+printDate.getDate()+'</a>'))+'</td>';printDate.setDate(printDate.getDate()+1);printDate=this._daylightSavingAdjust(printDate);} |
| 170 | +calender+=tbody+'</tr>';} |
| 171 | +drawMonth++;if(drawMonth>11){drawMonth=0;drawYear++;} |
| 172 | +calender+='</tbody></table>'+(isMultiMonth?'</div>'+ |
| 173 | +((numMonths[0]>0&&col==numMonths[1]-1)?'<div class="ui-datepicker-row-break"></div>':''):'');group+=calender;} |
| 174 | +html+=group;} |
| 175 | +html+=buttonPanel+($.browser.msie&&parseInt($.browser.version,10)<7&&!inst.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':'');inst._keyEvent=false;return html;},_generateMonthYearHeader:function(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,secondary,monthNames,monthNamesShort){minDate=(inst.rangeStart&&minDate&&selectedDate<minDate?selectedDate:minDate);var changeMonth=this._get(inst,'changeMonth');var changeYear=this._get(inst,'changeYear');var showMonthAfterYear=this._get(inst,'showMonthAfterYear');var html='<div class="ui-datepicker-title">';var monthHtml='';if(secondary||!changeMonth) |
| 176 | +monthHtml+='<span class="ui-datepicker-month">'+monthNames[drawMonth]+'</span> ';else{var inMinYear=(minDate&&minDate.getFullYear()==drawYear);var inMaxYear=(maxDate&&maxDate.getFullYear()==drawYear);monthHtml+='<select class="ui-datepicker-month" '+'onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+'\', this, \'M\');" '+'onclick="DP_jQuery.datepicker._clickMonthYear(\'#'+inst.id+'\');"'+'>';for(var month=0;month<12;month++){if((!inMinYear||month>=minDate.getMonth())&&(!inMaxYear||month<=maxDate.getMonth())) |
| 177 | +monthHtml+='<option value="'+month+'"'+ |
| 178 | +(month==drawMonth?' selected="selected"':'')+'>'+monthNamesShort[month]+'</option>';} |
| 179 | +monthHtml+='</select>';} |
| 180 | +if(!showMonthAfterYear) |
| 181 | +html+=monthHtml+((secondary||changeMonth||changeYear)&&(!(changeMonth&&changeYear))?' ':'');if(secondary||!changeYear) |
| 182 | +html+='<span class="ui-datepicker-year">'+drawYear+'</span>';else{var years=this._get(inst,'yearRange').split(':');var year=0;var endYear=0;if(years.length!=2){year=drawYear-10;endYear=drawYear+10;}else if(years[0].charAt(0)=='+'||years[0].charAt(0)=='-'){year=drawYear+parseInt(years[0],10);endYear=drawYear+parseInt(years[1],10);}else{year=parseInt(years[0],10);endYear=parseInt(years[1],10);} |
| 183 | +year=(minDate?Math.max(year,minDate.getFullYear()):year);endYear=(maxDate?Math.min(endYear,maxDate.getFullYear()):endYear);html+='<select class="ui-datepicker-year" '+'onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+'\', this, \'Y\');" '+'onclick="DP_jQuery.datepicker._clickMonthYear(\'#'+inst.id+'\');"'+'>';for(;year<=endYear;year++){html+='<option value="'+year+'"'+ |
| 184 | +(year==drawYear?' selected="selected"':'')+'>'+year+'</option>';} |
| 185 | +html+='</select>';} |
| 186 | +if(showMonthAfterYear) |
| 187 | +html+=(secondary||changeMonth||changeYear?' ':'')+monthHtml;html+='</div>';return html;},_adjustInstDate:function(inst,offset,period){var year=inst.drawYear+(period=='Y'?offset:0);var month=inst.drawMonth+(period=='M'?offset:0);var day=Math.min(inst.selectedDay,this._getDaysInMonth(year,month))+ |
| 188 | +(period=='D'?offset:0);var date=this._daylightSavingAdjust(new Date(year,month,day));var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();if(period=='M'||period=='Y') |
| 189 | +this._notifyChange(inst);},_notifyChange:function(inst){var onChange=this._get(inst,'onChangeMonthYear');if(onChange) |
| 190 | +onChange.apply((inst.input?inst.input[0]:null),[inst.selectedYear,inst.selectedMonth+1,inst]);},_getNumberOfMonths:function(inst){var numMonths=this._get(inst,'numberOfMonths');return(numMonths==null?[1,1]:(typeof numMonths=='number'?[1,numMonths]:numMonths));},_getMinMaxDate:function(inst,minMax,checkRange){var date=this._determineDate(this._get(inst,minMax+'Date'),null);return(!checkRange||!inst.rangeStart?date:(!date||inst.rangeStart>date?inst.rangeStart:date));},_getDaysInMonth:function(year,month){return 32-new Date(year,month,32).getDate();},_getFirstDayOfMonth:function(year,month){return new Date(year,month,1).getDay();},_canAdjustMonth:function(inst,offset,curYear,curMonth){var numMonths=this._getNumberOfMonths(inst);var date=this._daylightSavingAdjust(new Date(curYear,curMonth+(offset<0?offset:numMonths[1]),1));if(offset<0) |
| 191 | +date.setDate(this._getDaysInMonth(date.getFullYear(),date.getMonth()));return this._isInRange(inst,date);},_isInRange:function(inst,date){var newMinDate=(!inst.rangeStart?null:this._daylightSavingAdjust(new Date(inst.selectedYear,inst.selectedMonth,inst.selectedDay)));newMinDate=(newMinDate&&inst.rangeStart<newMinDate?inst.rangeStart:newMinDate);var minDate=newMinDate||this._getMinMaxDate(inst,'min');var maxDate=this._getMinMaxDate(inst,'max');return((!minDate||date>=minDate)&&(!maxDate||date<=maxDate));},_getFormatConfig:function(inst){var shortYearCutoff=this._get(inst,'shortYearCutoff');shortYearCutoff=(typeof shortYearCutoff!='string'?shortYearCutoff:new Date().getFullYear()%100+parseInt(shortYearCutoff,10));return{shortYearCutoff:shortYearCutoff,dayNamesShort:this._get(inst,'dayNamesShort'),dayNames:this._get(inst,'dayNames'),monthNamesShort:this._get(inst,'monthNamesShort'),monthNames:this._get(inst,'monthNames')};},_formatDate:function(inst,day,month,year){if(!day){inst.currentDay=inst.selectedDay;inst.currentMonth=inst.selectedMonth;inst.currentYear=inst.selectedYear;} |
| 192 | +var date=(day?(typeof day=='object'?day:this._daylightSavingAdjust(new Date(year,month,day))):this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return this.formatDate(this._get(inst,'dateFormat'),date,this._getFormatConfig(inst));}});function extendRemove(target,props){$.extend(target,props);for(var name in props) |
| 193 | +if(props[name]==null||props[name]==undefined) |
| 194 | +target[name]=props[name];return target;};function isArray(a){return(a&&(($.browser.safari&&typeof a=='object'&&a.length)||(a.constructor&&a.constructor.toString().match(/\Array\(\)/))));};$.fn.datepicker=function(options){if(!$.datepicker.initialized){$(document).mousedown($.datepicker._checkExternalClick).find('body').append($.datepicker.dpDiv);$.datepicker.initialized=true;} |
| 195 | +var otherArgs=Array.prototype.slice.call(arguments,1);if(typeof options=='string'&&(options=='isDisabled'||options=='getDate')) |
| 196 | +return $.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this[0]].concat(otherArgs));return this.each(function(){typeof options=='string'?$.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options);});};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.1";window.DP_jQuery=$;})(jQuery);(function($){var setDataSwitch={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"},uiDialogClasses='ui-dialog '+'ui-widget '+'ui-widget-content '+'ui-corner-all ';$.widget("ui.dialog",{_init:function(){this.originalTitle=this.element.attr('title');var self=this,options=this.options,title=options.title||this.originalTitle||' ',titleId=$.ui.dialog.getTitleId(this.element),uiDialog=(this.uiDialog=$('<div/>')).appendTo(document.body).hide().addClass(uiDialogClasses+options.dialogClass).css({position:'absolute',overflow:'hidden',zIndex:options.zIndex}).attr('tabIndex',-1).css('outline',0).keydown(function(event){(options.closeOnEscape&&event.keyCode&&event.keyCode==$.ui.keyCode.ESCAPE&&self.close(event));}).attr({role:'dialog','aria-labelledby':titleId}).mousedown(function(event){self.moveToTop(false,event);}),uiDialogContent=this.element.show().removeAttr('title').addClass('ui-dialog-content '+'ui-widget-content').appendTo(uiDialog),uiDialogTitlebar=(this.uiDialogTitlebar=$('<div></div>')).addClass('ui-dialog-titlebar '+'ui-widget-header '+'ui-corner-all '+'ui-helper-clearfix').prependTo(uiDialog),uiDialogTitlebarClose=$('<a href="#"/>').addClass('ui-dialog-titlebar-close '+'ui-corner-all').attr('role','button').hover(function(){uiDialogTitlebarClose.addClass('ui-state-hover');},function(){uiDialogTitlebarClose.removeClass('ui-state-hover');}).focus(function(){uiDialogTitlebarClose.addClass('ui-state-focus');}).blur(function(){uiDialogTitlebarClose.removeClass('ui-state-focus');}).mousedown(function(ev){ev.stopPropagation();}).click(function(event){self.close(event);return false;}).appendTo(uiDialogTitlebar),uiDialogTitlebarCloseText=(this.uiDialogTitlebarCloseText=$('<span/>')).addClass('ui-icon '+'ui-icon-closethick').text(options.closeText).appendTo(uiDialogTitlebarClose),uiDialogTitle=$('<span/>').addClass('ui-dialog-title').attr('id',titleId).html(title).prependTo(uiDialogTitlebar);uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();(options.draggable&&$.fn.draggable&&this._makeDraggable());(options.resizable&&$.fn.resizable&&this._makeResizable());this._createButtons(options.buttons);this._isOpen=false;(options.bgiframe&&$.fn.bgiframe&&uiDialog.bgiframe());(options.autoOpen&&this.open());},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind('.dialog').removeData('dialog').removeClass('ui-dialog-content ui-widget-content').hide().appendTo('body');this.uiDialog.remove();(this.originalTitle&&this.element.attr('title',this.originalTitle));},close:function(event){var self=this;if(false===self._trigger('beforeclose',event)){return;} |
| 197 | +(self.overlay&&self.overlay.destroy());self.uiDialog.unbind('keypress.ui-dialog');(self.options.hide?self.uiDialog.hide(self.options.hide,function(){self._trigger('close',event);}):self.uiDialog.hide()&&self._trigger('close',event));$.ui.dialog.overlay.resize();self._isOpen=false;},isOpen:function(){return this._isOpen;},moveToTop:function(force,event){if((this.options.modal&&!force)||(!this.options.stack&&!this.options.modal)){return this._trigger('focus',event);} |
| 198 | +if(this.options.zIndex>$.ui.dialog.maxZ){$.ui.dialog.maxZ=this.options.zIndex;} |
| 199 | +(this.overlay&&this.overlay.$el.css('z-index',$.ui.dialog.overlay.maxZ=++$.ui.dialog.maxZ));var saveScroll={scrollTop:this.element.attr('scrollTop'),scrollLeft:this.element.attr('scrollLeft')};this.uiDialog.css('z-index',++$.ui.dialog.maxZ);this.element.attr(saveScroll);this._trigger('focus',event);},open:function(){if(this._isOpen){return;} |
| 200 | +var options=this.options,uiDialog=this.uiDialog;this.overlay=options.modal?new $.ui.dialog.overlay(this):null;(uiDialog.next().length&&uiDialog.appendTo('body'));this._size();this._position(options.position);uiDialog.show(options.show);this.moveToTop(true);(options.modal&&uiDialog.bind('keypress.ui-dialog',function(event){if(event.keyCode!=$.ui.keyCode.TAB){return;} |
| 201 | +var tabbables=$(':tabbable',this),first=tabbables.filter(':first')[0],last=tabbables.filter(':last')[0];if(event.target==last&&!event.shiftKey){setTimeout(function(){first.focus();},1);}else if(event.target==first&&event.shiftKey){setTimeout(function(){last.focus();},1);}}));$([]).add(uiDialog.find('.ui-dialog-content :tabbable:first')).add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')).add(uiDialog).filter(':first').focus();this._trigger('open');this._isOpen=true;},_createButtons:function(buttons){var self=this,hasButtons=false,uiDialogButtonPane=$('<div></div>').addClass('ui-dialog-buttonpane '+'ui-widget-content '+'ui-helper-clearfix');this.uiDialog.find('.ui-dialog-buttonpane').remove();(typeof buttons=='object'&&buttons!==null&&$.each(buttons,function(){return!(hasButtons=true);}));if(hasButtons){$.each(buttons,function(name,fn){$('<button type="button"></button>').addClass('ui-state-default '+'ui-corner-all').text(name).click(function(){fn.apply(self.element[0],arguments);}).hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');}).focus(function(){$(this).addClass('ui-state-focus');}).blur(function(){$(this).removeClass('ui-state-focus');}).appendTo(uiDialogButtonPane);});uiDialogButtonPane.appendTo(this.uiDialog);}},_makeDraggable:function(){var self=this,options=this.options,heightBeforeDrag;this.uiDialog.draggable({cancel:'.ui-dialog-content',handle:'.ui-dialog-titlebar',containment:'document',start:function(){heightBeforeDrag=options.height;$(this).height($(this).height()).addClass("ui-dialog-dragging");(options.dragStart&&options.dragStart.apply(self.element[0],arguments));},drag:function(){(options.drag&&options.drag.apply(self.element[0],arguments));},stop:function(){$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);(options.dragStop&&options.dragStop.apply(self.element[0],arguments));$.ui.dialog.overlay.resize();}});},_makeResizable:function(handles){handles=(handles===undefined?this.options.resizable:handles);var self=this,options=this.options,resizeHandles=typeof handles=='string'?handles:'n,e,s,w,se,sw,ne,nw';this.uiDialog.resizable({cancel:'.ui-dialog-content',alsoResize:this.element,maxWidth:options.maxWidth,maxHeight:options.maxHeight,minWidth:options.minWidth,minHeight:options.minHeight,start:function(){$(this).addClass("ui-dialog-resizing");(options.resizeStart&&options.resizeStart.apply(self.element[0],arguments));},resize:function(){(options.resize&&options.resize.apply(self.element[0],arguments));},handles:resizeHandles,stop:function(){$(this).removeClass("ui-dialog-resizing");options.height=$(this).height();options.width=$(this).width();(options.resizeStop&&options.resizeStop.apply(self.element[0],arguments));$.ui.dialog.overlay.resize();}}).find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');},_position:function(pos){var wnd=$(window),doc=$(document),pTop=doc.scrollTop(),pLeft=doc.scrollLeft(),minTop=pTop;if($.inArray(pos,['center','top','right','bottom','left'])>=0){pos=[pos=='right'||pos=='left'?pos:'center',pos=='top'||pos=='bottom'?pos:'middle'];} |
| 202 | +if(pos.constructor!=Array){pos=['center','middle'];} |
| 203 | +if(pos[0].constructor==Number){pLeft+=pos[0];}else{switch(pos[0]){case'left':pLeft+=0;break;case'right':pLeft+=wnd.width()-this.uiDialog.outerWidth();break;default:case'center':pLeft+=(wnd.width()-this.uiDialog.outerWidth())/2;}} |
| 204 | +if(pos[1].constructor==Number){pTop+=pos[1];}else{switch(pos[1]){case'top':pTop+=0;break;case'bottom':pTop+=wnd.height()-this.uiDialog.outerHeight();break;default:case'middle':pTop+=(wnd.height()-this.uiDialog.outerHeight())/2;}} |
| 205 | +pTop=Math.max(pTop,minTop);this.uiDialog.css({top:pTop,left:pLeft});},_setData:function(key,value){(setDataSwitch[key]&&this.uiDialog.data(setDataSwitch[key],value));switch(key){case"buttons":this._createButtons(value);break;case"closeText":this.uiDialogTitlebarCloseText.text(value);break;case"dialogClass":this.uiDialog.removeClass(this.options.dialogClass).addClass(uiDialogClasses+value);break;case"draggable":(value?this._makeDraggable():this.uiDialog.draggable('destroy'));break;case"height":this.uiDialog.height(value);break;case"position":this._position(value);break;case"resizable":var uiDialog=this.uiDialog,isResizable=this.uiDialog.is(':data(resizable)');(isResizable&&!value&&uiDialog.resizable('destroy'));(isResizable&&typeof value=='string'&&uiDialog.resizable('option','handles',value));(isResizable||this._makeResizable(value));break;case"title":$(".ui-dialog-title",this.uiDialogTitlebar).html(value||' ');break;case"width":this.uiDialog.width(value);break;} |
| 206 | +$.widget.prototype._setData.apply(this,arguments);},_size:function(){var options=this.options;this.element.css({height:0,minHeight:0,width:'auto'});var nonContentHeight=this.uiDialog.css({height:'auto',width:options.width}).height();this.element.css({minHeight:Math.max(options.minHeight-nonContentHeight,0),height:options.height=='auto'?'auto':Math.max(options.height-nonContentHeight,0)});}});$.extend($.ui.dialog,{version:"1.7.1",defaults:{autoOpen:true,bgiframe:false,buttons:{},closeOnEscape:true,closeText:'close',dialogClass:'',draggable:true,hide:null,height:'auto',maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:'center',resizable:true,show:null,stack:true,title:'',width:300,zIndex:1000},getter:'isOpen',uuid:0,maxZ:0,getTitleId:function($el){return'ui-dialog-title-'+($el.attr('id')||++this.uuid);},overlay:function(dialog){this.$el=$.ui.dialog.overlay.create(dialog);}});$.extend($.ui.dialog.overlay,{instances:[],maxZ:0,events:$.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),function(event){return event+'.dialog-overlay';}).join(' '),create:function(dialog){if(this.instances.length===0){setTimeout(function(){$(document).bind($.ui.dialog.overlay.events,function(event){var dialogZ=$(event.target).parents('.ui-dialog').css('zIndex')||0;return(dialogZ>$.ui.dialog.overlay.maxZ);});},1);$(document).bind('keydown.dialog-overlay',function(event){(dialog.options.closeOnEscape&&event.keyCode&&event.keyCode==$.ui.keyCode.ESCAPE&&dialog.close(event));});$(window).bind('resize.dialog-overlay',$.ui.dialog.overlay.resize);} |
| 207 | +var $el=$('<div></div>').appendTo(document.body).addClass('ui-widget-overlay').css({width:this.width(),height:this.height()});(dialog.options.bgiframe&&$.fn.bgiframe&&$el.bgiframe());this.instances.push($el);return $el;},destroy:function($el){this.instances.splice($.inArray(this.instances,$el),1);if(this.instances.length===0){$([document,window]).unbind('.dialog-overlay');} |
| 208 | +$el.remove();},height:function(){if($.browser.msie&&$.browser.version<7){var scrollHeight=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var offsetHeight=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(scrollHeight<offsetHeight){return $(window).height()+'px';}else{return scrollHeight+'px';}}else{return $(document).height()+'px';}},width:function(){if($.browser.msie&&$.browser.version<7){var scrollWidth=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var offsetWidth=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(scrollWidth<offsetWidth){return $(window).width()+'px';}else{return scrollWidth+'px';}}else{return $(document).width()+'px';}},resize:function(){var $overlays=$([]);$.each($.ui.dialog.overlay.instances,function(){$overlays=$overlays.add(this);});$overlays.css({width:0,height:0}).css({width:$.ui.dialog.overlay.width(),height:$.ui.dialog.overlay.height()});}});$.extend($.ui.dialog.overlay.prototype,{destroy:function(){$.ui.dialog.overlay.destroy(this.$el);}});})(jQuery);(function($){$.widget("ui.draggable",$.extend({},$.ui.mouse,{_init:function(){if(this.options.helper=='original'&&!(/^(?:r|a|f)/).test(this.element.css("position"))) |
| 209 | +this.element[0].style.position='relative';(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit();},destroy:function(){if(!this.element.data('draggable'))return;this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable" |
| 210 | ++" ui-draggable-dragging" |
| 211 | ++" ui-draggable-disabled");this._mouseDestroy();},_mouseCapture:function(event){var o=this.options;if(this.helper||o.disabled||$(event.target).is('.ui-resizable-handle')) |
| 212 | +return false;this.handle=this._getHandle(event);if(!this.handle) |
| 213 | +return false;return true;},_mouseStart:function(event){var o=this.options;this.helper=this._createHelper(event);this._cacheHelperProportions();if($.ui.ddmanager) |
| 214 | +$.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;if(o.cursorAt) |
| 215 | +this._adjustOffsetFromHelper(o.cursorAt);if(o.containment) |
| 216 | +this._setContainment();this._trigger("start",event);this._cacheHelperProportions();if($.ui.ddmanager&&!o.dropBehaviour) |
| 217 | +$.ui.ddmanager.prepareOffsets(this,event);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(event,true);return true;},_mouseDrag:function(event,noPropagation){this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!noPropagation){var ui=this._uiHash();this._trigger('drag',event,ui);this.position=ui.position;} |
| 218 | +if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+'px';if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+'px';if($.ui.ddmanager)$.ui.ddmanager.drag(this,event);return false;},_mouseStop:function(event){var dropped=false;if($.ui.ddmanager&&!this.options.dropBehaviour) |
| 219 | +dropped=$.ui.ddmanager.drop(this,event);if(this.dropped){dropped=this.dropped;this.dropped=false;} |
| 220 | +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))){var self=this;$(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){self._trigger("stop",event);self._clear();});}else{this._trigger("stop",event);this._clear();} |
| 221 | +return false;},_getHandle:function(event){var handle=!this.options.handle||!$(this.options.handle,this.element).length?true:false;$(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==event.target)handle=true;});return handle;},_createHelper:function(event){var o=this.options;var helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event])):(o.helper=='clone'?this.element.clone():this.element);if(!helper.parents('body').length) |
| 222 | +helper.appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo));if(helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(helper.css("position"))) |
| 223 | +helper.css("position","absolute");return helper;},_adjustOffsetFromHelper:function(obj){if(obj.left!=undefined)this.offset.click.left=obj.left+this.margins.left;if(obj.right!=undefined)this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left;if(obj.top!=undefined)this.offset.click.top=obj.top+this.margins.top;if(obj.bottom!=undefined)this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top;},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition=='absolute'&&this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop();} |
| 224 | +if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=='html'&&$.browser.msie)) |
| 225 | +po={top:0,left:0};return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.element.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()};}else{return{top:0,left:0};}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},_setContainment:function(){var o=this.options;if(o.containment=='parent')o.containment=this.helper[0].parentNode;if(o.containment=='document'||o.containment=='window')this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment=='document'?document:window).width()-this.helperProportions.width-this.margins.left,($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!(/^(document|window|parent)$/).test(o.containment)&&o.containment.constructor!=Array){var ce=$(o.containment)[0];if(!ce)return;var co=$(o.containment).offset();var over=($(ce).css("overflow")!='hidden');this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,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,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];}else if(o.containment.constructor==Array){this.containment=o.containment;}},_convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;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);return{top:(pos.top |
| 226 | ++this.offset.relative.top*mod |
| 227 | ++this.offset.parent.top*mod |
| 228 | +-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop()))*mod)),left:(pos.left |
| 229 | ++this.offset.relative.left*mod |
| 230 | ++this.offset.parent.left*mod |
| 231 | +-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod))};},_generatePosition:function(event){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);if(this.cssPosition=='relative'&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset();} |
| 232 | +var pageX=event.pageX;var pageY=event.pageY;if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0])pageX=this.containment[0]+this.offset.click.left;if(event.pageY-this.offset.click.top<this.containment[1])pageY=this.containment[1]+this.offset.click.top;if(event.pageX-this.offset.click.left>this.containment[2])pageX=this.containment[2]+this.offset.click.left;if(event.pageY-this.offset.click.top>this.containment[3])pageY=this.containment[3]+this.offset.click.top;} |
| 233 | +if(o.grid){var top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];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;var left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];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;}} |
| 234 | +return{top:(pageY |
| 235 | +-this.offset.click.top |
| 236 | +-this.offset.relative.top |
| 237 | +-this.offset.parent.top |
| 238 | ++($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop())))),left:(pageX |
| 239 | +-this.offset.click.left |
| 240 | +-this.offset.relative.left |
| 241 | +-this.offset.parent.left |
| 242 | ++($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())))};},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval)this.helper.remove();this.helper=null;this.cancelHelperRemoval=false;},_trigger:function(type,event,ui){ui=ui||this._uiHash();$.ui.plugin.call(this,type,[event,ui]);if(type=="drag")this.positionAbs=this._convertPositionTo("absolute");return $.widget.prototype._trigger.call(this,type,event,ui);},plugins:{},_uiHash:function(event){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,offset:this.positionAbs};}}));$.extend($.ui.draggable,{version:"1.7.1",eventPrefix:"drag",defaults:{addClasses:true,appendTo:"parent",axis:false,cancel:":input,option",connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,delay:0,distance:1,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false}});$.ui.plugin.add("draggable","connectToSortable",{start:function(event,ui){var inst=$(this).data("draggable"),o=inst.options,uiSortable=$.extend({},ui,{item:inst.element});inst.sortables=[];$(o.connectToSortable).each(function(){var sortable=$.data(this,'sortable');if(sortable&&!sortable.options.disabled){inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable._refreshItems();sortable._trigger("activate",event,uiSortable);}});},stop:function(event,ui){var inst=$(this).data("draggable"),uiSortable=$.extend({},ui,{item:inst.element});$.each(inst.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;inst.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(event);this.instance.options.helper=this.instance.options._helper;if(inst.options.helper=='original') |
| 243 | +this.instance.currentItem.css({top:'auto',left:'auto'});}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",event,uiSortable);}});},drag:function(event,ui){var inst=$(this).data("draggable"),self=this;var checkPos=function(o){var dyClick=this.offset.click.top,dxClick=this.offset.click.left;var helperTop=this.positionAbs.top,helperLeft=this.positionAbs.left;var itemHeight=o.height,itemWidth=o.width;var itemTop=o.top,itemLeft=o.left;return $.ui.isOver(helperTop+dyClick,helperLeft+dxClick,itemTop,itemLeft,itemHeight,itemWidth);};$.each(inst.sortables,function(i){this.instance.positionAbs=inst.positionAbs;this.instance.helperProportions=inst.helperProportions;this.instance.offset.click=inst.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=$(self).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return ui.helper[0];};event.target=this.instance.currentItem[0];this.instance._mouseCapture(event,true);this.instance._mouseStart(event,true,true);this.instance.offset.click.top=inst.offset.click.top;this.instance.offset.click.left=inst.offset.click.left;this.instance.offset.parent.left-=inst.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=inst.offset.parent.top-this.instance.offset.parent.top;inst._trigger("toSortable",event);inst.dropped=this.instance.element;inst.currentItem=inst.element;this.instance.fromOutside=inst;} |
| 244 | +if(this.instance.currentItem)this.instance._mouseDrag(event);}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger('out',event,this.instance._uiHash(this.instance));this.instance._mouseStop(event,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder)this.instance.placeholder.remove();inst._trigger("fromSortable",event);inst.dropped=false;}};});}});$.ui.plugin.add("draggable","cursor",{start:function(event,ui){var t=$('body'),o=$(this).data('draggable').options;if(t.css("cursor"))o._cursor=t.css("cursor");t.css("cursor",o.cursor);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._cursor)$('body').css("cursor",o._cursor);}});$.ui.plugin.add("draggable","iframeFix",{start:function(event,ui){var o=$(this).data('draggable').options;$(o.iframeFix===true?"iframe":o.iframeFix).each(function(){$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css($(this).offset()).appendTo("body");});},stop:function(event,ui){$("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","opacity",{start:function(event,ui){var t=$(ui.helper),o=$(this).data('draggable').options;if(t.css("opacity"))o._opacity=t.css("opacity");t.css('opacity',o.opacity);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._opacity)$(ui.helper).css('opacity',o._opacity);}});$.ui.plugin.add("draggable","scroll",{start:function(event,ui){var i=$(this).data("draggable");if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML')i.overflowOffset=i.scrollParent.offset();},drag:function(event,ui){var i=$(this).data("draggable"),o=i.options,scrolled=false;if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML'){if(!o.axis||o.axis!='x'){if((i.overflowOffset.top+i.scrollParent[0].offsetHeight)-event.pageY<o.scrollSensitivity) |
| 245 | +i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop+o.scrollSpeed;else if(event.pageY-i.overflowOffset.top<o.scrollSensitivity) |
| 246 | +i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop-o.scrollSpeed;} |
| 247 | +if(!o.axis||o.axis!='y'){if((i.overflowOffset.left+i.scrollParent[0].offsetWidth)-event.pageX<o.scrollSensitivity) |
| 248 | +i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft+o.scrollSpeed;else if(event.pageX-i.overflowOffset.left<o.scrollSensitivity) |
| 249 | +i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft-o.scrollSpeed;}}else{if(!o.axis||o.axis!='x'){if(event.pageY-$(document).scrollTop()<o.scrollSensitivity) |
| 250 | +scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity) |
| 251 | +scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);} |
| 252 | +if(!o.axis||o.axis!='y'){if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity) |
| 253 | +scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity) |
| 254 | +scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}} |
| 255 | +if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour) |
| 256 | +$.ui.ddmanager.prepareOffsets(i,event);}});$.ui.plugin.add("draggable","snap",{start:function(event,ui){var i=$(this).data("draggable"),o=i.options;i.snapElements=[];$(o.snap.constructor!=String?(o.snap.items||':data(draggable)'):o.snap).each(function(){var $t=$(this);var $o=$t.offset();if(this!=i.element[0])i.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left});});},drag:function(event,ui){var inst=$(this).data("draggable"),o=inst.options;var d=o.snapTolerance;var x1=ui.offset.left,x2=x1+inst.helperProportions.width,y1=ui.offset.top,y2=y1+inst.helperProportions.height;for(var i=inst.snapElements.length-1;i>=0;i--){var l=inst.snapElements[i].left,r=l+inst.snapElements[i].width,t=inst.snapElements[i].top,b=t+inst.snapElements[i].height;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))){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})));inst.snapElements[i].snapping=false;continue;} |
| 257 | +if(o.snapMode!='inner'){var ts=Math.abs(t-y2)<=d;var bs=Math.abs(b-y1)<=d;var ls=Math.abs(l-x2)<=d;var rs=Math.abs(r-x1)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r}).left-inst.margins.left;} |
| 258 | +var first=(ts||bs||ls||rs);if(o.snapMode!='outer'){var ts=Math.abs(t-y1)<=d;var bs=Math.abs(b-y2)<=d;var ls=Math.abs(l-x1)<=d;var rs=Math.abs(r-x2)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left-inst.margins.left;} |
| 259 | +if(!inst.snapElements[i].snapping&&(ts||bs||ls||rs||first)) |
| 260 | +(inst.options.snap.snap&&inst.options.snap.snap.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item})));inst.snapElements[i].snapping=(ts||bs||ls||rs||first);};}});$.ui.plugin.add("draggable","stack",{start:function(event,ui){var o=$(this).data("draggable").options;var group=$.makeArray($(o.stack.group)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||o.stack.min)-(parseInt($(b).css("zIndex"),10)||o.stack.min);});$(group).each(function(i){this.style.zIndex=o.stack.min+i;});this[0].style.zIndex=o.stack.min+group.length;}});$.ui.plugin.add("draggable","zIndex",{start:function(event,ui){var t=$(ui.helper),o=$(this).data("draggable").options;if(t.css("zIndex"))o._zIndex=t.css("zIndex");t.css('zIndex',o.zIndex);},stop:function(event,ui){var o=$(this).data("draggable").options;if(o._zIndex)$(ui.helper).css('zIndex',o._zIndex);}});})(jQuery);(function($){$.widget("ui.resizable",$.extend({},$.ui.mouse,{_init:function(){var self=this,o=this.options;this.element.addClass("ui-resizable");$.extend(this,{_aspectRatio:!!(o.aspectRatio),aspectRatio:o.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:o.helper||o.ghost||o.animate?o.helper||'ui-resizable-helper':null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css('position'))&&$.browser.opera) |
| 261 | +this.element.css({position:'relative',top:'auto',left:'auto'});this.element.wrap($('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css('position'),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css('top'),left:this.element.css('left')}));this.element=this.element.parent().data("resizable",this.element.data('resizable'));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css('resize');this.originalElement.css('resize','none');this._proportionallyResizeElements.push(this.originalElement.css({position:'static',zoom:1,display:'block'}));this.originalElement.css({margin:this.originalElement.css('margin')});this._proportionallyResize();} |
| 262 | +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'});if(this.handles.constructor==String){if(this.handles=='all')this.handles='n,e,s,w,se,sw,ne,nw';var n=this.handles.split(",");this.handles={};for(var i=0;i<n.length;i++){var handle=$.trim(n[i]),hname='ui-resizable-'+handle;var axis=$('<div class="ui-resizable-handle '+hname+'"></div>');if(/sw|se|ne|nw/.test(handle))axis.css({zIndex:++o.zIndex});if('se'==handle){axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');};this.handles[handle]='.ui-resizable-'+handle;this.element.append(axis);}} |
| 263 | +this._renderAxis=function(target){target=target||this.element;for(var i in this.handles){if(this.handles[i].constructor==String) |
| 264 | +this.handles[i]=$(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var axis=$(this.handles[i],this.element),padWrapper=0;padWrapper=/sw|ne|nw|se|n|s/.test(i)?axis.outerHeight():axis.outerWidth();var padPos=['padding',/ne|nw|n/.test(i)?'Top':/se|sw|s/.test(i)?'Bottom':/^e$/.test(i)?'Right':'Left'].join("");target.css(padPos,padWrapper);this._proportionallyResize();} |
| 265 | +if(!$(this.handles[i]).length) |
| 266 | +continue;}};this._renderAxis(this.element);this._handles=$('.ui-resizable-handle',this.element).disableSelection();this._handles.mouseover(function(){if(!self.resizing){if(this.className) |
| 267 | +var axis=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);self.axis=axis&&axis[1]?axis[1]:'se';}});if(o.autoHide){this._handles.hide();$(this.element).addClass("ui-resizable-autohide").hover(function(){$(this).removeClass("ui-resizable-autohide");self._handles.show();},function(){if(!self.resizing){$(this).addClass("ui-resizable-autohide");self._handles.hide();}});} |
| 268 | +this._mouseInit();},destroy:function(){this._mouseDestroy();var _destroy=function(exp){$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();};if(this.elementIsWrapper){_destroy(this.element);var wrapper=this.element;wrapper.parent().append(this.originalElement.css({position:wrapper.css('position'),width:wrapper.outerWidth(),height:wrapper.outerHeight(),top:wrapper.css('top'),left:wrapper.css('left')})).end().remove();} |
| 269 | +this.originalElement.css('resize',this.originalResizeStyle);_destroy(this.originalElement);},_mouseCapture:function(event){var handle=false;for(var i in this.handles){if($(this.handles[i])[0]==event.target)handle=true;} |
| 270 | +return this.options.disabled||!!handle;},_mouseStart:function(event){var o=this.options,iniPos=this.element.position(),el=this.element;this.resizing=true;this.documentScroll={top:$(document).scrollTop(),left:$(document).scrollLeft()};if(el.is('.ui-draggable')||(/absolute/).test(el.css('position'))){el.css({position:'absolute',top:iniPos.top,left:iniPos.left});} |
| 271 | +if($.browser.opera&&(/relative/).test(el.css('position'))) |
| 272 | +el.css({position:'relative',top:'auto',left:'auto'});this._renderProxy();var curleft=num(this.helper.css('left')),curtop=num(this.helper.css('top'));if(o.containment){curleft+=$(o.containment).scrollLeft()||0;curtop+=$(o.containment).scrollTop()||0;} |
| 273 | +this.offset=this.helper.offset();this.position={left:curleft,top:curtop};this.size=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalSize=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalPosition={left:curleft,top:curtop};this.sizeDiff={width:el.outerWidth()-el.width(),height:el.outerHeight()-el.height()};this.originalMousePosition={left:event.pageX,top:event.pageY};this.aspectRatio=(typeof o.aspectRatio=='number')?o.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var cursor=$('.ui-resizable-'+this.axis).css('cursor');$('body').css('cursor',cursor=='auto'?this.axis+'-resize':cursor);el.addClass("ui-resizable-resizing");this._propagate("start",event);return true;},_mouseDrag:function(event){var el=this.helper,o=this.options,props={},self=this,smp=this.originalMousePosition,a=this.axis;var dx=(event.pageX-smp.left)||0,dy=(event.pageY-smp.top)||0;var trigger=this._change[a];if(!trigger)return false;var data=trigger.apply(this,[event,dx,dy]),ie6=$.browser.msie&&$.browser.version<7,csdif=this.sizeDiff;if(this._aspectRatio||event.shiftKey) |
| 274 | +data=this._updateRatio(data,event);data=this._respectSize(data,event);this._propagate("resize",event);el.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length) |
| 275 | +this._proportionallyResize();this._updateCache(data);this._trigger('resize',event,this.ui());return false;},_mouseStop:function(event){this.resizing=false;var o=this.options,self=this;if(this._helper){var pr=this._proportionallyResizeElements,ista=pr.length&&(/textarea/i).test(pr[0].nodeName),soffseth=ista&&$.ui.hasScroll(pr[0],'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var s={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;if(!o.animate) |
| 276 | +this.element.css($.extend(s,{top:top,left:left}));self.helper.height(self.size.height);self.helper.width(self.size.width);if(this._helper&&!o.animate)this._proportionallyResize();} |
| 277 | +$('body').css('cursor','auto');this.element.removeClass("ui-resizable-resizing");this._propagate("stop",event);if(this._helper)this.helper.remove();return false;},_updateCache:function(data){var o=this.options;this.offset=this.helper.offset();if(isNumber(data.left))this.position.left=data.left;if(isNumber(data.top))this.position.top=data.top;if(isNumber(data.height))this.size.height=data.height;if(isNumber(data.width))this.size.width=data.width;},_updateRatio:function(data,event){var o=this.options,cpos=this.position,csize=this.size,a=this.axis;if(data.height)data.width=(csize.height*this.aspectRatio);else if(data.width)data.height=(csize.width/this.aspectRatio);if(a=='sw'){data.left=cpos.left+(csize.width-data.width);data.top=null;} |
| 278 | +if(a=='nw'){data.top=cpos.top+(csize.height-data.height);data.left=cpos.left+(csize.width-data.width);} |
| 279 | +return data;},_respectSize:function(data,event){var el=this.helper,o=this.options,pRatio=this._aspectRatio||event.shiftKey,a=this.axis,ismaxw=isNumber(data.width)&&o.maxWidth&&(o.maxWidth<data.width),ismaxh=isNumber(data.height)&&o.maxHeight&&(o.maxHeight<data.height),isminw=isNumber(data.width)&&o.minWidth&&(o.minWidth>data.width),isminh=isNumber(data.height)&&o.minHeight&&(o.minHeight>data.height);if(isminw)data.width=o.minWidth;if(isminh)data.height=o.minHeight;if(ismaxw)data.width=o.maxWidth;if(ismaxh)data.height=o.maxHeight;var dw=this.originalPosition.left+this.originalSize.width,dh=this.position.top+this.size.height;var cw=/sw|nw|w/.test(a),ch=/nw|ne|n/.test(a);if(isminw&&cw)data.left=dw-o.minWidth;if(ismaxw&&cw)data.left=dw-o.maxWidth;if(isminh&&ch)data.top=dh-o.minHeight;if(ismaxh&&ch)data.top=dh-o.maxHeight;var isNotwh=!data.width&&!data.height;if(isNotwh&&!data.left&&data.top)data.top=null;else if(isNotwh&&!data.top&&data.left)data.left=null;return data;},_proportionallyResize:function(){var o=this.options;if(!this._proportionallyResizeElements.length)return;var element=this.helper||this.element;for(var i=0;i<this._proportionallyResizeElements.length;i++){var prel=this._proportionallyResizeElements[i];if(!this.borderDif){var b=[prel.css('borderTopWidth'),prel.css('borderRightWidth'),prel.css('borderBottomWidth'),prel.css('borderLeftWidth')],p=[prel.css('paddingTop'),prel.css('paddingRight'),prel.css('paddingBottom'),prel.css('paddingLeft')];this.borderDif=$.map(b,function(v,i){var border=parseInt(v,10)||0,padding=parseInt(p[i],10)||0;return border+padding;});} |
| 280 | +if($.browser.msie&&!(!($(element).is(':hidden')||$(element).parents(':hidden').length))) |
| 281 | +continue;prel.css({height:(element.height()-this.borderDif[0]-this.borderDif[2])||0,width:(element.width()-this.borderDif[1]-this.borderDif[3])||0});};},_renderProxy:function(){var el=this.element,o=this.options;this.elementOffset=el.offset();if(this._helper){this.helper=this.helper||$('<div style="overflow:hidden;"></div>');var ie6=$.browser.msie&&$.browser.version<7,ie6offset=(ie6?1:0),pxyoffset=(ie6?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+pxyoffset,height:this.element.outerHeight()+pxyoffset,position:'absolute',left:this.elementOffset.left-ie6offset+'px',top:this.elementOffset.top-ie6offset+'px',zIndex:++o.zIndex});this.helper.appendTo("body").disableSelection();}else{this.helper=this.element;}},_change:{e:function(event,dx,dy){return{width:this.originalSize.width+dx};},w:function(event,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{left:sp.left+dx,width:cs.width-dx};},n:function(event,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{top:sp.top+dy,height:cs.height-dy};},s:function(event,dx,dy){return{height:this.originalSize.height+dy};},se:function(event,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[event,dx,dy]));},sw:function(event,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[event,dx,dy]));},ne:function(event,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[event,dx,dy]));},nw:function(event,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[event,dx,dy]));}},_propagate:function(n,event){$.ui.plugin.call(this,n,[event,this.ui()]);(n!="resize"&&this._trigger(n,event,this.ui()));},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition};}}));$.extend($.ui.resizable,{version:"1.7.1",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,distance:1,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000}});$.ui.plugin.add("resizable","alsoResize",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options;_store=function(exp){$(exp).each(function(){$(this).data("resizable-alsoresize",{width:parseInt($(this).width(),10),height:parseInt($(this).height(),10),left:parseInt($(this).css('left'),10),top:parseInt($(this).css('top'),10)});});};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.parentNode){if(o.alsoResize.length){o.alsoResize=o.alsoResize[0];_store(o.alsoResize);} |
| 282 | +else{$.each(o.alsoResize,function(exp,c){_store(exp);});}}else{_store(o.alsoResize);}},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options,os=self.originalSize,op=self.originalPosition;var delta={height:(self.size.height-os.height)||0,width:(self.size.width-os.width)||0,top:(self.position.top-op.top)||0,left:(self.position.left-op.left)||0},_alsoResize=function(exp,c){$(exp).each(function(){var el=$(this),start=$(this).data("resizable-alsoresize"),style={},css=c&&c.length?c:['width','height','top','left'];$.each(css||['width','height','top','left'],function(i,prop){var sum=(start[prop]||0)+(delta[prop]||0);if(sum&&sum>=0) |
| 283 | +style[prop]=sum||null;});if(/relative/.test(el.css('position'))&&$.browser.opera){self._revertToRelativePosition=true;el.css({position:'absolute',top:'auto',left:'auto'});} |
| 284 | +el.css(style);});};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.nodeType){$.each(o.alsoResize,function(exp,c){_alsoResize(exp,c);});}else{_alsoResize(o.alsoResize);}},stop:function(event,ui){var self=$(this).data("resizable");if(self._revertToRelativePosition&&$.browser.opera){self._revertToRelativePosition=false;el.css({position:'relative'});} |
| 285 | +$(this).removeData("resizable-alsoresize-start");}});$.ui.plugin.add("resizable","animate",{stop:function(event,ui){var self=$(this).data("resizable"),o=self.options;var pr=self._proportionallyResizeElements,ista=pr.length&&(/textarea/i).test(pr[0].nodeName),soffseth=ista&&$.ui.hasScroll(pr[0],'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var style={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;self.element.animate($.extend(style,top&&left?{top:top,left:left}:{}),{duration:o.animateDuration,easing:o.animateEasing,step:function(){var data={width:parseInt(self.element.css('width'),10),height:parseInt(self.element.css('height'),10),top:parseInt(self.element.css('top'),10),left:parseInt(self.element.css('left'),10)};if(pr&&pr.length)$(pr[0]).css({width:data.width,height:data.height});self._updateCache(data);self._propagate("resize",event);}});}});$.ui.plugin.add("resizable","containment",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options,el=self.element;var oc=o.containment,ce=(oc instanceof $)?oc.get(0):(/parent/.test(oc))?el.parent().get(0):oc;if(!ce)return;self.containerElement=$(ce);if(/document/.test(oc)||oc==document){self.containerOffset={left:0,top:0};self.containerPosition={left:0,top:0};self.parentData={element:$(document),left:0,top:0,width:$(document).width(),height:$(document).height()||document.body.parentNode.scrollHeight};} |
| 286 | +else{var element=$(ce),p=[];$(["Top","Right","Left","Bottom"]).each(function(i,name){p[i]=num(element.css("padding"+name));});self.containerOffset=element.offset();self.containerPosition=element.position();self.containerSize={height:(element.innerHeight()-p[3]),width:(element.innerWidth()-p[1])};var co=self.containerOffset,ch=self.containerSize.height,cw=self.containerSize.width,width=($.ui.hasScroll(ce,"left")?ce.scrollWidth:cw),height=($.ui.hasScroll(ce)?ce.scrollHeight:ch);self.parentData={element:ce,left:co.left,top:co.top,width:width,height:height};}},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options,ps=self.containerSize,co=self.containerOffset,cs=self.size,cp=self.position,pRatio=self._aspectRatio||event.shiftKey,cop={top:0,left:0},ce=self.containerElement;if(ce[0]!=document&&(/static/).test(ce.css('position')))cop=co;if(cp.left<(self._helper?co.left:0)){self.size.width=self.size.width+(self._helper?(self.position.left-co.left):(self.position.left-cop.left));if(pRatio)self.size.height=self.size.width/o.aspectRatio;self.position.left=o.helper?co.left:0;} |
| 287 | +if(cp.top<(self._helper?co.top:0)){self.size.height=self.size.height+(self._helper?(self.position.top-co.top):self.position.top);if(pRatio)self.size.width=self.size.height*o.aspectRatio;self.position.top=self._helper?co.top:0;} |
| 288 | +self.offset.left=self.parentData.left+self.position.left;self.offset.top=self.parentData.top+self.position.top;var woset=Math.abs((self._helper?self.offset.left-cop.left:(self.offset.left-cop.left))+self.sizeDiff.width),hoset=Math.abs((self._helper?self.offset.top-cop.top:(self.offset.top-co.top))+self.sizeDiff.height);var isParent=self.containerElement.get(0)==self.element.parent().get(0),isOffsetRelative=/relative|absolute/.test(self.containerElement.css('position'));if(isParent&&isOffsetRelative)woset-=self.parentData.left;if(woset+self.size.width>=self.parentData.width){self.size.width=self.parentData.width-woset;if(pRatio)self.size.height=self.size.width/self.aspectRatio;} |
| 289 | +if(hoset+self.size.height>=self.parentData.height){self.size.height=self.parentData.height-hoset;if(pRatio)self.size.width=self.size.height*self.aspectRatio;}},stop:function(event,ui){var self=$(this).data("resizable"),o=self.options,cp=self.position,co=self.containerOffset,cop=self.containerPosition,ce=self.containerElement;var helper=$(self.helper),ho=helper.offset(),w=helper.outerWidth()-self.sizeDiff.width,h=helper.outerHeight()-self.sizeDiff.height;if(self._helper&&!o.animate&&(/relative/).test(ce.css('position'))) |
| 290 | +$(this).css({left:ho.left-cop.left-co.left,width:w,height:h});if(self._helper&&!o.animate&&(/static/).test(ce.css('position'))) |
| 291 | +$(this).css({left:ho.left-cop.left-co.left,width:w,height:h});}});$.ui.plugin.add("resizable","ghost",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options,cs=self.size;self.ghost=self.originalElement.clone();self.ghost.css({opacity:.25,display:'block',position:'relative',height:cs.height,width:cs.width,margin:0,left:0,top:0}).addClass('ui-resizable-ghost').addClass(typeof o.ghost=='string'?o.ghost:'');self.ghost.appendTo(self.helper);},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options;if(self.ghost)self.ghost.css({position:'relative',height:self.size.height,width:self.size.width});},stop:function(event,ui){var self=$(this).data("resizable"),o=self.options;if(self.ghost&&self.helper)self.helper.get(0).removeChild(self.ghost.get(0));}});$.ui.plugin.add("resizable","grid",{resize:function(event,ui){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;o.grid=typeof o.grid=="number"?[o.grid,o.grid]:o.grid;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);if(/^(se|s|e)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;} |
| 292 | +else if(/^(ne)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;} |
| 293 | +else if(/^(sw)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.left=op.left-ox;} |
| 294 | +else{self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;self.position.left=op.left-ox;}}});var num=function(v){return parseInt(v,10)||0;};var isNumber=function(value){return!isNaN(parseInt(value,10));};})(jQuery);(function($){$.widget("ui.tabs",{_init:function(){if(this.options.deselectable!==undefined){this.options.collapsible=this.options.deselectable;} |
| 295 | +this._tabify(true);},_setData:function(key,value){if(key=='selected'){if(this.options.collapsible&&value==this.options.selected){return;} |
| 296 | +this.select(value);} |
| 297 | +else{this.options[key]=value;if(key=='deselectable'){this.options.collapsible=value;} |
| 298 | +this._tabify();}},_tabId:function(a){return a.title&&a.title.replace(/\s/g,'_').replace(/[^A-Za-z0-9\-_:\.]/g,'')||this.options.idPrefix+$.data(a);},_sanitizeSelector:function(hash){return hash.replace(/:/g,'\\:');},_cookie:function(){var cookie=this.cookie||(this.cookie=this.options.cookie.name||'ui-tabs-'+$.data(this.list[0]));return $.cookie.apply(null,[cookie].concat($.makeArray(arguments)));},_ui:function(tab,panel){return{tab:tab,panel:panel,index:this.anchors.index(tab)};},_cleanup:function(){this.lis.filter('.ui-state-processing').removeClass('ui-state-processing').find('span:data(label.tabs)').each(function(){var el=$(this);el.html(el.data('label.tabs')).removeData('label.tabs');});},_tabify:function(init){this.list=this.element.children('ul:first');this.lis=$('li:has(a[href])',this.list);this.anchors=this.lis.map(function(){return $('a',this)[0];});this.panels=$([]);var self=this,o=this.options;var fragmentId=/^#.+/;this.anchors.each(function(i,a){var href=$(a).attr('href');var hrefBase=href.split('#')[0],baseEl;if(hrefBase&&(hrefBase===location.toString().split('#')[0]||(baseEl=$('base')[0])&&hrefBase===baseEl.href)){href=a.hash;a.href=href;} |
| 299 | +if(fragmentId.test(href)){self.panels=self.panels.add(self._sanitizeSelector(href));} |
| 300 | +else if(href!='#'){$.data(a,'href.tabs',href);$.data(a,'load.tabs',href.replace(/#.*$/,''));var id=self._tabId(a);a.href='#'+id;var $panel=$('#'+id);if(!$panel.length){$panel=$(o.panelTemplate).attr('id',id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom').insertAfter(self.panels[i-1]||self.list);$panel.data('destroy.tabs',true);} |
| 301 | +self.panels=self.panels.add($panel);} |
| 302 | +else{o.disabled.push(i);}});if(init){this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all');this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');this.lis.addClass('ui-state-default ui-corner-top');this.panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom');if(o.selected===undefined){if(location.hash){this.anchors.each(function(i,a){if(a.hash==location.hash){o.selected=i;return false;}});} |
| 303 | +if(typeof o.selected!='number'&&o.cookie){o.selected=parseInt(self._cookie(),10);} |
| 304 | +if(typeof o.selected!='number'&&this.lis.filter('.ui-tabs-selected').length){o.selected=this.lis.index(this.lis.filter('.ui-tabs-selected'));} |
| 305 | +o.selected=o.selected||0;} |
| 306 | +else if(o.selected===null){o.selected=-1;} |
| 307 | +o.selected=((o.selected>=0&&this.anchors[o.selected])||o.selected<0)?o.selected:0;o.disabled=$.unique(o.disabled.concat($.map(this.lis.filter('.ui-state-disabled'),function(n,i){return self.lis.index(n);}))).sort();if($.inArray(o.selected,o.disabled)!=-1){o.disabled.splice($.inArray(o.selected,o.disabled),1);} |
| 308 | +this.panels.addClass('ui-tabs-hide');this.lis.removeClass('ui-tabs-selected ui-state-active');if(o.selected>=0&&this.anchors.length){this.panels.eq(o.selected).removeClass('ui-tabs-hide');this.lis.eq(o.selected).addClass('ui-tabs-selected ui-state-active');self.element.queue("tabs",function(){self._trigger('show',null,self._ui(self.anchors[o.selected],self.panels[o.selected]));});this.load(o.selected);} |
| 309 | +$(window).bind('unload',function(){self.lis.add(self.anchors).unbind('.tabs');self.lis=self.anchors=self.panels=null;});} |
| 310 | +else{o.selected=this.lis.index(this.lis.filter('.ui-tabs-selected'));} |
| 311 | +this.element[o.collapsible?'addClass':'removeClass']('ui-tabs-collapsible');if(o.cookie){this._cookie(o.selected,o.cookie);} |
| 312 | +for(var i=0,li;(li=this.lis[i]);i++){$(li)[$.inArray(i,o.disabled)!=-1&&!$(li).hasClass('ui-tabs-selected')?'addClass':'removeClass']('ui-state-disabled');} |
| 313 | +if(o.cache===false){this.anchors.removeData('cache.tabs');} |
| 314 | +this.lis.add(this.anchors).unbind('.tabs');if(o.event!='mouseover'){var addState=function(state,el){if(el.is(':not(.ui-state-disabled)')){el.addClass('ui-state-'+state);}};var removeState=function(state,el){el.removeClass('ui-state-'+state);};this.lis.bind('mouseover.tabs',function(){addState('hover',$(this));});this.lis.bind('mouseout.tabs',function(){removeState('hover',$(this));});this.anchors.bind('focus.tabs',function(){addState('focus',$(this).closest('li'));});this.anchors.bind('blur.tabs',function(){removeState('focus',$(this).closest('li'));});} |
| 315 | +var hideFx,showFx;if(o.fx){if($.isArray(o.fx)){hideFx=o.fx[0];showFx=o.fx[1];} |
| 316 | +else{hideFx=showFx=o.fx;}} |
| 317 | +function resetStyle($el,fx){$el.css({display:''});if($.browser.msie&&fx.opacity){$el[0].style.removeAttribute('filter');}} |
| 318 | +var showTab=showFx?function(clicked,$show){$(clicked).closest('li').removeClass('ui-state-default').addClass('ui-tabs-selected ui-state-active');$show.hide().removeClass('ui-tabs-hide').animate(showFx,showFx.duration||'normal',function(){resetStyle($show,showFx);self._trigger('show',null,self._ui(clicked,$show[0]));});}:function(clicked,$show){$(clicked).closest('li').removeClass('ui-state-default').addClass('ui-tabs-selected ui-state-active');$show.removeClass('ui-tabs-hide');self._trigger('show',null,self._ui(clicked,$show[0]));};var hideTab=hideFx?function(clicked,$hide){$hide.animate(hideFx,hideFx.duration||'normal',function(){self.lis.removeClass('ui-tabs-selected ui-state-active').addClass('ui-state-default');$hide.addClass('ui-tabs-hide');resetStyle($hide,hideFx);self.element.dequeue("tabs");});}:function(clicked,$hide,$show){self.lis.removeClass('ui-tabs-selected ui-state-active').addClass('ui-state-default');$hide.addClass('ui-tabs-hide');self.element.dequeue("tabs");};this.anchors.bind(o.event+'.tabs',function(){var el=this,$li=$(this).closest('li'),$hide=self.panels.filter(':not(.ui-tabs-hide)'),$show=$(self._sanitizeSelector(this.hash));if(($li.hasClass('ui-tabs-selected')&&!o.collapsible)||$li.hasClass('ui-state-disabled')||$li.hasClass('ui-state-processing')||self._trigger('select',null,self._ui(this,$show[0]))===false){this.blur();return false;} |
| 319 | +o.selected=self.anchors.index(this);self.abort();if(o.collapsible){if($li.hasClass('ui-tabs-selected')){o.selected=-1;if(o.cookie){self._cookie(o.selected,o.cookie);} |
| 320 | +self.element.queue("tabs",function(){hideTab(el,$hide);}).dequeue("tabs");this.blur();return false;} |
| 321 | +else if(!$hide.length){if(o.cookie){self._cookie(o.selected,o.cookie);} |
| 322 | +self.element.queue("tabs",function(){showTab(el,$show);});self.load(self.anchors.index(this));this.blur();return false;}} |
| 323 | +if(o.cookie){self._cookie(o.selected,o.cookie);} |
| 324 | +if($show.length){if($hide.length){self.element.queue("tabs",function(){hideTab(el,$hide);});} |
| 325 | +self.element.queue("tabs",function(){showTab(el,$show);});self.load(self.anchors.index(this));} |
| 326 | +else{throw'jQuery UI Tabs: Mismatching fragment identifier.';} |
| 327 | +if($.browser.msie){this.blur();}});this.anchors.bind('click.tabs',function(){return false;});},destroy:function(){var o=this.options;this.abort();this.element.unbind('.tabs').removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible').removeData('tabs');this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');this.anchors.each(function(){var href=$.data(this,'href.tabs');if(href){this.href=href;} |
| 328 | +var $this=$(this).unbind('.tabs');$.each(['href','load','cache'],function(i,prefix){$this.removeData(prefix+'.tabs');});});this.lis.unbind('.tabs').add(this.panels).each(function(){if($.data(this,'destroy.tabs')){$(this).remove();} |
| 329 | +else{$(this).removeClass(['ui-state-default','ui-corner-top','ui-tabs-selected','ui-state-active','ui-state-hover','ui-state-focus','ui-state-disabled','ui-tabs-panel','ui-widget-content','ui-corner-bottom','ui-tabs-hide'].join(' '));}});if(o.cookie){this._cookie(null,o.cookie);}},add:function(url,label,index){if(index===undefined){index=this.anchors.length;} |
| 330 | +var self=this,o=this.options,$li=$(o.tabTemplate.replace(/#\{href\}/g,url).replace(/#\{label\}/g,label)),id=!url.indexOf('#')?url.replace('#',''):this._tabId($('a',$li)[0]);$li.addClass('ui-state-default ui-corner-top').data('destroy.tabs',true);var $panel=$('#'+id);if(!$panel.length){$panel=$(o.panelTemplate).attr('id',id).data('destroy.tabs',true);} |
| 331 | +$panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide');if(index>=this.lis.length){$li.appendTo(this.list);$panel.appendTo(this.list[0].parentNode);} |
| 332 | +else{$li.insertBefore(this.lis[index]);$panel.insertBefore(this.panels[index]);} |
| 333 | +o.disabled=$.map(o.disabled,function(n,i){return n>=index?++n:n;});this._tabify();if(this.anchors.length==1){$li.addClass('ui-tabs-selected ui-state-active');$panel.removeClass('ui-tabs-hide');this.element.queue("tabs",function(){self._trigger('show',null,self._ui(self.anchors[0],self.panels[0]));});this.load(0);} |
| 334 | +this._trigger('add',null,this._ui(this.anchors[index],this.panels[index]));},remove:function(index){var o=this.options,$li=this.lis.eq(index).remove(),$panel=this.panels.eq(index).remove();if($li.hasClass('ui-tabs-selected')&&this.anchors.length>1){this.select(index+(index+1<this.anchors.length?1:-1));} |
| 335 | +o.disabled=$.map($.grep(o.disabled,function(n,i){return n!=index;}),function(n,i){return n>=index?--n:n;});this._tabify();this._trigger('remove',null,this._ui($li.find('a')[0],$panel[0]));},enable:function(index){var o=this.options;if($.inArray(index,o.disabled)==-1){return;} |
| 336 | +this.lis.eq(index).removeClass('ui-state-disabled');o.disabled=$.grep(o.disabled,function(n,i){return n!=index;});this._trigger('enable',null,this._ui(this.anchors[index],this.panels[index]));},disable:function(index){var self=this,o=this.options;if(index!=o.selected){this.lis.eq(index).addClass('ui-state-disabled');o.disabled.push(index);o.disabled.sort();this._trigger('disable',null,this._ui(this.anchors[index],this.panels[index]));}},select:function(index){if(typeof index=='string'){index=this.anchors.index(this.anchors.filter('[href$='+index+']'));} |
| 337 | +else if(index===null){index=-1;} |
| 338 | +if(index==-1&&this.options.collapsible){index=this.options.selected;} |
| 339 | +this.anchors.eq(index).trigger(this.options.event+'.tabs');},load:function(index){var self=this,o=this.options,a=this.anchors.eq(index)[0],url=$.data(a,'load.tabs');this.abort();if(!url||this.element.queue("tabs").length!==0&&$.data(a,'cache.tabs')){this.element.dequeue("tabs");return;} |
| 340 | +this.lis.eq(index).addClass('ui-state-processing');if(o.spinner){var span=$('span',a);span.data('label.tabs',span.html()).html(o.spinner);} |
| 341 | +this.xhr=$.ajax($.extend({},o.ajaxOptions,{url:url,success:function(r,s){$(self._sanitizeSelector(a.hash)).html(r);self._cleanup();if(o.cache){$.data(a,'cache.tabs',true);} |
| 342 | +self._trigger('load',null,self._ui(self.anchors[index],self.panels[index]));try{o.ajaxOptions.success(r,s);} |
| 343 | +catch(e){} |
| 344 | +self.element.dequeue("tabs");}}));},abort:function(){this.element.queue([]);this.panels.stop(false,true);if(this.xhr){this.xhr.abort();delete this.xhr;} |
| 345 | +this._cleanup();},url:function(index,url){this.anchors.eq(index).removeData('cache.tabs').data('load.tabs',url);},length:function(){return this.anchors.length;}});$.extend($.ui.tabs,{version:'1.7.1',getter:'length',defaults:{ajaxOptions:null,cache:false,cookie:null,collapsible:false,disabled:[],event:'click',fx:null,idPrefix:'ui-tabs-',panelTemplate:'<div></div>',spinner:'<em>Loading…</em>',tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'}});$.extend($.ui.tabs.prototype,{rotation:null,rotate:function(ms,continuing){var self=this,o=this.options;var rotate=self._rotate||(self._rotate=function(e){clearTimeout(self.rotation);self.rotation=setTimeout(function(){var t=o.selected;self.select(++t<self.anchors.length?t:0);},ms);if(e){e.stopPropagation();}});var stop=self._unrotate||(self._unrotate=!continuing?function(e){if(e.clientX){self.rotate(null);}}:function(e){t=o.selected;rotate();});if(ms){this.element.bind('tabsshow',rotate);this.anchors.bind(o.event+'.tabs',stop);rotate();} |
| 346 | +else{clearTimeout(self.rotation);this.element.unbind('tabsshow',rotate);this.anchors.unbind(o.event+'.tabs',stop);delete this._rotate;delete this._unrotate;}}});})(jQuery);(function($){$.whileAsync=function(opts) |
4 | 347 | {var delay=Math.abs(opts.delay)||10,bulk=isNaN(opts.bulk)?500:Math.abs(opts.bulk),test=opts.test||function(){return true;},loop=opts.loop||function(){},end=opts.end||function(){};(function(){var t=false,begin=new Date();while(t=test()) |
5 | 348 | {loop();if(bulk===0||(new Date()-begin)>bulk) |
6 | 349 | {break;}} |
— | — | @@ -127,7 +470,8 @@ |
128 | 471 | configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
129 | 472 | var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
130 | 473 | maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
131 | | -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':2},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
| 474 | +$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':2},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){if($.browser.msie&&$.browser.version>=8){if(!this.isSecondRun){this.isSecondRun=true;return;}} |
| 475 | +$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
132 | 476 | var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;} |
133 | 477 | match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;} |
134 | 478 | tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |