Luke Plant avatar Luke Plant committed e9fe70d

Converted javascript to use normal camelCase conventions in method/variable names

Comments (0)

Files changed (2)

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

     this.wym = wym;
     this.opts = opts;
     this.name = wym._element.get(0).name;
-    // available_styles: an array of dictionaries corresponding to PresentationInfo objects
-    this.available_styles = new Array();
-    // presentation_info: a dictionary of { sect_id : [PresentationInfo] }
-    this.presentation_info = {};
+    // availableStyles: an array of dictionaries corresponding to PresentationInfo objects
+    this.availableStyles = new Array();
+    // presentationInfo: a dictionary of { sectId : [PresentationInfo] }
+    this.presentationInfo = {};
 
     // commands: an array of dictionaries corresponding to PresentationInfo objects for commands.
     this.commands = new Array();
-    // command_dict: a dictionary mapping command name to PresentationInfo object.
-    this.command_dict = {};
+    // commandDict: a dictionary mapping command name to PresentationInfo object.
+    this.commandDict = {};
 
     // a selector which matches any command block.  Filled in later.
-    this.all_command_selectors = "";
+    this.allCommandSelectors = "";
 
     // the node of the current block level element being edited.
-    this.current_node = null;
+    this.currentNode = null;
 
     // Need to sync with presentation.py
-    this.blockdef_selector = "h1,h2,h3,h4,h5,h6,p,ol,ul,blockquote,li,pre";
+    this.blockdefSelector = "h1,h2,h3,h4,h5,h6,p,ol,ul,blockquote,li,pre";
 
-    this.setup_controls(jQuery(wym._bvox).find(".wym_area_bottom"));
+    this.setupControls(jQuery(wym._bvox).find(".wym_area_bottom"));
 }
 
 function escapeHtml(html) {
 }
 
 
