3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('classnamemanager', function(Y) {
10 * Contains a singleton (ClassNameManager) that enables easy creation and caching of
11 * prefixed class names.
12 * @module classnamemanager
16 * A singleton class providing:
19 * <li>Easy creation of prefixed class names</li>
20 * <li>Caching of previously created class names for improved performance.</li>
23 * @class ClassNameManager
28 var CLASS_NAME_PREFIX = 'classNamePrefix',
29 CLASS_NAME_DELIMITER = 'classNameDelimiter',
35 * Configuration property indicating the prefix for all CSS class names in this YUI instance.
37 * @property classNamePrefix
42 CONFIG[CLASS_NAME_PREFIX] = CONFIG[CLASS_NAME_PREFIX] || 'yui3';
45 * Configuration property indicating the delimiter used to compose all CSS class names in
48 * @property classNameDelimiter
53 CONFIG[CLASS_NAME_DELIMITER] = CONFIG[CLASS_NAME_DELIMITER] || '-';
55 Y.ClassNameManager = function () {
57 var sPrefix = CONFIG[CLASS_NAME_PREFIX],
58 sDelimiter = CONFIG[CLASS_NAME_DELIMITER];
63 * Returns a class name prefixed with the the value of the
64 * <code>Y.config.classNamePrefix</code> attribute + the provided strings.
65 * Uses the <code>Y.config.classNameDelimiter</code> attribute to delimit the
66 * provided strings. E.g. Y.ClassNameManager.getClassName('foo','bar'); // yui-foo-bar
68 * @method getClassName
69 * @param {String}+ classnameSection one or more classname sections to be joined
70 * @param {Boolean} skipPrefix If set to true, the classname will not be prefixed with the default Y.config.classNameDelimiter value.
72 getClassName: Y.cached(function () {
74 var args = Y.Array(arguments);
76 if (args[args.length-1] !== true) {
77 args.unshift(sPrefix);
82 return args.join(sDelimiter);
90 }, '3.5.1' ,{requires:['yui-base']});