1/* 2Copyright (c) 2010, Yahoo! Inc. All rights reserved. 3Code licensed under the BSD License: 4http://developer.yahoo.com/yui/license.html 5version: 3.4.0 6build: nightly 7*/ 8YUI.add('widget-skin', function(Y) { 9 10/** 11 * Provides skin related utlility methods. 12 * 13 * @module widget 14 * @submodule widget-skin 15 */ 16 17var 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 34Y.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.4.0' ,{requires:['widget-base']});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.