]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
cleaned up tinymce plugin
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 26 Jan 2011 03:14:06 +0000 (03:14 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 26 Jan 2011 03:14:06 +0000 (03:14 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7933 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/tinymce/graphics/ed-bg.gif [deleted file]
mod/tinymce/graphics/example.gif [deleted file]
mod/tinymce/graphics/more.gif [deleted file]
mod/tinymce/views/default/input/longtext.php
mod/tinymce/views/default/tinymce/css.php
mod/tinymce/views/default/tinymce/init.php [new file with mode: 0644]

diff --git a/mod/tinymce/graphics/ed-bg.gif b/mod/tinymce/graphics/ed-bg.gif
deleted file mode 100644 (file)
index a00467c..0000000
Binary files a/mod/tinymce/graphics/ed-bg.gif and /dev/null differ
diff --git a/mod/tinymce/graphics/example.gif b/mod/tinymce/graphics/example.gif
deleted file mode 100644 (file)
index 1ab5da4..0000000
Binary files a/mod/tinymce/graphics/example.gif and /dev/null differ
diff --git a/mod/tinymce/graphics/more.gif b/mod/tinymce/graphics/more.gif
deleted file mode 100644 (file)
index 4ff564d..0000000
Binary files a/mod/tinymce/graphics/more.gif and /dev/null differ
index 9d3a3615510c16603a592595c8d7edea916d0359..daa68502e04ba2b3259062b5903173f868c39d90 100644 (file)
@@ -1,98 +1,28 @@
 <?php
 /**
- * Elgg long text input with the tinymce text editor intacts
- * Displays a long text input field
+ * Long text input with the tinymce text editor
  *
  * @package ElggTinyMCE
  *
- * @uses $vars['value'] The current value, if any
- * @uses $vars['js'] Any Javascript to enter into the input tag
+ * @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
- * @uses $vars['internalid'] The id of the input field
+ * @uses $vars['internalid']   The id of the input field
  *
  */
 
-global $tinymce_js_loaded;
+elgg_register_js('mod/tinymce/vendor/tinymce/jscripts/tiny_mce/tiny_mce.js', 'tinymce');
 
-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 type="text/javascript" src="<?php echo elgg_get_site_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 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 elgg_get_site_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 elgg_get_site_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;
-}
+// make sure the init script is only loaded once
+elgg_unextend_view('footer/analytics', 'tinymce/init');
+elgg_extend_view('footer/analytics', 'tinymce/init');
 
 ?>
 
-<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="elgg-input-textarea mceEditor" name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], null, 'UTF-8'); ?></textarea>
+<a class="elgg-longtext-control tinymce-toggle-editor small" href="javascript:toggleEditor('<?php echo $vars['internalname']; ?>');">
+       <?php echo elgg_echo('tinymce:remove'); ?>
+</a>
 
-<script type="text/javascript">
-       $(document).ready(function() {
-               $('textarea').parents('form').submit(function() {
-                       tinyMCE.triggerSave();
-               });
-       });
-</script>
+<textarea class="elgg-input-textarea mceEditor" name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?>>
+       <?php echo htmlspecialchars($vars['value'], null, 'UTF-8'); ?>
+</textarea>
index e8d768b91796136a4ab81039e091af68f7219505..6980a67e060bd8b40f7a66dcf3a6638e58ab2c9a 100644 (file)
@@ -1,52 +1,22 @@
 <?php
 /**
-* TinyMCE CSS
-*/
+ * TinyMCE CSS
+ *
+ * Overrides on the default TinyMCE skin
+ * Gives the textarea and buttons rounded corners
+ */
 ?>
-#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;
 }
-#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;
+.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;
 }
diff --git a/mod/tinymce/views/default/tinymce/init.php b/mod/tinymce/views/default/tinymce/init.php
new file mode 100644 (file)
index 0000000..6282fa0
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * TinyMCE initialization script
+ *
+ * You can find configuration information here:
+ * http://tinymce.moxiecode.com/wiki.php/Configuration
+ */
+?>
+
+<script 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 elgg_get_site_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 elgg_get_site_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.tinymce-toggle-editor").html('<?php echo $toggleEditor_linktext ?>');
+       } else {
+               tinyMCE.execCommand('mceRemoveControl', false, id);
+               <?php $toggleEditor_linktext = elgg_echo('tinymce:add'); ?>
+               $("a.tinymce-toggle-editor").html('<?php echo $toggleEditor_linktext ?>');
+       }
+}
+
+$(document).ready(function() {
+       $('textarea').parents('form').submit(function() {
+               tinyMCE.triggerSave();
+       });
+});
+</script>