[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/layouts/vlayout/modules/Vtiger/resources/ -> CkEditor.js (source)

   1  /*+***********************************************************************************
   2   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   3   * ("License"); You may not use this file except in compliance with the License
   4   * The Original Code is:  vtiger CRM Open Source
   5   * The Initial Developer of the Original Code is vtiger.
   6   * Portions created by vtiger are Copyright (C) vtiger.
   7   * All Rights Reserved.
   8   *************************************************************************************/
   9  jQuery.Class("Vtiger_CkEditor_Js",{},{
  10      
  11      /*
  12       *Function to set the textArea element 
  13       */
  14      setElement : function(element){
  15          this.element = element;
  16          return this;
  17      },
  18      
  19      /*
  20       *Function to get the textArea element
  21       */
  22      getElement : function(){
  23          return this.element;
  24      },
  25      
  26      /*
  27       * Function to return Element's id atrribute value
  28       */
  29      getElementId :function(){
  30          var element = this.getElement();
  31          return element.attr('id');
  32      },
  33      /*
  34       * Function to get the instance of ckeditor
  35       */
  36      
  37      getCkEditorInstanceFromName :function(){
  38          var elementName = this.getElementId();
  39          return CKEDITOR.instances[elementName];
  40      },
  41      
  42      /***
  43       * Function to get the plain text
  44       */
  45      getPlainText : function() {
  46          var ckEditorInstnace = this.getCkEditorInstanceFromName();
  47          return ckEditorInstnace.document.getBody().getText();
  48      },
  49      /*
  50       * Function to load CkEditor
  51       * @params : element: element on which CkEditor has to be loaded, config: custom configurations for ckeditor
  52       */
  53      loadCkEditor : function(element,customConfig){
  54          
  55          this.setElement(element);
  56          var instance = this.getCkEditorInstanceFromName();
  57          var elementName = this.getElementId();
  58          var config = {}
  59          
  60          if(typeof customConfig != 'undefined'){
  61              var config = jQuery.extend(config,customConfig);
  62          }
  63          if(instance)
  64          {
  65              CKEDITOR.remove(instance);
  66          }
  67          
  68          
  69      
  70          CKEDITOR.replace( elementName,config);
  71      },
  72      
  73      /*
  74       * Function to load contents in ckeditor textarea
  75       * @params : textArea Element,contents ;
  76       */
  77      loadContentsInCkeditor : function(contents){
  78          var editor = this.getCkEditorInstanceFromName();
  79          var editorData = editor.getData();
  80          var replaced_text = editorData.replace(editorData, contents); 
  81          editor.setData(replaced_text);    
  82      }
  83  });
  84      


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1