forked from jonparis/AstridReminders
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheditor_plugin.js
61 lines (59 loc) · 2.72 KB
/
editor_plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* AstridReminders JS
*
* PHP version 5
*
* @package AstridCTA
* @author Jon Paris ([email protected]), Chris Lema ([email protected]) and Justin Kussow ([email protected])
* @copyright Copyright (c)2012 ALL RIGHTS RESERVED
*/
(function() {
tinymce.create('tinymce.plugins.AstridRemindMe', {
init : function(ed, url) {
ed.addCommand('add_link_form', function() {
var astrid_source_title = jQuery('#title').val();
var astrid_source_url = "";
var site_name = jQuery('#wp-admin-bar-site-name > a').html();
var selection = tinyMCE.activeEditor.selection.getContent();
if(jQuery("#view-post-btn > a") && jQuery("#view-post-btn > a").attr("href") != null)
astrid_source_url = jQuery("#view-post-btn > a").attr("href");
else if (jQuery("#referredby") && jQuery("#post_ID")){
var post_id = jQuery("#post_ID").val();
var source_base = jQuery("#editor-buttons-css").attr('href');
var until_str = source_base.indexOf("/wp-includes");
var astrid_source_url = source_base.substring(0, until_str) + "?p=" + post_id;
}
ed.windowManager.open({
title : 'Astrid - "Remind Me" link or button',
file : url + '/link_editor/astrid_get_link.php?ar_source_url=' + encodeURIComponent(astrid_source_url) +
'&ar_source_name=' + encodeURIComponent(astrid_source_title) +
'&ar_text_selection=' + encodeURIComponent(selection) +
'&ar_site_name=' + encodeURIComponent(site_name),
width : 600 + parseInt(ed.getLang('AstridRemindMe.delta_width', 0)),
height : 520 + parseInt(ed.getLang('AstridRemindMe.delta_height', 0)),
inline : 1
}, {
plugin_url : url
});
});
ed.addButton('astrid_reminder', {
title : 'Create a "remind me" link to create action item reminders',
image : url+'/images/astrid_32.png',
cmd : 'add_link_form'
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : "Astrid Remind Me Link Creator",
author : 'Jon Paris',
authorurl : 'http://astrid.com/',
infourl : 'http://astrid.com/',
version : "1.0"
};
}
});
tinymce.PluginManager.add('astrid_reminder', tinymce.plugins.AstridRemindMe);
})();