// Licensed Materials - Property of IBM // // IBM Cognos Products: cclcore // // (C) Copyright IBM Corp. 2012 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. dojo.provide("bidi.dojo.editor.Editor"); dojo.require("dijit.Editor"); dojo.declare( "bidi.dojo.editor.Editor", dijit.Editor, { _userList: false, textDir: "", constructor: function(params){ if (params.plugins){ this._userList = true; } }, postCreate: function(){ var direction = dojo.getComputedStyle(this.domNode).direction; if (!this._userList){ if ("ltr" == direction){ this.plugins=["undo","redo","|","cut","copy","paste","|","bold","italic","underline","strikethrough","|", "insertOrderedList","insertUnorderedList","indent","outdent","|","justifyLeft","justifyCenter","justifyRight","justifyFull" ]; } else if ("rtl" == direction){ this.plugins=["undo","redo","|","cut","copy","paste","|","bold","italic","underline","strikethrough","|", "insertOrderedList","insertUnorderedList","indent","outdent","|","justifyRight","justifyCenter","justifyLeft","justifyFull" ]; } } this.inherited(arguments); this._setTextDir(); }, execCommand: function(cmd){ // summary: // Main handler for executing any commands to the editor, like paste, bold, etc. // Overrides dijit.Editor.execCommand(). var implFunc = "_" + cmd + "Impl"; if(this.customUndo && (cmd=='undo' || cmd=='redo')){ return this[cmd](); } else{ var r; if(this[implFunc]){ if(this.customUndo){ this.endEditing(); this._beginEditing(); } r = this[implFunc](arguments); if(this.customUndo){ this._endEditing(); } } else{ r = this.inherited('execCommand', arguments); } return r; } }, _setTextDir: function(){ if (this.editNode){ dojo.attr(this.editNode, "dir", (this.isTextDirLeftToRight()? "ltr" : "rtl")); } }, isTextDirLeftToRight: function(){ // summary: // Returns default text direction. // Default text direction is defined by textDir attribute provided that it contains one of // "ltr" or "rtl" values. In other cases default text direction is the same, as orientation // of the editor. if(!this.textDir){ return this._isLeftToRight(); } var textDir = this.textDir.toUpperCase(); if (textDir == "LTR"){ return true; }else if(textDir == "RTL"){ return false; }else{ return this.isLeftToRight(); } }, _isLeftToRight: function(){ if (!this.editNode){ return true; } var direction = dojo.getComputedStyle(this.domNode).direction; return ("ltr" == direction); } } );