sonata_jqueryui_js_jquery.ui.core_1.js 8.0 KB

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