| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 // $Id: plaintext.js,v 1.1.2.3.2.1 2008/11/21 22:54:27 jeffcd Exp $ 2 3 function yui_editor_plaintext() { 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 var id = YAHOO.Drupal.editors[e].id; 8 9 myEditor.plaintextState = 'off'; 10 if (config.plaintext == 1) { 11 $("#"+id).after("<button id=\"toggleEditor-"+id+"\">"+ Drupal.t('Switch to Plain Editor') +"</button>"); 12 var _button = new YAHOO.widget.Button('toggleEditor-'+id); 13 _button.addClass('toggleEditor'); 14 15 _button.on('click', function(ev, myEditor) { 16 var Event = YAHOO.util.Event; 17 var Dom = YAHOO.util.Dom; 18 19 Event.stopEvent(ev); 20 if (myEditor.plaintextState == 'off') { 21 myEditor.plaintextState = 'on'; 22 myEditor.saveHTML(); 23 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'position', 'absolute'); 24 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'top', '-9999px'); 25 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'left', '-9999px'); 26 myEditor.get('element_cont').removeClass('yui-editor-container'); 27 Dom.setStyle(myEditor.get('element'), 'visibility', 'visible'); 28 Dom.setStyle(myEditor.get('element'), 'top', ''); 29 Dom.setStyle(myEditor.get('element'), 'left', ''); 30 Dom.setStyle(myEditor.get('element'), 'position', 'static'); 31 _button.set("label", Drupal.t('Switch to Rich Text Editor')); 32 $(".grippie").show(); 33 $(".teaser-checkbox").show(); 34 } 35 else { 36 myEditor.plaintextState = 'off'; 37 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'position', 'static'); 38 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'top', '0'); 39 Dom.setStyle(myEditor.get('element_cont').get('firstChild'), 'left', '0'); 40 Dom.setStyle(myEditor.get('element'), 'visibility', 'hidden'); 41 Dom.setStyle(myEditor.get('element'), 'top', '-9999px'); 42 Dom.setStyle(myEditor.get('element'), 'left', '-9999px'); 43 Dom.setStyle(myEditor.get('element'), 'position', 'absolute'); 44 myEditor.get('element_cont').addClass('yui-editor-container'); 45 myEditor._setDesignMode('on'); 46 myEditor.setEditorHTML(myEditor.get('textarea').value); 47 _button.set("label", Drupal.t('Switch to Plain Editor')); 48 $(".grippie").hide(); 49 $(".teaser-checkbox").hide(); 50 } 51 }, myEditor); 52 } 53 54 var toggle = 'off'; 55 $('#toggleEditor-'+id).bind('click', function () { toggle = 'on'; }); 56 $('form').bind('submit', function (e) { 57 if (toggle == 'on') { 58 toggle = 'off'; 59 return false; 60 } 61 else if (myEditor.plaintextState == 'on') { 62 myEditor.setEditorHTML(myEditor.get('textarea').value); 63 } 64 else { 65 myEditor.saveHTML(); 66 } 67 }); 68 } 69 } 70 YAHOO.Drupal.yui_editor_load.subscribe(yui_editor_plaintext);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |