# shortcode-variables/4.2.2/assets/js/tinymce.js

Snippet Shortcodes, version 4.2.2. 70 lines.

- Page: https://pluginprobe.com/plugins/shortcode-variables/4.2.2/code/assets/js/tinymce.js
- Raw: https://pluginprobe.com/plugins/shortcode-variables/4.2.2/raw/assets/js/tinymce.js
- Modified: 2020-10-20T07:14:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shortcode-variables/4.2.2/code/assets/js/tinymce.js#L10-L20`.

```javascript
(function() {

    tinymce.PluginManager.add( 'sh_cd_tinymce_button', function( editor, url ) {

            editor.addButton( 'sh_cd_tinymce_button', {
            text: sh_cd_tinymce[ 'button-text' ],
            type: 'menubutton',
            icon: false,
                menu: [
                        {
                            text: 'Your shortcodes',
                            onclick: function() {

                                if ( true !== sh_cd_tinymce[ 'premium' ] ) {

                                    if( true === confirm( sh_cd_tinymce[ 'upgrade-text' ] ) ) {
                                        window.location.href = sh_cd_tinymce[ 'upgrade-url' ];
                                    }

                                } else {
                                    sh_cd_tinymce_popup( editor, sh_cd_tinymce[ 'values-your' ] );
                                }
                            }
                        },
                        {
                            text: 'Premade shortcodes',
                            onclick: function() {

                                if ( true !== sh_cd_tinymce[ 'premium' ] ) {

                                    if( true === confirm( sh_cd_tinymce[ 'upgrade-text' ] ) ) {
                                        window.location.href = sh_cd_tinymce[ 'upgrade-url' ];
                                    }

                                } else {
                                    sh_cd_tinymce_popup( editor, sh_cd_tinymce[ 'values-premade' ] );
                                }
                            }
                        }
                    ]
            });
    });

    /**
     * Render pop up
     * @param editor
     * @param values
     */
    function sh_cd_tinymce_popup( editor, values ) {

        editor.windowManager.open( {
            title:  sh_cd_tinymce[ 'dialog-title' ],
            width: 400,
            height:80,
            body: [
                {
                    type: 'listbox',
                    width: 400,
                    name: 'shortcode',
                    label: sh_cd_tinymce[ 'dialog-label' ],
                    'values': values
                }
                ],
            onsubmit: function( e ) {
                editor.insertContent( e.data.shortcode );
            }
        });
    }

})();
```
