Commits

Luke Plant committed 396a641

Added show style/hide styles toggle.

Comments (0)

Files changed (2)

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

 PresentationControls.prototype.setupControls = function(container) {
     var idPrefix = "id_prescontrol_" + this.name + "_";
     var previewButtonId = idPrefix + 'previewbutton';
+    var showStylesButtonId = idPrefix + 'showstyles';
     var previewBoxId = idPrefix + 'previewbox';
     var cleanHtmlButtonId = idPrefix + 'cleanhtmlbutton';
     var self = this;
         "<div class=\"prescontrol\">" +
             "<input type=\"submit\" value=\"Clean pasted HTML\" id=\"" + cleanHtmlButtonId  +  "\" />" +
             "<input type=\"submit\" value=\"Preview\" id=\"" + previewButtonId + "\" />" +
+            "<input type=\"submit\" id=\"" + showStylesButtonId + "\" />" +
             "<div class=\"prescontrolerror\" id=\"" + idPrefix + "errorbox" + "\"></div>" +
         "</div>");
 
     this.errorBox = jQuery('#' + idPrefix + "errorbox");
     this.previewButton = jQuery('#' + previewButtonId);
     this.previewBox = jQuery('#' + previewBoxId);
+    this.showStylesButton = jQuery('#' + showStylesButtonId);
     this.cleanHtmlButton = jQuery('#' + cleanHtmlButtonId);
 
     this.setupCssStorage();
                               function(event) {
                                   self.previewBox.hide();
                               });
+    // start with styles hidden
+    this.showStyles(false);
+    this.showStylesButton.toggle(function(event) {
+                                     self.showStyles(true);
+                                     return false;
+                                 },
+                                 function(event) {
+                                     self.showStyles(false);
+                                     return false;
+                                 });
     this.cleanHtmlButton.click(function(event) {
                                    self.cleanHtml();
                                    return false;
     return false;
 };
 
+PresentationControls.prototype.showStyles = function(show) {
+    if (show) {
+        jQuery(this.wym._doc).find('#presmodestyles').remove();
+        jQuery(this.wym._iframe.ownerDocument).find('#presmodestyles').remove();
+        this.showStylesButton.attr('value', 'Hide styles');
+    } else {
+        jQuery('<style rel="stylesheet" type="text/css" id="presmodestyles">' +
+               'p.secommand { display:none; } ' +
+               '*:before    { display: none!important; } ' +
+               '*:after     { top: 0!important; } ' +
+               '</style>').appendTo(jQuery(this.wym._doc).find("head"));
+        jQuery('<style rel="stylesheet" type="text/css" id="presmodestyles">' +
+               '.wym_layout_commands, .wym_classes  {display: none!important;} ' +
+               '</style>').appendTo(jQuery(this.wym._iframe.ownerDocument).find("head"));
+        this.showStylesButton.attr('value', 'Show styles');
+    }
+};
+
 // ---- WYMeditor plugin definition ----
 
 // The actual WYMeditor plugin:

semanticeditor/media/semanticeditor/wymeditor/iframe/default/wymiframe.css

 ul li   {list-style: none;}
 ol li   {list-style: decimal;}
 
-/* presentation mode off */
-/*p.secommand {display: none;}
-*:before    {display: none!important;}
-*:after     {top: 0!important;}
-*/
 /* styles for the container and command markers */
 
 p:after,
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.