PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.9
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.9
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
insert-php / admin / assets / js / tinymce4.4.js

tinymce4.4.js in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.2.9, at admin/assets/js/tinymce4.4.js

71 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 $(document).on('tinymce-editor-setup', function(event, editor) {
3
4 if( void 0 === wbcr_inp_shortcode_snippets ) {
5 console.log('Unknown error.');
6 return;
7 }
8
9 if( $.isEmptyObject(wbcr_inp_shortcode_snippets) ) {
10 return;
11 }
12
13 editor.settings.toolbar1 += ',wbcr_insert_php_button';
14
15 var menu = [];
16
17 $.each(wbcr_inp_shortcode_snippets, function(index, item) {
18 menu.push({
19 text: item.title,
20 value: item.id,
21 onclick: function() {
22 var content = "";
23 var snippet_type = item.type;
24 var snippet_name = item.name;
25 var selected_content = editor.selection.getContent();
26
27 for( var tag in item ) {
28 if( !item.hasOwnProperty(tag) ) {
29 continue;
30 }
31
32 if( 'type' === tag ) {
33 snippet_type = item[tag];
34 } else if( 'name' === tag ) {
35 snippet_name = item[tag];
36 } else if( tag.indexOf('snippet_tags') === -1 ) {
37 if( !('' !== selected_content && 'content' === tag) ) {
38 content += ' ' + tag + '="' + item[tag] + '"';
39 }
40 }
41 }
42
43 if( '' === snippet_name || undefined === snippet_name ) {
44 if( 'universal' === snippet_type ) {
45 snippet_name = "wbcr_snippet";
46 } else {
47 snippet_name = "wbcr_" + snippet_type + "_snippet";
48 }
49 }
50
51 if( '' === selected_content ) {
52 editor.selection.setContent('[' + snippet_name + content + ']');
53 } else {
54 editor.selection.setContent(
55 '[' + snippet_name + content + ']' +
56 selected_content +
57 '[/' + snippet_name + ']');
58 }
59 }
60 });
61 });
62
63 editor.addButton('wbcr_insert_php_button', {
64 title: wbcr_inp_tinymce_snippets_button_title,
65 type: 'menubutton',
66 icon: 'icon wbcr-inp-shortcode-icon',
67 menu: menu
68 });
69
70 });
71 })(jQuery);