[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/widget-skin/ -> widget-skin.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('widget-skin', function (Y, NAME) {
   9  
  10  /**
  11   * Provides skin related utlility methods.
  12   *
  13   * @module widget
  14   * @submodule widget-skin
  15   */
  16  var BOUNDING_BOX = "boundingBox",
  17      CONTENT_BOX = "contentBox",
  18      SKIN = "skin",
  19      _getClassName = Y.ClassNameManager.getClassName;
  20  
  21  /**
  22   * Returns the name of the skin that's currently applied to the widget.
  23   *
  24   * Searches up the Widget's ancestor axis for, by default, a class
  25   * yui3-skin-(name), and returns the (name) portion. Otherwise, returns null.
  26   *
  27   * This is only really useful after the widget's DOM structure is in the
  28   * document, either by render or by progressive enhancement.
  29   *
  30   * @method getSkinName
  31   * @for Widget
  32   * @param {String} [skinPrefix] The prefix which the implementation uses for the skin
  33   * ("yui3-skin-" is the default).
  34   *
  35   * NOTE: skinPrefix will be used as part of a regular expression:
  36   *
  37   *     new RegExp('\\b' + skinPrefix + '(\\S+)')
  38   *
  39   * Although an unlikely use case, literal characters which may result in an invalid
  40   * regular expression should be escaped.
  41   *
  42   * @return {String} The name of the skin, or null, if a matching skin class is not found.
  43   */
  44  
  45  Y.Widget.prototype.getSkinName = function (skinPrefix) {
  46  
  47      var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ),
  48          match,
  49          search;
  50  
  51      skinPrefix = skinPrefix || _getClassName(SKIN, "");
  52  
  53      search = new RegExp( '\\b' + skinPrefix + '(\\S+)' );
  54  
  55      if ( root ) {
  56          root.ancestor( function ( node ) {
  57              match = node.get( 'className' ).match( search );
  58              return match;
  59          } );
  60      }
  61  
  62      return ( match ) ? match[1] : null;
  63  };
  64  
  65  
  66  }, '3.17.2', {"requires": ["widget-base"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1