• Jump To … +
    Arte.js Commands.js Configuration.js PluginManager.js TextArea.js Util.js jquery-dom-cleanup.js jquery-dom-manipulation.js jquery-dom-traversal.js rangy-blockElementApplier.js rangy-elementApplierOptions.js rangy-extensions.js rangy-inlineElementApplier.js richtextCommandApplier.js InsertCommand.js StateDetector.js UndoManager.js keyboardEventHandler.js pasteHandler.js Button.js ButtonWithDialog.js ButtonWithDropDown.js Configuration.js SelectionManager.js toolbar.js
  • rangy-elementApplierOptions.js

  • ¶
    (function($) {
        $.Arte = $.Arte || {};
        $.Arte.ElementApplierOptions = function(initOptions) {
            if (initOptions._isProcessed) {
  • ¶

    Options object is already processed

                return initOptions;
            }
    
            var constants = $.Arte.constants;
            this.tagName = "";
            this.topEditableParent = "";
            this.commandName = "";
            this.commandAttrType = initOptions.commandAttrType;
            this.textArea = null;
            switch (this.commandAttrType) {
                case constants.commandAttrType.className:
                    this.classNameRegex = "";
                    this.className = "";
                    break;
                case constants.commandAttrType.styleName:
                    this.styleName = "";
                    this.styleValue = "";
                    break;
            }
    
            for (var prop in initOptions) {
                this[prop] = initOptions[prop];
            }
    
            if (this.tagName) {
                this.tagName = $("<" + this.tagName + ">").prop("tagName");
            }
    
            this.attr = {};
            if (this.commandAttrType == constants.commandAttrType.className) {
                this.attr["class"] = this.className;
            }
    
            if (this.commandAttrType == constants.commandAttrType.styleName) {
  • ¶

    Construct a style string, so that we can easily apply/remove this from an element

                var div = $("<div>").css(this.styleName, this.styleValue);
                this.attr.style = div[0].style.cssText;
            }
    
            if (!this.commandName) {
                var commandConfig = $.Arte.util.getCommandConfig(this);
                if (commandConfig) {
                    this.commandName = commandConfig.commandName;
                    this.commandAttrType = commandConfig.commandAttrType;
                }
            }
  • ¶

    Adding a field so that we don’t do this multiple times.

            this._isProcessed = true;
        };
    })(jQuery);