Merge lp:~daker/ubuntu-html5-theme/fix.1240682 into lp:~ubuntu-html5-theme-devs/ubuntu-html5-theme/ambiance

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: Kyle Nitzsche
Approved revision: 89
Merged at revision: 89
Proposed branch: lp:~daker/ubuntu-html5-theme/fix.1240682
Merge into: lp:~ubuntu-html5-theme-devs/ubuntu-html5-theme/ambiance
Diff against target: 549 lines (+231/-233)
3 files modified
0.1/ambiance/js/buttons.js (+9/-9)
0.1/ambiance/js/list.js (+132/-134)
0.1/ambiance/js/pagestacks.js (+90/-90)
To merge this branch: bzr merge lp:~daker/ubuntu-html5-theme/fix.1240682
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Kyle Nitzsche Needs Fixing
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+191900@code.launchpad.net

Commit message

Space instead of tab

To post a comment you must log in.
Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

Hi Adnane: I think list.js still uses tabs.

review: Needs Fixing
89. By Adnane Belmadiaf

Fixed list.js

Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

thanks

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '0.1/ambiance/js/buttons.js'
--- 0.1/ambiance/js/buttons.js 2013-10-03 21:36:44 +0000
+++ 0.1/ambiance/js/buttons.js 2013-10-30 20:52:23 +0000
@@ -5,18 +5,18 @@
5 * This file is part of ubuntu-html5-theme.5 * This file is part of ubuntu-html5-theme.
6 *6 *
7 * This package is free software; you can redistribute it and/or modify7 * 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 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 9 * published by the Free Software Foundation; either version 3 of the
10 * License, or10 * License, or
11 * (at your option) any later version.11 * (at your option) any later version.
12 12
13 * This package is distributed in the hope that it will be useful,13 * This package is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.16 * GNU General Public License for more details.
17 17
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see 19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.20 * <http://www.gnu.org/licenses/>.
21 */21 */
2222
@@ -27,9 +27,9 @@
2727
28Button.prototype = {28Button.prototype = {
29 click: function (callback) {29 click: function (callback) {
30 if ( ! document.getElementById(this.id)) {30 if ( ! document.getElementById(this.id)) {
31 throw "Invalid button ID: " + String(this.id);31 throw "Invalid button ID: " + String(this.id);
32 }32 }
33 new FastButton(document.getElementById(this.id), callback);33 new FastButton(document.getElementById(this.id), callback);
34 }34 }
35};35};
3636
=== modified file '0.1/ambiance/js/list.js'
--- 0.1/ambiance/js/list.js 2013-10-21 14:02:06 +0000
+++ 0.1/ambiance/js/list.js 2013-10-30 20:52:23 +0000
@@ -5,18 +5,18 @@
5 * This file is part of ubuntu-html5-theme.5 * This file is part of ubuntu-html5-theme.
6 *6 *
7 * This package is free software; you can redistribute it and/or modify7 * 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 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 9 * published by the Free Software Foundation; either version 3 of the
10 * License, or10 * License, or
11 * (at your option) any later version.11 * (at your option) any later version.
12 12
13 * This package is distributed in the hope that it will be useful,13 * This package is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.16 * GNU General Public License for more details.
17 17
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see 19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.20 * <http://www.gnu.org/licenses/>.
21 */21 */
2222
@@ -24,142 +24,140 @@
24var List = (function () {24var List = (function () {
25 var LIST_DATA_ROLE = 'list';25 var LIST_DATA_ROLE = 'list';
2626
27 var __addUlIfNotFound = function(list) {27 var __addUlIfNotFound = function (list) {
28 if (list) {28 if (list) {
29 var uls = list.querySelectorAll('ul');29 var uls = list.querySelectorAll('ul');
30 if (uls == null || uls.length == 0) {30 if (uls == null || uls.length == 0) {
31 var ul = document.createElement('ul');31 var ul = document.createElement('ul');
32 list.appendChild(ul);32 list.appendChild(ul);
33 }33 }
34 }34 }
35 };35 };
3636
37 var List = function (selector) {37 var List = function (selector) {
38 var list = document.querySelector(selector);38 var list = document.querySelector(selector);
39 if (list == null || list.nodeName.toLowerCase() !== 'section' || list.getAttribute('data-role') != LIST_DATA_ROLE) {39 if (list == null || list.nodeName.toLowerCase() !== 'section' || list.getAttribute('data-role') != LIST_DATA_ROLE) {
40 throw new Error('Element with selector "' + selector + '" does not exist or not declared as a "list" <section>');40 throw new Error('Element with selector "' + selector + '" does not exist or not declared as a "list" <section>');
41 }41 }
42 this._list = list;42 this._list = list;
4343
44 __addUlIfNotFound(this._list);44 __addUlIfNotFound(this._list);
45 };45 };
4646
47 List.prototype = {47 List.prototype = {
48 setHeader: function (text) {48 setHeader: function (text) {
49 if (typeof(text) == 'string') {49 if (typeof (text) == 'string') {
50 var header = this._list.querySelectorAll('header');50 var header = this._list.querySelectorAll('header');
51 if (header) {51 if (header) {
52 if (header.length > 1) {52 if (header.length > 1) {
53 // more than one <header> detected53 // more than one <header> detected
54 throw new Error("More than one <header> tag detected");54 throw new Error("More than one <header> tag detected");
55 }55 }
56 if (header.length == 1)56 if (header.length == 1)
57 header = header[0];57 header = header[0];
58 else58 else
59 header = null;59 header = null;
60 }60 }
6161
62 if (!header)62 if (!header)
63 header = document.createElement('header');63 header = document.createElement('header');
6464
65 header.innerText = text;65 header.innerText = text;
66 }66 }
67 },67 },
68 /*68 /*
69 \brief Appends a item to the list69 \brief Appends a item to the list
70 70
71 Appends a given item to the current list.71 Appends a given item to the current list.
72 72
73 \param text A string of text (images & custom html not supported at the moment)73 \param text A string of text (images & custom html not supported at the moment)
74 \param onclick (optional) A function callback that is to be called when the item is clicked.74 \param onclick (optional) A function callback that is to be called when the item is clicked.
75 It will be called with the clicked node as a parameter along with the value of75 It will be called with the clicked node as a parameter along with the value of
76 user_data (if any).76 user_data (if any).
77 \param id (optional) An optional Id for the added node, the id will only be added if it does not already77 \param id (optional) An optional Id for the added node, the id will only be added if it does not already
78 conflict with another one.78 conflict with another one.
79 \param user_data (optional) An javascript entity that will be passed to the onclick callback (if any)79 \param user_data (optional) An javascript entity that will be passed to the onclick callback (if any)
80 when the event has been trigger.80 when the event has been trigger.
81 \return added item node or null81 \return added item node or null
82 */82 */
83 append: function (text, label, id, onclick, user_data) {83 append: function (text, label, id, onclick, user_data) {
84 var li = document.createElement('li');84 var li = document.createElement('li');
85 var a = document.createElement('a');85 var a = document.createElement('a');
8686
87 a.setAttribute('href', '#');87 a.setAttribute('href', '#');
88 if (onclick && typeof(onclick) == 'function') {88 if (onclick && typeof (onclick) == 'function') {
89 li.addEventListener('click', function(event) {89 li.addEventListener('click', function (event) {
90 onclick(event ? event.target : null, user_data);90 onclick(event ? event.target : null, user_data);
91 if (event)91 if (event)
92 event.preventDefault();92 event.preventDefault();
93 });93 });
94 }94 }
95 //FIXME: no real checks on text content95 //FIXME: no real checks on text content
96 a.innerText = text;96 a.innerText = text;
97 li.appendChild(a);97 li.appendChild(a);
9898
99 if (label && typeof(label) == 'string') {99 if (label && typeof (label) == 'string') {
100 var n = document.createElement('label');100 var n = document.createElement('label');
101 n.innerText = label;101 n.innerText = label;
102 li.appendChild(n);102 li.appendChild(n);
103 }103 }
104104
105 if (id && typeof(id) == 'string') {105 if (id && typeof (id) == 'string') {
106 if ( ! document.getElementById(id))106 if (!document.getElementById(id))
107 li.setAttribute('id', id);107 li.setAttribute('id', id);
108 }108 }
109 this._list.querySelector('ul').appendChild(li);109 this._list.querySelector('ul').appendChild(li);
110110
111 return li;111 return li;
112 },112 },
113 /*113 /*
114 \brief returns the nth child item from a list114 \brief returns the nth child item from a list
115 115
116 \param index Index of the child to return (0 based number)116 \param index Index of the child to return (0 based number)
117 \return selected item node or null117 \return selected item node or null
118 */118 */
119 at: function (index) {119 at: function (index) {
120 if (typeof(index) != 'number')120 if (typeof (index) != 'number')
121 return null;121 return null;
122 return this._list.querySelector('ul').querySelector('li:nth-child(' + index + ')');122 return this._list.querySelector('ul').querySelector('li:nth-child(' + index + ')');
123 },123 },
124 /*124 /*
125 \brief removes the nth child item from a list125 \brief removes the nth child item from a list
126 126
127 \param index Index of the child to remove (0 based number)127 \param index Index of the child to remove (0 based number)
128 \return nothing128 \return nothing
129 */129 */
130 remove: function (index) {130 remove: function (index) {
131 var item = this.at(index);131 var item = this.at(index);
132 if (item) {132 if (item) {
133 item.parentNode.removeChild(item);133 item.parentNode.removeChild(item);
134 }134 }
135 },135 },
136 /*136 /*
137 \brief removes all the child items from a list137 \brief removes all the child items from a list
138 \return nothing138 \return nothing
139 */139 */
140 removeAllItems: function() {140 removeAllItems: function () {
141 if (this._list.querySelector('ul'))141 if (this._list.querySelector('ul'))
142 this._list.querySelector('ul').innerHTML = '';142 this._list.querySelector('ul').innerHTML = '';
143 },143 },
144 /*144 /*
145 \brief iterator over the list of list items and calls a function on each one145 \brief iterator over the list of list items and calls a function on each one
146 146
147 \param func function to be called for each list item. The function147 \param func function to be called for each list item. The function
148 receives the DOM node associated with the current item along with its148 receives the DOM node associated with the current item along with its
149 index.149 index.
150 \return nothing150 \return nothing
151 */151 */
152 forEach: function (func) {152 forEach: function (func) {
153 if (typeof(func) !== 'function')153 if (typeof (func) !== 'function')
154 return;154 return;
155 var items = this._list.querySelector('ul').querySelectorAll('li');155 var items = this._list.querySelector('ul').querySelectorAll('li');
156 Array.prototype.forEach.call(items, function (element, index) {156 Array.prototype.forEach.call(items, function (element, index) {
157 func(element, index);157 func(element, index);
158 });158 });
159 },159 },
160 };160 };
161161
162 return List;162 return List;
163}) ();163})();
164
165
166\ No newline at end of file164\ No newline at end of file
167165
=== modified file '0.1/ambiance/js/pagestacks.js'
--- 0.1/ambiance/js/pagestacks.js 2013-07-19 00:08:53 +0000
+++ 0.1/ambiance/js/pagestacks.js 2013-10-30 20:52:23 +0000
@@ -5,113 +5,113 @@
5 * This file is part of ubuntu-html5-theme.5 * This file is part of ubuntu-html5-theme.
6 *6 *
7 * This package is free software; you can redistribute it and/or modify7 * 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 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 9 * published by the Free Software Foundation; either version 3 of the
10 * License, or10 * License, or
11 * (at your option) any later version.11 * (at your option) any later version.
12 12
13 * This package is distributed in the hope that it will be useful,13 * This package is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.16 * GNU General Public License for more details.
17 17
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see 19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.20 * <http://www.gnu.org/licenses/>.
21 */21 */
2222
23/* Pagestack */23/* Pagestack */
24
24var Pagestack = (function () {25var Pagestack = (function () {
25 26
26 function __safeCall(f, args, errorfunc) {27 function __safeCall(f, args, errorfunc) {
27 if (typeof(f) !== 'function')28 if (typeof (f) !== 'function')
28 return;29 return;
29 try {30 try {
30 f.apply(null, args);31 f.apply(null, args);
31 }32 } catch (e) {
32 catch(e) { if (errorfunc && typeof(errorfunc) === 'function') errorfunc(e) }33 if (errorfunc && typeof (errorfunc) === 'function') errorfunc(e)
34 }
33 };35 };
3436
35 function Pagestack () {37 function Pagestack() {
36 this._pages = [];38 this._pages = [];
37 };39 };
3840
39 Pagestack.prototype = {41 Pagestack.prototype = {
40 __setAllPagesVisibility: function (visible) {42 __setAllPagesVisibility: function (visible) {
41 var visibility = visible ? "block" : "none";43 var visibility = visible ? "block" : "none";
42 [].forEach.call(document.querySelectorAll("[data-role='pagestack'] [data-role='page']"), function(el) {44 [].forEach.call(document.querySelectorAll("[data-role='pagestack'] [data-role='page']"), function (el) {
43 el.style.display = visibility;45 el.style.display = visibility;
4446
45 // treat footers separately47 // treat footers separately
46 var footer = el.querySelector('footer');48 var footer = el.querySelector('footer');
47 if (footer)49 if (footer)
48 footer.style.display = visibility;50 footer.style.display = visibility;
49 });51 });
50 },52 },
51 __isPage: function (element) {53 __isPage: function (element) {
52 return element.getAttribute('data-role') === 'page';54 return element.getAttribute('data-role') === 'page';
53 },55 },
54 __deactivate: function (id) {56 __deactivate: function (id) {
55 if (!id || typeof(id) !== 'string')57 if (!id || typeof (id) !== 'string')
56 return;58 return;
57 var page = document.getElementById(id);59 var page = document.getElementById(id);
58 if ( ! this.__isPage(page)) {60 if (!this.__isPage(page)) {
59 return;61 return;
60 }62 }
61 page.style.display = "none";63 page.style.display = "none";
62 if (page.querySelector('footer')) {64 if (page.querySelector('footer')) {
63 var footer = page.querySelector('footer');65 var footer = page.querySelector('footer');
64 footer.style.display = 'none';66 footer.style.display = 'none';
65 footer.classList.remove('revealed');67 footer.classList.remove('revealed');
66 }68 }
67 },69 },
68 __activate: function (id) {70 __activate: function (id) {
69 if (!id || typeof(id) !== 'string')71 if (!id || typeof (id) !== 'string')
70 return;72 return;
71 var page = document.getElementById(id);73 var page = document.getElementById(id);
72 if ( ! this.__isPage(page)) {74 if (!this.__isPage(page)) {
73 return;75 return;
74 }76 }
75 page.style.display = "block";77 page.style.display = "block";
76 if (page.querySelector('footer')) {78 if (page.querySelector('footer')) {
77 var footer = page.querySelector('footer');79 var footer = page.querySelector('footer');
78 footer.style.display = 'block';80 footer.style.display = 'block';
79 footer.classList.add('revealed');81 footer.classList.add('revealed');
80 }82 }
81 },83 },
82 push: function (id, properties) {84 push: function (id, properties) {
83 try {85 try {
84 __safeCall(this.__setAllPagesVisibility.bind(this), [false]);86 __safeCall(this.__setAllPagesVisibility.bind(this), [false]);
8587
86 this.__activate(id);88 this.__activate(id);
87 this._pages.push(id);89 this._pages.push(id);
88 }90 } catch (e) {}
89 catch(e) {}91 },
90 },92 isEmpty: function () {
91 isEmpty: function () {93 return this._pages.length === 0;
92 return this._pages.length === 0;94 },
93 },95 currentPage: function () {
94 currentPage: function () {96 return this.isEmpty() ? null : this._pages[this._pages.length - 1];
95 return this.isEmpty() ? null : this._pages[this._pages.length-1];97 },
96 },98 depth: function () {
97 depth: function() {99 return this._pages.length;
98 return this._pages.length;100 },
99 },101 clear: function () {
100 clear: function() {102 if (this.isEmpty())
101 if (this.isEmpty())103 return;
102 return;104 __safeCall(this.__deactivate.bind(this), [this.currentPage()]);
103 __safeCall(this.__deactivate.bind(this), [this.currentPage()]);105 this._pages = [];
104 this._pages = [];106 },
105 },107 pop: function () {
106 pop: function() {108 if (this.isEmpty())
107 if(this.isEmpty())109 return;
108 return;110 __safeCall(this.__deactivate.bind(this), [this.currentPage()]);
109 __safeCall(this.__deactivate.bind(this), [this.currentPage()]);111 this._pages.pop();
110 this._pages.pop();112 __safeCall(this.__activate.bind(this), [this.currentPage()]);
111 __safeCall(this.__activate.bind(this), [this.currentPage()]);113 }
112 }
113 }114 }
114115
115 return Pagestack;116 return Pagestack;
116})();117})();
117
118\ No newline at end of file118\ No newline at end of file

Subscribers

People subscribed via source and target branches