forked from cleditor/cleditor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.cleditor.maximize.js
76 lines (63 loc) · 1.82 KB
/
jquery.cleditor.maximize.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//by Sergio Drago Sergio Drago <albsteen@gmail.com>
//updated and fixed by Milan Svoboda <milan.svoboda@centrum.cz>
var clmai18n_en = {
title: "Maximize"
};
if (!clmai18n) {
var clmai18n = clmai18n_en;
}
(function($) {
$.cleditor.buttons.maximize = {
name: "maximize",
image: "maximize.gif",
title: clmai18n.title,
command: "",
popupName: "",
buttonClick: maximizeButtonClick
};
$.cleditor.defaultOptions.controls =
$.cleditor.defaultOptions.controls.replace(" source", " source maximize");
$.cleditor.defaultOptions.maximized = false;
function maximizeButtonClick(e, data) {
var editor = data.editor;
var b = $("body");
var m = editor.$main;
if (editor.options.maximized == false) {
editor.options.orig = {
overflow: b.css("overflow"),
position: m.css("position"),
width: m.css("width"),
height: m.css("height"),
offset: m.offset(),
zindex: m.css("z-index")
};
b.css({ overflow: "hidden" });
m.css({ position: "absolute", top: 0, left: 0,
width: $(window).width() - 4,
height: $(window).height() - 4 });
m.width($(window).width() - 4);
m.height($(window).height() - 4);
m.offset({ top: 0, left: 0 });
m.css({ 'z-index': 1 });
editor.options.maximized = true;
editor.options.scrollto = 0;
} else {
var orig = editor.options.orig;
b.css({ overflow: orig.overflow });
m.css({ position: orig.position, top: orig.offset.top, left: orig.offset.left,
width: orig.width,
height: orig.height });
m.width(orig.width);
m.height(orig.height);
m.offset(orig.offset);
m.css({ 'z-index': orig.zindex });
editor.options.maximized = false;
editor.options.scrollto = m.position().top;
}
editor.updateTextArea();
editor.refresh();
$(window).scrollTop(editor.options.scrollto);
if (!$.browser.msie) { editor.focus(); } // don't run with scrollTo in IE
return false;
}
})(jQuery);