7ee7ec3f09a8bd3a32f02e2bf9c4890e744cf2b3.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. /*! jQuery UI - v1.11.1 - 2014-09-17
  2. * http://jqueryui.com
  3. * Includes: widget.js
  4. * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Widget 1.11.1
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/jQuery.widget/
  23. */
  24. var widget_uuid = 0,
  25. widget_slice = Array.prototype.slice;
  26. $.cleanData = (function( orig ) {
  27. return function( elems ) {
  28. var events, elem, i;
  29. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  30. try {
  31. // Only trigger remove when necessary to save time
  32. events = $._data( elem, "events" );
  33. if ( events && events.remove ) {
  34. $( elem ).triggerHandler( "remove" );
  35. }
  36. // http://bugs.jquery.com/ticket/8235
  37. } catch( e ) {}
  38. }
  39. orig( elems );
  40. };
  41. })( $.cleanData );
  42. $.widget = function( name, base, prototype ) {
  43. var fullName, existingConstructor, constructor, basePrototype,
  44. // proxiedPrototype allows the provided prototype to remain unmodified
  45. // so that it can be used as a mixin for multiple widgets (#8876)
  46. proxiedPrototype = {},
  47. namespace = name.split( "." )[ 0 ];
  48. name = name.split( "." )[ 1 ];
  49. fullName = namespace + "-" + name;
  50. if ( !prototype ) {
  51. prototype = base;
  52. base = $.Widget;
  53. }
  54. // create selector for plugin
  55. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  56. return !!$.data( elem, fullName );
  57. };
  58. $[ namespace ] = $[ namespace ] || {};
  59. existingConstructor = $[ namespace ][ name ];
  60. constructor = $[ namespace ][ name ] = function( options, element ) {
  61. // allow instantiation without "new" keyword
  62. if ( !this._createWidget ) {
  63. return new constructor( options, element );
  64. }
  65. // allow instantiation without initializing for simple inheritance
  66. // must use "new" keyword (the code above always passes args)
  67. if ( arguments.length ) {
  68. this._createWidget( options, element );
  69. }
  70. };
  71. // extend with the existing constructor to carry over any static properties
  72. $.extend( constructor, existingConstructor, {
  73. version: prototype.version,
  74. // copy the object used to create the prototype in case we need to
  75. // redefine the widget later
  76. _proto: $.extend( {}, prototype ),
  77. // track widgets that inherit from this widget in case this widget is
  78. // redefined after a widget inherits from it
  79. _childConstructors: []
  80. });
  81. basePrototype = new base();
  82. // we need to make the options hash a property directly on the new instance
  83. // otherwise we'll modify the options hash on the prototype that we're
  84. // inheriting from
  85. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  86. $.each( prototype, function( prop, value ) {
  87. if ( !$.isFunction( value ) ) {
  88. proxiedPrototype[ prop ] = value;
  89. return;
  90. }
  91. proxiedPrototype[ prop ] = (function() {
  92. var _super = function() {
  93. return base.prototype[ prop ].apply( this, arguments );
  94. },
  95. _superApply = function( args ) {
  96. return base.prototype[ prop ].apply( this, args );
  97. };
  98. return function() {
  99. var __super = this._super,
  100. __superApply = this._superApply,
  101. returnValue;
  102. this._super = _super;
  103. this._superApply = _superApply;
  104. returnValue = value.apply( this, arguments );
  105. this._super = __super;
  106. this._superApply = __superApply;
  107. return returnValue;
  108. };
  109. })();
  110. });
  111. constructor.prototype = $.widget.extend( basePrototype, {
  112. // TODO: remove support for widgetEventPrefix
  113. // always use the name + a colon as the prefix, e.g., draggable:start
  114. // don't prefix for widgets that aren't DOM-based
  115. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  116. }, proxiedPrototype, {
  117. constructor: constructor,
  118. namespace: namespace,
  119. widgetName: name,
  120. widgetFullName: fullName
  121. });
  122. // If this widget is being redefined then we need to find all widgets that
  123. // are inheriting from it and redefine all of them so that they inherit from
  124. // the new version of this widget. We're essentially trying to replace one
  125. // level in the prototype chain.
  126. if ( existingConstructor ) {
  127. $.each( existingConstructor._childConstructors, function( i, child ) {
  128. var childPrototype = child.prototype;
  129. // redefine the child widget using the same prototype that was
  130. // originally used, but inherit from the new version of the base
  131. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  132. });
  133. // remove the list of existing child constructors from the old constructor
  134. // so the old child constructors can be garbage collected
  135. delete existingConstructor._childConstructors;
  136. } else {
  137. base._childConstructors.push( constructor );
  138. }
  139. $.widget.bridge( name, constructor );
  140. return constructor;
  141. };
  142. $.widget.extend = function( target ) {
  143. var input = widget_slice.call( arguments, 1 ),
  144. inputIndex = 0,
  145. inputLength = input.length,
  146. key,
  147. value;
  148. for ( ; inputIndex < inputLength; inputIndex++ ) {
  149. for ( key in input[ inputIndex ] ) {
  150. value = input[ inputIndex ][ key ];
  151. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  152. // Clone objects
  153. if ( $.isPlainObject( value ) ) {
  154. target[ key ] = $.isPlainObject( target[ key ] ) ?
  155. $.widget.extend( {}, target[ key ], value ) :
  156. // Don't extend strings, arrays, etc. with objects
  157. $.widget.extend( {}, value );
  158. // Copy everything else by reference
  159. } else {
  160. target[ key ] = value;
  161. }
  162. }
  163. }
  164. }
  165. return target;
  166. };
  167. $.widget.bridge = function( name, object ) {
  168. var fullName = object.prototype.widgetFullName || name;
  169. $.fn[ name ] = function( options ) {
  170. var isMethodCall = typeof options === "string",
  171. args = widget_slice.call( arguments, 1 ),
  172. returnValue = this;
  173. // allow multiple hashes to be passed on init
  174. options = !isMethodCall && args.length ?
  175. $.widget.extend.apply( null, [ options ].concat(args) ) :
  176. options;
  177. if ( isMethodCall ) {
  178. this.each(function() {
  179. var methodValue,
  180. instance = $.data( this, fullName );
  181. if ( options === "instance" ) {
  182. returnValue = instance;
  183. return false;
  184. }
  185. if ( !instance ) {
  186. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  187. "attempted to call method '" + options + "'" );
  188. }
  189. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  190. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  191. }
  192. methodValue = instance[ options ].apply( instance, args );
  193. if ( methodValue !== instance && methodValue !== undefined ) {
  194. returnValue = methodValue && methodValue.jquery ?
  195. returnValue.pushStack( methodValue.get() ) :
  196. methodValue;
  197. return false;
  198. }
  199. });
  200. } else {
  201. this.each(function() {
  202. var instance = $.data( this, fullName );
  203. if ( instance ) {
  204. instance.option( options || {} );
  205. if ( instance._init ) {
  206. instance._init();
  207. }
  208. } else {
  209. $.data( this, fullName, new object( options, this ) );
  210. }
  211. });
  212. }
  213. return returnValue;
  214. };
  215. };
  216. $.Widget = function( /* options, element */ ) {};
  217. $.Widget._childConstructors = [];
  218. $.Widget.prototype = {
  219. widgetName: "widget",
  220. widgetEventPrefix: "",
  221. defaultElement: "<div>",
  222. options: {
  223. disabled: false,
  224. // callbacks
  225. create: null
  226. },
  227. _createWidget: function( options, element ) {
  228. element = $( element || this.defaultElement || this )[ 0 ];
  229. this.element = $( element );
  230. this.uuid = widget_uuid++;
  231. this.eventNamespace = "." + this.widgetName + this.uuid;
  232. this.options = $.widget.extend( {},
  233. this.options,
  234. this._getCreateOptions(),
  235. options );
  236. this.bindings = $();
  237. this.hoverable = $();
  238. this.focusable = $();
  239. if ( element !== this ) {
  240. $.data( element, this.widgetFullName, this );
  241. this._on( true, this.element, {
  242. remove: function( event ) {
  243. if ( event.target === element ) {
  244. this.destroy();
  245. }
  246. }
  247. });
  248. this.document = $( element.style ?
  249. // element within the document
  250. element.ownerDocument :
  251. // element is window or document
  252. element.document || element );
  253. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  254. }
  255. this._create();
  256. this._trigger( "create", null, this._getCreateEventData() );
  257. this._init();
  258. },
  259. _getCreateOptions: $.noop,
  260. _getCreateEventData: $.noop,
  261. _create: $.noop,
  262. _init: $.noop,
  263. destroy: function() {
  264. this._destroy();
  265. // we can probably remove the unbind calls in 2.0
  266. // all event bindings should go through this._on()
  267. this.element
  268. .unbind( this.eventNamespace )
  269. .removeData( this.widgetFullName )
  270. // support: jquery <1.6.3
  271. // http://bugs.jquery.com/ticket/9413
  272. .removeData( $.camelCase( this.widgetFullName ) );
  273. this.widget()
  274. .unbind( this.eventNamespace )
  275. .removeAttr( "aria-disabled" )
  276. .removeClass(
  277. this.widgetFullName + "-disabled " +
  278. "ui-state-disabled" );
  279. // clean up events and states
  280. this.bindings.unbind( this.eventNamespace );
  281. this.hoverable.removeClass( "ui-state-hover" );
  282. this.focusable.removeClass( "ui-state-focus" );
  283. },
  284. _destroy: $.noop,
  285. widget: function() {
  286. return this.element;
  287. },
  288. option: function( key, value ) {
  289. var options = key,
  290. parts,
  291. curOption,
  292. i;
  293. if ( arguments.length === 0 ) {
  294. // don't return a reference to the internal hash
  295. return $.widget.extend( {}, this.options );
  296. }
  297. if ( typeof key === "string" ) {
  298. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  299. options = {};
  300. parts = key.split( "." );
  301. key = parts.shift();
  302. if ( parts.length ) {
  303. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  304. for ( i = 0; i < parts.length - 1; i++ ) {
  305. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  306. curOption = curOption[ parts[ i ] ];
  307. }
  308. key = parts.pop();
  309. if ( arguments.length === 1 ) {
  310. return curOption[ key ] === undefined ? null : curOption[ key ];
  311. }
  312. curOption[ key ] = value;
  313. } else {
  314. if ( arguments.length === 1 ) {
  315. return this.options[ key ] === undefined ? null : this.options[ key ];
  316. }
  317. options[ key ] = value;
  318. }
  319. }
  320. this._setOptions( options );
  321. return this;
  322. },
  323. _setOptions: function( options ) {
  324. var key;
  325. for ( key in options ) {
  326. this._setOption( key, options[ key ] );
  327. }
  328. return this;
  329. },
  330. _setOption: function( key, value ) {
  331. this.options[ key ] = value;
  332. if ( key === "disabled" ) {
  333. this.widget()
  334. .toggleClass( this.widgetFullName + "-disabled", !!value );
  335. // If the widget is becoming disabled, then nothing is interactive
  336. if ( value ) {
  337. this.hoverable.removeClass( "ui-state-hover" );
  338. this.focusable.removeClass( "ui-state-focus" );
  339. }
  340. }
  341. return this;
  342. },
  343. enable: function() {
  344. return this._setOptions({ disabled: false });
  345. },
  346. disable: function() {
  347. return this._setOptions({ disabled: true });
  348. },
  349. _on: function( suppressDisabledCheck, element, handlers ) {
  350. var delegateElement,
  351. instance = this;
  352. // no suppressDisabledCheck flag, shuffle arguments
  353. if ( typeof suppressDisabledCheck !== "boolean" ) {
  354. handlers = element;
  355. element = suppressDisabledCheck;
  356. suppressDisabledCheck = false;
  357. }
  358. // no element argument, shuffle and use this.element
  359. if ( !handlers ) {
  360. handlers = element;
  361. element = this.element;
  362. delegateElement = this.widget();
  363. } else {
  364. element = delegateElement = $( element );
  365. this.bindings = this.bindings.add( element );
  366. }
  367. $.each( handlers, function( event, handler ) {
  368. function handlerProxy() {
  369. // allow widgets to customize the disabled handling
  370. // - disabled as an array instead of boolean
  371. // - disabled class as method for disabling individual parts
  372. if ( !suppressDisabledCheck &&
  373. ( instance.options.disabled === true ||
  374. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  375. return;
  376. }
  377. return ( typeof handler === "string" ? instance[ handler ] : handler )
  378. .apply( instance, arguments );
  379. }
  380. // copy the guid so direct unbinding works
  381. if ( typeof handler !== "string" ) {
  382. handlerProxy.guid = handler.guid =
  383. handler.guid || handlerProxy.guid || $.guid++;
  384. }
  385. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  386. eventName = match[1] + instance.eventNamespace,
  387. selector = match[2];
  388. if ( selector ) {
  389. delegateElement.delegate( selector, eventName, handlerProxy );
  390. } else {
  391. element.bind( eventName, handlerProxy );
  392. }
  393. });
  394. },
  395. _off: function( element, eventName ) {
  396. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  397. element.unbind( eventName ).undelegate( eventName );
  398. },
  399. _delay: function( handler, delay ) {
  400. function handlerProxy() {
  401. return ( typeof handler === "string" ? instance[ handler ] : handler )
  402. .apply( instance, arguments );
  403. }
  404. var instance = this;
  405. return setTimeout( handlerProxy, delay || 0 );
  406. },
  407. _hoverable: function( element ) {
  408. this.hoverable = this.hoverable.add( element );
  409. this._on( element, {
  410. mouseenter: function( event ) {
  411. $( event.currentTarget ).addClass( "ui-state-hover" );
  412. },
  413. mouseleave: function( event ) {
  414. $( event.currentTarget ).removeClass( "ui-state-hover" );
  415. }
  416. });
  417. },
  418. _focusable: function( element ) {
  419. this.focusable = this.focusable.add( element );
  420. this._on( element, {
  421. focusin: function( event ) {
  422. $( event.currentTarget ).addClass( "ui-state-focus" );
  423. },
  424. focusout: function( event ) {
  425. $( event.currentTarget ).removeClass( "ui-state-focus" );
  426. }
  427. });
  428. },
  429. _trigger: function( type, event, data ) {
  430. var prop, orig,
  431. callback = this.options[ type ];
  432. data = data || {};
  433. event = $.Event( event );
  434. event.type = ( type === this.widgetEventPrefix ?
  435. type :
  436. this.widgetEventPrefix + type ).toLowerCase();
  437. // the original event may come from any element
  438. // so we need to reset the target on the new event
  439. event.target = this.element[ 0 ];
  440. // copy original event properties over to the new event
  441. orig = event.originalEvent;
  442. if ( orig ) {
  443. for ( prop in orig ) {
  444. if ( !( prop in event ) ) {
  445. event[ prop ] = orig[ prop ];
  446. }
  447. }
  448. }
  449. this.element.trigger( event, data );
  450. return !( $.isFunction( callback ) &&
  451. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  452. event.isDefaultPrevented() );
  453. }
  454. };
  455. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  456. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  457. if ( typeof options === "string" ) {
  458. options = { effect: options };
  459. }
  460. var hasOptions,
  461. effectName = !options ?
  462. method :
  463. options === true || typeof options === "number" ?
  464. defaultEffect :
  465. options.effect || defaultEffect;
  466. options = options || {};
  467. if ( typeof options === "number" ) {
  468. options = { duration: options };
  469. }
  470. hasOptions = !$.isEmptyObject( options );
  471. options.complete = callback;
  472. if ( options.delay ) {
  473. element.delay( options.delay );
  474. }
  475. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  476. element[ method ]( options );
  477. } else if ( effectName !== method && element[ effectName ] ) {
  478. element[ effectName ]( options.duration, options.easing, callback );
  479. } else {
  480. element.queue(function( next ) {
  481. $( this )[ method ]();
  482. if ( callback ) {
  483. callback.call( element[ 0 ] );
  484. }
  485. next();
  486. });
  487. }
  488. };
  489. });
  490. var widget = $.widget;
  491. }));