dojox/editor/plugins/Save.js

  • Provides:

    • dojox.editor.plugins.Save
  • dojox.editor.plugins.Save

    • type
      Function
    • chains:
      • dijit._editor._Plugin: (prototype)
      • dijit._editor._Plugin: (call)
    • summary
      This plugin provides Save cabability to the editor.  When
      clicked, the document in the editor frame will be osted to the URL
      provided, or none, if none provided.  Users who desire a different save
      function can extend this plugin (via dojo.extend) and over-ride the
      save method	while save is in process, the save button is disabled.
  • dojox.editor.plugins.Save.iconClassPrefix

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

    • summary
  • dojox.editor.plugins.Save.logResults

    • summary
  • dojox.editor.plugins.Save._initButton

    • type
      Function
    • source: [view]
        var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "Save");
        this.button = new dijit.form.Button({
         label: strings["save"],
         showLabel: false,
         iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "Save",
         tabIndex: "-1",
         onClick: dojo.hitch(this, "_save")
        });
    • summary
      Over-ride for creation of the save button.
  • dojox.editor.plugins.Save.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.Save.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.Save._save

    • type
      Function
    • source: [view]
        var content = this.editor.get("value");
        this.save(content);
    • summary
      Function to trigger saving of the editor document
    • tags:
  • dojox.editor.plugins.Save.save

    • type
      Function
    • parameters:
      • content: (typeof )
    • source: [view]
      define("dojox/editor/plugins/Save", ["dojo", "dijit", "dojox", "dijit/form/Button", "dijit/_editor/_Plugin", "dojo/i18n", "i18n!dojox/editor/plugins/nls/Save"], function(dojo, dijit, dojox) {


      dojo.declare("dojox.editor.plugins.Save",dijit._editor._Plugin,{
       // summary:
       //  This plugin provides Save cabability to the editor. When
       //  clicked, the document in the editor frame will be osted to the URL
       //  provided, or none, if none provided. Users who desire a different save
       //  function can extend this plugin (via dojo.extend) and over-ride the
       //  save method while save is in process, the save button is disabled.


       // iconClassPrefix: [const] String
       //  The CSS class name for the button node is formed from `iconClassPrefix`
       //  and `command`
       iconClassPrefix: "dijitAdditionalEditorIcon",


       // url [public] String
       //  The URL to POST the content back to. Used by the save function.
       url: "",


       // logErrors [public] boolean
       //  Boolean flag to indicate that the default action for save and
       //  error handlers is to just log to console. Default is true.
       logResults: true,


       _initButton: function(){
        // summary:
        //  Over-ride for creation of the save button.
        var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "Save");
        this.button = new dijit.form.Button({
         label: strings["save"],
         showLabel: false,
         iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "Save",
         tabIndex: "-1",
         onClick: dojo.hitch(this, "_save")
        });
       },

       
       updateState: function(){
        // summary:
        //  Over-ride for button state control for disabled to work.
        this.button.set("disabled", this.get("disabled"));
       },


       setEditor: function(editor){
        // summary:
        //  Over-ride for the setting of the editor.
        // editor: Object
        //  The editor to configure for this plugin to use.
        this.editor = editor;
        this._initButton();
       },


       _save: function(){
        // summary:
        //  Function to trigger saving of the editor document
        // tags:
        //  private
        var content = this.editor.get("value");
        this.save(content);
       },


       save: function(content){
        // summary:
        //  User over-ridable save function for the editor content.
        //  Please note that the service URL provided should do content
        //  filtering of the posted content to avoid XSS injection via
        //  the data from the editor.
        // tags:
        //  public


        // Set the default header to post as a body of text/html.
        var headers = {
         "Content-Type": "text/html"
        };
        if(this.url){
         var postArgs = {
          url: this.url,
          postData: content,
          headers: headers,
          handleAs: "text"
         };
         this.button.set("disabled", true);
         var deferred = dojo.xhrPost(postArgs);
         deferred.addCallback(dojo.hitch(this, this.onSuccess));
         deferred.addErrback(dojo.hitch(this, this.onError));
        }else{
         console.log("No URL provided, no post-back of content: " + content);
        }
    • summary
      User over-ridable save function for the editor content.
      Please note that the service URL provided should do content
      filtering of the posted content to avoid XSS injection via
      the data from the editor.
  • dojox.editor.plugins.Save.onSuccess

    • type
      Function
    • parameters:
      • resp: (typeof The)
        response from the server, if any, in text format.
      • ioargs: (typeof )
    • source: [view]
        this.button.set("disabled", false);
        if(this.logResults){
         console.log(resp);
        }
    • summary
      User over-ridable save success function for editor content.
      Be sure to call this.inherited(arguments) if over-riding this method.
    • tags:
  • dojox.editor.plugins.Save.onError

    • type
      Function
    • parameters:
      • error: (typeof )
      • ioargs: (typeof )
    • source: [view]
        this.button.set("disabled", false);
        if(this.logResults){
         console.log(error);
        }
    • summary
      User over-ridable save success function for editor content.
      Be sure to call this.inherited(arguments) if over-riding this method.
      resp:
      The response from the server, if any, in text format.
    • tags:
  • dojox.editor.plugins.Save.button

    • summary
  • dojox.editor.plugins.Save.editor

    • summary
  • dojox.editor.plugins.Save.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