aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/tinymce/start.php2
-rw-r--r--mod/tinymce/views/default/js/tinymce.php28
-rw-r--r--mod/tinymce/views/default/tinymce/init.php3
-rw-r--r--views/default/input/longtext.php1
4 files changed, 25 insertions, 9 deletions
diff --git a/mod/tinymce/start.php b/mod/tinymce/start.php
index 3de517d27..81667f8d5 100644
--- a/mod/tinymce/start.php
+++ b/mod/tinymce/start.php
@@ -21,7 +21,7 @@ function tinymce_longtext_menu($hook, $type, $items, $vars) {
$items[] = ElggMenuItem::factory(array(
'name' => 'tinymce_toggler',
'class' => 'tinymce-toggle-editor elgg-longtext-control',
- 'href' => "javascript:elgg.tinymce.toggleEditor('{$vars['id']}');",
+ 'href' => "#{$vars['id']}",
'text' => elgg_echo('tinymce:remove'),
));
diff --git a/mod/tinymce/views/default/js/tinymce.php b/mod/tinymce/views/default/js/tinymce.php
index 09fbee2ad..4697e33a7 100644
--- a/mod/tinymce/views/default/js/tinymce.php
+++ b/mod/tinymce/views/default/js/tinymce.php
@@ -1,13 +1,22 @@
elgg.provide('elgg.tinymce');
-elgg.tinymce.toggleEditor = function(id) {
+/**
+ * Toggles the tinymce editor
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.tinymce.toggleEditor = function(event) {
+ event.preventDefault();
+
+ var target = $(this).attr('href');
+ var id = $(target).attr('id');
if (!tinyMCE.get(id)) {
tinyMCE.execCommand('mceAddControl', false, id);
- <?php //FIXME This changes all controls on the page!! ?>
- $("a.tinymce-toggle-editor").html(elgg.echo('tinymce:remove'));
+ $(this).html(elgg.echo('tinymce:remove'));
} else {
tinyMCE.execCommand('mceRemoveControl', false, id);
- $("a.tinymce-toggle-editor").html(elgg.echo('tinymce:add'));
+ $(this).html(elgg.echo('tinymce:add'));
}
}
@@ -18,6 +27,13 @@ elgg.tinymce.toggleEditor = function(id) {
* http://tinymce.moxiecode.com/wiki.php/Configuration
*/
elgg.tinymce.init = function() {
+
+ $('.tinymce-toggle-editor').live('click', elgg.tinymce.toggleEditor);
+
+ $('.elgg-input-longtext').parents('form').submit(function() {
+ tinyMCE.triggerSave();
+ });
+
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "elgg-input-longtext",
@@ -52,10 +68,6 @@ elgg.tinymce.init = function() {
content_css: elgg.config.wwwroot + 'mod/tinymce/tinymce_content.css'
});
- $('.elgg-input-longtext').parents('form').submit(function() {
- tinyMCE.triggerSave();
- });
-
}
elgg.register_event_handler('init', 'system', elgg.tinymce.init); \ No newline at end of file
diff --git a/mod/tinymce/views/default/tinymce/init.php b/mod/tinymce/views/default/tinymce/init.php
index 100a1a987..408aba094 100644
--- a/mod/tinymce/views/default/tinymce/init.php
+++ b/mod/tinymce/views/default/tinymce/init.php
@@ -1,4 +1,7 @@
<?php
+/**
+ * Initialize the TinyMCE script
+ */
elgg_register_js('mod/tinymce/vendor/tinymce/jscripts/tiny_mce/tiny_mce.js', 'tinymce');
elgg_register_js(elgg_get_simplecache_url('js', 'tinymce'), 'elgg.tinymce'); \ No newline at end of file
diff --git a/views/default/input/longtext.php b/views/default/input/longtext.php
index ec0f170ca..bd61b86ce 100644
--- a/views/default/input/longtext.php
+++ b/views/default/input/longtext.php
@@ -24,5 +24,6 @@ $vars = array_merge($defaults, $vars);
echo elgg_view_menu('longtext', array(
'sort_by' => 'priority',
'class' => 'elgg-menu-hz',
+ 'id' => $vars['id'],
));
echo elgg_view('input/plaintext', $vars);