-PresentationControls.prototype.setup_css_storage = function() {
+PresentationControls.prototype.setupCssStorage = function() {
     // We need a place to store custom CSS rules. (Existing jQuery plugins don't
     // allow for our need of changing style sheet of document in an iframe, and
     // rolling our own is easier than fixing them).
     this.stylesheet = this.wym._doc.styleSheets[0];
 };
 
-PresentationControls.prototype.add_css_rule = function(selector, rule) {
+PresentationControls.prototype.addCssRule = function(selector, rule) {
     var ss = this.stylesheet;
     var rules = ss.rules ? 'rules' : 'cssRules';
     // should work with IE and Firefox, don't know about Safari
         ss.insertRule(selector + '{'+ rule +'}', ss[rules].length);
 };
 
-PresentationControls.prototype.setup_controls = function(container) {
-    var id_prefix = "id_prescontrol_" + this.name + "_";
-    var previewbutton_id = id_prefix + 'previewbutton';
-    var previewbox_id = id_prefix + 'previewbox';
-    var cleanhtmlbutton_id = id_prefix + 'cleanhtmlbutton';
+PresentationControls.prototype.setupControls = function(container) {
+    var idPrefix = "id_prescontrol_" + this.name + "_";
+    var previewButtonId = idPrefix + 'previewbutton';
+    var previewBoxId = idPrefix + 'previewbox';
+    var cleanHtmlButtonId = idPrefix + 'cleanhtmlbutton';
     var self = this;
 
     // Create elements
     container.after(
         "<div class=\"prescontrol\">" +
-            "<input type=\"submit\" value=\"Clean pasted HTML\" id=\"" + cleanhtmlbutton_id  +  "\" />" +
-            "<input type=\"submit\" value=\"Preview\" id=\"" + previewbutton_id + "\" />" +
-            "<div class=\"prescontrolerror\" id=\"" + id_prefix + "errorbox" + "\"></div>" +
+            "<input type=\"submit\" value=\"Clean pasted HTML\" id=\"" + cleanHtmlButtonId  +  "\" />" +
+            "<input type=\"submit\" value=\"Preview\" id=\"" + previewButtonId + "\" />" +
+            "<div class=\"prescontrolerror\" id=\"" + idPrefix + "errorbox" + "\"></div>" +
         "</div>");
 
-    jQuery("body").append("<div style=\"position: absolute; display: none\" class=\"previewbox\" id=\"" + previewbox_id + "\">");
+    jQuery("body").append("<div style=\"position: absolute; display: none\" class=\"previewbox\" id=\"" + previewBoxId + "\">");
 
-    this.classlist = jQuery(this.wym._options.classesSelector).find("ul");
-    this.commandlist = jQuery(this.wym._options.layoutCommandsSelector).find("ul");
-    this.errorbox = jQuery('#' + id_prefix + "errorbox");
-    this.previewbutton = jQuery('#' + previewbutton_id);
-    this.previewbox = jQuery('#' + previewbox_id);
-    this.cleanhtmlbutton = jQuery('#' + cleanhtmlbutton_id);
+    this.classList = jQuery(this.wym._options.classesSelector).find("ul");
+    this.commandList = jQuery(this.wym._options.layoutCommandsSelector).find("ul");
+    this.errorBox = jQuery('#' + idPrefix + "errorbox");
+    this.previewButton = jQuery('#' + previewButtonId);
+    this.previewBox = jQuery('#' + previewBoxId);
+    this.cleanHtmlButton = jQuery('#' + cleanHtmlButtonId);
 
-    this.setup_css_storage();
+    this.setupCssStorage();
 
      // Initial set up
     // Remove any tooltips
     jQuery(".orbitaltooltip-simplebox").unbind().remove();
 
-    // retrieve_commands() must come before retrieve_styles(), due to use
-    // of calculate_selectors() which needs .commands to be set.
-    this.retrieve_commands(); // async
-    this.retrieve_styles(); // async
-    this.separate_presentation();
+    // retrieveCommands() must come before retrieveStyles(), due to use
+    // of calculateSelectors() which needs .commands to be set.
+    this.retrieveCommands(); // async
+    this.retrieveStyles(); // async
+    this.separatePresentation();
 
-    this.previewbutton.toggle(function(event) {
-                                 self.show_preview();
+    this.previewButton.toggle(function(event) {
+                                 self.showPreview();
                                  return false;
                               },
                               function(event) {
-                                  self.previewbox.hide();
+                                  self.previewBox.hide();
                               });
-    this.cleanhtmlbutton.click(function(event) {
-                                   self.clean_html();
+    this.cleanHtmlButton.click(function(event) {
+                                   self.cleanHtml();
                                    return false;
                                });
     jQuery(this.wym._doc)
         .bind("keyup", function(evt) {
-                  // this style of binding gives doc_keyup
+                  // this style of binding gives docKeyup
                   // access to 'this' PresentationControl
-                  self.doc_keyup(evt);
+                  self.docKeyup(evt);
               })
         .bind("keydown", function(evt) {
-                  self.doc_keydown(evt);
+                  self.docKeydown(evt);
               })
         .bind("mouseup", function(evt) {
-                  self.update_classlist_item_all();
+                  self.updateClassListItemAll();
               });
     jQuery(this.wym._options.containersSelector).find("a")
          .bind("click", function(evt) {
-                   self.update_classlist_item_all();
+                   self.updateClassListItemAll();
                });
 
     // Insert rewriting of HTML before the WYMeditor updates the textarea.
     jQuery(this.wym._options.updateSelector)
         .bind(this.wym._options.updateEvent, function(event) {
-                  self.form_submit(event);
+                  self.formSubmit(event);
               });
 
-    // Fix height of classlist (in timeout to give command list time to load)
+    // Fix height of classList (in timeout to give command list time to load)
     setTimeout(function() {
                    var h = jQuery(" .wym_area_main").height() -
                        jQuery(self.wym._options.containersSelector).height() -
                        jQuery(self.wym._options.layoutCommandsSelector).height() -
                        jQuery(self.wym._options.classesSelector + " h2").height() -
                        20; // 20 is a fudge value, probably equal to some marings/paddings
-                   self.classlist.css("height", h.toString() + "px");
+                   self.classList.css("height", h.toString() + "px");
                }, 1000);
 
     // Stop the tooltips from getting in the way - dismiss with a click.
 
 };
 
-PresentationControls.prototype.set_html = function(html) {
+PresentationControls.prototype.setHtml = function(html) {
     // WUMEditor ought to call .listen() after setting
     // the HTML (to rebind events for images),
     // but it doesn't at the moment, so we work around it by wrapping.
             }
         }
     }
-}
+};
 
 PresentationControls.prototype.previousElementSibling = function(node) {
     var prev = node;
             }
         }
     }
-}
+};
 
-PresentationControls.prototype.doc_keyup = function(evt) {
+PresentationControls.prototype.docKeyup = function(evt) {
     // Some browsers (Firefox at least) will insert a new paragraph with the
     // same ID as the old one when the user presses 'Enter'. This needs fixing
     // for our styling to work. It's possible that multiple 'p' elements can be inserted
     // for one keyup event, so we handle that. This appears to happen for any
     // elements that are created by pressing 'Enter'
 
-    // We also need to update the disable/enabled state of the classlist and commandlist
+    // We also need to update the disable/enabled state of the classList and commandList
     var self = this;
     var wym = self.wym;
-    var container = jQuery(wym.selected()).parentsOrSelf(this.blockdef_selector);
+    var container = jQuery(wym.selected()).parentsOrSelf(this.blockdefSelector);
     if (evt.keyCode == 13 && !evt.shiftKey) {
         if (container.is("p[id],li[id]")) {
             // Need to clear id on all elem's with that id except the first.
                      });
         }
     }
