2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('widget-skin', function (Y, NAME) {
11
* Provides skin related utlility methods.
14
* @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.
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.
27
* This is only really useful after the widget's DOM structure is in the
28
* document, either by render or by progressive enhancement.
32
* @param {String} [skinPrefix] The prefix which the implementation uses for the skin
33
* ("yui3-skin-" is the default).
35
* NOTE: skinPrefix will be used as part of a regular expression:
37
* new RegExp('\\b' + skinPrefix + '(\\S+)')
39
* Although an unlikely use case, literal characters which may result in an invalid
40
* regular expression should be escaped.
42
* @return {String} The name of the skin, or null, if a matching skin class is not found.
45
Y.Widget.prototype.getSkinName = function (skinPrefix) {
47
var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ),
51
skinPrefix = skinPrefix || _getClassName(SKIN, "");
53
search = new RegExp( '\\b' + skinPrefix + '(\\S+)' );
56
root.ancestor( function ( node ) {
57
match = node.get( 'className' ).match( search );
62
return ( match ) ? match[1] : null;
66
}, '3.10.3', {"requires": ["widget-base"]});