editor_plugin.js
56 lines
| 1 | /* |
| 2 | * Shortcoder inserting javascript in TinyMCE editor |
| 3 | * http://www.aakashweb.com |
| 4 | * v1.1 |
| 5 | * Added since WP Socializer v2.0 |
| 6 | */ |
| 7 | function sc_show_editor(){ |
| 8 | var url = document.getElementById('sc_editorUrl').innerHTML; |
| 9 | tb_show('Insert a Shortcode', url + '?random=' + Math.random() + '&TB_iframe=1'); |
| 10 | } |
| 11 | |
| 12 | // For adding button in the visual editing toolbox |
| 13 | (function() { |
| 14 | tinymce.create('tinymce.plugins.SCButton', { |
| 15 | |
| 16 | init : function(ed, url) { |
| 17 | ed.addButton('scbutton', { |
| 18 | title : 'Insert shortcodes created using Shortcoder', |
| 19 | image : url + '/icon.png', |
| 20 | onclick : function() { |
| 21 | sc_show_editor(); |
| 22 | } |
| 23 | }); |
| 24 | }, |
| 25 | |
| 26 | getInfo : function() { |
| 27 | return { |
| 28 | longname : 'Shortcoder', |
| 29 | author : 'Aakash Chakravarthy', |
| 30 | authorurl : 'http://www.aakashweb.com/', |
| 31 | infourl : 'http://www.aakashweb.com/', |
| 32 | version : '1.0' |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | }); |
| 37 | |
| 38 | tinymce.PluginManager.add('scbutton', tinymce.plugins.SCButton); |
| 39 | })(); |
| 40 | |
| 41 | // For adding button in the code editing toolbox |
| 42 | |
| 43 | if(document.getElementById("ed_toolbar")){ |
| 44 | qt_toolbar = document.getElementById("ed_toolbar"); |
| 45 | edButtons[edButtons.length] = new edButton("ed_scbutton", "WP Socializer", "", "",""); |
| 46 | var qt_button = qt_toolbar.lastChild; |
| 47 | while (qt_button.nodeType != 1){ |
| 48 | qt_button = qt_button.previousSibling; |
| 49 | } |
| 50 | qt_button = qt_button.cloneNode(true); |
| 51 | qt_button.value = 'Shortcoder'; |
| 52 | qt_button.title = 'Insert shortcodes created using Shortcoder'; |
| 53 | qt_button.onclick = function(){ sc_show_editor(); }; |
| 54 | qt_button.id = "ed_scbutton"; |
| 55 | qt_toolbar.appendChild(qt_button); |
| 56 | } |