Merge lp:~daker/ubuntu-html5-theme/fix.1427729-1427909 into lp:ubuntu-html5-theme

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: David Barth
Approved revision: 199
Merged at revision: 199
Proposed branch: lp:~daker/ubuntu-html5-theme/fix.1427729-1427909
Merge into: lp:ubuntu-html5-theme
Diff against target: 871 lines (+300/-249)
7 files modified
0.1/ambiance/js/actionsbar.js (+0/-151)
0.1/ambiance/js/core.js (+276/-67)
0.1/ambiance/js/page.js (+2/-14)
0.1/ambiance/js/pagestacks.js (+18/-10)
0.1/ambiance/js/tabs.js (+2/-1)
examples/html5-theme/widgets/Pagestack.html (+2/-5)
examples/html5-theme/widgets/Tabs.html (+0/-1)
To merge this branch: bzr merge lp:~daker/ubuntu-html5-theme/fix.1427729-1427909
Reviewer Review Type Date Requested Status
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+251678@code.launchpad.net

Commit message

Removed ActionsBar deps
Fixed the back button in PageStack
Fixed PageStack actions

To post a comment you must log in.
198. By Alexandre Abreu

revert revision 196: push to trunk instead of usual landing

199. By Adnane Belmadiaf

Merged trunk
Removed actionbar.js call

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file '0.1/ambiance/js/actionsbar.js'
--- 0.1/ambiance/js/actionsbar.js 2015-01-30 23:39:20 +0000
+++ 0.1/ambiance/js/actionsbar.js 1970-01-01 00:00:00 +0000
@@ -1,151 +0,0 @@
1/*
2 * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
3 * License granted by Canonical Limited
4 *
5 * This file is part of ubuntu-html5-ui-toolkit.
6 *
7 * This package is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 3 of the
10 * License, or
11 * (at your option) any later version.
12
13 * This package is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23/**
24 * An ActionBar is the JavaScript representation of an Ubuntu HTML5 app <em>ActionBar</em>.
25 */
26
27var ActionBar = (function () {
28
29 function ActionBar(tabs, oldFooter, parent) {
30 this._tabs = tabs;
31 this._oldFooter = oldFooter;
32 this._oldFooterParent = parent;
33
34 this._overlay = document.querySelector('[data-role="overlay"]');
35
36 var newActionsBar = document.querySelector('[data-role="actions"]');
37
38 if (!this._oldFooter)
39 return;
40
41 var actionBar = this._oldFooter,
42 actions = actionBar.querySelector('ul'),
43 actionButtons = actionBar.querySelectorAll('ul li'),
44 i = actionButtons.length;
45 newActionsBarWrapper = document.createElement('div');
46 newActionsBarWrapper.setAttribute("data-role", "actions-wrapper");
47 newActionsBarWrapper.setAttribute("id", "actions_" + this._oldFooterParent.id);
48
49 if (actionButtons.length > 2) {
50 // Maintain the first then replace the rest with an action overflow
51 var firstAction = actionButtons[0],
52 overflowList = document.createElement('ul'),
53 /* Actions Button */
54 firstButton = document.createElement('button'),
55 overflowButton = document.createElement('button'),
56 /* Icon */
57 firstIcon = firstAction.querySelector('img').getAttribute('src'),
58 /* ID*/
59 firstId = firstAction.querySelector('a').getAttribute('id');
60
61 var k =1;
62
63 if (this._tabs._tabsitems.length == 1) {
64 k = 2;
65 this._tabs._tabtitle.style.width = "calc(100% - 155px)";
66
67 // Maintain the second
68 var secondAction = actionButtons[1],
69 /* Actions Button */
70 secondButton = document.createElement('button'),
71 /* Icon */
72 secondIcon = secondAction.querySelector('img').getAttribute('src'),
73 /* ID*/
74 secondId = secondAction.querySelector('a').getAttribute('id');
75 }
76
77 overflowList.setAttribute('data-role', 'actions-overflow-list');
78
79 // Hide the overflow
80 for (var x = k; x < i; x++) {
81 var li = document.createElement('li'),
82 a_id = actionButtons[x].querySelector('a').getAttribute('id'),
83 lbl = actionButtons[x].querySelector('span').innerHTML,
84 icon = actionButtons[x].querySelector('img').getAttribute('src');
85
86 li.innerHTML = lbl;
87 li.setAttribute('id', a_id);
88
89 li.style.backgroundImage = 'url( ' + icon + ' )';
90 overflowList.appendChild(li);
91
92 li.onclick = function (e) {
93 overflowList.classList.toggle('opened');
94 self._overlay.classList.toggle('active');
95 e.preventDefault();
96 };
97 }
98
99 // Add the action overflow button
100 overflowButton.setAttribute('data-role', 'actions-overflow-icon');
101
102 //firstButton.style.backgroundImage = 'url( ' + firstIcon + ' )';
103 firstButton.setAttribute('id', firstId);
104 document.styleSheets[0].addRule('#'+ firstId + ':after','background-image: url("' + firstIcon + '");');
105
106 newActionsBarWrapper.appendChild(firstButton);
107 if (this._tabs._tabsitems.length == 1) {
108 secondButton.setAttribute('id', secondId);
109 document.styleSheets[0].addRule('#'+ secondId + ':after','background-image: url("' + secondIcon + '");');
110 newActionsBarWrapper.appendChild(secondButton);
111 }
112 newActionsBarWrapper.appendChild(overflowButton);
113 newActionsBarWrapper.appendChild(overflowList);
114
115 self = this;
116 overflowButton.onclick = function (e) {
117 overflowList.classList.toggle('opened');
118 self._overlay.classList.toggle('active');
119 self._tabs._tabs.classList.remove('opened');
120 e.preventDefault();
121 };
122 } else {
123
124 for (var y = 0; y < i; y++) {
125 var actionButton = document.createElement('button'),
126 actionButton_lbl = actionButtons[y].querySelector('span').innerHTML,
127 actionButton_icon = actionButtons[y].querySelector('img').getAttribute('src'),
128 actionButton_id = actionButtons[y].querySelector('a').getAttribute('id');
129
130 actionButton.setAttribute('id', actionButton_id);
131 document.styleSheets[0].addRule('#'+ actionButton_id + ':after','background-image: url("' + actionButton_icon + '");');
132 newActionsBarWrapper.appendChild(actionButton);
133 }
134 }
135
136 newActionsBar.appendChild(newActionsBarWrapper);
137 };
138
139 ActionBar.prototype = {
140 /**
141 * Returns the DOM element associated with the id this widget is bind to.
142 * @method element
143 * @example
144 var myactionbar = UI.actionbar("actionbarid").element();
145 */
146 element: function () {
147 return this.actionbar;
148 }
149 };
150 return ActionBar;
151})();
1520
=== modified file '0.1/ambiance/js/core.js'
--- 0.1/ambiance/js/core.js 2015-03-04 21:10:49 +0000
+++ 0.1/ambiance/js/core.js 2015-03-04 21:23:40 +0000
@@ -38,22 +38,23 @@
38 [...]38 [...]
39 };39 };
40 */40 */
41var UbuntuUI = (function () {41var UbuntuUI = (function() {
4242
43 PAGESTACK_BACK_ID = 'ubuntu-pagestack-back';43 PAGESTACK_BACK_ID = 'ubuntu-pagestack-back';
4444
45 function __hasPageStack(document) {45 function __hasPageStack(document) {
46 return document.querySelectorAll("[data-role='pagestack']") != null;46 return document.querySelectorAll("[data-role='pagestack']").length >= 1;
47 };47 };
4848
49 function __hasTabs(document) {49 function __hasTabs(document) {
50 return document.querySelectorAll("[data-role='tabs']") != null;50 return document.querySelectorAll("[data-role='tabs']").length >= 1;
51 };51 };
5252
53 function __createBackButtonListItem() {53 function __createBackButtonListItem() {
54 var backBtn = document.createElement('button');54 var backBtn = document.createElement('button');
55 backBtn.setAttribute('data-role', 'back-btn');55 backBtn.setAttribute('data-role', 'back-btn');
56 backBtn.setAttribute('id', PAGESTACK_BACK_ID + '-' + Math.random());56 backBtn.setAttribute('id', PAGESTACK_BACK_ID + '-' + Math.floor(Math.random()));
57 backBtn.disabled = true;
57 return backBtn;58 return backBtn;
58 };59 };
5960
@@ -61,9 +62,9 @@
61 var U = this;62 var U = this;
62 U.isTouch = "ontouchstart" in window;63 U.isTouch = "ontouchstart" in window;
63 U.touchEvents = {64 U.touchEvents = {
64 touchStart: ['touchstart','mousedown'],65 touchStart: ['touchstart', 'mousedown'],
65 touchMove: ['touchmove','mousemove'],66 touchMove: ['touchmove', 'mousemove'],
66 touchEnd: ['touchend','mouseup'],67 touchEnd: ['touchend', 'mouseup'],
67 touchLeave: ['mouseleave'],68 touchLeave: ['mouseleave'],
68 };69 };
6970
@@ -75,7 +76,7 @@
75 this._content.style.paddingTop = this._headerHeight + "px";76 this._content.style.paddingTop = this._headerHeight + "px";
7677
77 var self = this;78 var self = this;
78 window.onscroll = function(event){79 window.onscroll = function(event) {
79 var scrollTop = window.pageYOffset;80 var scrollTop = window.pageYOffset;
80 var y = Math.min(self._headerHeight, Math.max(0, (self._y + scrollTop - self._prevScrollTop)));81 var y = Math.min(self._headerHeight, Math.max(0, (self._y + scrollTop - self._prevScrollTop)));
8182
@@ -93,22 +94,7 @@
93 };94 };
9495
95 UbuntuUI.prototype = {96 UbuntuUI.prototype = {
96 __setupPageStack: function (d) {97 __setupPageStack: function(d) {
97 // TODO validate no more than one page stack etc.
98 // d.querySelectorAll("[data-role='pagestack']")
99
100 // FIXME: support multiple page stack & complex docs?
101 var pagestacks = d.querySelectorAll("[data-role='pagestack']");
102 if (pagestacks.length == 0)
103 return;
104 var pagestack = pagestacks[0];
105
106 this._pageStack = new Pagestack(pagestack);
107
108 var pages = pagestack.querySelectorAll("[data-role='page']");
109 if (pages.length > 0) {
110 this._pageStack.push(pages[0].getAttribute('id'));
111 }
11298
113 var header = d.querySelector("[data-role='header']");99 var header = d.querySelector("[data-role='header']");
114100
@@ -122,13 +108,31 @@
122 header.insertBefore(backBtn, header.firstChild);108 header.insertBefore(backBtn, header.firstChild);
123109
124 var self = this;110 var self = this;
125 backBtn.onclick = function (e) {111 backBtn.onclick = function(e) {
126 if (self._pageStack.depth() > 1){112 if (self._pageStack.depth() > 1) {
127 self._pageStack.pop();113 self._pageStack.pop();
128 }114 }
129 e.preventDefault();115 e.preventDefault();
130 };116 };
131117
118 this._content = document.querySelector('[data-role="content"]');
119 this._overlay = document.createElement('div');
120 this._overlay.setAttribute('data-role', 'overlay');
121 this._content.appendChild(this._overlay);
122
123 // FIXME: support multiple page stack & complex docs?
124 var pagestacks = d.querySelectorAll("[data-role='pagestack']");
125 if (pagestacks.length == 0)
126 return;
127 var pagestack = pagestacks[0];
128
129 this._pageStack = new Pagestack(pagestack);
130
131 var pages = pagestack.querySelectorAll("[data-role='page']");
132 if (pages.length > 0) {
133 this._pageStack.push(pages[0].getAttribute('id'));
134 }
135
132 this._pageActions = d.createElement('div');136 this._pageActions = d.createElement('div');
133 this._pageActions.setAttribute('data-role', 'actions');137 this._pageActions.setAttribute('data-role', 'actions');
134138
@@ -145,7 +149,7 @@
145 s.webkitTransform = s.transform = 'translate3d(0, ' + y + 'px, 0)';149 s.webkitTransform = s.transform = 'translate3d(0, ' + y + 'px, 0)';
146 },150 },
147151
148 __setupPage: function (document) {152 __setupPage: function(document) {
149 if (this._pageStack != null)153 if (this._pageStack != null)
150 return;154 return;
151 if (__hasPageStack(document)) {155 if (__hasPageStack(document)) {
@@ -163,7 +167,7 @@
163 var footers = apptabsElements[idx].querySelectorAll("[data-role='footer']");167 var footers = apptabsElements[idx].querySelectorAll("[data-role='footer']");
164 if (footers.length >= 0) {168 if (footers.length >= 0) {
165 // TODO: validate footer count: should be 1 footer169 // TODO: validate footer count: should be 1 footer
166 actionBar = new ActionBar(this._tabs, footers[0], apptabsElements[idx]);170 actionBar = this.__setupTabAction(footers[0], apptabsElements[idx]);
167 if (footers[0] != null) footers[0].remove();171 if (footers[0] != null) footers[0].remove();
168 }172 }
169 }173 }
@@ -175,14 +179,14 @@
175 var footers = apppagesElements[idx].querySelectorAll("[data-role='footer']");179 var footers = apppagesElements[idx].querySelectorAll("[data-role='footer']");
176 if (footers.length >= 0) {180 if (footers.length >= 0) {
177 // TODO: validate footer count: should be 1 footer181 // TODO: validate footer count: should be 1 footer
178 actionBar = new ActionBar(this._tabs, footers[0], apppagesElements[idx]);182 actionBar = this.__setupPageAction(footers[0], apppagesElements[idx]);
179 if (footers[0] != null) footers[0].remove();183 if (footers[0] != null) footers[0].remove();
180 }184 }
181 }185 }
182 }186 }
183 },187 },
184188
185 __setupTabs: function (document) {189 __setupTabs: function(document) {
186 if (this._tabs != null)190 if (this._tabs != null)
187 return;191 return;
188 if (__hasTabs(document)) {192 if (__hasTabs(document)) {
@@ -191,7 +195,7 @@
191 if (apptabsElements.length == 0)195 if (apptabsElements.length == 0)
192 return;196 return;
193 this._tabs = new Tabs(apptabsElements[0]);197 this._tabs = new Tabs(apptabsElements[0]);
194 this._tabs.onTabChanged(function (e) {198 this._tabs.onTabChanged(function(e) {
195 if (!e || !e.infos)199 if (!e || !e.infos)
196 return;200 return;
197 if (e.infos.tabId) {201 if (e.infos.tabId) {
@@ -199,14 +203,229 @@
199 }203 }
200 }.bind(this));204 }.bind(this));
201 }205 }
202 }206 }
207 },
208
209
210 __setupTabAction: function(oldFooter, parent) {
211 this._oldFooter = oldFooter;
212 this._oldFooterParent = parent;
213
214 this._overlay = document.querySelector('[data-role="overlay"]');
215
216 var newActionsBar = document.querySelector('[data-role="actions"]');
217
218 if (!this._oldFooter)
219 return;
220
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);
228
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'),
233 /* Action Button */
234 firstButton = document.createElement('button'),
235 overflowButton = document.createElement('button'),
236 /* Icon */
237 firstIcon = firstAction.querySelector('img').getAttribute('src'),
238 /* ID*/
239 firstId = firstAction.querySelector('a').getAttribute('id'),
240 k = 1;
241
242 if (this._tabs != 'undefined' && this._tabs) {
243 if (this._tabs._tabsItems.length == 1) {
244 k = 2;
245 this._tabs._tabTitle.style.width = "calc(100% - 155px)";
246
247 // Maintain the second item
248 var secondAction = actionButtons[1],
249 /* Action Button */
250 secondButton = document.createElement('button'),
251 /* Icon */
252 secondIcon = secondAction.querySelector('img').getAttribute('src'),
253 /* ID*/
254 secondId = secondAction.querySelector('a').getAttribute('id');
255 }
256 }
257
258 overflowList.setAttribute('data-role', 'actions-overflow-list');
259
260 // Hide the overflow
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');
266
267 li.innerHTML = lbl;
268 li.setAttribute('id', a_id);
269
270 li.style.backgroundImage = 'url( ' + icon + ' )';
271 overflowList.appendChild(li);
272
273 li.onclick = function(e) {
274 overflowList.classList.toggle('opened');
275 self._overlay.classList.toggle('active');
276 e.preventDefault();
277 };
278 }
279
280 // Add the action overflow button
281 overflowButton.setAttribute('data-role', 'actions-overflow-icon');
282
283 //firstButton.style.backgroundImage = 'url( ' + firstIcon + ' )';
284 firstButton.setAttribute('id', firstId);
285 document.styleSheets[0].addRule('#' + firstId + ':after', 'background-image: url("' + firstIcon + '");');
286
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);
293 }
294 }
295 newActionsBarWrapper.appendChild(overflowButton);
296 newActionsBarWrapper.appendChild(overflowList);
297
298 self = this;
299 overflowButton.onclick = function(e) {
300 overflowList.classList.toggle('opened');
301 self._overlay.classList.toggle('active');
302 self._tabs._tabs.classList.remove('opened');
303 e.preventDefault();
304 };
305 } else {
306
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');
312
313 actionButton.setAttribute('id', actionButton_id);
314 document.styleSheets[0].addRule('#' + actionButton_id + ':after', 'background-image: url("' + actionButton_icon + '");');
315 newActionsBarWrapper.appendChild(actionButton);
316 }
317 }
318
319 newActionsBar.appendChild(newActionsBarWrapper);
320 },
321
322
323 __setupPageAction: function(oldFooter, parent) {
324 this._oldFooter = oldFooter;
325 this._oldFooterParent = parent;
326 this._overlay = document.querySelector('[data-role="overlay"]');
327
328 var newActionsBar = document.querySelector('[data-role="actions"]');
329
330 if (!this._oldFooter)
331 return;
332
333 var actionBar = this._oldFooter,
334 actions = actionBar.querySelector('ul'),
335 actionButtons = actionBar.querySelectorAll('ul li'),
336 i = actionButtons.length;
337
338 newActionsBarWrapper = document.createElement('div');
339 newActionsBarWrapper.setAttribute("data-role", "actions-wrapper");
340 newActionsBarWrapper.setAttribute("id", "actions_" + this._oldFooterParent.id);
341
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'),
346 /* Actions Button */
347 firstButton = document.createElement('button'),
348 overflowButton = document.createElement('button'),
349 /* Icon */
350 firstIcon = firstAction.querySelector('img').getAttribute('src'),
351 /* ID*/
352 firstId = firstAction.querySelector('a').getAttribute('id'),
353 k = 2;
354
355 this._tabTitle.style.width = "calc(100% - 155px)";
356
357 // Maintain the second item
358 var secondAction = actionButtons[1],
359 /* Action Button */
360 secondButton = document.createElement('button'),
361 /* Icon */
362 secondIcon = secondAction.querySelector('img').getAttribute('src'),
363 /* ID*/
364 secondId = secondAction.querySelector('a').getAttribute('id');
365
366 overflowList.setAttribute('data-role', 'actions-overflow-list');
367
368 // Hide the overflow
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');
374
375 li.innerHTML = lbl;
376 li.setAttribute('id', a_id);
377
378 li.style.backgroundImage = 'url( ' + icon + ' )';
379 overflowList.appendChild(li);
380
381 li.onclick = function(e) {
382 overflowList.classList.toggle('opened');
383 self._overlay.classList.toggle('active');
384 e.preventDefault();
385 };
386 }
387
388 // Add the action overflow button
389 overflowButton.setAttribute('data-role', 'actions-overflow-icon');
390
391 firstButton.setAttribute('id', firstId);
392 document.styleSheets[0].addRule('#' + firstId + ':after', 'background-image: url("' + firstIcon + '");');
393
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);
400
401 self = this;
402 overflowButton.onclick = function(e) {
403 overflowList.classList.toggle('opened');
404 self._overlay.classList.toggle('active');
405 e.preventDefault();
406 };
407 } else {
408
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');
414
415 actionButton.setAttribute('id', actionButton_id);
416 document.styleSheets[0].addRule('#' + actionButton_id + ':after', 'background-image: url("' + actionButton_icon + '");');
417 newActionsBarWrapper.appendChild(actionButton);
418 }
419 }
420
421 newActionsBar.appendChild(newActionsBarWrapper);
203 },422 },
204423
205 /**424 /**
206 * Required call that initializes the UbuntuUI object425 * Required call that initializes the UbuntuUI object
207 * @method {} init426 * @method {} init
208 */427 */
209 init: function () {428 init: function() {
210 this.__setupTabs(document);429 this.__setupTabs(document);
211 this.__setupPage(document);430 this.__setupPage(document);
212 this.__setupActionsBar(document);431 this.__setupActionsBar(document);
@@ -218,11 +437,10 @@
218 * @param {ID} id - The element's id attribute437 * @param {ID} id - The element's id attribute
219 * @return {Page} - The Page with the specified id438 * @return {Page} - The Page with the specified id
220 */439 */
221 page: function (id) {440 page: function(id) {
222 if (typeof Page != 'undefined' && Page ) {441 if (typeof Page != 'undefined' && Page) {
223 return new Page(id);442 return new Page(id);
224 }443 } else {
225 else {
226 console.error('Could not find the Page element. You might be missing the "page.js" Page definition script. Please add a <script> declaration to include it.');444 console.error('Could not find the Page element. You might be missing the "page.js" Page definition script. Please add a <script> declaration to include it.');
227 }445 }
228 },446 },
@@ -233,11 +451,10 @@
233 * @param {ID} id - The element's id attribute451 * @param {ID} id - The element's id attribute
234 * @return {Tab} - The Tab with the specified id452 * @return {Tab} - The Tab with the specified id
235 */453 */
236 tab: function (id) {454 tab: function(id) {
237 if (typeof Tab != 'undefined' && Tab ) {455 if (typeof Tab != 'undefined' && Tab) {
238 return new Tab(id);456 return new Tab(id);
239 }457 } else {
240 else {
241 console.error('Could not find the Tab element. You might be missing the "tab.js" Tab definition script. Please add a <script> declaration to include it.');458 console.error('Could not find the Tab element. You might be missing the "tab.js" Tab definition script. Please add a <script> declaration to include it.');
242 }459 }
243 },460 },
@@ -248,11 +465,10 @@
248 * @param {ID} id - The element's id attribute465 * @param {ID} id - The element's id attribute
249 * @return {Shape} - The Shape with the specified id466 * @return {Shape} - The Shape with the specified id
250 */467 */
251 shape: function (id) {468 shape: function(id) {
252 if (typeof Shape != 'undefined' && Shape ) {469 if (typeof Shape != 'undefined' && Shape) {
253 return new Shape(id);470 return new Shape(id);
254 }471 } else {
255 else {
256 console.error('Could not find the Shape element. You might be missing the "shape.js" Shape definition script. Please add a <script> declaration to include it.');472 console.error('Could not find the Shape element. You might be missing the "shape.js" Shape definition script. Please add a <script> declaration to include it.');
257 }473 }
258 },474 },
@@ -263,11 +479,10 @@
263 * @param {ID} id - The element's id attribute479 * @param {ID} id - The element's id attribute
264 * @return {Button} - The Button with the specified id480 * @return {Button} - The Button with the specified id
265 */481 */
266 button: function (id) {482 button: function(id) {
267 if (typeof Button != 'undefined' && Button) {483 if (typeof Button != 'undefined' && Button) {
268 return new Button(id);484 return new Button(id);
269 }485 } else {
270 else {
271 console.error('Could not find the Button element. You might be missing the "button.js" Button definition script. Please add a <script> declaration to include it.');486 console.error('Could not find the Button element. You might be missing the "button.js" Button definition script. Please add a <script> declaration to include it.');
272 }487 }
273 },488 },
@@ -278,7 +493,7 @@
278 * @param {ID} id - The element's id attribute493 * @param {ID} id - The element's id attribute
279 * @return {Progress} - The Progress with the specified id494 * @return {Progress} - The Progress with the specified id
280 */495 */
281 progress: function (id) {496 progress: function(id) {
282 if (typeof Progress != 'undefined' && Progress) {497 if (typeof Progress != 'undefined' && Progress) {
283 return new Progress(id);498 return new Progress(id);
284 }499 }
@@ -290,11 +505,10 @@
290 * @param {ID} id - The element's id attribute505 * @param {ID} id - The element's id attribute
291 * @return {Dialog} - The Dialog with the specified id506 * @return {Dialog} - The Dialog with the specified id
292 */507 */
293 dialog: function (id) {508 dialog: function(id) {
294 if (typeof Dialog != 'undefined' && Dialog) {509 if (typeof Dialog != 'undefined' && Dialog) {
295 return new Dialog(id);510 return new Dialog(id);
296 }511 } else {
297 else {
298 console.error('Could not find the Dialog element. You might be missing the "dialog.js" Dialog definition script. Please add a <script> declaration to include it.');512 console.error('Could not find the Dialog element. You might be missing the "dialog.js" Dialog definition script. Please add a <script> declaration to include it.');
299 }513 }
300 },514 },
@@ -306,11 +520,10 @@
306 * @param {ID} id - The element's id attribute520 * @param {ID} id - The element's id attribute
307 * @return {Popover} - The Popover with the specified id521 * @return {Popover} - The Popover with the specified id
308 */522 */
309 popover: function (elem, id) {523 popover: function(elem, id) {
310 if (typeof Popover != 'undefined' && Popover) {524 if (typeof Popover != 'undefined' && Popover) {
311 return new Popover(elem, id);525 return new Popover(elem, id);
312 }526 } else {
313 else {
314 console.error('Could not find the Popover element. You might be missing the "popover.js" Popover definition script. Please add a <script> declaration to include it.');527 console.error('Could not find the Popover element. You might be missing the "popover.js" Popover definition script. Please add a <script> declaration to include it.');
315 }528 }
316 },529 },
@@ -321,11 +534,10 @@
321 * @param {ID} id - The element's id attribute534 * @param {ID} id - The element's id attribute
322 * @return {Header} - The Header with the specified id535 * @return {Header} - The Header with the specified id
323 */536 */
324 header: function (id) {537 header: function(id) {
325 if (typeof Header != 'undefined' && Header) {538 if (typeof Header != 'undefined' && Header) {
326 return new Header(id);539 return new Header(id);
327 }540 } else {
328 else {
329 console.error('Could not find the Header element. You might be missing the "header.js" Header definition script. Please add a <script> declaration to include it.');541 console.error('Could not find the Header element. You might be missing the "header.js" Header definition script. Please add a <script> declaration to include it.');
330 }542 }
331 },543 },
@@ -336,11 +548,10 @@
336 * @param {ID} id - The element's id attribute548 * @param {ID} id - The element's id attribute
337 * @return {Toolbar} - The Toolbar with the specified id549 * @return {Toolbar} - The Toolbar with the specified id
338 */550 */
339 toolbar: function (id) {551 toolbar: function(id) {
340 if (typeof Toolbar != 'undefined' && Toolbar) {552 if (typeof Toolbar != 'undefined' && Toolbar) {
341 return new Toolbar(id, this.__getTabInfosDelegate());553 return new Toolbar(id, this.__getTabInfosDelegate());
342 }554 } else {
343 else {
344 console.error('Could not find the Toolbar element. You might be missing the "toolbar.js" Toolbar definition script. Please add a <script> declaration to include it.');555 console.error('Could not find the Toolbar element. You might be missing the "toolbar.js" Toolbar definition script. Please add a <script> declaration to include it.');
345 }556 }
346 },557 },
@@ -351,11 +562,10 @@
351 * @param {Selector} selector - A selector that JavaScript querySelector method understands562 * @param {Selector} selector - A selector that JavaScript querySelector method understands
352 * @return {List}563 * @return {List}
353 */564 */
354 list: function (selector) {565 list: function(selector) {
355 if (typeof List != 'undefined' && List) {566 if (typeof List != 'undefined' && List) {
356 return new List(selector);567 return new List(selector);
357 }568 } else {
358 else {
359 console.error('Could not find the List element. You might be missing the "list.js" List definition script. Please add a <script> declaration to include it.');569 console.error('Could not find the List element. You might be missing the "list.js" List definition script. Please add a <script> declaration to include it.');
360 }570 }
361 },571 },
@@ -368,11 +578,10 @@
368 * @param {Boolean} multiSelection - If multiple choice selection is enabled the list is always expanded.578 * @param {Boolean} multiSelection - If multiple choice selection is enabled the list is always expanded.
369 * @return {OptionSelector}579 * @return {OptionSelector}
370 */580 */
371 optionselector: function (id, expanded, multiSelection) {581 optionselector: function(id, expanded, multiSelection) {
372 if (typeof OptionSelector != 'undefined' && OptionSelector) {582 if (typeof OptionSelector != 'undefined' && OptionSelector) {
373 return new OptionSelector(id, expanded, multiSelection);583 return new OptionSelector(id, expanded, multiSelection);
374 }584 } else {
375 else {
376 console.error('Could not find the OptionSelector element. You might be missing the "option-selector.js" OptionSelector definition script. Please add a <script> declaration to include it.');585 console.error('Could not find the OptionSelector element. You might be missing the "option-selector.js" OptionSelector definition script. Please add a <script> declaration to include it.');
377 }586 }
378 },587 },
379588
=== modified file '0.1/ambiance/js/page.js'
--- 0.1/ambiance/js/page.js 2014-05-25 22:08:39 +0000
+++ 0.1/ambiance/js/page.js 2015-03-04 21:23:40 +0000
@@ -58,9 +58,7 @@
58 this.onActivatedCallbacks = [];58 this.onActivatedCallbacks = [];
5959
60 this._header = document.querySelector('div[data-role="mainview"] header');60 this._header = document.querySelector('div[data-role="mainview"] header');
61 this._tabtitle = this._header.querySelector('[data-role="tabtitle"]');61 this._tabTitle = this._header.querySelector('[data-role="tabtitle"]');
62 this._backbtn = this._header.querySelector('[data-role="back-btn"]');
63
64 this.__setup();62 this.__setup();
65};63};
66Page.PAGE_ACTIVATED_EVENT = 'ubuntu-html5-on-page-activated';64Page.PAGE_ACTIVATED_EVENT = 'ubuntu-html5-on-page-activated';
@@ -178,7 +176,7 @@
178 } catch (e) {}176 } catch (e) {}
179177
180 title = title || DEFAULT_TITLE;178 title = title || DEFAULT_TITLE;
181 this._tabtitle.textContent= title;179 this._tabTitle.textContent= title;
182 },180 },
183181
184 /**182 /**
@@ -192,14 +190,6 @@
192 element.getAttribute('data-role') === 'page';190 element.getAttribute('data-role') === 'page';
193 },191 },
194192
195
196 /**
197 * @private
198 */
199 isFirst_Page: function (element) {
200 return element.parentNode.querySelector(':first-child') == element;
201 },
202
203 /**193 /**
204 * @private194 * @private
205 */195 */
@@ -210,8 +200,6 @@
210 if (!this.isPage(page)) {200 if (!this.isPage(page)) {
211 return;201 return;
212 }202 }
213
214 this._backbtn.disabled = this.isFirst_Page(page);
215 page.style.display = displayStyle;203 page.style.display = displayStyle;
216 },204 },
217205
218206
=== modified file '0.1/ambiance/js/pagestacks.js'
--- 0.1/ambiance/js/pagestacks.js 2014-09-17 17:44:50 +0000
+++ 0.1/ambiance/js/pagestacks.js 2015-03-04 21:23:40 +0000
@@ -86,9 +86,10 @@
86 }86 }
87 };87 };
8888
89 function Pagestack(pagestack) {89 function Pagestack(pageStack) {
90 this._pages = [];90 this._pages = [];
91 this._pagestack = pagestack;91 this._pageStack = pageStack;
92 this._backBtn = document.querySelector('[data-role="back-btn"]');
92 };93 };
9394
94 Pagestack.prototype = {95 Pagestack.prototype = {
@@ -161,7 +162,7 @@
161 },162 },
162163
163 onPageChanged : function(callback){164 onPageChanged : function(callback){
164 this._pagestack.addEventListener("pagechanged", callback);165 this._pageStack.addEventListener("pagechanged", callback);
165 },166 },
166167
167 /**168 /**
@@ -170,15 +171,11 @@
170 __setAllPagesVisibility: function (visible) {171 __setAllPagesVisibility: function (visible) {
171 var visibility = visible ? "block" : "none";172 var visibility = visible ? "block" : "none";
172173
173 var children = [].slice.call(this._pagestack.children);174 var children = [].slice.call(this._pageStack.children);
174 children.forEach(function(element) {175 children.forEach(function(element) {
175 var pageHelper = new Page();176 var pageHelper = new Page();
176 if (pageHelper.isPage(element)) {177 if (pageHelper.isPage(element)) {
177 el.style.display = visibility;178 element.style.display = visibility;
178 // treat footers separately
179 var footer = el.querySelector('footer');
180 if (footer)
181 footer.style.display = visibility;
182 }179 }
183 });180 });
184 },181 },
@@ -194,10 +191,21 @@
194 * @private191 * @private
195 */192 */
196 __dispatchPageChanged: function (page) {193 __dispatchPageChanged: function (page) {
194 this._backBtn.disabled = (this.depth() == 1);
195
196 [].forEach.call( document.querySelectorAll('[data-role="actions-wrapper"]'), function(el) {
197 el.style.display = 'none';
198 });
199
200 var pageActions = document.getElementById("actions_" + page);
201 if (pageActions !== null) {
202 pageActions.style.display = 'block';
203 }
204
197 var event = document.createEvent('Event');205 var event = document.createEvent('Event');
198 event.initEvent('pagechanged',true,true);206 event.initEvent('pagechanged',true,true);
199 event.page = page;207 event.page = page;
200 this._pagestack.dispatchEvent(event);208 this._pageStack.dispatchEvent(event);
201 },209 },
202 };210 };
203211
204212
=== modified file '0.1/ambiance/js/tabs.js'
--- 0.1/ambiance/js/tabs.js 2015-01-15 22:02:35 +0000
+++ 0.1/ambiance/js/tabs.js 2015-03-04 21:23:40 +0000
@@ -167,7 +167,7 @@
167 var backbtn = document.createElement('button');167 var backbtn = document.createElement('button');
168 backbtn.setAttribute('data-role', 'back-btn');168 backbtn.setAttribute('data-role', 'back-btn');
169 backbtn.setAttribute('id', PAGESTACK_BACK_ID + '-' + Math.floor(Math.random()));169 backbtn.setAttribute('id', PAGESTACK_BACK_ID + '-' + Math.floor(Math.random()));
170 backbtn.style.display = 'none';170 backbtn.disabled = true;
171171
172 if(this._tabs.childElementCount > 1) {172 if(this._tabs.childElementCount > 1) {
173 this._tabsbtn = document.createElement('button');173 this._tabsbtn = document.createElement('button');
@@ -245,6 +245,7 @@
245 * @private245 * @private
246 */246 */
247 __dispatchTabChangedEvent: function (tabId) {247 __dispatchTabChangedEvent: function (tabId) {
248
248 this._evt = document.createEvent('Event');249 this._evt = document.createEvent('Event');
249 this._evt.initEvent('tabchanged', true, true);250 this._evt.initEvent('tabchanged', true, true);
250 this._evt.infos = {251 this._evt.infos = {
251252
=== modified file 'examples/html5-theme/widgets/Pagestack.html'
--- examples/html5-theme/widgets/Pagestack.html 2014-05-25 23:29:28 +0000
+++ examples/html5-theme/widgets/Pagestack.html 2015-03-04 21:23:40 +0000
@@ -48,11 +48,9 @@
48 <script src="../../../0.1/ambiance/js/popovers.js"></script>48 <script src="../../../0.1/ambiance/js/popovers.js"></script>
49 <script src="../../../0.1/ambiance/js/list.js"></script>49 <script src="../../../0.1/ambiance/js/list.js"></script>
50 <script src="../../../0.1/ambiance/js/toolbars.js"></script>50 <script src="../../../0.1/ambiance/js/toolbars.js"></script>
51 <script src="../../../0.1/ambiance/js/actionsbar.js"></script>
52 <script src="../../../0.1/ambiance/js/tab.js"></script>51 <script src="../../../0.1/ambiance/js/tab.js"></script>
53 <script src="../../../0.1/ambiance/js/tabs.js"></script>52 <script src="../../../0.1/ambiance/js/tabs.js"></script>
5453
55 <script src="../apps/rss-reader/app.js"></script>
56</head>54</head>
5755
58<body>56<body>
@@ -138,9 +136,8 @@
138136
139 </div>137 </div>
140138
141 <script type="text/javascript">139 <script src="../apps/rss-reader/app.js"></script>
142 var UI = new UbuntuUI();140
143 </script>
144</body>141</body>
145</html>142</html>
146143
147144
=== modified file 'examples/html5-theme/widgets/Tabs.html'
--- examples/html5-theme/widgets/Tabs.html 2014-08-30 20:10:18 +0000
+++ examples/html5-theme/widgets/Tabs.html 2015-03-04 21:23:40 +0000
@@ -35,7 +35,6 @@
35 <!-- Ubuntu UI javascript imports - Ambiance theme -->35 <!-- Ubuntu UI javascript imports - Ambiance theme -->
36 <script src="../../../0.1/ambiance/js/fast-buttons.js"></script>36 <script src="../../../0.1/ambiance/js/fast-buttons.js"></script>
37 <script src="../../../0.1/ambiance/js/core.js"></script>37 <script src="../../../0.1/ambiance/js/core.js"></script>
38 <script src="../../../0.1/ambiance/js/actionsbar.js"></script>
39 <script src="../../../0.1/ambiance/js/tab.js"></script>38 <script src="../../../0.1/ambiance/js/tab.js"></script>
40 <script src="../../../0.1/ambiance/js/tabs.js"></script>39 <script src="../../../0.1/ambiance/js/tabs.js"></script>
41</head>40</head>

Subscribers

People subscribed via source and target branches