Plugin Directory

Changeset 1518058


Ignore:
Timestamp:
10/19/2016 07:08:26 PM (9 years ago)
Author:
healcode_wordpress
Message:

Update to work with TinyMCE version 4+

Location:
healcode-mindbody-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • healcode-mindbody-widget/trunk/healcode-mb-widget.php

    r1437309 r1518058  
    44Plugin URI: https://wordpress.org/plugins/healcode-mb-widget/
    55Description: Add HealCode Widgets to your WordPress website. This plugin lets you generate a shortcode for a widget. The shortcodes can be used in your pages, posts and widgets.
    6 Version: 1.1.12
     6Version: 1.1.13
    77Author: HealCode
    88Author URI: http://www.healcode.com/
  • healcode-mindbody-widget/trunk/js/healcode-wp-mb-widget.js

    r1518057 r1518058  
    2828function hcShortCodeEditorInsertion(element) {
    2929  var shortCode = jQuery(element).val();
    30   var editor = jQuery(element).data('editor');
    31   hcGenerateShortCodeInsertEditor(shortCode, editor);
     30  var editorName    = jQuery(element).data('editor');
     31  var $editor  = jQuery('#' + editorName);
     32  var currentlyActive = activeTinyMCE($editor);
     33  hcGenerateShortCodeInsertEditor(shortCode, $editor, editorName, currentlyActive);
    3234}
    3335
    34 function hcGenerateShortCodeInsertEditor(shortCodeValue, wpEditor) {
     36function activeTinyMCE($wpEditor) {
     37  return $wpEditor.parents('.wp-editor-wrap').first().hasClass('tmce-active');
     38}
     39
     40function hcGenerateShortCodeInsertEditor(shortCodeValue, $wpEditor, wpEditorName, activeTinyMce) {
    3541  var fullShortCode = '[hc-hmw snippet="' + shortCodeValue + '"]';
    36   tinyMCE.editors[wpEditor].focus();
    37   tinyMCE.execCommand('mceInsertContent', false, fullShortCode);
     42  if (activeTinyMce) {
     43    tinyMCE.editors[wpEditorName].focus();
     44    tinyMCE.execCommand('mceInsertContent', false, fullShortCode);
     45  } else {
     46    // figure out how to insert at the last cursor position in the editor
     47  }
    3848  tb_remove();
    3949}
    4050
    4151jQuery(document).ready(function() {
    42   tinymce.init({
    43       selector: "textarea"});
    44 
    4552  jQuery('body').on('click', '.button.hc-wp-media-button', function() {
    4653    hcShortCodeModalContents(this);
Note: See TracChangeset for help on using the changeset viewer.