2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('widget-skin', function(Y) {
11 * Provides skin related utlility methods.
14 * @submodule widget-skin
17 var BOUNDING_BOX = "boundingBox",
18 CONTENT_BOX = "contentBox",
20 _getClassName = Y.ClassNameManager.getClassName;
23 * Returns the name of the skin that's currently applied to the widget.
24 * This is only really useful after the widget's DOM structure is in the
25 * document, either by render or by progressive enhancement. Searches up
26 * the Widget's ancestor axis for a class yui3-skin-(name), and returns the
27 * (name) portion. Otherwise, returns null.
31 * @return {String} the name of the skin, or null (yui3-skin-sam => sam)
34 Y.Widget.prototype.getSkinName = function () {
35 var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ),
36 search = new RegExp( '\\b' + _getClassName( SKIN ) + '-(\\S+)' ),
40 root.ancestor( function ( node ) {
41 match = node.get( 'className' ).match( search );
46 return ( match ) ? match[1] : null;
50 }, '3.3.0' ,{requires:['widget-base']});