Merge branch 'MDL-32509' of git://github.com/danpoltawski/moodle
[moodle.git] / lib / yui / 3.5.0 / build / widget-skin / widget-skin-debug.js
blob74b674d429ab0bb7d6fc9f053aafb7c1c3c91d78
1 /*
2 YUI 3.5.0 (build 5089)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add('widget-skin', function(Y) {
9 /**
10  * Provides skin related utlility methods.
11  *
12  * @module widget
13  * @submodule widget-skin
14  */
16 var BOUNDING_BOX = "boundingBox",
17     CONTENT_BOX = "contentBox",
18     SKIN = "skin",
19     _getClassName = Y.ClassNameManager.getClassName;
21 /**
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.
27  *
28  * @method getSkinName
29  * @for Widget
30  * @return {String} the name of the skin, or null (yui3-skin-sam => sam)
31  */
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+)' ),
36         match;
38     if ( root ) {
39         root.ancestor( function ( node ) {
40             match = node.get( 'className' ).match( search );
41             return match;
42         } );
43     }
45     return ( match ) ? match[1] : null;
49 }, '3.5.0' ,{requires:['widget-base']});