Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('scrollview-list', function (Y, NAME) {
2
 
3
/**
4
 * Provides a plugin, which adds support for a scroll indicator to ScrollView instances
5
 *
6
 * @module scrollview-list
7
 */
8
var getCN = Y.ClassNameManager.getClassName,
9
SCROLLVIEW = 'scrollview',
10
LIST_CLASS = getCN(SCROLLVIEW, 'list'),
11
ITEM_CLASS = getCN(SCROLLVIEW, 'item'),
12
CONTENT_BOX = "contentBox",
13
HOST = "host";
14
 
15
/**
16
 * ScrollView plugin that adds class names to immediate descendant "<li>" to
17
 *  allow for easier styling through CSS
18
 *
19
 * @class ScrollViewList
20
 * @namespace Plugin
21
 * @extends Plugin.Base
22
 * @constructor
23
 */
24
function ListPlugin() {
25
    ListPlugin.superclass.constructor.apply(this, arguments);
26
}
27
 
28
 
29
/**
30
 * The identity of the plugin
31
 *
32
 * @property NAME
33
 * @type String
34
 * @default 'pluginList'
35
 * @static
36
 */
37
ListPlugin.NAME = 'pluginList';
38
 
39
/**
40
 * The namespace on which the plugin will reside.
41
 *
42
 * @property NS
43
 * @type String
44
 * @default 'list'
45
 * @static
46
 */
47
ListPlugin.NS = 'list';
48
 
49
 
50
/**
51
 * The default attribute configuration for the plugin
52
 *
53
 * @property ATTRS
54
 * @type Object
55
 * @static
56
 */
57
ListPlugin.ATTRS = {
58
 
59
    /**
60
     * Specifies whether the list elements (the immediate <ul>'s and the
61
     *  immediate <li>'s inside those <ul>'s) have class names attached to
62
     *  them or not
63
     *
64
     * @attribute isAttached
65
     * @type boolean
66
     * @deprecated No real use for this attribute on the public API
67
     */
68
    isAttached: {
69
        value:false,
70
        validator: Y.Lang.isBoolean
71
    }
72
};
73
 
74
Y.namespace("Plugin").ScrollViewList = Y.extend(ListPlugin, Y.Plugin.Base, {
75
 
76
    /**
77
     * Designated initializer
78
     *
79
     * @method initializer
80
     */
81
    initializer: function() {
82
        this._host = this.get(HOST);
83
        this.afterHostEvent("render", this._addClassesToList);
84
    },
85
 
86
    _addClassesToList: function() {
87
        if (!this.get('isAttached')) {
88
            var cb = this._host.get(CONTENT_BOX),
89
            ulList,
90
            liList;
91
 
92
            if (cb.hasChildNodes()) {
93
                //get all direct descendants of the UL's that are directly under the content box.
94
                ulList = cb.all('> ul');
95
                liList = cb.all('> ul > li');
96
 
97
                //go through the UL's and add the class
98
                ulList.each(function(list) {
99
                    list.addClass(LIST_CLASS);
100
                });
101
 
102
                //go through LI's and add the class
103
                liList.each(function(item) {
104
                    item.addClass(ITEM_CLASS);
105
                });
106
 
107
                this.set('isAttached', true);
108
 
109
                // We need to call this again, since sv-list
110
                //  relies on the "-vert" class, to apply padding.
111
                //  [ 1st syncUI pass applies -vert, 2nd pass re-calcs dims ]
112
                this._host.syncUI();
113
            }
114
        }
115
    }
116
 
117
});
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
}, '3.18.1', {"requires": ["plugin", "classnamemanager"], "skinnable": true});