3
Copyright 2011 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('scrollview-list', function(Y) {
10
* Provides a plugin, which adds support for a scroll indicator to ScrollView instances
12
* @module scrollview-list
14
var getCN = Y.ClassNameManager.getClassName,
15
SCROLLVIEW = 'scrollview',
16
LIST_CLASS = getCN(SCROLLVIEW, 'list'),
17
ITEM_CLASS = getCN(SCROLLVIEW, 'item'),
18
CONTENT_BOX = "contentBox",
19
RENDERED = 'rendered',
20
RENDER_UI = 'renderUI',
24
* ScrollView plugin that adds class names to immediate descendant "<li>" to
25
* allow for easier styling through CSS
27
* @class ScrollViewList
29
* @extends Plugin.Base
32
function ListPlugin() {
33
ListPlugin.superclass.constructor.apply(this, arguments);
38
* The identity of the plugin
42
* @default 'pluginList'
45
ListPlugin.NAME = 'pluginList';
48
* The namespace on which the plugin will reside.
55
ListPlugin.NS = 'list';
59
* The default attribute configuration for the plugin
68
* Specifies whether the list elements (the immediate <ul>'s and the immediate <li>'s inside those <ul>'s) have class names attached to them or not
70
* @attribute isAttached
72
* @deprecated No real use for this attribute on the public API
76
validator: Y.Lang.isBoolean
80
Y.namespace("Plugin").ScrollViewList = Y.extend(ListPlugin, Y.Plugin.Base, {
83
* Designated initializer
87
initializer: function() {
88
this._host = this.get(HOST);
89
this.afterHostEvent("render", this._addClassesToList);
92
_addClassesToList: function() {
93
if (!this.get('isAttached')) {
94
var cb = this._host.get(CONTENT_BOX),
98
if (cb.hasChildNodes()) {
99
//get all direct descendants of the UL's that are directly under the content box.
100
ulList = cb.all('> ul');
101
liList = cb.all('> ul > li');
103
//go through the UL's and add the class
104
ulList.each(function(list) {
105
list.addClass(LIST_CLASS);
108
//go through LI's and add the class
109
liList.each(function(item) {
110
item.addClass(ITEM_CLASS);
113
this.set('isAttached', true);
115
// We need to call this again, since sv-list
116
// relies on the "-vert" class, to apply padding.
117
// [ 1st syncUI pass applies -vert, 2nd pass re-calcs dims ]
136
}, '3.4.1' ,{requires:['plugin', 'classnamemanager'], skinnable:true});