Merge lp:~daker/ubuntu-html5-theme/fix.1240682 into lp:~ubuntu-html5-theme-devs/ubuntu-html5-theme/ambiance
- fix.1240682
- Merge into 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 |
Related bugs: |
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
Description of the change
To post a comment you must log in.
- 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
1 | === modified file '0.1/ambiance/js/buttons.js' |
2 | --- 0.1/ambiance/js/buttons.js 2013-10-03 21:36:44 +0000 |
3 | +++ 0.1/ambiance/js/buttons.js 2013-10-30 20:52:23 +0000 |
4 | @@ -5,18 +5,18 @@ |
5 | * This file is part of ubuntu-html5-theme. |
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 | + * it under the terms of the GNU Lesser General Public License as |
11 | + * published by the Free Software Foundation; either version 3 of the |
12 | * License, or |
13 | * (at your option) any later version. |
14 | - |
15 | + |
16 | * This package is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | - |
21 | - * You should have received a copy of the GNU Lesser General Public |
22 | - * License along with this program. If not, see |
23 | + |
24 | + * You should have received a copy of the GNU Lesser General Public |
25 | + * License along with this program. If not, see |
26 | * <http://www.gnu.org/licenses/>. |
27 | */ |
28 | |
29 | @@ -27,9 +27,9 @@ |
30 | |
31 | Button.prototype = { |
32 | click: function (callback) { |
33 | - if ( ! document.getElementById(this.id)) { |
34 | - throw "Invalid button ID: " + String(this.id); |
35 | - } |
36 | + if ( ! document.getElementById(this.id)) { |
37 | + throw "Invalid button ID: " + String(this.id); |
38 | + } |
39 | new FastButton(document.getElementById(this.id), callback); |
40 | } |
41 | }; |
42 | |
43 | === modified file '0.1/ambiance/js/list.js' |
44 | --- 0.1/ambiance/js/list.js 2013-10-21 14:02:06 +0000 |
45 | +++ 0.1/ambiance/js/list.js 2013-10-30 20:52:23 +0000 |
46 | @@ -5,18 +5,18 @@ |
47 | * This file is part of ubuntu-html5-theme. |
48 | * |
49 | * This package is free software; you can redistribute it and/or modify |
50 | - * it under the terms of the GNU Lesser General Public License as |
51 | - * published by the Free Software Foundation; either version 3 of the |
52 | + * it under the terms of the GNU Lesser General Public License as |
53 | + * published by the Free Software Foundation; either version 3 of the |
54 | * License, or |
55 | * (at your option) any later version. |
56 | - |
57 | + |
58 | * This package is distributed in the hope that it will be useful, |
59 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
60 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
61 | * GNU General Public License for more details. |
62 | - |
63 | - * You should have received a copy of the GNU Lesser General Public |
64 | - * License along with this program. If not, see |
65 | + |
66 | + * You should have received a copy of the GNU Lesser General Public |
67 | + * License along with this program. If not, see |
68 | * <http://www.gnu.org/licenses/>. |
69 | */ |
70 | |
71 | @@ -24,142 +24,140 @@ |
72 | var List = (function () { |
73 | var LIST_DATA_ROLE = 'list'; |
74 | |
75 | - var __addUlIfNotFound = function(list) { |
76 | - if (list) { |
77 | - var uls = list.querySelectorAll('ul'); |
78 | - if (uls == null || uls.length == 0) { |
79 | - var ul = document.createElement('ul'); |
80 | - list.appendChild(ul); |
81 | - } |
82 | - } |
83 | + var __addUlIfNotFound = function (list) { |
84 | + if (list) { |
85 | + var uls = list.querySelectorAll('ul'); |
86 | + if (uls == null || uls.length == 0) { |
87 | + var ul = document.createElement('ul'); |
88 | + list.appendChild(ul); |
89 | + } |
90 | + } |
91 | }; |
92 | |
93 | var List = function (selector) { |
94 | - var list = document.querySelector(selector); |
95 | - if (list == null || list.nodeName.toLowerCase() !== 'section' || list.getAttribute('data-role') != LIST_DATA_ROLE) { |
96 | - throw new Error('Element with selector "' + selector + '" does not exist or not declared as a "list" <section>'); |
97 | - } |
98 | - this._list = list; |
99 | + var list = document.querySelector(selector); |
100 | + if (list == null || list.nodeName.toLowerCase() !== 'section' || list.getAttribute('data-role') != LIST_DATA_ROLE) { |
101 | + throw new Error('Element with selector "' + selector + '" does not exist or not declared as a "list" <section>'); |
102 | + } |
103 | + this._list = list; |
104 | |
105 | - __addUlIfNotFound(this._list); |
106 | + __addUlIfNotFound(this._list); |
107 | }; |
108 | |
109 | List.prototype = { |
110 | - setHeader: function (text) { |
111 | - if (typeof(text) == 'string') { |
112 | - var header = this._list.querySelectorAll('header'); |
113 | - if (header) { |
114 | - if (header.length > 1) { |
115 | - // more than one <header> detected |
116 | - throw new Error("More than one <header> tag detected"); |
117 | - } |
118 | - if (header.length == 1) |
119 | - header = header[0]; |
120 | - else |
121 | - header = null; |
122 | - } |
123 | - |
124 | - if (!header) |
125 | - header = document.createElement('header'); |
126 | - |
127 | - header.innerText = text; |
128 | - } |
129 | - }, |
130 | - /* |
131 | - \brief Appends a item to the list |
132 | - |
133 | - Appends a given item to the current list. |
134 | - |
135 | - \param text A string of text (images & custom html not supported at the moment) |
136 | - \param onclick (optional) A function callback that is to be called when the item is clicked. |
137 | - It will be called with the clicked node as a parameter along with the value of |
138 | - user_data (if any). |
139 | - \param id (optional) An optional Id for the added node, the id will only be added if it does not already |
140 | - conflict with another one. |
141 | + setHeader: function (text) { |
142 | + if (typeof (text) == 'string') { |
143 | + var header = this._list.querySelectorAll('header'); |
144 | + if (header) { |
145 | + if (header.length > 1) { |
146 | + // more than one <header> detected |
147 | + throw new Error("More than one <header> tag detected"); |
148 | + } |
149 | + if (header.length == 1) |
150 | + header = header[0]; |
151 | + else |
152 | + header = null; |
153 | + } |
154 | + |
155 | + if (!header) |
156 | + header = document.createElement('header'); |
157 | + |
158 | + header.innerText = text; |
159 | + } |
160 | + }, |
161 | + /* |
162 | + \brief Appends a item to the list |
163 | + |
164 | + Appends a given item to the current list. |
165 | + |
166 | + \param text A string of text (images & custom html not supported at the moment) |
167 | + \param onclick (optional) A function callback that is to be called when the item is clicked. |
168 | + It will be called with the clicked node as a parameter along with the value of |
169 | + user_data (if any). |
170 | + \param id (optional) An optional Id for the added node, the id will only be added if it does not already |
171 | + conflict with another one. |
172 | \param user_data (optional) An javascript entity that will be passed to the onclick callback (if any) |
173 | - when the event has been trigger. |
174 | - \return added item node or null |
175 | - */ |
176 | - append: function (text, label, id, onclick, user_data) { |
177 | - var li = document.createElement('li'); |
178 | - var a = document.createElement('a'); |
179 | - |
180 | - a.setAttribute('href', '#'); |
181 | - if (onclick && typeof(onclick) == 'function') { |
182 | - li.addEventListener('click', function(event) { |
183 | - onclick(event ? event.target : null, user_data); |
184 | - if (event) |
185 | - event.preventDefault(); |
186 | - }); |
187 | - } |
188 | - //FIXME: no real checks on text content |
189 | - a.innerText = text; |
190 | - li.appendChild(a); |
191 | - |
192 | - if (label && typeof(label) == 'string') { |
193 | - var n = document.createElement('label'); |
194 | - n.innerText = label; |
195 | - li.appendChild(n); |
196 | - } |
197 | - |
198 | - if (id && typeof(id) == 'string') { |
199 | - if ( ! document.getElementById(id)) |
200 | - li.setAttribute('id', id); |
201 | - } |
202 | - this._list.querySelector('ul').appendChild(li); |
203 | - |
204 | - return li; |
205 | - }, |
206 | - /* |
207 | - \brief returns the nth child item from a list |
208 | - |
209 | - \param index Index of the child to return (0 based number) |
210 | - \return selected item node or null |
211 | - */ |
212 | - at: function (index) { |
213 | - if (typeof(index) != 'number') |
214 | - return null; |
215 | - return this._list.querySelector('ul').querySelector('li:nth-child(' + index + ')'); |
216 | - }, |
217 | - /* |
218 | - \brief removes the nth child item from a list |
219 | - |
220 | - \param index Index of the child to remove (0 based number) |
221 | - \return nothing |
222 | - */ |
223 | - remove: function (index) { |
224 | - var item = this.at(index); |
225 | - if (item) { |
226 | - item.parentNode.removeChild(item); |
227 | - } |
228 | - }, |
229 | - /* |
230 | - \brief removes all the child items from a list |
231 | - \return nothing |
232 | - */ |
233 | - removeAllItems: function() { |
234 | - if (this._list.querySelector('ul')) |
235 | - this._list.querySelector('ul').innerHTML = ''; |
236 | - }, |
237 | - /* |
238 | - \brief iterator over the list of list items and calls a function on each one |
239 | - |
240 | - \param func function to be called for each list item. The function |
241 | - receives the DOM node associated with the current item along with its |
242 | - index. |
243 | - \return nothing |
244 | - */ |
245 | - forEach: function (func) { |
246 | - if (typeof(func) !== 'function') |
247 | - return; |
248 | - var items = this._list.querySelector('ul').querySelectorAll('li'); |
249 | - Array.prototype.forEach.call(items, function (element, index) { |
250 | - func(element, index); |
251 | - }); |
252 | - }, |
253 | + when the event has been trigger. |
254 | + \return added item node or null |
255 | + */ |
256 | + append: function (text, label, id, onclick, user_data) { |
257 | + var li = document.createElement('li'); |
258 | + var a = document.createElement('a'); |
259 | + |
260 | + a.setAttribute('href', '#'); |
261 | + if (onclick && typeof (onclick) == 'function') { |
262 | + li.addEventListener('click', function (event) { |
263 | + onclick(event ? event.target : null, user_data); |
264 | + if (event) |
265 | + event.preventDefault(); |
266 | + }); |
267 | + } |
268 | + //FIXME: no real checks on text content |
269 | + a.innerText = text; |
270 | + li.appendChild(a); |
271 | + |
272 | + if (label && typeof (label) == 'string') { |
273 | + var n = document.createElement('label'); |
274 | + n.innerText = label; |
275 | + li.appendChild(n); |
276 | + } |
277 | + |
278 | + if (id && typeof (id) == 'string') { |
279 | + if (!document.getElementById(id)) |
280 | + li.setAttribute('id', id); |
281 | + } |
282 | + this._list.querySelector('ul').appendChild(li); |
283 | + |
284 | + return li; |
285 | + }, |
286 | + /* |
287 | + \brief returns the nth child item from a list |
288 | + |
289 | + \param index Index of the child to return (0 based number) |
290 | + \return selected item node or null |
291 | + */ |
292 | + at: function (index) { |
293 | + if (typeof (index) != 'number') |
294 | + return null; |
295 | + return this._list.querySelector('ul').querySelector('li:nth-child(' + index + ')'); |
296 | + }, |
297 | + /* |
298 | + \brief removes the nth child item from a list |
299 | + |
300 | + \param index Index of the child to remove (0 based number) |
301 | + \return nothing |
302 | + */ |
303 | + remove: function (index) { |
304 | + var item = this.at(index); |
305 | + if (item) { |
306 | + item.parentNode.removeChild(item); |
307 | + } |
308 | + }, |
309 | + /* |
310 | + \brief removes all the child items from a list |
311 | + \return nothing |
312 | + */ |
313 | + removeAllItems: function () { |
314 | + if (this._list.querySelector('ul')) |
315 | + this._list.querySelector('ul').innerHTML = ''; |
316 | + }, |
317 | + /* |
318 | + \brief iterator over the list of list items and calls a function on each one |
319 | + |
320 | + \param func function to be called for each list item. The function |
321 | + receives the DOM node associated with the current item along with its |
322 | + index. |
323 | + \return nothing |
324 | + */ |
325 | + forEach: function (func) { |
326 | + if (typeof (func) !== 'function') |
327 | + return; |
328 | + var items = this._list.querySelector('ul').querySelectorAll('li'); |
329 | + Array.prototype.forEach.call(items, function (element, index) { |
330 | + func(element, index); |
331 | + }); |
332 | + }, |
333 | }; |
334 | |
335 | return List; |
336 | -}) (); |
337 | - |
338 | - |
339 | +})(); |
340 | \ No newline at end of file |
341 | |
342 | === modified file '0.1/ambiance/js/pagestacks.js' |
343 | --- 0.1/ambiance/js/pagestacks.js 2013-07-19 00:08:53 +0000 |
344 | +++ 0.1/ambiance/js/pagestacks.js 2013-10-30 20:52:23 +0000 |
345 | @@ -5,113 +5,113 @@ |
346 | * This file is part of ubuntu-html5-theme. |
347 | * |
348 | * This package is free software; you can redistribute it and/or modify |
349 | - * it under the terms of the GNU Lesser General Public License as |
350 | - * published by the Free Software Foundation; either version 3 of the |
351 | + * it under the terms of the GNU Lesser General Public License as |
352 | + * published by the Free Software Foundation; either version 3 of the |
353 | * License, or |
354 | * (at your option) any later version. |
355 | - |
356 | + |
357 | * This package is distributed in the hope that it will be useful, |
358 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
359 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
360 | * GNU General Public License for more details. |
361 | - |
362 | - * You should have received a copy of the GNU Lesser General Public |
363 | - * License along with this program. If not, see |
364 | + |
365 | + * You should have received a copy of the GNU Lesser General Public |
366 | + * License along with this program. If not, see |
367 | * <http://www.gnu.org/licenses/>. |
368 | */ |
369 | |
370 | /* Pagestack */ |
371 | + |
372 | var Pagestack = (function () { |
373 | - |
374 | + |
375 | function __safeCall(f, args, errorfunc) { |
376 | - if (typeof(f) !== 'function') |
377 | - return; |
378 | - try { |
379 | - f.apply(null, args); |
380 | - } |
381 | - catch(e) { if (errorfunc && typeof(errorfunc) === 'function') errorfunc(e) } |
382 | + if (typeof (f) !== 'function') |
383 | + return; |
384 | + try { |
385 | + f.apply(null, args); |
386 | + } catch (e) { |
387 | + if (errorfunc && typeof (errorfunc) === 'function') errorfunc(e) |
388 | + } |
389 | }; |
390 | |
391 | - function Pagestack () { |
392 | - this._pages = []; |
393 | + function Pagestack() { |
394 | + this._pages = []; |
395 | }; |
396 | |
397 | Pagestack.prototype = { |
398 | - __setAllPagesVisibility: function (visible) { |
399 | - var visibility = visible ? "block" : "none"; |
400 | - [].forEach.call(document.querySelectorAll("[data-role='pagestack'] [data-role='page']"), function(el) { |
401 | - el.style.display = visibility; |
402 | - |
403 | - // treat footers separately |
404 | - var footer = el.querySelector('footer'); |
405 | - if (footer) |
406 | - footer.style.display = visibility; |
407 | - }); |
408 | - }, |
409 | - __isPage: function (element) { |
410 | - return element.getAttribute('data-role') === 'page'; |
411 | - }, |
412 | - __deactivate: function (id) { |
413 | - if (!id || typeof(id) !== 'string') |
414 | - return; |
415 | - var page = document.getElementById(id); |
416 | - if ( ! this.__isPage(page)) { |
417 | - return; |
418 | - } |
419 | - page.style.display = "none"; |
420 | - if (page.querySelector('footer')) { |
421 | - var footer = page.querySelector('footer'); |
422 | - footer.style.display = 'none'; |
423 | - footer.classList.remove('revealed'); |
424 | - } |
425 | - }, |
426 | - __activate: function (id) { |
427 | - if (!id || typeof(id) !== 'string') |
428 | - return; |
429 | - var page = document.getElementById(id); |
430 | - if ( ! this.__isPage(page)) { |
431 | - return; |
432 | - } |
433 | - page.style.display = "block"; |
434 | - if (page.querySelector('footer')) { |
435 | - var footer = page.querySelector('footer'); |
436 | - footer.style.display = 'block'; |
437 | - footer.classList.add('revealed'); |
438 | - } |
439 | - }, |
440 | - push: function (id, properties) { |
441 | - try { |
442 | - __safeCall(this.__setAllPagesVisibility.bind(this), [false]); |
443 | - |
444 | - this.__activate(id); |
445 | - this._pages.push(id); |
446 | - } |
447 | - catch(e) {} |
448 | - }, |
449 | - isEmpty: function () { |
450 | - return this._pages.length === 0; |
451 | - }, |
452 | - currentPage: function () { |
453 | - return this.isEmpty() ? null : this._pages[this._pages.length-1]; |
454 | - }, |
455 | - depth: function() { |
456 | - return this._pages.length; |
457 | - }, |
458 | - clear: function() { |
459 | - if (this.isEmpty()) |
460 | - return; |
461 | - __safeCall(this.__deactivate.bind(this), [this.currentPage()]); |
462 | - this._pages = []; |
463 | - }, |
464 | - pop: function() { |
465 | - if(this.isEmpty()) |
466 | - return; |
467 | - __safeCall(this.__deactivate.bind(this), [this.currentPage()]); |
468 | - this._pages.pop(); |
469 | - __safeCall(this.__activate.bind(this), [this.currentPage()]); |
470 | - } |
471 | + __setAllPagesVisibility: function (visible) { |
472 | + var visibility = visible ? "block" : "none"; |
473 | + [].forEach.call(document.querySelectorAll("[data-role='pagestack'] [data-role='page']"), function (el) { |
474 | + el.style.display = visibility; |
475 | + |
476 | + // treat footers separately |
477 | + var footer = el.querySelector('footer'); |
478 | + if (footer) |
479 | + footer.style.display = visibility; |
480 | + }); |
481 | + }, |
482 | + __isPage: function (element) { |
483 | + return element.getAttribute('data-role') === 'page'; |
484 | + }, |
485 | + __deactivate: function (id) { |
486 | + if (!id || typeof (id) !== 'string') |
487 | + return; |
488 | + var page = document.getElementById(id); |
489 | + if (!this.__isPage(page)) { |
490 | + return; |
491 | + } |
492 | + page.style.display = "none"; |
493 | + if (page.querySelector('footer')) { |
494 | + var footer = page.querySelector('footer'); |
495 | + footer.style.display = 'none'; |
496 | + footer.classList.remove('revealed'); |
497 | + } |
498 | + }, |
499 | + __activate: function (id) { |
500 | + if (!id || typeof (id) !== 'string') |
501 | + return; |
502 | + var page = document.getElementById(id); |
503 | + if (!this.__isPage(page)) { |
504 | + return; |
505 | + } |
506 | + page.style.display = "block"; |
507 | + if (page.querySelector('footer')) { |
508 | + var footer = page.querySelector('footer'); |
509 | + footer.style.display = 'block'; |
510 | + footer.classList.add('revealed'); |
511 | + } |
512 | + }, |
513 | + push: function (id, properties) { |
514 | + try { |
515 | + __safeCall(this.__setAllPagesVisibility.bind(this), [false]); |
516 | + |
517 | + this.__activate(id); |
518 | + this._pages.push(id); |
519 | + } catch (e) {} |
520 | + }, |
521 | + isEmpty: function () { |
522 | + return this._pages.length === 0; |
523 | + }, |
524 | + currentPage: function () { |
525 | + return this.isEmpty() ? null : this._pages[this._pages.length - 1]; |
526 | + }, |
527 | + depth: function () { |
528 | + return this._pages.length; |
529 | + }, |
530 | + clear: function () { |
531 | + if (this.isEmpty()) |
532 | + return; |
533 | + __safeCall(this.__deactivate.bind(this), [this.currentPage()]); |
534 | + this._pages = []; |
535 | + }, |
536 | + pop: function () { |
537 | + if (this.isEmpty()) |
538 | + return; |
539 | + __safeCall(this.__deactivate.bind(this), [this.currentPage()]); |
540 | + this._pages.pop(); |
541 | + __safeCall(this.__activate.bind(this), [this.currentPage()]); |
542 | + } |
543 | } |
544 | |
545 | return Pagestack; |
546 | -})(); |
547 | - |
548 | +})(); |
549 | \ No newline at end of file |
Hi Adnane: I think list.js still uses tabs.