thesis 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.md +3 -3
- data/app/assets/javascripts/thesis/hallo.js +2949 -0
- data/app/assets/javascripts/thesis/rangy-core.js +94 -0
- data/app/assets/javascripts/thesis/thesis.js.coffee +157 -0
- data/app/assets/javascripts/thesis.js +3 -0
- data/app/assets/stylesheets/thesis/font/FontAwesome.otf +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.eot +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.svg +284 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.ttf +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.woff +0 -0
- data/app/assets/stylesheets/thesis/font-awesome/font-awesome.scss +534 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/animated-overlay.gif +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_20_555555_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_4b8e0b_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_a83300_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_cccccc_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/jquery-ui-1.10.2.custom.css +1175 -0
- data/app/assets/stylesheets/thesis/thesis.css.scss +65 -0
- data/app/assets/stylesheets/thesis.css +4 -0
- data/config/routes.rb +3 -0
- data/lib/thesis/controllers/controller_helpers.rb +4 -2
- data/lib/thesis/controllers/thesis_controller.rb +8 -2
- data/lib/thesis/models/page.rb +3 -3
- data/lib/thesis/routing/route_constraint.rb +2 -1
- data/lib/thesis/routing/routes.rb +12 -0
- data/lib/thesis/version.rb +1 -1
- data/lib/thesis.rb +2 -3
- metadata +32 -1
@@ -0,0 +1,2949 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
2
|
+
(function() {
|
3
|
+
|
4
|
+
$.widget("ncri.hallohtml", {
|
5
|
+
options: {
|
6
|
+
editable: null,
|
7
|
+
toolbar: null,
|
8
|
+
uuid: "",
|
9
|
+
lang: 'en',
|
10
|
+
dialogOpts: {
|
11
|
+
autoOpen: false,
|
12
|
+
width: 600,
|
13
|
+
height: 'auto',
|
14
|
+
modal: false,
|
15
|
+
resizable: true,
|
16
|
+
draggable: true,
|
17
|
+
dialogClass: 'htmledit-dialog'
|
18
|
+
},
|
19
|
+
dialog: null,
|
20
|
+
buttonCssClass: null
|
21
|
+
},
|
22
|
+
translations: {
|
23
|
+
en: {
|
24
|
+
title: 'Edit HTML',
|
25
|
+
update: 'Update'
|
26
|
+
},
|
27
|
+
de: {
|
28
|
+
title: 'HTML bearbeiten',
|
29
|
+
update: 'Aktualisieren'
|
30
|
+
}
|
31
|
+
},
|
32
|
+
texts: null,
|
33
|
+
populateToolbar: function($toolbar) {
|
34
|
+
var $buttonHolder, $buttonset, id, widget;
|
35
|
+
widget = this;
|
36
|
+
this.texts = this.translations[this.options.lang];
|
37
|
+
this.options.toolbar = $toolbar;
|
38
|
+
this.options.dialog = $("<div>").attr('id', "" + this.options.uuid + "-htmledit-dialog");
|
39
|
+
$buttonset = $("<span>").addClass(widget.widgetName);
|
40
|
+
id = "" + this.options.uuid + "-htmledit";
|
41
|
+
$buttonHolder = $('<span>');
|
42
|
+
$buttonHolder.hallobutton({
|
43
|
+
label: this.texts.title,
|
44
|
+
icon: 'icon-list-alt',
|
45
|
+
editable: this.options.editable,
|
46
|
+
command: null,
|
47
|
+
queryState: false,
|
48
|
+
uuid: this.options.uuid,
|
49
|
+
cssClass: this.options.buttonCssClass
|
50
|
+
});
|
51
|
+
$buttonset.append($buttonHolder);
|
52
|
+
this.button = $buttonHolder;
|
53
|
+
this.button.click(function() {
|
54
|
+
if (widget.options.dialog.dialog("isOpen")) {
|
55
|
+
widget._closeDialog();
|
56
|
+
} else {
|
57
|
+
widget._openDialog();
|
58
|
+
}
|
59
|
+
return false;
|
60
|
+
});
|
61
|
+
this.options.editable.element.on("hallodeactivated", function() {
|
62
|
+
return widget._closeDialog();
|
63
|
+
});
|
64
|
+
$toolbar.append($buttonset);
|
65
|
+
this.options.dialog.dialog(this.options.dialogOpts);
|
66
|
+
return this.options.dialog.dialog("option", "title", this.texts.title);
|
67
|
+
},
|
68
|
+
_openDialog: function() {
|
69
|
+
var $editableEl, html, widget, xposition, yposition,
|
70
|
+
_this = this;
|
71
|
+
widget = this;
|
72
|
+
$editableEl = $(this.options.editable.element);
|
73
|
+
xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
|
74
|
+
yposition = this.options.toolbar.offset().top - $(document).scrollTop();
|
75
|
+
this.options.dialog.dialog("option", "position", [xposition, yposition]);
|
76
|
+
this.options.editable.keepActivated(true);
|
77
|
+
this.options.dialog.dialog("open");
|
78
|
+
this.options.dialog.on('dialogclose', function() {
|
79
|
+
$('label', _this.button).removeClass('ui-state-active');
|
80
|
+
_this.options.editable.element.focus();
|
81
|
+
return _this.options.editable.keepActivated(false);
|
82
|
+
});
|
83
|
+
this.options.dialog.html($("<textarea>").addClass('html_source'));
|
84
|
+
html = this.options.editable.element.html();
|
85
|
+
this.options.dialog.children('.html_source').val(html);
|
86
|
+
this.options.dialog.prepend($("<button>" + this.texts.update + "</button>"));
|
87
|
+
return this.options.dialog.on('click', 'button', function() {
|
88
|
+
html = widget.options.dialog.children('.html_source').val();
|
89
|
+
widget.options.editable.element.html(html);
|
90
|
+
widget.options.editable.element.trigger('change');
|
91
|
+
return false;
|
92
|
+
});
|
93
|
+
},
|
94
|
+
_closeDialog: function() {
|
95
|
+
return this.options.dialog.dialog("close");
|
96
|
+
}
|
97
|
+
});
|
98
|
+
|
99
|
+
(function(jQuery) {
|
100
|
+
return jQuery.widget("IKS.hallolists", {
|
101
|
+
options: {
|
102
|
+
editable: null,
|
103
|
+
toolbar: null,
|
104
|
+
uuid: '',
|
105
|
+
lists: {
|
106
|
+
ordered: true,
|
107
|
+
unordered: true
|
108
|
+
},
|
109
|
+
buttonCssClass: null
|
110
|
+
},
|
111
|
+
populateToolbar: function(toolbar) {
|
112
|
+
var buttonize, buttonset,
|
113
|
+
_this = this;
|
114
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
115
|
+
buttonize = function(type, label) {
|
116
|
+
var buttonElement;
|
117
|
+
buttonElement = jQuery('<span></span>');
|
118
|
+
buttonElement.hallobutton({
|
119
|
+
uuid: _this.options.uuid,
|
120
|
+
editable: _this.options.editable,
|
121
|
+
label: label,
|
122
|
+
command: "insert" + type + "List",
|
123
|
+
icon: "icon-list-" + (label.toLowerCase()),
|
124
|
+
cssClass: _this.options.buttonCssClass
|
125
|
+
});
|
126
|
+
return buttonset.append(buttonElement);
|
127
|
+
};
|
128
|
+
if (this.options.lists.ordered) {
|
129
|
+
buttonize("Ordered", "OL");
|
130
|
+
}
|
131
|
+
if (this.options.lists.unordered) {
|
132
|
+
buttonize("Unordered", "UL");
|
133
|
+
}
|
134
|
+
buttonset.hallobuttonset();
|
135
|
+
return toolbar.append(buttonset);
|
136
|
+
}
|
137
|
+
});
|
138
|
+
})(jQuery);
|
139
|
+
|
140
|
+
(function(jQuery) {
|
141
|
+
return jQuery.widget("IKS.halloformat", {
|
142
|
+
options: {
|
143
|
+
editable: null,
|
144
|
+
uuid: '',
|
145
|
+
formattings: {
|
146
|
+
bold: true,
|
147
|
+
italic: true,
|
148
|
+
strikeThrough: false,
|
149
|
+
underline: false
|
150
|
+
},
|
151
|
+
buttonCssClass: null
|
152
|
+
},
|
153
|
+
populateToolbar: function(toolbar) {
|
154
|
+
var buttonize, buttonset, enabled, format, widget, _ref,
|
155
|
+
_this = this;
|
156
|
+
widget = this;
|
157
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
158
|
+
buttonize = function(format) {
|
159
|
+
var buttonHolder;
|
160
|
+
buttonHolder = jQuery('<span></span>');
|
161
|
+
buttonHolder.hallobutton({
|
162
|
+
label: format,
|
163
|
+
editable: _this.options.editable,
|
164
|
+
command: format,
|
165
|
+
uuid: _this.options.uuid,
|
166
|
+
cssClass: _this.options.buttonCssClass
|
167
|
+
});
|
168
|
+
return buttonset.append(buttonHolder);
|
169
|
+
};
|
170
|
+
_ref = this.options.formattings;
|
171
|
+
for (format in _ref) {
|
172
|
+
enabled = _ref[format];
|
173
|
+
if (!enabled) {
|
174
|
+
continue;
|
175
|
+
}
|
176
|
+
buttonize(format);
|
177
|
+
}
|
178
|
+
buttonset.hallobuttonset();
|
179
|
+
return toolbar.append(buttonset);
|
180
|
+
}
|
181
|
+
});
|
182
|
+
})(jQuery);
|
183
|
+
|
184
|
+
(function(jQuery) {
|
185
|
+
return jQuery.widget("IKS.hallolink", {
|
186
|
+
options: {
|
187
|
+
editable: null,
|
188
|
+
uuid: "",
|
189
|
+
link: true,
|
190
|
+
image: true,
|
191
|
+
defaultUrl: 'http://',
|
192
|
+
dialogOpts: {
|
193
|
+
autoOpen: false,
|
194
|
+
width: 540,
|
195
|
+
height: 95,
|
196
|
+
title: "Enter Link",
|
197
|
+
buttonTitle: "Insert",
|
198
|
+
buttonUpdateTitle: "Update",
|
199
|
+
modal: true,
|
200
|
+
resizable: false,
|
201
|
+
draggable: false,
|
202
|
+
dialogClass: 'hallolink-dialog'
|
203
|
+
},
|
204
|
+
buttonCssClass: null
|
205
|
+
},
|
206
|
+
populateToolbar: function(toolbar) {
|
207
|
+
var butTitle, butUpdateTitle, buttonize, buttonset, dialog, dialogId, dialogSubmitCb, isEmptyLink, urlInput, widget,
|
208
|
+
_this = this;
|
209
|
+
widget = this;
|
210
|
+
dialogId = "" + this.options.uuid + "-dialog";
|
211
|
+
butTitle = this.options.dialogOpts.buttonTitle;
|
212
|
+
butUpdateTitle = this.options.dialogOpts.buttonUpdateTitle;
|
213
|
+
dialog = jQuery("<div id=\"" + dialogId + "\"> <form action=\"#\" method=\"post\" class=\"linkForm\"> <input class=\"url\" type=\"text\" name=\"url\" value=\"" + this.options.defaultUrl + "\" /> <input type=\"submit\" id=\"addlinkButton\" value=\"" + butTitle + "\"/> </form></div>");
|
214
|
+
urlInput = jQuery('input[name=url]', dialog).focus(function(e) {
|
215
|
+
return this.select();
|
216
|
+
});
|
217
|
+
isEmptyLink = function(link) {
|
218
|
+
if ((new RegExp(/^\s*$/)).test(link)) {
|
219
|
+
return true;
|
220
|
+
}
|
221
|
+
if (link === widget.options.defaultUrl) {
|
222
|
+
return true;
|
223
|
+
}
|
224
|
+
return false;
|
225
|
+
};
|
226
|
+
dialogSubmitCb = function(event) {
|
227
|
+
var link, selectionStart;
|
228
|
+
event.preventDefault();
|
229
|
+
link = urlInput.val();
|
230
|
+
widget.options.editable.restoreSelection(widget.lastSelection);
|
231
|
+
if (isEmptyLink(link)) {
|
232
|
+
selectionStart = widget.lastSelection.startContainer;
|
233
|
+
if (widget.lastSelection.collapsed) {
|
234
|
+
widget.lastSelection.setStartBefore(selectionStart);
|
235
|
+
widget.lastSelection.setEndAfter(selectionStart);
|
236
|
+
window.getSelection().addRange(widget.lastSelection);
|
237
|
+
}
|
238
|
+
document.execCommand("unlink", null, "");
|
239
|
+
} else {
|
240
|
+
if (!(/:\/\//.test(link)) && !(/^mailto:/.test(link))) {
|
241
|
+
link = 'http://' + link;
|
242
|
+
}
|
243
|
+
if (widget.lastSelection.startContainer.parentNode.href === void 0) {
|
244
|
+
document.execCommand("createLink", null, link);
|
245
|
+
} else {
|
246
|
+
widget.lastSelection.startContainer.parentNode.href = link;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
widget.options.editable.element.trigger('change');
|
250
|
+
widget.options.editable.removeAllSelections();
|
251
|
+
dialog.dialog('close');
|
252
|
+
return false;
|
253
|
+
};
|
254
|
+
dialog.find("input[type=submit]").click(dialogSubmitCb);
|
255
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
256
|
+
buttonize = function(type) {
|
257
|
+
var button, buttonHolder, id;
|
258
|
+
id = "" + _this.options.uuid + "-" + type;
|
259
|
+
buttonHolder = jQuery('<span></span>');
|
260
|
+
buttonHolder.hallobutton({
|
261
|
+
label: 'Link',
|
262
|
+
icon: 'icon-link',
|
263
|
+
editable: _this.options.editable,
|
264
|
+
command: null,
|
265
|
+
queryState: false,
|
266
|
+
uuid: _this.options.uuid,
|
267
|
+
cssClass: _this.options.buttonCssClass
|
268
|
+
});
|
269
|
+
buttonset.append(buttonHolder);
|
270
|
+
button = buttonHolder;
|
271
|
+
button.on("click", function(event) {
|
272
|
+
var button_selector, selectionParent;
|
273
|
+
widget.lastSelection = widget.options.editable.getSelection();
|
274
|
+
urlInput = jQuery('input[name=url]', dialog);
|
275
|
+
selectionParent = widget.lastSelection.startContainer.parentNode;
|
276
|
+
if (!selectionParent.href) {
|
277
|
+
urlInput.val(widget.options.defaultUrl);
|
278
|
+
jQuery(urlInput[0].form).find('input[type=submit]').val(butTitle);
|
279
|
+
} else {
|
280
|
+
urlInput.val(jQuery(selectionParent).attr('href'));
|
281
|
+
button_selector = 'input[type=submit]';
|
282
|
+
jQuery(urlInput[0].form).find(button_selector).val(butUpdateTitle);
|
283
|
+
}
|
284
|
+
widget.options.editable.keepActivated(true);
|
285
|
+
dialog.dialog('open');
|
286
|
+
dialog.on('dialogclose', function() {
|
287
|
+
jQuery('label', buttonHolder).removeClass('ui-state-active');
|
288
|
+
widget.options.editable.element.focus();
|
289
|
+
return widget.options.editable.keepActivated(false);
|
290
|
+
});
|
291
|
+
return false;
|
292
|
+
});
|
293
|
+
return _this.element.on("keyup paste change mouseup", function(event) {
|
294
|
+
var nodeName, start;
|
295
|
+
start = jQuery(widget.options.editable.getSelection().startContainer);
|
296
|
+
if (start.prop('nodeName')) {
|
297
|
+
nodeName = start.prop('nodeName');
|
298
|
+
} else {
|
299
|
+
nodeName = start.parent().prop('nodeName');
|
300
|
+
}
|
301
|
+
if (nodeName && nodeName.toUpperCase() === "A") {
|
302
|
+
jQuery('label', button).addClass('ui-state-active');
|
303
|
+
return;
|
304
|
+
}
|
305
|
+
return jQuery('label', button).removeClass('ui-state-active');
|
306
|
+
});
|
307
|
+
};
|
308
|
+
if (this.options.link) {
|
309
|
+
buttonize("A");
|
310
|
+
}
|
311
|
+
if (this.options.link) {
|
312
|
+
toolbar.append(buttonset);
|
313
|
+
buttonset.hallobuttonset();
|
314
|
+
return dialog.dialog(this.options.dialogOpts);
|
315
|
+
}
|
316
|
+
}
|
317
|
+
});
|
318
|
+
})(jQuery);
|
319
|
+
|
320
|
+
$.widget("ncri.hallo-image-insert-edit", {
|
321
|
+
options: {
|
322
|
+
editable: null,
|
323
|
+
toolbar: null,
|
324
|
+
uuid: "",
|
325
|
+
insert_file_dialog_ui_url: null,
|
326
|
+
lang: 'en',
|
327
|
+
dialogOpts: {
|
328
|
+
autoOpen: false,
|
329
|
+
width: 560,
|
330
|
+
height: 'auto',
|
331
|
+
modal: false,
|
332
|
+
resizable: true,
|
333
|
+
draggable: true,
|
334
|
+
dialogClass: 'insert-image-dialog'
|
335
|
+
},
|
336
|
+
dialog: null,
|
337
|
+
buttonCssClass: null
|
338
|
+
},
|
339
|
+
translations: {
|
340
|
+
en: {
|
341
|
+
title_insert: 'Insert Image',
|
342
|
+
title_properties: 'Image Properties',
|
343
|
+
insert: 'Insert',
|
344
|
+
chage_image: 'Change Image:',
|
345
|
+
source: 'URL',
|
346
|
+
width: 'Width',
|
347
|
+
height: 'Height',
|
348
|
+
alt: 'Alt Text',
|
349
|
+
padding: 'Padding',
|
350
|
+
float: 'Float',
|
351
|
+
float_left: 'left',
|
352
|
+
float_right: 'right',
|
353
|
+
float_none: 'No'
|
354
|
+
},
|
355
|
+
de: {
|
356
|
+
title_insert: 'Bild einfügen',
|
357
|
+
title_properties: 'Bildeigenschaften',
|
358
|
+
insert: 'Einfügen',
|
359
|
+
chage_image: 'Bild ändern:',
|
360
|
+
source: 'URL',
|
361
|
+
width: 'Breite',
|
362
|
+
height: 'Höhe',
|
363
|
+
alt: 'Alt Text',
|
364
|
+
padding: 'Padding',
|
365
|
+
float: 'Float',
|
366
|
+
float_left: 'Links',
|
367
|
+
float_right: 'Rechts',
|
368
|
+
float_none: 'Nein'
|
369
|
+
}
|
370
|
+
},
|
371
|
+
texts: null,
|
372
|
+
dialog_image_selection_ui_loaded: false,
|
373
|
+
$image: null,
|
374
|
+
populateToolbar: function($toolbar) {
|
375
|
+
var $buttonHolder, $buttonset, dialog_html, widget;
|
376
|
+
widget = this;
|
377
|
+
this.texts = this.translations[this.options.lang];
|
378
|
+
this.options.toolbar = $toolbar;
|
379
|
+
dialog_html = "<div id='hallo_img_properties'></div>";
|
380
|
+
if (this.options.insert_file_dialog_ui_url) {
|
381
|
+
dialog_html += "<div id='hallo_img_file_select_ui'></div>";
|
382
|
+
}
|
383
|
+
this.options.dialog = $("<div>").attr('id', "" + this.options.uuid + "-insert-image-dialog").html(dialog_html);
|
384
|
+
$buttonset = $("<span>").addClass(this.widgetName);
|
385
|
+
$buttonHolder = $('<span>');
|
386
|
+
$buttonHolder.hallobutton({
|
387
|
+
label: this.texts.title_insert,
|
388
|
+
icon: 'icon-picture',
|
389
|
+
editable: this.options.editable,
|
390
|
+
command: null,
|
391
|
+
queryState: false,
|
392
|
+
uuid: this.options.uuid,
|
393
|
+
cssClass: this.options.buttonCssClass
|
394
|
+
});
|
395
|
+
$buttonset.append($buttonHolder);
|
396
|
+
this.button = $buttonHolder;
|
397
|
+
this.button.click(function() {
|
398
|
+
if (widget.options.dialog.dialog("isOpen")) {
|
399
|
+
widget._closeDialog();
|
400
|
+
} else {
|
401
|
+
widget.lastSelection = widget.options.editable.getSelection();
|
402
|
+
widget._openDialog();
|
403
|
+
}
|
404
|
+
return false;
|
405
|
+
});
|
406
|
+
this.options.editable.element.on("halloselected, hallounselected", function() {
|
407
|
+
if (widget.options.dialog.dialog("isOpen")) {
|
408
|
+
return widget.lastSelection = widget.options.editable.getSelection();
|
409
|
+
}
|
410
|
+
});
|
411
|
+
this.options.editable.element.on("hallodeactivated", function() {
|
412
|
+
return widget._closeDialog();
|
413
|
+
});
|
414
|
+
$(this.options.editable.element).on("click", "img", function(e) {
|
415
|
+
widget._openDialog($(this));
|
416
|
+
return false;
|
417
|
+
});
|
418
|
+
this.options.editable.element.on('halloselected', function(event, data) {
|
419
|
+
var toolbar_option;
|
420
|
+
toolbar_option = widget.options.editable.options.toolbar;
|
421
|
+
if (toolbar_option === "halloToolbarContextual" && $(data.originalEvent.target).is('img')) {
|
422
|
+
$toolbar.hide();
|
423
|
+
return false;
|
424
|
+
}
|
425
|
+
});
|
426
|
+
$toolbar.append($buttonset);
|
427
|
+
return this.options.dialog.dialog(this.options.dialogOpts);
|
428
|
+
},
|
429
|
+
_openDialog: function($image) {
|
430
|
+
var $editableEl, widget, xposition, yposition,
|
431
|
+
_this = this;
|
432
|
+
this.$image = $image;
|
433
|
+
widget = this;
|
434
|
+
$editableEl = $(this.options.editable.element);
|
435
|
+
xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
|
436
|
+
if (this.$image) {
|
437
|
+
yposition = this.$image.offset().top - $(document).scrollTop();
|
438
|
+
} else {
|
439
|
+
yposition = this.options.toolbar.offset().top - $(document).scrollTop();
|
440
|
+
}
|
441
|
+
this.options.dialog.dialog("option", "position", [xposition, yposition]);
|
442
|
+
this.options.editable.keepActivated(true);
|
443
|
+
this.options.dialog.dialog("open");
|
444
|
+
if (this.$image) {
|
445
|
+
this.options.dialog.dialog("option", "title", this.texts.title_properties);
|
446
|
+
$(document).keyup(function(e) {
|
447
|
+
if (e.keyCode === 46 || e.keyCode === 8) {
|
448
|
+
$(document).off();
|
449
|
+
widget._closeDialog();
|
450
|
+
widget.$image.remove();
|
451
|
+
widget.$image = null;
|
452
|
+
}
|
453
|
+
return e.preventDefault();
|
454
|
+
});
|
455
|
+
this.options.editable.element.on("click", function() {
|
456
|
+
widget.$image = null;
|
457
|
+
return widget._closeDialog();
|
458
|
+
});
|
459
|
+
} else {
|
460
|
+
this.options.dialog.children('#hallo_img_properties').hide();
|
461
|
+
this.options.dialog.dialog("option", "title", this.texts.title_insert);
|
462
|
+
if ($('#hallo_img_file_select_title').length > 0) {
|
463
|
+
$('#hallo_img_file_select_title').text('');
|
464
|
+
}
|
465
|
+
}
|
466
|
+
this._load_dialog_image_properties_ui();
|
467
|
+
this.options.dialog.on('dialogclose', function() {
|
468
|
+
var scrollbar_pos;
|
469
|
+
$('label', _this.button).removeClass('ui-state-active');
|
470
|
+
scrollbar_pos = $(document).scrollTop();
|
471
|
+
_this.options.editable.element.focus();
|
472
|
+
$(document).scrollTop(scrollbar_pos);
|
473
|
+
return _this.options.editable.keepActivated(false);
|
474
|
+
});
|
475
|
+
if (this.options.insert_file_dialog_ui_url && !this.dialog_image_selection_ui_loaded) {
|
476
|
+
this.options.dialog.on('click', ".reload_link", function() {
|
477
|
+
widget._load_dialog_image_selection_ui();
|
478
|
+
return false;
|
479
|
+
});
|
480
|
+
this.options.dialog.on('click', '.file_preview img', function() {
|
481
|
+
var new_source;
|
482
|
+
if (widget.$image) {
|
483
|
+
new_source = $(this).attr('src').replace(/-thumb/, '');
|
484
|
+
widget.$image.attr('src', new_source);
|
485
|
+
$('#hallo_img_source').val(new_source);
|
486
|
+
} else {
|
487
|
+
widget._insert_image($(this).attr('src').replace(/-thumb/, ''));
|
488
|
+
}
|
489
|
+
return false;
|
490
|
+
});
|
491
|
+
return this._load_dialog_image_selection_ui();
|
492
|
+
}
|
493
|
+
},
|
494
|
+
_insert_image: function(source) {
|
495
|
+
this.options.editable.restoreSelection(this.lastSelection);
|
496
|
+
document.execCommand("insertImage", null, source);
|
497
|
+
this.options.editable.element.trigger('change');
|
498
|
+
this.options.editable.removeAllSelections();
|
499
|
+
return this._closeDialog();
|
500
|
+
},
|
501
|
+
_closeDialog: function() {
|
502
|
+
return this.options.dialog.dialog("close");
|
503
|
+
},
|
504
|
+
_load_dialog_image_selection_ui: function() {
|
505
|
+
var widget;
|
506
|
+
widget = this;
|
507
|
+
return $.ajax({
|
508
|
+
url: this.options.insert_file_dialog_ui_url,
|
509
|
+
success: function(data, textStatus, jqXHR) {
|
510
|
+
var $properties, file_select_title, t;
|
511
|
+
file_select_title = '';
|
512
|
+
$properties = widget.options.dialog.children('#hallo_img_properties');
|
513
|
+
if ($properties.is(':visible')) {
|
514
|
+
file_select_title = widget.texts.change_image;
|
515
|
+
}
|
516
|
+
t = "<div id='hallo_img_file_select_title'>" + file_select_title + "</div>";
|
517
|
+
widget.options.dialog.children('#hallo_img_file_select_ui').html(t + data);
|
518
|
+
return widget.dialog_image_selection_ui_loaded = true;
|
519
|
+
},
|
520
|
+
beforeSend: function() {
|
521
|
+
return widget.options.dialog.children('#hallo_img_file_select_ui').html('<div class="hallo_insert_file_loader"></div>');
|
522
|
+
}
|
523
|
+
});
|
524
|
+
},
|
525
|
+
_load_dialog_image_properties_ui: function() {
|
526
|
+
var $img_properties, button, height, html, widget, width;
|
527
|
+
widget = this;
|
528
|
+
$img_properties = this.options.dialog.children('#hallo_img_properties');
|
529
|
+
if (this.$image) {
|
530
|
+
width = this.$image.is('[width]') ? this.$image.attr('width') : '';
|
531
|
+
height = this.$image.is('[height]') ? this.$image.attr('height') : '';
|
532
|
+
html = this._property_input_html('source', this.$image.attr('src'), {
|
533
|
+
label: this.texts.source
|
534
|
+
}) + this._property_input_html('alt', this.$image.attr('alt') || '', {
|
535
|
+
label: this.texts.alt
|
536
|
+
}) + this._property_row_html(this._property_input_html('width', width, {
|
537
|
+
label: this.texts.width,
|
538
|
+
row: false
|
539
|
+
}) + this._property_input_html('height', height, {
|
540
|
+
label: this.texts.height,
|
541
|
+
row: false
|
542
|
+
})) + this._property_input_html('padding', this.$image.css('padding'), {
|
543
|
+
label: this.texts.padding
|
544
|
+
}) + this._property_row_html(this._property_cb_html('float_left', this.$image.css('float') === 'left', {
|
545
|
+
label: this.texts.float_left,
|
546
|
+
row: false
|
547
|
+
}) + this._property_cb_html('float_right', this.$image.css('float') === 'right', {
|
548
|
+
label: this.texts.float_right,
|
549
|
+
row: false
|
550
|
+
}) + this._property_cb_html('unfloat', this.$image.css('float') === 'none', {
|
551
|
+
label: this.texts.float_none,
|
552
|
+
row: false
|
553
|
+
}), this.texts.float);
|
554
|
+
$img_properties.html(html);
|
555
|
+
$img_properties.show();
|
556
|
+
} else {
|
557
|
+
if (!this.options.insert_file_dialog_ui_url) {
|
558
|
+
$img_properties.html(this._property_input_html('source', '', {
|
559
|
+
label: this.texts.source
|
560
|
+
}));
|
561
|
+
$img_properties.show();
|
562
|
+
}
|
563
|
+
}
|
564
|
+
if (this.$image) {
|
565
|
+
if (!this.options.insert_file_dialog_ui_url) {
|
566
|
+
$('#insert_image_btn').remove();
|
567
|
+
}
|
568
|
+
if ($('#hallo_img_file_select_title').length > 0) {
|
569
|
+
$('#hallo_img_file_select_title').text(this.texts.chage_image);
|
570
|
+
}
|
571
|
+
$('#hallo_img_properties #hallo_img_source').keyup(function() {
|
572
|
+
return widget.$image.attr('src', this.value);
|
573
|
+
});
|
574
|
+
$('#hallo_img_properties #hallo_img_alt').keyup(function() {
|
575
|
+
return widget.$image.attr('alt', this.value);
|
576
|
+
});
|
577
|
+
$('#hallo_img_properties #hallo_img_padding').keyup(function() {
|
578
|
+
return widget.$image.css('padding', this.value);
|
579
|
+
});
|
580
|
+
$('#hallo_img_properties #hallo_img_height').keyup(function() {
|
581
|
+
widget.$image.css('height', this.value);
|
582
|
+
return widget.$image.attr('height', this.value);
|
583
|
+
});
|
584
|
+
$('#hallo_img_properties #hallo_img_width').keyup(function() {
|
585
|
+
widget.$image.css('width', this.value);
|
586
|
+
return widget.$image.attr('width', this.value);
|
587
|
+
});
|
588
|
+
$('#hallo_img_properties #hallo_img_float_left').click(function() {
|
589
|
+
if (!this.checked) {
|
590
|
+
return false;
|
591
|
+
}
|
592
|
+
widget.$image.css('float', 'left');
|
593
|
+
$('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
|
594
|
+
return $('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
|
595
|
+
});
|
596
|
+
$('#hallo_img_properties #hallo_img_float_right').click(function() {
|
597
|
+
if (!this.checked) {
|
598
|
+
return false;
|
599
|
+
}
|
600
|
+
widget.$image.css('float', 'right');
|
601
|
+
$('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
|
602
|
+
return $('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
|
603
|
+
});
|
604
|
+
return $('#hallo_img_properties #hallo_img_unfloat').click(function() {
|
605
|
+
if (!this.checked) {
|
606
|
+
return false;
|
607
|
+
}
|
608
|
+
widget.$image.css('float', 'none');
|
609
|
+
$('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
|
610
|
+
return $('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
|
611
|
+
});
|
612
|
+
} else {
|
613
|
+
if (!this.options.insert_file_dialog_ui_url) {
|
614
|
+
button = "<button id=\"insert_image_btn\">" + this.texts.insert + "</button>";
|
615
|
+
$img_properties.after(button);
|
616
|
+
return $('#insert_image_btn').click(function() {
|
617
|
+
var $img_source;
|
618
|
+
$img_source = $('#hallo_img_properties #hallo_img_source');
|
619
|
+
return widget._insert_image($img_source.val());
|
620
|
+
});
|
621
|
+
}
|
622
|
+
}
|
623
|
+
},
|
624
|
+
_property_col_html: function(col_html) {
|
625
|
+
return "<div class='hallo_img_property_col'>" + col_html + "</div>";
|
626
|
+
},
|
627
|
+
_property_row_html: function(row_html, label) {
|
628
|
+
if (label == null) {
|
629
|
+
label = '';
|
630
|
+
}
|
631
|
+
row_html = this._property_col_html(label) + this._property_col_html(row_html);
|
632
|
+
return "<div class='hallo_img_property_row'>" + row_html + "</div>";
|
633
|
+
},
|
634
|
+
_property_html: function(property_html, options) {
|
635
|
+
var entry;
|
636
|
+
if (options == null) {
|
637
|
+
options = {};
|
638
|
+
}
|
639
|
+
if (options.row === false) {
|
640
|
+
if (options.label) {
|
641
|
+
entry = "" + options.label + " " + property_html;
|
642
|
+
property_html = "<span class='img_property_entry'>" + entry + "</span>";
|
643
|
+
}
|
644
|
+
return property_html;
|
645
|
+
} else {
|
646
|
+
entry = "<span class='img_property_entry'>" + property_html + "</span>";
|
647
|
+
return this._property_row_html(entry, options.label);
|
648
|
+
}
|
649
|
+
},
|
650
|
+
_property_input_html: function(id, value, options) {
|
651
|
+
var text_field;
|
652
|
+
if (options == null) {
|
653
|
+
options = {};
|
654
|
+
}
|
655
|
+
text_field = "<input type='text' id='hallo_img_" + id + "' value='" + value + "'>";
|
656
|
+
return this._property_html(text_field, options);
|
657
|
+
},
|
658
|
+
_property_cb_html: function(id, checked, options) {
|
659
|
+
var cb, checked_attr;
|
660
|
+
if (options == null) {
|
661
|
+
options = {};
|
662
|
+
}
|
663
|
+
checked_attr = checked ? 'checked=checked' : '';
|
664
|
+
cb = "<input type='checkbox' id='hallo_img_" + id + "' " + checked_attr + "'>";
|
665
|
+
return this._property_html(cb, options);
|
666
|
+
}
|
667
|
+
});
|
668
|
+
|
669
|
+
(function(jQuery) {
|
670
|
+
return jQuery.widget('IKS.halloblock', {
|
671
|
+
options: {
|
672
|
+
editable: null,
|
673
|
+
toolbar: null,
|
674
|
+
uuid: '',
|
675
|
+
elements: ['h1', 'h2', 'h3', 'p', 'pre', 'blockquote'],
|
676
|
+
buttonCssClass: null
|
677
|
+
},
|
678
|
+
populateToolbar: function(toolbar) {
|
679
|
+
var buttonset, contentId, target;
|
680
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
681
|
+
contentId = "" + this.options.uuid + "-" + this.widgetName + "-data";
|
682
|
+
target = this._prepareDropdown(contentId);
|
683
|
+
toolbar.append(buttonset);
|
684
|
+
buttonset.hallobuttonset();
|
685
|
+
buttonset.append(target);
|
686
|
+
return buttonset.append(this._prepareButton(target));
|
687
|
+
},
|
688
|
+
_prepareDropdown: function(contentId) {
|
689
|
+
var addElement, containingElement, contentArea, element, _i, _len, _ref,
|
690
|
+
_this = this;
|
691
|
+
contentArea = jQuery("<div id=\"" + contentId + "\"></div>");
|
692
|
+
containingElement = this.options.editable.element.get(0).tagName.toLowerCase();
|
693
|
+
addElement = function(element) {
|
694
|
+
var el, events, queryState;
|
695
|
+
el = jQuery("<button class='blockselector'> <" + element + " class=\"menu-item\">" + element + "</" + element + "> </button>");
|
696
|
+
if (containingElement === element) {
|
697
|
+
el.addClass('selected');
|
698
|
+
}
|
699
|
+
if (containingElement !== 'div') {
|
700
|
+
el.addClass('disabled');
|
701
|
+
}
|
702
|
+
el.on('click', function() {
|
703
|
+
var tagName;
|
704
|
+
tagName = element.toUpperCase();
|
705
|
+
if (el.hasClass('disabled')) {
|
706
|
+
return;
|
707
|
+
}
|
708
|
+
if (navigator.appName === 'Microsoft Internet Explorer') {
|
709
|
+
_this.options.editable.execute('FormatBlock', "<" + tagName + ">");
|
710
|
+
return;
|
711
|
+
}
|
712
|
+
return _this.options.editable.execute('formatBlock', tagName);
|
713
|
+
});
|
714
|
+
queryState = function(event) {
|
715
|
+
var block;
|
716
|
+
block = document.queryCommandValue('formatBlock');
|
717
|
+
if (block.toLowerCase() === element) {
|
718
|
+
el.addClass('selected');
|
719
|
+
return;
|
720
|
+
}
|
721
|
+
return el.removeClass('selected');
|
722
|
+
};
|
723
|
+
events = 'keyup paste change mouseup';
|
724
|
+
_this.options.editable.element.on(events, queryState);
|
725
|
+
_this.options.editable.element.on('halloenabled', function() {
|
726
|
+
return _this.options.editable.element.on(events, queryState);
|
727
|
+
});
|
728
|
+
_this.options.editable.element.on('hallodisabled', function() {
|
729
|
+
return _this.options.editable.element.off(events, queryState);
|
730
|
+
});
|
731
|
+
return el;
|
732
|
+
};
|
733
|
+
_ref = this.options.elements;
|
734
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
735
|
+
element = _ref[_i];
|
736
|
+
contentArea.append(addElement(element));
|
737
|
+
}
|
738
|
+
return contentArea;
|
739
|
+
},
|
740
|
+
_prepareButton: function(target) {
|
741
|
+
var buttonElement;
|
742
|
+
buttonElement = jQuery('<span></span>');
|
743
|
+
buttonElement.hallodropdownbutton({
|
744
|
+
uuid: this.options.uuid,
|
745
|
+
editable: this.options.editable,
|
746
|
+
label: 'block',
|
747
|
+
icon: 'icon-text-height',
|
748
|
+
target: target,
|
749
|
+
cssClass: this.options.buttonCssClass
|
750
|
+
});
|
751
|
+
return buttonElement;
|
752
|
+
}
|
753
|
+
});
|
754
|
+
})(jQuery);
|
755
|
+
|
756
|
+
(function(jQuery) {
|
757
|
+
return jQuery.widget("IKS.halloheadings", {
|
758
|
+
options: {
|
759
|
+
editable: null,
|
760
|
+
uuid: '',
|
761
|
+
formatBlocks: ["p", "h1", "h2", "h3"],
|
762
|
+
buttonCssClass: null
|
763
|
+
},
|
764
|
+
populateToolbar: function(toolbar) {
|
765
|
+
var buttonize, buttonset, command, format, ie, widget, _i, _len, _ref,
|
766
|
+
_this = this;
|
767
|
+
widget = this;
|
768
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
769
|
+
ie = navigator.appName === 'Microsoft Internet Explorer';
|
770
|
+
command = (ie ? "FormatBlock" : "formatBlock");
|
771
|
+
buttonize = function(format) {
|
772
|
+
var buttonHolder;
|
773
|
+
buttonHolder = jQuery('<span></span>');
|
774
|
+
buttonHolder.hallobutton({
|
775
|
+
label: format,
|
776
|
+
editable: _this.options.editable,
|
777
|
+
command: command,
|
778
|
+
commandValue: (ie ? "<" + format + ">" : format),
|
779
|
+
uuid: _this.options.uuid,
|
780
|
+
cssClass: _this.options.buttonCssClass,
|
781
|
+
queryState: function(event) {
|
782
|
+
var compared, map, result, val, value, _i, _len, _ref;
|
783
|
+
try {
|
784
|
+
value = document.queryCommandValue(command);
|
785
|
+
if (ie) {
|
786
|
+
map = {
|
787
|
+
p: "normal"
|
788
|
+
};
|
789
|
+
_ref = [1, 2, 3, 4, 5, 6];
|
790
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
791
|
+
val = _ref[_i];
|
792
|
+
map["h" + val] = val;
|
793
|
+
}
|
794
|
+
compared = value.match(new RegExp(map[format], "i"));
|
795
|
+
} else {
|
796
|
+
compared = value.match(new RegExp(format, "i"));
|
797
|
+
}
|
798
|
+
result = compared ? true : false;
|
799
|
+
return buttonHolder.hallobutton('checked', result);
|
800
|
+
} catch (e) {
|
801
|
+
|
802
|
+
}
|
803
|
+
}
|
804
|
+
});
|
805
|
+
buttonHolder.find('button .ui-button-text').text(format.toUpperCase());
|
806
|
+
return buttonset.append(buttonHolder);
|
807
|
+
};
|
808
|
+
_ref = this.options.formatBlocks;
|
809
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
810
|
+
format = _ref[_i];
|
811
|
+
buttonize(format);
|
812
|
+
}
|
813
|
+
buttonset.hallobuttonset();
|
814
|
+
return toolbar.append(buttonset);
|
815
|
+
}
|
816
|
+
});
|
817
|
+
})(jQuery);
|
818
|
+
|
819
|
+
(function(jQuery) {
|
820
|
+
return jQuery.widget("IKS.halloreundo", {
|
821
|
+
options: {
|
822
|
+
editable: null,
|
823
|
+
toolbar: null,
|
824
|
+
uuid: '',
|
825
|
+
buttonCssClass: null
|
826
|
+
},
|
827
|
+
populateToolbar: function(toolbar) {
|
828
|
+
var buttonize, buttonset,
|
829
|
+
_this = this;
|
830
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
831
|
+
buttonize = function(cmd, label) {
|
832
|
+
var buttonElement;
|
833
|
+
buttonElement = jQuery('<span></span>');
|
834
|
+
buttonElement.hallobutton({
|
835
|
+
uuid: _this.options.uuid,
|
836
|
+
editable: _this.options.editable,
|
837
|
+
label: label,
|
838
|
+
icon: cmd === 'undo' ? 'icon-undo' : 'icon-repeat',
|
839
|
+
command: cmd,
|
840
|
+
queryState: false,
|
841
|
+
cssClass: _this.options.buttonCssClass
|
842
|
+
});
|
843
|
+
return buttonset.append(buttonElement);
|
844
|
+
};
|
845
|
+
buttonize("undo", "Undo");
|
846
|
+
buttonize("redo", "Redo");
|
847
|
+
buttonset.hallobuttonset();
|
848
|
+
return toolbar.append(buttonset);
|
849
|
+
}
|
850
|
+
});
|
851
|
+
})(jQuery);
|
852
|
+
|
853
|
+
(function(jQuery) {
|
854
|
+
return jQuery.widget("IKS.halloimage", {
|
855
|
+
options: {
|
856
|
+
editable: null,
|
857
|
+
toolbar: null,
|
858
|
+
uuid: "",
|
859
|
+
limit: 8,
|
860
|
+
search: null,
|
861
|
+
searchUrl: null,
|
862
|
+
suggestions: null,
|
863
|
+
loaded: null,
|
864
|
+
upload: null,
|
865
|
+
uploadUrl: null,
|
866
|
+
dialogOpts: {
|
867
|
+
autoOpen: false,
|
868
|
+
width: 270,
|
869
|
+
height: "auto",
|
870
|
+
title: "Insert Images",
|
871
|
+
modal: false,
|
872
|
+
resizable: false,
|
873
|
+
draggable: true,
|
874
|
+
dialogClass: 'halloimage-dialog'
|
875
|
+
},
|
876
|
+
dialog: null,
|
877
|
+
buttonCssClass: null,
|
878
|
+
entity: null,
|
879
|
+
vie: null,
|
880
|
+
dbPediaUrl: "http://dev.iks-project.eu/stanbolfull",
|
881
|
+
maxWidth: 250,
|
882
|
+
maxHeight: 250
|
883
|
+
},
|
884
|
+
populateToolbar: function(toolbar) {
|
885
|
+
var buttonHolder, buttonset, dialogId, id, tabContent, tabs, widget;
|
886
|
+
this.options.toolbar = toolbar;
|
887
|
+
widget = this;
|
888
|
+
dialogId = "" + this.options.uuid + "-image-dialog";
|
889
|
+
this.options.dialog = jQuery("<div id=\"" + dialogId + "\"> <div class=\"nav\"> <ul class=\"tabs\"> </ul> <div id=\"" + this.options.uuid + "-tab-activeIndicator\" class=\"tab-activeIndicator\" /> </div> <div class=\"dialogcontent\"> </div>");
|
890
|
+
tabs = jQuery('.tabs', this.options.dialog);
|
891
|
+
tabContent = jQuery('.dialogcontent', this.options.dialog);
|
892
|
+
if (widget.options.suggestions) {
|
893
|
+
this._addGuiTabSuggestions(tabs, tabContent);
|
894
|
+
}
|
895
|
+
if (widget.options.search || widget.options.searchUrl) {
|
896
|
+
this._addGuiTabSearch(tabs, tabContent);
|
897
|
+
}
|
898
|
+
if (widget.options.upload || widget.options.uploadUrl) {
|
899
|
+
this._addGuiTabUpload(tabs, tabContent);
|
900
|
+
}
|
901
|
+
this.current = jQuery('<div class="currentImage"></div>').halloimagecurrent({
|
902
|
+
uuid: this.options.uuid,
|
903
|
+
imageWidget: this,
|
904
|
+
editable: this.options.editable,
|
905
|
+
dialog: this.options.dialog,
|
906
|
+
maxWidth: this.options.maxWidth,
|
907
|
+
maxHeight: this.options.maxHeight
|
908
|
+
});
|
909
|
+
jQuery('.dialogcontent', this.options.dialog).append(this.current);
|
910
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
911
|
+
id = "" + this.options.uuid + "-image";
|
912
|
+
buttonHolder = jQuery('<span></span>');
|
913
|
+
buttonHolder.hallobutton({
|
914
|
+
label: 'Images',
|
915
|
+
icon: 'icon-picture',
|
916
|
+
editable: this.options.editable,
|
917
|
+
command: null,
|
918
|
+
queryState: false,
|
919
|
+
uuid: this.options.uuid,
|
920
|
+
cssClass: this.options.buttonCssClass
|
921
|
+
});
|
922
|
+
buttonset.append(buttonHolder);
|
923
|
+
this.button = buttonHolder;
|
924
|
+
this.button.on("click", function(event) {
|
925
|
+
if (widget.options.dialog.dialog("isOpen")) {
|
926
|
+
widget._closeDialog();
|
927
|
+
} else {
|
928
|
+
widget._openDialog();
|
929
|
+
}
|
930
|
+
return false;
|
931
|
+
});
|
932
|
+
this.options.editable.element.on("hallodeactivated", function(event) {
|
933
|
+
return widget._closeDialog();
|
934
|
+
});
|
935
|
+
jQuery(this.options.editable.element).delegate("img", "click", function(event) {
|
936
|
+
return widget._openDialog();
|
937
|
+
});
|
938
|
+
toolbar.append(buttonset);
|
939
|
+
this.options.dialog.dialog(this.options.dialogOpts);
|
940
|
+
return this._handleTabs();
|
941
|
+
},
|
942
|
+
setCurrent: function(image) {
|
943
|
+
return this.current.halloimagecurrent('setImage', image);
|
944
|
+
},
|
945
|
+
_handleTabs: function() {
|
946
|
+
var widget;
|
947
|
+
widget = this;
|
948
|
+
jQuery('.nav li', this.options.dialog).on('click', function() {
|
949
|
+
var id, left;
|
950
|
+
jQuery("." + widget.widgetName + "-tab").hide();
|
951
|
+
id = jQuery(this).attr('id');
|
952
|
+
jQuery("#" + id + "-content").show();
|
953
|
+
left = jQuery(this).position().left + (jQuery(this).width() / 2);
|
954
|
+
return jQuery("#" + widget.options.uuid + "-tab-activeIndicator").css({
|
955
|
+
"margin-left": left
|
956
|
+
});
|
957
|
+
});
|
958
|
+
return jQuery('.nav li', this.options.dialog).first().click();
|
959
|
+
},
|
960
|
+
_openDialog: function() {
|
961
|
+
var cleanUp, editableEl, getActive, suggestionSelector, toolbarEl, widget, xposition, yposition,
|
962
|
+
_this = this;
|
963
|
+
widget = this;
|
964
|
+
cleanUp = function() {
|
965
|
+
return window.setTimeout(function() {
|
966
|
+
var thumbnails;
|
967
|
+
thumbnails = jQuery(".imageThumbnail");
|
968
|
+
return jQuery(thumbnails).each(function() {
|
969
|
+
var size;
|
970
|
+
size = jQuery("#" + this.id).width();
|
971
|
+
if (size <= 20) {
|
972
|
+
return jQuery("#" + this.id).parent("li").remove();
|
973
|
+
}
|
974
|
+
});
|
975
|
+
}, 15000);
|
976
|
+
};
|
977
|
+
suggestionSelector = "#" + this.options.uuid + "-tab-suggestions-content";
|
978
|
+
getActive = function() {
|
979
|
+
return jQuery('.imageThumbnailActive', suggestionSelector).first().attr("src");
|
980
|
+
};
|
981
|
+
jQuery("#" + this.options.uuid + "-sugg-activeImage").attr("src", getActive());
|
982
|
+
jQuery("#" + this.options.uuid + "-sugg-activeImageBg").attr("src", getActive());
|
983
|
+
this.lastSelection = this.options.editable.getSelection();
|
984
|
+
editableEl = jQuery(this.options.editable.element);
|
985
|
+
toolbarEl = jQuery(this.options.toolbar);
|
986
|
+
xposition = editableEl.offset().left + editableEl.outerWidth() - 3;
|
987
|
+
yposition = toolbarEl.offset().top + toolbarEl.outerHeight() + 29;
|
988
|
+
yposition -= jQuery(document).scrollTop();
|
989
|
+
this.options.dialog.dialog("option", "position", [xposition, yposition]);
|
990
|
+
cleanUp();
|
991
|
+
widget.options.loaded = 1;
|
992
|
+
this.options.editable.keepActivated(true);
|
993
|
+
this.options.dialog.dialog("open");
|
994
|
+
return this.options.dialog.on('dialogclose', function() {
|
995
|
+
jQuery('label', _this.button).removeClass('ui-state-active');
|
996
|
+
_this.options.editable.element.focus();
|
997
|
+
return _this.options.editable.keepActivated(false);
|
998
|
+
});
|
999
|
+
},
|
1000
|
+
_closeDialog: function() {
|
1001
|
+
return this.options.dialog.dialog("close");
|
1002
|
+
},
|
1003
|
+
_addGuiTabSuggestions: function(tabs, element) {
|
1004
|
+
var tab;
|
1005
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-suggestions\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-suggestions\"> <span>Suggestions</span> </li>"));
|
1006
|
+
tab = jQuery("<div id=\"" + this.options.uuid + "-tab-suggestions-content\" class=\"" + this.widgetName + "-tab tab-suggestions\"></div>");
|
1007
|
+
element.append(tab);
|
1008
|
+
return tab.halloimagesuggestions({
|
1009
|
+
uuid: this.options.uuid,
|
1010
|
+
imageWidget: this,
|
1011
|
+
entity: this.options.entity
|
1012
|
+
});
|
1013
|
+
},
|
1014
|
+
_addGuiTabSearch: function(tabs, element) {
|
1015
|
+
var dialogId, tab, widget;
|
1016
|
+
widget = this;
|
1017
|
+
dialogId = "" + this.options.uuid + "-image-dialog";
|
1018
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-search\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-search\"> <span>Search</span> </li>"));
|
1019
|
+
tab = jQuery("<div id=\"" + this.options.uuid + "-tab-search-content\" class=\"" + widget.widgetName + "-tab tab-search\"></div>");
|
1020
|
+
element.append(tab);
|
1021
|
+
return tab.halloimagesearch({
|
1022
|
+
uuid: this.options.uuid,
|
1023
|
+
imageWidget: this,
|
1024
|
+
searchCallback: this.options.search,
|
1025
|
+
searchUrl: this.options.searchUrl,
|
1026
|
+
limit: this.options.limit,
|
1027
|
+
entity: this.options.entity
|
1028
|
+
});
|
1029
|
+
},
|
1030
|
+
_addGuiTabUpload: function(tabs, element) {
|
1031
|
+
var tab;
|
1032
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-upload\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-upload\"> <span>Upload</span> </li>"));
|
1033
|
+
tab = jQuery("<div id=\"" + this.options.uuid + "-tab-upload-content\" class=\"" + this.widgetName + "-tab tab-upload\"></div>");
|
1034
|
+
element.append(tab);
|
1035
|
+
return tab.halloimageupload({
|
1036
|
+
uuid: this.options.uuid,
|
1037
|
+
uploadCallback: this.options.upload,
|
1038
|
+
uploadUrl: this.options.uploadUrl,
|
1039
|
+
imageWidget: this,
|
1040
|
+
entity: this.options.entity
|
1041
|
+
});
|
1042
|
+
}
|
1043
|
+
/*
|
1044
|
+
insertImage = () ->
|
1045
|
+
# This may need to insert an image that does not have the same URL as
|
1046
|
+
# the preview image, since it may be a different size
|
1047
|
+
# Check if we have a selection and fall back to @lastSelection otherwise
|
1048
|
+
try
|
1049
|
+
if not widget.options.editable.getSelection()
|
1050
|
+
throw new Error "SelectionNotSet"
|
1051
|
+
catch error
|
1052
|
+
widget.options.editable.restoreSelection(widget.lastSelection)
|
1053
|
+
|
1054
|
+
document.execCommand "insertImage", null, jQuery(this).attr('src')
|
1055
|
+
img = document.getSelection().anchorNode.firstChild
|
1056
|
+
jQuery(img).attr "alt", jQuery(".caption").value
|
1057
|
+
|
1058
|
+
triggerModified = () ->
|
1059
|
+
widget.element.trigger "hallomodified"
|
1060
|
+
window.setTimeout triggerModified, 100
|
1061
|
+
widget._closeDialog()
|
1062
|
+
|
1063
|
+
addImage = "##{widget.options.uuid}-#{widget.widgetName-addimage"
|
1064
|
+
@options.dialog.find(".halloimage-activeImage, addImage).click insertImage
|
1065
|
+
*/
|
1066
|
+
|
1067
|
+
});
|
1068
|
+
})(jQuery);
|
1069
|
+
|
1070
|
+
(function(jQuery) {
|
1071
|
+
return jQuery.widget("Liip.hallooverlay", {
|
1072
|
+
options: {
|
1073
|
+
editable: null,
|
1074
|
+
toolbar: null,
|
1075
|
+
uuid: "",
|
1076
|
+
overlay: null,
|
1077
|
+
padding: 10,
|
1078
|
+
background: null
|
1079
|
+
},
|
1080
|
+
_create: function() {
|
1081
|
+
var widget;
|
1082
|
+
widget = this;
|
1083
|
+
if (!this.options.bound) {
|
1084
|
+
this.options.bound = true;
|
1085
|
+
this.options.editable.element.on("halloactivated", function(event, data) {
|
1086
|
+
widget.options.currentEditable = jQuery(event.target);
|
1087
|
+
if (!widget.options.visible) {
|
1088
|
+
return widget.showOverlay();
|
1089
|
+
}
|
1090
|
+
});
|
1091
|
+
this.options.editable.element.on("hallomodified", function(event, data) {
|
1092
|
+
widget.options.currentEditable = jQuery(event.target);
|
1093
|
+
if (widget.options.visible) {
|
1094
|
+
return widget.resizeOverlay();
|
1095
|
+
}
|
1096
|
+
});
|
1097
|
+
return this.options.editable.element.on("hallodeactivated", function(event, data) {
|
1098
|
+
widget.options.currentEditable = jQuery(event.target);
|
1099
|
+
if (widget.options.visible) {
|
1100
|
+
return widget.hideOverlay();
|
1101
|
+
}
|
1102
|
+
});
|
1103
|
+
}
|
1104
|
+
},
|
1105
|
+
showOverlay: function() {
|
1106
|
+
this.options.visible = true;
|
1107
|
+
if (this.options.overlay === null) {
|
1108
|
+
if (jQuery("#halloOverlay").length > 0) {
|
1109
|
+
this.options.overlay = jQuery("#halloOverlay");
|
1110
|
+
} else {
|
1111
|
+
this.options.overlay = jQuery("<div id=\"halloOverlay\" class=\"halloOverlay\">");
|
1112
|
+
jQuery(document.body).append(this.options.overlay);
|
1113
|
+
}
|
1114
|
+
this.options.overlay.on('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable));
|
1115
|
+
}
|
1116
|
+
this.options.overlay.show();
|
1117
|
+
if (this.options.background === null) {
|
1118
|
+
if (jQuery("#halloBackground").length > 0) {
|
1119
|
+
this.options.background = jQuery("#halloBackground");
|
1120
|
+
} else {
|
1121
|
+
this.options.background = jQuery("<div id=\"halloBackground\" class=\"halloBackground\">");
|
1122
|
+
jQuery(document.body).append(this.options.background);
|
1123
|
+
}
|
1124
|
+
}
|
1125
|
+
this.resizeOverlay();
|
1126
|
+
this.options.background.show();
|
1127
|
+
if (!this.options.originalZIndex) {
|
1128
|
+
this.options.originalZIndex = this.options.currentEditable.css("z-index");
|
1129
|
+
}
|
1130
|
+
return this.options.currentEditable.css('z-index', '350');
|
1131
|
+
},
|
1132
|
+
resizeOverlay: function() {
|
1133
|
+
var offset;
|
1134
|
+
offset = this.options.currentEditable.offset();
|
1135
|
+
return this.options.background.css({
|
1136
|
+
top: offset.top - this.options.padding,
|
1137
|
+
left: offset.left - this.options.padding,
|
1138
|
+
width: this.options.currentEditable.width() + 2 * this.options.padding,
|
1139
|
+
height: this.options.currentEditable.height() + 2 * this.options.padding
|
1140
|
+
});
|
1141
|
+
},
|
1142
|
+
hideOverlay: function() {
|
1143
|
+
this.options.visible = false;
|
1144
|
+
this.options.overlay.hide();
|
1145
|
+
this.options.background.hide();
|
1146
|
+
return this.options.currentEditable.css('z-index', this.options.originalZIndex);
|
1147
|
+
},
|
1148
|
+
_findBackgroundColor: function(jQueryfield) {
|
1149
|
+
var color;
|
1150
|
+
color = jQueryfield.css("background-color");
|
1151
|
+
if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') {
|
1152
|
+
return color;
|
1153
|
+
}
|
1154
|
+
if (jQueryfield.is("body")) {
|
1155
|
+
return "white";
|
1156
|
+
} else {
|
1157
|
+
return this._findBackgroundColor(jQueryfield.parent());
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
});
|
1161
|
+
})(jQuery);
|
1162
|
+
|
1163
|
+
(function(jQuery) {
|
1164
|
+
return jQuery.widget('IKS.halloindicator', {
|
1165
|
+
options: {
|
1166
|
+
editable: null,
|
1167
|
+
className: 'halloEditIndicator'
|
1168
|
+
},
|
1169
|
+
_create: function() {
|
1170
|
+
var _this = this;
|
1171
|
+
return this.element.on('halloenabled', function() {
|
1172
|
+
return _this.buildIndicator();
|
1173
|
+
});
|
1174
|
+
},
|
1175
|
+
populateToolbar: function() {},
|
1176
|
+
buildIndicator: function() {
|
1177
|
+
var editButton;
|
1178
|
+
editButton = jQuery('<div><i class="icon-edit"></i> Edit</div>');
|
1179
|
+
editButton.addClass(this.options.className);
|
1180
|
+
editButton.hide();
|
1181
|
+
this.element.before(editButton);
|
1182
|
+
this.bindIndicator(editButton);
|
1183
|
+
return this.setIndicatorPosition(editButton);
|
1184
|
+
},
|
1185
|
+
bindIndicator: function(indicator) {
|
1186
|
+
var _this = this;
|
1187
|
+
indicator.on('click', function() {
|
1188
|
+
return _this.options.editable.element.focus();
|
1189
|
+
});
|
1190
|
+
this.element.on('halloactivated', function() {
|
1191
|
+
return indicator.hide();
|
1192
|
+
});
|
1193
|
+
this.element.on('hallodisabled', function() {
|
1194
|
+
return indicator.remove();
|
1195
|
+
});
|
1196
|
+
return this.options.editable.element.hover(function() {
|
1197
|
+
if (jQuery(this).hasClass('inEditMode')) {
|
1198
|
+
return;
|
1199
|
+
}
|
1200
|
+
return indicator.show();
|
1201
|
+
}, function(data) {
|
1202
|
+
if (jQuery(this).hasClass('inEditMode')) {
|
1203
|
+
return;
|
1204
|
+
}
|
1205
|
+
if (data.relatedTarget === indicator.get(0)) {
|
1206
|
+
return;
|
1207
|
+
}
|
1208
|
+
return indicator.hide();
|
1209
|
+
});
|
1210
|
+
},
|
1211
|
+
setIndicatorPosition: function(indicator) {
|
1212
|
+
var offset;
|
1213
|
+
indicator.css('position', 'absolute');
|
1214
|
+
offset = this.element.position();
|
1215
|
+
indicator.css('top', offset.top + 2);
|
1216
|
+
return indicator.css('left', offset.left + 2);
|
1217
|
+
}
|
1218
|
+
});
|
1219
|
+
})(jQuery);
|
1220
|
+
|
1221
|
+
(function(jQuery) {
|
1222
|
+
var z;
|
1223
|
+
z = null;
|
1224
|
+
if (this.VIE !== void 0) {
|
1225
|
+
z = new VIE;
|
1226
|
+
z.use(new z.StanbolService({
|
1227
|
+
proxyDisabled: true,
|
1228
|
+
url: 'http://dev.iks-project.eu:8081'
|
1229
|
+
}));
|
1230
|
+
}
|
1231
|
+
return jQuery.widget('IKS.halloannotate', {
|
1232
|
+
options: {
|
1233
|
+
vie: z,
|
1234
|
+
editable: null,
|
1235
|
+
toolbar: null,
|
1236
|
+
uuid: '',
|
1237
|
+
select: function() {},
|
1238
|
+
decline: function() {},
|
1239
|
+
remove: function() {},
|
1240
|
+
buttonCssClass: null
|
1241
|
+
},
|
1242
|
+
_create: function() {
|
1243
|
+
var editableElement, turnOffAnnotate, widget;
|
1244
|
+
widget = this;
|
1245
|
+
if (this.options.vie === void 0) {
|
1246
|
+
throw new Error('The halloannotate plugin requires VIE');
|
1247
|
+
return;
|
1248
|
+
}
|
1249
|
+
if (typeof this.element.annotate !== 'function') {
|
1250
|
+
throw new Error('The halloannotate plugin requires annotate.js');
|
1251
|
+
return;
|
1252
|
+
}
|
1253
|
+
this.state = 'off';
|
1254
|
+
this.instantiate();
|
1255
|
+
turnOffAnnotate = function() {
|
1256
|
+
var editable;
|
1257
|
+
editable = this;
|
1258
|
+
return jQuery(editable).halloannotate('turnOff');
|
1259
|
+
};
|
1260
|
+
editableElement = this.options.editable.element;
|
1261
|
+
return editableElement.on('hallodisabled', turnOffAnnotate);
|
1262
|
+
},
|
1263
|
+
populateToolbar: function(toolbar) {
|
1264
|
+
var buttonHolder,
|
1265
|
+
_this = this;
|
1266
|
+
buttonHolder = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
1267
|
+
this.button = buttonHolder.hallobutton({
|
1268
|
+
label: 'Annotate',
|
1269
|
+
icon: 'icon-tags',
|
1270
|
+
editable: this.options.editable,
|
1271
|
+
command: null,
|
1272
|
+
uuid: this.options.uuid,
|
1273
|
+
cssClass: this.options.buttonCssClass,
|
1274
|
+
queryState: false
|
1275
|
+
});
|
1276
|
+
buttonHolder.on('change', function(event) {
|
1277
|
+
if (_this.state === "pending") {
|
1278
|
+
return;
|
1279
|
+
}
|
1280
|
+
if (_this.state === "off") {
|
1281
|
+
return _this.turnOn();
|
1282
|
+
}
|
1283
|
+
return _this.turnOff();
|
1284
|
+
});
|
1285
|
+
buttonHolder.buttonset();
|
1286
|
+
return toolbar.append(this.button);
|
1287
|
+
},
|
1288
|
+
cleanupContentClone: function(el) {
|
1289
|
+
if (this.state === 'on') {
|
1290
|
+
return el.find(".entity:not([about])").each(function() {
|
1291
|
+
return jQuery(this).replaceWith(jQuery(this).html());
|
1292
|
+
});
|
1293
|
+
}
|
1294
|
+
},
|
1295
|
+
instantiate: function() {
|
1296
|
+
var widget;
|
1297
|
+
widget = this;
|
1298
|
+
return this.options.editable.element.annotate({
|
1299
|
+
vie: this.options.vie,
|
1300
|
+
debug: false,
|
1301
|
+
showTooltip: true,
|
1302
|
+
select: this.options.select,
|
1303
|
+
remove: this.options.remove,
|
1304
|
+
success: this.options.success,
|
1305
|
+
error: this.options.error
|
1306
|
+
}).on('annotateselect', function(event, data) {
|
1307
|
+
return widget.options.editable.setModified();
|
1308
|
+
}).on('annotateremove', function() {
|
1309
|
+
return jQuery.noop();
|
1310
|
+
});
|
1311
|
+
},
|
1312
|
+
turnPending: function() {
|
1313
|
+
this.state = 'pending';
|
1314
|
+
this.button.hallobutton('checked', false);
|
1315
|
+
return this.button.hallobutton('disable');
|
1316
|
+
},
|
1317
|
+
turnOn: function() {
|
1318
|
+
var widget,
|
1319
|
+
_this = this;
|
1320
|
+
this.turnPending();
|
1321
|
+
widget = this;
|
1322
|
+
try {
|
1323
|
+
return this.options.editable.element.annotate('enable', function(success) {
|
1324
|
+
if (!success) {
|
1325
|
+
return;
|
1326
|
+
}
|
1327
|
+
_this.state = 'on';
|
1328
|
+
_this.button.hallobutton('checked', true);
|
1329
|
+
return _this.button.hallobutton('enable');
|
1330
|
+
});
|
1331
|
+
} catch (e) {
|
1332
|
+
return alert(e);
|
1333
|
+
}
|
1334
|
+
},
|
1335
|
+
turnOff: function() {
|
1336
|
+
this.options.editable.element.annotate('disable');
|
1337
|
+
this.state = 'off';
|
1338
|
+
if (!this.button) {
|
1339
|
+
return;
|
1340
|
+
}
|
1341
|
+
this.button.attr('checked', false);
|
1342
|
+
this.button.find("label").removeClass("ui-state-clicked");
|
1343
|
+
return this.button.button('refresh');
|
1344
|
+
}
|
1345
|
+
});
|
1346
|
+
})(jQuery);
|
1347
|
+
|
1348
|
+
(function(jQuery) {
|
1349
|
+
return jQuery.widget('IKS.halloimagesearch', {
|
1350
|
+
options: {
|
1351
|
+
imageWidget: null,
|
1352
|
+
searchCallback: null,
|
1353
|
+
searchUrl: null,
|
1354
|
+
limit: 5
|
1355
|
+
},
|
1356
|
+
_create: function() {
|
1357
|
+
return this.element.html('<div>\
|
1358
|
+
<form method="get">\
|
1359
|
+
<input type="text" class="searchInput" placeholder="Search" />\
|
1360
|
+
<input type="submit" class="btn searchButton" value="OK" />\
|
1361
|
+
</form>\
|
1362
|
+
<div class="searchResults imageThumbnailContainer">\
|
1363
|
+
<div class="activitySpinner">Loading images...</div>\
|
1364
|
+
<ul></ul>\
|
1365
|
+
</div>\
|
1366
|
+
</div>');
|
1367
|
+
},
|
1368
|
+
_init: function() {
|
1369
|
+
var _this = this;
|
1370
|
+
if (this.options.searchUrl && !this.options.searchCallback) {
|
1371
|
+
this.options.searchCallback = this._ajaxSearch;
|
1372
|
+
}
|
1373
|
+
jQuery('.activitySpinner', this.element).hide();
|
1374
|
+
return jQuery('form', this.element).submit(function(event) {
|
1375
|
+
var query;
|
1376
|
+
event.preventDefault();
|
1377
|
+
jQuery('.activitySpinner', _this.element).show();
|
1378
|
+
query = jQuery('.searchInput', _this.element.element).val();
|
1379
|
+
return _this.options.searchCallback(query, _this.options.limit, 0, function(results) {
|
1380
|
+
return _this._showResults(results);
|
1381
|
+
});
|
1382
|
+
});
|
1383
|
+
},
|
1384
|
+
_showResult: function(image) {
|
1385
|
+
var html,
|
1386
|
+
_this = this;
|
1387
|
+
if (!image.label) {
|
1388
|
+
image.label = image.alt;
|
1389
|
+
}
|
1390
|
+
html = jQuery("<li> <img src=\"" + image.url + "\" class=\"imageThumbnail\" title=\"" + image.label + "\"></li>");
|
1391
|
+
html.on('click', function() {
|
1392
|
+
return _this.options.imageWidget.setCurrent(image);
|
1393
|
+
});
|
1394
|
+
jQuery('img', html).on('mousedown', function(event) {
|
1395
|
+
event.preventDefault();
|
1396
|
+
return _this.options.imageWidget.setCurrent(image);
|
1397
|
+
});
|
1398
|
+
return jQuery('.imageThumbnailContainer ul', this.element).append(html);
|
1399
|
+
},
|
1400
|
+
_showNextPrev: function(results) {
|
1401
|
+
var container,
|
1402
|
+
_this = this;
|
1403
|
+
container = jQuery('imageThumbnailContainer ul', this.element);
|
1404
|
+
container.prepend(jQuery('<div class="pager-prev" style="display:none" />'));
|
1405
|
+
container.append(jQuery('<div class="pager-next" style="display:none" />'));
|
1406
|
+
if (results.offset > 0) {
|
1407
|
+
jQuery('.pager-prev', container).show();
|
1408
|
+
}
|
1409
|
+
if (results.offset < results.total) {
|
1410
|
+
jQuery('.pager-next', container).show();
|
1411
|
+
}
|
1412
|
+
jQuery('.pager-prev', container).click(function(event) {
|
1413
|
+
var offset;
|
1414
|
+
offset = results.offset - _this.options.limit;
|
1415
|
+
return _this.options.searchCallback(query, _this.options.limit, offset, function(results) {
|
1416
|
+
return _this._showResults(results);
|
1417
|
+
});
|
1418
|
+
});
|
1419
|
+
return jQuery('.pager-next', container).click(function(event) {
|
1420
|
+
var offset;
|
1421
|
+
offset = results.offset + _this.options.limit;
|
1422
|
+
return _this.options.searchCallback(query, _this.options.limit, offset, function(results) {
|
1423
|
+
return _this._showResults(results);
|
1424
|
+
});
|
1425
|
+
});
|
1426
|
+
},
|
1427
|
+
_showResults: function(results) {
|
1428
|
+
var image, _i, _len, _ref;
|
1429
|
+
jQuery('.activitySpinner', this.element).hide();
|
1430
|
+
jQuery('.imageThumbnailContainer ul', this.element).empty();
|
1431
|
+
jQuery('.imageThumbnailContainer ul', this.element).show();
|
1432
|
+
_ref = results.assets;
|
1433
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1434
|
+
image = _ref[_i];
|
1435
|
+
this._showResult(image);
|
1436
|
+
}
|
1437
|
+
this.options.imageWidget.setCurrent(results.assets.shift());
|
1438
|
+
return this._showNextPrev(results);
|
1439
|
+
},
|
1440
|
+
_ajaxSearch: function(query, limit, offset, success) {
|
1441
|
+
var searchUrl;
|
1442
|
+
searchUrl = this.searchUrl + '?' + jQuery.param({
|
1443
|
+
q: query,
|
1444
|
+
limit: limit,
|
1445
|
+
offset: offset
|
1446
|
+
});
|
1447
|
+
return jQuery.getJSON(searchUrl, success);
|
1448
|
+
}
|
1449
|
+
});
|
1450
|
+
})(jQuery);
|
1451
|
+
|
1452
|
+
(function(jQuery) {
|
1453
|
+
return jQuery.widget('IKS.halloimageupload', {
|
1454
|
+
options: {
|
1455
|
+
uploadCallback: null,
|
1456
|
+
uploadUrl: null,
|
1457
|
+
imageWidget: null,
|
1458
|
+
entity: null
|
1459
|
+
},
|
1460
|
+
_create: function() {
|
1461
|
+
return this.element.html('\
|
1462
|
+
<form class="upload">\
|
1463
|
+
<input type="file" class="file" name="userfile" accept="image/*" />\
|
1464
|
+
<input type="hidden" name="tags" value="" />\
|
1465
|
+
<input type="text" class="caption" name="caption" placeholder="Title" />\
|
1466
|
+
<button class="uploadSubmit">Upload</button>\
|
1467
|
+
</form>\
|
1468
|
+
');
|
1469
|
+
},
|
1470
|
+
_init: function() {
|
1471
|
+
var widget;
|
1472
|
+
widget = this;
|
1473
|
+
if (widget.options.uploadUrl && !widget.options.uploadCallback) {
|
1474
|
+
widget.options.uploadCallback = widget._iframeUpload;
|
1475
|
+
}
|
1476
|
+
return jQuery('.uploadSubmit', this.element).on('click', function(event) {
|
1477
|
+
event.preventDefault();
|
1478
|
+
event.stopPropagation();
|
1479
|
+
return widget.options.uploadCallback({
|
1480
|
+
widget: widget,
|
1481
|
+
success: function(url) {
|
1482
|
+
return widget.options.imageWidget.setCurrent({
|
1483
|
+
url: url,
|
1484
|
+
label: ''
|
1485
|
+
});
|
1486
|
+
}
|
1487
|
+
});
|
1488
|
+
});
|
1489
|
+
},
|
1490
|
+
_prepareIframe: function(widget) {
|
1491
|
+
var iframe, iframeName;
|
1492
|
+
iframeName = "" + widget.widgetName + "_postframe_" + widget.options.uuid;
|
1493
|
+
iframeName = iframeName.replace(/-/g, '_');
|
1494
|
+
iframe = jQuery("#" + iframeName);
|
1495
|
+
if (iframe.length) {
|
1496
|
+
return iframe;
|
1497
|
+
}
|
1498
|
+
iframe = jQuery("<iframe name=\"" + iframeName + "\" id=\"" + iframeName + "\" class=\"hidden\" style=\"display:none\" />");
|
1499
|
+
this.element.append(iframe);
|
1500
|
+
iframe.get(0).name = iframeName;
|
1501
|
+
return iframe;
|
1502
|
+
},
|
1503
|
+
_iframeUpload: function(data) {
|
1504
|
+
var iframe, uploadForm, uploadUrl, widget;
|
1505
|
+
widget = data.widget;
|
1506
|
+
iframe = widget._prepareIframe(widget);
|
1507
|
+
uploadForm = jQuery('form.upload', widget.element);
|
1508
|
+
if (typeof widget.options.uploadUrl === 'function') {
|
1509
|
+
uploadUrl = widget.options.uploadUrl(widget.options.entity);
|
1510
|
+
} else {
|
1511
|
+
uploadUrl = widget.options.uploadUrl;
|
1512
|
+
}
|
1513
|
+
iframe.on('load', function() {
|
1514
|
+
var imageUrl;
|
1515
|
+
imageUrl = iframe.get(0).contentWindow.location.href;
|
1516
|
+
widget.element.hide();
|
1517
|
+
return data.success(imageUrl);
|
1518
|
+
});
|
1519
|
+
uploadForm.attr('action', uploadUrl);
|
1520
|
+
uploadForm.attr('method', 'post');
|
1521
|
+
uploadForm.attr('target', iframe.get(0).name);
|
1522
|
+
uploadForm.attr('enctype', 'multipart/form-data');
|
1523
|
+
uploadForm.attr('encoding', 'multipart/form-data');
|
1524
|
+
return uploadForm.submit();
|
1525
|
+
}
|
1526
|
+
});
|
1527
|
+
})(jQuery);
|
1528
|
+
|
1529
|
+
(function(jQuery) {
|
1530
|
+
return jQuery.widget('IKS.halloimagesuggestions', {
|
1531
|
+
loaded: false,
|
1532
|
+
options: {
|
1533
|
+
entity: null,
|
1534
|
+
vie: null,
|
1535
|
+
dbPediaUrl: null,
|
1536
|
+
getSuggestions: null,
|
1537
|
+
thumbnailUri: '<http://dbpedia.org/ontology/thumbnail>'
|
1538
|
+
},
|
1539
|
+
_create: function() {
|
1540
|
+
return this.element.html('\
|
1541
|
+
<div id="' + this.options.uuid + '-tab-suggestions">\
|
1542
|
+
<div class="imageThumbnailContainer">\
|
1543
|
+
<div class="activitySpinner">Loading images...</div>\
|
1544
|
+
<ul></ul>\
|
1545
|
+
</div>\
|
1546
|
+
</div>');
|
1547
|
+
},
|
1548
|
+
_init: function() {
|
1549
|
+
return jQuery('.activitySpinner', this.element).hide();
|
1550
|
+
},
|
1551
|
+
_normalizeRelated: function(related) {
|
1552
|
+
if (_.isString(related)) {
|
1553
|
+
return related;
|
1554
|
+
}
|
1555
|
+
if (_.isArray(related)) {
|
1556
|
+
return related.join(',');
|
1557
|
+
}
|
1558
|
+
return related.pluck('@subject').join(',');
|
1559
|
+
},
|
1560
|
+
_prepareVIE: function() {
|
1561
|
+
if (!this.options.vie) {
|
1562
|
+
this.options.vie = new VIE;
|
1563
|
+
}
|
1564
|
+
if (this.options.vie.services.dbpedia) {
|
1565
|
+
return;
|
1566
|
+
}
|
1567
|
+
if (!this.options.dbPediaUrl) {
|
1568
|
+
return;
|
1569
|
+
}
|
1570
|
+
return this.options.vie.use(new vie.DBPediaService({
|
1571
|
+
url: this.options.dbPediaUrl,
|
1572
|
+
proxyDisabled: true
|
1573
|
+
}));
|
1574
|
+
},
|
1575
|
+
_getSuggestions: function() {
|
1576
|
+
var limit, normalizedTags, tags;
|
1577
|
+
if (this.loaded) {
|
1578
|
+
return;
|
1579
|
+
}
|
1580
|
+
if (!this.options.entity) {
|
1581
|
+
return;
|
1582
|
+
}
|
1583
|
+
jQuery('.activitySpinner', this.element).show();
|
1584
|
+
tags = this.options.entity.get('skos:related');
|
1585
|
+
if (tags.length === 0) {
|
1586
|
+
jQuery("#activitySpinner").html('No images found.');
|
1587
|
+
return;
|
1588
|
+
}
|
1589
|
+
jQuery('.imageThumbnailContainer ul', this.element).empty();
|
1590
|
+
normalizedTags = this._normalizeRelated(tags);
|
1591
|
+
limit = this.options.limit;
|
1592
|
+
if (this.options.getSuggestions) {
|
1593
|
+
this.options.getSuggestions(normalizedTags, limit, 0, this._showSuggestions);
|
1594
|
+
}
|
1595
|
+
this._prepareVIE();
|
1596
|
+
if (this.options.vie.services.dbpedia) {
|
1597
|
+
this._getSuggestionsDbPedia(tags);
|
1598
|
+
}
|
1599
|
+
return this.loaded = true;
|
1600
|
+
},
|
1601
|
+
_getSuggestionsDbPedia: function(tags) {
|
1602
|
+
var thumbId, widget;
|
1603
|
+
widget = this;
|
1604
|
+
thumbId = 1;
|
1605
|
+
return _.each(tags, function(tag) {
|
1606
|
+
return vie.load({
|
1607
|
+
entity: tag
|
1608
|
+
}).using('dbpedia').execute().done(function(entities) {
|
1609
|
+
jQuery('.activitySpinner', this.element).hide();
|
1610
|
+
return _.each(entities, function(entity) {
|
1611
|
+
var img, thumbnail;
|
1612
|
+
thumbnail = entity.attributes[widget.options.thumbnailUri];
|
1613
|
+
if (!thumbnail) {
|
1614
|
+
return;
|
1615
|
+
}
|
1616
|
+
if (_.isObject(thumbnail)) {
|
1617
|
+
img = thumbnail[0].value;
|
1618
|
+
}
|
1619
|
+
if (_.isString(thumbnail)) {
|
1620
|
+
img = widget.options.entity.fromReference(thumbnail);
|
1621
|
+
}
|
1622
|
+
return widget._showSuggestion({
|
1623
|
+
url: img,
|
1624
|
+
label: tag
|
1625
|
+
});
|
1626
|
+
});
|
1627
|
+
});
|
1628
|
+
});
|
1629
|
+
},
|
1630
|
+
_showSuggestion: function(image) {
|
1631
|
+
var html,
|
1632
|
+
_this = this;
|
1633
|
+
html = jQuery("<li> <img src=\"" + image.url + "\" class=\"imageThumbnail\" title=\"" + image.label + "\"> </li>");
|
1634
|
+
html.on('click', function() {
|
1635
|
+
return _this.options.imageWidget.setCurrent(image);
|
1636
|
+
});
|
1637
|
+
return jQuery('.imageThumbnailContainer ul', this.element).append(html);
|
1638
|
+
},
|
1639
|
+
_showSuggestions: function(suggestions) {
|
1640
|
+
var _this = this;
|
1641
|
+
jQuery('.activitySpinner', this.element).hide();
|
1642
|
+
return _.each(suggestions, function(image) {
|
1643
|
+
return _this._showSuggestion(image);
|
1644
|
+
});
|
1645
|
+
}
|
1646
|
+
});
|
1647
|
+
})(jQuery);
|
1648
|
+
|
1649
|
+
(function(jQuery) {
|
1650
|
+
return jQuery.widget('IKS.halloimagecurrent', {
|
1651
|
+
options: {
|
1652
|
+
imageWidget: null,
|
1653
|
+
startPlace: '',
|
1654
|
+
draggables: [],
|
1655
|
+
maxWidth: 400,
|
1656
|
+
maxHeight: 200
|
1657
|
+
},
|
1658
|
+
_create: function() {
|
1659
|
+
this.element.html('<div>\
|
1660
|
+
<div class="activeImageContainer">\
|
1661
|
+
<div class="rotationWrapper">\
|
1662
|
+
<div class="hintArrow"></div>\
|
1663
|
+
<img src="" class="activeImage" />\
|
1664
|
+
</div>\
|
1665
|
+
<img src="" class="activeImage activeImageBg" />\
|
1666
|
+
</div>\
|
1667
|
+
</div>');
|
1668
|
+
this.element.hide();
|
1669
|
+
return this._prepareDnD();
|
1670
|
+
},
|
1671
|
+
_init: function() {
|
1672
|
+
var editable, widget;
|
1673
|
+
editable = jQuery(this.options.editable.element);
|
1674
|
+
widget = this;
|
1675
|
+
jQuery('img', editable).each(function(index, elem) {
|
1676
|
+
return widget._initDraggable(elem, editable);
|
1677
|
+
});
|
1678
|
+
return jQuery('p', editable).each(function(index, elem) {
|
1679
|
+
if (jQuery(elem).data('jquery_droppable_initialized')) {
|
1680
|
+
return;
|
1681
|
+
}
|
1682
|
+
jQuery(elem).droppable({
|
1683
|
+
tolerance: 'pointer',
|
1684
|
+
drop: function(event, ui) {
|
1685
|
+
return widget._handleDropEvent(event, ui);
|
1686
|
+
},
|
1687
|
+
over: function(event, ui) {
|
1688
|
+
return widget._handleOverEvent(event, ui);
|
1689
|
+
},
|
1690
|
+
out: function(event, ui) {
|
1691
|
+
return widget._handleLeaveEvent(event, ui);
|
1692
|
+
}
|
1693
|
+
});
|
1694
|
+
return jQuery(elem).data('jquery_droppable_initialized', true);
|
1695
|
+
});
|
1696
|
+
},
|
1697
|
+
_prepareDnD: function() {
|
1698
|
+
var editable, overlayMiddleConfig, widget;
|
1699
|
+
widget = this;
|
1700
|
+
editable = jQuery(this.options.editable.element);
|
1701
|
+
this.options.offset = editable.offset();
|
1702
|
+
this.options.third = parseFloat(editable.width() / 3);
|
1703
|
+
overlayMiddleConfig = {
|
1704
|
+
width: this.options.third,
|
1705
|
+
height: editable.height()
|
1706
|
+
};
|
1707
|
+
this.overlay = {
|
1708
|
+
big: jQuery("<div/>").addClass("bigOverlay").css({
|
1709
|
+
width: this.options.third * 2,
|
1710
|
+
height: editable.height()
|
1711
|
+
}),
|
1712
|
+
left: jQuery("<div/>").addClass("smallOverlay smallOverlayLeft"),
|
1713
|
+
right: jQuery("<div/>").addClass("smallOverlay smallOverlayRight")
|
1714
|
+
};
|
1715
|
+
this.overlay.left.css(overlayMiddleConfig);
|
1716
|
+
this.overlay.right.css(overlayMiddleConfig).css("left", this.options.third * 2);
|
1717
|
+
editable.on('halloactivated', function() {
|
1718
|
+
return widget._enableDragging();
|
1719
|
+
});
|
1720
|
+
return editable.on('hallodeactivated', function() {
|
1721
|
+
return widget._disableDragging();
|
1722
|
+
});
|
1723
|
+
},
|
1724
|
+
setImage: function(image) {
|
1725
|
+
if (!image) {
|
1726
|
+
return;
|
1727
|
+
}
|
1728
|
+
this.element.show();
|
1729
|
+
jQuery('.activeImage', this.element).attr('src', image.url);
|
1730
|
+
if (image.label) {
|
1731
|
+
jQuery('input', this.element).val(image.label);
|
1732
|
+
}
|
1733
|
+
return this._initImage(jQuery(this.options.editable.element));
|
1734
|
+
},
|
1735
|
+
_delayAction: function(functionToCall, delay) {
|
1736
|
+
var timer;
|
1737
|
+
timer = clearTimeout(timer);
|
1738
|
+
if (!timer) {
|
1739
|
+
return timer = setTimeout(functionToCall, delay);
|
1740
|
+
}
|
1741
|
+
},
|
1742
|
+
_calcDropPosition: function(offset, event) {
|
1743
|
+
var position, rightTreshold;
|
1744
|
+
position = offset.left + this.options.third;
|
1745
|
+
rightTreshold = offset.left + this.options.third * 2;
|
1746
|
+
if (event.pageX >= position && event.pageX <= rightTreshold) {
|
1747
|
+
return 'middle';
|
1748
|
+
} else if (event.pageX < position) {
|
1749
|
+
return 'left';
|
1750
|
+
} else if (event.pageX > rightTreshold) {
|
1751
|
+
return 'right';
|
1752
|
+
}
|
1753
|
+
},
|
1754
|
+
_createInsertElement: function(image, tmp) {
|
1755
|
+
var imageInsert, tmpImg;
|
1756
|
+
imageInsert = jQuery('<img>');
|
1757
|
+
tmpImg = new Image();
|
1758
|
+
jQuery(tmpImg).on('load', function() {});
|
1759
|
+
tmpImg.src = image.src;
|
1760
|
+
imageInsert.attr({
|
1761
|
+
src: tmpImg.src,
|
1762
|
+
alt: !tmp ? jQuery(image).attr('alt') : void 0,
|
1763
|
+
"class": tmp ? 'halloTmp' : 'imageInText'
|
1764
|
+
});
|
1765
|
+
imageInsert.show();
|
1766
|
+
return imageInsert;
|
1767
|
+
},
|
1768
|
+
_createLineFeedbackElement: function() {
|
1769
|
+
return jQuery('<div/>').addClass('halloTmpLine');
|
1770
|
+
},
|
1771
|
+
_removeFeedbackElements: function() {
|
1772
|
+
this.overlay.big.remove();
|
1773
|
+
this.overlay.left.remove();
|
1774
|
+
this.overlay.right.remove();
|
1775
|
+
return jQuery('.halloTmp, .halloTmpLine', this.options.editable.element).remove();
|
1776
|
+
},
|
1777
|
+
_removeCustomHelper: function() {
|
1778
|
+
return jQuery('.customHelper').remove();
|
1779
|
+
},
|
1780
|
+
_showOverlay: function(position) {
|
1781
|
+
var eHeight, editable;
|
1782
|
+
editable = jQuery(this.options.editable.element);
|
1783
|
+
eHeight = editable.height();
|
1784
|
+
eHeight += parseFloat(editable.css('paddingTop'));
|
1785
|
+
eHeight += parseFloat(editable.css('paddingBottom'));
|
1786
|
+
this.overlay.big.css({
|
1787
|
+
height: eHeight
|
1788
|
+
});
|
1789
|
+
this.overlay.left.css({
|
1790
|
+
height: eHeight
|
1791
|
+
});
|
1792
|
+
this.overlay.right.css({
|
1793
|
+
height: eHeight
|
1794
|
+
});
|
1795
|
+
switch (position) {
|
1796
|
+
case 'left':
|
1797
|
+
this.overlay.big.addClass("bigOverlayLeft");
|
1798
|
+
this.overlay.big.removeClass("bigOverlayRight");
|
1799
|
+
this.overlay.big.css({
|
1800
|
+
left: this.options.third
|
1801
|
+
});
|
1802
|
+
this.overlay.big.show();
|
1803
|
+
this.overlay.left.hide();
|
1804
|
+
return this.overlay.right.hide();
|
1805
|
+
case 'middle':
|
1806
|
+
this.overlay.big.removeClass("bigOverlayLeft bigOverlayRight");
|
1807
|
+
this.overlay.big.hide();
|
1808
|
+
this.overlay.left.show();
|
1809
|
+
return this.overlay.right.show();
|
1810
|
+
case 'right':
|
1811
|
+
this.overlay.big.addClass("bigOverlayRight");
|
1812
|
+
this.overlay.big.removeClass("bigOverlayLeft");
|
1813
|
+
this.overlay.big.css({
|
1814
|
+
left: 0
|
1815
|
+
});
|
1816
|
+
this.overlay.big.show();
|
1817
|
+
this.overlay.left.hide();
|
1818
|
+
return this.overlay.right.hide();
|
1819
|
+
}
|
1820
|
+
},
|
1821
|
+
_checkOrigin: function(event) {
|
1822
|
+
if (jQuery(event.target).parents("[contenteditable]").length !== 0) {
|
1823
|
+
return true;
|
1824
|
+
}
|
1825
|
+
return false;
|
1826
|
+
},
|
1827
|
+
_createFeedback: function(image, position) {
|
1828
|
+
var el;
|
1829
|
+
if (position === 'middle') {
|
1830
|
+
return this._createLineFeedbackElement();
|
1831
|
+
}
|
1832
|
+
el = this._createInsertElement(image, true);
|
1833
|
+
return el.addClass("inlineImage-" + position);
|
1834
|
+
},
|
1835
|
+
_handleOverEvent: function(event, ui) {
|
1836
|
+
var editable, postPone, widget;
|
1837
|
+
widget = this;
|
1838
|
+
editable = jQuery(this.options.editable);
|
1839
|
+
postPone = function() {
|
1840
|
+
var position, target;
|
1841
|
+
window.waitWithTrash = clearTimeout(window.waitWithTrash);
|
1842
|
+
position = widget._calcDropPosition(widget.options.offset, event);
|
1843
|
+
jQuery('.trashcan', ui.helper).remove();
|
1844
|
+
editable[0].element.append(widget.overlay.big);
|
1845
|
+
editable[0].element.append(widget.overlay.left);
|
1846
|
+
editable[0].element.append(widget.overlay.right);
|
1847
|
+
widget._removeFeedbackElements();
|
1848
|
+
target = jQuery(event.target);
|
1849
|
+
target.prepend(widget._createFeedback(ui.draggable[0], position));
|
1850
|
+
if (position === 'middle') {
|
1851
|
+
target.prepend(widget._createFeedback(ui.draggable[0], 'right'));
|
1852
|
+
jQuery('.halloTmp', event.target).hide();
|
1853
|
+
} else {
|
1854
|
+
target.prepend(widget._createFeedback(ui.draggable[0], 'middle'));
|
1855
|
+
jQuery('.halloTmpLine', event.target).hide();
|
1856
|
+
}
|
1857
|
+
return widget._showOverlay(position);
|
1858
|
+
};
|
1859
|
+
return setTimeout(postPone, 5);
|
1860
|
+
},
|
1861
|
+
_handleDragEvent: function(event, ui) {
|
1862
|
+
var position, tmpFeedbackLR, tmpFeedbackMiddle;
|
1863
|
+
position = this._calcDropPosition(this.options.offset, event);
|
1864
|
+
if (position === this._lastPositionDrag) {
|
1865
|
+
return;
|
1866
|
+
}
|
1867
|
+
this._lastPositionDrag = position;
|
1868
|
+
tmpFeedbackLR = jQuery('.halloTmp', this.options.editable.element);
|
1869
|
+
tmpFeedbackMiddle = jQuery('.halloTmpLine', this.options.editable.element);
|
1870
|
+
if (position === 'middle') {
|
1871
|
+
tmpFeedbackMiddle.show();
|
1872
|
+
tmpFeedbackLR.hide();
|
1873
|
+
} else {
|
1874
|
+
tmpFeedbackMiddle.hide();
|
1875
|
+
tmpFeedbackLR.removeClass('inlineImage-left inlineImage-right');
|
1876
|
+
tmpFeedbackLR.addClass("inlineImage-" + position);
|
1877
|
+
tmpFeedbackLR.show();
|
1878
|
+
}
|
1879
|
+
return this._showOverlay(position);
|
1880
|
+
},
|
1881
|
+
_handleLeaveEvent: function(event, ui) {
|
1882
|
+
var func;
|
1883
|
+
func = function() {
|
1884
|
+
if (!jQuery('div.trashcan', ui.helper).length) {
|
1885
|
+
jQuery(ui.helper).append(jQuery('<div class="trashcan"></div>'));
|
1886
|
+
return jQuery('.bigOverlay, .smallOverlay').remove();
|
1887
|
+
}
|
1888
|
+
};
|
1889
|
+
window.waitWithTrash = setTimeout(func, 200);
|
1890
|
+
return this._removeFeedbackElements();
|
1891
|
+
},
|
1892
|
+
_handleStartEvent: function(event, ui) {
|
1893
|
+
var internalDrop;
|
1894
|
+
internalDrop = this._checkOrigin(event);
|
1895
|
+
if (internalDrop) {
|
1896
|
+
jQuery(event.target).remove();
|
1897
|
+
}
|
1898
|
+
jQuery(document).trigger('startPreventSave');
|
1899
|
+
return this.options.startPlace = jQuery(event.target);
|
1900
|
+
},
|
1901
|
+
_handleStopEvent: function(event, ui) {
|
1902
|
+
var internalDrop;
|
1903
|
+
internalDrop = this._checkOrigin(event);
|
1904
|
+
if (internalDrop) {
|
1905
|
+
jQuery(event.target).remove();
|
1906
|
+
} else {
|
1907
|
+
jQuery(this.options.editable.element).trigger('change');
|
1908
|
+
}
|
1909
|
+
this.overlay.big.hide();
|
1910
|
+
this.overlay.left.hide();
|
1911
|
+
this.overlay.right.hide();
|
1912
|
+
return jQuery(document).trigger('stopPreventSave');
|
1913
|
+
},
|
1914
|
+
_handleDropEvent: function(event, ui) {
|
1915
|
+
var classes, editable, imageInsert, internalDrop, left, position;
|
1916
|
+
editable = jQuery(this.options.editable.element);
|
1917
|
+
internalDrop = this._checkOrigin(event);
|
1918
|
+
position = this._calcDropPosition(this.options.offset, event);
|
1919
|
+
this._removeFeedbackElements();
|
1920
|
+
this._removeCustomHelper();
|
1921
|
+
imageInsert = this._createInsertElement(ui.draggable[0], false);
|
1922
|
+
classes = 'inlineImage-middle inlineImage-left inlineImage-right';
|
1923
|
+
if (position === 'middle') {
|
1924
|
+
imageInsert.show();
|
1925
|
+
imageInsert.removeClass(classes);
|
1926
|
+
left = editable.width();
|
1927
|
+
left += parseFloat(editable.css('paddingLeft'));
|
1928
|
+
left += parseFloat(editable.css('paddingRight'));
|
1929
|
+
left -= imageInsert.attr('width');
|
1930
|
+
imageInsert.addClass("inlineImage-" + position).css({
|
1931
|
+
position: 'relative',
|
1932
|
+
left: left / 2
|
1933
|
+
});
|
1934
|
+
imageInsert.insertBefore(jQuery(event.target));
|
1935
|
+
} else {
|
1936
|
+
imageInsert.removeClass(classes);
|
1937
|
+
imageInsert.addClass("inlineImage-" + position);
|
1938
|
+
imageInsert.css('display', 'block');
|
1939
|
+
jQuery(event.target).prepend(imageInsert);
|
1940
|
+
}
|
1941
|
+
this.overlay.big.hide();
|
1942
|
+
this.overlay.left.hide();
|
1943
|
+
this.overlay.right.hide();
|
1944
|
+
editable.trigger('change');
|
1945
|
+
return this._initImage(editable);
|
1946
|
+
},
|
1947
|
+
_createHelper: function(event) {
|
1948
|
+
return jQuery('<div>').css({
|
1949
|
+
backgroundImage: "url(" + (jQuery(event.currentTarget).attr('src')) + ")"
|
1950
|
+
}).addClass('customHelper').appendTo('body');
|
1951
|
+
},
|
1952
|
+
_initDraggable: function(elem, editable) {
|
1953
|
+
var widget;
|
1954
|
+
widget = this;
|
1955
|
+
if (!elem.jquery_draggable_initialized) {
|
1956
|
+
elem.jquery_draggable_initialized = true;
|
1957
|
+
jQuery(elem).draggable({
|
1958
|
+
cursor: 'move',
|
1959
|
+
helper: function(event) {
|
1960
|
+
return widget._createHelper(event);
|
1961
|
+
},
|
1962
|
+
drag: function(event, ui) {
|
1963
|
+
return widget._handleDragEvent(event, ui);
|
1964
|
+
},
|
1965
|
+
start: function(event, ui) {
|
1966
|
+
return widget._handleStartEvent(event, ui);
|
1967
|
+
},
|
1968
|
+
stop: function(event, ui) {
|
1969
|
+
return widget._handleStopEvent(event, ui);
|
1970
|
+
},
|
1971
|
+
disabled: !editable.hasClass('inEditMode'),
|
1972
|
+
cursorAt: {
|
1973
|
+
top: 50,
|
1974
|
+
left: 50
|
1975
|
+
}
|
1976
|
+
});
|
1977
|
+
}
|
1978
|
+
return widget.options.draggables.push(elem);
|
1979
|
+
},
|
1980
|
+
_initImage: function(editable) {
|
1981
|
+
var widget;
|
1982
|
+
widget = this;
|
1983
|
+
return jQuery('.rotationWrapper img', this.options.dialog).each(function(index, elem) {
|
1984
|
+
return widget._initDraggable(elem, editable);
|
1985
|
+
});
|
1986
|
+
},
|
1987
|
+
_enableDragging: function() {
|
1988
|
+
return jQuery.each(this.options.draggables, function(index, d) {
|
1989
|
+
return jQuery(d).draggable('option', 'disabled', false);
|
1990
|
+
});
|
1991
|
+
},
|
1992
|
+
_disableDragging: function() {
|
1993
|
+
return jQuery.each(this.options.draggables, function(index, d) {
|
1994
|
+
return jQuery(d).draggable('option', 'disabled', true);
|
1995
|
+
});
|
1996
|
+
}
|
1997
|
+
});
|
1998
|
+
})(jQuery);
|
1999
|
+
|
2000
|
+
(function(jQuery) {
|
2001
|
+
return jQuery.widget("IKS.hallojustify", {
|
2002
|
+
options: {
|
2003
|
+
editable: null,
|
2004
|
+
toolbar: null,
|
2005
|
+
uuid: '',
|
2006
|
+
buttonCssClass: null
|
2007
|
+
},
|
2008
|
+
populateToolbar: function(toolbar) {
|
2009
|
+
var buttonize, buttonset,
|
2010
|
+
_this = this;
|
2011
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
2012
|
+
buttonize = function(alignment) {
|
2013
|
+
var buttonElement;
|
2014
|
+
buttonElement = jQuery('<span></span>');
|
2015
|
+
buttonElement.hallobutton({
|
2016
|
+
uuid: _this.options.uuid,
|
2017
|
+
editable: _this.options.editable,
|
2018
|
+
label: alignment,
|
2019
|
+
command: "justify" + alignment,
|
2020
|
+
icon: "icon-align-" + (alignment.toLowerCase()),
|
2021
|
+
cssClass: _this.options.buttonCssClass
|
2022
|
+
});
|
2023
|
+
return buttonset.append(buttonElement);
|
2024
|
+
};
|
2025
|
+
buttonize("Left");
|
2026
|
+
buttonize("Center");
|
2027
|
+
buttonize("Right");
|
2028
|
+
buttonset.hallobuttonset();
|
2029
|
+
return toolbar.append(buttonset);
|
2030
|
+
}
|
2031
|
+
});
|
2032
|
+
})(jQuery);
|
2033
|
+
|
2034
|
+
(function(jQuery) {
|
2035
|
+
return jQuery.widget('IKS.halloblacklist', {
|
2036
|
+
options: {
|
2037
|
+
tags: []
|
2038
|
+
},
|
2039
|
+
_init: function() {
|
2040
|
+
if (this.options.tags.indexOf('br') !== -1) {
|
2041
|
+
return this.element.on('keydown', function(event) {
|
2042
|
+
if (event.originalEvent.keyCode === 13) {
|
2043
|
+
return event.preventDefault();
|
2044
|
+
}
|
2045
|
+
});
|
2046
|
+
}
|
2047
|
+
},
|
2048
|
+
cleanupContentClone: function(el) {
|
2049
|
+
var tag, _i, _len, _ref, _results;
|
2050
|
+
_ref = this.options.tags;
|
2051
|
+
_results = [];
|
2052
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2053
|
+
tag = _ref[_i];
|
2054
|
+
_results.push(jQuery(tag, el).remove());
|
2055
|
+
}
|
2056
|
+
return _results;
|
2057
|
+
}
|
2058
|
+
});
|
2059
|
+
})(jQuery);
|
2060
|
+
|
2061
|
+
(function(jQuery) {
|
2062
|
+
return jQuery.widget("Liip.hallotoolbarlinebreak", {
|
2063
|
+
options: {
|
2064
|
+
editable: null,
|
2065
|
+
uuid: "",
|
2066
|
+
breakAfter: []
|
2067
|
+
},
|
2068
|
+
populateToolbar: function(toolbar) {
|
2069
|
+
var buttonRow, buttonset, buttonsets, queuedButtonsets, row, rowcounter, _i, _j, _len, _len1, _ref;
|
2070
|
+
buttonsets = jQuery('.ui-buttonset', toolbar);
|
2071
|
+
queuedButtonsets = jQuery();
|
2072
|
+
rowcounter = 0;
|
2073
|
+
_ref = this.options.breakAfter;
|
2074
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2075
|
+
row = _ref[_i];
|
2076
|
+
rowcounter++;
|
2077
|
+
buttonRow = "<div class=\"halloButtonrow halloButtonrow-" + rowcounter + "\" />";
|
2078
|
+
for (_j = 0, _len1 = buttonsets.length; _j < _len1; _j++) {
|
2079
|
+
buttonset = buttonsets[_j];
|
2080
|
+
queuedButtonsets = jQuery(queuedButtonsets).add(jQuery(buttonset));
|
2081
|
+
if (jQuery(buttonset).hasClass(row)) {
|
2082
|
+
queuedButtonsets.wrapAll(buttonRow);
|
2083
|
+
buttonsets = buttonsets.not(queuedButtonsets);
|
2084
|
+
queuedButtonsets = jQuery();
|
2085
|
+
break;
|
2086
|
+
}
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
if (buttonsets.length > 0) {
|
2090
|
+
rowcounter++;
|
2091
|
+
buttonRow = "<div class=\"halloButtonrow halloButtonrow-" + rowcounter + "\" />";
|
2092
|
+
return buttonsets.wrapAll(buttonRow);
|
2093
|
+
}
|
2094
|
+
}
|
2095
|
+
});
|
2096
|
+
})(jQuery);
|
2097
|
+
|
2098
|
+
(function(jQuery) {
|
2099
|
+
jQuery.widget('IKS.hallobutton', {
|
2100
|
+
button: null,
|
2101
|
+
isChecked: false,
|
2102
|
+
options: {
|
2103
|
+
uuid: '',
|
2104
|
+
label: null,
|
2105
|
+
icon: null,
|
2106
|
+
editable: null,
|
2107
|
+
command: null,
|
2108
|
+
commandValue: null,
|
2109
|
+
queryState: true,
|
2110
|
+
cssClass: null
|
2111
|
+
},
|
2112
|
+
_create: function() {
|
2113
|
+
var hoverclass, id, opts, _base, _ref,
|
2114
|
+
_this = this;
|
2115
|
+
if ((_ref = (_base = this.options).icon) == null) {
|
2116
|
+
_base.icon = "icon-" + (this.options.label.toLowerCase());
|
2117
|
+
}
|
2118
|
+
id = "" + this.options.uuid + "-" + this.options.label;
|
2119
|
+
opts = this.options;
|
2120
|
+
this.button = this._createButton(id, opts.command, opts.label, opts.icon);
|
2121
|
+
this.element.append(this.button);
|
2122
|
+
if (this.options.cssClass) {
|
2123
|
+
this.button.addClass(this.options.cssClass);
|
2124
|
+
}
|
2125
|
+
if (this.options.editable.options.touchScreen) {
|
2126
|
+
this.button.addClass('btn-large');
|
2127
|
+
}
|
2128
|
+
this.button.data('hallo-command', this.options.command);
|
2129
|
+
if (this.options.commandValue) {
|
2130
|
+
this.button.data('hallo-command-value', this.options.commandValue);
|
2131
|
+
}
|
2132
|
+
hoverclass = 'ui-state-hover';
|
2133
|
+
this.button.on('mouseenter', function(event) {
|
2134
|
+
if (_this.isEnabled()) {
|
2135
|
+
return _this.button.addClass(hoverclass);
|
2136
|
+
}
|
2137
|
+
});
|
2138
|
+
return this.button.on('mouseleave', function(event) {
|
2139
|
+
return _this.button.removeClass(hoverclass);
|
2140
|
+
});
|
2141
|
+
},
|
2142
|
+
_init: function() {
|
2143
|
+
var editableElement, events, queryState,
|
2144
|
+
_this = this;
|
2145
|
+
if (!this.button) {
|
2146
|
+
this.button = this._prepareButton();
|
2147
|
+
}
|
2148
|
+
this.element.append(this.button);
|
2149
|
+
if (this.options.queryState === true) {
|
2150
|
+
queryState = function(event) {
|
2151
|
+
var compared, value;
|
2152
|
+
if (!_this.options.command) {
|
2153
|
+
return;
|
2154
|
+
}
|
2155
|
+
try {
|
2156
|
+
if (_this.options.commandValue) {
|
2157
|
+
value = document.queryCommandValue(_this.options.command);
|
2158
|
+
compared = value.match(new RegExp(_this.options.commandValue, "i"));
|
2159
|
+
return _this.checked(compared ? true : false);
|
2160
|
+
} else {
|
2161
|
+
return _this.checked(document.queryCommandState(_this.options.command));
|
2162
|
+
}
|
2163
|
+
} catch (e) {
|
2164
|
+
|
2165
|
+
}
|
2166
|
+
};
|
2167
|
+
} else {
|
2168
|
+
queryState = this.options.queryState;
|
2169
|
+
}
|
2170
|
+
if (this.options.command) {
|
2171
|
+
this.button.on('click', function(event) {
|
2172
|
+
if (_this.options.commandValue) {
|
2173
|
+
_this.options.editable.execute(_this.options.command, _this.options.commandValue);
|
2174
|
+
} else {
|
2175
|
+
_this.options.editable.execute(_this.options.command);
|
2176
|
+
}
|
2177
|
+
queryState();
|
2178
|
+
return false;
|
2179
|
+
});
|
2180
|
+
}
|
2181
|
+
if (!this.options.queryState) {
|
2182
|
+
return;
|
2183
|
+
}
|
2184
|
+
editableElement = this.options.editable.element;
|
2185
|
+
events = 'keyup paste change mouseup hallomodified';
|
2186
|
+
editableElement.on(events, queryState);
|
2187
|
+
editableElement.on('halloenabled', function() {
|
2188
|
+
return editableElement.on(events, queryState);
|
2189
|
+
});
|
2190
|
+
return editableElement.on('hallodisabled', function() {
|
2191
|
+
return editableElement.off(events, queryState);
|
2192
|
+
});
|
2193
|
+
},
|
2194
|
+
enable: function() {
|
2195
|
+
return this.button.removeAttr('disabled');
|
2196
|
+
},
|
2197
|
+
disable: function() {
|
2198
|
+
return this.button.attr('disabled', 'true');
|
2199
|
+
},
|
2200
|
+
isEnabled: function() {
|
2201
|
+
return this.button.attr('disabled') !== 'true';
|
2202
|
+
},
|
2203
|
+
refresh: function() {
|
2204
|
+
if (this.isChecked) {
|
2205
|
+
return this.button.addClass('ui-state-active');
|
2206
|
+
} else {
|
2207
|
+
return this.button.removeClass('ui-state-active');
|
2208
|
+
}
|
2209
|
+
},
|
2210
|
+
checked: function(checked) {
|
2211
|
+
this.isChecked = checked;
|
2212
|
+
return this.refresh();
|
2213
|
+
},
|
2214
|
+
_createButton: function(id, command, label, icon) {
|
2215
|
+
var classes;
|
2216
|
+
classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only', "" + command + "_button"];
|
2217
|
+
return jQuery("<button id=\"" + id + "\" class=\"" + (classes.join(' ')) + "\" title=\"" + label + "\"> <span class=\"ui-button-text\"> <i class=\"" + icon + "\"></i> </span> </button>");
|
2218
|
+
}
|
2219
|
+
});
|
2220
|
+
return jQuery.widget('IKS.hallobuttonset', {
|
2221
|
+
buttons: null,
|
2222
|
+
_create: function() {
|
2223
|
+
return this.element.addClass('ui-buttonset');
|
2224
|
+
},
|
2225
|
+
_init: function() {
|
2226
|
+
return this.refresh();
|
2227
|
+
},
|
2228
|
+
refresh: function() {
|
2229
|
+
var rtl;
|
2230
|
+
rtl = this.element.css('direction') === 'rtl';
|
2231
|
+
this.buttons = this.element.find('.ui-button');
|
2232
|
+
this.buttons.removeClass('ui-corner-all ui-corner-left ui-corner-right');
|
2233
|
+
if (rtl) {
|
2234
|
+
this.buttons.filter(':first').addClass('ui-corner-right');
|
2235
|
+
return this.buttons.filter(':last').addClass('ui-corner-left');
|
2236
|
+
} else {
|
2237
|
+
this.buttons.filter(':first').addClass('ui-corner-left');
|
2238
|
+
return this.buttons.filter(':last').addClass('ui-corner-right');
|
2239
|
+
}
|
2240
|
+
}
|
2241
|
+
});
|
2242
|
+
})(jQuery);
|
2243
|
+
|
2244
|
+
(function(jQuery) {
|
2245
|
+
return jQuery.widget('IKS.hallodropdownbutton', {
|
2246
|
+
button: null,
|
2247
|
+
options: {
|
2248
|
+
uuid: '',
|
2249
|
+
label: null,
|
2250
|
+
icon: null,
|
2251
|
+
editable: null,
|
2252
|
+
target: '',
|
2253
|
+
cssClass: null
|
2254
|
+
},
|
2255
|
+
_create: function() {
|
2256
|
+
var _base, _ref;
|
2257
|
+
return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "icon-" + (this.options.label.toLowerCase());
|
2258
|
+
},
|
2259
|
+
_init: function() {
|
2260
|
+
var target,
|
2261
|
+
_this = this;
|
2262
|
+
target = jQuery(this.options.target);
|
2263
|
+
target.css('position', 'absolute');
|
2264
|
+
target.addClass('dropdown-menu');
|
2265
|
+
target.hide();
|
2266
|
+
if (!this.button) {
|
2267
|
+
this.button = this._prepareButton();
|
2268
|
+
}
|
2269
|
+
this.button.on('click', function() {
|
2270
|
+
if (target.hasClass('open')) {
|
2271
|
+
_this._hideTarget();
|
2272
|
+
return;
|
2273
|
+
}
|
2274
|
+
return _this._showTarget();
|
2275
|
+
});
|
2276
|
+
target.on('click', function() {
|
2277
|
+
return _this._hideTarget();
|
2278
|
+
});
|
2279
|
+
this.options.editable.element.on('hallodeactivated', function() {
|
2280
|
+
return _this._hideTarget();
|
2281
|
+
});
|
2282
|
+
return this.element.append(this.button);
|
2283
|
+
},
|
2284
|
+
_showTarget: function() {
|
2285
|
+
var target;
|
2286
|
+
target = jQuery(this.options.target);
|
2287
|
+
this._updateTargetPosition();
|
2288
|
+
target.addClass('open');
|
2289
|
+
return target.show();
|
2290
|
+
},
|
2291
|
+
_hideTarget: function() {
|
2292
|
+
var target;
|
2293
|
+
target = jQuery(this.options.target);
|
2294
|
+
target.removeClass('open');
|
2295
|
+
return target.hide();
|
2296
|
+
},
|
2297
|
+
_updateTargetPosition: function() {
|
2298
|
+
var left, target, top, _ref;
|
2299
|
+
target = jQuery(this.options.target);
|
2300
|
+
_ref = this.button.position(), top = _ref.top, left = _ref.left;
|
2301
|
+
top += this.button.outerHeight();
|
2302
|
+
target.css('top', top);
|
2303
|
+
return target.css('left', left - 20);
|
2304
|
+
},
|
2305
|
+
_prepareButton: function() {
|
2306
|
+
var buttonEl, classes, id;
|
2307
|
+
id = "" + this.options.uuid + "-" + this.options.label;
|
2308
|
+
classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only'];
|
2309
|
+
buttonEl = jQuery("<button id=\"" + id + "\" class=\"" + (classes.join(' ')) + "\" title=\"" + this.options.label + "\"> <span class=\"ui-button-text\"><i class=\"" + this.options.icon + "\"></i></span> </button>");
|
2310
|
+
if (this.options.cssClass) {
|
2311
|
+
buttonEl.addClass(this.options.cssClass);
|
2312
|
+
}
|
2313
|
+
return buttonEl;
|
2314
|
+
}
|
2315
|
+
});
|
2316
|
+
})(jQuery);
|
2317
|
+
|
2318
|
+
(function(jQuery) {
|
2319
|
+
return jQuery.widget('IKS.halloToolbarFixed', {
|
2320
|
+
toolbar: null,
|
2321
|
+
options: {
|
2322
|
+
parentElement: 'body',
|
2323
|
+
editable: null,
|
2324
|
+
toolbar: null,
|
2325
|
+
affix: true,
|
2326
|
+
affixTopOffset: 2
|
2327
|
+
},
|
2328
|
+
_create: function() {
|
2329
|
+
var el, widthToAdd,
|
2330
|
+
_this = this;
|
2331
|
+
this.toolbar = this.options.toolbar;
|
2332
|
+
this.toolbar.show();
|
2333
|
+
jQuery(this.options.parentElement).append(this.toolbar);
|
2334
|
+
this._bindEvents();
|
2335
|
+
jQuery(window).resize(function(event) {
|
2336
|
+
return _this.setPosition();
|
2337
|
+
});
|
2338
|
+
jQuery(window).scroll(function(event) {
|
2339
|
+
return _this.setPosition();
|
2340
|
+
});
|
2341
|
+
if (this.options.parentElement === 'body') {
|
2342
|
+
el = jQuery(this.element);
|
2343
|
+
widthToAdd = parseFloat(el.css('padding-left'));
|
2344
|
+
widthToAdd += parseFloat(el.css('padding-right'));
|
2345
|
+
widthToAdd += parseFloat(el.css('border-left-width'));
|
2346
|
+
widthToAdd += parseFloat(el.css('border-right-width'));
|
2347
|
+
widthToAdd += (parseFloat(el.css('outline-width'))) * 2;
|
2348
|
+
widthToAdd += (parseFloat(el.css('outline-offset'))) * 2;
|
2349
|
+
return jQuery(this.toolbar).css("width", el.width() + widthToAdd);
|
2350
|
+
}
|
2351
|
+
},
|
2352
|
+
_getPosition: function(event, selection) {
|
2353
|
+
var offset, position, width;
|
2354
|
+
if (!event) {
|
2355
|
+
return;
|
2356
|
+
}
|
2357
|
+
width = parseFloat(this.element.css('outline-width'));
|
2358
|
+
offset = width + parseFloat(this.element.css('outline-offset'));
|
2359
|
+
return position = {
|
2360
|
+
top: this.element.offset().top - this.toolbar.outerHeight() - offset,
|
2361
|
+
left: this.element.offset().left - offset
|
2362
|
+
};
|
2363
|
+
},
|
2364
|
+
_getCaretPosition: function(range) {
|
2365
|
+
var newRange, position, tmpSpan;
|
2366
|
+
tmpSpan = jQuery("<span/>");
|
2367
|
+
newRange = rangy.createRange();
|
2368
|
+
newRange.setStart(range.endContainer, range.endOffset);
|
2369
|
+
newRange.insertNode(tmpSpan.get(0));
|
2370
|
+
position = {
|
2371
|
+
top: tmpSpan.offset().top,
|
2372
|
+
left: tmpSpan.offset().left
|
2373
|
+
};
|
2374
|
+
tmpSpan.remove();
|
2375
|
+
return position;
|
2376
|
+
},
|
2377
|
+
setPosition: function() {
|
2378
|
+
var elementBottom, elementTop, height, offset, scrollTop, topOffset;
|
2379
|
+
if (this.options.parentElement !== 'body') {
|
2380
|
+
return;
|
2381
|
+
}
|
2382
|
+
this.toolbar.css('position', 'absolute');
|
2383
|
+
this.toolbar.css('top', this.element.offset().top - this.toolbar.outerHeight());
|
2384
|
+
if (this.options.affix) {
|
2385
|
+
scrollTop = jQuery(window).scrollTop();
|
2386
|
+
offset = this.element.offset();
|
2387
|
+
height = this.element.height();
|
2388
|
+
topOffset = this.options.affixTopOffset;
|
2389
|
+
elementTop = offset.top - (this.toolbar.height() + this.options.affixTopOffset);
|
2390
|
+
elementBottom = (height - topOffset) + (offset.top - this.toolbar.height());
|
2391
|
+
if (scrollTop > elementTop && scrollTop < elementBottom) {
|
2392
|
+
this.toolbar.css('position', 'fixed');
|
2393
|
+
this.toolbar.css('top', this.options.affixTopOffset);
|
2394
|
+
}
|
2395
|
+
} else {
|
2396
|
+
|
2397
|
+
}
|
2398
|
+
return this.toolbar.css('left', this.element.offset().left - 2);
|
2399
|
+
},
|
2400
|
+
_updatePosition: function(position) {},
|
2401
|
+
_bindEvents: function() {
|
2402
|
+
var _this = this;
|
2403
|
+
this.element.on('halloactivated', function(event, data) {
|
2404
|
+
_this.setPosition();
|
2405
|
+
return _this.toolbar.show();
|
2406
|
+
});
|
2407
|
+
return this.element.on('hallodeactivated', function(event, data) {
|
2408
|
+
return _this.toolbar.hide();
|
2409
|
+
});
|
2410
|
+
}
|
2411
|
+
});
|
2412
|
+
})(jQuery);
|
2413
|
+
|
2414
|
+
(function(jQuery) {
|
2415
|
+
return jQuery.widget('IKS.halloToolbarContextual', {
|
2416
|
+
toolbar: null,
|
2417
|
+
options: {
|
2418
|
+
parentElement: 'body',
|
2419
|
+
editable: null,
|
2420
|
+
toolbar: null,
|
2421
|
+
positionAbove: false
|
2422
|
+
},
|
2423
|
+
_create: function() {
|
2424
|
+
var _this = this;
|
2425
|
+
this.toolbar = this.options.toolbar;
|
2426
|
+
jQuery(this.options.parentElement).append(this.toolbar);
|
2427
|
+
this._bindEvents();
|
2428
|
+
return jQuery(window).resize(function(event) {
|
2429
|
+
return _this._updatePosition(_this._getPosition(event));
|
2430
|
+
});
|
2431
|
+
},
|
2432
|
+
_getPosition: function(event, selection) {
|
2433
|
+
var eventType, position;
|
2434
|
+
if (!event) {
|
2435
|
+
return;
|
2436
|
+
}
|
2437
|
+
eventType = event.type;
|
2438
|
+
switch (eventType) {
|
2439
|
+
case 'keydown':
|
2440
|
+
case 'keyup':
|
2441
|
+
case 'keypress':
|
2442
|
+
return this._getCaretPosition(selection);
|
2443
|
+
case 'click':
|
2444
|
+
case 'mousedown':
|
2445
|
+
case 'mouseup':
|
2446
|
+
return position = {
|
2447
|
+
top: event.pageY,
|
2448
|
+
left: event.pageX
|
2449
|
+
};
|
2450
|
+
}
|
2451
|
+
},
|
2452
|
+
_getCaretPosition: function(range) {
|
2453
|
+
var newRange, position, tmpSpan;
|
2454
|
+
tmpSpan = jQuery("<span/>");
|
2455
|
+
newRange = rangy.createRange();
|
2456
|
+
newRange.setStart(range.endContainer, range.endOffset);
|
2457
|
+
newRange.insertNode(tmpSpan.get(0));
|
2458
|
+
position = {
|
2459
|
+
top: tmpSpan.offset().top,
|
2460
|
+
left: tmpSpan.offset().left
|
2461
|
+
};
|
2462
|
+
tmpSpan.remove();
|
2463
|
+
return position;
|
2464
|
+
},
|
2465
|
+
setPosition: function() {
|
2466
|
+
if (this.options.parentElement !== 'body') {
|
2467
|
+
this.options.parentElement = 'body';
|
2468
|
+
jQuery(this.options.parentElement).append(this.toolbar);
|
2469
|
+
}
|
2470
|
+
this.toolbar.css('position', 'absolute');
|
2471
|
+
this.toolbar.css('top', this.element.offset().top - 20);
|
2472
|
+
return this.toolbar.css('left', this.element.offset().left);
|
2473
|
+
},
|
2474
|
+
_updatePosition: function(position, selection) {
|
2475
|
+
var left, selectionRect, toolbar_height_offset, top, top_offset;
|
2476
|
+
if (selection == null) {
|
2477
|
+
selection = null;
|
2478
|
+
}
|
2479
|
+
if (!position) {
|
2480
|
+
return;
|
2481
|
+
}
|
2482
|
+
if (!(position.top && position.left)) {
|
2483
|
+
return;
|
2484
|
+
}
|
2485
|
+
toolbar_height_offset = this.toolbar.outerHeight() + 10;
|
2486
|
+
if (selection && !selection.collapsed && selection.nativeRange) {
|
2487
|
+
selectionRect = selection.nativeRange.getBoundingClientRect();
|
2488
|
+
if (this.options.positionAbove) {
|
2489
|
+
top_offset = selectionRect.top - toolbar_height_offset;
|
2490
|
+
} else {
|
2491
|
+
top_offset = selectionRect.bottom + 10;
|
2492
|
+
}
|
2493
|
+
top = jQuery(window).scrollTop() + top_offset;
|
2494
|
+
left = jQuery(window).scrollLeft() + selectionRect.left;
|
2495
|
+
} else {
|
2496
|
+
if (this.options.positionAbove) {
|
2497
|
+
top_offset = -10 - toolbar_height_offset;
|
2498
|
+
} else {
|
2499
|
+
top_offset = 20;
|
2500
|
+
}
|
2501
|
+
top = position.top + top_offset;
|
2502
|
+
left = position.left - this.toolbar.outerWidth() / 2 + 30;
|
2503
|
+
}
|
2504
|
+
this.toolbar.css('top', top);
|
2505
|
+
return this.toolbar.css('left', left);
|
2506
|
+
},
|
2507
|
+
_bindEvents: function() {
|
2508
|
+
var _this = this;
|
2509
|
+
this.element.on('halloselected', function(event, data) {
|
2510
|
+
var position;
|
2511
|
+
position = _this._getPosition(data.originalEvent, data.selection);
|
2512
|
+
if (!position) {
|
2513
|
+
return;
|
2514
|
+
}
|
2515
|
+
_this._updatePosition(position, data.selection);
|
2516
|
+
if (_this.toolbar.html() !== '') {
|
2517
|
+
return _this.toolbar.show();
|
2518
|
+
}
|
2519
|
+
});
|
2520
|
+
this.element.on('hallounselected', function(event, data) {
|
2521
|
+
return _this.toolbar.hide();
|
2522
|
+
});
|
2523
|
+
return this.element.on('hallodeactivated', function(event, data) {
|
2524
|
+
return _this.toolbar.hide();
|
2525
|
+
});
|
2526
|
+
}
|
2527
|
+
});
|
2528
|
+
})(jQuery);
|
2529
|
+
|
2530
|
+
/*
|
2531
|
+
Hallo 1.0.2 - a rich text editing jQuery UI widget
|
2532
|
+
(c) 2011 Henri Bergius, IKS Consortium
|
2533
|
+
Hallo may be freely distributed under the MIT license
|
2534
|
+
http://hallojs.org
|
2535
|
+
*/
|
2536
|
+
|
2537
|
+
|
2538
|
+
(function(jQuery) {
|
2539
|
+
return jQuery.widget('IKS.hallo', {
|
2540
|
+
toolbar: null,
|
2541
|
+
bound: false,
|
2542
|
+
originalContent: '',
|
2543
|
+
previousContent: '',
|
2544
|
+
uuid: '',
|
2545
|
+
selection: null,
|
2546
|
+
_keepActivated: false,
|
2547
|
+
originalHref: null,
|
2548
|
+
options: {
|
2549
|
+
editable: true,
|
2550
|
+
plugins: {},
|
2551
|
+
toolbar: 'halloToolbarContextual',
|
2552
|
+
parentElement: 'body',
|
2553
|
+
buttonCssClass: null,
|
2554
|
+
toolbarCssClass: null,
|
2555
|
+
toolbarPositionAbove: false,
|
2556
|
+
toolbarOptions: {},
|
2557
|
+
placeholder: '',
|
2558
|
+
forceStructured: true,
|
2559
|
+
checkTouch: true,
|
2560
|
+
touchScreen: null
|
2561
|
+
},
|
2562
|
+
_create: function() {
|
2563
|
+
var options, plugin, _ref,
|
2564
|
+
_this = this;
|
2565
|
+
this.id = this._generateUUID();
|
2566
|
+
if (this.options.checkTouch && this.options.touchScreen === null) {
|
2567
|
+
this.checkTouch();
|
2568
|
+
}
|
2569
|
+
_ref = this.options.plugins;
|
2570
|
+
for (plugin in _ref) {
|
2571
|
+
options = _ref[plugin];
|
2572
|
+
if (!jQuery.isPlainObject(options)) {
|
2573
|
+
options = {};
|
2574
|
+
}
|
2575
|
+
jQuery.extend(options, {
|
2576
|
+
editable: this,
|
2577
|
+
uuid: this.id,
|
2578
|
+
buttonCssClass: this.options.buttonCssClass
|
2579
|
+
});
|
2580
|
+
jQuery(this.element)[plugin](options);
|
2581
|
+
}
|
2582
|
+
this.element.one('halloactivated', function() {
|
2583
|
+
return _this._prepareToolbar();
|
2584
|
+
});
|
2585
|
+
return this.originalContent = this.getContents();
|
2586
|
+
},
|
2587
|
+
_init: function() {
|
2588
|
+
if (this.options.editable) {
|
2589
|
+
return this.enable();
|
2590
|
+
} else {
|
2591
|
+
return this.disable();
|
2592
|
+
}
|
2593
|
+
},
|
2594
|
+
destroy: function() {
|
2595
|
+
var options, plugin, _ref;
|
2596
|
+
this.disable();
|
2597
|
+
if (this.toolbar) {
|
2598
|
+
this.toolbar.remove();
|
2599
|
+
this.element[this.options.toolbar]('destroy');
|
2600
|
+
}
|
2601
|
+
_ref = this.options.plugins;
|
2602
|
+
for (plugin in _ref) {
|
2603
|
+
options = _ref[plugin];
|
2604
|
+
jQuery(this.element)[plugin]('destroy');
|
2605
|
+
}
|
2606
|
+
return jQuery.Widget.prototype.destroy.call(this);
|
2607
|
+
},
|
2608
|
+
disable: function() {
|
2609
|
+
var _this = this;
|
2610
|
+
this.element.attr("contentEditable", false);
|
2611
|
+
this.element.off("focus", this._activated);
|
2612
|
+
this.element.off("blur", this._deactivated);
|
2613
|
+
this.element.off("keyup paste change", this._checkModified);
|
2614
|
+
this.element.off("keyup", this._keys);
|
2615
|
+
this.element.off("keyup mouseup", this._checkSelection);
|
2616
|
+
this.bound = false;
|
2617
|
+
jQuery(this.element).removeClass('isModified');
|
2618
|
+
jQuery(this.element).removeClass('inEditMode');
|
2619
|
+
this.element.parents('a').andSelf().each(function(idx, elem) {
|
2620
|
+
var element;
|
2621
|
+
element = jQuery(elem);
|
2622
|
+
if (!element.is('a')) {
|
2623
|
+
return;
|
2624
|
+
}
|
2625
|
+
if (!_this.originalHref) {
|
2626
|
+
return;
|
2627
|
+
}
|
2628
|
+
return element.attr('href', _this.originalHref);
|
2629
|
+
});
|
2630
|
+
return this._trigger("disabled", null);
|
2631
|
+
},
|
2632
|
+
enable: function() {
|
2633
|
+
var _this = this;
|
2634
|
+
this.element.parents('a[href]').andSelf().each(function(idx, elem) {
|
2635
|
+
var element;
|
2636
|
+
element = jQuery(elem);
|
2637
|
+
if (!element.is('a[href]')) {
|
2638
|
+
return;
|
2639
|
+
}
|
2640
|
+
_this.originalHref = element.attr('href');
|
2641
|
+
return element.removeAttr('href');
|
2642
|
+
});
|
2643
|
+
this.element.attr("contentEditable", true);
|
2644
|
+
if (!this.element.html().trim()) {
|
2645
|
+
this.element.html(this.options.placeholder);
|
2646
|
+
this.element.css({
|
2647
|
+
'min-width': this.element.innerWidth(),
|
2648
|
+
'min-height': this.element.innerHeight()
|
2649
|
+
});
|
2650
|
+
}
|
2651
|
+
if (!this.bound) {
|
2652
|
+
this.element.on("focus", this, this._activated);
|
2653
|
+
this.element.on("blur", this, this._deactivated);
|
2654
|
+
this.element.on("keyup paste change", this, this._checkModified);
|
2655
|
+
this.element.on("keyup", this, this._keys);
|
2656
|
+
this.element.on("keyup mouseup", this, this._checkSelection);
|
2657
|
+
this.bound = true;
|
2658
|
+
}
|
2659
|
+
if (this.options.forceStructured) {
|
2660
|
+
this._forceStructured();
|
2661
|
+
}
|
2662
|
+
return this._trigger("enabled", null);
|
2663
|
+
},
|
2664
|
+
activate: function() {
|
2665
|
+
return this.element.focus();
|
2666
|
+
},
|
2667
|
+
containsSelection: function() {
|
2668
|
+
var range;
|
2669
|
+
range = this.getSelection();
|
2670
|
+
return this.element.has(range.startContainer).length > 0;
|
2671
|
+
},
|
2672
|
+
getSelection: function() {
|
2673
|
+
var range, sel;
|
2674
|
+
sel = rangy.getSelection();
|
2675
|
+
range = null;
|
2676
|
+
if (sel.rangeCount > 0) {
|
2677
|
+
range = sel.getRangeAt(0);
|
2678
|
+
} else {
|
2679
|
+
range = rangy.createRange();
|
2680
|
+
}
|
2681
|
+
return range;
|
2682
|
+
},
|
2683
|
+
restoreSelection: function(range) {
|
2684
|
+
var sel;
|
2685
|
+
sel = rangy.getSelection();
|
2686
|
+
return sel.setSingleRange(range);
|
2687
|
+
},
|
2688
|
+
replaceSelection: function(cb) {
|
2689
|
+
var newTextNode, r, range, sel, t;
|
2690
|
+
if (navigator.appName === 'Microsoft Internet Explorer') {
|
2691
|
+
t = document.selection.createRange().text;
|
2692
|
+
r = document.selection.createRange();
|
2693
|
+
return r.pasteHTML(cb(t));
|
2694
|
+
} else {
|
2695
|
+
sel = window.getSelection();
|
2696
|
+
range = sel.getRangeAt(0);
|
2697
|
+
newTextNode = document.createTextNode(cb(range.extractContents()));
|
2698
|
+
range.insertNode(newTextNode);
|
2699
|
+
range.setStartAfter(newTextNode);
|
2700
|
+
sel.removeAllRanges();
|
2701
|
+
return sel.addRange(range);
|
2702
|
+
}
|
2703
|
+
},
|
2704
|
+
removeAllSelections: function() {
|
2705
|
+
if (navigator.appName === 'Microsoft Internet Explorer') {
|
2706
|
+
return range.empty();
|
2707
|
+
} else {
|
2708
|
+
return window.getSelection().removeAllRanges();
|
2709
|
+
}
|
2710
|
+
},
|
2711
|
+
getContents: function() {
|
2712
|
+
var cleanup, contentClone, plugin;
|
2713
|
+
contentClone = this.element.clone();
|
2714
|
+
for (plugin in this.options.plugins) {
|
2715
|
+
cleanup = jQuery(this.element).data('IKS-' + plugin).cleanupContentClone;
|
2716
|
+
if (!jQuery.isFunction(cleanup)) {
|
2717
|
+
continue;
|
2718
|
+
}
|
2719
|
+
jQuery(this.element)[plugin]('cleanupContentClone', contentClone);
|
2720
|
+
}
|
2721
|
+
return contentClone.html();
|
2722
|
+
},
|
2723
|
+
setContents: function(contents) {
|
2724
|
+
return this.element.html(contents);
|
2725
|
+
},
|
2726
|
+
isModified: function() {
|
2727
|
+
if (!this.previousContent) {
|
2728
|
+
this.previousContent = this.originalContent;
|
2729
|
+
}
|
2730
|
+
return this.previousContent !== this.getContents();
|
2731
|
+
},
|
2732
|
+
setUnmodified: function() {
|
2733
|
+
jQuery(this.element).removeClass('isModified');
|
2734
|
+
return this.previousContent = this.getContents();
|
2735
|
+
},
|
2736
|
+
setModified: function() {
|
2737
|
+
jQuery(this.element).addClass('isModified');
|
2738
|
+
return this._trigger('modified', null, {
|
2739
|
+
editable: this,
|
2740
|
+
content: this.getContents()
|
2741
|
+
});
|
2742
|
+
},
|
2743
|
+
restoreOriginalContent: function() {
|
2744
|
+
return this.element.html(this.originalContent);
|
2745
|
+
},
|
2746
|
+
execute: function(command, value) {
|
2747
|
+
if (document.execCommand(command, false, value)) {
|
2748
|
+
return this.element.trigger("change");
|
2749
|
+
}
|
2750
|
+
},
|
2751
|
+
protectFocusFrom: function(el) {
|
2752
|
+
var _this = this;
|
2753
|
+
return el.on("mousedown", function(event) {
|
2754
|
+
event.preventDefault();
|
2755
|
+
_this._protectToolbarFocus = true;
|
2756
|
+
return setTimeout(function() {
|
2757
|
+
return _this._protectToolbarFocus = false;
|
2758
|
+
}, 300);
|
2759
|
+
});
|
2760
|
+
},
|
2761
|
+
keepActivated: function(_keepActivated) {
|
2762
|
+
this._keepActivated = _keepActivated;
|
2763
|
+
},
|
2764
|
+
_generateUUID: function() {
|
2765
|
+
var S4;
|
2766
|
+
S4 = function() {
|
2767
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
2768
|
+
};
|
2769
|
+
return "" + (S4()) + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + (S4()) + (S4());
|
2770
|
+
},
|
2771
|
+
_prepareToolbar: function() {
|
2772
|
+
var defaults, plugin, populate, toolbarOptions;
|
2773
|
+
this.toolbar = jQuery('<div class="hallotoolbar"></div>').hide();
|
2774
|
+
if (this.options.toolbarCssClass) {
|
2775
|
+
this.toolbar.addClass(this.options.toolbarCssClass);
|
2776
|
+
}
|
2777
|
+
defaults = {
|
2778
|
+
editable: this,
|
2779
|
+
parentElement: this.options.parentElement,
|
2780
|
+
toolbar: this.toolbar,
|
2781
|
+
positionAbove: this.options.toolbarPositionAbove
|
2782
|
+
};
|
2783
|
+
toolbarOptions = $.extend({}, defaults, this.options.toolbarOptions);
|
2784
|
+
this.element[this.options.toolbar](toolbarOptions);
|
2785
|
+
for (plugin in this.options.plugins) {
|
2786
|
+
populate = jQuery(this.element).data('IKS-' + plugin).populateToolbar;
|
2787
|
+
if (!jQuery.isFunction(populate)) {
|
2788
|
+
continue;
|
2789
|
+
}
|
2790
|
+
this.element[plugin]('populateToolbar', this.toolbar);
|
2791
|
+
}
|
2792
|
+
this.element[this.options.toolbar]('setPosition');
|
2793
|
+
return this.protectFocusFrom(this.toolbar);
|
2794
|
+
},
|
2795
|
+
changeToolbar: function(element, toolbar, hide) {
|
2796
|
+
var originalToolbar;
|
2797
|
+
if (hide == null) {
|
2798
|
+
hide = false;
|
2799
|
+
}
|
2800
|
+
originalToolbar = this.options.toolbar;
|
2801
|
+
this.options.parentElement = element;
|
2802
|
+
if (toolbar) {
|
2803
|
+
this.options.toolbar = toolbar;
|
2804
|
+
}
|
2805
|
+
if (!this.toolbar) {
|
2806
|
+
return;
|
2807
|
+
}
|
2808
|
+
this.element[originalToolbar]('destroy');
|
2809
|
+
this.toolbar.remove();
|
2810
|
+
this._prepareToolbar();
|
2811
|
+
if (hide) {
|
2812
|
+
return this.toolbar.hide();
|
2813
|
+
}
|
2814
|
+
},
|
2815
|
+
_checkModified: function(event) {
|
2816
|
+
var widget;
|
2817
|
+
widget = event.data;
|
2818
|
+
if (widget.isModified()) {
|
2819
|
+
return widget.setModified();
|
2820
|
+
}
|
2821
|
+
},
|
2822
|
+
_keys: function(event) {
|
2823
|
+
var old, widget;
|
2824
|
+
widget = event.data;
|
2825
|
+
if (event.keyCode === 27) {
|
2826
|
+
old = widget.getContents();
|
2827
|
+
widget.restoreOriginalContent(event);
|
2828
|
+
widget._trigger("restored", null, {
|
2829
|
+
editable: widget,
|
2830
|
+
content: widget.getContents(),
|
2831
|
+
thrown: old
|
2832
|
+
});
|
2833
|
+
return widget.turnOff();
|
2834
|
+
}
|
2835
|
+
},
|
2836
|
+
_rangesEqual: function(r1, r2) {
|
2837
|
+
if (r1.startContainer !== r2.startContainer) {
|
2838
|
+
return false;
|
2839
|
+
}
|
2840
|
+
if (r1.startOffset !== r2.startOffset) {
|
2841
|
+
return false;
|
2842
|
+
}
|
2843
|
+
if (r1.endContainer !== r2.endContainer) {
|
2844
|
+
return false;
|
2845
|
+
}
|
2846
|
+
if (r1.endOffset !== r2.endOffset) {
|
2847
|
+
return false;
|
2848
|
+
}
|
2849
|
+
return true;
|
2850
|
+
},
|
2851
|
+
_checkSelection: function(event) {
|
2852
|
+
var widget;
|
2853
|
+
if (event.keyCode === 27) {
|
2854
|
+
return;
|
2855
|
+
}
|
2856
|
+
widget = event.data;
|
2857
|
+
return setTimeout(function() {
|
2858
|
+
var sel;
|
2859
|
+
sel = widget.getSelection();
|
2860
|
+
if (widget._isEmptySelection(sel) || widget._isEmptyRange(sel)) {
|
2861
|
+
if (widget.selection) {
|
2862
|
+
widget.selection = null;
|
2863
|
+
widget._trigger("unselected", null, {
|
2864
|
+
editable: widget,
|
2865
|
+
originalEvent: event
|
2866
|
+
});
|
2867
|
+
}
|
2868
|
+
return;
|
2869
|
+
}
|
2870
|
+
if (!widget.selection || !widget._rangesEqual(sel, widget.selection)) {
|
2871
|
+
widget.selection = sel.cloneRange();
|
2872
|
+
return widget._trigger("selected", null, {
|
2873
|
+
editable: widget,
|
2874
|
+
selection: widget.selection,
|
2875
|
+
ranges: [widget.selection],
|
2876
|
+
originalEvent: event
|
2877
|
+
});
|
2878
|
+
}
|
2879
|
+
}, 0);
|
2880
|
+
},
|
2881
|
+
_isEmptySelection: function(selection) {
|
2882
|
+
if (selection.type === "Caret") {
|
2883
|
+
return true;
|
2884
|
+
}
|
2885
|
+
return false;
|
2886
|
+
},
|
2887
|
+
_isEmptyRange: function(range) {
|
2888
|
+
if (range.collapsed) {
|
2889
|
+
return true;
|
2890
|
+
}
|
2891
|
+
if (range.isCollapsed) {
|
2892
|
+
if (typeof range.isCollapsed === 'function') {
|
2893
|
+
return range.isCollapsed();
|
2894
|
+
}
|
2895
|
+
return range.isCollapsed;
|
2896
|
+
}
|
2897
|
+
return false;
|
2898
|
+
},
|
2899
|
+
turnOn: function() {
|
2900
|
+
if (this.getContents() === this.options.placeholder) {
|
2901
|
+
this.setContents('');
|
2902
|
+
}
|
2903
|
+
jQuery(this.element).addClass('inEditMode');
|
2904
|
+
return this._trigger("activated", null, this);
|
2905
|
+
},
|
2906
|
+
turnOff: function() {
|
2907
|
+
jQuery(this.element).removeClass('inEditMode');
|
2908
|
+
this._trigger("deactivated", null, this);
|
2909
|
+
if (!this.getContents()) {
|
2910
|
+
return this.setContents(this.options.placeholder);
|
2911
|
+
}
|
2912
|
+
},
|
2913
|
+
_activated: function(event) {
|
2914
|
+
return event.data.turnOn();
|
2915
|
+
},
|
2916
|
+
_deactivated: function(event) {
|
2917
|
+
if (event.data._keepActivated) {
|
2918
|
+
return;
|
2919
|
+
}
|
2920
|
+
if (event.data._protectToolbarFocus !== true) {
|
2921
|
+
return event.data.turnOff();
|
2922
|
+
} else {
|
2923
|
+
return setTimeout(function() {
|
2924
|
+
return jQuery(event.data.element).focus();
|
2925
|
+
}, 300);
|
2926
|
+
}
|
2927
|
+
},
|
2928
|
+
_forceStructured: function(event) {
|
2929
|
+
try {
|
2930
|
+
return document.execCommand('styleWithCSS', 0, false);
|
2931
|
+
} catch (e) {
|
2932
|
+
try {
|
2933
|
+
return document.execCommand('useCSS', 0, true);
|
2934
|
+
} catch (e) {
|
2935
|
+
try {
|
2936
|
+
return document.execCommand('styleWithCSS', false, false);
|
2937
|
+
} catch (e) {
|
2938
|
+
|
2939
|
+
}
|
2940
|
+
}
|
2941
|
+
}
|
2942
|
+
},
|
2943
|
+
checkTouch: function() {
|
2944
|
+
return this.options.touchScreen = !!('createTouch' in document);
|
2945
|
+
}
|
2946
|
+
});
|
2947
|
+
})(jQuery);
|
2948
|
+
|
2949
|
+
}).call(this);
|