PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.8.6
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.8.6
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / bws_menu / js / shortcode-button.js

shortcode-button.js in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.8.6, at bws_menu/js/shortcode-button.js

124 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 if ( typeof bws_shortcode_button != 'undefined' ) {
3 var win;
4 tinymce.create( 'tinymce.plugins.BWSButton', {
5 /**
6 * Initializes the plugin, this will be executed after the plugin has been created.
7 * This call is done before the editor instance has finished it's initialization so use the onInit event
8 * of the editor instance to intercept that event.
9 *
10 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
11 * @param {string} url Absolute URL to where the plugin is located.
12 */
13 init : function( ed, url ) {
14 ed.addButton( 'add_bws_shortcode', {
15 title : bws_shortcode_button.title,
16 classes: 'bws_shortcode_button widget btn',
17 image : bws_shortcode_button.icon_url,
18 onclick: function() {
19 if ( bws_shortcode_button.wp_version < '3.9' ) {
20 /* triggers the thickbox */
21 var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
22 W = W - 80;
23 H = H - 84;
24 tb_show( bws_shortcode_button.title, '#TB_inline?width=' + W + '&height=' + H + '&inlineId=bws_shortcode_popup' );
25
26 var current_object = '#TB_ajaxContent';
27 } else {
28 win = ed.windowManager.open( {
29 width: 400,
30 height: 400,
31 inline: true,
32 title: bws_shortcode_button.title,
33 body: {
34 id : 'bws-shortcode-content',
35 type: 'container',
36 classes: 'bws-shortcode',
37 html: $( '#bws_shortcode_popup' ).html()
38 },
39 buttons: [{
40 text: 'Insert',
41 classes: 'button-primary primary bws_shortcode_insert',
42 onclick: function( e ) {
43 var shortcode = $( '.mce-container-body #bws_shortcode_display' ).text();
44 if ( '' != shortcode ) {
45 /* insert shortcode to tinymce */
46 ed.insertContent( shortcode );
47 }
48 ed.windowManager.close();
49 },
50 },
51 {
52 text: 'Cancel',
53 onclick: 'close'
54 }],
55
56 });
57 var current_object = '.mce-container-body';
58 }
59 var select_count = $( current_object + ' select#bws_shortcode_select option').length;
60 if ( 1 == select_count ) {
61 $( current_object + ' #bws_shortcode_select_plugin' ).hide();
62 }
63
64 var plugin = $( current_object + ' #bws_shortcode_select option:selected' ).val();
65 $( current_object + ' #bws_shortcode_content > div' ).hide();
66 $( current_object + ' #bws_shortcode_content > #' + plugin ).show();
67
68 if ( $( current_object + ' #bws_shortcode_content > #' + plugin + ' .bws_default_shortcode' ).length > 0 ) {
69 $( current_object + ' #bws_shortcode_display' ).text( $( current_object + ' #bws_shortcode_content > #' + plugin + ' .bws_default_shortcode' ).val() );
70 }
71
72 $( current_object + ' #bws_shortcode_select' ).on( 'change',function() {
73 var plugin = $( current_object + ' #bws_shortcode_select option:selected' ).val();
74 $( current_object + ' #bws_shortcode_content > div' ).hide();
75 $( current_object + ' #bws_shortcode_content > #' + plugin ).show();
76 if ( $( current_object + ' #bws_shortcode_content > #' + plugin + ' .bws_default_shortcode' ).length > 0 ) {
77 $( current_object + ' #bws_shortcode_display' ).text( $( current_object + ' #bws_shortcode_content > #' + plugin + ' .bws_default_shortcode' ).val() );
78 } else {
79 $( current_object + ' #bws_shortcode_display' ).text( '' );
80 }
81 });
82
83 $.each( bws_shortcode_button.function_name, function( index, value ) {
84 eval( value + '();' );
85 });
86 }
87 });
88 },
89
90 /**
91 * Creates control instances based in the incomming name. This method is normally not
92 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
93 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
94 * method can be used to create those.
95 *
96 * @param {String} n Name of the control to create.
97 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
98 * @return {tinymce.ui.Control} New control instance or null if no control was created.
99 */
100 createControl : function(n, cm) {
101 return null;
102 },
103
104 /**
105 * Returns information about the plugin as a name/value array.
106 * The current keys are longname, author, authorurl, infourl and version.
107 *
108 * @return {Object} Name/value array containing information about the plugin.
109 */
110 getInfo : function() {
111 return {
112 longname : 'BWS Shortcode Buttons',
113 author : 'BWS',
114 authorurl : 'http://bestwebsoft.com',
115 infourl : '',
116 version : "0.1"
117 };
118 }
119 });
120
121 /* Register plugin */
122 tinymce.PluginManager.add( 'add_bws_shortcode', tinymce.plugins.BWSButton );
123 }
124 })(jQuery);