3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('widget-skin', function(Y) {
10 * Provides skin related utlility methods.
13 * @submodule widget-skin
16 var BOUNDING_BOX = "boundingBox",
17 CONTENT_BOX = "contentBox",
19 _getClassName = Y.ClassNameManager.getClassName;
22 * Returns the name of the skin that's currently applied to the widget.
23 * This is only really useful after the widget's DOM structure is in the
24 * document, either by render or by progressive enhancement. Searches up
25 * the Widget's ancestor axis for a class yui3-skin-(name), and returns the
26 * (name) portion. Otherwise, returns null.
30 * @return {String} the name of the skin, or null (yui3-skin-sam => sam)
33 Y.Widget.prototype.getSkinName = function () {
34 var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ),
35 search = new RegExp( '\\b' + _getClassName( SKIN ) + '-(\\S+)' ),
39 root.ancestor( function ( node ) {
40 match = node.get( 'className' ).match( search );
45 return ( match ) ? match[1] : null;
49 }, '3.5.0' ,{requires:['widget-base']});