/shared/shortcodes/js/tinymce.js

https://github.com/deltafactory/landing-pages · JavaScript · 190 lines · 35 code · 8 blank · 147 comment · 7 complexity · 5a4135c6f3bf845778b7b3e45f345069 MD5 · raw file

  1. (function() {
  2. // Check Inbound Active Plugins
  3. var indexOf = function(needle) {
  4. if(typeof Array.prototype.indexOf === 'function') {
  5. indexOf = Array.prototype.indexOf;
  6. } else {
  7. indexOf = function(needle) {
  8. var i = -1, index = -1;
  9. for(i = 0; i < this.length; i++) {
  10. if(this[i] === needle) {
  11. index = i;
  12. break;
  13. }
  14. }
  15. return index;
  16. };
  17. }
  18. return indexOf.call(this, needle);
  19. };
  20. var active_plugins = inbound_load.inbound_plugins,
  21. cta_check = 'cta',
  22. cta_status = indexOf.call(active_plugins, cta_check),
  23. lp_check = 'landing-pages',
  24. lp_status = indexOf.call(active_plugins, lp_check),
  25. leads_check = 'leads',
  26. leads_status = indexOf.call(active_plugins, leads_check);
  27. // End Check Active Plugins
  28. if (leads_status > -1) {
  29. console.log("leads on");
  30. }
  31. if (lp_status > -1) {
  32. console.log("lp on");
  33. }
  34. if (cta_status > -1) {
  35. console.log("cta on");
  36. }
  37. /* Broken from 3.9 forward
  38. var shortcode_addons = ["landing-pages","cta","leads"]; // Addon example
  39. tinyMCE.create('tinymce.plugins.InboundShortcodes', {
  40. init: function(ed, url) {
  41. ed.addCommand('InboundShortcodesPopup', function(a, params) {
  42. var popup = params.identifier;
  43. tb_show( inbound_load.pop_title, inbound_load.image_dir + 'popup.php?popup=' + popup + '&width=' + 900 + "&path=" + inbound_load.image_dir);
  44. // ajax call
  45. var userID = jQuery("#user-id").val();
  46. var clicked = jQuery.cookie("inbound_shortcode_trigger");
  47. console.log("CLICKED");
  48. if (clicked != "true") {
  49. jQuery.ajax({
  50. type: 'POST',
  51. url: ajaxurl,
  52. data: {
  53. action: 'inbound_shortcode_prompt_ajax',
  54. user_id: userID
  55. },
  56. success: function(data){
  57. var self = this;
  58. console.log('ran notice');
  59. }
  60. });
  61. }
  62. jQuery.cookie("inbound_shortcode_trigger", true, { path: '/', expires: 365 });
  63. });
  64. },
  65. createControl: function(btn, e) {
  66. if (btn == 'InboundShortcodesButton') {
  67. var a = this;
  68. // adds the tinymce button
  69. btn = e.createSplitButton('InboundShortcodesButton', {
  70. title: 'Insert Shortcode',
  71. image: inbound_load.image_dir + 'shortcodes-blue.png',
  72. icons: true
  73. });
  74. // adds the dropdown to the button
  75. btn.onRenderMenu.add(function(c, b) {
  76. b.add({title : 'Inbound Form Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
  77. a.addWithPopup( b, 'Build a Form', 'forms' );
  78. a.addWithPopup( b, 'Insert Existing Form', 'quick-forms' );
  79. a.addWithPopup( b, 'Build a Button', 'button' );
  80. if (cta_status > -1) {
  81. b.add({title : 'Call to Action Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
  82. a.addWithPopup( b, 'Insert Call to Action', 'call-to-action' ); // to to CTA
  83. }
  84. if (lp_status > -1) {
  85. //b.add({title : 'Landing Page Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
  86. //a.addWithPopup( b, 'Insert Landing Page Lists', 'landing_pages' );
  87. }
  88. b.add({title : 'Inbound Style Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
  89. a.addWithPopup( b, 'Social Share', 'social-share' );
  90. a.addWithPopup( b, 'Insert Icon List', 'lists' );
  91. a.addWithPopup( b, 'Insert Columns', 'columns' );
  92. /* Loop for Addon Shortcode KEEP
  93. myArray = shortcode_addons;
  94. for(i=0; i<myArray.length; i++) {
  95. a.addWithPopup( b, myArray[i], myArray[i] );
  96. }
  97. */
  98. /**
  99. //a.addWithPopup( b, 'Insert Button Shortcode', 'button' );
  100. //a.addWithPopup( b, 'Alert', 'alert' );
  101. //a.addWithPopup( b, 'Call Out', 'callout' );
  102. //b.add({title : 'Layout Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
  103. //a.addWithPopup( b, 'Content Box', 'content_box' );
  104. //a.addWithPopup( b, 'Divider', 'divider' );
  105. //a.addWithPopup( b, 'Tabs', 'tabs' );
  106. // Need forking
  107. //a.addWithPopup( b, 'Heading', 'heading' );
  108. //a.addWithPopup( b, 'Icon', 'icon' );
  109. //a.addWithPopup( b, 'Intro', 'intro' );
  110. //a.addWithPopup( b, 'Lead Paragraph', 'leadp' );
  111. //a.addWithPopup( b, 'Map', 'gmap' );
  112. //a.addWithPopup( b, 'Pricing', 'pricing' );
  113. //a.addWithPopup( b, 'Profile', 'profile' );
  114. //a.addWithPopup( b, 'Social Links', 'social_links' );
  115. //a.addWithPopup( b, 'Teaser', 'teaser' );
  116. //a.addWithPopup( b, 'Video', 'video' );
  117. });
  118. return btn;
  119. }
  120. return null;
  121. },
  122. addWithPopup: function(ed, title, id, sub) {
  123. ed.add({
  124. title: title,
  125. icon: 'editor-icon-' + id,
  126. onclick: function() {
  127. tinyMCE.activeEditor.execCommand('InboundShortcodesPopup', false, {
  128. title: title,
  129. identifier: id
  130. });
  131. }
  132. });
  133. // http://www.tinymce.com/wiki.php/API3:class.tinymce.ui.DropMenu
  134. if (typeof (sub) != "undefined" && sub != null && sub != "") {
  135. var sub1 = ed.addMenu({title : 'Menu 3'});
  136. sub1.add({title : 'Menu 1.1', onclick : function() {
  137. alert('Item 1.1 was clicked.');
  138. }});
  139. }
  140. },
  141. addImmediate: function(ed, title, sc) {
  142. ed.add({
  143. title: title,
  144. onclick: function() {
  145. tinyMCE.activeEditor.execCommand('mceInsertContent', false, sc);
  146. }
  147. });
  148. },
  149. getInfo: function() {
  150. return {
  151. longname: 'Inbound Shortcodes',
  152. author: 'David Wells',
  153. authorurl: 'http://www.inboundnow.com/',
  154. infourl: 'http://www.inboundnow.com/',
  155. version: '1.0'
  156. };
  157. }
  158. });
  159. tinymce.PluginManager.add('InboundShortcodes', tinymce.plugins.InboundShortcodes);
  160. */
  161. })();