Luke Plant avatar Luke Plant committed e798092

Gave command buttons border to indicate being used by current section

Comments (0)

Files changed (1)

semanticeditor/media/semanticeditor/javascript/wymeditor/plugins/semantic/wymeditor.semantic.js

     return false;
 };
 
+PresentationControls.prototype.has_command = function(sect_id, command) {
+    // Returns true if the section has the command before it.
+    // For section 'p_1' command 'newrow', we just need to check
+    // for the existence of 'newrow_p_1'.
+    return (this.presentation_info[command.name + "_" + sect_id] != undefined);
+}
+
 PresentationControls.prototype.next_id = function(tagName) {
     // All sections that can receive styles need a section ID.
     // For the initial HTML, this is assigned server-side when the
 };
 
 PresentationControls.prototype.update_command_blocks = function(node, id, max) {
+    // Updates the 'id' of any HTML block that represents a command.
     if (max == 0) {
         return;
     };
         elem = elem.prev();
     }
     elem.before(newelem);
-    var new_id = command.name + "_" + sect_id; // duplication with do_command
+    var new_id = command.name + "_" + sect_id; // duplication with update_command_blocks
     newelem.attr('id', new_id);
     return new_id;
 };
 };
 
 PresentationControls.prototype.update_classlist_item = function(btn, style) {
-    var self = this;
     var sect_id = this.get_current_section(style);
     if (sect_id == undefined) {
         // Can't use it.
-        if (style.prestype == "command")
+        if (style.prestype == "command") {
             // Don't want the class list (displayed below command list)
             // to jump up and down
             btn.addClass("disabled");
-        else
+            btn.removeClass("used");
+        } else {
             btn.hide();
+        }
     } else {
-        if (style.prestype == "command")
+        if (style.prestype == "command") {
             btn.removeClass("disabled");
-        else
+            if (this.has_command(sect_id, style)) {
+                btn.addClass("used");
+            } else {
+                btn.removeClass("used");
+            }
+        } else {
             btn.show();
-        if (self.has_style(sect_id, style)) {
-            btn.addClass("used");
-        } else {
-            btn.removeClass("used");
+            if (this.has_style(sect_id, style)) {
+                btn.addClass("used");
+            } else {
+                btn.removeClass("used");
+            }
         }
     }
 };
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.