-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
52 lines (48 loc) · 1.46 KB
/
plugin.js
File metadata and controls
52 lines (48 loc) · 1.46 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
jQuery(document).ready(function() {
var span = jQuery('h3 span');
if ('0' != span.length) {
//theme editor
var file = span.html();
file = file.replace( /\(|\)/g, '');
} else {
//plugin editor
file = jQuery('input[name="file"]').val();
}
file = file.split('.');
mode = file[1];
if (mode != 'php')
mode = 'css';
var textarea = document.getElementById("newcontent");
if (textarea) {
var editor = CodeMirror.fromTextArea(textarea, {
theme: "elegant",
mode: mode,
lineNumbers: true,
onKeyEvent: function(i, e) {
// Hook into F11
if ((e.keyCode == 122 || e.keyCode == 27) && e.type == "keydown") {
e.stop();
return toggleFullscreenEditing();
}
},
});
function toggleFullscreenEditing() {
var editorDiv = jQuery(".CodeMirror-scroll");
if (!editorDiv.hasClass("fullscreen")) {
toggleFullscreenEditing.beforeFullscreen = {
height: editorDiv.height(),
width: editorDiv.width()
}
editorDiv.addClass("fullscreen");
editorDiv.height("100%");
editorDiv.width("100%");
editor.refresh();
} else {
editorDiv.removeClass("fullscreen");
editorDiv.height(toggleFullscreenEditing.beforeFullscreen.height);
editorDiv.width(toggleFullscreenEditing.beforeFullscreen.width);
editor.refresh();
}
}
}
});