~michael.nelson/ubuntu-webcatalog/1267731-import-sca-apps-error

« back to all changes in this revision

Viewing changes to src/webcatalog/static/yui/3.10.3/build/scrollview-list/scrollview-list.js

  • Committer: Tarmac
  • Author(s): Stephen Stewart
  • Date: 2013-06-26 09:19:32 UTC
  • mfrom: (184.1.4 ubuntu-global-nav)
  • Revision ID: tarmac-20130626091932-8urtuli368k8p7ds
[r=beuno,jonas-drange] add ubuntu global nav to apps.ubuntu.com

Show diffs side-by-side

added added

removed removed

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