src/cm/media/js/lib/yui/yui3-3.15.0/build/shim-plugin/shim-plugin-debug.js
changeset 602 e16a97fb364a
equal deleted inserted replaced
601:d334a616c023 602:e16a97fb364a
       
     1 YUI.add('shim-plugin', function (Y, NAME) {
       
     2 
       
     3     /**
       
     4      * Provides shimming support for Node via a Plugin.
       
     5      * This fixes SELECT bleedthrough for IE6 & Mac scrollbars
       
     6      * @module shim-plugin
       
     7      */
       
     8 
       
     9     /**
       
    10      * Node plugin which can be used to add shim support.
       
    11      *
       
    12      * @class Plugin.Shim
       
    13      * @param {Object} User configuration object
       
    14      */
       
    15     function Shim(config) {
       
    16         this.init(config);
       
    17     }
       
    18 
       
    19     /**
       
    20      * Default class used to mark the shim element
       
    21      *
       
    22      * @property CLASS_NAME
       
    23      * @type String
       
    24      * @static
       
    25      * @default "yui-node-shim"
       
    26      */
       
    27     // TODO: use ClassNameManager
       
    28     Shim.CLASS_NAME = 'yui-node-shim';
       
    29 
       
    30     /**
       
    31      * Default markup template used to generate the shim element.
       
    32      *
       
    33      * @property TEMPLATE
       
    34      * @type String
       
    35      * @static
       
    36      */
       
    37     Shim.TEMPLATE = '<iframe class="' + Shim.CLASS_NAME +
       
    38             '" frameborder="0" title="Node Stacking Shim"' +
       
    39             'src="javascript:false" tabindex="-1" role="presentation"' +
       
    40             'style="position:absolute; z-index:-1;"></iframe>';
       
    41 
       
    42     Shim.prototype = {
       
    43         init: function(config) {
       
    44             this._host = config.host;
       
    45             this.initEvents();
       
    46             this.insert();
       
    47             this.sync();
       
    48         },
       
    49 
       
    50         initEvents: function() {
       
    51             this._resizeHandle = this._host.on('resize', this.sync, this);
       
    52         },
       
    53 
       
    54         getShim: function() {
       
    55             return this._shim || (
       
    56                 this._shim = Y.Node.create(
       
    57                     Shim.TEMPLATE,
       
    58                     this._host.get('ownerDocument')
       
    59                 )
       
    60             );
       
    61         },
       
    62 
       
    63         insert: function() {
       
    64             var node = this._host;
       
    65             this._shim = node.insertBefore( this.getShim(),
       
    66                     node.get('firstChild'));
       
    67         },
       
    68 
       
    69         /**
       
    70          * Updates the size of the shim to fill its container
       
    71          * @method sync
       
    72          */
       
    73         sync: function() {
       
    74             var shim = this._shim,
       
    75                 node = this._host;
       
    76 
       
    77             if (shim) {
       
    78                 shim.setAttrs({
       
    79                     width: node.getStyle('width'),
       
    80                     height: node.getStyle('height')
       
    81                 });
       
    82             }
       
    83         },
       
    84 
       
    85         /**
       
    86          * Removes the shim and destroys the plugin
       
    87          * @method destroy
       
    88          */
       
    89         destroy: function() {
       
    90             var shim = this._shim;
       
    91             if (shim) {
       
    92                 shim.remove(true);
       
    93             }
       
    94 
       
    95             this._resizeHandle.detach();
       
    96         }
       
    97     };
       
    98 
       
    99     Shim.NAME = 'Shim';
       
   100     Shim.NS = 'shim';
       
   101 
       
   102     Y.namespace('Plugin');
       
   103     Y.Plugin.Shim = Shim;
       
   104 
       
   105 
       
   106 }, '@VERSION@', {"requires": ["node-style", "node-pluginhost"]});