core.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*!
  2. * jQuery UI Core 1.11.2
  3. * http://jqueryui.com
  4. *
  5. * Copyright 2014 jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. *
  9. * http://api.jqueryui.com/category/ui-core/
  10. */
  11. (function( factory ) {
  12. if ( typeof define === "function" && define.amd ) {
  13. // AMD. Register as an anonymous module.
  14. define( [ "jquery" ], factory );
  15. } else {
  16. // Browser globals
  17. factory( jQuery );
  18. }
  19. }(function( $ ) {
  20. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  21. $.ui = $.ui || {};
  22. $.extend( $.ui, {
  23. version: "1.11.2",
  24. keyCode: {
  25. BACKSPACE: 8,
  26. COMMA: 188,
  27. DELETE: 46,
  28. DOWN: 40,
  29. END: 35,
  30. ENTER: 13,
  31. ESCAPE: 27,
  32. HOME: 36,
  33. LEFT: 37,
  34. PAGE_DOWN: 34,
  35. PAGE_UP: 33,
  36. PERIOD: 190,
  37. RIGHT: 39,
  38. SPACE: 32,
  39. TAB: 9,
  40. UP: 38
  41. }
  42. });
  43. // plugins
  44. $.fn.extend({
  45. scrollParent: function( includeHidden ) {
  46. var position = this.css( "position" ),
  47. excludeStaticParent = position === "absolute",
  48. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  49. scrollParent = this.parents().filter( function() {
  50. var parent = $( this );
  51. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  52. return false;
  53. }
  54. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  55. }).eq( 0 );
  56. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  57. },
  58. uniqueId: (function() {
  59. var uuid = 0;
  60. return function() {
  61. return this.each(function() {
  62. if ( !this.id ) {
  63. this.id = "ui-id-" + ( ++uuid );
  64. }
  65. });
  66. };
  67. })(),
  68. removeUniqueId: function() {
  69. return this.each(function() {
  70. if ( /^ui-id-\d+$/.test( this.id ) ) {
  71. $( this ).removeAttr( "id" );
  72. }
  73. });
  74. }
  75. });
  76. // selectors
  77. function focusable( element, isTabIndexNotNaN ) {
  78. var map, mapName, img,
  79. nodeName = element.nodeName.toLowerCase();
  80. if ( "area" === nodeName ) {
  81. map = element.parentNode;
  82. mapName = map.name;
  83. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  84. return false;
  85. }
  86. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  87. return !!img && visible( img );
  88. }
  89. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  90. !element.disabled :
  91. "a" === nodeName ?
  92. element.href || isTabIndexNotNaN :
  93. isTabIndexNotNaN) &&
  94. // the element and all of its ancestors must be visible
  95. visible( element );
  96. }
  97. function visible( element ) {
  98. return $.expr.filters.visible( element ) &&
  99. !$( element ).parents().addBack().filter(function() {
  100. return $.css( this, "visibility" ) === "hidden";
  101. }).length;
  102. }
  103. $.extend( $.expr[ ":" ], {
  104. data: $.expr.createPseudo ?
  105. $.expr.createPseudo(function( dataName ) {
  106. return function( elem ) {
  107. return !!$.data( elem, dataName );
  108. };
  109. }) :
  110. // support: jQuery <1.8
  111. function( elem, i, match ) {
  112. return !!$.data( elem, match[ 3 ] );
  113. },
  114. focusable: function( element ) {
  115. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  116. },
  117. tabbable: function( element ) {
  118. var tabIndex = $.attr( element, "tabindex" ),
  119. isTabIndexNaN = isNaN( tabIndex );
  120. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  121. }
  122. });
  123. // support: jQuery <1.8
  124. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  125. $.each( [ "Width", "Height" ], function( i, name ) {
  126. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  127. type = name.toLowerCase(),
  128. orig = {
  129. innerWidth: $.fn.innerWidth,
  130. innerHeight: $.fn.innerHeight,
  131. outerWidth: $.fn.outerWidth,
  132. outerHeight: $.fn.outerHeight
  133. };
  134. function reduce( elem, size, border, margin ) {
  135. $.each( side, function() {
  136. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  137. if ( border ) {
  138. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  139. }
  140. if ( margin ) {
  141. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  142. }
  143. });
  144. return size;
  145. }
  146. $.fn[ "inner" + name ] = function( size ) {
  147. if ( size === undefined ) {
  148. return orig[ "inner" + name ].call( this );
  149. }
  150. return this.each(function() {
  151. $( this ).css( type, reduce( this, size ) + "px" );
  152. });
  153. };
  154. $.fn[ "outer" + name] = function( size, margin ) {
  155. if ( typeof size !== "number" ) {
  156. return orig[ "outer" + name ].call( this, size );
  157. }
  158. return this.each(function() {
  159. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  160. });
  161. };
  162. });
  163. }
  164. // support: jQuery <1.8
  165. if ( !$.fn.addBack ) {
  166. $.fn.addBack = function( selector ) {
  167. return this.add( selector == null ?
  168. this.prevObject : this.prevObject.filter( selector )
  169. );
  170. };
  171. }
  172. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  173. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  174. $.fn.removeData = (function( removeData ) {
  175. return function( key ) {
  176. if ( arguments.length ) {
  177. return removeData.call( this, $.camelCase( key ) );
  178. } else {
  179. return removeData.call( this );
  180. }
  181. };
  182. })( $.fn.removeData );
  183. }
  184. // deprecated
  185. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  186. $.fn.extend({
  187. focus: (function( orig ) {
  188. return function( delay, fn ) {
  189. return typeof delay === "number" ?
  190. this.each(function() {
  191. var elem = this;
  192. setTimeout(function() {
  193. $( elem ).focus();
  194. if ( fn ) {
  195. fn.call( elem );
  196. }
  197. }, delay );
  198. }) :
  199. orig.apply( this, arguments );
  200. };
  201. })( $.fn.focus ),
  202. disableSelection: (function() {
  203. var eventType = "onselectstart" in document.createElement( "div" ) ?
  204. "selectstart" :
  205. "mousedown";
  206. return function() {
  207. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  208. event.preventDefault();
  209. });
  210. };
  211. })(),
  212. enableSelection: function() {
  213. return this.unbind( ".ui-disableSelection" );
  214. },
  215. zIndex: function( zIndex ) {
  216. if ( zIndex !== undefined ) {
  217. return this.css( "zIndex", zIndex );
  218. }
  219. if ( this.length ) {
  220. var elem = $( this[ 0 ] ), position, value;
  221. while ( elem.length && elem[ 0 ] !== document ) {
  222. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  223. // This makes behavior of this function consistent across browsers
  224. // WebKit always returns auto if the element is positioned
  225. position = elem.css( "position" );
  226. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  227. // IE returns 0 when zIndex is not specified
  228. // other browsers return a string
  229. // we ignore the case of nested elements with an explicit value of 0
  230. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  231. value = parseInt( elem.css( "zIndex" ), 10 );
  232. if ( !isNaN( value ) && value !== 0 ) {
  233. return value;
  234. }
  235. }
  236. elem = elem.parent();
  237. }
  238. }
  239. return 0;
  240. }
  241. });
  242. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  243. $.ui.plugin = {
  244. add: function( module, option, set ) {
  245. var i,
  246. proto = $.ui[ module ].prototype;
  247. for ( i in set ) {
  248. proto.plugins[ i ] = proto.plugins[ i ] || [];
  249. proto.plugins[ i ].push( [ option, set[ i ] ] );
  250. }
  251. },
  252. call: function( instance, name, args, allowDisconnected ) {
  253. var i,
  254. set = instance.plugins[ name ];
  255. if ( !set ) {
  256. return;
  257. }
  258. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  259. return;
  260. }
  261. for ( i = 0; i < set.length; i++ ) {
  262. if ( instance.options[ set[ i ][ 0 ] ] ) {
  263. set[ i ][ 1 ].apply( instance.element, args );
  264. }
  265. }
  266. }
  267. };
  268. }));