Luke Plant avatar Luke Plant committed 35b67f1

Removed a lot of unused code

Comments (0)

Files changed (1)

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

     this.name = wym._element.get(0).name;
     // available_styles: an array of dictionaries corresponding to PresentationInfo objects
     this.available_styles = new Array();
-    // stored_headings: array of StructureItem objects (attributes .level, .name, .sect_id, .tag)
-    this.stored_headings = new Array();
-    // active_heading_list - a possibly filtered version of stored_headings
-    this.active_heading_list = new Array();
     // presentation_info: a dictionary of { sect_id : [PresentationInfo] }
     this.presentation_info = {};
 
-    // an array of dictionaries corresponding to PresentationInfo objects for commands.
+    // commands: an array of dictionaries corresponding to PresentationInfo objects for commands.
     this.commands = new Array();
-    // a dictionary mapping command name to PresentationInfo object.
+    // command_dict: a dictionary mapping command name to PresentationInfo object.
     this.command_dict = {};
 
-
     this.setup_controls(jQuery(wym._bvox).find(".wym_area_bottom"));
 }
 
 
 PresentationControls.prototype.setup_controls = function(container) {
     var id_prefix = "id_prescontrol_" + this.name + "_";
-    var headingsbox_id = id_prefix + 'headings';
-    var headingsfilter_id = id_prefix + 'headingsfilter';
     var previewbutton_id = id_prefix + 'previewbutton';
     var previewbox_id = id_prefix + 'previewbox';
-    var refresh_id = id_prefix + 'refresh';
-    var newrowbutton_id = id_prefix + 'newrowbutton';
-    var newcolbutton_id = id_prefix + 'newcolbutton';
-    var removebutton_id = id_prefix + 'removebutton';
     var cleanhtmlbutton_id = id_prefix + 'cleanhtmlbutton';
     var self = this;
 
     // Create elements
     container.after(
         "<div class=\"prescontrol\">" +
-        "</div>" +
-        "<div class=\"prescontrolheadings\" style=\"margin-right: 260px;\">Document structure:<br/><select size=\"15\" id=\"" + headingsbox_id + "\"></select>" +
-        "<br/><label><input type=\"checkbox\" id=\"" + headingsfilter_id + "\"> Headings only</label></div>" +
-
         "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>" +
             "<td><input type=\"submit\" value=\"Clean pasted HTML\" id=\"" + cleanhtmlbutton_id  +  "\" /></td>" +
-            "<td><input type=\"submit\" value=\"Refresh structure\" id=\"" + refresh_id + "\" /></td>" +
             "<td><input type=\"submit\" value=\"Preview\" id=\"" + previewbutton_id + "\" /></td>" +
             "<td width=\"100%\"><div class=\"prescontrolerror\" id=\"" + id_prefix + "errorbox" + "\"></div></td></tr></table>" +
         "</div>");
 
     this.classlist = jQuery(this.wym._options.classesSelector).find("ul");
     this.commandlist = jQuery(this.wym._options.layoutCommandsSelector).find("ul");
-    this.headingscontrol = jQuery('#' + headingsbox_id);
-    this.headingsfilter = jQuery('#' + headingsfilter_id);
     this.errorbox = jQuery('#' + id_prefix + "errorbox");
     this.previewbutton = jQuery('#' + previewbutton_id);
     this.previewbox = jQuery('#' + previewbox_id);
-    this.refreshbutton = jQuery('#' + refresh_id);
-    //this.newrowbutton = jQuery('#' + newrowbutton_id);
-    //this.newcolbutton = jQuery('#' + newcolbutton_id);
-    //this.removebutton = jQuery('#' + removebutton_id);
     this.cleanhtmlbutton = jQuery('#' + cleanhtmlbutton_id);
 
     this.setup_css_storage();
                                    self.update_all_style_display();
                                });
 
