]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Enable TinyMCE for the blog form
authorEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 16:21:04 +0000 (12:21 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 16:21:04 +0000 (12:21 -0400)
plugins/Blog/BlogPlugin.php
plugins/Blog/blog.js [new file with mode: 0644]

index 89619b5f54fec08789fc6f3d3653a5f2820d0952..04eef36e04195df00469abf217c5d39330cdda95 100644 (file)
@@ -207,4 +207,13 @@ class BlogPlugin extends MicroAppPlugin
         
         return null;
     }
+
+    function onEndShowScripts($action)
+    {
+        $action->script(common_path('plugins/TinyMCE/js/jquery.tinymce.js'));
+        $action->inlineScript('var _tinymce_path = "'.common_path('plugins/TinyMCE/js/tiny_mce.js').'";'."\n".
+                              'var _tinymce_placeholder = "'.common_path('plugins/TinyMCE/icons/placeholder.png').'";'."\n");
+        $action->script($this->path('blog.js'));
+        return true;
+    }
 }
diff --git a/plugins/Blog/blog.js b/plugins/Blog/blog.js
new file mode 100644 (file)
index 0000000..333a289
--- /dev/null
@@ -0,0 +1,33 @@
+(function() {
+    var origInit = SN.Init.NoticeFormSetup;
+    SN.Init.NoticeFormSetup = function(form) {
+        origInit(form);
+        var content = form.find("#blog-entry-content");
+        if (content.length > 0) {
+            content.tinymce({
+                script_url : window._tinymce_path,
+                // General options
+                theme : "advanced",
+                plugins : "paste,fullscreen,autoresize,autolink,inlinepopups,tabfocus",
+                theme_advanced_buttons1 : "bold,italic,strikethrough,|,undo,redo,|,link,unlink,image",
+                theme_advanced_buttons2 : "",
+                theme_advanced_buttons3 : "",
+                add_form_submit_trigger : false,
+                theme_advanced_resizing : true,
+                tabfocus_elements: ":prev,:next",
+                setup: function(ed) {
+
+                    form.find('.submit:first').click(function() {
+                        tinymce.triggerSave();
+                    });
+
+                    form.find('input[type=file]').change(function() {
+                        var img = '<img src="'+window._tinymce_placeholder+'" class="placeholder" width="320" height="240">';
+                        var html = tinyMCE.activeEditor.getContent();
+                        ed.setContent(html + img);
+                    });
+                }
+            });
+        }
+    };
+})();
\ No newline at end of file