Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/customizableUI.js

Issue 5741004535627776: Fix toolbar icon customization in Australis (Closed)
Left Patch Set: Improved approach (custom button type), marked our custom API extensions Created Nov. 25, 2013, 9:34 a.m.
Right Patch Set: Added 32x32 icon and fixed my own review comments Created Dec. 2, 2013, 10:55 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/appSupport.js ('k') | lib/ui.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return null; 238 return null;
239 239
240 let widget = window.document.getElementById(id); 240 let widget = window.document.getElementById(id);
241 if (!widget) 241 if (!widget)
242 return null; 242 return null;
243 243
244 let toolbar = getToolbar(widget); 244 let toolbar = getToolbar(widget);
245 if (!toolbar) 245 if (!toolbar)
246 return null; 246 return null;
247 247
248 let items = toolbar.currentSet.split(","); 248 return {area: toolbar.id};
249 let index = items.indexOf(id); 249 },
250 if (index < 0) 250
251 return null; 251 addWidgetToArea: function(id)
252 else 252 {
253 return {area: toolbar.id, placement: index}; 253 // Note: the official API function also has area and position parameters.
Wladimir Palant 2013/11/27 16:04:01 Given that we don't use the placement parameter in
254 }, 254 // We ignore those here and simply restore the previous position instead.
255
256 addWidgetToArea: function(id, area, position)
257 {
258 let widget = widgets.get(id); 255 let widget = widgets.get(id);
259 for (let window of UI.applicationWindows) 256 for (let window of UI.applicationWindows)
260 { 257 {
261 let toolbox = getToolbox(window, widget); 258 let toolbox = getToolbox(window, widget);
262 if (!toolbox) 259 if (!toolbox)
263 continue; 260 continue;
264 261
265 let position = toolbox.getAttribute(widget.positionAttribute); 262 let position = toolbox.getAttribute(widget.positionAttribute);
Wladimir Palant 2013/11/27 16:04:01 This masks a parameter. We should probably simply
266 if (position) 263 if (position)
267 position = position.replace(/^hidden,/, "visible,"); 264 position = position.replace(/^hidden,/, "visible,");
268 showWidget(toolbox, widget, position); 265 showWidget(toolbox, widget, position);
269 } 266 }
270 }, 267 },
271 268
272 removeWidgetFromArea: function(id) 269 removeWidgetFromArea: function(id)
273 { 270 {
274 let widget = widgets.get(id); 271 let widget = widgets.get(id);
275 for (let window of UI.applicationWindows) 272 for (let window of UI.applicationWindows)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 for (let [id, widget] of widgets) 315 for (let [id, widget] of widgets)
319 { 316 {
320 let toolbox = getToolbox(window, widget); 317 let toolbox = getToolbox(window, widget);
321 if (toolbox) 318 if (toolbox)
322 toolbox.removeEventListener("aftercustomization", onToolbarCustomization , false); 319 toolbox.removeEventListener("aftercustomization", onToolbarCustomization , false);
323 320
324 removeWidget(window, widget); 321 removeWidget(window, widget);
325 } 322 }
326 } 323 }
327 }); 324 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld