/usr/share/javascript/yui3/tabview-base/tabview-base.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('tabview-base', function(Y) {
var getClassName = Y.ClassNameManager.getClassName,
TABVIEW = 'tabview',
TAB = 'tab',
CONTENT = 'content',
PANEL = 'panel',
SELECTED = 'selected',
EMPTY_OBJ = {},
DOT = '.',
_classNames = {
tabview: getClassName(TABVIEW),
tabviewPanel: getClassName(TABVIEW, PANEL),
tabviewList: getClassName(TABVIEW, 'list'),
tab: getClassName(TAB),
tabLabel: getClassName(TAB, 'label'),
tabPanel: getClassName(TAB, PANEL),
selectedTab: getClassName(TAB, SELECTED),
selectedPanel: getClassName(TAB, PANEL, SELECTED)
},
_queries = {
tabview: DOT + _classNames.tabview,
tabviewList: '> ul',
tab: '> ul > li',
tabLabel: '> ul > li > a ',
tabviewPanel: '> div',
tabPanel: '> div > div',
selectedTab: '> ul > ' + DOT + _classNames.selectedTab,
selectedPanel: '> div ' + DOT + _classNames.selectedPanel
},
TabviewBase = function(config) {
this.init.apply(this, arguments);
};
TabviewBase.NAME = 'tabviewBase';
TabviewBase._queries = _queries;
TabviewBase._classNames = _classNames;
Y.mix(TabviewBase.prototype, {
init: function(config) {
config = config || EMPTY_OBJ;
this._node = config.host || Y.one(config.node);
this.refresh();
},
initClassNames: function(index) {
Y.Object.each(_queries, function(query, name) {
// this === tabview._node
if (_classNames[name]) {
var result = this.all(query);
if (index !== undefined) {
result = result.item(index);
}
if (result) {
result.addClass(_classNames[name]);
}
}
}, this._node);
this._node.addClass(_classNames.tabview);
},
_select: function(index) {
var node = this._node,
oldItem = node.one(_queries.selectedTab),
oldContent = node.one(_queries.selectedPanel),
newItem = node.all(_queries.tab).item(index),
newContent = node.all(_queries.tabPanel).item(index);
if (oldItem) {
oldItem.removeClass(_classNames.selectedTab);
}
if (oldContent) {
oldContent.removeClass(_classNames.selectedPanel);
}
if (newItem) {
newItem.addClass(_classNames.selectedTab);
}
if (newContent) {
newContent.addClass(_classNames.selectedPanel);
}
},
initState: function() {
var node = this._node,
activeNode = node.one(_queries.selectedTab),
activeIndex = activeNode ?
node.all(_queries.tab).indexOf(activeNode) : 0;
this._select(activeIndex);
},
// collapse extra space between list-items
_scrubTextNodes: function() {
this._node.one(_queries.tabviewList).get('childNodes').each(function(node) {
if (node.get('nodeType') === 3) { // text node
node.remove();
}
});
},
// base renderer only enlivens existing markup
refresh: function() {
this._scrubTextNodes();
this.initClassNames();
this.initState();
this.initEvents();
},
tabEventName: 'click',
initEvents: function() {
// TODO: detach prefix for delegate?
// this._node.delegate('tabview|' + this.tabEventName),
this._node.delegate(this.tabEventName,
this.onTabEvent,
_queries.tab,
this
);
},
onTabEvent: function(e) {
e.preventDefault();
this._select(this._node.all(_queries.tab).indexOf(e.currentTarget));
},
destroy: function() {
this._node.detach(this.tabEventName);
}
});
Y.TabviewBase = TabviewBase;
}, '3.5.1' ,{requires:['node-event-delegate', 'classnamemanager', 'skin-sam-tabview']});
|