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

Delta Between Two Patch Sets: lib/utils.js

Issue 11015083: Merge labels and access keys into one string in locales (Closed)
Left Patch Set: Created July 3, 2013, 9:11 a.m.
Right Patch Set: Created July 9, 2013, 12:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« lib/ui.js ('K') | « lib/ui.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 else 481 else
482 return [label, ""]; 482 return [label, ""];
483 } 483 }
484 }, 484 },
485 485
486 /** 486 /**
487 * Split all labels starting from a particular DOM node. 487 * Split all labels starting from a particular DOM node.
488 */ 488 */
489 splitAllLabels: function(/**DOMNode*/ root) 489 splitAllLabels: function(/**DOMNode*/ root)
490 { 490 {
491 let elements = root.querySelectorAll("*[label], label[value]"); 491 let attrMap = {
492 __proto__: null,
493 "label": "value",
494 "setting": "title"
495 };
496
497 let elements = root.querySelectorAll("*[label], label[value], setting[title] ");
492 for (let i = 0; i < elements.length; i++) 498 for (let i = 0; i < elements.length; i++)
493 { 499 {
494 let element = elements[i]; 500 let element = elements[i];
495 let attr = (element.localName == "label" ? "value" : "label"); 501 let attr = (element.localName in attrMap ? attrMap[element.localName] : "l abel");
496 let [label, accesskey] = this.splitLabel(element.getAttribute(attr)); 502 let origLabel = element.getAttribute(attr);
497 element.setAttribute(attr, label); 503
498 element.setAttribute("accesskey", accesskey); 504 let [label, accesskey] = this.splitLabel(origLabel);
505 if (label != origLabel)
506 element.setAttribute(attr, label);
507 if (accesskey != "")
Wladimir Palant 2013/07/09 12:10:59 The added checks here aren't strictly necessary bu
508 element.setAttribute("accesskey", accesskey);
499 509
500 // Labels forward changes of the accessKey property to their control, only 510 // Labels forward changes of the accessKey property to their control, only
501 // set it for actual controls. 511 // set it for actual controls.
502 if (element.localName != "label") 512 if (element.localName != "label")
503 element.accessKey = accesskey; 513 element.accessKey = accesskey;
504 } 514 }
505 } 515 }
506 }; 516 };
507 517
508 /** 518 /**
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 Cu.reportError(e); 763 Cu.reportError(e);
754 // Expected, ctypes isn't supported in Gecko 1.9.2 764 // Expected, ctypes isn't supported in Gecko 1.9.2
755 return null; 765 return null;
756 } 766 }
757 }); 767 });
758 768
759 if ("@mozilla.org/messenger/headerparser;1" in Cc) 769 if ("@mozilla.org/messenger/headerparser;1" in Cc)
760 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser"); 770 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser");
761 else 771 else
762 Utils.headerParser = null; 772 Utils.headerParser = null;
LEFTRIGHT
« lib/ui.js ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld