Merge lp:~abreu-alexandre/ubuntu-html5-theme/add-element-function into lp:ubuntu-html5-theme

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 96
Merged at revision: 94
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/add-element-function
Merge into: lp:ubuntu-html5-theme
Diff against target: 284 lines (+97/-17)
13 files modified
0.1/ambiance/css/buttons.css (+6/-0)
0.1/ambiance/css/default.css (+2/-0)
0.1/ambiance/css/tabs.css (+1/-0)
0.1/ambiance/js/buttons.js (+12/-3)
0.1/ambiance/js/core.js (+5/-6)
0.1/ambiance/js/dialogs.js (+10/-0)
0.1/ambiance/js/header.js (+7/-1)
0.1/ambiance/js/list.js (+12/-2)
0.1/ambiance/js/page.js (+9/-3)
0.1/ambiance/js/popovers.js (+9/-0)
0.1/ambiance/js/shape.js (+9/-0)
0.1/ambiance/js/toolbars.js (+9/-0)
0.1/examples/widgets/Buttons.html (+6/-2)
To merge this branch: bzr merge lp:~abreu-alexandre/ubuntu-html5-theme/add-element-function
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+197878@code.launchpad.net

Commit message

Add convenient element() function to most widgets ... (we might want to factor those out in a second step)

Description of the change

