PageRenderTime 16ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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