-    // Event handlers
-    this.headingscontrol.change(function(event) {
-
-    });
-    this.refreshbutton.click(function(event) {
-                                 self.refresh_headings();
-                                 self.headingscontrol.get(0).focus();
-                                 return false;
-                             });
     this.previewbutton.toggle(function(event) {
                                  self.show_preview();
                                  return false;
                               function(event) {
                                   self.previewbox.hide();
                               });
-    this.headingsfilter.change(function(event) {
-                                   self.update_active_heading_list();
-                                   self.update_headingbox();
-                               });
-/*    this.newrowbutton.click(function(event) {
-                                self.insert_row();
-                                return false;
-                            });
-    this.newcolbutton.click(function(event) {
-                                self.insert_column();
-                                return false;
-                            });
-    this.removebutton.click(function(event) {
-                                self.remove_layout_command();
-                                return false;
-                            });*/
     this.cleanhtmlbutton.click(function(event) {
                                    self.clean_html();
                                    return false;
 
 };
 
-PresentationControls.prototype.get_heading_index = function() {
-    var selected = this.headingscontrol.get(0).value;
-    if (!selected) {
-        return null;
-    }
-    return parseInt(selected, 10);
-};
-
 PresentationControls.prototype.has_style = function(sect_id, style) {
     var styles = this.presentation_info[sect_id];
     for (var i = 0; i < styles.length; i++) {
     return undefined; // shouldn't get here
 };
 
-PresentationControls.prototype.insert_row = function() {
-    // Insert a new row command into outline above selected item
-    var sect_id = get_current_section(this.newrow_style);
-    var headingIndex = this.get_heading_index();
-    if (headingIndex == null) return;
-    var sect_id = this.active_heading_list[headingIndex].sect_id;
-    if (sect_id.match(/^newrow_/)) {
-        alert("Can't insert new row here");
-        return;
-    }
-
-    for (var i=0; i < this.stored_headings.length; i++) {
-        if (this.stored_headings[i].sect_id == sect_id) {
-            // Update the headings:
-            this.insert_row_command(this.stored_headings, i, sect_id);
-            // Update presentation info:
-            // An empty array will do, don't actually need a
-            // command in there (and the GUI will overwrite any
-            // anything we put in it)
-            this.presentation_info['newrow_' + sect_id] = new Array();
-            break;
-        }
-    }
-
-    // Refresh GUI
-    this.update_active_heading_list();
-    this.update_headingbox();
-
-    // select what was selected before
-    this.headingscontrol.get(0).value = headingIndex;
-};
-
-PresentationControls.prototype.insert_row_command = function(arr, i, sect_id) {
-    arr.splice(i, 0, {level:1,
-                      name:"New row",
-                      tag:"row",
-                      sect_id:"newrow_" + sect_id
-                     });
-};
-
-
-PresentationControls.prototype.insert_column = function() {
-    // Insert a new row command into outline above selected item
-    var headingIndex = this.get_heading_index();
-    if (headingIndex == null) return;
-    var sect_id = this.active_heading_list[headingIndex].sect_id;
-    if (sect_id.match(/^newrow_/) || sect_id.match(/^newcol_/)) {
-        alert("Can't insert new column here");
-        return;
-    }
-
-    for (var i=0; i < this.stored_headings.length; i++) {
-        if (this.stored_headings[i].sect_id == sect_id) {
-            // Update the headings:
-            this.insert_column_command(this.stored_headings, i, sect_id);
-            // Update presentation info:
-            // An empty array will do, don't actually need a
-            // command in there (and the GUI will overwrite any
-            // anything we put in it)
-            this.presentation_info['newcol_' + sect_id] = new Array();
-            break;
-        }
-    }
-    // Refresh GUI
-    this.update_active_heading_list();
-    this.update_headingbox();
-
-    // select what was selected before
-    this.headingscontrol.get(0).value = headingIndex;
-};
-
-PresentationControls.prototype.insert_column_command = function(arr, i, sect_id) {
-    arr.splice(i, 0, {level:1,
-                      name:"New column",
-                      tag:"column",
-                      sect_id:"newcol_" + sect_id
-                     });
-};
-
-PresentationControls.prototype.remove_layout_command = function() {
-    var headingIndex = this.get_heading_index();
-    if (headingIndex == null) return;
-    var sect_id = this.active_heading_list[headingIndex].sect_id;
-    if (!sect_id.match(/^newrow_/) && !sect_id.match(/^newcol_/)) {
-        alert("Can only use 'remove' on new row or column commands");
-        return;
-    }
-    // Update heading list
-    this.stored_headings.splice(headingIndex, 1);
-    // Update presentation info
-    delete this.presentation_info[sect_id];
-    // Refresh GUI
-    this.update_active_heading_list();
-    this.update_headingbox();
-
-    if (headingIndex > 0) {
-        this.headingscontrol.get(0).value = headingIndex - 1;
-    }
-};
-
 PresentationControls.prototype.clean_html = function() {
     var self = this;
     var html = this.wym.xhtml();
     this.errorbox.append(escapeHtml(message));
 };
 
-PresentationControls.prototype.refresh_headings = function() {
-    var self = this;
-    var html = this.wym.xhtml();
-    jQuery.post(this.opts.extract_structure_url, { 'html':html },
-        function(data) {
-            self.with_good_data(data, function(value) {
-                self.stored_headings = value;
-                self.add_layout_to_headings();
-                self.update_active_heading_list();
-                self.update_headingbox();
-                self.update_all_style_display();
-            });
-        }, "json");
-};
-
-PresentationControls.prototype.add_layout_to_headings = function() {
-    // Row/Column info is transmitted as part of presentation info
-    // but it is displayed in the headings list, because it represents
-    // divs that are inserted (and can be styled).  So we need to
-    // update this.stored_headings using this.presentation_info
-    var first_sect_id;
-    if (this.stored_headings.length > 0) {
-        first_sect_id = this.stored_headings[0].sect_id;
-    } else {
-        first_sect_id = '';
-    }
-    for (var i = 0; i < this.stored_headings.length; i++) {
-        // Loop through, if any have corresponding newrow or newcol
-        // entries, then add them into list.
-        var sect_id = this.stored_headings[i].sect_id;
-        if (this.presentation_info['newrow_' + sect_id] != null) {
-            this.insert_row_command(this.stored_headings, i, sect_id);
-            i++;
-        }
-        if (this.presentation_info['newcol_' + sect_id] != null) {
-            this.insert_column_command(this.stored_headings, i, sect_id);
-            i++;
-        }
-    }
-
-    if (this.stored_headings.length > 0) {
-        // If after this process we don't have newrow and newcol commands
-        // at the beginning of the heading list, we add them.
-        if (this.stored_headings[0].tag != 'row') {
-            this.insert_row_command(this.stored_headings, 0, first_sect_id);
-        }
-        if (this.stored_headings[1].tag != 'column') {
-            this.insert_column_command(this.stored_headings, 1, first_sect_id);
-        }
-    }
-
-};
-
-
-PresentationControls.prototype.update_active_heading_list = function() {
-    var self = this;
-    var items;
-    if (this.headingsfilter.get(0).checked) {
-        items = jQuery.grep(self.stored_headings,
-                            function(item, idx) {
-                                return (item.tag.toUpperCase()).match(/H\d/);
-                            });
-    } else {
-        items = self.stored_headings;
-    }
-    self.active_heading_list = items;
-};
-
-PresentationControls.prototype.update_headingbox = function() {
-    var self = this;
-    this.headingscontrol.empty();
-    jQuery.each(this.active_heading_list, function(i, item) {
-                    var spaces = (new Array((item.level - 1)*3)).join("&nbsp;");
-                    var caption = "";
-                    var tag = item.tag.toLowerCase();
-                    if (tag == 'row' || tag == 'column') {
-                        caption = escapeHtml(item.name);
-                    } else {
-                        caption = tag + ": " + escapeHtml(item.name);
-                    }
-                    self.headingscontrol.append("<option class ='" + tag + "' value='" + i.toString() + "'>" + spaces + caption + "</option>");
-    });
-};
-
 PresentationControls.prototype.retrieve_styles = function() {
     // Retrieve via AJAX
     var self = this;
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.