| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /* 2 * jQuery UI 1.7.3 3 * 4 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) 5 * Dual licensed under the MIT (MIT-LICENSE.txt) 6 * and GPL (GPL-LICENSE.txt) licenses. 7 * 8 * http://docs.jquery.com/UI 9 */ 10 ;jQuery.ui || (function($) { 11 12 var _remove = $.fn.remove, 13 isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); 14 15 //Helper functions and ui object 16 $.ui = { 17 version: "1.7.3", 18 19 // $.ui.plugin is deprecated. Use the proxy pattern instead. 20 plugin: { 21 add: function(module, option, set) { 22 var proto = $.ui[module].prototype; 23 for(var i in set) { 24 proto.plugins[i] = proto.plugins[i] || []; 25 proto.plugins[i].push([option, set[i]]); 26 } 27 }, 28 call: function(instance, name, args) { 29 var set = instance.plugins[name]; 30 if(!set || !instance.element[0].parentNode) { return; } 31 32 for (var i = 0; i < set.length; i++) { 33 if (instance.options[set[i][0]]) { 34 set[i][1].apply(instance.element, args); 35 } 36 } 37 } 38 }, 39 40 contains: function(a, b) { 41 return document.compareDocumentPosition 42 ? a.compareDocumentPosition(b) & 16 43 : a !== b && a.contains(b); 44 }, 45 46 hasScroll: function(el, a) { 47 48 //If overflow is hidden, the element might have extra content, but the user wants to hide it 49 if ($(el).css('overflow') == 'hidden') { return false; } 50 51 var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', 52 has = false; 53 54 if (el[scroll] > 0) { return true; } 55 56 // TODO: determine which cases actually cause this to happen 57 // if the element doesn't have the scroll set, see if it's possible to 58 // set the scroll 59 el[scroll] = 1; 60 has = (el[scroll] > 0); 61 el[scroll] = 0; 62 return has; 63 }, 64 65 isOverAxis: function(x, reference, size) { 66 //Determines when x coordinate is over "b" element axis 67 return (x > reference) && (x < (reference + size)); 68 }, 69 70 isOver: function(y, x, top, left, height, width) { 71 //Determines when x, y coordinates is over "b" element 72 return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); 73 }, 74 75 keyCode: { 76 BACKSPACE: 8, 77 CAPS_LOCK: 20, 78 COMMA: 188, 79 CONTROL: 17, 80 DELETE: 46, 81 DOWN: 40, 82 END: 35, 83 ENTER: 13, 84 ESCAPE: 27, 85 HOME: 36, 86 INSERT: 45, 87 LEFT: 37, 88 NUMPAD_ADD: 107, 89 NUMPAD_DECIMAL: 110, 90 NUMPAD_DIVIDE: 111, 91 NUMPAD_ENTER: 108, 92 NUMPAD_MULTIPLY: 106, 93 NUMPAD_SUBTRACT: 109, 94 PAGE_DOWN: 34, 95 PAGE_UP: 33, 96 PERIOD: 190, 97 RIGHT: 39, 98 SHIFT: 16, 99 SPACE: 32, 100 TAB: 9, 101 UP: 38 102 } 103 }; 104 105 // WAI-ARIA normalization 106 if (isFF2) { 107 var attr = $.attr, 108 removeAttr = $.fn.removeAttr, 109 ariaNS = "http://www.w3.org/2005/07/aaa", 110 ariaState = /^aria-/, 111 ariaRole = /^wairole:/; 112 113 $.attr = function(elem, name, value) { 114 var set = value !== undefined; 115 116 return (name == 'role' 117 ? (set 118 ? attr.call(this, elem, name, "wairole:" + value) 119 : (attr.apply(this, arguments) || "").replace(ariaRole, "")) 120 : (ariaState.test(name) 121 ? (set 122 ? elem.setAttributeNS(ariaNS, 123 name.replace(ariaState, "aaa:"), value) 124 : attr.call(this, elem, name.replace(ariaState, "aaa:"))) 125 : attr.apply(this, arguments))); 126 }; 127 128 $.fn.removeAttr = function(name) { 129 return (ariaState.test(name) 130 ? this.each(function() { 131 this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); 132 }) : removeAttr.call(this, name)); 133 }; 134 } 135 136 //jQuery plugins 137 $.fn.extend({ 138 remove: function(selector, keepData) { 139 return this.each(function() { 140 if ( !keepData ) { 141 if ( !selector || $.filter( selector, [ this ] ).length ) { 142 $( "*", this ).add( this ).each(function() { 143 $( this ).triggerHandler( "remove" ); 144 }); 145 } 146 } 147 return _remove.call( $(this), selector, keepData ); 148 }); 149 }, 150 151 enableSelection: function() { 152 return this 153 .attr('unselectable', 'off') 154 .css('MozUserSelect', '') 155 .unbind('selectstart.ui'); 156 }, 157 158 disableSelection: function() { 159 return this 160 .attr('unselectable', 'on') 161 .css('MozUserSelect', 'none') 162 .bind('selectstart.ui', function() { return false; }); 163 }, 164 165 scrollParent: function() { 166 var scrollParent; 167 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { 168 scrollParent = this.parents().filter(function() { 169 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)); 170 }).eq(0); 171 } else { 172 scrollParent = this.parents().filter(function() { 173 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); 174 }).eq(0); 175 } 176 177 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; 178 } 179 }); 180 181 182 //Additional selectors 183 $.extend($.expr[':'], { 184 data: function(elem, i, match) { 185 return !!$.data(elem, match[3]); 186 }, 187 188 focusable: function(element) { 189 var nodeName = element.nodeName.toLowerCase(), 190 tabIndex = $.attr(element, 'tabindex'); 191 return (/input|select|textarea|button|object/.test(nodeName) 192 ? !element.disabled 193 : 'a' == nodeName || 'area' == nodeName 194 ? element.href || !isNaN(tabIndex) 195 : !isNaN(tabIndex)) 196 // the element and all of its ancestors must be visible 197 // the browser may report that the area is hidden 198 && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; 199 }, 200 201 tabbable: function(element) { 202 var tabIndex = $.attr(element, 'tabindex'); 203 return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); 204 } 205 }); 206 207 208 // $.widget is a factory to create jQuery plugins 209 // taking some boilerplate code out of the plugin code 210 function getter(namespace, plugin, method, args) { 211 function getMethods(type) { 212 var methods = $[namespace][plugin][type] || []; 213 return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); 214 } 215 216 var methods = getMethods('getter'); 217 if (args.length == 1 && typeof args[0] == 'string') { 218 methods = methods.concat(getMethods('getterSetter')); 219 } 220 return ($.inArray(method, methods) != -1); 221 } 222 223 $.widget = function(name, prototype) { 224 var namespace = name.split(".")[0]; 225 name = name.split(".")[1]; 226 227 // create plugin method 228 $.fn[name] = function(options) { 229 var isMethodCall = (typeof options == 'string'), 230 args = Array.prototype.slice.call(arguments, 1); 231 232 // prevent calls to internal methods 233 if (isMethodCall && options.substring(0, 1) == '_') { 234 return this; 235 } 236 237 // handle getter methods 238 if (isMethodCall && getter(namespace, name, options, args)) { 239 var instance = $.data(this[0], name); 240 return (instance ? instance[options].apply(instance, args) 241 : undefined); 242 } 243 244 // handle initialization and non-getter methods 245 return this.each(function() { 246 var instance = $.data(this, name); 247 248 // constructor 249 (!instance && !isMethodCall && 250 $.data(this, name, new $[namespace][name](this, options))._init()); 251 252 // method call 253 (instance && isMethodCall && $.isFunction(instance[options]) && 254 instance[options].apply(instance, args)); 255 }); 256 }; 257 258 // create widget constructor 259 $[namespace] = $[namespace] || {}; 260 $[namespace][name] = function(element, options) { 261 var self = this; 262 263 this.namespace = namespace; 264 this.widgetName = name; 265 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; 266 this.widgetBaseClass = namespace + '-' + name; 267 268 this.options = $.extend({}, 269 $.widget.defaults, 270 $[namespace][name].defaults, 271 $.metadata && $.metadata.get(element)[name], 272 options); 273 274 this.element = $(element) 275 .bind('setData.' + name, function(event, key, value) { 276 if (event.target == element) { 277 return self._setData(key, value); 278 } 279 }) 280 .bind('getData.' + name, function(event, key) { 281 if (event.target == element) { 282 return self._getData(key); 283 } 284 }) 285 .bind('remove', function() { 286 return self.destroy(); 287 }); 288 }; 289 290 // add widget prototype 291 $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); 292 293 // TODO: merge getter and getterSetter properties from widget prototype 294 // and plugin prototype 295 $[namespace][name].getterSetter = 'option'; 296 }; 297 298 $.widget.prototype = { 299 _init: function() {}, 300 destroy: function() { 301 this.element.removeData(this.widgetName) 302 .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') 303 .removeAttr('aria-disabled'); 304 }, 305 306 option: function(key, value) { 307 var options = key, 308 self = this; 309 310 if (typeof key == "string") { 311 if (value === undefined) { 312 return this._getData(key); 313 } 314 options = {}; 315 options[key] = value; 316 } 317 318 $.each(options, function(key, value) { 319 self._setData(key, value); 320 }); 321 }, 322 _getData: function(key) { 323 return this.options[key]; 324 }, 325 _setData: function(key, value) { 326 this.options[key] = value; 327 328 if (key == 'disabled') { 329 this.element 330 [value ? 'addClass' : 'removeClass']( 331 this.widgetBaseClass + '-disabled' + ' ' + 332 this.namespace + '-state-disabled') 333 .attr("aria-disabled", value); 334 } 335 }, 336 337 enable: function() { 338 this._setData('disabled', false); 339 }, 340 disable: function() { 341 this._setData('disabled', true); 342 }, 343 344 _trigger: function(type, event, data) { 345 var callback = this.options[type], 346 eventName = (type == this.widgetEventPrefix 347 ? type : this.widgetEventPrefix + type); 348 349 event = $.Event(event); 350 event.type = eventName; 351 352 // copy original event properties over to the new event 353 // this would happen if we could call $.event.fix instead of $.Event 354 // but we don't have a way to force an event to be fixed multiple times 355 if (event.originalEvent) { 356 for (var i = $.event.props.length, prop; i;) { 357 prop = $.event.props[--i]; 358 event[prop] = event.originalEvent[prop]; 359 } 360 } 361 362 this.element.trigger(event, data); 363 364 return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false 365 || event.isDefaultPrevented()); 366 } 367 }; 368 369 $.widget.defaults = { 370 disabled: false 371 }; 372 373 374 /** Mouse Interaction Plugin **/ 375 376 $.ui.mouse = { 377 _mouseInit: function() { 378 var self = this; 379 380 this.element 381 .bind('mousedown.'+this.widgetName, function(event) { 382 return self._mouseDown(event); 383 }) 384 .bind('click.'+this.widgetName, function(event) { 385 if(self._preventClickEvent) { 386 self._preventClickEvent = false; 387 event.stopImmediatePropagation(); 388 return false; 389 } 390 }); 391 392 // Prevent text selection in IE 393 if ($.browser.msie) { 394 this._mouseUnselectable = this.element.attr('unselectable'); 395 this.element.attr('unselectable', 'on'); 396 } 397 398 this.started = false; 399 }, 400 401 // TODO: make sure destroying one instance of mouse doesn't mess with 402 // other instances of mouse 403 _mouseDestroy: function() { 404 this.element.unbind('.'+this.widgetName); 405 406 // Restore text selection in IE 407 ($.browser.msie 408 && this.element.attr('unselectable', this._mouseUnselectable)); 409 }, 410 411 _mouseDown: function(event) { 412 // don't let more than one widget handle mouseStart 413 // TODO: figure out why we have to use originalEvent 414 event.originalEvent = event.originalEvent || {}; 415 if (event.originalEvent.mouseHandled) { return; } 416 417 // we may have missed mouseup (out of window) 418 (this._mouseStarted && this._mouseUp(event)); 419 420 this._mouseDownEvent = event; 421 422 var self = this, 423 btnIsLeft = (event.which == 1), 424 elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); 425 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { 426 return true; 427 } 428 429 this.mouseDelayMet = !this.options.delay; 430 if (!this.mouseDelayMet) { 431 this._mouseDelayTimer = setTimeout(function() { 432 self.mouseDelayMet = true; 433 }, this.options.delay); 434 } 435 436 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 437 this._mouseStarted = (this._mouseStart(event) !== false); 438 if (!this._mouseStarted) { 439 event.preventDefault(); 440 return true; 441 } 442 } 443 444 // these delegates are required to keep context 445 this._mouseMoveDelegate = function(event) { 446 return self._mouseMove(event); 447 }; 448 this._mouseUpDelegate = function(event) { 449 return self._mouseUp(event); 450 }; 451 $(document) 452 .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) 453 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); 454 455 // preventDefault() is used to prevent the selection of text here - 456 // however, in Safari, this causes select boxes not to be selectable 457 // anymore, so this fix is needed 458 ($.browser.safari || event.preventDefault()); 459 460 event.originalEvent.mouseHandled = true; 461 return true; 462 }, 463 464 _mouseMove: function(event) { 465 // IE mouseup check - mouseup happened when mouse was out of window 466 if ($.browser.msie && !event.button) { 467 return this._mouseUp(event); 468 } 469 470 if (this._mouseStarted) { 471 this._mouseDrag(event); 472 return event.preventDefault(); 473 } 474 475 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 476 this._mouseStarted = 477 (this._mouseStart(this._mouseDownEvent, event) !== false); 478 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); 479 } 480 481 return !this._mouseStarted; 482 }, 483 484 _mouseUp: function(event) { 485 $(document) 486 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) 487 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); 488 489 if (this._mouseStarted) { 490 this._mouseStarted = false; 491 this._preventClickEvent = (event.target == this._mouseDownEvent.target); 492 this._mouseStop(event); 493 } 494 495 return false; 496 }, 497 498 _mouseDistanceMet: function(event) { 499 return (Math.max( 500 Math.abs(this._mouseDownEvent.pageX - event.pageX), 501 Math.abs(this._mouseDownEvent.pageY - event.pageY) 502 ) >= this.options.distance 503 ); 504 }, 505 506 _mouseDelayMet: function(event) { 507 return this.mouseDelayMet; 508 }, 509 510 // These are placeholder methods, to be overriden by extending plugin 511 _mouseStart: function(event) {}, 512 _mouseDrag: function(event) {}, 513 _mouseStop: function(event) {}, 514 _mouseCapture: function(event) { return true; } 515 }; 516 517 $.ui.mouse.defaults = { 518 cancel: null, 519 distance: 1, 520 delay: 0 521 }; 522 523 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |