Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

widget-skin-debug.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.4.0
  6. build: nightly
  7. */
  8. YUI.add('widget-skin', function(Y) {
  9. /**
  10. * Provides skin related utlility methods.
  11. *
  12. * @module widget
  13. * @submodule widget-skin
  14. */
  15. var BOUNDING_BOX = "boundingBox",
  16. CONTENT_BOX = "contentBox",
  17. SKIN = "skin",
  18. _getClassName = Y.ClassNameManager.getClassName;
  19. /**
  20. * Returns the name of the skin that's currently applied to the widget.
  21. * This is only really useful after the widget's DOM structure is in the
  22. * document, either by render or by progressive enhancement. Searches up
  23. * the Widget's ancestor axis for a class yui3-skin-(name), and returns the
  24. * (name) portion. Otherwise, returns null.
  25. *
  26. * @method getSkinName
  27. * @for Widget
  28. * @return {String} the name of the skin, or null (yui3-skin-sam => sam)
  29. */
  30. Y.Widget.prototype.getSkinName = function () {
  31. var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ),
  32. search = new RegExp( '\\b' + _getClassName( SKIN ) + '-(\\S+)' ),
  33. match;
  34. if ( root ) {
  35. root.ancestor( function ( node ) {
  36. match = node.get( 'className' ).match( search );
  37. return match;
  38. } );
  39. }
  40. return ( match ) ? match[1] : null;
  41. };
  42. }, '3.4.0' ,{requires:['widget-base']});