210
__setupTabAction: function(oldFooter, parent) {
211
this._oldFooter = oldFooter;
212
this._oldFooterParent = parent;
214
this._overlay = document.querySelector('[data-role="overlay"]');
216
var newActionsBar = document.querySelector('[data-role="actions"]');
218
if (!this._oldFooter)
221
var actionBar = this._oldFooter,
222
actions = actionBar.querySelector('ul'),
223
actionButtons = actionBar.querySelectorAll('ul li'),
224
i = actionButtons.length;
225
newActionsBarWrapper = document.createElement('div');
226
newActionsBarWrapper.setAttribute("data-role", "actions-wrapper");
227
newActionsBarWrapper.setAttribute("id", "actions_" + this._oldFooterParent.id);
229
if (actionButtons.length > 2) {
230
// Maintain the first item then replace the rest with an action overflow
231
var firstAction = actionButtons[0],
232
overflowList = document.createElement('ul'),
234
firstButton = document.createElement('button'),
235
overflowButton = document.createElement('button'),
237
firstIcon = firstAction.querySelector('img').getAttribute('src'),
239
firstId = firstAction.querySelector('a').getAttribute('id'),
242
if (this._tabs != 'undefined' && this._tabs) {
243
if (this._tabs._tabsItems.length == 1) {
245
this._tabs._tabTitle.style.width = "calc(100% - 155px)";
247
// Maintain the second item
248
var secondAction = actionButtons[1],
250
secondButton = document.createElement('button'),
252
secondIcon = secondAction.querySelector('img').getAttribute('src'),
254
secondId = secondAction.querySelector('a').getAttribute('id');
258
overflowList.setAttribute('data-role', 'actions-overflow-list');
261
for (var x = k; x < i; x++) {
262
var li = document.createElement('li'),
263
a_id = actionButtons[x].querySelector('a').getAttribute('id'),
264
lbl = actionButtons[x].querySelector('span').innerHTML,
265
icon = actionButtons[x].querySelector('img').getAttribute('src');
268
li.setAttribute('id', a_id);
270
li.style.backgroundImage = 'url( ' + icon + ' )';
271
overflowList.appendChild(li);
273
li.onclick = function(e) {
274
overflowList.classList.toggle('opened');
275
self._overlay.classList.toggle('active');
280
// Add the action overflow button
281
overflowButton.setAttribute('data-role', 'actions-overflow-icon');
283
//firstButton.style.backgroundImage = 'url( ' + firstIcon + ' )';
284
firstButton.setAttribute('id', firstId);
285
document.styleSheets[0].addRule('#' + firstId + ':after', 'background-image: url("' + firstIcon + '");');
287
newActionsBarWrapper.appendChild(firstButton);
288
if (this._tabs != 'undefined' && this._tabs) {
289
if (this._tabs._tabsItems.length == 1) {
290
secondButton.setAttribute('id', secondId);
291
document.styleSheets[0].addRule('#' + secondId + ':after', 'background-image: url("' + secondIcon + '");');
292
newActionsBarWrapper.appendChild(secondButton);
295
newActionsBarWrapper.appendChild(overflowButton);
296
newActionsBarWrapper.appendChild(overflowList);
299
overflowButton.onclick = function(e) {
300
overflowList.classList.toggle('opened');
301
self._overlay.classList.toggle('active');
302
self._tabs._tabs.classList.remove('opened');
307
for (var y = 0; y < i; y++) {
308
var actionButton = document.createElement('button'),
309
actionButton_lbl = actionButtons[y].querySelector('span').innerHTML,
310
actionButton_icon = actionButtons[y].querySelector('img').getAttribute('src'),
311
actionButton_id = actionButtons[y].querySelector('a').getAttribute('id');
313
actionButton.setAttribute('id', actionButton_id);
314
document.styleSheets[0].addRule('#' + actionButton_id + ':after', 'background-image: url("' + actionButton_icon + '");');
315
newActionsBarWrapper.appendChild(actionButton);
319
newActionsBar.appendChild(newActionsBarWrapper);
323
__setupPageAction: function(oldFooter, parent) {
324
this._oldFooter = oldFooter;
325
this._oldFooterParent = parent;
326
this._overlay = document.querySelector('[data-role="overlay"]');
328
var newActionsBar = document.querySelector('[data-role="actions"]');
330
if (!this._oldFooter)
333
var actionBar = this._oldFooter,
334
actions = actionBar.querySelector('ul'),
335
actionButtons = actionBar.querySelectorAll('ul li'),
336
i = actionButtons.length;
338
newActionsBarWrapper = document.createElement('div');
339
newActionsBarWrapper.setAttribute("data-role", "actions-wrapper");
340
newActionsBarWrapper.setAttribute("id", "actions_" + this._oldFooterParent.id);
342
if (actionButtons.length > 2) {
343
// Maintain the first then replace the rest with an action overflow
344
var firstAction = actionButtons[0],
345
overflowList = document.createElement('ul'),
347
firstButton = document.createElement('button'),
348
overflowButton = document.createElement('button'),
350
firstIcon = firstAction.querySelector('img').getAttribute('src'),
352
firstId = firstAction.querySelector('a').getAttribute('id'),
355
this._tabTitle.style.width = "calc(100% - 155px)";
357
// Maintain the second item
358
var secondAction = actionButtons[1],
360
secondButton = document.createElement('button'),
362
secondIcon = secondAction.querySelector('img').getAttribute('src'),
364
secondId = secondAction.querySelector('a').getAttribute('id');
366
overflowList.setAttribute('data-role', 'actions-overflow-list');
369
for (var x = k; x < i; x++) {
370
var li = document.createElement('li'),
371
a_id = actionButtons[x].querySelector('a').getAttribute('id'),
372
lbl = actionButtons[x].querySelector('span').innerHTML,
373
icon = actionButtons[x].querySelector('img').getAttribute('src');
376
li.setAttribute('id', a_id);
378
li.style.backgroundImage = 'url( ' + icon + ' )';
379
overflowList.appendChild(li);
381
li.onclick = function(e) {
382
overflowList.classList.toggle('opened');
383
self._overlay.classList.toggle('active');
388
// Add the action overflow button
389
overflowButton.setAttribute('data-role', 'actions-overflow-icon');
391
firstButton.setAttribute('id', firstId);
392
document.styleSheets[0].addRule('#' + firstId + ':after', 'background-image: url("' + firstIcon + '");');
394
newActionsBarWrapper.appendChild(firstButton);
395
secondButton.setAttribute('id', secondId);
396
document.styleSheets[0].addRule('#' + secondId + ':after', 'background-image: url("' + secondIcon + '");');
397
newActionsBarWrapper.appendChild(secondButton);
398
newActionsBarWrapper.appendChild(overflowButton);
399
newActionsBarWrapper.appendChild(overflowList);
402
overflowButton.onclick = function(e) {
403
overflowList.classList.toggle('opened');
404
self._overlay.classList.toggle('active');
409
for (var y = 0; y < i; y++) {
410
var actionButton = document.createElement('button'),
411
actionButton_lbl = actionButtons[y].querySelector('span').innerHTML,
412
actionButton_icon = actionButtons[y].querySelector('img').getAttribute('src'),
413
actionButton_id = actionButtons[y].querySelector('a').getAttribute('id');
415
actionButton.setAttribute('id', actionButton_id);
416
document.styleSheets[0].addRule('#' + actionButton_id + ':after', 'background-image: url("' + actionButton_icon + '");');
417
newActionsBarWrapper.appendChild(actionButton);
421
newActionsBar.appendChild(newActionsBarWrapper);
206
425
* Required call that initializes the UbuntuUI object
207
426
* @method {} init
210
429
this.__setupTabs(document);
211
430
this.__setupPage(document);
212
431
this.__setupActionsBar(document);