-    this.update_classlist_item_all(container);
+    this.updateClassListItemAll(container);
 };
 
-PresentationControls.prototype.doc_keydown = function(evt) {
+PresentationControls.prototype.docKeydown = function(evt) {
     // Need to intercept backspace and delete, to stop command blocks
     // being deleted. (The system copes fairly well with them being
     // deleted, but it can be very confusing for the user.)
-    var is_backspace = (evt.keyCode == 8);
+    var isBackspace = (evt.keyCode == 8);
     var is_delete = (evt.keyCode == 46);
 
-    if (is_backspace || is_delete) {
+    if (isBackspace || isDelete) {
 
-        s = this.wym._iframe.contentWindow.getSelection()
+        var s = this.wym._iframe.contentWindow.getSelection();
         if (s.anchorNode != s.focusNode) {
             // an extended selection.  It doesn't matter if this
             // contains command blocks - it doesn't confuse the user
             return;
         }
 
-        node = s.focusNode;
+        var node = s.focusNode;
         if (node.nodeName == "#text") {
             // always true?
             node = node.parentNode;
         }
-        if (is_backspace) {
+        if (isBackspace) {
             if (s.focusOffset != 0) {
                 return; // not at first character within text node
             }
             // need to check *previous* node
             target = this.previousElementSibling(node);
         }
-        if (is_delete) {
+        if (isDelete) {
             if (s.focusOffset != s.focusNode.textContent.length) {
                 return; // not at last character within text node
             }
             return;
         }
 
-        if (jQuery(target).is(this.all_command_selectors)) {
+        if (jQuery(target).is(this.allCommandSelectors)) {
             // stop backspace or delete from working.
             evt.preventDefault();
         }
     }
 };
 
-PresentationControls.prototype.update_classlist_item_all = function(cur_container) {
+PresentationControls.prototype.updateClassListItemAll = function(curContainer) {
     var self = this;
-    if (cur_container == undefined) {
-        cur_container = jQuery(this.wym.selected()).parentsOrSelf(this.blockdef_selector);
+    if (curContainer == undefined) {
+        curContainer = jQuery(this.wym.selected()).parentsOrSelf(this.blockdefSelector);
     }
-    var node = cur_container.get(0);
-    if (node != undefined && node != this.current_node) {
+    var node = curContainer.get(0);
+    if (node != undefined && node != this.currentNode) {
         // if current node has changed, might need to update list
-        this.current_node = node;
-        // Sets enabled/disabled on all items in classlist and commands
-        var pairs = [[this.available_styles, this.classlist],
-                     [this.commands, this.commandlist]];
+        this.currentNode = node;
+        // Sets enabled/disabled on all items in classList and commands
+        var pairs = [[this.availableStyles, this.classList],
+                     [this.commands, this.commandList]];
 
         for (var i = 0; i < pairs.length; i++) {
             var styles = pairs[i][0];
             var btncontainer = pairs[i][1];
             btncontainer.find("a").each(function(k) {
-                                            self.update_classlist_item(jQuery(this), styles[k]);
+                                            self.updateClassListItem(jQuery(this), styles[k]);
                                         });
         }
     }
 };
 
 // Splits the HTML into 'content HTML' and 'presentation'
-PresentationControls.prototype.separate_presentation = function() {
+PresentationControls.prototype.separatePresentation = function() {
     // 'andthen' is a function to do afterwards.  This is a nasty
     // hack to get things to work.
     var self = this;
-    jQuery.post(this.opts.separate_presentation_url, { html: self.wym.xhtml() } ,
+    jQuery.post(this.opts.separatePresentationUrl, { html: self.wym.xhtml() } ,
                 function(data) {
-                    self.with_good_data(data,
+                    self.withGoodData(data,
                         function(value) {
                             // Store the presentation
-                            self.presentation_info = value.presentation;
+                            self.presentationInfo = value.presentation;
                             // Update the HTML
-                            self.set_html(value.html);
+                            self.setHtml(value.html);
                             // Update presentation of HTML
-                            self.update_after_loading();
+                            self.updateAfterLoading();
                         });
                 }, "json");
 };
 
-PresentationControls.prototype.ensure_all_ids = function() {
+PresentationControls.prototype.ensureAllIds = function() {
     // We check all block level elements (or all elements that can have commands
     // applied to them)
 
     }
     elems = jQuery.unique(elems);
     jQuery(this.wym._doc).find(elems.join(",")).each(function(i) {
-                                                         self.ensure_id(this);
+                                                         self.ensureId(this);
                                                      });
 };
 
-PresentationControls.prototype.clean_presentation_info = function() {
+PresentationControls.prototype.cleanPresentationInfo = function() {
     // clear out orphaned items
     var orphaned = [];
-    for (var key in this.presentation_info) {
+    for (var key in this.presentationInfo) {
         var sel = "#" + key;
         if (!jQuery(this.wym._doc).find(sel).is(sel)) {
             orphaned.push(key);
         }
     }
     for (var i = 0; i < orphaned.length; i++) {
-        delete this.presentation_info[orphaned[i]];
+        delete this.presentationInfo[orphaned[i]];
     }
 };
 
-PresentationControls.prototype.form_submit = function(event) {
-    this.prepare_data();
+PresentationControls.prototype.formSubmit = function(event) {
+    this.prepareData();
     // Since we are in the middle of submitting the page, an asynchronous
     // request will be too late! So we block instead.
 
                   type: "POST",
                   data: {
                       html: this.wym.xhtml(),
-                      presentation: JSON.stringify(this.presentation_info)
+                      presentation: JSON.stringify(this.presentationInfo)
                   },
-                  url: this.opts.combine_presentation_url,
+                  url: this.opts.combinePresentationUrl,
                   dataType: "json",
                   async: false
     }).responseText;
     var data = JSON.parse(res);
     if (data.result == 'ok') {
         // Replace existing HTML with combined.
-        this.set_html(data.value.html);
+        this.setHtml(data.value.html);
         // In case the normal WYMeditor update got called *before* this
         // event handler, we do another update.
         this.wym.update();
     } else {
         event.preventDefault();
-        this.show_error(data.message);
+        this.showError(data.message);
         alert("Data in " + this.name + " can't be saved - see error message.");
     }
 };
 
 
-PresentationControls.prototype.build_classlist = function() {
+PresentationControls.prototype.buildClassList = function() {
     var self = this;
-    this.build_list_generic(this.classlist, this.available_styles,
-                            function(style, btn) { self.toggle_style(style, btn); },
-                            'id_classlist_');
+    this.buildListGeneric(this.classList, this.availableStyles,
+                          function(style, btn) { self.toggleStyle(style, btn); },
+                          'id_classlist_');
 };
 
-PresentationControls.prototype.build_commandlist = function () {
+PresentationControls.prototype.buildCommandList = function () {
     var self = this;
-    this.build_list_generic(this.commandlist, this.commands,
-                            function(command, btn) { self.do_command(command, btn); },
-                            'id_commandlist_');
+    this.buildListGeneric(this.commandList, this.commands,
+                          function(command, btn) { self.doCommand(command, btn); },
+                          'id_commandlist_');
 };
 
-PresentationControls.prototype.build_list_generic = function(container, stylelist, btn_action, id_stem) {
+PresentationControls.prototype.buildListGeneric = function(container, stylelist, btnAction, idStem) {
     // container - jQuery object that will hold the 'buttons'
     // stylelist - list of PresentationInfo objects
-    // btn_action - function to call when the button is clicked
-    // id_stem - stem of 'id' attribute to use for each button.
+    // btnAction - function to call when the button is clicked
+    // idStem - stem of 'id' attribute to use for each button.
     container.empty();
 
     var self = this;
         var style = stylelist[i];
 
         btn.click(function(event) {
-                      btn_action(style, btn);
+                      btnAction(style, btn);
                   });
 
         // Attach tooltip to label we just added:
         help = "<h1>" + escapeHtml(item.verbose_name) + "</h1>" + help;
         help = help + '<br/><hr/><p>Can be used on these elements:</p><p>' + item.allowed_elements.join(' ') + '</p>';
         // Assign an id, because orbitaltooltip doesn't work without it.
-        btn.attr('id', id_stem + i);
+        btn.attr('id', idStem + i);
         setTimeout(function() {
                        btn.orbitaltooltip({
                            orbitalPosition: 270,
 
 };
 
-PresentationControls.prototype.has_style = function(sect_id, style) {
-    var styles = this.presentation_info[sect_id];
+PresentationControls.prototype.hasStyle = function(sectId, style) {
+    var styles = this.presentationInfo[sectId];
     if (styles == undefined)
         return false;
     for (var i = 0; i < styles.length; i++) {
     return false;
 };
 
-PresentationControls.prototype.has_command = function(sect_id, command) {
+PresentationControls.prototype.hasCommand = function(sectId, command) {
     // Returns true if the section has the command before it.
-    return (this.presentation_info[this.command_block_id(sect_id, command)] != undefined);
-}
+    return (this.presentationInfo[this.commandBlockId(sectId, command)] != undefined);
+};
 
-PresentationControls.prototype.next_id = function(tagName) {
+PresentationControls.prototype.nextId = function(tagName) {
     // All sections that can receive styles need a section ID.
     // For the initial HTML, this is assigned server-side when the
     // HTML is split into 'semantic HTML' and 'presentation info'.
     }
 };
 
-PresentationControls.prototype.update_command_blocks = function(node, id, max) {
+PresentationControls.prototype.updateCommandBlocks = function(node, id, max) {
     // Updates the 'id' of any HTML block that represents a command.
     if (max == 0) {
         return;
         // command blocks are like <p id="newrow_p_1" class="newrow">
         // check we've got a command block.
         var className = prev.className;
-        var prev_id = prev.id;
-        if (prev_id && className && prev_id.match(eval("/^" + className + "_/"))) {
+        var prevId = prev.id;
+        if (prevId && className && prevId.match(eval("/^" + className + "_/"))) {
             prev.id = className + "_" + id;
-            // need to update presentation_info as well
-            this.presentation_info[prev.id] = this.presentation_info[prev_id];
-            delete this.presentation_info[prev_id];
+            // need to update presentationInfo as well
+            this.presentationInfo[prev.id] = this.presentationInfo[prevId];
+            delete this.presentationInfo[prevId];
             // and then the visible indicators
-            this.update_style_display(prev.id);
+            this.updateStyleDisplay(prev.id);
             // do the next one.
-            this.update_command_blocks(prev, id, max - 1);
+            this.updateCommandBlocks(prev, id, max - 1);
         }
     }
 };
 
-PresentationControls.prototype.assign_id = function(node, id) {
+PresentationControls.prototype.assignId = function(node, id) {
     // Assign an ID to an element.  This can be tricky, because, if the section
     // has a command block before it, we need to make sure that the id of those
     // blocks are changed, since the 'position' of the command blocks are only stored
     // by giving them the right id.
     node.id = id;
     // Need to change (up to) the two previous siblings.
-    this.update_command_blocks(node, id, 2);
+    this.updateCommandBlocks(node, id, 2);
 };
 
-PresentationControls.prototype.register_section = function(sect_id) {
+PresentationControls.prototype.registerSection = function(sectId) {
     // Make sure we have somewhere to store styles for a section.
-    this.presentation_info[sect_id] = new Array();
+    this.presentationInfo[sectId] = new Array();
 };
 
-PresentationControls.prototype.calculate_selectors = function(stylelist) {
+PresentationControls.prototype.calculateSelectors = function(stylelist) {
     // Given a list of styles, add a 'allowed_elements_selector' attribute
     // on the basis of the 'allowed_elements' attribute.
 
         var style = stylelist[i];
         style.allowed_elements_selector =
             jQuery.map(style.allowed_elements,
-                       function(t,j) { return self.tagname_to_selector(t); }
+                       function(t,j) { return self.tagnameToSelector(t); }
                       ).join(",");
     }
 };
 
-PresentationControls.prototype.tagname_to_selector = function(name) {
+PresentationControls.prototype.tagnameToSelector = function(name) {
     // Convert a tag name into a selector used to match elements that represent
     // that tag.  This function accounts for the use of p elements to represent
     // commands in the document.
 
-    var c = this.command_dict[name];
+    var c = this.commandDict[name];
     if (c == null) {
         // not a command
         if (name == "p") {
     }
 };
 
-PresentationControls.prototype.ensure_id = function(node) {
+PresentationControls.prototype.ensureId = function(node) {
     var id = node.id;
 
     if (id == undefined || id == "") {
-        id = this.next_id(node.tagName.toLowerCase());
-        this.assign_id(node, id);
-        this.register_section(id);
+        id = this.nextId(node.tagName.toLowerCase());
+        this.assignId(node, id);
+        this.registerSection(id);
     }
     return id;
 };
 
-PresentationControls.prototype.get_current_section = function(style) {
+PresentationControls.prototype.getCurrentSection = function(style) {
     // Returns the section ID of the current section that is applicable
     // to the given style, or undefined if there is none.
     // Since sections can be nested, if more than one section is possible
     var container = jQuery(wym.selected()).parentsOrSelf(expr);
     if (container.is(expr)) {
         var first = container.get(0);
-        var id = this.ensure_id(first);
+        var id = this.ensureId(first);
         return id;
     }
     return undefined;
 };
 
-PresentationControls.prototype.toggle_style = function(style, btn) {
+PresentationControls.prototype.toggleStyle = function(style, btn) {
     // What section are we on?
-    var sect_id = this.get_current_section(style);
-    if (sect_id == undefined) {
+    var sectId = this.getCurrentSection(style);
+    if (sectId == undefined) {
         // No allowed to use it there
         alert("Cannot use this style on current element.");
         return;
     }
 
-    if (this.has_style(sect_id, style)) {
-        this.remove_style(sect_id, style);
+    if (this.hasStyle(sectId, style)) {
+        this.removeStyle(sectId, style);
     } else {
-        this.add_style(sect_id, style);
+        this.addStyle(sectId, style);
     }
-    this.update_style_display(sect_id);
-    this.update_classlist_item(btn, style);
+    this.updateStyleDisplay(sectId);
+    this.updateClassListItem(btn, style);
 };
 
-PresentationControls.prototype.command_block_id = function(sect_id, command) {
+PresentationControls.prototype.commandBlockId = function(sectId, command) {
     // Returns the ID to use for a command block that appears before
-    // section sect_id for a given command.  This is also the key used
-    // in this.presentation_info
-    return command.name + "_" + sect_id;
-}
+    // section sectId for a given command.  This is also the key used
+    // in this.presentationInfo
+    return command.name + "_" + sectId;
+};
 
-PresentationControls.prototype.insert_command_block = function(sect_id, command) {
+PresentationControls.prototype.insertCommandBlock = function(sectId, command) {
     // There is some custom logic about the different commands here i.e.
     // that newrow should appear before newcol.
     var newelem = jQuery("<p class=\"" + command.name + "\">&nbsp;</p>");
-    var elem = jQuery(this.wym._doc).find("#" + sect_id);
+    var elem = jQuery(this.wym._doc).find("#" + sectId);
     // New row should appear before new col
     if (elem.prev().is("p.newcol") && command.name == 'newrow') {
         elem = elem.prev();
     }
     elem.before(newelem);
-    var new_id = this.command_block_id(sect_id, command);
-    newelem.attr('id', new_id);
-    return new_id;
+    var newId = this.commandBlockId(sectId, command);
+    newelem.attr('id', newId);
+    return newId;
 };
 
-PresentationControls.prototype.do_command = function(command, btn) {
+PresentationControls.prototype.doCommand = function(command, btn) {
     // What section are we on?
-    var sect_id = this.get_current_section(command);
-    if (sect_id == undefined) {
-        // No allowed to use it there
+    var sectId = this.getCurrentSection(command);
+    if (sectId == undefined) {
+        // Not allowed to use it there
         alert("Cannot use this command on current element.");
         return;
     }
     // newrow and newcol are the only commands at the moment.
-    // We handle both using inserted blocks
-    if (this.has_command(sect_id, command)) {
-        // remove it.
-        var id = this.command_block_id(sect_id, command);
+    // We handle both using inserted blocks, and both commands
+    // act as toggles (remove if already present).
+    if (this.hasCommand(sectId, command)) {
+        var id = this.commandBlockId(sectId, command);
         jQuery(this.wym._doc).find('#' + id).remove();
-        delete this.presentation_info[id];
+        delete this.presentationInfo[id];
     } else {
-        var new_id = this.insert_command_block(sect_id, command);
-        this.register_section(new_id);
-        this.presentation_info[new_id].push(command);
-        this.update_style_display(new_id);
+        var newId = this.insertCommandBlock(sectId, command);
+        this.registerSection(newId);
+        this.presentationInfo[newId].push(command);
+        this.updateStyleDisplay(newId);
     }
-    this.update_classlist_item(btn, command);
+    this.updateClassListItem(btn, command);
 };
 
-PresentationControls.prototype.insert_command_blocks = function() {
+PresentationControls.prototype.insertCommandBlocks = function() {
     // This is run once, after loading HTML.  We can rely on 'ids' being
     // present, since the HTML is all sent by the server.
-    for (var key in this.presentation_info) {
-        var presinfos = this.presentation_info[key];
+    for (var key in this.presentationInfo) {
+        var presinfos = this.presentationInfo[key];
         for (var i = 0; i < presinfos.length; i++) {
             var pi = presinfos[i];
             if (pi.prestype == 'command') {
                 // key = e.g. 'newrow_p_1', we need 'p_1'
                 var id = key.split('_').slice(1).join('_');
-                this.insert_command_block(id, this.command_dict[pi.name]);
+                this.insertCommandBlock(id, this.commandDict[pi.name]);
             }
         }
     }
 };
 
-PresentationControls.prototype.update_classlist_item = function(btn, style) {
-    var sect_id = this.get_current_section(style);
-    if (sect_id == undefined) {
+PresentationControls.prototype.updateClassListItem = function(btn, style) {
+    var sectId = this.getCurrentSection(style);
+    if (sectId == undefined) {
         // Can't use it.
         if (style.prestype == "command") {
             // Don't want the class list (displayed below command list)
     } else {
         if (style.prestype == "command") {
             btn.removeClass("disabled");
-            if (this.has_command(sect_id, style)) {
+            if (this.hasCommand(sectId, style)) {
                 btn.addClass("used");
             } else {
                 btn.removeClass("used");
             }
         } else {
             btn.show();
-            if (this.has_style(sect_id, style)) {
+            if (this.hasStyle(sectId, style)) {
                 btn.addClass("used");
             } else {
                 btn.removeClass("used");
     }
 };
 
-PresentationControls.prototype.show_preview = function() {
-    this.prepare_data();
+PresentationControls.prototype.showPreview = function() {
+    this.prepareData();
     var self = this;
-    jQuery.post(this.opts.preview_url, { 'html': self.wym.xhtml(),
-                                         'presentation': JSON.stringify(this.presentation_info)
-                                        },
+    jQuery.post(this.opts.previewUrl, {'html': self.wym.xhtml(),
+                                       'presentation': JSON.stringify(this.presentationInfo)
+                                      },
                 function(data) {
-                    self.with_good_data(data,
+                    self.withGoodData(data,
                         function(value) {
-                            var btn = self.previewbutton;
-                            var box = self.previewbox;
+                            var btn = self.previewButton;
+                            var box = self.previewBox;
                             var pos = btn.offset();
                             box.html(value.html);
                             var height = box.height() + parseInt(box.css('padding-top')) + parseInt(box.css('padding-bottom')) +
     return false;
 };
 
-PresentationControls.prototype.add_style = function(sect_id, presinfo) {
-    var styles = this.presentation_info[sect_id];
+PresentationControls.prototype.addStyle = function(sectId, presinfo) {
+    var styles = this.presentationInfo[sectId];
     styles.push(presinfo);
-    this.presentation_info[sect_id] = jQuery.unique(styles);
+    this.presentationInfo[sectId] = jQuery.unique(styles);
 };
 
-PresentationControls.prototype.remove_style = function(sect_id, presinfo) {
-    var styles = this.presentation_info[sect_id];
+PresentationControls.prototype.removeStyle = function(sectId, presinfo) {
+    var styles = this.presentationInfo[sectId];
     styles = jQuery.grep(styles, function(item, i) {
                              return !(item.prestype == presinfo.prestype
                                       && item.name == presinfo.name);
                          });
-    this.presentation_info[sect_id] = styles;
+    this.presentationInfo[sectId] = styles;
 };
 
-PresentationControls.prototype.update_style_display = function(sect_id) {
-    var styles = this.presentation_info[sect_id];
+PresentationControls.prototype.updateStyleDisplay = function(sectId) {
+    var styles = this.presentationInfo[sectId];
     var self = this;
-    var style_list = jQuery.map(styles, function(s, i) {
-                                    return self.get_verbose_style_name(s.name);
-                                }).join(", ");
-    this.add_css_rule("#" + sect_id + ":before", 'content: "' + style_list + '"');
+    var stylelist = jQuery.map(styles, function(s, i) {
+                                   return self.getVerboseStyleName(s.name);
+                               }).join(", ");
+    this.addCssRule("#" + sectId + ":before", 'content: "' + stylelist + '"');
 };
 
-PresentationControls.prototype.update_all_style_display = function() {
-    for (var key in this.presentation_info) {
-        this.update_style_display(key);
+PresentationControls.prototype.updateAllStyleDisplay = function() {
+    for (var key in this.presentationInfo) {
+        this.updateStyleDisplay(key);
     }
 };
 
-PresentationControls.prototype.update_after_loading = function() {
-    this.insert_command_blocks();
-    this.update_all_style_display();
+PresentationControls.prototype.updateAfterLoading = function() {
+    this.insertCommandBlocks();
+    this.updateAllStyleDisplay();
 };
 
-PresentationControls.prototype.get_verbose_style_name = function(stylename) {
+PresentationControls.prototype.getVerboseStyleName = function(stylename) {
     // Full style information is not stored against individual headings, only
     // the type and name. So sometimes we need to go from one to the other.
 
-    var styles = this.available_styles;
+    var styles = this.availableStyles;
     for (var i = 0; i < styles.length; i++) {
         if (styles[i].name == stylename) {
             return styles[i].verbose_name;
     return undefined; // shouldn't get here
 };
 
-PresentationControls.prototype.prepare_data = function() {
+PresentationControls.prototype.prepareData = function() {
     // Prepare data/html for sending server side.
 
     // We need to ensure all elements have ids, *and* that command block
     // elements have correct ids (which is a side effect of the below).
-    this.ensure_all_ids();
-    // this.presentation_info might have old info, if command blocks have
+    this.ensureAllIds();
+    // this.presentationInfo might have old info, if command blocks have
     // been removed.  Need to clean.
-    this.clean_presentation_info();
+    this.cleanPresentationInfo();
 };
 
-PresentationControls.prototype.clean_html = function() {
-    this.prepare_data();
+PresentationControls.prototype.cleanHtml = function() {
+    this.prepareData();
     var self = this;
     var html = this.wym.xhtml();
-    jQuery.post(this.opts.clean_html_url, {'html':html},
+    jQuery.post(this.opts.cleanHtmlUrl, {'html':html},
                 function(data) {
-                    self.with_good_data(data, function(value) {
-                                            self.set_html(value.html);
-                                            self.update_after_loading();
+                    self.withGoodData(data, function(value) {
+                                            self.setHtml(value.html);
+                                            self.updateAfterLoading();
                                         });
                 }, "json");
 };
 // If data contains an error message, display to the user,
 // otherwise clear the displayed error and perform the callback
 // with the value in the data.
-PresentationControls.prototype.with_good_data = function(data, callback) {
+PresentationControls.prototype.withGoodData = function(data, callback) {
     if (data.result == 'ok') {
-        this.clear_error();
+        this.clearError();
         callback(data.value);
     } else {
         // TODO - perhaps distinguish between a server error
         // and a user error
-        this.show_error(data.message);
+        this.showError(data.message);
     }
 };
 
-PresentationControls.prototype.clear_error = function() {
-    this.errorbox.empty();
+PresentationControls.prototype.clearError = function() {
+    this.errorBox.empty();
 };
 
-PresentationControls.prototype.show_error = function(message) {
-    this.clear_error();
-    this.errorbox.append(escapeHtml(message));
+PresentationControls.prototype.showError = function(message) {
+    this.clearError();
+    this.errorBox.append(escapeHtml(message));
 };
 
-PresentationControls.prototype.retrieve_styles = function() {
+PresentationControls.prototype.retrieveStyles = function() {
     var self = this;
-    // Needs async=false, since separate_presentation depends on data.
+    // Needs async=false, since separatePresentation depends on data.
     var res = jQuery.ajax({
                   type: "GET",
                   data: {
                       'template':this.opts.template,
-                      'page_id':this.opts.page_id
+                      'page_id':this.opts.pageId
                   },
-                  url: this.opts.retrieve_styles_url,
+                  url: this.opts.retrieveStylesUrl,
                   dataType: "json",
                   async: false
     }).responseText;
     var data = JSON.parse(res);
 
-    self.with_good_data(data, function(value) {
-        self.available_styles = data.value;
-        self.calculate_selectors(self.available_styles);
-        self.build_classlist();
+    self.withGoodData(data, function(value) {
+        self.availableStyles = data.value;
+        self.calculateSelectors(self.availableStyles);
+        self.buildClassList();
     });
 };
 
-PresentationControls.prototype.retrieve_commands = function() {
+PresentationControls.prototype.retrieveCommands = function() {
     var self = this;
-    // Needs async=false, since separate_presentation depends on data.
+    // Needs async=false, since separatePresentation depends on data.
     var res = jQuery.ajax({
                   type: "GET",
                   data: {},
-                  url: this.opts.retrieve_commands_url,
+                  url: this.opts.retrieveCommandsUrl,
                   dataType: "json",
                   async: false
     }).responseText;
     var data = JSON.parse(res);
 
-    self.with_good_data(data, function(value) {
+    self.withGoodData(data, function(value) {
                             self.commands = data.value;
-                            self.calculate_selectors(self.commands);
+                            self.calculateSelectors(self.commands);
                             for (var i = 0; i < self.commands.length; i++) {
                                 var c = self.commands[i];
-                                self.command_dict[c.name] = c;
+                                self.commandDict[c.name] = c;
                             }
-                            self.all_command_selectors = jQuery.map(self.commands,
-                                                                    function(c, i) { return self.tagname_to_selector(c.name); }
+                            self.allCommandSelectors = jQuery.map(self.commands,
+                                                                    function(c, i) { return self.tagnameToSelector(c.name); }
                                                                     ).join(",");
-                            self.build_commandlist();
+                            self.buildCommandList();
                         });
 };
 

semanticeditor/templates/semanticeditor/editorwidget.html

             }
 
             symanticopts = {
-                retrieve_styles_url: "{% url semantic.retrieve_styles %}",
-                retrieve_commands_url: "{% url semantic.retrieve_commands %}",
-                separate_presentation_url: "{% url semantic.separate_presentation %}",
-                combine_presentation_url: "{% url semantic.combine_presentation %}",
-                clean_html_url: "{% url semantic.clean_html %}",
-                preview_url: "{% url semantic.preview %}",
+                retrieveStylesUrl: "{% url semantic.retrieve_styles %}",
+                retrieveCommandsUrl: "{% url semantic.retrieve_commands %}",
+                separatePresentationUrl: "{% url semantic.separate_presentation %}",
+                combinePresentationUrl: "{% url semantic.combine_presentation %}",
+                cleanHtmlUrl: "{% url semantic.clean_html %}",
+                previewUrl: "{% url semantic.preview %}",
                 template: template,
-                page_id: "{{ page.id }}"
+                pageId: "{{ page.id }}"
             };
             wym.semantic(symanticopts);
 
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.