[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/resources/lib/jquery.ui/ -> jquery.ui.core.js (source)

   1  /*!
   2   * jQuery UI Core 1.9.2
   3   * http://jqueryui.com
   4   *
   5   * Copyright 2012 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  
  13  var uuid = 0,
  14      runiqueId = /^ui-id-\d+$/;
  15  
  16  // prevent duplicate loading
  17  // this is only a problem because we proxy existing functions
  18  // and we don't want to double proxy them
  19  $.ui = $.ui || {};
  20  if ( $.ui.version ) {
  21      return;
  22  }
  23  
  24  $.extend( $.ui, {
  25      version: "1.9.2",
  26  
  27      keyCode: {
  28          BACKSPACE: 8,
  29          COMMA: 188,
  30          DELETE: 46,
  31          DOWN: 40,
  32          END: 35,
  33          ENTER: 13,
  34          ESCAPE: 27,
  35          HOME: 36,
  36          LEFT: 37,
  37          NUMPAD_ADD: 107,
  38          NUMPAD_DECIMAL: 110,
  39          NUMPAD_DIVIDE: 111,
  40          NUMPAD_ENTER: 108,
  41          NUMPAD_MULTIPLY: 106,
  42          NUMPAD_SUBTRACT: 109,
  43          PAGE_DOWN: 34,
  44          PAGE_UP: 33,
  45          PERIOD: 190,
  46          RIGHT: 39,
  47          SPACE: 32,
  48          TAB: 9,
  49          UP: 38
  50      }
  51  });
  52  
  53  // plugins
  54  $.fn.extend({
  55      _focus: $.fn.focus,
  56      focus: function( delay, fn ) {
  57          return typeof delay === "number" ?
  58              this.each(function() {
  59                  var elem = this;
  60                  setTimeout(function() {
  61                      $( elem ).focus();
  62                      if ( fn ) {
  63                          fn.call( elem );
  64                      }
  65                  }, delay );
  66              }) :
  67              this._focus.apply( this, arguments );
  68      },
  69  
  70      scrollParent: function() {
  71          var scrollParent;
  72          if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  73              scrollParent = this.parents().filter(function() {
  74                  return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  75              }).eq(0);
  76          } else {
  77              scrollParent = this.parents().filter(function() {
  78                  return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  79              }).eq(0);
  80          }
  81  
  82          return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  83      },
  84  
  85      zIndex: function( zIndex ) {
  86          if ( zIndex !== undefined ) {
  87              return this.css( "zIndex", zIndex );
  88          }
  89  
  90          if ( this.length ) {
  91              var elem = $( this[ 0 ] ), position, value;
  92              while ( elem.length && elem[ 0 ] !== document ) {
  93                  // Ignore z-index if position is set to a value where z-index is ignored by the browser
  94                  // This makes behavior of this function consistent across browsers
  95                  // WebKit always returns auto if the element is positioned
  96                  position = elem.css( "position" );
  97                  if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  98                      // IE returns 0 when zIndex is not specified
  99                      // other browsers return a string
 100                      // we ignore the case of nested elements with an explicit value of 0
 101                      // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
 102                      value = parseInt( elem.css( "zIndex" ), 10 );
 103                      if ( !isNaN( value ) && value !== 0 ) {
 104                          return value;
 105                      }
 106                  }
 107                  elem = elem.parent();
 108              }
 109          }
 110  
 111          return 0;
 112      },
 113  
 114      uniqueId: function() {
 115          return this.each(function() {
 116              if ( !this.id ) {
 117                  this.id = "ui-id-" + (++uuid);
 118              }
 119          });
 120      },
 121  
 122      removeUniqueId: function() {
 123          return this.each(function() {
 124              if ( runiqueId.test( this.id ) ) {
 125                  $( this ).removeAttr( "id" );
 126              }
 127          });
 128      }
 129  });
 130  
 131  // selectors
 132  function focusable( element, isTabIndexNotNaN ) {
 133      var map, mapName, img,
 134          nodeName = element.nodeName.toLowerCase();
 135      if ( "area" === nodeName ) {
 136          map = element.parentNode;
 137          mapName = map.name;
 138          if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
 139              return false;
 140          }
 141          img = $( "img[usemap=#" + mapName + "]" )[0];
 142          return !!img && visible( img );
 143      }
 144      return ( /input|select|textarea|button|object/.test( nodeName ) ?
 145          !element.disabled :
 146          "a" === nodeName ?
 147              element.href || isTabIndexNotNaN :
 148              isTabIndexNotNaN) &&
 149          // the element and all of its ancestors must be visible
 150          visible( element );
 151  }
 152  
 153  function visible( element ) {
 154      return $.expr.filters.visible( element ) &&
 155          !$( element ).parents().andSelf().filter(function() {
 156              return $.css( this, "visibility" ) === "hidden";
 157          }).length;
 158  }
 159  
 160  $.extend( $.expr[ ":" ], {
 161      data: $.expr.createPseudo ?
 162          $.expr.createPseudo(function( dataName ) {
 163              return function( elem ) {
 164                  return !!$.data( elem, dataName );
 165              };
 166          }) :
 167          // support: jQuery <1.8
 168          function( elem, i, match ) {
 169              return !!$.data( elem, match[ 3 ] );
 170          },
 171  
 172      focusable: function( element ) {
 173          return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
 174      },
 175  
 176      tabbable: function( element ) {
 177          var tabIndex = $.attr( element, "tabindex" ),
 178              isTabIndexNaN = isNaN( tabIndex );
 179          return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
 180      }
 181  });
 182  
 183  // support
 184  $(function() {
 185      var body = document.body,
 186          div = body.appendChild( div = document.createElement( "div" ) );
 187  
 188      // access offsetHeight before setting the style to prevent a layout bug
 189      // in IE 9 which causes the element to continue to take up space even
 190      // after it is removed from the DOM (#8026)
 191      div.offsetHeight;
 192  
 193      $.extend( div.style, {
 194          minHeight: "100px",
 195          height: "auto",
 196          padding: 0,
 197          borderWidth: 0
 198      });
 199  
 200      $.support.minHeight = div.offsetHeight === 100;
 201      $.support.selectstart = "onselectstart" in div;
 202  
 203      // set display to none to avoid a layout bug in IE
 204      // http://dev.jquery.com/ticket/4014
 205      body.removeChild( div ).style.display = "none";
 206  });
 207  
 208  // support: jQuery <1.8
 209  if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
 210      $.each( [ "Width", "Height" ], function( i, name ) {
 211          var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
 212              type = name.toLowerCase(),
 213              orig = {
 214                  innerWidth: $.fn.innerWidth,
 215                  innerHeight: $.fn.innerHeight,
 216                  outerWidth: $.fn.outerWidth,
 217                  outerHeight: $.fn.outerHeight
 218              };
 219  
 220  		function reduce( elem, size, border, margin ) {
 221              $.each( side, function() {
 222                  size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
 223                  if ( border ) {
 224                      size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
 225                  }
 226                  if ( margin ) {
 227                      size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
 228                  }
 229              });
 230              return size;
 231          }
 232  
 233          $.fn[ "inner" + name ] = function( size ) {
 234              if ( size === undefined ) {
 235                  return orig[ "inner" + name ].call( this );
 236              }
 237  
 238              return this.each(function() {
 239                  $( this ).css( type, reduce( this, size ) + "px" );
 240              });
 241          };
 242  
 243          $.fn[ "outer" + name] = function( size, margin ) {
 244              if ( typeof size !== "number" ) {
 245                  return orig[ "outer" + name ].call( this, size );
 246              }
 247  
 248              return this.each(function() {
 249                  $( this).css( type, reduce( this, size, true, margin ) + "px" );
 250              });
 251          };
 252      });
 253  }
 254  
 255  // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
 256  if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
 257      $.fn.removeData = (function( removeData ) {
 258          return function( key ) {
 259              if ( arguments.length ) {
 260                  return removeData.call( this, $.camelCase( key ) );
 261              } else {
 262                  return removeData.call( this );
 263              }
 264          };
 265      })( $.fn.removeData );
 266  }
 267  
 268  
 269  
 270  
 271  
 272  // deprecated
 273  
 274  (function() {
 275      var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
 276      $.ui.ie = uaMatch.length ? true : false;
 277      $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
 278  })();
 279  
 280  $.fn.extend({
 281      disableSelection: function() {
 282          return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
 283              ".ui-disableSelection", function( event ) {
 284                  event.preventDefault();
 285              });
 286      },
 287  
 288      enableSelection: function() {
 289          return this.unbind( ".ui-disableSelection" );
 290      }
 291  });
 292  
 293  $.extend( $.ui, {
 294      // $.ui.plugin is deprecated.  Use the proxy pattern instead.
 295      plugin: {
 296          add: function( module, option, set ) {
 297              var i,
 298                  proto = $.ui[ module ].prototype;
 299              for ( i in set ) {
 300                  proto.plugins[ i ] = proto.plugins[ i ] || [];
 301                  proto.plugins[ i ].push( [ option, set[ i ] ] );
 302              }
 303          },
 304          call: function( instance, name, args ) {
 305              var i,
 306                  set = instance.plugins[ name ];
 307              if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
 308                  return;
 309              }
 310  
 311              for ( i = 0; i < set.length; i++ ) {
 312                  if ( instance.options[ set[ i ][ 0 ] ] ) {
 313                      set[ i ][ 1 ].apply( instance.element, args );
 314                  }
 315              }
 316          }
 317      },
 318  
 319      contains: $.contains,
 320  
 321      // only used by resizable
 322      hasScroll: function( el, a ) {
 323  
 324          //If overflow is hidden, the element might have extra content, but the user wants to hide it
 325          if ( $( el ).css( "overflow" ) === "hidden") {
 326              return false;
 327          }
 328  
 329          var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
 330              has = false;
 331  
 332          if ( el[ scroll ] > 0 ) {
 333              return true;
 334          }
 335  
 336          // TODO: determine which cases actually cause this to happen
 337          // if the element doesn't have the scroll set, see if it's possible to
 338          // set the scroll
 339          el[ scroll ] = 1;
 340          has = ( el[ scroll ] > 0 );
 341          el[ scroll ] = 0;
 342          return has;
 343      },
 344  
 345      // these are odd functions, fix the API or move into individual plugins
 346      isOverAxis: function( x, reference, size ) {
 347          //Determines when x coordinate is over "b" element axis
 348          return ( x > reference ) && ( x < ( reference + size ) );
 349      },
 350      isOver: function( y, x, top, left, height, width ) {
 351          //Determines when x, y coordinates is over "b" element
 352          return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
 353      }
 354  });
 355  
 356  })( jQuery );


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1