API Docs for: 3.8.0
Show:

File: node/js/shim-plugin.js

  1.     /**
  2.      * Provides shimming support for Node via a Plugin.
  3.      * This fixes SELECT bleedthrough for IE6 & Mac scrollbars
  4.      * @module shim-plugin
  5.      */

  6.     /**
  7.      * Node plugin which can be used to add shim support.
  8.      *
  9.      * @class Plugin.Shim
  10.      * @param {Object} User configuration object
  11.      */
  12.     function Shim(config) {
  13.         this.init(config);
  14.     }

  15.     /**
  16.      * Default class used to mark the shim element
  17.      *
  18.      * @property CLASS_NAME
  19.      * @type String
  20.      * @static
  21.      * @default "yui-node-shim"
  22.      */
  23.     // TODO: use ClassNameManager
  24.     Shim.CLASS_NAME = 'yui-node-shim';

  25.     /**
  26.      * Default markup template used to generate the shim element.
  27.      *
  28.      * @property TEMPLATE
  29.      * @type String
  30.      * @static
  31.      */
  32.     Shim.TEMPLATE = '<iframe class="' + Shim.CLASS_NAME +
  33.             '" frameborder="0" title="Node Stacking Shim"' +
  34.             'src="javascript:false" tabindex="-1" role="presentation"' +
  35.             'style="position:absolute; z-index:-1;"></iframe>';

  36.     Shim.prototype = {
  37.         init: function(config) {
  38.             this._host = config.host;
  39.             this.initEvents();
  40.             this.insert();
  41.             this.sync();
  42.         },

  43.         initEvents: function() {
  44.             this._resizeHandle = this._host.on('resize', this.sync, this);
  45.         },
  46.        
  47.         getShim: function() {
  48.             return this._shim || (
  49.                 this._shim = Y.Node.create(
  50.                     Shim.TEMPLATE,
  51.                     this._host.get('ownerDocument')
  52.                 )
  53.             );
  54.         },

  55.         insert: function() {
  56.             var node = this._host;
  57.             this._shim = node.insertBefore( this.getShim(),
  58.                     node.get('firstChild'));
  59.         },

  60.         /**
  61.          * Updates the size of the shim to fill its container
  62.          * @method sync
  63.          */
  64.         sync: function() {
  65.             var shim = this._shim,
  66.                 node = this._host;

  67.             if (shim) {
  68.                 shim.setAttrs({
  69.                     width: node.getStyle('width'),
  70.                     height: node.getStyle('height')
  71.                 });
  72.             }
  73.         },

  74.         /**
  75.          * Removes the shim and destroys the plugin
  76.          * @method destroy
  77.          */
  78.         destroy: function() {
  79.             var shim = this._shim;
  80.             if (shim) {
  81.                 shim.remove(true);
  82.             }

  83.             this._resizeHandle.detach();
  84.         }
  85.     };

  86.     Shim.NAME = 'Shim';
  87.     Shim.NS = 'shim';

  88.     Y.namespace('Plugin');
  89.     Y.Plugin.Shim = Shim;

  90.