]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/widget/widget-skin.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / widget / widget-skin.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('widget-skin', function(Y) {
9
10 /**
11  * Provides skin related utlility methods.
12  *
13  * @module widget
14  * @submodule widget-skin
15  */
16
17 var BOUNDING_BOX = "boundingBox",
18     CONTENT_BOX = "contentBox",
19     SKIN = "skin",
20     _getClassName = Y.ClassNameManager.getClassName;
21
22 /**
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.
28  *
29  * @method getSkinName
30  * @for Widget
31  * @return {String} the name of the skin, or null (yui3-skin-sam => sam)
32  */
33
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+)' ),
37         match;
38
39     if ( root ) {
40         root.ancestor( function ( node ) {
41             match = node.get( 'className' ).match( search );
42             return match;
43         } );
44     }
45
46     return ( match ) ? match[1] : null;
47 };
48
49
50 }, '3.3.0' ,{requires:['widget-base']});