-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathadmin_javascript.js.php
More file actions
109 lines (97 loc) · 3.81 KB
/
admin_javascript.js.php
File metadata and controls
109 lines (97 loc) · 3.81 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
ob_start();
$root = dirname(dirname(dirname(dirname(__FILE__))));
if (file_exists($root.'/wp-load.php')) {
// WP 2.6
require_once($root.'/wp-load.php');
} else {
// Before 2.6
require_once($root.'/wp-config.php');
}
ob_end_clean(); //Ensure we don't have output from other plugins.
header("Content-type: text/javascript");
if (!$guessurl = site_url())
$guessurl = wp_guess_url();
$baseuri = $guessurl;
$exhibituri = $baseuri . '/wp-content/plugins/datapress';
$imageurl = $exhibituri . '/exhibit.png';
$footnotesurl = $exhibituri . '/footnotes.png';
print <<<EOF
function guess_type(input) {
var siteUrl = location.hostname;
var jsonRegEx = RegExp("https?:\/\/(w{3}.)?(" + siteUrl + "|.+)\..+\.js(on)?");
if(input.match(/https?:\/\/.+\.google.com.+/)) {
return "google-spreadsheet";
} else if(match = jsonRegEx.exec(input)) {
return "application/json";
}
return "exhibit";
}
function set_post_exhibit(exhibit_id) {
var datapress_link = jQuery('#load_datapress_config_link');
datapress_link[0].href = '$baseuri/wp-admin/admin-ajax.php?action=datapress_configurator&exhibitid=' + exhibit_id + '&TB_iframe=true';
var exhibit_id_element = jQuery('#exhibitid');
exhibit_id_element[0].value = exhibit_id;
}
// send html to the post editor
function add_exhibit_token_and_exit() {
var imagestring = "<img src='$imageurl' alt='Your Exhibit' height='70' width='70'/>";
var footstring = "<img src='$footnotesurl' alt='Your Footnotes' height='70' width = '70'/>";
var h = imagestring + " " + footstring;
var searchfor = '$imageurl';
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
ed.focus();
if (ed.getContent().indexOf(searchfor) == -1) {
if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
ed.execCommand('mceInsertContent', false, h);
}
} else if ( typeof edInsertContent == 'function' ) {
if ((typeof edCanvas.value != 'undefined') && (edCanvas.value.indexOf(searchfor) == -1)) {
edInsertContent(edCanvas, h);
}
} else {
if (jQuery(edCanvas).val().indexOf(searchfor) == -1) {
jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
}
}
tb_remove();
}
// Add dataset marker to the current editing location in the editor
function add_dataset_token_and_exit(dbid) {
var length = jQuery.fn.contextMenu.displayfuncs ? jQuery.fn.contextMenu.displayfuncs.length : 0;
var spanopen = "<span class='dp_editdata' dbid='" + dbid + "' displayid='" + length + "'>";
var h = spanopen + " </span>";
var searchfor = spanopen + "\\s+</span>";
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
ed.focus();
if (ed.getContent().search(searchfor) == -1) {
if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
ed.execCommand('mceInsertContent', false, h);
}
} else if ( typeof edInsertContent == 'function' ) {
if ((typeof edCanvas.value != 'undefined') && (edCanvas.value.search(searchfor) == -1)) {
edInsertContent(edCanvas, h);
}
} else {
if (jQuery(edCanvas).val().search(searchfor) == -1) {
jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
}
}
tb_remove();
jQuery(".dp_editdata[dbid=" + dbid + "]").contextMenu('dataEditMenu', {
bindings: {
'edit': function(t) {
jQuery("span#dpEditDataLinkContainer").html("<a href=\"$baseuri/wp-admin/admin-ajax.php?identifier=" + dbid + "&action=template_editor&TB_iframe=true&width=640&height=673\" id=\"dpEditDataLink\" class=\"thickbox\">test</a>");
tb_init('a#dpEditDataLink')
jQuery("a#dpEditDataLink").click();
},
'delete': function(t) {
tinyMCE.activeEditor.execCommand('mceRemoveNode', false, null);
},
}
});
}
EOF
?>