Simplify a bit using new definition
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 21 Jul 2011 15:32:46 -0600
changeset 440 2452d1c6d2f2
parent 439 d521738e127f
child 441 33cf86cf2e6b
Simplify a bit using new definition
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Thu Jul 21 15:28:41 2011 -0600
+++ b/editcommands.html	Thu Jul 21 15:32:46 2011 -0600
@@ -2346,24 +2346,9 @@
   contained</a> in the <a href=#active-range>active range</a>:
 
   <ol>
-    <li>If <var title="">command</var> is in the following list, set the <a href=#state-override>state
-    override</a> appropriately:
-
-    <ul>
-      <li>bold: True if <var title="">new value</var> is not null and is greater than or equal
-      to 600, false otherwise.
-
-      <li>italic: True if <var title="">new value</var> is "italic" or "oblique", false
-      otherwise.
-
-      <li>strikethrough: True if <var title="">new value</var> is "line-through", false otherwise.
-
-      <li>subscript: True if <var title="">new value</var> is "sub", false otherwise.
-
-      <li>superscript: True if <var title="">new value</var> is "super", false otherwise.
-
-      <li>underline: True if <var title="">new value</var> is "underline", false otherwise.
-    </ul>
+    <li>If <var title="">command</var> has <a href=#inline-command-activated-values>inline command activated values</a>,
+    set the <a href=#state-override>state override</a> to true if <var title="">new value</var> is
+    among them and false if it's not.
 
     <li>If <var title="">command</var> is "subscript", unset the <a href=#state-override>state
     override</a> for "superscript".
--- a/implementation.js	Thu Jul 21 15:28:41 2011 -0600
+++ b/implementation.js	Thu Jul 21 15:32:46 2011 -0600
@@ -2886,29 +2886,11 @@
 	if (!getAllEffectivelyContainedNodes(getActiveRange())
 	.filter(function(node) { return node.nodeType == Node.TEXT_NODE})
 	.some(isEditable)) {
-		// "If command is in the following list, set the state override
-		// appropriately:"
-		switch (command) {
-			// "bold: True if new value is not null and is greater than or
-			// equal to 600, false otherwise."
-			case "bold": setStateOverride(command, newValue === "bold"); break;
-
-			// "italic: True if new value is "italic" or "oblique", false
-			// otherwise."
-			case "italic": setStateOverride(command, newValue === "italic"); break;
-
-			// "strikethrough: True if new value is "line-through", false
-			// otherwise."
-			case "strikethrough": setStateOverride(command, newValue === "line-through"); break;
-
-			// "subscript: True if new value is "sub", false otherwise."
-			case "subscript": setStateOverride(command, newValue === "sub"); break;
-
-			// "superscript: True if new value is "super", false otherwise."
-			case "superscript": setStateOverride(command, newValue === "super"); break;
-
-			// "underline: True if new value is "underline", false otherwise."
-			case "underline": setStateOverride(command, newValue === "underline");
+		// "If command has inline command activated values, set the state
+		// override to true if new value is among them and false if it's not."
+		if ("inlineCommandActivatedValues" in commands[command]) {
+			setStateOverride(command, commands[command].inlineCommandActivatedValues
+				.indexOf(newValue) != -1);
 		}
 
 		// "If command is "subscript", unset the state override for
--- a/source.html	Thu Jul 21 15:28:41 2011 -0600
+++ b/source.html	Thu Jul 21 15:32:46 2011 -0600
@@ -2331,24 +2331,9 @@
   contained</span> in the <span>active range</span>:
 
   <ol>
-    <li>If <var>command</var> is in the following list, set the <span>state
-    override</span> appropriately:
-
-    <ul>
-      <li>bold: True if <var>new value</var> is not null and is greater than or equal
-      to 600, false otherwise.
-
-      <li>italic: True if <var>new value</var> is "italic" or "oblique", false
-      otherwise.
-
-      <li>strikethrough: True if <var>new value</var> is "line-through", false otherwise.
-
-      <li>subscript: True if <var>new value</var> is "sub", false otherwise.
-
-      <li>superscript: True if <var>new value</var> is "super", false otherwise.
-
-      <li>underline: True if <var>new value</var> is "underline", false otherwise.
-    </ul>
+    <li>If <var>command</var> has <span>inline command activated values</span>,
+    set the <span>state override</span> to true if <var>new value</var> is
+    among them and false if it's not.
 
     <li>If <var>command</var> is "subscript", unset the <span>state
     override</span> for "superscript".