dojox/editor/plugins/TextColor.js

  • Provides:

    • dojox.editor.plugins.TextColor
  • dojox.editor.plugins._TextColorDropDown

    • type
      Function
    • chains:
      • dijit._Widget: (prototype)
      • dijit._Widget: (call)
      • dijit._Templated: (call)
    • mixins:
      • dijit._Templated.prototype: (prototype)
    • summary
      Constructor over-ride so that the translated strings are mixsed in so
      the template fills out.
    • source: [view]
        var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "TextColor");
        dojo.mixin(this, strings);
  • dojox.editor.plugins._TextColorDropDown.templateString

    • type
      String
    • summary
      The template used to create the ColorPicker.
  • dojox.editor.plugins._TextColorDropDown.widgetsInTemplate

    • type
      Boolean
    • summary
      Flag denoting widgets are contained in the template.
  • dojox.editor.plugins._TextColorDropDown.startup

    • type
      Function
    • source: [view]
        if(!this._started){
         this.inherited(arguments);
         this.connect(this._setButton, "onClick", dojo.hitch(this, function(){
          this.onChange(this.get("value"));
         }));
         this.connect(this._cancelButton, "onClick", dojo.hitch(this, function(){
          dijit.popup.close(this.dialog);
          this.onCancel();
         }));
         // Fully statred, so go ahead and remove the hide.
         dojo.style(this.domNode, "display", "block");
        }
    • summary
      Over-ride of startup to do the basic connect setups and such.
  • dojox.editor.plugins._TextColorDropDown._setValueAttr

    • type
      Function
    • parameters:
      • value: (typeof String)
        The value to set in the color picker
      • priorityChange: (typeof Value)
        to indicate whether or not to trigger an onChange event.
    • source: [view]
        this._colorPicker.set("value", value, priorityChange);
    • summary
      Passthrough function for the color picker value.
  • dojox.editor.plugins._TextColorDropDown._getValueAttr

    • type
      Function
    • source: [view]
        return this._colorPicker.get("value");
    • summary
      Passthrough function for the color picker value.
  • dojox.editor.plugins._TextColorDropDown.onChange

    • type
      Function
    • parameters:
      • value: (typeof String)
        The value from the color picker.
    • source: [view]
        // summary:
        //  Hook point to get the value when the color picker value is selected.
        // value: String
        //  The value from the color picker.
    • summary
      Hook point to get the value when the color picker value is selected.
  • dojox.editor.plugins._TextColorDropDown.onCancel

    • type
      Function
    • source: [view]
        // summary:
        //  Hook point to get when the dialog is canceled.
    • summary
      Hook point to get when the dialog is canceled.
  • dojox.editor.plugins.TextColor

    • type
      Function
    • chains:
      • dijit._editor._Plugin: (prototype)
      • dijit._editor._Plugin: (call)
    • summary
      This plugin provides dropdown color pickers for setting text color and background color
      and makes use of the nicer-looking (though not entirely accessible), dojox.widget.ColorPicker.
    • description
      The commands provided by this plugin are:
      * foreColor - sets the text color
      * hiliteColor - sets the background color
      
      Override _Plugin.buttonClass to use DropDownButton (with ColorPalette) to control this plugin
    • source: [view]
        this._picker = new dojox.editor.plugins._TextColorDropDown();
        dojo.body().appendChild(this._picker.domNode);
        this._picker.startup();
        this.dropDown = this._picker.dialog;
        this.connect(this._picker, "onChange", function(color){
         this.editor.execCommand(this.command, color);
        });
        this.connect(this._picker, "onCancel", function(){
         this.editor.focus();
        });
  • dojox.editor.plugins.TextColor.buttonClass

    • summary
  • dojox.editor.plugins.TextColor.useDefaultCommand

    • type
      Boolean
    • summary
      False as we do not use the default editor command/click behavior.
  • dojox.editor.plugins.TextColor.updateState

    • type
      Function
    • source: [view]
        var _e = this.editor;
        var _c = this.command;
        if(!_e || !_e.isLoaded || !_c.length){
         return;
        }

        
        var disabled = this.get("disabled");

        
        var value;
        if(this.button){
         this.button.set("disabled", disabled);
         if(disabled){
          return;
         }
         try{
          value = _e.queryCommandValue(_c)|| "";
         }catch(e){
          //Firefox may throw error above if the editor is just loaded, ignore it
          value = "";
         }
        }

        
        if(value == ""){
         value = "#000000";
        }
        if(value == "transparent"){
         value = "#ffffff";
        }


        if(typeof value == "string"){
         //if RGB value, convert to hex value
         if(value.indexOf("rgb")> -1){
          value = dojo.colorFromRgb(value).toHex();
         }
        }else{ //it's an integer(IE returns an MS access #)
         value =((value & 0x0000ff)<< 16)|(value & 0x00ff00)|((value & 0xff0000)>>> 16);
         value = value.toString(16);
         value = "#000000".slice(0, 7 - value.length)+ value;

         
        }

        
        if(value !== this._picker.get('value')){
         this._picker.set('value', value, false);
        }
    • summary
      Overrides _Plugin.updateState().  This updates the ColorPalette
      to show the color of the currently selected text.
    • tags:
    • returns
      it's an integer(IE returns an MS access #)
  • dojox.editor.plugins.TextColor.destroy

    • type
      Function
    • source: [view]
        this.inherited(arguments);
        this._picker.destroyRecursive();
        delete this._picker;
    • summary
      Over-ride cleanup function.
  • dojox.editor.plugins.TextColor._picker

    • summary
  • dojox.editor.plugins.TextColor.dropDown

    • summary
  • this

    • mixins:
      • strings: (normal)
    • summary
  • o.plugin

    • summary
  • dojox.editor.plugins

    • type
      Object
    • summary
  • dojox.editor

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary