| 1 |
<?php |
| 2 |
class Element_TinyMCE extends Element_Textarea { |
| 3 |
protected $basic; |
| 4 |
|
| 5 |
public function jQueryDocumentReady() { |
| 6 |
echo 'jQuery("#', $this->attributes["id"], '").width(jQuery("#', $this->attributes["id"], '").width());'; |
| 7 |
} |
| 8 |
|
| 9 |
function renderJS() { |
| 10 |
echo <<<JS |
| 11 |
tinyMCE.init({ |
| 12 |
mode: "exact", |
| 13 |
elements: "{$this->attributes["id"]}", |
| 14 |
JS; |
| 15 |
if(empty($this->basic)) { |
| 16 |
echo <<<JS |
| 17 |
theme: "advanced", |
| 18 |
plugins: "safari,table,paste,inlinepopups,preview,fullscreen", |
| 19 |
dialog_type: "modal", |
| 20 |
theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,|,formatselect,fontselect,fontsizeselect", |
| 21 |
theme_advanced_buttons2: "link,unlink,anchor,image,charmap,hr,|,tablecontrols,|,pastetext,pasteword,|,cleanup,code,preview,fullscreen,|,undo,redo", |
| 22 |
theme_advanced_buttons3: "", |
| 23 |
theme_advanced_toolbar_location: "top", |
| 24 |
theme_advanced_toolbar_align : "left", |
| 25 |
theme_advanced_resizing : true, |
| 26 |
JS; |
| 27 |
} |
| 28 |
else |
| 29 |
echo 'theme: "simple",'; |
| 30 |
echo <<<JS |
| 31 |
forced_root_block: false, |
| 32 |
force_br_newlines: true, |
| 33 |
force_p_newlines: false |
| 34 |
}); |
| 35 |
JS; |
| 36 |
|
| 37 |
$ajax = $this->form->getAjax(); |
| 38 |
$id = $this->form->getID(); |
| 39 |
if(!empty($ajax)) { |
| 40 |
echo <<<JS |
| 41 |
jQuery("#$id").bind("submit", function() { |
| 42 |
tinyMCE.triggerSave(); |
| 43 |
}); |
| 44 |
JS; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
function getJSFiles() { |
| 49 |
return array( |
| 50 |
$this->form->getResourcesPath() . "/tiny_mce/tiny_mce.js" |
| 51 |
); |
| 52 |
} |
| 53 |
} |
| 54 |
|