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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/**
* fullpage.js
*
* Copyright 2009, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://tinymce.moxiecode.com/license
* Contributing: http://tinymce.moxiecode.com/contributing
*/
(function() {
tinyMCEPopup.requireLangPack();
var defaultDocTypes =
'XHTML 1.0 Transitional=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">,' +
'XHTML 1.0 Frameset=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">,' +
'XHTML 1.0 Strict=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">,' +
'XHTML 1.1=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">,' +
'HTML 4.01 Transitional=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">,' +
'HTML 4.01 Strict=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">,' +
'HTML 4.01 Frameset=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
var defaultEncodings =
'Western european (iso-8859-1)=iso-8859-1,' +
'Central European (iso-8859-2)=iso-8859-2,' +
'Unicode (UTF-8)=utf-8,' +
'Chinese traditional (Big5)=big5,' +
'Cyrillic (iso-8859-5)=iso-8859-5,' +
'Japanese (iso-2022-jp)=iso-2022-jp,' +
'Greek (iso-8859-7)=iso-8859-7,' +
'Korean (iso-2022-kr)=iso-2022-kr,' +
'ASCII (us-ascii)=us-ascii';
var defaultFontNames = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
var defaultFontSizes = '10px,11px,12px,13px,14px,15px,16px';
function setVal(id, value) {
var elm = document.getElementById(id);
if (elm) {
value = value || '';
if (elm.nodeName == "SELECT")
selectByValue(document.forms[0], id, value);
else if (elm.type == "checkbox")
elm.checked = !!value;
else
elm.value = value;
}
};
function getVal(id) {
var elm = document.getElementById(id);
if (elm.nodeName == "SELECT")
return elm.options[elm.selectedIndex].value;
if (elm.type == "checkbox")
return elm.checked;
return elm.value;
};
window.FullPageDialog = {
changedStyle : function() {
var val, styles = tinyMCEPopup.editor.dom.parseStyle(getVal('style'));
setVal('fontface', styles['font-face']);
setVal('fontsize', styles['font-size']);
setVal('textcolor', styles['color']);
if (val = styles['background-image'])
setVal('bgimage', val.replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1"));
else
setVal('bgimage', '');
setVal('bgcolor', styles['background-color']);
// Reset margin form elements
setVal('topmargin', '');
setVal('rightmargin', '');
setVal('bottommargin', '');
setVal('leftmargin', '');
// Expand margin
if (val = styles['margin']) {
val = val.split(' ');
styles['margin-top'] = val[0] || '';
styles['margin-right'] = val[1] || val[0] || '';
styles['margin-bottom'] = val[2] || val[0] || '';
styles['margin-left'] = val[3] || val[0] || '';
}
if (val = styles['margin-top'])
setVal('topmargin', val.replace(/px/, ''));
if (val = styles['margin-right'])
setVal('rightmargin', val.replace(/px/, ''));
if (val = styles['margin-bottom'])
setVal('bottommargin', val.replace(/px/, ''));
if (val = styles['margin-left'])
setVal('leftmargin', val.replace(/px/, ''));
updateColor('bgcolor_pick', 'bgcolor');
updateColor('textcolor_pick', 'textcolor');
},
changedStyleProp : function() {
var val, dom = tinyMCEPopup.editor.dom, styles = dom.parseStyle(getVal('style'));
styles['font-face'] = getVal('fontface');
styles['font-size'] = getVal('fontsize');
styles['color'] = getVal('textcolor');
styles['background-color'] = getVal('bgcolor');
if (val = getVal('bgimage'))
styles['background-image'] = "url('" + val + "')";
else
styles['background-image'] = '';
delete styles['margin'];
if (val = getVal('topmargin'))
styles['margin-top'] = val + "px";
else
styles['margin-top'] = '';
if (val = getVal('rightmargin'))
styles['margin-right'] = val + "px";
else
styles['margin-right'] = '';
if (val = getVal('bottommargin'))
styles['margin-bottom'] = val + "px";
else
styles['margin-bottom'] = '';
if (val = getVal('leftmargin'))
styles['margin-left'] = val + "px";
else
styles['margin-left'] = '';
// Serialize, parse and reserialize this will compress redundant styles
setVal('style', dom.serializeStyle(dom.parseStyle(dom.serializeStyle(styles))));
this.changedStyle();
},
update : function() {
var data = {};
tinymce.each(tinyMCEPopup.dom.select('select,input,textarea'), function(node) {
data[node.id] = getVal(node.id);
});
tinyMCEPopup.editor.plugins.fullpage._dataToHtml(data);
tinyMCEPopup.close();
}
};
function init() {
var form = document.forms[0], i, item, list, editor = tinyMCEPopup.editor;
// Setup doctype select box
list = editor.getParam("fullpage_doctypes", defaultDocTypes).split(',');
for (i = 0; i < list.length; i++) {
item = list[i].split('=');
if (item.length > 1)
addSelectValue(form, 'doctype', item[0], item[1]);
}
// Setup fonts select box
list = editor.getParam("fullpage_fonts", defaultFontNames).split(';');
for (i = 0; i < list.length; i++) {
item = list[i].split('=');
if (item.length > 1)
addSelectValue(form, 'fontface', item[0], item[1]);
}
// Setup fontsize select box
list = editor.getParam("fullpage_fontsizes", defaultFontSizes).split(',');
for (i = 0; i < list.length; i++)
addSelectValue(form, 'fontsize', list[i], list[i]);
// Setup encodings select box
list = editor.getParam("fullpage_encodings", defaultEncodings).split(',');
for (i = 0; i < list.length; i++) {
item = list[i].split('=');
if (item.length > 1)
addSelectValue(form, 'docencoding', item[0], item[1]);
}
// Setup color pickers
document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
document.getElementById('link_color_pickcontainer').innerHTML = getColorPickerHTML('link_color_pick','link_color');
document.getElementById('visited_color_pickcontainer').innerHTML = getColorPickerHTML('visited_color_pick','visited_color');
document.getElementById('active_color_pickcontainer').innerHTML = getColorPickerHTML('active_color_pick','active_color');
document.getElementById('textcolor_pickcontainer').innerHTML = getColorPickerHTML('textcolor_pick','textcolor');
document.getElementById('stylesheet_browsercontainer').innerHTML = getBrowserHTML('stylesheetbrowser','stylesheet','file','fullpage');
document.getElementById('bgimage_pickcontainer').innerHTML = getBrowserHTML('bgimage_browser','bgimage','image','fullpage');
// Resize some elements
if (isVisible('stylesheetbrowser'))
document.getElementById('stylesheet').style.width = '220px';
if (isVisible('link_href_browser'))
document.getElementById('element_link_href').style.width = '230px';
if (isVisible('bgimage_browser'))
document.getElementById('bgimage').style.width = '210px';
// Update form
tinymce.each(tinyMCEPopup.getWindowArg('data'), function(value, key) {
setVal(key, value);
});
FullPageDialog.changedStyle();
// Update colors
updateColor('textcolor_pick', 'textcolor');
updateColor('bgcolor_pick', 'bgcolor');
updateColor('visited_color_pick', 'visited_color');
updateColor('active_color_pick', 'active_color');
updateColor('link_color_pick', 'link_color');
};
tinyMCEPopup.onInit.add(init);
})();
|