dojox/editor/plugins/PageBreak.js

  • Provides:

    • dojox.editor.plugins.PageBreak
  • dojox.editor.plugins.PageBreak

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

    • summary
  • dojox.editor.plugins.PageBreak.iconClassPrefix

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

    • tags: private
    • type
      Array
    • summary
      The nodes that should not allow page breaks to be inserted into them.
  • dojox.editor.plugins.PageBreak._pbContent

    • tags: private
    • type
      String
    • summary
      The markup used for the pagebreak insert.
  • dojox.editor.plugins.PageBreak._initButton

    • type
      Function
    • source: [view]
        var ed = this.editor;
        var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "PageBreak");
        this.button = new dijit.form.Button({
         label: strings["pageBreak"],
         showLabel: false,
         iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "PageBreak",
         tabIndex: "-1",
         onClick: dojo.hitch(this, "_insertPageBreak")
        });
        ed.onLoadDeferred.addCallback(
         dojo.hitch(this, function(){
          //Register our hotkey to CTRL-SHIFT-ENTER.
          ed.addKeyHandler(dojo.keys.ENTER, true, true, dojo.hitch(this, this._insertPageBreak));
          if(dojo.isWebKit || dojo.isOpera){
           // Webkit and Opera based browsers don't generate keypress events when ctrl and shift are
           // held then enter is pressed. Odd, that.
           this.connect(this.editor, "onKeyDown", dojo.hitch(this, function(e){
            if((e.keyCode === dojo.keys.ENTER) && e.ctrlKey && e.shiftKey){
             this._insertPageBreak();
            }
           }));
          }
         })
        );
    • summary
      Over-ride for creation of the resize button.
  • dojox.editor.plugins.PageBreak.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.PageBreak.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.PageBreak._style

    • type
      Function
    • source: [view]
        if(!this._styled){
         this._styled = true;
         var doc = this.editor.document;
         var style = ".dijitEditorPageBreak {\n" +
          "\tborder-top-style: solid;\n" +
          "\tborder-top-width: 3px;\n" +
          "\tborder-top-color: #585858;\n" +
          "\tborder-bottom-style: solid;\n" +
          "\tborder-bottom-width: 1px;\n" +
          "\tborder-bottom-color: #585858;\n" +
          "\tborder-left-style: solid;\n" +
          "\tborder-left-width: 1px;\n" +
          "\tborder-left-color: #585858;\n" +
          "\tborder-right-style: solid;\n" +
          "\tborder-right-width: 1px;\n" +
          "\tborder-right-color: #585858;\n" +
          "\tcolor: #A4A4A4;\n" +
          "\tbackground-color: #A4A4A4;\n" +
          "\theight: 10px;\n"+
          "\tpage-break-after: always;\n" +
          "\tpadding: 0px 0px 0px 0px;\n" +
         "}\n\n" +
         "@media print {\n" +
          "\t.dijitEditorPageBreak { page-break-after: always; " +
          "background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); " +
          "border: 0px none rgba(0,0,0,0); display: hidden; " +
          "width: 0px; height: 0px;}\n" +
         "}";


         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;
         }
        }
    • summary
      Internal function for inserting dynamic css.  This was originally
      in an editor.onLoadDeferred, but I ran into issues in Chrome with
      the tag being ignored.  Having it done at insert worked better.
    • tags:
  • dojox.editor.plugins.PageBreak._insertPageBreak

    • type
      Function
    • source: [view]
        try{
         if(!this._styled){ this._style(); }
         //this.editor.focus();
         if(this._allowBreak()){
          this.editor.execCommand("inserthtml", this._pbContent);
         }
        }catch(e){
         console.warn(e);
        }
    • summary
      Function to insert a CSS page break at the current point in the document
    • tags:
  • dojox.editor.plugins.PageBreak._allowBreak

    • type
      Function
    • source: [view]
        var ed = this.editor;
        var doc = ed.document;
        var node = ed._sCall("getSelectedElement", null) || ed._sCall("getParentElement", null);
        while(node && node !== doc.body && node !== doc.html){
         if(ed._sCall("isTag", [node, this._unbreakableNodes])){
          return false;
         }
         node = node.parentNode;
        }
        return true;
    • summary
      Internal function to see if we should allow a page break at the document
      location.
    • tags:
  • dojox.editor.plugins.PageBreak.button

    • summary
  • dojox.editor.plugins.PageBreak.editor

    • summary
  • dojox.editor.plugins.PageBreak.setEditor.editor

    • type
      Object
    • summary
      The editor to configure for this plugin to use.
  • dojox.editor.plugins.PageBreak._styled

    • summary
  • name

    • summary
  • o.plugin

    • summary
  • dojox.editor.plugins

    • type
      Object
    • summary
  • dojox.editor

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary