jwysiwyg_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +98 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/images/jquery.wysiwyg.bg.png +0 -0
- data/app/assets/images/jquery.wysiwyg.gif +0 -0
- data/app/assets/images/jquery.wysiwyg.jpg +0 -0
- data/app/assets/images/jquery.wysiwyg.no-alpha.gif +0 -0
- data/app/assets/images/plugins/fileManager/icon.png +0 -0
- data/app/assets/images/plugins/fileManager/images/application.png +0 -0
- data/app/assets/images/plugins/fileManager/images/code.png +0 -0
- data/app/assets/images/plugins/fileManager/images/css.png +0 -0
- data/app/assets/images/plugins/fileManager/images/db.png +0 -0
- data/app/assets/images/plugins/fileManager/images/directory.png +0 -0
- data/app/assets/images/plugins/fileManager/images/doc.png +0 -0
- data/app/assets/images/plugins/fileManager/images/file.png +0 -0
- data/app/assets/images/plugins/fileManager/images/film.png +0 -0
- data/app/assets/images/plugins/fileManager/images/flash.png +0 -0
- data/app/assets/images/plugins/fileManager/images/folder_open.png +0 -0
- data/app/assets/images/plugins/fileManager/images/html.png +0 -0
- data/app/assets/images/plugins/fileManager/images/java.png +0 -0
- data/app/assets/images/plugins/fileManager/images/linux.png +0 -0
- data/app/assets/images/plugins/fileManager/images/mkdir.png +0 -0
- data/app/assets/images/plugins/fileManager/images/music.png +0 -0
- data/app/assets/images/plugins/fileManager/images/pdf.png +0 -0
- data/app/assets/images/plugins/fileManager/images/php.png +0 -0
- data/app/assets/images/plugins/fileManager/images/picture.png +0 -0
- data/app/assets/images/plugins/fileManager/images/ppt.png +0 -0
- data/app/assets/images/plugins/fileManager/images/prev-directory.png +0 -0
- data/app/assets/images/plugins/fileManager/images/psd.png +0 -0
- data/app/assets/images/plugins/fileManager/images/remove.png +0 -0
- data/app/assets/images/plugins/fileManager/images/rename.png +0 -0
- data/app/assets/images/plugins/fileManager/images/ruby.png +0 -0
- data/app/assets/images/plugins/fileManager/images/script.png +0 -0
- data/app/assets/images/plugins/fileManager/images/txt.png +0 -0
- data/app/assets/images/plugins/fileManager/images/upload.png +0 -0
- data/app/assets/images/plugins/fileManager/images/xls.png +0 -0
- data/app/assets/images/plugins/fileManager/images/zip.png +0 -0
- data/app/assets/javascripts/controls/wysiwyg.colorpicker.js +250 -0
- data/app/assets/javascripts/controls/wysiwyg.cssWrap.js +134 -0
- data/app/assets/javascripts/controls/wysiwyg.image.js +285 -0
- data/app/assets/javascripts/controls/wysiwyg.link.js +249 -0
- data/app/assets/javascripts/controls/wysiwyg.table.js +129 -0
- data/app/assets/javascripts/i18n/lang.cs.js +116 -0
- data/app/assets/javascripts/i18n/lang.de.js +94 -0
- data/app/assets/javascripts/i18n/lang.en.js +117 -0
- data/app/assets/javascripts/i18n/lang.es.js +94 -0
- data/app/assets/javascripts/i18n/lang.fr.js +94 -0
- data/app/assets/javascripts/i18n/lang.he.js +94 -0
- data/app/assets/javascripts/i18n/lang.hr.js +98 -0
- data/app/assets/javascripts/i18n/lang.it.js +94 -0
- data/app/assets/javascripts/i18n/lang.ja.js +95 -0
- data/app/assets/javascripts/i18n/lang.nl.js +94 -0
- data/app/assets/javascripts/i18n/lang.pl.js +94 -0
- data/app/assets/javascripts/i18n/lang.pt_br.js +94 -0
- data/app/assets/javascripts/i18n/lang.ru.js +117 -0
- data/app/assets/javascripts/i18n/lang.se.js +94 -0
- data/app/assets/javascripts/i18n/lang.sl.js +94 -0
- data/app/assets/javascripts/i18n/lang.zh-cn.js +93 -0
- data/app/assets/javascripts/plugins/wysiwyg.autoload.js +61 -0
- data/app/assets/javascripts/plugins/wysiwyg.fileManager.js +572 -0
- data/app/assets/javascripts/plugins/wysiwyg.fullscreen.js +141 -0
- data/app/assets/javascripts/plugins/wysiwyg.i18n.js +99 -0
- data/app/assets/javascripts/plugins/wysiwyg.rmFormat.js +357 -0
- data/app/assets/stylesheets/jquery.wysiwyg.css +95 -0
- data/app/assets/stylesheets/jquery.wysiwyg.modal.css +62 -0
- data/app/assets/stylesheets/jquery.wysiwyg.old-school.css +63 -0
- data/app/assets/stylesheets/jwysiwyg.css +1 -0
- data/app/assets/stylesheets/plugins/fileManager/wysiwyg.fileManager.css +113 -0
- data/jwysiwyg_rails.gemspec +129 -0
- data/lib/engine.rb +8 -0
- data/lib/jwysiwyg_rails.rb +14 -0
- data/test/helper.rb +18 -0
- data/test/test_jwysiwyg_rails.rb +7 -0
- metadata +219 -0
@@ -0,0 +1,572 @@
|
|
1
|
+
/**
|
2
|
+
* File Manager plugin for jWYSIWYG
|
3
|
+
*
|
4
|
+
* Yotam Bar-On, 2011
|
5
|
+
*
|
6
|
+
* The file manager ui uses the Silk icon set from FAMFAMFAM
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function ($) {
|
11
|
+
"use strict";
|
12
|
+
|
13
|
+
if (undefined === $.wysiwyg) {
|
14
|
+
throw "wysiwyg.fileManager.js depends on $.wysiwyg";
|
15
|
+
}
|
16
|
+
|
17
|
+
/*
|
18
|
+
* Wysiwyg namespace: public properties and methods
|
19
|
+
*/
|
20
|
+
// Only for show
|
21
|
+
var fileManager = {
|
22
|
+
name: "fileManager",
|
23
|
+
version: "0.98", // Same as jwysiwyg
|
24
|
+
ajaxHandler: "",
|
25
|
+
selected: null,
|
26
|
+
setAjaxHandler: function (_handler) {
|
27
|
+
this.ajaxHandler = _handler;
|
28
|
+
this.ready = true;
|
29
|
+
|
30
|
+
return this;
|
31
|
+
},
|
32
|
+
ready: false,
|
33
|
+
init: function (callback) {
|
34
|
+
if (this.ready) {
|
35
|
+
var manager = new fileManagerObj(this.ajaxHandler);
|
36
|
+
manager.load(callback);
|
37
|
+
} else {
|
38
|
+
console.log("$.wysiwyg.fileManager: Must set ajax handler first, using $.wysiwyg.fileManager.setAjaxHandler()");
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
// Register:
|
45
|
+
$.wysiwyg.plugin.register(fileManager);
|
46
|
+
|
47
|
+
// Private object:
|
48
|
+
function fileManagerObj(_handler) {
|
49
|
+
this.handler = _handler;
|
50
|
+
this.loaded = false;
|
51
|
+
this.move = false;
|
52
|
+
this.rename = false;
|
53
|
+
this.remove = false;
|
54
|
+
this.upload = false;
|
55
|
+
this.mkdir = false;
|
56
|
+
this.selectedFile = "";
|
57
|
+
this.curDir = "/";
|
58
|
+
this.curListHtml = "";
|
59
|
+
this.dialog = null;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Methods
|
63
|
+
*/
|
64
|
+
var console = $.wysiwyg.console;
|
65
|
+
console.log("handler: " + this.handler);
|
66
|
+
|
67
|
+
this.load = function (callback) {
|
68
|
+
var self = this;
|
69
|
+
self.loaded = true;
|
70
|
+
self.authenticate(function (response) {
|
71
|
+
if (response !== "success") {
|
72
|
+
var dialog = new $.wysiwyg.dialog(null, {
|
73
|
+
"title" : "Error",
|
74
|
+
"content" : response
|
75
|
+
});
|
76
|
+
dialog.open();
|
77
|
+
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
|
81
|
+
// Wrap the file list:
|
82
|
+
var uiHtml = '<div class="wysiwyg-files-wrapper">' +
|
83
|
+
'<input type="text" name="url" />' +
|
84
|
+
'<div id="wysiwyg-files-list-wrapper"></div>';
|
85
|
+
|
86
|
+
// If handler does not support upload, icon will not appear:
|
87
|
+
if (self.upload.enabled) {
|
88
|
+
uiHtml += '<div class="wysiwyg-files-action-upload" title="{{upload_action}}"></div>';
|
89
|
+
}
|
90
|
+
|
91
|
+
// If handler does not support mkdir, icon will not appear:
|
92
|
+
if (self.mkdir.enabled) {
|
93
|
+
uiHtml += '<div class="wysiwyg-files-action-mkdir" title="{{mkdir_action}}"></div>';
|
94
|
+
}
|
95
|
+
|
96
|
+
uiHtml += '<input style="display:none;" type="button" name="submit" value="{{select}}" />' +
|
97
|
+
'</div>';
|
98
|
+
|
99
|
+
uiHtml = self.i18n(uiHtml);
|
100
|
+
if ($.wysiwyg.dialog) {
|
101
|
+
// Support for native $.wysiwyg.dialog()
|
102
|
+
var _title = self.i18n("{{file_manager}}");
|
103
|
+
var fileManagerUI = new $.wysiwyg.dialog(_handler, {
|
104
|
+
"title": _title,
|
105
|
+
"content": uiHtml,
|
106
|
+
"close": function (e, dialog) {
|
107
|
+
self.dialog = null;
|
108
|
+
},
|
109
|
+
"open": function (e, dialog) {
|
110
|
+
|
111
|
+
self.dialog = dialog;
|
112
|
+
|
113
|
+
self.loadDir();
|
114
|
+
self.bindHover();
|
115
|
+
self.bindBrowse();
|
116
|
+
|
117
|
+
// Select file bindings
|
118
|
+
dialog.find("input[name=submit]").bind("click", function () {
|
119
|
+
var file = dialog.find("input[name=url]").val();
|
120
|
+
fileManagerUI.close();
|
121
|
+
self.loaded = false;
|
122
|
+
callback(file);
|
123
|
+
});
|
124
|
+
|
125
|
+
// Create Directory
|
126
|
+
$(".wysiwyg-files-action-mkdir").bind("click", function (e) {
|
127
|
+
e.preventDefault();
|
128
|
+
var uiHtml = '<div>' +
|
129
|
+
'<input type="text" class="wysiwyg-files-textfield" name="newName" value="{{new_directory}}" />' +
|
130
|
+
'<input type="button" name="cancel" value="{{cancel}}" />' +
|
131
|
+
'<input type="button" name="create" value="{{create}}" />' +
|
132
|
+
'</div>';
|
133
|
+
uiHtml = self.i18n(uiHtml);
|
134
|
+
var _mkdirTitle = self.i18n("{{mkdir_title}}");
|
135
|
+
var mkdirDialog = new $.wysiwyg.dialog(null, {
|
136
|
+
"title": _mkdirTitle,
|
137
|
+
"content": uiHtml,
|
138
|
+
"close": function () {
|
139
|
+
|
140
|
+
},
|
141
|
+
"open": function (e, _dialog) {
|
142
|
+
_dialog.find("input[name=create]").bind("click", function () {
|
143
|
+
self.mkDir(_dialog.find("input[name=newName]").val(), function (response) {
|
144
|
+
self.loadDir();
|
145
|
+
mkdirDialog.close();
|
146
|
+
});
|
147
|
+
});
|
148
|
+
|
149
|
+
_dialog.find("input[name=cancel]").bind("click", function () {
|
150
|
+
mkdirDialog.close();
|
151
|
+
});
|
152
|
+
}
|
153
|
+
});
|
154
|
+
mkdirDialog.open();
|
155
|
+
});
|
156
|
+
|
157
|
+
// Upload File
|
158
|
+
$(".wysiwyg-files-action-upload").bind("click", function (e) {
|
159
|
+
self.loadUploadUI();
|
160
|
+
});
|
161
|
+
|
162
|
+
},
|
163
|
+
"modal": false
|
164
|
+
// "theme": "jqueryui"
|
165
|
+
});
|
166
|
+
|
167
|
+
fileManagerUI.open();
|
168
|
+
|
169
|
+
} else {
|
170
|
+
// If $.wysiwyg.dialog() does not work..
|
171
|
+
console.error("$.wysiwyg.fileManager: This plugin uses the native dialog system of jWYSIWYG. Make sure you are using version > 0.98");
|
172
|
+
}
|
173
|
+
});
|
174
|
+
};
|
175
|
+
|
176
|
+
this.authenticate = function (callback) {
|
177
|
+
if (!this.loaded) {
|
178
|
+
return false;
|
179
|
+
}
|
180
|
+
var self = this;
|
181
|
+
$.getJSON(self.handler, { "action": "auth", "auth": "jwysiwyg" }, function (json, textStatus) {
|
182
|
+
if (json.success) {
|
183
|
+
self.move = json.data.move;
|
184
|
+
self.rename = json.data.rename;
|
185
|
+
self.remove = json.data.remove;
|
186
|
+
self.mkdir = json.data.mkdir;
|
187
|
+
self.upload = json.data.upload;
|
188
|
+
callback("success");
|
189
|
+
} else {
|
190
|
+
callback(json.error + "\n<br>$.wysiwyg.fileManager: Unable to authenticate handler.");
|
191
|
+
}
|
192
|
+
});
|
193
|
+
};
|
194
|
+
|
195
|
+
this.loadDir = function () {
|
196
|
+
if (!this.loaded) {
|
197
|
+
return false;
|
198
|
+
}
|
199
|
+
var self = this;
|
200
|
+
self.curDir = self.curDir.replace(/\/$/, '') + '/';
|
201
|
+
|
202
|
+
// Retreives list of files inside a certain directory:
|
203
|
+
$.getJSON(self.handler, { "dir": self.curDir, "action": "list" }, function (json) {
|
204
|
+
if (json.success) {
|
205
|
+
self.dialog.find("#wysiwyg-files-list-wrapper").removeClass("wysiwyg-files-ajax").html(self.listDir(json));
|
206
|
+
self.bindHover();
|
207
|
+
self.bindBrowse();
|
208
|
+
} else {
|
209
|
+
alert(json.error);
|
210
|
+
}
|
211
|
+
});
|
212
|
+
};
|
213
|
+
|
214
|
+
/**
|
215
|
+
* Ajax Methods.
|
216
|
+
*/
|
217
|
+
|
218
|
+
// List Directory
|
219
|
+
this.listDir = function (json) {
|
220
|
+
if (!this.loaded) {
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
var self = this;
|
224
|
+
var treeHtml = '<ul class="wysiwyg-files-list">';
|
225
|
+
if (self.curDir !== "/") {
|
226
|
+
var prevDir = self.curDir.replace(/[^\/]+\/?$/, '');
|
227
|
+
treeHtml += '<li class="wysiwyg-files-dir wysiwyg-files-dir-prev">' +
|
228
|
+
'<a href="#" rel="' + prevDir + '" title="{{previous_directory}}">' +
|
229
|
+
self.curDir +
|
230
|
+
'</a></li>';
|
231
|
+
}
|
232
|
+
$.each(json.data.directories, function (name, dirPath) {
|
233
|
+
treeHtml += '<li class="wysiwyg-files-dir">' +
|
234
|
+
'<a href="#" rel="' + dirPath + '">' +
|
235
|
+
name +
|
236
|
+
'</a></li>';
|
237
|
+
});
|
238
|
+
$.each(json.data.files, function (name, url) {
|
239
|
+
var ext = name.replace(/^.*?\./, '').toLowerCase();
|
240
|
+
treeHtml += '<li class="wysiwyg-files-file wysiwyg-files-' + ext + '">' +
|
241
|
+
'<a href="#" rel="' + url + '">' +
|
242
|
+
name +
|
243
|
+
'</a></li>';
|
244
|
+
});
|
245
|
+
treeHtml += '</ul>';
|
246
|
+
|
247
|
+
return self.i18n(treeHtml);
|
248
|
+
};
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Should be remembered for future implementation:
|
252
|
+
* If handler does not support certain actions - do not show their icons/button.
|
253
|
+
* Only action a handler MUST support is "list" (list directory).
|
254
|
+
*
|
255
|
+
* Implemented: 28-May-2011, Yotam Bar-On
|
256
|
+
*/
|
257
|
+
|
258
|
+
// Remove File Method:
|
259
|
+
this.removeFile = function (type, callback) {
|
260
|
+
if (!this.loaded) { return false; }
|
261
|
+
if (!this.remove.enabled) { console.log("$.wysiwyg.fileManager: handler: remove is disabled."); return false; }
|
262
|
+
|
263
|
+
var self = this;
|
264
|
+
$.getJSON(self.remove.handler, { "action": "remove", "type": type, "dir": self.curDir, "file": self.selectedFile }, function (json) {
|
265
|
+
if (json.success) {
|
266
|
+
alert(json.data);
|
267
|
+
} else {
|
268
|
+
alert(json.error);
|
269
|
+
}
|
270
|
+
callback(json);
|
271
|
+
});
|
272
|
+
};
|
273
|
+
|
274
|
+
// Rename File Method
|
275
|
+
this.renameFile = function (type, newName, callback) {
|
276
|
+
if (!this.loaded) { return false; }
|
277
|
+
if (!this.rename.enabled) { console.log("$.wysiwyg.fileManager: handler: rename is disabled."); return false; }
|
278
|
+
|
279
|
+
var self = this;
|
280
|
+
$.getJSON(self.rename.handler, { "action": "rename", "type": type, "dir": self.curDir, "file": self.selectedFile, "newName": newName }, function (json) {
|
281
|
+
if (json.success) {
|
282
|
+
alert(json.data);
|
283
|
+
} else {
|
284
|
+
alert(json.error);
|
285
|
+
}
|
286
|
+
callback(json);
|
287
|
+
});
|
288
|
+
};
|
289
|
+
|
290
|
+
// Make Directory Method
|
291
|
+
this.mkDir = function (newName, callback) {
|
292
|
+
if (!this.loaded) { return false; }
|
293
|
+
if (!this.mkdir.enabled) { console.log("$.wysiwyg.fileManager: handler: mkdir is disabled."); return false; }
|
294
|
+
|
295
|
+
var self = this;
|
296
|
+
$.getJSON(self.mkdir.handler, { "action": "mkdir", "dir": self.curDir, "newName": newName }, function (json) {
|
297
|
+
if (json.success) {
|
298
|
+
alert(json.data);
|
299
|
+
} else {
|
300
|
+
alert(json.error);
|
301
|
+
}
|
302
|
+
callback(json);
|
303
|
+
});
|
304
|
+
};
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Currently we will not support moving of files. This will be supported only when a more interactive interface will be introduced.
|
308
|
+
*/
|
309
|
+
this.moveFile = function () {
|
310
|
+
if (!this.loaded) {
|
311
|
+
return false;
|
312
|
+
}
|
313
|
+
if (!this.move.enabled) {
|
314
|
+
console.log("$.wysiwyg.fileManager: handler: move is disabled."); return false;
|
315
|
+
}
|
316
|
+
var self = this;
|
317
|
+
return false;
|
318
|
+
};
|
319
|
+
|
320
|
+
// Upload:
|
321
|
+
this.loadUploadUI = function () {
|
322
|
+
if (!this.loaded) { return false; }
|
323
|
+
if (!this.upload.enabled) { console.log("$.wysiwyg.fileManager: handler: move is disabled."); return false; }
|
324
|
+
var self = this;
|
325
|
+
var uiHtml = '<form enctype="multipart/form-data" method="post" action="' + self.upload.handler + '">' +
|
326
|
+
'<p><input type="file" name="handle" /><br>' +
|
327
|
+
'<input type="text" name="newName" style="width:250px; border:solid 1px !important;" /><br>' +
|
328
|
+
'<input type="text" name="action" style="display:none;" value="upload" /><br></p>' +
|
329
|
+
'<input type="text" name="dir" style="display:none;" value="' + self.curDir + '" /></p>' +
|
330
|
+
'<input type="submit" name="submit" value="{{submit}}" />' +
|
331
|
+
'</form>';
|
332
|
+
uiHtml = self.i18n(uiHtml);
|
333
|
+
|
334
|
+
var _uploadTitle = self.i18n("{{upload_title}}");
|
335
|
+
|
336
|
+
var dialog = new $.wysiwyg.dialog(null, {
|
337
|
+
"title": _uploadTitle,
|
338
|
+
"content": "",
|
339
|
+
"open": function (e, _dialog) {
|
340
|
+
|
341
|
+
$("<iframe/>", { "class": "wysiwyg-files-upload" }).load(function () {
|
342
|
+
var $doc = $(this).contents();
|
343
|
+
$doc.find("body").append(uiHtml);
|
344
|
+
$doc.find("input[type=file]").change(function () {
|
345
|
+
var $val = $(this).val();
|
346
|
+
$val = $val.replace(/.*[\\\/]/, '');
|
347
|
+
// Should implement validation of extensions before submitting form
|
348
|
+
$doc.find("input[name=newName]").val($val);
|
349
|
+
});
|
350
|
+
|
351
|
+
}).appendTo(_dialog.find(".wysiwyg-dialog-content"));
|
352
|
+
|
353
|
+
},
|
354
|
+
"close": function () {
|
355
|
+
self.loadDir();
|
356
|
+
}
|
357
|
+
});
|
358
|
+
|
359
|
+
dialog.open();
|
360
|
+
};
|
361
|
+
|
362
|
+
/**
|
363
|
+
* i18n Support.
|
364
|
+
* The below methods will enable basic support for i18n
|
365
|
+
*/
|
366
|
+
|
367
|
+
// Default translations (EN):
|
368
|
+
this.defaultTranslations = {
|
369
|
+
"file_manager": "File Manager",
|
370
|
+
"upload_title": "Upload File",
|
371
|
+
"rename_title": "Rename File",
|
372
|
+
"remove_title": "Remove File",
|
373
|
+
"mkdir_title": "Create Directory",
|
374
|
+
"upload_action": "Upload new file to current directory",
|
375
|
+
"mkdir_action": "Create new directory",
|
376
|
+
"remove_action": "Remove this file",
|
377
|
+
"rename_action": "Rename this file",
|
378
|
+
"delete_message": "Are you sure you want to delete this file?",
|
379
|
+
"new_directory": "New Directory",
|
380
|
+
"previous_directory": "Go to previous directory",
|
381
|
+
"rename": "Rename",
|
382
|
+
"select": "Select",
|
383
|
+
"create": "Create",
|
384
|
+
"submit": "Submit",
|
385
|
+
"cancel": "Cancel",
|
386
|
+
"yes": "Yes",
|
387
|
+
"no": "No"
|
388
|
+
};
|
389
|
+
/**
|
390
|
+
* Take an html string with placeholders: {{placeholder}} and translate it.
|
391
|
+
* It takes all labels and trys to translate them.
|
392
|
+
* If there is no translation (or i18n plugin is not loaded) it will use the defaults.
|
393
|
+
*/
|
394
|
+
this.i18n = function (tHtml) {
|
395
|
+
var map = this.defaultTranslations;
|
396
|
+
// If i18n plugin exists:
|
397
|
+
if ($.wysiwyg.i18n) {
|
398
|
+
$.each(map, function (key, val) {
|
399
|
+
map[key] = $.wysiwyg.i18n.t(key, "dialogs.fileManager");
|
400
|
+
});
|
401
|
+
}
|
402
|
+
|
403
|
+
$.each(map, function (key, val) {
|
404
|
+
tHtml = tHtml.replace("{{" + key + "}}", val);
|
405
|
+
});
|
406
|
+
|
407
|
+
return tHtml;
|
408
|
+
};
|
409
|
+
|
410
|
+
/**
|
411
|
+
* BINDINGS FOR ELEMENTS
|
412
|
+
* The below methods are bind methods for elements inside the File Manager's dialogs.
|
413
|
+
* Their purpose is to enable simple coding of the dialog interfaces,
|
414
|
+
* and to make the use of "live" deprecated.
|
415
|
+
*/
|
416
|
+
|
417
|
+
this.bindHover = function () {
|
418
|
+
var self = this,
|
419
|
+
dialog = self.dialog,
|
420
|
+
object = dialog.find("li");
|
421
|
+
|
422
|
+
/**
|
423
|
+
* HOVER + ACTIONS BINDINGS:
|
424
|
+
*/
|
425
|
+
object.bind("mouseenter", function () {
|
426
|
+
$(this).addClass("wysiwyg-files-hover");
|
427
|
+
|
428
|
+
if ($(this).hasClass("wysiwyg-files-dir")) {
|
429
|
+
$(this).addClass("wysiwyg-files-dir-expanded");
|
430
|
+
}
|
431
|
+
|
432
|
+
// Add action buttons:
|
433
|
+
if (!$(this).hasClass("wysiwyg-files-dir-prev")) {
|
434
|
+
|
435
|
+
$(".wysiwyg-files-action").remove();
|
436
|
+
|
437
|
+
// If handler does not support remove, icon will not appear:
|
438
|
+
if (self.remove.enabled) {
|
439
|
+
var rmText = self.i18n("{{remove_action}}");
|
440
|
+
$("<div/>", { "class": "wysiwyg-files-action wysiwyg-files-action-remove", "title": rmText }).appendTo(this);
|
441
|
+
|
442
|
+
// "Remove" binding:
|
443
|
+
$(".wysiwyg-files-action-remove").bind("click", function (e) {
|
444
|
+
e.preventDefault();
|
445
|
+
var entry = $(this).parent("li");
|
446
|
+
// What are we deleting?
|
447
|
+
var type = entry.hasClass("wysiwyg-files-file") ? "file" : "dir";
|
448
|
+
var uiHtml = "<p>{{delete_message}}</p>" +
|
449
|
+
'<div class="">' +
|
450
|
+
'<input type="button" name="cancel" value="{{no}}" />' +
|
451
|
+
'<input type="button" name="remove" value="{{yes}}" />' +
|
452
|
+
"</div>";
|
453
|
+
uiHtml = self.i18n(uiHtml);
|
454
|
+
|
455
|
+
var _removeTitle = self.i18n("{{remove_title}}");
|
456
|
+
|
457
|
+
var removeDialog = new $.wysiwyg.dialog(null, {
|
458
|
+
"title": _removeTitle,
|
459
|
+
"content": uiHtml,
|
460
|
+
"close": function () {
|
461
|
+
|
462
|
+
},
|
463
|
+
"open": function (e, _dialog) {
|
464
|
+
_dialog.find("input[name=remove]").bind("click", function () {
|
465
|
+
self.selectedFile = entry.find("a").text();
|
466
|
+
self.removeFile(type, function (response) {
|
467
|
+
self.loadDir();
|
468
|
+
removeDialog.close();
|
469
|
+
});
|
470
|
+
});
|
471
|
+
|
472
|
+
_dialog.find("input[name=cancel]").bind("click", function () {
|
473
|
+
removeDialog.close();
|
474
|
+
});
|
475
|
+
}
|
476
|
+
});
|
477
|
+
|
478
|
+
removeDialog.open();
|
479
|
+
});
|
480
|
+
}
|
481
|
+
|
482
|
+
// If handler does not support rename, icon will not appear:
|
483
|
+
if (self.rename.enabled) {
|
484
|
+
var rnText = self.i18n("{{rename_action}}");
|
485
|
+
$("<div/>", { "class": "wysiwyg-files-action wysiwyg-files-action-rename", "title": rnText }).appendTo(this);
|
486
|
+
|
487
|
+
// "Rename" binding:
|
488
|
+
$(".wysiwyg-files-action-rename").bind("click", function (e) {
|
489
|
+
e.preventDefault();
|
490
|
+
var entry = $(this).parent("li");
|
491
|
+
// What are we deleting?
|
492
|
+
var type = entry.hasClass("wysiwyg-files-file") ? "file" : "dir";
|
493
|
+
var uiHtml = '<div>' +
|
494
|
+
'<input type="text" class="wysiwyg-files-textfield" name="newName" value="' + entry.find("a").text() + '" />' +
|
495
|
+
'<input type="button" name="cancel" value="{{cancel}}" />' +
|
496
|
+
'<input type="button" name="rename" value="{{rename}}" />' +
|
497
|
+
'</div>';
|
498
|
+
uiHtml = self.i18n(uiHtml);
|
499
|
+
var _renameTitle = self.i18n("{{rename_title}}");
|
500
|
+
|
501
|
+
var renameDialog = new $.wysiwyg.dialog(null, {
|
502
|
+
"title": _renameTitle,
|
503
|
+
"content": uiHtml,
|
504
|
+
"close": function () {
|
505
|
+
|
506
|
+
},
|
507
|
+
"open": function (e, _dialog) {
|
508
|
+
_dialog.find("input[name=rename]").bind("click", function () {
|
509
|
+
self.selectedFile = entry.find("a").text();
|
510
|
+
self.renameFile(type, _dialog.find("input[name=newName]").val(), function (response) {
|
511
|
+
self.loadDir();
|
512
|
+
renameDialog.close();
|
513
|
+
});
|
514
|
+
});
|
515
|
+
|
516
|
+
_dialog.find("input[name=cancel]").bind("click", function () {
|
517
|
+
renameDialog.close();
|
518
|
+
});
|
519
|
+
}
|
520
|
+
});
|
521
|
+
|
522
|
+
renameDialog.open();
|
523
|
+
});
|
524
|
+
}
|
525
|
+
}
|
526
|
+
}).bind("mouseleave", function () {
|
527
|
+
$(this).removeClass("wysiwyg-files-dir-expanded");
|
528
|
+
$(this).removeClass("wysiwyg-files-hover");
|
529
|
+
|
530
|
+
// Remove action buttons:
|
531
|
+
$(".wysiwyg-files-action").remove();
|
532
|
+
});
|
533
|
+
};
|
534
|
+
|
535
|
+
/**
|
536
|
+
* BROWSING BINDINGS
|
537
|
+
*/
|
538
|
+
this.bindBrowse = function () {
|
539
|
+
var self = this,
|
540
|
+
dialog = self.dialog,
|
541
|
+
object = self.dialog.find("li").find("a");
|
542
|
+
|
543
|
+
// Browse:
|
544
|
+
object.bind("click", function (e) {
|
545
|
+
$(".wysiwyg-files-wrapper").find("li").css("backgroundColor", "#FFF");
|
546
|
+
|
547
|
+
// Browse Directory:
|
548
|
+
if ($(this).parent("li").hasClass("wysiwyg-files-dir")) {
|
549
|
+
self.selectedFile = $(this).attr("rel");
|
550
|
+
self.curDir = $(this).attr("rel");
|
551
|
+
dialog.find("input[name=submit]").hide();
|
552
|
+
$(".wysiwyg-files-wrapper").find("input[name=url]").val("");
|
553
|
+
$('#wysiwyg-files-list-wrapper').addClass("wysiwyg-files-ajax");
|
554
|
+
$('#wysiwyg-files-list-wrapper').html("");
|
555
|
+
self.loadDir();
|
556
|
+
dialog.find("input[name=submit]").hide();
|
557
|
+
|
558
|
+
// Select Entry:
|
559
|
+
} else {
|
560
|
+
self.selectedFile = $(this).text();
|
561
|
+
$(this).parent("li").css("backgroundColor", "#BDF");
|
562
|
+
$(".wysiwyg-files-wrapper").find("input[name=url]").val($(this).attr("rel"));
|
563
|
+
dialog.find("input[name=submit]").show();
|
564
|
+
}
|
565
|
+
});
|
566
|
+
};
|
567
|
+
|
568
|
+
this.bindPreview = function (object) {
|
569
|
+
var self = this;
|
570
|
+
};
|
571
|
+
}
|
572
|
+
})(jQuery);
|
@@ -0,0 +1,141 @@
|
|
1
|
+
/**
|
2
|
+
* Fullscreen plugin
|
3
|
+
*
|
4
|
+
* Depends on jWYSIWYG
|
5
|
+
*/
|
6
|
+
(function ($) {
|
7
|
+
if (undefined === $.wysiwyg) {
|
8
|
+
throw "wysiwyg.fullscreen.js depends on $.wysiwyg";
|
9
|
+
}
|
10
|
+
|
11
|
+
/*
|
12
|
+
* Wysiwyg namespace: public properties and methods
|
13
|
+
*/
|
14
|
+
var fullscreen = {
|
15
|
+
name: "fullscreen",
|
16
|
+
version: "",
|
17
|
+
defaults: {
|
18
|
+
css: {
|
19
|
+
editor: {
|
20
|
+
width: "100%",
|
21
|
+
height: "100%"
|
22
|
+
},
|
23
|
+
element: {
|
24
|
+
width: "100%",
|
25
|
+
height: "100%",
|
26
|
+
position: "fixed",
|
27
|
+
left: "0px",
|
28
|
+
top: "0px",
|
29
|
+
background: "rgb(255, 255, 255)",
|
30
|
+
padding: "0px",
|
31
|
+
"border-bottom-color": "",
|
32
|
+
"border-bottom-style": "",
|
33
|
+
"border-bottom-width": "0px",
|
34
|
+
"border-left-color": "",
|
35
|
+
"border-left-style": "",
|
36
|
+
"border-left-width": "0px",
|
37
|
+
"border-right-color": "",
|
38
|
+
"border-right-style": "",
|
39
|
+
"border-right-width": "0px",
|
40
|
+
"border-top-color": "",
|
41
|
+
"border-top-style": "",
|
42
|
+
"border-top-width": "0px",
|
43
|
+
"z-index": 1000
|
44
|
+
},
|
45
|
+
original: {
|
46
|
+
width: "100%",
|
47
|
+
height: "100%",
|
48
|
+
position: "fixed",
|
49
|
+
left: "0px",
|
50
|
+
top: "0px",
|
51
|
+
background: "rgb(255, 255, 255)",
|
52
|
+
padding: "0px",
|
53
|
+
"border-bottom-color": "",
|
54
|
+
"border-bottom-style": "",
|
55
|
+
"border-bottom-width": "0px",
|
56
|
+
"border-left-color": "",
|
57
|
+
"border-left-style": "",
|
58
|
+
"border-left-width": "0px",
|
59
|
+
"border-right-color": "",
|
60
|
+
"border-right-style": "",
|
61
|
+
"border-right-width": "0px",
|
62
|
+
"border-top-color": "",
|
63
|
+
"border-top-style": "",
|
64
|
+
"border-top-width": "0px",
|
65
|
+
"z-index": 1000
|
66
|
+
}
|
67
|
+
}
|
68
|
+
},
|
69
|
+
options: {},
|
70
|
+
originalBoundary: {
|
71
|
+
editor: {},
|
72
|
+
element: {},
|
73
|
+
original: {}
|
74
|
+
},
|
75
|
+
|
76
|
+
init: function (Wysiwyg, options) {
|
77
|
+
options = options || {};
|
78
|
+
this.options = $.extend(true, this.defaults, options);
|
79
|
+
|
80
|
+
if (Wysiwyg.ui.toolbar.find(".fullscreen").hasClass("active")) {
|
81
|
+
this.restore(Wysiwyg);
|
82
|
+
Wysiwyg.ui.toolbar.find(".fullscreen").removeClass("active");
|
83
|
+
} else {
|
84
|
+
this.stretch(Wysiwyg);
|
85
|
+
Wysiwyg.ui.toolbar.find(".fullscreen").addClass("active");
|
86
|
+
}
|
87
|
+
},
|
88
|
+
|
89
|
+
restore: function (Wysiwyg) {
|
90
|
+
var propertyName;
|
91
|
+
|
92
|
+
for (propertyName in this.defaults.css.editor) {
|
93
|
+
Wysiwyg.editor.css(propertyName, this.originalBoundary.editor[propertyName]);
|
94
|
+
this.originalBoundary.editor[propertyName] = null;
|
95
|
+
}
|
96
|
+
|
97
|
+
for (propertyName in this.defaults.css.element) {
|
98
|
+
Wysiwyg.element.css(propertyName, this.originalBoundary.element[propertyName]);
|
99
|
+
this.originalBoundary.element[propertyName] = null;
|
100
|
+
}
|
101
|
+
|
102
|
+
for (propertyName in this.defaults.css.original) {
|
103
|
+
$(Wysiwyg.original).css(propertyName, this.originalBoundary.original[propertyName]);
|
104
|
+
this.originalBoundary.original[propertyName] = null;
|
105
|
+
}
|
106
|
+
},
|
107
|
+
|
108
|
+
stretch: function (Wysiwyg) {
|
109
|
+
var propertyName;
|
110
|
+
|
111
|
+
// save previous values
|
112
|
+
for (propertyName in this.defaults.css.editor) {
|
113
|
+
this.originalBoundary.editor[propertyName] = Wysiwyg.editor.css(propertyName);
|
114
|
+
}
|
115
|
+
|
116
|
+
for (propertyName in this.defaults.css.element) {
|
117
|
+
this.originalBoundary.element[propertyName] = Wysiwyg.element.css(propertyName);
|
118
|
+
}
|
119
|
+
|
120
|
+
for (propertyName in this.defaults.css.original) {
|
121
|
+
this.originalBoundary.original[propertyName] = $(Wysiwyg.original).css(propertyName);
|
122
|
+
}
|
123
|
+
|
124
|
+
// set new values
|
125
|
+
for (propertyName in this.defaults.css.editor) {
|
126
|
+
Wysiwyg.editor.css(propertyName, this.options.css.editor[propertyName]);
|
127
|
+
}
|
128
|
+
|
129
|
+
for (propertyName in this.defaults.css.element) {
|
130
|
+
Wysiwyg.element.css(propertyName, this.options.css.element[propertyName]);
|
131
|
+
}
|
132
|
+
|
133
|
+
this.options.css.original.top = Wysiwyg.ui.toolbar.css("height");
|
134
|
+
for (propertyName in this.defaults.css.original) {
|
135
|
+
$(Wysiwyg.original).css(propertyName, this.options.css.original[propertyName]);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
};
|
139
|
+
|
140
|
+
$.wysiwyg.plugin.register(fullscreen);
|
141
|
+
})(jQuery);
|