Add convenient element() function to most widgets ... (we might want to factor those out in a second step)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
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/css/buttons.css'
2--- 0.1/ambiance/css/buttons.css 2013-07-17 15:27:43 +0000
3+++ 0.1/ambiance/css/buttons.css 2013-12-05 14:18:28 +0000
4@@ -67,6 +67,12 @@
5 left: 0;
6 }
7
8+[data-role="button"].ubuntu {
9+ background: #dd4814;
10+ color: #ffffff;
11+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
12+}
13+
14 [data-role="button"].danger {
15 background: red;
16 color: #ffffff;
17
18=== modified file '0.1/ambiance/css/default.css'
19--- 0.1/ambiance/css/default.css 2013-07-19 13:18:03 +0000
20+++ 0.1/ambiance/css/default.css 2013-12-05 14:18:28 +0000
21@@ -53,6 +53,8 @@
22 width: 100%;
23 font-size: 1rem "Ubuntu";
24 color: #787878;
25+ margin-left: 1em;
26+ margin-right: 1em;
27 }
28
29 [data-role="content"] p {
30
31=== modified file '0.1/ambiance/css/tabs.css'
32--- 0.1/ambiance/css/tabs.css 2013-07-19 13:18:03 +0000
33+++ 0.1/ambiance/css/tabs.css 2013-12-05 14:18:28 +0000
34@@ -35,6 +35,7 @@
35 display: box;
36 -webkit-box-orient: horizontal;
37 box-orient: horizontal;
38+ margin-bottom: 1em;
39 }
40
41 [data-role="header"] div.tabs-inner {
42
43=== modified file '0.1/ambiance/js/buttons.js'
44--- 0.1/ambiance/js/buttons.js 2013-11-01 15:19:11 +0000
45+++ 0.1/ambiance/js/buttons.js 2013-12-05 14:18:28 +0000
46@@ -49,9 +49,18 @@
47 });
48 */
49 click: function (callback) {
50- if ( ! document.getElementById(this.id)) {
51- throw "Invalid button ID: " + String(this.id);
52- }
53+ if ( ! document.getElementById(this.id)) {
54+ throw "Invalid button ID: " + String(this.id);
55+ }
56 new FastButton(document.getElementById(this.id), callback);
57+ },
58+ /**
59+ * Returns the DOM element associated with the id this widget is bind to.
60+ * @method element
61+ * @example
62+ var mybutton = UI.button("buttonid").element();
63+ */
64+ element: function() {
65+ return document.getElementById(this.id);
66 }
67 };
68
69=== modified file '0.1/ambiance/js/core.js'
70--- 0.1/ambiance/js/core.js 2013-10-31 21:09:16 +0000
71+++ 0.1/ambiance/js/core.js 2013-12-05 14:18:28 +0000
72@@ -291,13 +291,12 @@
73 },
74
75 /**
76- * Gets the HTML element associated with an Ubuntu HTML5 JavaScript object
77- * @method getEl
78- * @param {UbuntuObject} object - An UbuntuUI widget object
79- * @return {Element} - The HTML element
80+ * Gets the DOM element from a given selector
81+ * @method element
82+ * @return {Element} - The DOM element
83 */
84- getEl: function(widget) {
85- return document.getElementById(widget.id);
86+ element: function(selector) {
87+ return document.querySelector(selector);
88 },
89
90 };
91
92=== modified file '0.1/ambiance/js/dialogs.js'
93--- 0.1/ambiance/js/dialogs.js 2013-10-31 21:09:16 +0000
94+++ 0.1/ambiance/js/dialogs.js 2013-12-05 14:18:28 +0000
95@@ -44,6 +44,7 @@
96
97 */
98 var Dialog = function (id) {
99+ this.id = id;
100 this.dialog = document.getElementById(id);
101 };
102
103@@ -68,5 +69,14 @@
104 */
105 toggle: function () {
106 this.dialog.classList.toggle('active');
107+ },
108+ /**
109+ * Returns the DOM element associated with the id this widget is bind to.
110+ * @method element
111+ * @example
112+ var mydialog = UI.dialog("dialogid").element();
113+ */
114+ element: function () {
115+ return document.getElementById(this.id);
116 }
117 };
118
119=== modified file '0.1/ambiance/js/header.js'
120--- 0.1/ambiance/js/header.js 2013-10-31 21:09:16 +0000
121+++ 0.1/ambiance/js/header.js 2013-12-05 14:18:28 +0000
122@@ -60,6 +60,12 @@
123
124 Header.prototype = {
125 /**
126- * Placeholder for future methods
127+ * Returns the DOM element associated with the id this widget is bind to.
128+ * @method element
129+ * @example
130+ var myheader = UI.header("headerid").element();
131 */
132+ element: function () {
133+ return document.getElementById(this.id);
134+ }
135 };
136
137=== modified file '0.1/ambiance/js/list.js'
138--- 0.1/ambiance/js/list.js 2013-11-01 15:19:11 +0000
139+++ 0.1/ambiance/js/list.js 2013-12-05 14:18:28 +0000
140@@ -67,6 +67,7 @@
141 if (list == null || list.nodeName.toLowerCase() !== 'section' || list.getAttribute('data-role') != LIST_DATA_ROLE) {
142 throw new Error('Element with selector "' + selector + '" does not exist or not declared as a "list" <section>');
143 }
144+ this._selector = selector;
145 this._list = list;
146
147 __addUlIfNotFound(this._list);
148@@ -98,7 +99,7 @@
149 header.innerText = text;
150 }
151 },
152- /**
153+ /**
154 * Append an item to a list
155 * @method append
156 * @param {String} text - The main text, flushed left (no markup)
157@@ -181,7 +182,16 @@
158 func(element, index);
159 });
160 },
161+ /**
162+ * Returns the DOM element associated with the selector this widget is bind to.
163+ * @method element
164+ * @example
165+ var mylist = UI.list("#listid").element();
166+ */
167+ element: function () {
168+ return this._list;
169+ }
170 };
171
172 return List;
173-})();
174\ No newline at end of file
175+})();
176
177=== modified file '0.1/ambiance/js/page.js'
178--- 0.1/ambiance/js/page.js 2013-10-31 21:09:16 +0000
179+++ 0.1/ambiance/js/page.js 2013-12-05 14:18:28 +0000
180@@ -56,7 +56,13 @@
181 };
182
183 Page.prototype = {
184- /*
185- * placeholder for future methods
186- */
187+ /**
188+ * Returns the DOM element associated with the selector this widget is bind to.
189+ * @method element
190+ * @example
191+ var mypage = UI.page("pageid").element();
192+ */
193+ element: function () {
194+ return document.getElementById(this.id);
195+ }
196 };
197
198=== modified file '0.1/ambiance/js/popovers.js'
199--- 0.1/ambiance/js/popovers.js 2013-11-01 15:40:10 +0000
200+++ 0.1/ambiance/js/popovers.js 2013-12-05 14:18:28 +0000
201@@ -226,5 +226,14 @@
202 this.popover.style.left = pos_left+ 'px';
203
204 return this.popover;
205+ },
206+ /**
207+ * Returns the DOM element associated with the id this widget is bind to.
208+ * @method element
209+ * @example
210+ var mypopover = UI.popover("popoverid").element();
211+ */
212+ element: function () {
213+ return this.popover;
214 }
215 };
216
217=== modified file '0.1/ambiance/js/shape.js'
218--- 0.1/ambiance/js/shape.js 2013-10-31 21:09:16 +0000
219+++ 0.1/ambiance/js/shape.js 2013-12-05 14:18:28 +0000
220@@ -56,4 +56,13 @@
221 el.addEventListener('click', callback);
222 }
223 },
224+ /**
225+ * Returns the DOM element associated with the id this widget is bind to.
226+ * @method element
227+ * @example
228+ var myshape = UI.shape("shapeid").element();
229+ */
230+ element: function () {
231+ return document.getElementById(this.id);
232+ }
233 };
234
235=== modified file '0.1/ambiance/js/toolbars.js'
236--- 0.1/ambiance/js/toolbars.js 2013-10-31 21:09:16 +0000
237+++ 0.1/ambiance/js/toolbars.js 2013-12-05 14:18:28 +0000
238@@ -83,5 +83,14 @@
239 */
240 touch: function (callback) {
241 this.toolbar.addEventListener(UbuntuUI.touchEvents.touchEnd, callback);
242+ },
243+ /**
244+ * Returns the DOM element associated with the id this widget is bind to.
245+ * @method element
246+ * @example
247+ var mytoolbar = UI.toolbar("toolbarid").element();
248+ */
249+ element: function () {
250+ return this.toolbar;
251 }
252 };
253
254=== modified file '0.1/examples/widgets/Buttons.html'
255--- 0.1/examples/widgets/Buttons.html 2013-07-17 15:27:43 +0000
256+++ 0.1/examples/widgets/Buttons.html 2013-12-05 14:18:28 +0000
257@@ -60,10 +60,12 @@
258 <div class="inset">
259 <button data-role="button" class="danger">Delete</button>
260 </div>
261-
262 <div class="inset">
263 <button data-role="button" class="warning">Warning</button>
264 </div>
265+ <div class="inset">
266+ <button data-role="button" class="ubuntu">Ubuntu</button>
267+ </div>
268
269 <h1>Links</h1>
270 <div class="inset">
271@@ -75,10 +77,12 @@
272 <div class="inset">
273 <a href="#" data-role="button">Delete</a>
274 </div>
275-
276 <div class="inset">
277 <a href="#" data-role="button">Warning</a>
278 </div>
279+ <div class="inset">
280+ <a href="#" data-role="button">Ubuntu</a>
281+ </div>
282 </div>
283 </div>
284 </body>

Subscribers

People subscribed via source and target branches