dojox/editor/plugins/ShowBlockNodes.js

  • Provides:

    • dojox.editor.plugins.ShowBlockNodes
  • dojox.editor.plugins.ShowBlockNodes

    • type
      Function
    • chains:
      • dijit._editor._Plugin: (prototype)
      • dijit._editor._Plugin: (call)
    • summary
  • dojox.editor.plugins.ShowBlockNodes.useDefaultCommand

    • summary
  • dojox.editor.plugins.ShowBlockNodes.iconClassPrefix

    • tags: const
    • type
      String
    • summary
      The CSS class name for the button node is formed from `iconClassPrefix` and `command`
  • dojox.editor.plugins.ShowBlockNodes._styled

    • summary
  • dojox.editor.plugins.ShowBlockNodes._initButton

    • type
      Function
    • source: [view]
        var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "ShowBlockNodes");
        this.button = new dijit.form.ToggleButton({
         label: strings["showBlockNodes"],
         showLabel: false,
         iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "ShowBlockNodes",
         tabIndex: "-1",
         onChange: dojo.hitch(this, "_showBlocks")
        });
        this.editor.addKeyHandler(dojo.keys.F9, true, true, dojo.hitch(this, this.toggle));
    • summary
      Over-ride for creation of the preview button.
  • dojox.editor.plugins.ShowBlockNodes.updateState

    • type
      Function
    • source: [view]
        this.button.set("disabled", this.get("disabled"));
    • summary
      Over-ride for button state control for disabled to work.
  • dojox.editor.plugins.ShowBlockNodes.setEditor

    • type
      Function
    • parameters:
      • editor: (typeof Object)
        The editor to configure for this plugin to use.
    • source: [view]
        this.editor = editor;
        this._initButton();
    • summary
      Over-ride for the setting of the editor.
  • dojox.editor.plugins.ShowBlockNodes.toggle

    • type
      Function
    • source: [view]
        this.button.set("checked", !this.button.get("checked"));
    • summary
      Function to allow programmatic toggling of the view.
  • dojox.editor.plugins.ShowBlockNodes._showBlocks

    • type
      Function
    • parameters:
      • show: (typeof )
    • source: [view]
        var doc = this.editor.document;
        if(!this._styled){
         try{
          //Attempt to inject our specialized style rules for doing this.
          this._styled = true;


          var style = "";
          var blocks = ["div", "p", "ul", "ol", "table", "h1",
           "h2", "h3", "h4", "h5", "h6", "pre", "dir", "center",
           "blockquote", "form", "fieldset", "address", "object",
           "pre", "hr", "ins", "noscript", "li", "map", "button",
           "dd", "dt"];


          var template = "@media screen {\n" +
            "\t.editorShowBlocks {TAG} {\n" +
            "\t\tbackground-image: url({MODURL}/images/blockelems/{TAG}.gif);\n" +
            "\t\tbackground-repeat: no-repeat;\n" +
            "\t\tbackground-position: top left;\n" +
            "\t\tborder-width: 1px;\n" +
            "\t\tborder-style: dashed;\n" +
            "\t\tborder-color: #D0D0D0;\n" +
            "\t\tpadding-top: 15px;\n" +
            "\t\tpadding-left: 15px;\n" +
           "\t}\n" +
          "}\n";


          dojo.forEach(blocks, function(tag){
           style += template.replace(/\{TAG\}/gi, tag);
          });


          //Finally associate in the image locations based off the module url.
          var modurl = dojo.moduleUrl(dojox._scopeName, "editor/plugins/resources").toString();
          if(!(modurl.match(/^https?:\/\//i)) &&
           !(modurl.match(/^file:\/\//i))){
           // We have to root it to the page location on webkit for some nutball reason.
           // Probably has to do with how iframe was loaded.
           var bUrl;
           if(modurl.charAt(0) === "/"){
            //Absolute path on the server, so lets handle...
            var proto = dojo.doc.location.protocol;
            var hostn = dojo.doc.location.host;
            bUrl =  proto + "//" + hostn;
           }else{
            bUrl = this._calcBaseUrl(dojo.global.location.href);
           }
           if(bUrl[bUrl.length - 1] !== "/" && modurl.charAt(0) !== "/"){
            bUrl += "/";
           }
           modurl = bUrl + modurl;
          }
          // Update all the urls.
          style = style.replace(/\{MODURL\}/gi, modurl);
          if(!dojo.isIE){
           var sNode = doc.createElement("style");
           sNode.appendChild(doc.createTextNode(style));
           doc.getElementsByTagName("head")[0].appendChild(sNode);
          }else{
           var ss = doc.createStyleSheet("");
           ss.cssText = style;
          }
         }catch(e){
          console.warn(e);
         }
        }


        // Apply/remove the classes based on state.
        if(show){
         dojo.addClass(this.editor.editNode, "editorShowBlocks");
        }else{
         dojo.removeClass(this.editor.editNode, "editorShowBlocks");
        }
    • summary
      Function to trigger printing of the editor document
    • tags:
  • dojox.editor.plugins.ShowBlockNodes._calcBaseUrl

    • type
      Function
    • parameters:
      • fullUrl: (typeof String)
        The full url to tear down to the base.
    • source: [view]
        var baseUrl = null;
        if (fullUrl !== null) {
         // Check to see if we need to strip off any query parameters from the Url.
         var index = fullUrl.indexOf("?");
         if (index != -1) {
          fullUrl = fullUrl.substring(0,index);
         }


         // Now we need to trim if necessary. If it ends in /, then we don't
         // have a filename to trim off so we can return.
         index = fullUrl.lastIndexOf("/");
         if (index > 0 && index < fullUrl.length) {
          baseUrl = fullUrl.substring(0,index);
         }else{
          baseUrl = fullUrl;
         }
        }
        return baseUrl; //String
    • summary
      Internal function used to figure out the full root url (no relatives)
      for loading images in the styles in the iframe.
    • tags:
    • returns
      String
  • dojox.editor.plugins.ShowBlockNodes.button

    • summary
  • dojox.editor.plugins.ShowBlockNodes.editor

    • summary
  • dojox.editor.plugins.ShowBlockNodes.setEditor.editor

    • type
      Object
    • summary
      The editor to configure for this plugin to use.
  • name

    • summary
  • o.plugin

    • summary
  • dojox.editor.plugins

    • type
      Object
    • summary
  • dojox.editor

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary