[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/yui_editor/plugins/ -> coder.js (source)

   1  // $Id: coder.js,v 1.1.2.5.2.1 2008/11/21 22:54:27 jeffcd Exp $
   2  
   3  function yui_editor_coder() {
   4    for (var e in YAHOO.Drupal.editors) {
   5      var myEditor = YAHOO.Drupal.editors[e].editor;
   6      var config = YAHOO.Drupal.editors[e].config;
   7  
   8      var coderState = 'off';
   9      if (config.coder == 1) {
  10        myEditor.on('toolbarLoaded', function() {
  11          var Dom = YAHOO.util.Dom;
  12          var codeConfig = {
  13            type: 'push', label: 'Edit HTML Code', value: 'editcode'
  14          };
  15          this.toolbar.addButtonToGroup(codeConfig, 'plugins');
  16  
  17          this.toolbar.on('editcodeClick', function(ev) {
  18            var ta = this.get('element'),
  19              iframe = this.get('iframe').get('element');
  20  
  21            if (coderState == 'on') {
  22              coderState = 'off';
  23              this.toolbar.set('disabled', false);
  24              this.setEditorHTML(ta.value);
  25              if (!this.browser.ie) {
  26                this._setDesignMode('on');
  27              }
  28  
  29              Dom.removeClass(iframe, 'editor-hidden');
  30              Dom.addClass(ta, 'editor-hidden');
  31              this.show();
  32              this._focusWindow();
  33            }
  34            else {
  35              coderState = 'on';
  36              this.cleanHTML();
  37              Dom.addClass(iframe, 'editor-hidden');
  38              Dom.removeClass(ta, 'editor-hidden');
  39              this.toolbar.set('disabled', true);
  40              this.toolbar.getButtonByValue('editcode').set('disabled', false);
  41              this.toolbar.selectButton('editcode');
  42              this.dompath.innerHTML = 'Editing HTML Code';
  43              Dom.setStyle(this.get('element'), 'border', '0px');
  44              this.hide();
  45            }
  46  
  47            return false;
  48          }, this, true);
  49  
  50          this.on('cleanHTML', function(ev) {
  51            this.get('element').value = ev.html;
  52          }, this, true);
  53  
  54          this.on('afterRender', function() {
  55            var wrapper = this.get('editor_wrapper');
  56            wrapper.appendChild(this.get('element'));
  57            this.setStyle('width', '100%');
  58            this.setStyle('height', '100%');
  59            this.setStyle('visibility', '');
  60            this.setStyle('top', '');
  61            this.setStyle('left', '');
  62            this.setStyle('position', '');
  63  
  64            this.addClass('editor-hidden');
  65          }, this, true);
  66        }, myEditor, true);
  67      }
  68  
  69      var toggle = 'off';
  70      $('#toggleEditor-'+id).bind('click', function () { toggle = 'on'; });
  71      $('form').bind('submit', function (e) {
  72        if (toggle == 'on') {
  73          toggle = 'off';
  74          return false;
  75        }
  76        else if (coderState == 'on') {
  77          myEditor.setEditorHTML(myEditor.get('textarea').value);
  78        }
  79        else {
  80          myEditor.saveHTML();
  81        }
  82      });
  83    }
  84  }
  85  YAHOO.Drupal.yui_editor_load.subscribe(yui_editor_coder);


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7