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

Proposed by Adnane Belmadiaf
Status: Work in progress
Proposed branch: lp:~daker/ubuntu-html5-theme/fix.1269074
Merge into: lp:ubuntu-html5-theme
Diff against target: 193 lines (+75/-26)
3 files modified
0.1/ambiance/js/core.js (+3/-3)
0.1/ambiance/js/option-selector.js (+16/-6)
examples/html5-theme/widgets/OptionSelector.html (+56/-17)
To merge this branch: bzr merge lp:~daker/ubuntu-html5-theme/fix.1269074
Reviewer Review Type Date Requested Status
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+207317@code.launchpad.net

Commit message

Added support for scrollable list

To post a comment you must log in.
Revision history for this message
Adnane Belmadiaf (daker) wrote :

Still WIP, need to fix some issues.

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

is it still WIP?

Unmerged revisions

144. By Adnane Belmadiaf

Initial support for native scrollable list

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '0.1/ambiance/js/core.js'
2--- 0.1/ambiance/js/core.js 2014-02-18 17:22:15 +0000
3+++ 0.1/ambiance/js/core.js 2014-02-19 22:02:14 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
7+ * Copyright (C) 2013, 2014 Adnane Belmadiaf <daker@ubuntu.com>
8 * License granted by Canonical Limited
9 *
10 * This file is part of ubuntu-html5-ui-toolkit.
11@@ -376,9 +376,9 @@
12 * @param {Boolean} multiSelection - If multiple choice selection is enabled the list is always expanded.
13 * @return {OptionSelector}
14 */
15- optionselector: function (id, expanded, multiSelection) {
16+ optionselector: function (id, expanded, multiSelection, containerHeight) {
17 if (typeof OptionSelector != 'undefined' && OptionSelector) {
18- return new OptionSelector(id, expanded, multiSelection);
19+ return new OptionSelector(id, expanded, multiSelection, containerHeight);
20 }
21 },
22
23
24=== modified file '0.1/ambiance/js/option-selector.js'
25--- 0.1/ambiance/js/option-selector.js 2014-01-27 18:42:31 +0000
26+++ 0.1/ambiance/js/option-selector.js 2014-02-19 22:02:14 +0000
27@@ -1,5 +1,5 @@
28 /*
29- * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
30+ * Copyright (C) 2013, 2014 Adnane Belmadiaf <daker@ubuntu.com>
31 * License granted by Canonical Limited
32 *
33 * This file is part of ubuntu-html5-ui-toolkit.
34@@ -49,11 +49,12 @@
35
36 var __values = "";
37
38- function OptionSelector (id, expanded, multiSelection) {
39+ function OptionSelector (id, expanded, multiSelection, containerHeight) {
40 this.currentIndex = 0;
41 this.currentlyExpanded = false;
42 this.expanded = typeof expanded !== 'undefined' ? expanded : false;
43 this.multiSelection = typeof multiSelection !== 'undefined' ? multiSelection : false;
44+ this.containerHeight_tmp = undefined;
45
46 if (this.multiSelection)
47 this.expanded = true;
48@@ -72,13 +73,18 @@
49 if (this.optionselector_ul.length == 0)
50 return;
51
52-
53 this.optionselector_ul_li = this.optionselector.querySelectorAll('li');
54 if (this.optionselector_ul == null)
55 return;
56 if (this.optionselector_ul_li.length == 0)
57 return;
58
59+ this.containerHeight = typeof containerHeight !== 'undefined' ? containerHeight : this.optionselector_ul_li.length;
60+
61+ if (typeof containerHeight != 'undefined') {
62+ this.containerHeight_tmp = containerHeight;
63+ }
64+
65 [].forEach.call(this.optionselector_ul_li, function (elm) {
66 elm.addEventListener('click', this.__onClicked.bind(this, elm), false);
67 }.bind(this));
68@@ -179,22 +185,26 @@
69 */
70 __open: function () {
71 this.optionselector_ul.style['-webkit-transition-duration'] = '.4s';
72- this.optionselector_ul.style.webkitTransform = 'translate3d(0, 0rem,0)';
73- this.optionselector.style.height = 3.07*this.optionselector_ul_li.length + 'rem';
74+ this.optionselector_ul.style.webkitTransform = 'translate3d(0, 0, 0)';
75+ this.optionselector.style.height = 3.05*this.containerHeight + 'rem';
76 this.currentlyExpanded = true;
77+ if (typeof this.containerHeight_tmp != 'undefined') {
78+ this.optionselector.style['overflow-y'] = 'auto';
79+ }
80 },
81
82 /**
83 * @private
84 */
85 __close: function (currentIndex) {
86+ this.optionselector.style['overflow-y'] = 'hidden';
87 this.optionselector_ul.style['-webkit-transition-duration'] = '.4s';
88- this.optionselector_ul.style.webkitTransform = 'translate3d(0,' + -3*currentIndex + 'rem,0)';
89 this.optionselector.style.height = '3rem';
90 [].forEach.call(this.optionselector_ul_li, function (elm) {
91 elm.classList.remove('active');
92 });
93 this.currentlyExpanded = false;
94+ this.optionselector_ul.style.webkitTransform = 'translate3d(0,' + -3*currentIndex + 'rem, 0)';
95 },
96
97 onClicked : function(callback){
98
99=== modified file 'examples/html5-theme/widgets/OptionSelector.html'
100--- examples/html5-theme/widgets/OptionSelector.html 2014-02-12 19:46:04 +0000
101+++ examples/html5-theme/widgets/OptionSelector.html 2014-02-19 22:02:14 +0000
102@@ -1,5 +1,5 @@
103 <!--
104- Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
105+ Copyright (C) 2013, 2014 Adnane Belmadiaf <daker@ubuntu.com>
106 License granted by Canonical Limited
107
108 This file is part of ubuntu-html5-ui-toolkit.
109@@ -54,6 +54,12 @@
110 os3.onClicked(function (e) {
111 console.log("optionselector3 values: " + e.values);
112 })
113+
114+ os4 = UI.optionselector('os4', expanded=false, multiSelection=false, containerHeight=4);
115+
116+ os4.onClicked(function (e) {
117+ console.log("optionselector4 values: " + e.values);
118+ })
119 };
120 </script>
121 </head>
122@@ -122,22 +128,55 @@
123 </div>
124 <div class="inset" style="margin: 15px;">
125 <h1>Expanded with a unique selection</h1>
126- <section data-role="option-selector" id="os3">
127- <ul>
128- <li data-value="0">
129- <p>Label 1</p>
130- </li>
131- <li data-value="1">
132- <p>Label 2</p>
133- </li>
134- <li data-value="3">
135- <p>Label 3</p>
136- </li>
137- <li data-value="4">
138- <p>Label 4</p>
139- </li>
140- <li data-value="5">
141- <p>Label 5</p>
142+ <section data-role="option-selector" id="os3" >
143+ <ul>
144+ <li data-value="0">
145+ <p>Label 1</p>
146+ </li>
147+ <li data-value="1">
148+ <p>Label 2</p>
149+ </li>
150+ <li data-value="3">
151+ <p>Label 3</p>
152+ </li>
153+ <li data-value="4">
154+ <p>Label 4</p>
155+ </li>
156+ <li data-value="5">
157+ <p>Label 5</p>
158+ </li>
159+ </ul>
160+ </section>
161+ </div>
162+
163+
164+ <div class="inset" style="margin: 15px;">
165+ <h1>Expanded with a unique selection, scrollable</h1>
166+ <section data-role="option-selector" id="os4" >
167+ <ul>
168+ <li data-value="0">
169+ <p>Label 1</p>
170+ </li>
171+ <li data-value="1">
172+ <p>Label 2</p>
173+ </li>
174+ <li data-value="2">
175+ <p>Label 3</p>
176+ </li>
177+ <li data-value="3">
178+ <p>Label 4</p>
179+ </li>
180+ <li data-value="4">
181+ <p>Label 5</p>
182+ </li>
183+ <li data-value="5">
184+ <p>Label 6</p>
185+ </li>
186+ <li data-value="7">
187+ <p>Label 7</p>
188+ </li>
189+ <li data-value="8">
190+ <p>Label 8</p>
191 </li>
192 </ul>
193 </section>

Subscribers

People subscribed via source and target branches