src/cm/media/js/lib/yui/yui3-3.15.0/build/classnamemanager/classnamemanager-debug.js
changeset 602 e16a97fb364a
equal deleted inserted replaced
601:d334a616c023 602:e16a97fb364a
       
     1 YUI.add('classnamemanager', function (Y, NAME) {
       
     2 
       
     3 /**
       
     4 * Contains a singleton (ClassNameManager) that enables easy creation and caching of
       
     5 * prefixed class names.
       
     6 * @module classnamemanager
       
     7 */
       
     8 
       
     9 /**
       
    10  * A singleton class providing:
       
    11  *
       
    12  * <ul>
       
    13  *    <li>Easy creation of prefixed class names</li>
       
    14  *    <li>Caching of previously created class names for improved performance.</li>
       
    15  * </ul>
       
    16  *
       
    17  * @class ClassNameManager
       
    18  * @static
       
    19  */
       
    20 
       
    21 // String constants
       
    22 var CLASS_NAME_PREFIX = 'classNamePrefix',
       
    23 	CLASS_NAME_DELIMITER = 'classNameDelimiter',
       
    24     CONFIG = Y.config;
       
    25 
       
    26 // Global config
       
    27 
       
    28 /**
       
    29  * Configuration property indicating the prefix for all CSS class names in this YUI instance.
       
    30  *
       
    31  * @property classNamePrefix
       
    32  * @type {String}
       
    33  * @default "yui"
       
    34  * @static
       
    35  */
       
    36 CONFIG[CLASS_NAME_PREFIX] = CONFIG[CLASS_NAME_PREFIX] || 'yui3';
       
    37 
       
    38 /**
       
    39  * Configuration property indicating the delimiter used to compose all CSS class names in
       
    40  * this YUI instance.
       
    41  *
       
    42  * @property classNameDelimiter
       
    43  * @type {String}
       
    44  * @default "-"
       
    45  * @static
       
    46  */
       
    47 CONFIG[CLASS_NAME_DELIMITER] = CONFIG[CLASS_NAME_DELIMITER] || '-';
       
    48 
       
    49 Y.ClassNameManager = function () {
       
    50 
       
    51 	var sPrefix    = CONFIG[CLASS_NAME_PREFIX],
       
    52 		sDelimiter = CONFIG[CLASS_NAME_DELIMITER];
       
    53 
       
    54 	return {
       
    55 
       
    56 		/**
       
    57 		 * Returns a class name prefixed with the the value of the
       
    58 		 * <code>Y.config.classNamePrefix</code> attribute + the provided strings.
       
    59 		 * Uses the <code>Y.config.classNameDelimiter</code> attribute to delimit the
       
    60 		 * provided strings. E.g. Y.ClassNameManager.getClassName('foo','bar'); // yui-foo-bar
       
    61 		 *
       
    62 		 * @method getClassName
       
    63 		 * @param {String} [classnameSection*] one or more classname sections to be joined
       
    64 		 * @param {Boolean} skipPrefix If set to true, the classname will not be prefixed with the default Y.config.classNameDelimiter value.
       
    65 		 */
       
    66 		getClassName: Y.cached(function () {
       
    67 
       
    68             var args = Y.Array(arguments);
       
    69 
       
    70             if (args[args.length-1] !== true) {
       
    71                 args.unshift(sPrefix);
       
    72             } else {
       
    73                 args.pop();
       
    74             }
       
    75 
       
    76 			return args.join(sDelimiter);
       
    77 		})
       
    78 
       
    79 	};
       
    80 
       
    81 }();
       
    82 
       
    83 
       
    84 }, '@VERSION@', {"requires": ["yui-base"]});