use_tinymce 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +34 -25
- data/Rakefile +13 -3
- data/assets/tinymce_jquery_4_0_2/tinymce/LICENSE.TXT +504 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/changelog.txt +157 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/jquery.tinymce.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/langs/readme.md +3 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/license.txt +504 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/advlist/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/anchor/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/autolink/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/autoresize/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/autosave/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/bbcode/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/charmap/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/code/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/compat3x/editable_selects.js +70 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/compat3x/form_utils.js +210 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/compat3x/mctabs.js +162 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/compat3x/tiny_mce_popup.js +435 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/compat3x/validate.js +252 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/contextmenu/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/directionality/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-cool.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-cry.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-embarassed.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-frown.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-innocent.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-kiss.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-laughing.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-sealed.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-smile.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-surprised.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-undecided.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-wink.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/img/smiley-yell.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/emoticons/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/example/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/example_dependency/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/fullpage/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/fullscreen/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/hr/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/image/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/insertdatetime/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/layer/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/legacyoutput/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/link/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/lists/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/media/moxieplayer.swf +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/media/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/nonbreaking/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/noneditable/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/pagebreak/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/paste/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/preview/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/print/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/save/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/searchreplace/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/spellchecker/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/tabfocus/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/table/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/template/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/textcolor/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/visualblocks/css/visualblocks.css +114 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/visualblocks/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/visualchars/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/plugins/wordcount/plugin.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/content.inline.min.css +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/content.min.css +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon-small.eot +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon-small.svg +166 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon-small.ttf +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon-small.woff +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon.eot +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon.svg +150 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon.ttf +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/icomoon.woff +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/fonts/readme.md +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/img/anchor.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/img/loader.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/img/object.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/img/trans.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/img/wline.gif +0 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/skin.ie7.min.css +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/skins/lightgray/skin.min.css +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/themes/modern/theme.min.js +1 -0
- data/assets/tinymce_jquery_4_0_2/tinymce/js/tinymce/tinymce.min.js +9 -0
- data/lib/tasks/use_tinymce.rake +14 -1
- data/lib/use_tinymce/railengine.rb +1 -1
- data/lib/use_tinymce/use_tinymce.rb +15 -6
- data/lib/use_tinymce/version.rb +1 -0
- metadata +474 -386
@@ -0,0 +1,435 @@
|
|
1
|
+
/**
|
2
|
+
* Popup.js
|
3
|
+
*
|
4
|
+
* Copyright, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
// Some global instances
|
12
|
+
var tinymce = null, tinyMCEPopup, tinyMCE;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* TinyMCE popup/dialog helper class. This gives you easy access to the
|
16
|
+
* parent editor instance and a bunch of other things. It's higly recommended
|
17
|
+
* that you load this script into your dialogs.
|
18
|
+
*
|
19
|
+
* @static
|
20
|
+
* @class tinyMCEPopup
|
21
|
+
*/
|
22
|
+
tinyMCEPopup = {
|
23
|
+
/**
|
24
|
+
* Initializes the popup this will be called automatically.
|
25
|
+
*
|
26
|
+
* @method init
|
27
|
+
*/
|
28
|
+
init : function() {
|
29
|
+
var t = this, w, ti, settings;
|
30
|
+
|
31
|
+
// Find window & API
|
32
|
+
w = t.getWin();
|
33
|
+
tinymce = w.tinymce;
|
34
|
+
tinyMCE = w.tinyMCE;
|
35
|
+
t.editor = tinymce.EditorManager.activeEditor;
|
36
|
+
t.params = t.editor.windowManager.params;
|
37
|
+
t.features = t.editor.windowManager.features;
|
38
|
+
settings = t.editor.settings;
|
39
|
+
|
40
|
+
// Setup popup CSS path(s)
|
41
|
+
if (settings.popup_css !== false) {
|
42
|
+
if (settings.popup_css) {
|
43
|
+
settings.popup_css = t.documentBaseURI.toAbsolute(settings.popup_css);
|
44
|
+
} else {
|
45
|
+
settings.popup_css = t.baseURI.toAbsolute("themes/" + settings.theme + "/skins/" + settings.skin + "/dialog.css");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
if (settings.popup_css_add) {
|
50
|
+
settings.popup_css += ',' + t.documentBaseURI.toAbsolute(settings.popup_css_add);
|
51
|
+
}
|
52
|
+
|
53
|
+
// Setup local DOM
|
54
|
+
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document, {ownEvents: true, proxy: tinyMCEPopup._eventProxy});
|
55
|
+
t.dom.bind(window, 'ready', t._onDOMLoaded, t);
|
56
|
+
|
57
|
+
// Enables you to skip loading the default css
|
58
|
+
if (t.features.popup_css !== false)
|
59
|
+
t.dom.loadCSS(t.features.popup_css || t.editor.settings.popup_css);
|
60
|
+
|
61
|
+
// Setup on init listeners
|
62
|
+
t.listeners = [];
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Fires when the popup is initialized.
|
66
|
+
*
|
67
|
+
* @event onInit
|
68
|
+
* @param {tinymce.Editor} editor Editor instance.
|
69
|
+
* @example
|
70
|
+
* // Alerts the selected contents when the dialog is loaded
|
71
|
+
* tinyMCEPopup.onInit.add(function(ed) {
|
72
|
+
* alert(ed.selection.getContent());
|
73
|
+
* });
|
74
|
+
*
|
75
|
+
* // Executes the init method on page load in some object using the SomeObject scope
|
76
|
+
* tinyMCEPopup.onInit.add(SomeObject.init, SomeObject);
|
77
|
+
*/
|
78
|
+
t.onInit = {
|
79
|
+
add : function(f, s) {
|
80
|
+
t.listeners.push({func : f, scope : s});
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
t.isWindow = !t.getWindowArg('mce_inline');
|
85
|
+
t.id = t.getWindowArg('mce_window_id');
|
86
|
+
},
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Returns the reference to the parent window that opened the dialog.
|
90
|
+
*
|
91
|
+
* @method getWin
|
92
|
+
* @return {Window} Reference to the parent window that opened the dialog.
|
93
|
+
*/
|
94
|
+
getWin : function() {
|
95
|
+
// Added frameElement check to fix bug: #2817583
|
96
|
+
return (!window.frameElement && window.dialogArguments) || opener || parent || top;
|
97
|
+
},
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Returns a window argument/parameter by name.
|
101
|
+
*
|
102
|
+
* @method getWindowArg
|
103
|
+
* @param {String} n Name of the window argument to retrive.
|
104
|
+
* @param {String} dv Optional default value to return.
|
105
|
+
* @return {String} Argument value or default value if it wasn't found.
|
106
|
+
*/
|
107
|
+
getWindowArg : function(n, dv) {
|
108
|
+
var v = this.params[n];
|
109
|
+
|
110
|
+
return tinymce.is(v) ? v : dv;
|
111
|
+
},
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Returns a editor parameter/config option value.
|
115
|
+
*
|
116
|
+
* @method getParam
|
117
|
+
* @param {String} n Name of the editor config option to retrive.
|
118
|
+
* @param {String} dv Optional default value to return.
|
119
|
+
* @return {String} Parameter value or default value if it wasn't found.
|
120
|
+
*/
|
121
|
+
getParam : function(n, dv) {
|
122
|
+
return this.editor.getParam(n, dv);
|
123
|
+
},
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Returns a language item by key.
|
127
|
+
*
|
128
|
+
* @method getLang
|
129
|
+
* @param {String} n Language item like mydialog.something.
|
130
|
+
* @param {String} dv Optional default value to return.
|
131
|
+
* @return {String} Language value for the item like "my string" or the default value if it wasn't found.
|
132
|
+
*/
|
133
|
+
getLang : function(n, dv) {
|
134
|
+
return this.editor.getLang(n, dv);
|
135
|
+
},
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Executed a command on editor that opened the dialog/popup.
|
139
|
+
*
|
140
|
+
* @method execCommand
|
141
|
+
* @param {String} cmd Command to execute.
|
142
|
+
* @param {Boolean} ui Optional boolean value if the UI for the command should be presented or not.
|
143
|
+
* @param {Object} val Optional value to pass with the comman like an URL.
|
144
|
+
* @param {Object} a Optional arguments object.
|
145
|
+
*/
|
146
|
+
execCommand : function(cmd, ui, val, a) {
|
147
|
+
a = a || {};
|
148
|
+
a.skip_focus = 1;
|
149
|
+
|
150
|
+
this.restoreSelection();
|
151
|
+
return this.editor.execCommand(cmd, ui, val, a);
|
152
|
+
},
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Resizes the dialog to the inner size of the window. This is needed since various browsers
|
156
|
+
* have different border sizes on windows.
|
157
|
+
*
|
158
|
+
* @method resizeToInnerSize
|
159
|
+
*/
|
160
|
+
resizeToInnerSize : function() {
|
161
|
+
var t = this;
|
162
|
+
|
163
|
+
// Detach it to workaround a Chrome specific bug
|
164
|
+
// https://sourceforge.net/tracker/?func=detail&atid=635682&aid=2926339&group_id=103281
|
165
|
+
setTimeout(function() {
|
166
|
+
var vp = t.dom.getViewPort(window);
|
167
|
+
|
168
|
+
t.editor.windowManager.resizeBy(
|
169
|
+
t.getWindowArg('mce_width') - vp.w,
|
170
|
+
t.getWindowArg('mce_height') - vp.h,
|
171
|
+
t.id || window
|
172
|
+
);
|
173
|
+
}, 10);
|
174
|
+
},
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Will executed the specified string when the page has been loaded. This function
|
178
|
+
* was added for compatibility with the 2.x branch.
|
179
|
+
*
|
180
|
+
* @method executeOnLoad
|
181
|
+
* @param {String} s String to evalutate on init.
|
182
|
+
*/
|
183
|
+
executeOnLoad : function(s) {
|
184
|
+
this.onInit.add(function() {
|
185
|
+
eval(s);
|
186
|
+
});
|
187
|
+
},
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Stores the current editor selection for later restoration. This can be useful since some browsers
|
191
|
+
* looses it's selection if a control element is selected/focused inside the dialogs.
|
192
|
+
*
|
193
|
+
* @method storeSelection
|
194
|
+
*/
|
195
|
+
storeSelection : function() {
|
196
|
+
this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark(1);
|
197
|
+
},
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Restores any stored selection. This can be useful since some browsers
|
201
|
+
* looses it's selection if a control element is selected/focused inside the dialogs.
|
202
|
+
*
|
203
|
+
* @method restoreSelection
|
204
|
+
*/
|
205
|
+
restoreSelection : function() {
|
206
|
+
var t = tinyMCEPopup;
|
207
|
+
|
208
|
+
if (!t.isWindow && tinymce.isIE)
|
209
|
+
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
|
210
|
+
},
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Loads a specific dialog language pack. If you pass in plugin_url as a argument
|
214
|
+
* when you open the window it will load the <plugin url>/langs/<code>_dlg.js lang pack file.
|
215
|
+
*
|
216
|
+
* @method requireLangPack
|
217
|
+
*/
|
218
|
+
requireLangPack : function() {
|
219
|
+
var t = this, u = t.getWindowArg('plugin_url') || t.getWindowArg('theme_url');
|
220
|
+
|
221
|
+
if (u && t.editor.settings.language && t.features.translate_i18n !== false && t.editor.settings.language_load !== false) {
|
222
|
+
u += '/langs/' + t.editor.settings.language + '_dlg.js';
|
223
|
+
|
224
|
+
if (!tinymce.ScriptLoader.isDone(u)) {
|
225
|
+
document.write('<script type="text/javascript" src="' + u + '"></script>');
|
226
|
+
tinymce.ScriptLoader.markDone(u);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
},
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Executes a color picker on the specified element id. When the user
|
233
|
+
* then selects a color it will be set as the value of the specified element.
|
234
|
+
*
|
235
|
+
* @method pickColor
|
236
|
+
* @param {DOMEvent} e DOM event object.
|
237
|
+
* @param {string} element_id Element id to be filled with the color value from the picker.
|
238
|
+
*/
|
239
|
+
pickColor : function(e, element_id) {
|
240
|
+
this.execCommand('mceColorPicker', true, {
|
241
|
+
color : document.getElementById(element_id).value,
|
242
|
+
func : function(c) {
|
243
|
+
document.getElementById(element_id).value = c;
|
244
|
+
|
245
|
+
try {
|
246
|
+
document.getElementById(element_id).onchange();
|
247
|
+
} catch (ex) {
|
248
|
+
// Try fire event, ignore errors
|
249
|
+
}
|
250
|
+
}
|
251
|
+
});
|
252
|
+
},
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Opens a filebrowser/imagebrowser this will set the output value from
|
256
|
+
* the browser as a value on the specified element.
|
257
|
+
*
|
258
|
+
* @method openBrowser
|
259
|
+
* @param {string} element_id Id of the element to set value in.
|
260
|
+
* @param {string} type Type of browser to open image/file/flash.
|
261
|
+
* @param {string} option Option name to get the file_broswer_callback function name from.
|
262
|
+
*/
|
263
|
+
openBrowser : function(element_id, type, option) {
|
264
|
+
tinyMCEPopup.restoreSelection();
|
265
|
+
this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
|
266
|
+
},
|
267
|
+
|
268
|
+
/**
|
269
|
+
* Creates a confirm dialog. Please don't use the blocking behavior of this
|
270
|
+
* native version use the callback method instead then it can be extended.
|
271
|
+
*
|
272
|
+
* @method confirm
|
273
|
+
* @param {String} t Title for the new confirm dialog.
|
274
|
+
* @param {function} cb Callback function to be executed after the user has selected ok or cancel.
|
275
|
+
* @param {Object} s Optional scope to execute the callback in.
|
276
|
+
*/
|
277
|
+
confirm : function(t, cb, s) {
|
278
|
+
this.editor.windowManager.confirm(t, cb, s, window);
|
279
|
+
},
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Creates a alert dialog. Please don't use the blocking behavior of this
|
283
|
+
* native version use the callback method instead then it can be extended.
|
284
|
+
*
|
285
|
+
* @method alert
|
286
|
+
* @param {String} t Title for the new alert dialog.
|
287
|
+
* @param {function} cb Callback function to be executed after the user has selected ok.
|
288
|
+
* @param {Object} s Optional scope to execute the callback in.
|
289
|
+
*/
|
290
|
+
alert : function(tx, cb, s) {
|
291
|
+
this.editor.windowManager.alert(tx, cb, s, window);
|
292
|
+
},
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Closes the current window.
|
296
|
+
*
|
297
|
+
* @method close
|
298
|
+
*/
|
299
|
+
close : function() {
|
300
|
+
var t = this;
|
301
|
+
|
302
|
+
// To avoid domain relaxing issue in Opera
|
303
|
+
function close() {
|
304
|
+
t.editor.windowManager.close(window);
|
305
|
+
tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
|
306
|
+
};
|
307
|
+
|
308
|
+
if (tinymce.isOpera)
|
309
|
+
t.getWin().setTimeout(close, 0);
|
310
|
+
else
|
311
|
+
close();
|
312
|
+
},
|
313
|
+
|
314
|
+
// Internal functions
|
315
|
+
|
316
|
+
_restoreSelection : function() {
|
317
|
+
var e = window.event.srcElement;
|
318
|
+
|
319
|
+
if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button'))
|
320
|
+
tinyMCEPopup.restoreSelection();
|
321
|
+
},
|
322
|
+
|
323
|
+
/* _restoreSelection : function() {
|
324
|
+
var e = window.event.srcElement;
|
325
|
+
|
326
|
+
// If user focus a non text input or textarea
|
327
|
+
if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text')
|
328
|
+
tinyMCEPopup.restoreSelection();
|
329
|
+
},*/
|
330
|
+
|
331
|
+
_onDOMLoaded : function() {
|
332
|
+
var t = tinyMCEPopup, ti = document.title, bm, h, nv;
|
333
|
+
|
334
|
+
// Translate page
|
335
|
+
if (t.features.translate_i18n !== false) {
|
336
|
+
h = document.body.innerHTML;
|
337
|
+
|
338
|
+
// Replace a=x with a="x" in IE
|
339
|
+
if (tinymce.isIE)
|
340
|
+
h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
|
341
|
+
|
342
|
+
document.dir = t.editor.getParam('directionality','');
|
343
|
+
|
344
|
+
if ((nv = t.editor.translate(h)) && nv != h)
|
345
|
+
document.body.innerHTML = nv;
|
346
|
+
|
347
|
+
if ((nv = t.editor.translate(ti)) && nv != ti)
|
348
|
+
document.title = ti = nv;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (!t.editor.getParam('browser_preferred_colors', false) || !t.isWindow)
|
352
|
+
t.dom.addClass(document.body, 'forceColors');
|
353
|
+
|
354
|
+
document.body.style.display = '';
|
355
|
+
|
356
|
+
// Restore selection in IE when focus is placed on a non textarea or input element of the type text
|
357
|
+
if (tinymce.isIE) {
|
358
|
+
document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
|
359
|
+
|
360
|
+
// Add base target element for it since it would fail with modal dialogs
|
361
|
+
t.dom.add(t.dom.select('head')[0], 'base', {target : '_self'});
|
362
|
+
}
|
363
|
+
|
364
|
+
t.restoreSelection();
|
365
|
+
t.resizeToInnerSize();
|
366
|
+
|
367
|
+
// Set inline title
|
368
|
+
if (!t.isWindow)
|
369
|
+
t.editor.windowManager.setTitle(window, ti);
|
370
|
+
else
|
371
|
+
window.focus();
|
372
|
+
|
373
|
+
if (!tinymce.isIE && !t.isWindow) {
|
374
|
+
t.dom.bind(document, 'focus', function() {
|
375
|
+
t.editor.windowManager.focus(t.id);
|
376
|
+
});
|
377
|
+
}
|
378
|
+
|
379
|
+
// Patch for accessibility
|
380
|
+
tinymce.each(t.dom.select('select'), function(e) {
|
381
|
+
e.onkeydown = tinyMCEPopup._accessHandler;
|
382
|
+
});
|
383
|
+
|
384
|
+
// Call onInit
|
385
|
+
// Init must be called before focus so the selection won't get lost by the focus call
|
386
|
+
tinymce.each(t.listeners, function(o) {
|
387
|
+
o.func.call(o.scope, t.editor);
|
388
|
+
});
|
389
|
+
|
390
|
+
// Move focus to window
|
391
|
+
if (t.getWindowArg('mce_auto_focus', true)) {
|
392
|
+
window.focus();
|
393
|
+
|
394
|
+
// Focus element with mceFocus class
|
395
|
+
tinymce.each(document.forms, function(f) {
|
396
|
+
tinymce.each(f.elements, function(e) {
|
397
|
+
if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
|
398
|
+
e.focus();
|
399
|
+
return false; // Break loop
|
400
|
+
}
|
401
|
+
});
|
402
|
+
});
|
403
|
+
}
|
404
|
+
|
405
|
+
document.onkeyup = tinyMCEPopup._closeWinKeyHandler;
|
406
|
+
},
|
407
|
+
|
408
|
+
_accessHandler : function(e) {
|
409
|
+
e = e || window.event;
|
410
|
+
|
411
|
+
if (e.keyCode == 13 || e.keyCode == 32) {
|
412
|
+
var elm = e.target || e.srcElement;
|
413
|
+
|
414
|
+
if (elm.onchange)
|
415
|
+
elm.onchange();
|
416
|
+
|
417
|
+
return tinymce.dom.Event.cancel(e);
|
418
|
+
}
|
419
|
+
},
|
420
|
+
|
421
|
+
_closeWinKeyHandler : function(e) {
|
422
|
+
e = e || window.event;
|
423
|
+
|
424
|
+
if (e.keyCode == 27)
|
425
|
+
tinyMCEPopup.close();
|
426
|
+
},
|
427
|
+
|
428
|
+
_eventProxy: function(id) {
|
429
|
+
return function(evt) {
|
430
|
+
tinyMCEPopup.dom.events.callNativeHandler(id, evt);
|
431
|
+
};
|
432
|
+
}
|
433
|
+
};
|
434
|
+
|
435
|
+
tinyMCEPopup.init();
|
@@ -0,0 +1,252 @@
|
|
1
|
+
/**
|
2
|
+
* validate.js
|
3
|
+
*
|
4
|
+
* Copyright, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
// String validation:
|
13
|
+
|
14
|
+
if (!Validator.isEmail('myemail'))
|
15
|
+
alert('Invalid email.');
|
16
|
+
|
17
|
+
// Form validation:
|
18
|
+
|
19
|
+
var f = document.forms['myform'];
|
20
|
+
|
21
|
+
if (!Validator.isEmail(f.myemail))
|
22
|
+
alert('Invalid email.');
|
23
|
+
*/
|
24
|
+
|
25
|
+
var Validator = {
|
26
|
+
isEmail : function(s) {
|
27
|
+
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
|
28
|
+
},
|
29
|
+
|
30
|
+
isAbsUrl : function(s) {
|
31
|
+
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
|
32
|
+
},
|
33
|
+
|
34
|
+
isSize : function(s) {
|
35
|
+
return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
|
36
|
+
},
|
37
|
+
|
38
|
+
isId : function(s) {
|
39
|
+
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
|
40
|
+
},
|
41
|
+
|
42
|
+
isEmpty : function(s) {
|
43
|
+
var nl, i;
|
44
|
+
|
45
|
+
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
|
46
|
+
return true;
|
47
|
+
|
48
|
+
if (s.type == 'checkbox' && !s.checked)
|
49
|
+
return true;
|
50
|
+
|
51
|
+
if (s.type == 'radio') {
|
52
|
+
for (i=0, nl = s.form.elements; i<nl.length; i++) {
|
53
|
+
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
|
57
|
+
return true;
|
58
|
+
}
|
59
|
+
|
60
|
+
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
|
61
|
+
},
|
62
|
+
|
63
|
+
isNumber : function(s, d) {
|
64
|
+
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
|
65
|
+
},
|
66
|
+
|
67
|
+
test : function(s, p) {
|
68
|
+
s = s.nodeType == 1 ? s.value : s;
|
69
|
+
|
70
|
+
return s == '' || new RegExp(p).test(s);
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
var AutoValidator = {
|
75
|
+
settings : {
|
76
|
+
id_cls : 'id',
|
77
|
+
int_cls : 'int',
|
78
|
+
url_cls : 'url',
|
79
|
+
number_cls : 'number',
|
80
|
+
email_cls : 'email',
|
81
|
+
size_cls : 'size',
|
82
|
+
required_cls : 'required',
|
83
|
+
invalid_cls : 'invalid',
|
84
|
+
min_cls : 'min',
|
85
|
+
max_cls : 'max'
|
86
|
+
},
|
87
|
+
|
88
|
+
init : function(s) {
|
89
|
+
var n;
|
90
|
+
|
91
|
+
for (n in s)
|
92
|
+
this.settings[n] = s[n];
|
93
|
+
},
|
94
|
+
|
95
|
+
validate : function(f) {
|
96
|
+
var i, nl, s = this.settings, c = 0;
|
97
|
+
|
98
|
+
nl = this.tags(f, 'label');
|
99
|
+
for (i=0; i<nl.length; i++) {
|
100
|
+
this.removeClass(nl[i], s.invalid_cls);
|
101
|
+
nl[i].setAttribute('aria-invalid', false);
|
102
|
+
}
|
103
|
+
|
104
|
+
c += this.validateElms(f, 'input');
|
105
|
+
c += this.validateElms(f, 'select');
|
106
|
+
c += this.validateElms(f, 'textarea');
|
107
|
+
|
108
|
+
return c == 3;
|
109
|
+
},
|
110
|
+
|
111
|
+
invalidate : function(n) {
|
112
|
+
this.mark(n.form, n);
|
113
|
+
},
|
114
|
+
|
115
|
+
getErrorMessages : function(f) {
|
116
|
+
var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
|
117
|
+
nl = this.tags(f, "label");
|
118
|
+
for (i=0; i<nl.length; i++) {
|
119
|
+
if (this.hasClass(nl[i], s.invalid_cls)) {
|
120
|
+
field = document.getElementById(nl[i].getAttribute("for"));
|
121
|
+
values = { field: nl[i].textContent };
|
122
|
+
if (this.hasClass(field, s.min_cls, true)) {
|
123
|
+
message = ed.getLang('invalid_data_min');
|
124
|
+
values.min = this.getNum(field, s.min_cls);
|
125
|
+
} else if (this.hasClass(field, s.number_cls)) {
|
126
|
+
message = ed.getLang('invalid_data_number');
|
127
|
+
} else if (this.hasClass(field, s.size_cls)) {
|
128
|
+
message = ed.getLang('invalid_data_size');
|
129
|
+
} else {
|
130
|
+
message = ed.getLang('invalid_data');
|
131
|
+
}
|
132
|
+
|
133
|
+
message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
|
134
|
+
return values[b] || '{#' + b + '}';
|
135
|
+
});
|
136
|
+
messages.push(message);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
return messages;
|
140
|
+
},
|
141
|
+
|
142
|
+
reset : function(e) {
|
143
|
+
var t = ['label', 'input', 'select', 'textarea'];
|
144
|
+
var i, j, nl, s = this.settings;
|
145
|
+
|
146
|
+
if (e == null)
|
147
|
+
return;
|
148
|
+
|
149
|
+
for (i=0; i<t.length; i++) {
|
150
|
+
nl = this.tags(e.form ? e.form : e, t[i]);
|
151
|
+
for (j=0; j<nl.length; j++) {
|
152
|
+
this.removeClass(nl[j], s.invalid_cls);
|
153
|
+
nl[j].setAttribute('aria-invalid', false);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
},
|
157
|
+
|
158
|
+
validateElms : function(f, e) {
|
159
|
+
var nl, i, n, s = this.settings, st = true, va = Validator, v;
|
160
|
+
|
161
|
+
nl = this.tags(f, e);
|
162
|
+
for (i=0; i<nl.length; i++) {
|
163
|
+
n = nl[i];
|
164
|
+
|
165
|
+
this.removeClass(n, s.invalid_cls);
|
166
|
+
|
167
|
+
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
|
168
|
+
st = this.mark(f, n);
|
169
|
+
|
170
|
+
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
|
171
|
+
st = this.mark(f, n);
|
172
|
+
|
173
|
+
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
|
174
|
+
st = this.mark(f, n);
|
175
|
+
|
176
|
+
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
|
177
|
+
st = this.mark(f, n);
|
178
|
+
|
179
|
+
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
|
180
|
+
st = this.mark(f, n);
|
181
|
+
|
182
|
+
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
|
183
|
+
st = this.mark(f, n);
|
184
|
+
|
185
|
+
if (this.hasClass(n, s.id_cls) && !va.isId(n))
|
186
|
+
st = this.mark(f, n);
|
187
|
+
|
188
|
+
if (this.hasClass(n, s.min_cls, true)) {
|
189
|
+
v = this.getNum(n, s.min_cls);
|
190
|
+
|
191
|
+
if (isNaN(v) || parseInt(n.value) < parseInt(v))
|
192
|
+
st = this.mark(f, n);
|
193
|
+
}
|
194
|
+
|
195
|
+
if (this.hasClass(n, s.max_cls, true)) {
|
196
|
+
v = this.getNum(n, s.max_cls);
|
197
|
+
|
198
|
+
if (isNaN(v) || parseInt(n.value) > parseInt(v))
|
199
|
+
st = this.mark(f, n);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
return st;
|
204
|
+
},
|
205
|
+
|
206
|
+
hasClass : function(n, c, d) {
|
207
|
+
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
|
208
|
+
},
|
209
|
+
|
210
|
+
getNum : function(n, c) {
|
211
|
+
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
|
212
|
+
c = c.replace(/[^0-9]/g, '');
|
213
|
+
|
214
|
+
return c;
|
215
|
+
},
|
216
|
+
|
217
|
+
addClass : function(n, c, b) {
|
218
|
+
var o = this.removeClass(n, c);
|
219
|
+
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
|
220
|
+
},
|
221
|
+
|
222
|
+
removeClass : function(n, c) {
|
223
|
+
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
|
224
|
+
return n.className = c != ' ' ? c : '';
|
225
|
+
},
|
226
|
+
|
227
|
+
tags : function(f, s) {
|
228
|
+
return f.getElementsByTagName(s);
|
229
|
+
},
|
230
|
+
|
231
|
+
mark : function(f, n) {
|
232
|
+
var s = this.settings;
|
233
|
+
|
234
|
+
this.addClass(n, s.invalid_cls);
|
235
|
+
n.setAttribute('aria-invalid', 'true');
|
236
|
+
this.markLabels(f, n, s.invalid_cls);
|
237
|
+
|
238
|
+
return false;
|
239
|
+
},
|
240
|
+
|
241
|
+
markLabels : function(f, n, ic) {
|
242
|
+
var nl, i;
|
243
|
+
|
244
|
+
nl = this.tags(f, "label");
|
245
|
+
for (i=0; i<nl.length; i++) {
|
246
|
+
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
|
247
|
+
this.addClass(nl[i], ic);
|
248
|
+
}
|
249
|
+
|
250
|
+
return null;
|
251
|
+
}
|
252
|
+
};
|