aboutsummaryrefslogtreecommitdiff
path: root/mod/tinymce/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'mod/tinymce/views/default')
-rw-r--r--mod/tinymce/views/default/js/tinymce.php67
-rw-r--r--mod/tinymce/views/default/tinymce/css.php9
-rw-r--r--mod/tinymce/views/default/tinymce/embed_custom_insert_js.php12
-rw-r--r--mod/tinymce/views/default/tinymce/init.php7
4 files changed, 76 insertions, 19 deletions
diff --git a/mod/tinymce/views/default/js/tinymce.php b/mod/tinymce/views/default/js/tinymce.php
index 09fbee2ad..344d71b14 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,11 +27,19 @@ 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",
theme : "advanced",
- plugins : "spellchecker,autosave,fullscreen,paste",
+ language : "<?php echo tinymce_get_site_language(); ?>",
+ plugins : "lists,spellchecker,autosave,fullscreen,paste,inlinepopups",
relative_urls : false,
remove_script_host : false,
document_base_url : elgg.config.wwwroot,
@@ -34,28 +51,52 @@ elgg.tinymce.init = function() {
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
theme_advanced_path : true,
+ width : "100%",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
setup : function(ed) {
//show the number of words
ed.onLoadContent.add(function(ed, o) {
var strip = (tinyMCE.activeEditor.getContent()).replace(/(&lt;([^&gt;]+)&gt;)/ig,"");
- var text = " <?php echo elgg_echo('tinymce:word_count'); ?>" + strip.split(' ').length + ' ';
+ var text = elgg.echo('tinymce:word_count') + strip.split(' ').length + ' ';
tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
});
-
+
ed.onKeyUp.add(function(ed, e) {
var strip = (tinyMCE.activeEditor.getContent()).replace(/(&lt;([^&gt;]+)&gt;)/ig,"");
- var text = " <?php echo elgg_echo('tinymce:word_count'); ?>" + strip.split(' ').length + ' ';
+ var text = elgg.echo('tinymce:word_count') + strip.split(' ').length + ' ';
tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
});
+
+ ed.onInit.add(function(ed) {
+ // prevent Firefox from dragging/dropping files into editor
+ if (tinymce.isGecko) {
+ tinymce.dom.Event.add(ed.getBody().parentNode, "drop", function(e) {
+ if (e.dataTransfer.files.length > 0) {
+ e.preventDefault();
+ }
+ });
+ }
+ });
+
},
- content_css: elgg.config.wwwroot + 'mod/tinymce/tinymce_content.css'
+ content_css: elgg.config.wwwroot + 'mod/tinymce/css/elgg_tinymce.css'
});
- $('.elgg-input-longtext').parents('form').submit(function() {
- tinyMCE.triggerSave();
- });
+ // work around for IE/TinyMCE bug where TinyMCE loses insert carot
+ if ($.browser.msie) {
+ $(".embed-control").live('hover', function() {
+ var classes = $(this).attr('class');
+ var embedClass = classes.split(/[, ]+/).pop();
+ var textAreaId = embedClass.substr(embedClass.indexOf('embed-control-') + "embed-control-".length);
+ if (window.tinyMCE) {
+ var editor = window.tinyMCE.get(textAreaId);
+ if (elgg.tinymce.bookmark == null) {
+ elgg.tinymce.bookmark = editor.selection.getBookmark(2);
+ }
+ }
+ });
+ }
}
-elgg.register_event_handler('init', 'system', elgg.tinymce.init); \ No newline at end of file
+elgg.register_hook_handler('init', 'system', elgg.tinymce.init);
diff --git a/mod/tinymce/views/default/tinymce/css.php b/mod/tinymce/views/default/tinymce/css.php
index 69302bd48..b12cae82c 100644
--- a/mod/tinymce/views/default/tinymce/css.php
+++ b/mod/tinymce/views/default/tinymce/css.php
@@ -5,14 +5,17 @@
* Overrides on the default TinyMCE skin
* Gives the textarea and buttons rounded corners
*
- * @todo why the crazy long rules?
+ * The rules are extra long in order to have enough
+ * weight to override the TinyMCE rules
*/
?>
/* TinyMCE */
.elgg-page .mceEditor table.mceLayout {
border: 1px solid #CCC;
+
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
+ border-radius: 5px;
}
.elgg-page table.mceLayout tr.mceFirst td.mceToolbar,
.elgg-page table.mceLayout tr.mceLast td.mceStatusbar {
@@ -21,4 +24,8 @@
.mceButton {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
+ border-radius: 4px;
+}
+.mceLast .mceStatusbar {
+ padding-left: 5px;
}
diff --git a/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php b/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php
index 84f98c405..a861a4035 100644
--- a/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php
+++ b/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php
@@ -1,8 +1,14 @@
if (window.tinyMCE) {
- var editor = window.tinyMCE.get(textAreaName);
-
+ var editor = window.tinyMCE.get(textAreaId);
+
if (editor) {
+
+ // work around for IE/TinyMCE bug where TinyMCE loses insert carot
+ if ($.browser.msie) {
+ editor.focus();
+ editor.selection.moveToBookmark(elgg.tinymce.bookmark);
+ }
+
editor.execCommand("mceInsertContent", true, content);
}
}
- \ 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..35dd71613 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
+elgg_load_js('tinymce');
+elgg_load_js('elgg.tinymce'); \ No newline at end of file