admin-preview.js
3 years ago
admin.js
3 years ago
blocks-placeholder.js
3 years ago
editor-el.js
3 years ago
mce-button.js
3 years ago
post-grid-blocks.js
3 years ago
rttpg.js
3 years ago
tpg-el-editor.js
3 years ago
mce-button.js
62 lines
| 1 | (function() { |
| 2 | tinymce.PluginManager.add('rt_tpg_scg', function( editor, url ) { |
| 3 | var tlpsc_tag = 'the-post-grid'; |
| 4 | |
| 5 | |
| 6 | //add popup |
| 7 | editor.addCommand('rt_tpg_scg_popup', function(ui, v) { |
| 8 | //setup defaults |
| 9 | |
| 10 | editor.windowManager.open( { |
| 11 | title: 'The Post Grid ShortCode', |
| 12 | width: jQuery( window ).width() * 0.3, |
| 13 | height: (jQuery( window ).height() - 36 - 50) * 0.1, |
| 14 | id: 'rt-tpg-insert-dialog', |
| 15 | body: [ |
| 16 | { |
| 17 | type : 'container', |
| 18 | html : '<span class="rt-loading">Loading...</span>' |
| 19 | }, |
| 20 | ], |
| 21 | onsubmit: function( e ) { |
| 22 | |
| 23 | var shortcode_str; |
| 24 | var id = jQuery("#scid").val(); |
| 25 | var title = jQuery( "#scid option:selected" ).text(); |
| 26 | if(id && id != 'undefined'){ |
| 27 | shortcode_str = '[' + tlpsc_tag; |
| 28 | shortcode_str += ' id="'+id+'" title="'+ title +'"'; |
| 29 | shortcode_str += ']'; |
| 30 | } |
| 31 | if(shortcode_str) { |
| 32 | editor.insertContent(shortcode_str); |
| 33 | }else{ |
| 34 | alert('No short code selected'); |
| 35 | } |
| 36 | } |
| 37 | }); |
| 38 | |
| 39 | putScList(); |
| 40 | }); |
| 41 | |
| 42 | //add button |
| 43 | editor.addButton('rt_tpg_scg', { |
| 44 | icon: 'rt_tpg_scg', |
| 45 | tooltip: 'The Post Grid', |
| 46 | cmd: 'rt_tpg_scg_popup', |
| 47 | }); |
| 48 | |
| 49 | function putScList(){ |
| 50 | var dialogBody = jQuery( '#rt-tpg-insert-dialog-body' ) |
| 51 | jQuery.post( ajaxurl, { |
| 52 | action: 'rtTPGShortCodeList' |
| 53 | }, function( response ) { |
| 54 | |
| 55 | dialogBody.html(response); |
| 56 | console.log(response); |
| 57 | }); |
| 58 | |
| 59 | } |
| 60 | |
| 61 | }); |
| 62 | })(); |