dojox/editor/plugins/UploadImage.js

  • Provides:

    • dojox.editor.plugins.UploadImage
  • dojox.editor.plugins.UploadImage

    • type
      Function
    • chains:
      • dijit._editor._Plugin: (prototype)
      • dijit._editor._Plugin: (call)
    • summary
      Adds an icon to the Editor toolbar that when clicked, opens a system dialog
      Although the toolbar icon is a tiny "image" the uploader could be used for
      any file type
  • dojox.editor.plugins.UploadImage.tempImageUrl

    • summary
  • dojox.editor.plugins.UploadImage.iconClassPrefix

    • summary
  • dojox.editor.plugins.UploadImage.useDefaultCommand

    • summary
  • dojox.editor.plugins.UploadImage.uploadUrl

    • summary
  • dojox.editor.plugins.UploadImage.button

    • summary
  • dojox.editor.plugins.UploadImage.label

    • summary
  • dojox.editor.plugins.UploadImage.setToolbar

    • type
      Function
    • parameters:
      • toolbar: (typeof )
    • source: [view]
         this.button.destroy();
         this.createFileInput();
         toolbar.addChild(this.button);
    • summary
  • dojox.editor.plugins.UploadImage._initButton

    • type
      Function
    • source: [view]
         this.command = "uploadImage";
         this.editor.commands[this.command] = "Upload Image";
         this.inherited("_initButton", arguments);
         delete this.command;
    • summary
  • dojox.editor.plugins.UploadImage.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.UploadImage.createFileInput

    • type
      Function
    • source: [view]
         var node = dojo.create('span', {innerHTML:"."}, document.body)
         dojo.style(node, {
          width:"40px",
          height:"20px",
          paddingLeft:"8px",
          paddingRight:"8px"
         })
         this.button = new dojox.form.FileUploader({
          isDebug:true,
          //force:"html",
          uploadUrl:this.uploadUrl,
          uploadOnChange:true,
          selectMultipleFiles:false,
          baseClass:"dojoxEditorUploadNorm",
          hoverClass:"dojoxEditorUploadHover",
          activeClass:"dojoxEditorUploadActive",
          disabledClass:"dojoxEditorUploadDisabled"
         }, node);
         this.connect(this.button, "onChange", "insertTempImage");
         this.connect(this.button, "onComplete", "onComplete");
    • summary
  • dojox.editor.plugins.UploadImage.onComplete

    • type
      Function
    • parameters:
      • data: (typeof )
      • ioArgs: (typeof )
      • widgetRef: (typeof )
    • source: [view]
         data = data[0];
         // Image is ready to insert
         var tmpImgNode = dojo.withGlobal(this.editor.window, "byId", dojo, [this.currentImageId]);
         var file;
         // download path is mainly used so we can access a PHP script
         // not relative to this file. The server *should* return a qualified path.
         if(this.downloadPath){
          file = this.downloadPath+data.name
         }else{
          file = data.file;
         }

         
         tmpImgNode.src = file;
         dojo.attr(tmpImgNode,'_djrealurl',file);


         if(data.width){
          tmpImgNode.width = data.width;
          tmpImgNode.height = data.height;
         }
    • summary
  • dojox.editor.plugins.UploadImage.insertTempImage

    • type
      Function
    • source: [view]
      define("dojox/editor/plugins/UploadImage", ["dojo", "dijit", "dojox", "dojox/form/FileUploader", "dijit/_editor/_Plugin"], function(dojo, dijit, dojox) {


      dojo.experimental("dojox.editor.plugins.UploadImage");


      dojo.declare("dojox.editor.plugins.UploadImage",
       dijit._editor._Plugin,
       {
        //summary:
        //  Adds an icon to the Editor toolbar that when clicked, opens a system dialog
        // Although the toolbar icon is a tiny "image" the uploader could be used for
        // any file type

        
        tempImageUrl: "",
        iconClassPrefix: "editorIcon",
        useDefaultCommand: false,
        uploadUrl: "",
        button:null,
        label:"Upload",

        
        setToolbar: function(toolbar){
         this.button.destroy();
         this.createFileInput();
         toolbar.addChild(this.button);
        },
        _initButton: function(){
         this.command = "uploadImage";
         this.editor.commands[this.command] = "Upload Image";
         this.inherited("_initButton", arguments);
         delete this.command;
        },

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

        
        createFileInput: function(){
         var node = dojo.create('span', {innerHTML:"."}, document.body)
         dojo.style(node, {
          width:"40px",
          height:"20px",
          paddingLeft:"8px",
          paddingRight:"8px"
         })
         this.button = new dojox.form.FileUploader({
          isDebug:true,
          //force:"html",
          uploadUrl:this.uploadUrl,
          uploadOnChange:true,
          selectMultipleFiles:false,
          baseClass:"dojoxEditorUploadNorm",
          hoverClass:"dojoxEditorUploadHover",
          activeClass:"dojoxEditorUploadActive",
          disabledClass:"dojoxEditorUploadDisabled"
         }, node);
         this.connect(this.button, "onChange", "insertTempImage");
         this.connect(this.button, "onComplete", "onComplete");
        },

        
        onComplete: function(data,ioArgs,widgetRef){
         data = data[0];
         // Image is ready to insert
         var tmpImgNode = dojo.withGlobal(this.editor.window, "byId", dojo, [this.currentImageId]);
         var file;
         // download path is mainly used so we can access a PHP script
         // not relative to this file. The server *should* return a qualified path.
         if(this.downloadPath){
          file = this.downloadPath+data.name
         }else{
          file = data.file;
         }

         
         tmpImgNode.src = file;
         dojo.attr(tmpImgNode,'_djrealurl',file);


         if(data.width){
          tmpImgNode.width = data.width;
          tmpImgNode.height = data.height;
         }
        },

        
        insertTempImage: function(){
         // inserting a "busy" image to show something is hapening
         // during upload and download of the image.
         this.currentImageId = "img_"+(new Date().getTime());
         var iTxt = '';
         this.editor.execCommand('inserthtml', iTxt);
    • summary
  • dojox.editor.plugins.UploadImage.command

    • summary
  • dojox.editor.plugins.UploadImage.currentImageId

    • summary
  • o.plugin

    • summary
  • dojox.editor.plugins

    • type
      Object
    • summary
  • dojox.editor

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary