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/input/longtext.php101
-rw-r--r--mod/tinymce/views/default/js/tinymce.php102
-rw-r--r--mod/tinymce/views/default/tinymce/css.php69
-rw-r--r--mod/tinymce/views/default/tinymce/embed_custom_insert_js.php12
-rw-r--r--mod/tinymce/views/default/tinymce/init.php7
5 files changed, 142 insertions, 149 deletions
diff --git a/mod/tinymce/views/default/input/longtext.php b/mod/tinymce/views/default/input/longtext.php
deleted file mode 100644
index 2f16c0fe7..000000000
--- a/mod/tinymce/views/default/input/longtext.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-/**
- * Elgg long text input with the tinymce text editor intacts
- * Displays a long text input field
- *
- * @package ElggTinyMCE
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- *
- * @uses $vars['value'] The current value, if any
- * @uses $vars['js'] Any Javascript to enter into the input tag
- * @uses $vars['internalname'] The name of the input field
- *
- */
-
-global $tinymce_js_loaded;
-
-if (!isset($vars['value']) || $vars['value'] === FALSE) {
- $vars['value'] = elgg_get_sticky_value($vars['internalname']);
-}
-
-$input = rand(0,9999);
-
-if (!isset($tinymce_js_loaded)) {
- $tinymce_js_loaded = false;
-}
-
-if (!$tinymce_js_loaded) {
-
-?>
-<!-- include tinymce -->
-<script language="javascript" type="text/javascript" src="<?php echo $vars['url']; ?>mod/tinymce/vendor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
-<!-- intialise tinymce, you can find other configurations here http://wiki.moxiecode.com/examples/tinymce/installation_example_01.php -->
-<script language="javascript" type="text/javascript">
-tinyMCE.init({
- mode : "specific_textareas",
- editor_selector : "mceEditor",
- theme : "advanced",
- plugins : "spellchecker,autosave,fullscreen,paste",
- relative_urls : false,
- remove_script_host : false,
- document_base_url : "<?php echo $vars['url']; ?>",
- theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,undo,redo,link,unlink,image,blockquote,code,pastetext,pasteword,more,fullscreen",
- theme_advanced_buttons2 : "",
- theme_advanced_buttons3 : "",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_statusbar_location : "bottom",
- theme_advanced_resizing : true,
- theme_advanced_path : true,
- 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 + ' ';
- 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 + ' ';
- tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
- });
- },
- content_css: '<?php echo $vars['url']; ?>mod/tinymce/tinymce_content.css'
-});
-
-function toggleEditor(id) {
- if (!tinyMCE.get(id)) {
- tinyMCE.execCommand('mceAddControl', false, id);
- <?php $toggleEditor_linktext = elgg_echo('tinymce:remove'); ?>
- $("a.toggle_editor").html('<?php echo $toggleEditor_linktext ?>');
- }
- else {
- tinyMCE.execCommand('mceRemoveControl', false, id);
- <?php $toggleEditor_linktext = elgg_echo('tinymce:add'); ?>
- $("a.toggle_editor").html('<?php echo $toggleEditor_linktext ?>');
- }
-}
-</script>
-<?php
-
- $tinymce_js_loaded = true;
-}
-
-?>
-
-<a class="longtext_control toggle_editor small link" href="javascript:toggleEditor('<?php echo $vars['internalname']; ?>');"><?php echo elgg_echo('tinymce:remove'); ?></a>
-<!-- show the textarea -->
-<textarea class="input_textarea mceEditor" name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], null, 'UTF-8'); ?></textarea>
-
-<script type="text/javascript">
- $(document).ready(function() {
- $('textarea').parents('form').submit(function() {
- tinyMCE.triggerSave();
- });
- });
-</script>
diff --git a/mod/tinymce/views/default/js/tinymce.php b/mod/tinymce/views/default/js/tinymce.php
new file mode 100644
index 000000000..344d71b14
--- /dev/null
+++ b/mod/tinymce/views/default/js/tinymce.php
@@ -0,0 +1,102 @@
+elgg.provide('elgg.tinymce');
+
+/**
+ * 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);
+ $(this).html(elgg.echo('tinymce:remove'));
+ } else {
+ tinyMCE.execCommand('mceRemoveControl', false, id);
+ $(this).html(elgg.echo('tinymce:add'));
+ }
+}
+
+/**
+ * TinyMCE initialization script
+ *
+ * You can find configuration information here:
+ * 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",
+ 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,
+ theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,undo,redo,link,unlink,image,blockquote,code,pastetext,pasteword,more,fullscreen",
+ theme_advanced_buttons2 : "",
+ theme_advanced_buttons3 : "",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_toolbar_align : "left",
+ 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 = 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 = 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/css/elgg_tinymce.css'
+ });
+
+ // 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_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 f7eee7fe9..b12cae82c 100644
--- a/mod/tinymce/views/default/tinymce/css.php
+++ b/mod/tinymce/views/default/tinymce/css.php
@@ -1,52 +1,31 @@
<?php
/**
-* TinyMCE CSS
-*/
+ * TinyMCE CSS
+ *
+ * Overrides on the default TinyMCE skin
+ * Gives the textarea and buttons rounded corners
+ *
+ * The rules are extra long in order to have enough
+ * weight to override the TinyMCE rules
+ */
?>
-#elgg_page_contents .mceButton {
- background-color: #e9e8e8;
- border-color: #B2B2B2;
- margin:4px;
- padding:2px;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
-}
-#elgg_page_contents a.mceButtonEnabled:hover,
-#elgg_page_contents a.mceButtonActive,
-#elgg_page_contents a.mceButtonSelected {
- background-color: #d5d5d5;
- border-color: #777 !important;
-}
-#elgg_page_contents .mceFocus .mceTop .mceLeft {
- background: #444444;
- border-left: 1px solid #999;
- border-top: 1px solid #999;
- -moz-border-radius: 4px 0 0 0;
- -webkit-border-top-left-radius: 4px;
- -khtml-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
-}
-#elgg_page_contents .mceFocus .mceTop .mceRight {
- background: #444444;
- border-right: 1px solid #999;
- border-top: 1px solid #999;
- border-top-right-radius: 4px;
- -khtml-border-top-right-radius: 4px;
- -webkit-border-top-right-radius: 4px;
- -moz-border-radius: 0 4px 0 0;
-}
-#elgg_page_contents .mceLayout{
+/* TinyMCE */
+.elgg-page .mceEditor table.mceLayout {
border: 1px solid #CCC;
- -webkit-border-radius: 5px;
+
+ -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 {
+ border-width: 0px;
+}
+.mceButton {
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
}
-#elgg_page_contents table.mceLayout tr.mceFirst td {border-top:0px solid #CCC}
-#elgg_page_contents table.mceLayout tr.mceLast td {border-bottom:0px solid #CCC}
-#elgg_page_contents #blogbody_toolbar1{}
-#elgg_page_contents .mceToolbar{}
-#elgg_page_contents #blogbody_ifr{height:400px !important;} /* blogs */
-#pagesForm #description_ifr {height:400px !important;} /* pages */
-#elgg_page_contents .mceIframeContainer{}
-.wp_themeSkin .mceButtonDisabled {
- border-color: #ccc !important;
+.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
new file mode 100644
index 000000000..35dd71613
--- /dev/null
+++ b/mod/tinymce/views/default/tinymce/init.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * Initialize the TinyMCE script
+ */
+
+elgg_load_js('tinymce');
+elgg_load_js('elgg.tinymce'); \ No newline at end of file