~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/classnamemanager/classnamemanager.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('classnamemanager', function(Y) {
 
8
 
 
9
/**
 
10
* Contains a singleton (ClassNameManager) that enables easy creation and caching of 
 
11
* prefixed class names.
 
12
* @module classnamemanager
 
13
*/
 
14
 
 
15
/**
 
16
 * A singleton class providing: 
 
17
 * 
 
18
 * <ul>
 
19
 *    <li>Easy creation of prefixed class names</li>
 
20
 *    <li>Caching of previously created class names for improved performance.</li>
 
21
 * </ul>
 
22
 * 
 
23
 * @class ClassNameManager
 
24
 * @static 
 
25
 */
 
26
 
 
27
// String constants
 
28
var CLASS_NAME_PREFIX = 'classNamePrefix',
 
29
        CLASS_NAME_DELIMITER = 'classNameDelimiter',
 
30
    CONFIG = Y.config;
 
31
 
 
32
// Global config
 
33
 
 
34
/**
 
35
 * Configuration property indicating the prefix for all CSS class names in this YUI instance.
 
36
 *
 
37
 * @property classNamePrefix
 
38
 * @type {String}
 
39
 * @default "yui"
 
40
 * @static
 
41
 */
 
42
CONFIG[CLASS_NAME_PREFIX] = CONFIG[CLASS_NAME_PREFIX] || 'yui3';
 
43
 
 
44
/**
 
45
 * Configuration property indicating the delimiter used to compose all CSS class names in
 
46
 * this YUI instance.
 
47
 *
 
48
 * @property classNameDelimiter
 
49
 * @type {String}
 
50
 * @default "-"
 
51
 * @static
 
52
 */
 
53
CONFIG[CLASS_NAME_DELIMITER] = CONFIG[CLASS_NAME_DELIMITER] || '-';
 
54
 
 
55
Y.ClassNameManager = function () {
 
56
 
 
57
        var sPrefix    = CONFIG[CLASS_NAME_PREFIX],
 
58
                sDelimiter = CONFIG[CLASS_NAME_DELIMITER];
 
59
 
 
60
        return {
 
61
 
 
62
                /**
 
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
 
67
                 *
 
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.  
 
71
                 */
 
72
                getClassName: Y.cached(function () {
 
73
 
 
74
            var args = Y.Array(arguments);
 
75
 
 
76
            if (args[args.length-1] !== true) {
 
77
                args.unshift(sPrefix);
 
78
            } else {
 
79
                args.pop();
 
80
            }
 
81
 
 
82
                        return args.join(sDelimiter);
 
83
                })
 
84
 
 
85
        };
 
86
 
 
87
}();
 
88
 
 
89
 
 
90
}, '3.5.1' ,{requires:['yui-base']});