hallo-rails 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
19
+ Thumbs.db
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hallo-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Oozou Limited
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Hallo-Rails
2
+
3
+ Hallo-rails is the excellent Hallo.js in-place editor packaged as a gem for the Rails 3.1+ asset pipeline.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'hallo-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hallo-rails
18
+
19
+ Note, there is a dependency on [`Rangy`](http://code.google.com/p/rangy/) which is included and also dependencies on JQuery, JQuery UI and [`Font Awesome`](http://fortawesome.github.io/Font-Awesome/) which are not included.
20
+
21
+ Therefore assuming you have already added JQuery, JQuery UI and Font Awesome simply add the following to your application.js
22
+
23
+ //= require rangy-core
24
+ //= require hallo
25
+
26
+ ## Usage
27
+
28
+ For full usage instructions please refer to the [`Hallo.js Documentation`](http://hallojs.org) but this should get you going
29
+
30
+ <div class="editable" contenteditable="true">Edit me!</div>
31
+
32
+ Along with something like this
33
+
34
+ $ ()->
35
+ $('.editable').each ->
36
+ $(this).hallo
37
+ plugins:
38
+ halloformat: {}
39
+ halloblock: {}
40
+ hallojustify: {}
41
+ hallolists: {}
42
+ halloreundo: {}
43
+ hallohtml: {}
44
+ hallolink: {}
45
+ editable: true
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hallo/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hallo-rails"
8
+ spec.version = Hallo::Rails::VERSION
9
+ spec.authors = ["Jan Jones"]
10
+ spec.email = ["jan.jones@oozou.com"]
11
+ spec.description = %q{Use Hallo in-place rich text editor for Rails.}
12
+ spec.summary = %q{Use Hallo in-place rich text editor for Rails.}
13
+ spec.homepage = "https://github.com/oozou/hallo-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "rangy-rails"
24
+ end
@@ -0,0 +1,9 @@
1
+ require "hallo/rails/version"
2
+ require "rangy-rails"
3
+
4
+ module Hallo
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Hallo
2
+ module Rails
3
+ VERSION = "1.0.3"
4
+ end
5
+ end
@@ -0,0 +1,2493 @@
1
+ /* Hallo 1.0.2 - rich text editor for jQuery UI
2
+ * by Henri Bergius and contributors. Available under the MIT license.
3
+ * See http://hallojs.org for more information
4
+ */(function() {
5
+ (function(jQuery) {
6
+ return jQuery.widget('IKS.hallo', {
7
+ toolbar: null,
8
+ bound: false,
9
+ originalContent: '',
10
+ previousContent: '',
11
+ uuid: '',
12
+ selection: null,
13
+ _keepActivated: false,
14
+ originalHref: null,
15
+ options: {
16
+ editable: true,
17
+ plugins: {},
18
+ toolbar: 'halloToolbarContextual',
19
+ parentElement: 'body',
20
+ buttonCssClass: null,
21
+ toolbarCssClass: null,
22
+ toolbarPositionAbove: false,
23
+ toolbarOptions: {},
24
+ placeholder: '',
25
+ forceStructured: true,
26
+ checkTouch: true,
27
+ touchScreen: null
28
+ },
29
+ _create: function() {
30
+ var options, plugin, _ref,
31
+ _this = this;
32
+
33
+ this.id = this._generateUUID();
34
+ if (this.options.checkTouch && this.options.touchScreen === null) {
35
+ this.checkTouch();
36
+ }
37
+ _ref = this.options.plugins;
38
+ for (plugin in _ref) {
39
+ options = _ref[plugin];
40
+ if (!jQuery.isPlainObject(options)) {
41
+ options = {};
42
+ }
43
+ jQuery.extend(options, {
44
+ editable: this,
45
+ uuid: this.id,
46
+ buttonCssClass: this.options.buttonCssClass
47
+ });
48
+ jQuery(this.element)[plugin](options);
49
+ }
50
+ this.element.one('halloactivated', function() {
51
+ return _this._prepareToolbar();
52
+ });
53
+ return this.originalContent = this.getContents();
54
+ },
55
+ _init: function() {
56
+ if (this.options.editable) {
57
+ return this.enable();
58
+ } else {
59
+ return this.disable();
60
+ }
61
+ },
62
+ destroy: function() {
63
+ var options, plugin, _ref;
64
+
65
+ this.disable();
66
+ if (this.toolbar) {
67
+ this.toolbar.remove();
68
+ this.element[this.options.toolbar]('destroy');
69
+ }
70
+ _ref = this.options.plugins;
71
+ for (plugin in _ref) {
72
+ options = _ref[plugin];
73
+ jQuery(this.element)[plugin]('destroy');
74
+ }
75
+ return jQuery.Widget.prototype.destroy.call(this);
76
+ },
77
+ disable: function() {
78
+ var _this = this;
79
+
80
+ this.element.attr("contentEditable", false);
81
+ this.element.off("focus", this._activated);
82
+ this.element.off("blur", this._deactivated);
83
+ this.element.off("keyup paste change", this._checkModified);
84
+ this.element.off("keyup", this._keys);
85
+ this.element.off("keyup mouseup", this._checkSelection);
86
+ this.bound = false;
87
+ jQuery(this.element).removeClass('isModified');
88
+ jQuery(this.element).removeClass('inEditMode');
89
+ this.element.parents('a').addBack().each(function(idx, elem) {
90
+ var element;
91
+
92
+ element = jQuery(elem);
93
+ if (!element.is('a')) {
94
+ return;
95
+ }
96
+ if (!_this.originalHref) {
97
+ return;
98
+ }
99
+ return element.attr('href', _this.originalHref);
100
+ });
101
+ return this._trigger("disabled", null);
102
+ },
103
+ enable: function() {
104
+ var _this = this;
105
+
106
+ this.element.parents('a[href]').addBack().each(function(idx, elem) {
107
+ var element;
108
+
109
+ element = jQuery(elem);
110
+ if (!element.is('a[href]')) {
111
+ return;
112
+ }
113
+ _this.originalHref = element.attr('href');
114
+ return element.removeAttr('href');
115
+ });
116
+ this.element.attr("contentEditable", true);
117
+ if (!jQuery.parseHTML(this.element.html())) {
118
+ this.element.html(this.options.placeholder);
119
+ this.element.css({
120
+ 'min-width': this.element.innerWidth(),
121
+ 'min-height': this.element.innerHeight()
122
+ });
123
+ }
124
+ if (!this.bound) {
125
+ this.element.on("focus", this, this._activated);
126
+ this.element.on("blur", this, this._deactivated);
127
+ this.element.on("keyup paste change", this, this._checkModified);
128
+ this.element.on("keyup", this, this._keys);
129
+ this.element.on("keyup mouseup", this, this._checkSelection);
130
+ this.bound = true;
131
+ }
132
+ if (this.options.forceStructured) {
133
+ this._forceStructured();
134
+ }
135
+ return this._trigger("enabled", null);
136
+ },
137
+ activate: function() {
138
+ return this.element.focus();
139
+ },
140
+ containsSelection: function() {
141
+ var range;
142
+
143
+ range = this.getSelection();
144
+ return this.element.has(range.startContainer).length > 0;
145
+ },
146
+ getSelection: function() {
147
+ var range, sel;
148
+
149
+ sel = rangy.getSelection();
150
+ range = null;
151
+ if (sel.rangeCount > 0) {
152
+ range = sel.getRangeAt(0);
153
+ } else {
154
+ range = rangy.createRange();
155
+ }
156
+ return range;
157
+ },
158
+ restoreSelection: function(range) {
159
+ var sel;
160
+
161
+ sel = rangy.getSelection();
162
+ return sel.setSingleRange(range);
163
+ },
164
+ replaceSelection: function(cb) {
165
+ var newTextNode, r, range, sel, t;
166
+
167
+ if (navigator.appName === 'Microsoft Internet Explorer') {
168
+ t = document.selection.createRange().text;
169
+ r = document.selection.createRange();
170
+ return r.pasteHTML(cb(t));
171
+ } else {
172
+ sel = window.getSelection();
173
+ range = sel.getRangeAt(0);
174
+ newTextNode = document.createTextNode(cb(range.extractContents()));
175
+ range.insertNode(newTextNode);
176
+ range.setStartAfter(newTextNode);
177
+ sel.removeAllRanges();
178
+ return sel.addRange(range);
179
+ }
180
+ },
181
+ removeAllSelections: function() {
182
+ if (navigator.appName === 'Microsoft Internet Explorer') {
183
+ return range.empty();
184
+ } else {
185
+ return window.getSelection().removeAllRanges();
186
+ }
187
+ },
188
+ getPluginInstance: function(plugin) {
189
+ var instance;
190
+
191
+ instance = jQuery(this.element).data("IKS-" + plugin);
192
+ if (instance) {
193
+ return instance;
194
+ }
195
+ return jQuery(this.element).data(plugin);
196
+ },
197
+ getContents: function() {
198
+ var cleanup, plugin;
199
+
200
+ for (plugin in this.options.plugins) {
201
+ cleanup = this.getPluginInstance(plugin).cleanupContentClone;
202
+ if (!jQuery.isFunction(cleanup)) {
203
+ continue;
204
+ }
205
+ jQuery(this.element)[plugin]('cleanupContentClone', this.element);
206
+ }
207
+ return this.element.html();
208
+ },
209
+ setContents: function(contents) {
210
+ return this.element.html(contents);
211
+ },
212
+ isModified: function() {
213
+ if (!this.previousContent) {
214
+ this.previousContent = this.originalContent;
215
+ }
216
+ return this.previousContent !== this.getContents();
217
+ },
218
+ setUnmodified: function() {
219
+ jQuery(this.element).removeClass('isModified');
220
+ return this.previousContent = this.getContents();
221
+ },
222
+ setModified: function() {
223
+ jQuery(this.element).addClass('isModified');
224
+ return this._trigger('modified', null, {
225
+ editable: this,
226
+ content: this.getContents()
227
+ });
228
+ },
229
+ restoreOriginalContent: function() {
230
+ return this.element.html(this.originalContent);
231
+ },
232
+ execute: function(command, value) {
233
+ if (document.execCommand(command, false, value)) {
234
+ return this.element.trigger("change");
235
+ }
236
+ },
237
+ protectFocusFrom: function(el) {
238
+ var _this = this;
239
+
240
+ return el.on("mousedown", function(event) {
241
+ event.preventDefault();
242
+ _this._protectToolbarFocus = true;
243
+ return setTimeout(function() {
244
+ return _this._protectToolbarFocus = false;
245
+ }, 300);
246
+ });
247
+ },
248
+ keepActivated: function(_keepActivated) {
249
+ this._keepActivated = _keepActivated;
250
+ },
251
+ _generateUUID: function() {
252
+ var S4;
253
+
254
+ S4 = function() {
255
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
256
+ };
257
+ return "" + (S4()) + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + (S4()) + (S4());
258
+ },
259
+ _prepareToolbar: function() {
260
+ var defaults, plugin, populate, toolbarOptions;
261
+
262
+ this.toolbar = jQuery('<div class="hallotoolbar"></div>').hide();
263
+ if (this.options.toolbarCssClass) {
264
+ this.toolbar.addClass(this.options.toolbarCssClass);
265
+ }
266
+ defaults = {
267
+ editable: this,
268
+ parentElement: this.options.parentElement,
269
+ toolbar: this.toolbar,
270
+ positionAbove: this.options.toolbarPositionAbove
271
+ };
272
+ toolbarOptions = jQuery.extend({}, defaults, this.options.toolbarOptions);
273
+ this.element[this.options.toolbar](toolbarOptions);
274
+ for (plugin in this.options.plugins) {
275
+ populate = this.getPluginInstance(plugin).populateToolbar;
276
+ if (!jQuery.isFunction(populate)) {
277
+ continue;
278
+ }
279
+ this.element[plugin]('populateToolbar', this.toolbar);
280
+ }
281
+ this.element[this.options.toolbar]('setPosition');
282
+ return this.protectFocusFrom(this.toolbar);
283
+ },
284
+ changeToolbar: function(element, toolbar, hide) {
285
+ var originalToolbar;
286
+
287
+ if (hide == null) {
288
+ hide = false;
289
+ }
290
+ originalToolbar = this.options.toolbar;
291
+ this.options.parentElement = element;
292
+ if (toolbar) {
293
+ this.options.toolbar = toolbar;
294
+ }
295
+ if (!this.toolbar) {
296
+ return;
297
+ }
298
+ this.element[originalToolbar]('destroy');
299
+ this.toolbar.remove();
300
+ this._prepareToolbar();
301
+ if (hide) {
302
+ return this.toolbar.hide();
303
+ }
304
+ },
305
+ _checkModified: function(event) {
306
+ var widget;
307
+
308
+ widget = event.data;
309
+ if (widget.isModified()) {
310
+ return widget.setModified();
311
+ }
312
+ },
313
+ _keys: function(event) {
314
+ var old, widget;
315
+
316
+ widget = event.data;
317
+ if (event.keyCode === 27) {
318
+ old = widget.getContents();
319
+ widget.restoreOriginalContent(event);
320
+ widget._trigger("restored", null, {
321
+ editable: widget,
322
+ content: widget.getContents(),
323
+ thrown: old
324
+ });
325
+ return widget.turnOff();
326
+ }
327
+ },
328
+ _rangesEqual: function(r1, r2) {
329
+ if (r1.startContainer !== r2.startContainer) {
330
+ return false;
331
+ }
332
+ if (r1.startOffset !== r2.startOffset) {
333
+ return false;
334
+ }
335
+ if (r1.endContainer !== r2.endContainer) {
336
+ return false;
337
+ }
338
+ if (r1.endOffset !== r2.endOffset) {
339
+ return false;
340
+ }
341
+ return true;
342
+ },
343
+ _checkSelection: function(event) {
344
+ var widget;
345
+
346
+ if (event.keyCode === 27) {
347
+ return;
348
+ }
349
+ widget = event.data;
350
+ return setTimeout(function() {
351
+ var sel;
352
+
353
+ sel = widget.getSelection();
354
+ if (widget._isEmptySelection(sel) || widget._isEmptyRange(sel)) {
355
+ if (widget.selection) {
356
+ widget.selection = null;
357
+ widget._trigger("unselected", null, {
358
+ editable: widget,
359
+ originalEvent: event
360
+ });
361
+ }
362
+ return;
363
+ }
364
+ if (!widget.selection || !widget._rangesEqual(sel, widget.selection)) {
365
+ widget.selection = sel.cloneRange();
366
+ return widget._trigger("selected", null, {
367
+ editable: widget,
368
+ selection: widget.selection,
369
+ ranges: [widget.selection],
370
+ originalEvent: event
371
+ });
372
+ }
373
+ }, 0);
374
+ },
375
+ _isEmptySelection: function(selection) {
376
+ if (selection.type === "Caret") {
377
+ return true;
378
+ }
379
+ return false;
380
+ },
381
+ _isEmptyRange: function(range) {
382
+ if (range.collapsed) {
383
+ return true;
384
+ }
385
+ if (range.isCollapsed) {
386
+ if (typeof range.isCollapsed === 'function') {
387
+ return range.isCollapsed();
388
+ }
389
+ return range.isCollapsed;
390
+ }
391
+ return false;
392
+ },
393
+ turnOn: function() {
394
+ if (this.getContents() === this.options.placeholder) {
395
+ this.setContents('');
396
+ }
397
+ jQuery(this.element).addClass('inEditMode');
398
+ return this._trigger("activated", null, this);
399
+ },
400
+ turnOff: function() {
401
+ jQuery(this.element).removeClass('inEditMode');
402
+ this._trigger("deactivated", null, this);
403
+ if (!this.getContents()) {
404
+ return this.setContents(this.options.placeholder);
405
+ }
406
+ },
407
+ _activated: function(event) {
408
+ return event.data.turnOn();
409
+ },
410
+ _deactivated: function(event) {
411
+ if (event.data._keepActivated) {
412
+ return;
413
+ }
414
+ if (event.data._protectToolbarFocus !== true) {
415
+ return event.data.turnOff();
416
+ } else {
417
+ return setTimeout(function() {
418
+ return jQuery(event.data.element).focus();
419
+ }, 300);
420
+ }
421
+ },
422
+ _forceStructured: function(event) {
423
+ var e;
424
+
425
+ try {
426
+ return document.execCommand('styleWithCSS', 0, false);
427
+ } catch (_error) {
428
+ e = _error;
429
+ try {
430
+ return document.execCommand('useCSS', 0, true);
431
+ } catch (_error) {
432
+ e = _error;
433
+ try {
434
+ return document.execCommand('styleWithCSS', false, false);
435
+ } catch (_error) {
436
+ e = _error;
437
+ }
438
+ }
439
+ }
440
+ },
441
+ checkTouch: function() {
442
+ return this.options.touchScreen = !!('createTouch' in document);
443
+ }
444
+ });
445
+ })(jQuery);
446
+
447
+ }).call(this);
448
+
449
+ (function() {
450
+ (function(jQuery) {
451
+ var z;
452
+
453
+ z = null;
454
+ if (this.VIE !== void 0) {
455
+ z = new VIE;
456
+ z.use(new z.StanbolService({
457
+ proxyDisabled: true,
458
+ url: 'http://dev.iks-project.eu:8081'
459
+ }));
460
+ }
461
+ return jQuery.widget('IKS.halloannotate', {
462
+ options: {
463
+ vie: z,
464
+ editable: null,
465
+ toolbar: null,
466
+ uuid: '',
467
+ select: function() {},
468
+ decline: function() {},
469
+ remove: function() {},
470
+ buttonCssClass: null
471
+ },
472
+ _create: function() {
473
+ var editableElement, turnOffAnnotate, widget;
474
+
475
+ widget = this;
476
+ if (this.options.vie === void 0) {
477
+ throw new Error('The halloannotate plugin requires VIE');
478
+ return;
479
+ }
480
+ if (typeof this.element.annotate !== 'function') {
481
+ throw new Error('The halloannotate plugin requires annotate.js');
482
+ return;
483
+ }
484
+ this.state = 'off';
485
+ this.instantiate();
486
+ turnOffAnnotate = function() {
487
+ var editable;
488
+
489
+ editable = this;
490
+ return jQuery(editable).halloannotate('turnOff');
491
+ };
492
+ editableElement = this.options.editable.element;
493
+ return editableElement.on('hallodisabled', turnOffAnnotate);
494
+ },
495
+ populateToolbar: function(toolbar) {
496
+ var buttonHolder,
497
+ _this = this;
498
+
499
+ buttonHolder = jQuery("<span class=\"" + this.widgetName + "\"></span>");
500
+ this.button = buttonHolder.hallobutton({
501
+ label: 'Annotate',
502
+ icon: 'icon-tags',
503
+ editable: this.options.editable,
504
+ command: null,
505
+ uuid: this.options.uuid,
506
+ cssClass: this.options.buttonCssClass,
507
+ queryState: false
508
+ });
509
+ buttonHolder.on('change', function(event) {
510
+ if (_this.state === "pending") {
511
+ return;
512
+ }
513
+ if (_this.state === "off") {
514
+ return _this.turnOn();
515
+ }
516
+ return _this.turnOff();
517
+ });
518
+ buttonHolder.buttonset();
519
+ return toolbar.append(this.button);
520
+ },
521
+ cleanupContentClone: function(el) {
522
+ if (this.state === 'on') {
523
+ return el.find(".entity:not([about])").each(function() {
524
+ return jQuery(this).replaceWith(jQuery(this).html());
525
+ });
526
+ }
527
+ },
528
+ instantiate: function() {
529
+ var widget;
530
+
531
+ widget = this;
532
+ return this.options.editable.element.annotate({
533
+ vie: this.options.vie,
534
+ debug: false,
535
+ showTooltip: true,
536
+ select: this.options.select,
537
+ remove: this.options.remove,
538
+ success: this.options.success,
539
+ error: this.options.error
540
+ }).on('annotateselect', function(event, data) {
541
+ return widget.options.editable.setModified();
542
+ }).on('annotateremove', function() {
543
+ return jQuery.noop();
544
+ });
545
+ },
546
+ turnPending: function() {
547
+ this.state = 'pending';
548
+ this.button.hallobutton('checked', false);
549
+ return this.button.hallobutton('disable');
550
+ },
551
+ turnOn: function() {
552
+ var e, widget,
553
+ _this = this;
554
+
555
+ this.turnPending();
556
+ widget = this;
557
+ try {
558
+ return this.options.editable.element.annotate('enable', function(success) {
559
+ if (!success) {
560
+ return;
561
+ }
562
+ _this.state = 'on';
563
+ _this.button.hallobutton('checked', true);
564
+ return _this.button.hallobutton('enable');
565
+ });
566
+ } catch (_error) {
567
+ e = _error;
568
+ return alert(e);
569
+ }
570
+ },
571
+ turnOff: function() {
572
+ this.options.editable.element.annotate('disable');
573
+ this.state = 'off';
574
+ if (!this.button) {
575
+ return;
576
+ }
577
+ this.button.attr('checked', false);
578
+ this.button.find("label").removeClass("ui-state-clicked");
579
+ return this.button.button('refresh');
580
+ }
581
+ });
582
+ })(jQuery);
583
+
584
+ }).call(this);
585
+
586
+ (function() {
587
+ (function(jQuery) {
588
+ return jQuery.widget('IKS.halloblacklist', {
589
+ options: {
590
+ tags: []
591
+ },
592
+ _init: function() {
593
+ if (this.options.tags.indexOf('br') !== -1) {
594
+ return this.element.on('keydown', function(event) {
595
+ if (event.originalEvent.keyCode === 13) {
596
+ return event.preventDefault();
597
+ }
598
+ });
599
+ }
600
+ },
601
+ cleanupContentClone: function(el) {
602
+ var tag, _i, _len, _ref, _results;
603
+
604
+ _ref = this.options.tags;
605
+ _results = [];
606
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
607
+ tag = _ref[_i];
608
+ _results.push(jQuery(tag, el).remove());
609
+ }
610
+ return _results;
611
+ }
612
+ });
613
+ })(jQuery);
614
+
615
+ }).call(this);
616
+
617
+ (function() {
618
+ (function(jQuery) {
619
+ return jQuery.widget('IKS.halloblock', {
620
+ options: {
621
+ editable: null,
622
+ toolbar: null,
623
+ uuid: '',
624
+ elements: ['h1', 'h2', 'h3', 'p', 'pre', 'blockquote'],
625
+ buttonCssClass: null
626
+ },
627
+ populateToolbar: function(toolbar) {
628
+ var buttonset, contentId, target;
629
+
630
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
631
+ contentId = "" + this.options.uuid + "-" + this.widgetName + "-data";
632
+ target = this._prepareDropdown(contentId);
633
+ toolbar.append(buttonset);
634
+ buttonset.hallobuttonset();
635
+ buttonset.append(target);
636
+ return buttonset.append(this._prepareButton(target));
637
+ },
638
+ _prepareDropdown: function(contentId) {
639
+ var addElement, containingElement, contentArea, element, _i, _len, _ref,
640
+ _this = this;
641
+
642
+ contentArea = jQuery("<div id=\"" + contentId + "\"></div>");
643
+ containingElement = this.options.editable.element.get(0).tagName.toLowerCase();
644
+ addElement = function(element) {
645
+ var el, events, queryState;
646
+
647
+ el = jQuery("<button class='blockselector'> <" + element + " class=\"menu-item\">" + element + "</" + element + "> </button>");
648
+ if (containingElement === element) {
649
+ el.addClass('selected');
650
+ }
651
+ if (containingElement !== 'div') {
652
+ el.addClass('disabled');
653
+ }
654
+ el.on('click', function() {
655
+ var tagName;
656
+
657
+ tagName = element.toUpperCase();
658
+ if (el.hasClass('disabled')) {
659
+ return;
660
+ }
661
+ if (navigator.appName === 'Microsoft Internet Explorer') {
662
+ _this.options.editable.execute('FormatBlock', "<" + tagName + ">");
663
+ return;
664
+ }
665
+ return _this.options.editable.execute('formatBlock', tagName);
666
+ });
667
+ queryState = function(event) {
668
+ var block;
669
+
670
+ block = document.queryCommandValue('formatBlock');
671
+ if (block.toLowerCase() === element) {
672
+ el.addClass('selected');
673
+ return;
674
+ }
675
+ return el.removeClass('selected');
676
+ };
677
+ events = 'keyup paste change mouseup';
678
+ _this.options.editable.element.on(events, queryState);
679
+ _this.options.editable.element.on('halloenabled', function() {
680
+ return _this.options.editable.element.on(events, queryState);
681
+ });
682
+ _this.options.editable.element.on('hallodisabled', function() {
683
+ return _this.options.editable.element.off(events, queryState);
684
+ });
685
+ return el;
686
+ };
687
+ _ref = this.options.elements;
688
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
689
+ element = _ref[_i];
690
+ contentArea.append(addElement(element));
691
+ }
692
+ return contentArea;
693
+ },
694
+ _prepareButton: function(target) {
695
+ var buttonElement;
696
+
697
+ buttonElement = jQuery('<span></span>');
698
+ buttonElement.hallodropdownbutton({
699
+ uuid: this.options.uuid,
700
+ editable: this.options.editable,
701
+ label: 'block',
702
+ icon: 'icon-text-height',
703
+ target: target,
704
+ cssClass: this.options.buttonCssClass
705
+ });
706
+ return buttonElement;
707
+ }
708
+ });
709
+ })(jQuery);
710
+
711
+ }).call(this);
712
+
713
+ (function() {
714
+ (function(jQuery) {
715
+ var rangyMessage;
716
+
717
+ rangyMessage = 'The hallocleanhtml plugin requires the selection save and\
718
+ restore module from Rangy';
719
+ return jQuery.widget('IKS.hallocleanhtml', {
720
+ _create: function() {
721
+ var editor,
722
+ _this = this;
723
+
724
+ if (jQuery.htmlClean === void 0) {
725
+ throw new Error('The hallocleanhtml plugin requires jQuery.htmlClean');
726
+ return;
727
+ }
728
+ editor = this.element;
729
+ return editor.bind('paste', this, function(event) {
730
+ var lastContent, lastRange, widget;
731
+
732
+ if (rangy.saveSelection === void 0) {
733
+ throw new Error(rangyMessage);
734
+ return;
735
+ }
736
+ widget = event.data;
737
+ widget.options.editable.getSelection().deleteContents();
738
+ lastRange = rangy.saveSelection();
739
+ lastContent = editor.html();
740
+ editor.html('');
741
+ return setTimeout(function() {
742
+ var cleanPasted, error, pasted, range;
743
+
744
+ pasted = editor.html();
745
+ cleanPasted = jQuery.htmlClean(pasted, _this.options);
746
+ editor.html(lastContent);
747
+ rangy.restoreSelection(lastRange);
748
+ if (cleanPasted !== '') {
749
+ try {
750
+ return document.execCommand('insertHTML', false, cleanPasted);
751
+ } catch (_error) {
752
+ error = _error;
753
+ range = widget.options.editable.getSelection();
754
+ return range.insertNode(range.createContextualFragment(cleanPasted));
755
+ }
756
+ }
757
+ }, 4);
758
+ });
759
+ }
760
+ });
761
+ })(jQuery);
762
+
763
+ }).call(this);
764
+
765
+ (function() {
766
+ (function(jQuery) {
767
+ return jQuery.widget("IKS.halloformat", {
768
+ options: {
769
+ editable: null,
770
+ uuid: '',
771
+ formattings: {
772
+ bold: true,
773
+ italic: true,
774
+ strikeThrough: false,
775
+ underline: false
776
+ },
777
+ buttonCssClass: null
778
+ },
779
+ populateToolbar: function(toolbar) {
780
+ var buttonize, buttonset, enabled, format, widget, _ref,
781
+ _this = this;
782
+
783
+ widget = this;
784
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
785
+ buttonize = function(format) {
786
+ var buttonHolder;
787
+
788
+ buttonHolder = jQuery('<span></span>');
789
+ buttonHolder.hallobutton({
790
+ label: format,
791
+ editable: _this.options.editable,
792
+ command: format,
793
+ uuid: _this.options.uuid,
794
+ cssClass: _this.options.buttonCssClass
795
+ });
796
+ return buttonset.append(buttonHolder);
797
+ };
798
+ _ref = this.options.formattings;
799
+ for (format in _ref) {
800
+ enabled = _ref[format];
801
+ if (!enabled) {
802
+ continue;
803
+ }
804
+ buttonize(format);
805
+ }
806
+ buttonset.hallobuttonset();
807
+ return toolbar.append(buttonset);
808
+ }
809
+ });
810
+ })(jQuery);
811
+
812
+ }).call(this);
813
+
814
+ (function() {
815
+ (function(jQuery) {
816
+ return jQuery.widget("IKS.halloheadings", {
817
+ options: {
818
+ editable: null,
819
+ uuid: '',
820
+ formatBlocks: ["p", "h1", "h2", "h3"],
821
+ buttonCssClass: null
822
+ },
823
+ populateToolbar: function(toolbar) {
824
+ var buttonize, buttonset, command, format, ie, widget, _i, _len, _ref,
825
+ _this = this;
826
+
827
+ widget = this;
828
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
829
+ ie = navigator.appName === 'Microsoft Internet Explorer';
830
+ command = (ie ? "FormatBlock" : "formatBlock");
831
+ buttonize = function(format) {
832
+ var buttonHolder;
833
+
834
+ buttonHolder = jQuery('<span></span>');
835
+ buttonHolder.hallobutton({
836
+ label: format,
837
+ editable: _this.options.editable,
838
+ command: command,
839
+ commandValue: (ie ? "<" + format + ">" : format),
840
+ uuid: _this.options.uuid,
841
+ cssClass: _this.options.buttonCssClass,
842
+ queryState: function(event) {
843
+ var compared, e, map, result, val, value, _i, _len, _ref;
844
+
845
+ try {
846
+ value = document.queryCommandValue(command);
847
+ if (ie) {
848
+ map = {
849
+ p: "normal"
850
+ };
851
+ _ref = [1, 2, 3, 4, 5, 6];
852
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
853
+ val = _ref[_i];
854
+ map["h" + val] = val;
855
+ }
856
+ compared = value.match(new RegExp(map[format], "i"));
857
+ } else {
858
+ compared = value.match(new RegExp(format, "i"));
859
+ }
860
+ result = compared ? true : false;
861
+ return buttonHolder.hallobutton('checked', result);
862
+ } catch (_error) {
863
+ e = _error;
864
+ }
865
+ }
866
+ });
867
+ buttonHolder.find('button .ui-button-text').text(format.toUpperCase());
868
+ return buttonset.append(buttonHolder);
869
+ };
870
+ _ref = this.options.formatBlocks;
871
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
872
+ format = _ref[_i];
873
+ buttonize(format);
874
+ }
875
+ buttonset.hallobuttonset();
876
+ return toolbar.append(buttonset);
877
+ }
878
+ });
879
+ })(jQuery);
880
+
881
+ }).call(this);
882
+
883
+ (function() {
884
+ (function(jQuery) {
885
+ return jQuery.widget("IKS.hallohtml", {
886
+ options: {
887
+ editable: null,
888
+ toolbar: null,
889
+ uuid: "",
890
+ lang: 'en',
891
+ dialogOpts: {
892
+ autoOpen: false,
893
+ width: 600,
894
+ height: 'auto',
895
+ modal: false,
896
+ resizable: true,
897
+ draggable: true,
898
+ dialogClass: 'htmledit-dialog'
899
+ },
900
+ dialog: null,
901
+ buttonCssClass: null
902
+ },
903
+ translations: {
904
+ en: {
905
+ title: 'Edit HTML',
906
+ update: 'Update'
907
+ },
908
+ de: {
909
+ title: 'HTML bearbeiten',
910
+ update: 'Aktualisieren'
911
+ }
912
+ },
913
+ texts: null,
914
+ populateToolbar: function($toolbar) {
915
+ var $buttonHolder, $buttonset, id, selector, widget;
916
+
917
+ widget = this;
918
+ this.texts = this.translations[this.options.lang];
919
+ this.options.toolbar = $toolbar;
920
+ selector = "" + this.options.uuid + "-htmledit-dialog";
921
+ this.options.dialog = jQuery("<div>").attr('id', selector);
922
+ $buttonset = jQuery("<span>").addClass(widget.widgetName);
923
+ id = "" + this.options.uuid + "-htmledit";
924
+ $buttonHolder = jQuery('<span>');
925
+ $buttonHolder.hallobutton({
926
+ label: this.texts.title,
927
+ icon: 'icon-list-alt',
928
+ editable: this.options.editable,
929
+ command: null,
930
+ queryState: false,
931
+ uuid: this.options.uuid,
932
+ cssClass: this.options.buttonCssClass
933
+ });
934
+ $buttonset.append($buttonHolder);
935
+ this.button = $buttonHolder;
936
+ this.button.click(function() {
937
+ if (widget.options.dialog.dialog("isOpen")) {
938
+ widget._closeDialog();
939
+ } else {
940
+ widget._openDialog();
941
+ }
942
+ return false;
943
+ });
944
+ this.options.editable.element.on("hallodeactivated", function() {
945
+ return widget._closeDialog();
946
+ });
947
+ $toolbar.append($buttonset);
948
+ this.options.dialog.dialog(this.options.dialogOpts);
949
+ return this.options.dialog.dialog("option", "title", this.texts.title);
950
+ },
951
+ _openDialog: function() {
952
+ var $editableEl, html, widget, xposition, yposition,
953
+ _this = this;
954
+
955
+ widget = this;
956
+ $editableEl = jQuery(this.options.editable.element);
957
+ xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
958
+ yposition = this.options.toolbar.offset().top - jQuery(document).scrollTop();
959
+ this.options.dialog.dialog("option", "position", [xposition, yposition]);
960
+ this.options.editable.keepActivated(true);
961
+ this.options.dialog.dialog("open");
962
+ this.options.dialog.on('dialogclose', function() {
963
+ jQuery('label', _this.button).removeClass('ui-state-active');
964
+ _this.options.editable.element.focus();
965
+ return _this.options.editable.keepActivated(false);
966
+ });
967
+ this.options.dialog.html(jQuery("<textarea>").addClass('html_source'));
968
+ html = this.options.editable.element.html();
969
+ this.options.dialog.children('.html_source').val(html);
970
+ this.options.dialog.prepend(jQuery("<button>" + this.texts.update + "</button>"));
971
+ return this.options.dialog.on('click', 'button', function() {
972
+ html = widget.options.dialog.children('.html_source').val();
973
+ widget.options.editable.element.html(html);
974
+ widget.options.editable.element.trigger('change');
975
+ return false;
976
+ });
977
+ },
978
+ _closeDialog: function() {
979
+ return this.options.dialog.dialog("close");
980
+ }
981
+ });
982
+ })(jQuery);
983
+
984
+ }).call(this);
985
+
986
+ (function() {
987
+ (function(jQuery) {
988
+ return jQuery.widget("IKS.halloimage", {
989
+ options: {
990
+ editable: null,
991
+ toolbar: null,
992
+ uuid: "",
993
+ limit: 8,
994
+ search: null,
995
+ searchUrl: null,
996
+ suggestions: null,
997
+ loaded: null,
998
+ upload: null,
999
+ uploadUrl: null,
1000
+ dialogOpts: {
1001
+ autoOpen: false,
1002
+ width: 270,
1003
+ height: "auto",
1004
+ title: "Insert Images",
1005
+ modal: false,
1006
+ resizable: false,
1007
+ draggable: true,
1008
+ dialogClass: 'halloimage-dialog'
1009
+ },
1010
+ dialog: null,
1011
+ buttonCssClass: null,
1012
+ entity: null,
1013
+ vie: null,
1014
+ dbPediaUrl: "http://dev.iks-project.eu/stanbolfull",
1015
+ maxWidth: 250,
1016
+ maxHeight: 250
1017
+ },
1018
+ populateToolbar: function(toolbar) {
1019
+ var buttonHolder, buttonset, dialogId, id, tabContent, tabs, widget;
1020
+
1021
+ this.options.toolbar = toolbar;
1022
+ widget = this;
1023
+ dialogId = "" + this.options.uuid + "-image-dialog";
1024
+ 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>");
1025
+ tabs = jQuery('.tabs', this.options.dialog);
1026
+ tabContent = jQuery('.dialogcontent', this.options.dialog);
1027
+ if (widget.options.suggestions) {
1028
+ this._addGuiTabSuggestions(tabs, tabContent);
1029
+ }
1030
+ if (widget.options.search || widget.options.searchUrl) {
1031
+ this._addGuiTabSearch(tabs, tabContent);
1032
+ }
1033
+ if (widget.options.upload || widget.options.uploadUrl) {
1034
+ this._addGuiTabUpload(tabs, tabContent);
1035
+ }
1036
+ this.current = jQuery('<div class="currentImage"></div>').halloimagecurrent({
1037
+ uuid: this.options.uuid,
1038
+ imageWidget: this,
1039
+ editable: this.options.editable,
1040
+ dialog: this.options.dialog,
1041
+ maxWidth: this.options.maxWidth,
1042
+ maxHeight: this.options.maxHeight
1043
+ });
1044
+ jQuery('.dialogcontent', this.options.dialog).append(this.current);
1045
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
1046
+ id = "" + this.options.uuid + "-image";
1047
+ buttonHolder = jQuery('<span></span>');
1048
+ buttonHolder.hallobutton({
1049
+ label: 'Images',
1050
+ icon: 'icon-picture',
1051
+ editable: this.options.editable,
1052
+ command: null,
1053
+ queryState: false,
1054
+ uuid: this.options.uuid,
1055
+ cssClass: this.options.buttonCssClass
1056
+ });
1057
+ buttonset.append(buttonHolder);
1058
+ this.button = buttonHolder;
1059
+ this.button.on("click", function(event) {
1060
+ if (widget.options.dialog.dialog("isOpen")) {
1061
+ widget._closeDialog();
1062
+ } else {
1063
+ widget._openDialog();
1064
+ }
1065
+ return false;
1066
+ });
1067
+ this.options.editable.element.on("hallodeactivated", function(event) {
1068
+ return widget._closeDialog();
1069
+ });
1070
+ jQuery(this.options.editable.element).delegate("img", "click", function(event) {
1071
+ return widget._openDialog();
1072
+ });
1073
+ toolbar.append(buttonset);
1074
+ this.options.dialog.dialog(this.options.dialogOpts);
1075
+ return this._handleTabs();
1076
+ },
1077
+ setCurrent: function(image) {
1078
+ return this.current.halloimagecurrent('setImage', image);
1079
+ },
1080
+ _handleTabs: function() {
1081
+ var widget;
1082
+
1083
+ widget = this;
1084
+ jQuery('.nav li', this.options.dialog).on('click', function() {
1085
+ var id, left;
1086
+
1087
+ jQuery("." + widget.widgetName + "-tab").hide();
1088
+ id = jQuery(this).attr('id');
1089
+ jQuery("#" + id + "-content").show();
1090
+ left = jQuery(this).position().left + (jQuery(this).width() / 2);
1091
+ return jQuery("#" + widget.options.uuid + "-tab-activeIndicator").css({
1092
+ "margin-left": left
1093
+ });
1094
+ });
1095
+ return jQuery('.nav li', this.options.dialog).first().click();
1096
+ },
1097
+ _openDialog: function() {
1098
+ var cleanUp, editableEl, getActive, suggestionSelector, toolbarEl, widget, xposition, yposition,
1099
+ _this = this;
1100
+
1101
+ widget = this;
1102
+ cleanUp = function() {
1103
+ return window.setTimeout(function() {
1104
+ var thumbnails;
1105
+
1106
+ thumbnails = jQuery(".imageThumbnail");
1107
+ return jQuery(thumbnails).each(function() {
1108
+ var size;
1109
+
1110
+ size = jQuery("#" + this.id).width();
1111
+ if (size <= 20) {
1112
+ return jQuery("#" + this.id).parent("li").remove();
1113
+ }
1114
+ });
1115
+ }, 15000);
1116
+ };
1117
+ suggestionSelector = "#" + this.options.uuid + "-tab-suggestions-content";
1118
+ getActive = function() {
1119
+ return jQuery('.imageThumbnailActive', suggestionSelector).first().attr("src");
1120
+ };
1121
+ jQuery("#" + this.options.uuid + "-sugg-activeImage").attr("src", getActive());
1122
+ jQuery("#" + this.options.uuid + "-sugg-activeImageBg").attr("src", getActive());
1123
+ this.lastSelection = this.options.editable.getSelection();
1124
+ editableEl = jQuery(this.options.editable.element);
1125
+ toolbarEl = jQuery(this.options.toolbar);
1126
+ xposition = editableEl.offset().left + editableEl.outerWidth() - 3;
1127
+ yposition = toolbarEl.offset().top + toolbarEl.outerHeight() + 29;
1128
+ yposition -= jQuery(document).scrollTop();
1129
+ this.options.dialog.dialog("option", "position", [xposition, yposition]);
1130
+ cleanUp();
1131
+ widget.options.loaded = 1;
1132
+ this.options.editable.keepActivated(true);
1133
+ this.options.dialog.dialog("open");
1134
+ return this.options.dialog.on('dialogclose', function() {
1135
+ jQuery('label', _this.button).removeClass('ui-state-active');
1136
+ _this.options.editable.element.focus();
1137
+ return _this.options.editable.keepActivated(false);
1138
+ });
1139
+ },
1140
+ _closeDialog: function() {
1141
+ return this.options.dialog.dialog("close");
1142
+ },
1143
+ _addGuiTabSuggestions: function(tabs, element) {
1144
+ var tab;
1145
+
1146
+ tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-suggestions\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-suggestions\"> <span>Suggestions</span> </li>"));
1147
+ tab = jQuery("<div id=\"" + this.options.uuid + "-tab-suggestions-content\" class=\"" + this.widgetName + "-tab tab-suggestions\"></div>");
1148
+ element.append(tab);
1149
+ return tab.halloimagesuggestions({
1150
+ uuid: this.options.uuid,
1151
+ imageWidget: this,
1152
+ entity: this.options.entity
1153
+ });
1154
+ },
1155
+ _addGuiTabSearch: function(tabs, element) {
1156
+ var dialogId, tab, widget;
1157
+
1158
+ widget = this;
1159
+ dialogId = "" + this.options.uuid + "-image-dialog";
1160
+ tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-search\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-search\"> <span>Search</span> </li>"));
1161
+ tab = jQuery("<div id=\"" + this.options.uuid + "-tab-search-content\" class=\"" + widget.widgetName + "-tab tab-search\"></div>");
1162
+ element.append(tab);
1163
+ return tab.halloimagesearch({
1164
+ uuid: this.options.uuid,
1165
+ imageWidget: this,
1166
+ searchCallback: this.options.search,
1167
+ searchUrl: this.options.searchUrl,
1168
+ limit: this.options.limit,
1169
+ entity: this.options.entity
1170
+ });
1171
+ },
1172
+ _addGuiTabUpload: function(tabs, element) {
1173
+ var tab;
1174
+
1175
+ tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-upload\" class=\"" + this.widgetName + "-tabselector " + this.widgetName + "-tab-upload\"> <span>Upload</span> </li>"));
1176
+ tab = jQuery("<div id=\"" + this.options.uuid + "-tab-upload-content\" class=\"" + this.widgetName + "-tab tab-upload\"></div>");
1177
+ element.append(tab);
1178
+ return tab.halloimageupload({
1179
+ uuid: this.options.uuid,
1180
+ uploadCallback: this.options.upload,
1181
+ uploadUrl: this.options.uploadUrl,
1182
+ imageWidget: this,
1183
+ entity: this.options.entity
1184
+ });
1185
+ }
1186
+ });
1187
+ })(jQuery);
1188
+
1189
+ }).call(this);
1190
+
1191
+ (function() {
1192
+ (function(jQuery) {
1193
+ return jQuery.widget("IKS.hallo-image-insert-edit", {
1194
+ options: {
1195
+ editable: null,
1196
+ toolbar: null,
1197
+ uuid: "",
1198
+ insert_file_dialog_ui_url: null,
1199
+ lang: 'en',
1200
+ dialogOpts: {
1201
+ autoOpen: false,
1202
+ width: 560,
1203
+ height: 'auto',
1204
+ modal: false,
1205
+ resizable: true,
1206
+ draggable: true,
1207
+ dialogClass: 'insert-image-dialog'
1208
+ },
1209
+ dialog: null,
1210
+ buttonCssClass: null
1211
+ },
1212
+ translations: {
1213
+ en: {
1214
+ title_insert: 'Insert Image',
1215
+ title_properties: 'Image Properties',
1216
+ insert: 'Insert',
1217
+ chage_image: 'Change Image:',
1218
+ source: 'URL',
1219
+ width: 'Width',
1220
+ height: 'Height',
1221
+ alt: 'Alt Text',
1222
+ padding: 'Padding',
1223
+ 'float': 'Float',
1224
+ float_left: 'left',
1225
+ float_right: 'right',
1226
+ float_none: 'No'
1227
+ },
1228
+ de: {
1229
+ title_insert: 'Bild einfügen',
1230
+ title_properties: 'Bildeigenschaften',
1231
+ insert: 'Einfügen',
1232
+ chage_image: 'Bild ändern:',
1233
+ source: 'URL',
1234
+ width: 'Breite',
1235
+ height: 'Höhe',
1236
+ alt: 'Alt Text',
1237
+ padding: 'Padding',
1238
+ 'float': 'Float',
1239
+ float_left: 'Links',
1240
+ float_right: 'Rechts',
1241
+ float_none: 'Nein'
1242
+ }
1243
+ },
1244
+ texts: null,
1245
+ dialog_image_selection_ui_loaded: false,
1246
+ $image: null,
1247
+ populateToolbar: function($toolbar) {
1248
+ var $buttonHolder, $buttonset, dialog_html, widget;
1249
+
1250
+ widget = this;
1251
+ this.texts = this.translations[this.options.lang];
1252
+ this.options.toolbar = $toolbar;
1253
+ dialog_html = "<div id='hallo_img_properties'></div>";
1254
+ if (this.options.insert_file_dialog_ui_url) {
1255
+ dialog_html += "<div id='hallo_img_file_select_ui'></div>";
1256
+ }
1257
+ this.options.dialog = jQuery("<div>").attr('id', "" + this.options.uuid + "-insert-image-dialog").html(dialog_html);
1258
+ $buttonset = jQuery("<span>").addClass(this.widgetName);
1259
+ $buttonHolder = jQuery('<span>');
1260
+ $buttonHolder.hallobutton({
1261
+ label: this.texts.title_insert,
1262
+ icon: 'icon-picture',
1263
+ editable: this.options.editable,
1264
+ command: null,
1265
+ queryState: false,
1266
+ uuid: this.options.uuid,
1267
+ cssClass: this.options.buttonCssClass
1268
+ });
1269
+ $buttonset.append($buttonHolder);
1270
+ this.button = $buttonHolder;
1271
+ this.button.click(function() {
1272
+ if (widget.options.dialog.dialog("isOpen")) {
1273
+ widget._closeDialog();
1274
+ } else {
1275
+ widget.lastSelection = widget.options.editable.getSelection();
1276
+ widget._openDialog();
1277
+ }
1278
+ return false;
1279
+ });
1280
+ this.options.editable.element.on("halloselected, hallounselected", function() {
1281
+ if (widget.options.dialog.dialog("isOpen")) {
1282
+ return widget.lastSelection = widget.options.editable.getSelection();
1283
+ }
1284
+ });
1285
+ this.options.editable.element.on("hallodeactivated", function() {
1286
+ return widget._closeDialog();
1287
+ });
1288
+ jQuery(this.options.editable.element).on("click", "img", function(e) {
1289
+ widget._openDialog(jQuery(this));
1290
+ return false;
1291
+ });
1292
+ this.options.editable.element.on('halloselected', function(event, data) {
1293
+ var toolbar_option;
1294
+
1295
+ toolbar_option = widget.options.editable.options.toolbar;
1296
+ if (toolbar_option === "halloToolbarContextual" && jQuery(data.originalEvent.target).is('img')) {
1297
+ $toolbar.hide();
1298
+ return false;
1299
+ }
1300
+ });
1301
+ $toolbar.append($buttonset);
1302
+ return this.options.dialog.dialog(this.options.dialogOpts);
1303
+ },
1304
+ _openDialog: function($image) {
1305
+ var $editableEl, widget, xposition, yposition,
1306
+ _this = this;
1307
+
1308
+ this.$image = $image;
1309
+ widget = this;
1310
+ $editableEl = jQuery(this.options.editable.element);
1311
+ xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
1312
+ if (this.$image) {
1313
+ yposition = this.$image.offset().top - jQuery(document).scrollTop();
1314
+ } else {
1315
+ yposition = this.options.toolbar.offset().top - jQuery(document).scrollTop();
1316
+ }
1317
+ this.options.dialog.dialog("option", "position", [xposition, yposition]);
1318
+ this.options.editable.keepActivated(true);
1319
+ this.options.dialog.dialog("open");
1320
+ if (this.$image) {
1321
+ this.options.dialog.dialog("option", "title", this.texts.title_properties);
1322
+ jQuery(document).keyup(function(e) {
1323
+ if (e.keyCode === 46 || e.keyCode === 8) {
1324
+ jQuery(document).off();
1325
+ widget._closeDialog();
1326
+ widget.$image.remove();
1327
+ widget.$image = null;
1328
+ }
1329
+ return e.preventDefault();
1330
+ });
1331
+ this.options.editable.element.on("click", function() {
1332
+ widget.$image = null;
1333
+ return widget._closeDialog();
1334
+ });
1335
+ } else {
1336
+ this.options.dialog.children('#hallo_img_properties').hide();
1337
+ this.options.dialog.dialog("option", "title", this.texts.title_insert);
1338
+ if (jQuery('#hallo_img_file_select_title').length > 0) {
1339
+ jQuery('#hallo_img_file_select_title').text('');
1340
+ }
1341
+ }
1342
+ this._load_dialog_image_properties_ui();
1343
+ this.options.dialog.on('dialogclose', function() {
1344
+ var scrollbar_pos;
1345
+
1346
+ jQuery('label', _this.button).removeClass('ui-state-active');
1347
+ scrollbar_pos = jQuery(document).scrollTop();
1348
+ _this.options.editable.element.focus();
1349
+ jQuery(document).scrollTop(scrollbar_pos);
1350
+ return _this.options.editable.keepActivated(false);
1351
+ });
1352
+ if (this.options.insert_file_dialog_ui_url && !this.dialog_image_selection_ui_loaded) {
1353
+ this.options.dialog.on('click', ".reload_link", function() {
1354
+ widget._load_dialog_image_selection_ui();
1355
+ return false;
1356
+ });
1357
+ this.options.dialog.on('click', '.file_preview img', function() {
1358
+ var new_source;
1359
+
1360
+ if (widget.$image) {
1361
+ new_source = jQuery(this).attr('src').replace(/-thumb/, '');
1362
+ widget.$image.attr('src', new_source);
1363
+ jQuery('#hallo_img_source').val(new_source);
1364
+ } else {
1365
+ widget._insert_image(jQuery(this).attr('src').replace(/-thumb/, ''));
1366
+ }
1367
+ return false;
1368
+ });
1369
+ return this._load_dialog_image_selection_ui();
1370
+ }
1371
+ },
1372
+ _insert_image: function(source) {
1373
+ this.options.editable.restoreSelection(this.lastSelection);
1374
+ document.execCommand("insertImage", null, source);
1375
+ this.options.editable.element.trigger('change');
1376
+ this.options.editable.removeAllSelections();
1377
+ return this._closeDialog();
1378
+ },
1379
+ _closeDialog: function() {
1380
+ return this.options.dialog.dialog("close");
1381
+ },
1382
+ _load_dialog_image_selection_ui: function() {
1383
+ var widget;
1384
+
1385
+ widget = this;
1386
+ return jQuery.ajax({
1387
+ url: this.options.insert_file_dialog_ui_url,
1388
+ success: function(data, textStatus, jqXHR) {
1389
+ var $properties, file_select_title, t;
1390
+
1391
+ file_select_title = '';
1392
+ $properties = widget.options.dialog.children('#hallo_img_properties');
1393
+ if ($properties.is(':visible')) {
1394
+ file_select_title = widget.texts.change_image;
1395
+ }
1396
+ t = "<div id='hallo_img_file_select_title'>" + file_select_title + "</div>";
1397
+ widget.options.dialog.children('#hallo_img_file_select_ui').html(t + data);
1398
+ return widget.dialog_image_selection_ui_loaded = true;
1399
+ },
1400
+ beforeSend: function() {
1401
+ return widget.options.dialog.children('#hallo_img_file_select_ui').html('<div class="hallo_insert_file_loader"></div>');
1402
+ }
1403
+ });
1404
+ },
1405
+ _load_dialog_image_properties_ui: function() {
1406
+ var $img_properties, button, height, html, widget, width;
1407
+
1408
+ widget = this;
1409
+ $img_properties = this.options.dialog.children('#hallo_img_properties');
1410
+ if (this.$image) {
1411
+ width = this.$image.is('[width]') ? this.$image.attr('width') : '';
1412
+ height = this.$image.is('[height]') ? this.$image.attr('height') : '';
1413
+ html = this._property_input_html('source', this.$image.attr('src'), {
1414
+ label: this.texts.source
1415
+ }) + this._property_input_html('alt', this.$image.attr('alt') || '', {
1416
+ label: this.texts.alt
1417
+ }) + this._property_row_html(this._property_input_html('width', width, {
1418
+ label: this.texts.width,
1419
+ row: false
1420
+ }) + this._property_input_html('height', height, {
1421
+ label: this.texts.height,
1422
+ row: false
1423
+ })) + this._property_input_html('padding', this.$image.css('padding'), {
1424
+ label: this.texts.padding
1425
+ }) + this._property_row_html(this._property_cb_html('float_left', this.$image.css('float') === 'left', {
1426
+ label: this.texts.float_left,
1427
+ row: false
1428
+ }) + this._property_cb_html('float_right', this.$image.css('float') === 'right', {
1429
+ label: this.texts.float_right,
1430
+ row: false
1431
+ }) + this._property_cb_html('unfloat', this.$image.css('float') === 'none', {
1432
+ label: this.texts.float_none,
1433
+ row: false
1434
+ }), this.texts[float]);
1435
+ $img_properties.html(html);
1436
+ $img_properties.show();
1437
+ } else {
1438
+ if (!this.options.insert_file_dialog_ui_url) {
1439
+ $img_properties.html(this._property_input_html('source', '', {
1440
+ label: this.texts.source
1441
+ }));
1442
+ $img_properties.show();
1443
+ }
1444
+ }
1445
+ if (this.$image) {
1446
+ if (!this.options.insert_file_dialog_ui_url) {
1447
+ jQuery('#insert_image_btn').remove();
1448
+ }
1449
+ if (jQuery('#hallo_img_file_select_title').length > 0) {
1450
+ jQuery('#hallo_img_file_select_title').text(this.texts.chage_image);
1451
+ }
1452
+ jQuery('#hallo_img_properties #hallo_img_source').keyup(function() {
1453
+ return widget.$image.attr('src', this.value);
1454
+ });
1455
+ jQuery('#hallo_img_properties #hallo_img_alt').keyup(function() {
1456
+ return widget.$image.attr('alt', this.value);
1457
+ });
1458
+ jQuery('#hallo_img_properties #hallo_img_padding').keyup(function() {
1459
+ return widget.$image.css('padding', this.value);
1460
+ });
1461
+ jQuery('#hallo_img_properties #hallo_img_height').keyup(function() {
1462
+ widget.$image.css('height', this.value);
1463
+ return widget.$image.attr('height', this.value);
1464
+ });
1465
+ jQuery('#hallo_img_properties #hallo_img_width').keyup(function() {
1466
+ widget.$image.css('width', this.value);
1467
+ return widget.$image.attr('width', this.value);
1468
+ });
1469
+ jQuery('#hallo_img_properties #hallo_img_float_left').click(function() {
1470
+ if (!this.checked) {
1471
+ return false;
1472
+ }
1473
+ widget.$image.css('float', 'left');
1474
+ jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
1475
+ return jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
1476
+ });
1477
+ jQuery('#hallo_img_properties #hallo_img_float_right').click(function() {
1478
+ if (!this.checked) {
1479
+ return false;
1480
+ }
1481
+ widget.$image.css('float', 'right');
1482
+ jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
1483
+ return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
1484
+ });
1485
+ return jQuery('#hallo_img_properties #hallo_img_unfloat').click(function() {
1486
+ if (!this.checked) {
1487
+ return false;
1488
+ }
1489
+ widget.$image.css('float', 'none');
1490
+ jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
1491
+ return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
1492
+ });
1493
+ } else {
1494
+ if (!this.options.insert_file_dialog_ui_url) {
1495
+ button = "<button id=\"insert_image_btn\">" + this.texts.insert + "</button>";
1496
+ $img_properties.after(button);
1497
+ return jQuery('#insert_image_btn').click(function() {
1498
+ var $img_source;
1499
+
1500
+ $img_source = jQuery('#hallo_img_properties #hallo_img_source');
1501
+ return widget._insert_image($img_source.val());
1502
+ });
1503
+ }
1504
+ }
1505
+ },
1506
+ _property_col_html: function(col_html) {
1507
+ return "<div class='hallo_img_property_col'>" + col_html + "</div>";
1508
+ },
1509
+ _property_row_html: function(row_html, label) {
1510
+ if (label == null) {
1511
+ label = '';
1512
+ }
1513
+ row_html = this._property_col_html(label) + this._property_col_html(row_html);
1514
+ return "<div class='hallo_img_property_row'>" + row_html + "</div>";
1515
+ },
1516
+ _property_html: function(property_html, options) {
1517
+ var entry;
1518
+
1519
+ if (options == null) {
1520
+ options = {};
1521
+ }
1522
+ if (options.row === false) {
1523
+ if (options.label) {
1524
+ entry = "" + options.label + " " + property_html;
1525
+ property_html = "<span class='img_property_entry'>" + entry + "</span>";
1526
+ }
1527
+ return property_html;
1528
+ } else {
1529
+ entry = "<span class='img_property_entry'>" + property_html + "</span>";
1530
+ return this._property_row_html(entry, options.label);
1531
+ }
1532
+ },
1533
+ _property_input_html: function(id, value, options) {
1534
+ var text_field;
1535
+
1536
+ if (options == null) {
1537
+ options = {};
1538
+ }
1539
+ text_field = "<input type='text' id='hallo_img_" + id + "' value='" + value + "'>";
1540
+ return this._property_html(text_field, options);
1541
+ },
1542
+ _property_cb_html: function(id, checked, options) {
1543
+ var cb, checked_attr;
1544
+
1545
+ if (options == null) {
1546
+ options = {};
1547
+ }
1548
+ checked_attr = checked ? 'checked=checked' : '';
1549
+ cb = "<input type='checkbox' id='hallo_img_" + id + "' " + checked_attr + "'>";
1550
+ return this._property_html(cb, options);
1551
+ }
1552
+ });
1553
+ })(jQuery);
1554
+
1555
+ }).call(this);
1556
+
1557
+ (function() {
1558
+ (function(jQuery) {
1559
+ return jQuery.widget('IKS.halloindicator', {
1560
+ options: {
1561
+ editable: null,
1562
+ className: 'halloEditIndicator'
1563
+ },
1564
+ _create: function() {
1565
+ var _this = this;
1566
+
1567
+ return this.element.on('halloenabled', function() {
1568
+ return _this.buildIndicator();
1569
+ });
1570
+ },
1571
+ populateToolbar: function() {},
1572
+ buildIndicator: function() {
1573
+ var editButton;
1574
+
1575
+ editButton = jQuery('<div><i class="icon-edit"></i> Edit</div>');
1576
+ editButton.addClass(this.options.className);
1577
+ editButton.hide();
1578
+ this.element.before(editButton);
1579
+ this.bindIndicator(editButton);
1580
+ return this.setIndicatorPosition(editButton);
1581
+ },
1582
+ bindIndicator: function(indicator) {
1583
+ var _this = this;
1584
+
1585
+ indicator.on('click', function() {
1586
+ return _this.options.editable.element.focus();
1587
+ });
1588
+ this.element.on('halloactivated', function() {
1589
+ return indicator.hide();
1590
+ });
1591
+ this.element.on('hallodisabled', function() {
1592
+ return indicator.remove();
1593
+ });
1594
+ return this.options.editable.element.hover(function() {
1595
+ if (jQuery(this).hasClass('inEditMode')) {
1596
+ return;
1597
+ }
1598
+ return indicator.show();
1599
+ }, function(data) {
1600
+ if (jQuery(this).hasClass('inEditMode')) {
1601
+ return;
1602
+ }
1603
+ if (data.relatedTarget === indicator.get(0)) {
1604
+ return;
1605
+ }
1606
+ return indicator.hide();
1607
+ });
1608
+ },
1609
+ setIndicatorPosition: function(indicator) {
1610
+ var offset;
1611
+
1612
+ indicator.css('position', 'absolute');
1613
+ offset = this.element.position();
1614
+ indicator.css('top', offset.top + 2);
1615
+ return indicator.css('left', offset.left + 2);
1616
+ }
1617
+ });
1618
+ })(jQuery);
1619
+
1620
+ }).call(this);
1621
+
1622
+ (function() {
1623
+ (function(jQuery) {
1624
+ return jQuery.widget("IKS.hallojustify", {
1625
+ options: {
1626
+ editable: null,
1627
+ toolbar: null,
1628
+ uuid: '',
1629
+ buttonCssClass: null
1630
+ },
1631
+ populateToolbar: function(toolbar) {
1632
+ var buttonize, buttonset,
1633
+ _this = this;
1634
+
1635
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
1636
+ buttonize = function(alignment) {
1637
+ var buttonElement;
1638
+
1639
+ buttonElement = jQuery('<span></span>');
1640
+ buttonElement.hallobutton({
1641
+ uuid: _this.options.uuid,
1642
+ editable: _this.options.editable,
1643
+ label: alignment,
1644
+ command: "justify" + alignment,
1645
+ icon: "icon-align-" + (alignment.toLowerCase()),
1646
+ cssClass: _this.options.buttonCssClass
1647
+ });
1648
+ return buttonset.append(buttonElement);
1649
+ };
1650
+ buttonize("Left");
1651
+ buttonize("Center");
1652
+ buttonize("Right");
1653
+ buttonset.hallobuttonset();
1654
+ return toolbar.append(buttonset);
1655
+ }
1656
+ });
1657
+ })(jQuery);
1658
+
1659
+ }).call(this);
1660
+
1661
+ (function() {
1662
+ (function(jQuery) {
1663
+ return jQuery.widget("IKS.hallolink", {
1664
+ options: {
1665
+ editable: null,
1666
+ uuid: "",
1667
+ link: true,
1668
+ image: true,
1669
+ defaultUrl: 'http://',
1670
+ dialogOpts: {
1671
+ autoOpen: false,
1672
+ width: 540,
1673
+ height: 95,
1674
+ title: "Enter Link",
1675
+ buttonTitle: "Insert",
1676
+ buttonUpdateTitle: "Update",
1677
+ modal: true,
1678
+ resizable: false,
1679
+ draggable: false,
1680
+ dialogClass: 'hallolink-dialog'
1681
+ },
1682
+ buttonCssClass: null
1683
+ },
1684
+ populateToolbar: function(toolbar) {
1685
+ var butTitle, butUpdateTitle, buttonize, buttonset, dialog, dialogId, dialogSubmitCb, isEmptyLink, urlInput, widget,
1686
+ _this = this;
1687
+
1688
+ widget = this;
1689
+ dialogId = "" + this.options.uuid + "-dialog";
1690
+ butTitle = this.options.dialogOpts.buttonTitle;
1691
+ butUpdateTitle = this.options.dialogOpts.buttonUpdateTitle;
1692
+ 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>");
1693
+ urlInput = jQuery('input[name=url]', dialog).focus(function(e) {
1694
+ return this.select();
1695
+ });
1696
+ isEmptyLink = function(link) {
1697
+ if ((new RegExp(/^\s*$/)).test(link)) {
1698
+ return true;
1699
+ }
1700
+ if (link === widget.options.defaultUrl) {
1701
+ return true;
1702
+ }
1703
+ return false;
1704
+ };
1705
+ dialogSubmitCb = function(event) {
1706
+ var link, linkNode;
1707
+
1708
+ event.preventDefault();
1709
+ link = urlInput.val();
1710
+ dialog.dialog('close');
1711
+ widget.options.editable.restoreSelection(widget.lastSelection);
1712
+ if (isEmptyLink(link)) {
1713
+ document.execCommand("unlink", null, "");
1714
+ } else {
1715
+ if (!(/:\/\//.test(link)) && !(/^mailto:/.test(link))) {
1716
+ link = 'http://' + link;
1717
+ }
1718
+ if (widget.lastSelection.startContainer.parentNode.href === void 0) {
1719
+ if (widget.lastSelection.collapsed) {
1720
+ linkNode = jQuery("<a href='" + link + "'>" + link + "</a>")[0];
1721
+ widget.lastSelection.insertNode(linkNode);
1722
+ } else {
1723
+ document.execCommand("createLink", null, link);
1724
+ }
1725
+ } else {
1726
+ widget.lastSelection.startContainer.parentNode.href = link;
1727
+ }
1728
+ }
1729
+ widget.options.editable.element.trigger('change');
1730
+ return false;
1731
+ };
1732
+ dialog.find("input[type=submit]").click(dialogSubmitCb);
1733
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
1734
+ buttonize = function(type) {
1735
+ var button, buttonHolder, id;
1736
+
1737
+ id = "" + _this.options.uuid + "-" + type;
1738
+ buttonHolder = jQuery('<span></span>');
1739
+ buttonHolder.hallobutton({
1740
+ label: 'Link',
1741
+ icon: 'icon-link',
1742
+ editable: _this.options.editable,
1743
+ command: null,
1744
+ queryState: false,
1745
+ uuid: _this.options.uuid,
1746
+ cssClass: _this.options.buttonCssClass
1747
+ });
1748
+ buttonset.append(buttonHolder);
1749
+ button = buttonHolder;
1750
+ button.on("click", function(event) {
1751
+ var button_selector, selectionParent;
1752
+
1753
+ widget.lastSelection = widget.options.editable.getSelection();
1754
+ urlInput = jQuery('input[name=url]', dialog);
1755
+ selectionParent = widget.lastSelection.startContainer.parentNode;
1756
+ if (!selectionParent.href) {
1757
+ urlInput.val(widget.options.defaultUrl);
1758
+ jQuery(urlInput[0].form).find('input[type=submit]').val(butTitle);
1759
+ } else {
1760
+ urlInput.val(jQuery(selectionParent).attr('href'));
1761
+ button_selector = 'input[type=submit]';
1762
+ jQuery(urlInput[0].form).find(button_selector).val(butUpdateTitle);
1763
+ }
1764
+ widget.options.editable.keepActivated(true);
1765
+ dialog.dialog('open');
1766
+ dialog.on('dialogclose', function() {
1767
+ widget.options.editable.restoreSelection(widget.lastSelection);
1768
+ jQuery('label', buttonHolder).removeClass('ui-state-active');
1769
+ widget.options.editable.element.focus();
1770
+ return widget.options.editable.keepActivated(false);
1771
+ });
1772
+ return false;
1773
+ });
1774
+ return _this.element.on("keyup paste change mouseup", function(event) {
1775
+ var nodeName, start;
1776
+
1777
+ start = jQuery(widget.options.editable.getSelection().startContainer);
1778
+ if (start.prop('nodeName')) {
1779
+ nodeName = start.prop('nodeName');
1780
+ } else {
1781
+ nodeName = start.parent().prop('nodeName');
1782
+ }
1783
+ if (nodeName && nodeName.toUpperCase() === "A") {
1784
+ jQuery('label', button).addClass('ui-state-active');
1785
+ return;
1786
+ }
1787
+ return jQuery('label', button).removeClass('ui-state-active');
1788
+ });
1789
+ };
1790
+ if (this.options.link) {
1791
+ buttonize("A");
1792
+ }
1793
+ if (this.options.link) {
1794
+ toolbar.append(buttonset);
1795
+ buttonset.hallobuttonset();
1796
+ return dialog.dialog(this.options.dialogOpts);
1797
+ }
1798
+ }
1799
+ });
1800
+ })(jQuery);
1801
+
1802
+ }).call(this);
1803
+
1804
+ (function() {
1805
+ (function(jQuery) {
1806
+ return jQuery.widget("IKS.hallolists", {
1807
+ options: {
1808
+ editable: null,
1809
+ toolbar: null,
1810
+ uuid: '',
1811
+ lists: {
1812
+ ordered: true,
1813
+ unordered: true
1814
+ },
1815
+ buttonCssClass: null
1816
+ },
1817
+ populateToolbar: function(toolbar) {
1818
+ var buttonize, buttonset,
1819
+ _this = this;
1820
+
1821
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
1822
+ buttonize = function(type, label) {
1823
+ var buttonElement;
1824
+
1825
+ buttonElement = jQuery('<span></span>');
1826
+ buttonElement.hallobutton({
1827
+ uuid: _this.options.uuid,
1828
+ editable: _this.options.editable,
1829
+ label: label,
1830
+ command: "insert" + type + "List",
1831
+ icon: "icon-list-" + (label.toLowerCase()),
1832
+ cssClass: _this.options.buttonCssClass
1833
+ });
1834
+ return buttonset.append(buttonElement);
1835
+ };
1836
+ if (this.options.lists.ordered) {
1837
+ buttonize("Ordered", "OL");
1838
+ }
1839
+ if (this.options.lists.unordered) {
1840
+ buttonize("Unordered", "UL");
1841
+ }
1842
+ buttonset.hallobuttonset();
1843
+ return toolbar.append(buttonset);
1844
+ }
1845
+ });
1846
+ })(jQuery);
1847
+
1848
+ }).call(this);
1849
+
1850
+ (function() {
1851
+ (function(jQuery) {
1852
+ return jQuery.widget("Liip.hallooverlay", {
1853
+ options: {
1854
+ editable: null,
1855
+ toolbar: null,
1856
+ uuid: "",
1857
+ overlay: null,
1858
+ padding: 10,
1859
+ background: null
1860
+ },
1861
+ _create: function() {
1862
+ var widget;
1863
+
1864
+ widget = this;
1865
+ if (!this.options.bound) {
1866
+ this.options.bound = true;
1867
+ this.options.editable.element.on("halloactivated", function(event, data) {
1868
+ widget.options.currentEditable = jQuery(event.target);
1869
+ if (!widget.options.visible) {
1870
+ return widget.showOverlay();
1871
+ }
1872
+ });
1873
+ this.options.editable.element.on("hallomodified", function(event, data) {
1874
+ widget.options.currentEditable = jQuery(event.target);
1875
+ if (widget.options.visible) {
1876
+ return widget.resizeOverlay();
1877
+ }
1878
+ });
1879
+ return this.options.editable.element.on("hallodeactivated", function(event, data) {
1880
+ widget.options.currentEditable = jQuery(event.target);
1881
+ if (widget.options.visible) {
1882
+ return widget.hideOverlay();
1883
+ }
1884
+ });
1885
+ }
1886
+ },
1887
+ showOverlay: function() {
1888
+ this.options.visible = true;
1889
+ if (this.options.overlay === null) {
1890
+ if (jQuery("#halloOverlay").length > 0) {
1891
+ this.options.overlay = jQuery("#halloOverlay");
1892
+ } else {
1893
+ this.options.overlay = jQuery("<div id=\"halloOverlay\" class=\"halloOverlay\">");
1894
+ jQuery(document.body).append(this.options.overlay);
1895
+ }
1896
+ this.options.overlay.on('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable));
1897
+ }
1898
+ this.options.overlay.show();
1899
+ if (this.options.background === null) {
1900
+ if (jQuery("#halloBackground").length > 0) {
1901
+ this.options.background = jQuery("#halloBackground");
1902
+ } else {
1903
+ this.options.background = jQuery("<div id=\"halloBackground\" class=\"halloBackground\">");
1904
+ jQuery(document.body).append(this.options.background);
1905
+ }
1906
+ }
1907
+ this.resizeOverlay();
1908
+ this.options.background.show();
1909
+ if (!this.options.originalZIndex) {
1910
+ this.options.originalZIndex = this.options.currentEditable.css("z-index");
1911
+ }
1912
+ return this.options.currentEditable.css('z-index', '350');
1913
+ },
1914
+ resizeOverlay: function() {
1915
+ var offset;
1916
+
1917
+ offset = this.options.currentEditable.offset();
1918
+ return this.options.background.css({
1919
+ top: offset.top - this.options.padding,
1920
+ left: offset.left - this.options.padding,
1921
+ width: this.options.currentEditable.width() + 2 * this.options.padding,
1922
+ height: this.options.currentEditable.height() + 2 * this.options.padding
1923
+ });
1924
+ },
1925
+ hideOverlay: function() {
1926
+ this.options.visible = false;
1927
+ this.options.overlay.hide();
1928
+ this.options.background.hide();
1929
+ return this.options.currentEditable.css('z-index', this.options.originalZIndex);
1930
+ },
1931
+ _findBackgroundColor: function(jQueryfield) {
1932
+ var color;
1933
+
1934
+ color = jQueryfield.css("background-color");
1935
+ if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') {
1936
+ return color;
1937
+ }
1938
+ if (jQueryfield.is("body")) {
1939
+ return "white";
1940
+ } else {
1941
+ return this._findBackgroundColor(jQueryfield.parent());
1942
+ }
1943
+ }
1944
+ });
1945
+ })(jQuery);
1946
+
1947
+ }).call(this);
1948
+
1949
+ (function() {
1950
+ (function(jQuery) {
1951
+ return jQuery.widget("IKS.halloreundo", {
1952
+ options: {
1953
+ editable: null,
1954
+ toolbar: null,
1955
+ uuid: '',
1956
+ buttonCssClass: null
1957
+ },
1958
+ populateToolbar: function(toolbar) {
1959
+ var buttonize, buttonset,
1960
+ _this = this;
1961
+
1962
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
1963
+ buttonize = function(cmd, label) {
1964
+ var buttonElement;
1965
+
1966
+ buttonElement = jQuery('<span></span>');
1967
+ buttonElement.hallobutton({
1968
+ uuid: _this.options.uuid,
1969
+ editable: _this.options.editable,
1970
+ label: label,
1971
+ icon: cmd === 'undo' ? 'icon-undo' : 'icon-repeat',
1972
+ command: cmd,
1973
+ queryState: false,
1974
+ cssClass: _this.options.buttonCssClass
1975
+ });
1976
+ return buttonset.append(buttonElement);
1977
+ };
1978
+ buttonize("undo", "Undo");
1979
+ buttonize("redo", "Redo");
1980
+ buttonset.hallobuttonset();
1981
+ return toolbar.append(buttonset);
1982
+ }
1983
+ });
1984
+ })(jQuery);
1985
+
1986
+ }).call(this);
1987
+
1988
+ (function() {
1989
+ (function(jQuery) {
1990
+ return jQuery.widget("Liip.hallotoolbarlinebreak", {
1991
+ options: {
1992
+ editable: null,
1993
+ uuid: "",
1994
+ breakAfter: []
1995
+ },
1996
+ populateToolbar: function(toolbar) {
1997
+ var buttonRow, buttonset, buttonsets, queuedButtonsets, row, rowcounter, _i, _j, _len, _len1, _ref;
1998
+
1999
+ buttonsets = jQuery('.ui-buttonset', toolbar);
2000
+ queuedButtonsets = jQuery();
2001
+ rowcounter = 0;
2002
+ _ref = this.options.breakAfter;
2003
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2004
+ row = _ref[_i];
2005
+ rowcounter++;
2006
+ buttonRow = "<div class=\"halloButtonrow halloButtonrow-" + rowcounter + "\" />";
2007
+ for (_j = 0, _len1 = buttonsets.length; _j < _len1; _j++) {
2008
+ buttonset = buttonsets[_j];
2009
+ queuedButtonsets = jQuery(queuedButtonsets).add(jQuery(buttonset));
2010
+ if (jQuery(buttonset).hasClass(row)) {
2011
+ queuedButtonsets.wrapAll(buttonRow);
2012
+ buttonsets = buttonsets.not(queuedButtonsets);
2013
+ queuedButtonsets = jQuery();
2014
+ break;
2015
+ }
2016
+ }
2017
+ }
2018
+ if (buttonsets.length > 0) {
2019
+ rowcounter++;
2020
+ buttonRow = "<div class=\"halloButtonrow halloButtonrow-" + rowcounter + "\" />";
2021
+ return buttonsets.wrapAll(buttonRow);
2022
+ }
2023
+ }
2024
+ });
2025
+ })(jQuery);
2026
+
2027
+ }).call(this);
2028
+
2029
+ (function() {
2030
+ (function(jQuery) {
2031
+ return jQuery.widget('IKS.halloToolbarContextual', {
2032
+ toolbar: null,
2033
+ options: {
2034
+ parentElement: 'body',
2035
+ editable: null,
2036
+ toolbar: null,
2037
+ positionAbove: false
2038
+ },
2039
+ _create: function() {
2040
+ var _this = this;
2041
+
2042
+ this.toolbar = this.options.toolbar;
2043
+ jQuery(this.options.parentElement).append(this.toolbar);
2044
+ this._bindEvents();
2045
+ return jQuery(window).resize(function(event) {
2046
+ return _this._updatePosition(_this._getPosition(event));
2047
+ });
2048
+ },
2049
+ _getPosition: function(event, selection) {
2050
+ var eventType, position;
2051
+
2052
+ if (!event) {
2053
+ return;
2054
+ }
2055
+ eventType = event.type;
2056
+ switch (eventType) {
2057
+ case 'keydown':
2058
+ case 'keyup':
2059
+ case 'keypress':
2060
+ return this._getCaretPosition(selection);
2061
+ case 'click':
2062
+ case 'mousedown':
2063
+ case 'mouseup':
2064
+ return position = {
2065
+ top: event.pageY,
2066
+ left: event.pageX
2067
+ };
2068
+ }
2069
+ },
2070
+ _getCaretPosition: function(range) {
2071
+ var newRange, position, tmpSpan;
2072
+
2073
+ tmpSpan = jQuery("<span/>");
2074
+ newRange = rangy.createRange();
2075
+ newRange.setStart(range.endContainer, range.endOffset);
2076
+ newRange.insertNode(tmpSpan.get(0));
2077
+ position = {
2078
+ top: tmpSpan.offset().top,
2079
+ left: tmpSpan.offset().left
2080
+ };
2081
+ tmpSpan.remove();
2082
+ return position;
2083
+ },
2084
+ setPosition: function() {
2085
+ if (this.options.parentElement !== 'body') {
2086
+ this.options.parentElement = 'body';
2087
+ jQuery(this.options.parentElement).append(this.toolbar);
2088
+ }
2089
+ this.toolbar.css('position', 'absolute');
2090
+ this.toolbar.css('top', this.element.offset().top - 20);
2091
+ return this.toolbar.css('left', this.element.offset().left);
2092
+ },
2093
+ _updatePosition: function(position, selection) {
2094
+ var left, selectionRect, toolbar_height_offset, top, top_offset;
2095
+
2096
+ if (selection == null) {
2097
+ selection = null;
2098
+ }
2099
+ if (!position) {
2100
+ return;
2101
+ }
2102
+ if (!(position.top && position.left)) {
2103
+ return;
2104
+ }
2105
+ toolbar_height_offset = this.toolbar.outerHeight() + 10;
2106
+ if (selection && !selection.collapsed && selection.nativeRange) {
2107
+ selectionRect = selection.nativeRange.getBoundingClientRect();
2108
+ if (this.options.positionAbove) {
2109
+ top_offset = selectionRect.top - toolbar_height_offset;
2110
+ } else {
2111
+ top_offset = selectionRect.bottom + 10;
2112
+ }
2113
+ top = jQuery(window).scrollTop() + top_offset;
2114
+ left = jQuery(window).scrollLeft() + selectionRect.left;
2115
+ } else {
2116
+ if (this.options.positionAbove) {
2117
+ top_offset = -10 - toolbar_height_offset;
2118
+ } else {
2119
+ top_offset = 20;
2120
+ }
2121
+ top = position.top + top_offset;
2122
+ left = position.left - this.toolbar.outerWidth() / 2 + 30;
2123
+ }
2124
+ this.toolbar.css('top', top);
2125
+ return this.toolbar.css('left', left);
2126
+ },
2127
+ _bindEvents: function() {
2128
+ var _this = this;
2129
+
2130
+ this.element.on('halloselected', function(event, data) {
2131
+ var position;
2132
+
2133
+ position = _this._getPosition(data.originalEvent, data.selection);
2134
+ if (!position) {
2135
+ return;
2136
+ }
2137
+ _this._updatePosition(position, data.selection);
2138
+ if (_this.toolbar.html() !== '') {
2139
+ return _this.toolbar.show();
2140
+ }
2141
+ });
2142
+ this.element.on('hallounselected', function(event, data) {
2143
+ return _this.toolbar.hide();
2144
+ });
2145
+ return this.element.on('hallodeactivated', function(event, data) {
2146
+ return _this.toolbar.hide();
2147
+ });
2148
+ }
2149
+ });
2150
+ })(jQuery);
2151
+
2152
+ }).call(this);
2153
+
2154
+ (function() {
2155
+ (function(jQuery) {
2156
+ return jQuery.widget('IKS.halloToolbarFixed', {
2157
+ toolbar: null,
2158
+ options: {
2159
+ parentElement: 'body',
2160
+ editable: null,
2161
+ toolbar: null,
2162
+ affix: true,
2163
+ affixTopOffset: 2
2164
+ },
2165
+ _create: function() {
2166
+ var el, widthToAdd,
2167
+ _this = this;
2168
+
2169
+ this.toolbar = this.options.toolbar;
2170
+ this.toolbar.show();
2171
+ jQuery(this.options.parentElement).append(this.toolbar);
2172
+ this._bindEvents();
2173
+ jQuery(window).resize(function(event) {
2174
+ return _this.setPosition();
2175
+ });
2176
+ jQuery(window).scroll(function(event) {
2177
+ return _this.setPosition();
2178
+ });
2179
+ if (this.options.parentElement === 'body') {
2180
+ el = jQuery(this.element);
2181
+ widthToAdd = parseFloat(el.css('padding-left'));
2182
+ widthToAdd += parseFloat(el.css('padding-right'));
2183
+ widthToAdd += parseFloat(el.css('border-left-width'));
2184
+ widthToAdd += parseFloat(el.css('border-right-width'));
2185
+ widthToAdd += (parseFloat(el.css('outline-width'))) * 2;
2186
+ widthToAdd += (parseFloat(el.css('outline-offset'))) * 2;
2187
+ return jQuery(this.toolbar).css("width", el.width() + widthToAdd);
2188
+ }
2189
+ },
2190
+ _getPosition: function(event, selection) {
2191
+ var offset, position, width;
2192
+
2193
+ if (!event) {
2194
+ return;
2195
+ }
2196
+ width = parseFloat(this.element.css('outline-width'));
2197
+ offset = width + parseFloat(this.element.css('outline-offset'));
2198
+ return position = {
2199
+ top: this.element.offset().top - this.toolbar.outerHeight() - offset,
2200
+ left: this.element.offset().left - offset
2201
+ };
2202
+ },
2203
+ _getCaretPosition: function(range) {
2204
+ var newRange, position, tmpSpan;
2205
+
2206
+ tmpSpan = jQuery("<span/>");
2207
+ newRange = rangy.createRange();
2208
+ newRange.setStart(range.endContainer, range.endOffset);
2209
+ newRange.insertNode(tmpSpan.get(0));
2210
+ position = {
2211
+ top: tmpSpan.offset().top,
2212
+ left: tmpSpan.offset().left
2213
+ };
2214
+ tmpSpan.remove();
2215
+ return position;
2216
+ },
2217
+ setPosition: function() {
2218
+ var elementBottom, elementTop, height, offset, scrollTop, topOffset;
2219
+
2220
+ if (this.options.parentElement !== 'body') {
2221
+ return;
2222
+ }
2223
+ this.toolbar.css('position', 'absolute');
2224
+ this.toolbar.css('top', this.element.offset().top - this.toolbar.outerHeight());
2225
+ if (this.options.affix) {
2226
+ scrollTop = jQuery(window).scrollTop();
2227
+ offset = this.element.offset();
2228
+ height = this.element.height();
2229
+ topOffset = this.options.affixTopOffset;
2230
+ elementTop = offset.top - (this.toolbar.height() + this.options.affixTopOffset);
2231
+ elementBottom = (height - topOffset) + (offset.top - this.toolbar.height());
2232
+ if (scrollTop > elementTop && scrollTop < elementBottom) {
2233
+ this.toolbar.css('position', 'fixed');
2234
+ this.toolbar.css('top', this.options.affixTopOffset);
2235
+ }
2236
+ } else {
2237
+
2238
+ }
2239
+ return this.toolbar.css('left', this.element.offset().left - 2);
2240
+ },
2241
+ _updatePosition: function(position) {},
2242
+ _bindEvents: function() {
2243
+ var _this = this;
2244
+
2245
+ this.element.on('halloactivated', function(event, data) {
2246
+ _this.setPosition();
2247
+ return _this.toolbar.show();
2248
+ });
2249
+ return this.element.on('hallodeactivated', function(event, data) {
2250
+ return _this.toolbar.hide();
2251
+ });
2252
+ }
2253
+ });
2254
+ })(jQuery);
2255
+
2256
+ }).call(this);
2257
+
2258
+ (function() {
2259
+ (function(jQuery) {
2260
+ jQuery.widget('IKS.hallobutton', {
2261
+ button: null,
2262
+ isChecked: false,
2263
+ options: {
2264
+ uuid: '',
2265
+ label: null,
2266
+ icon: null,
2267
+ editable: null,
2268
+ command: null,
2269
+ commandValue: null,
2270
+ queryState: true,
2271
+ cssClass: null
2272
+ },
2273
+ _create: function() {
2274
+ var hoverclass, id, opts, _base, _ref,
2275
+ _this = this;
2276
+
2277
+ if ((_ref = (_base = this.options).icon) == null) {
2278
+ _base.icon = "icon-" + (this.options.label.toLowerCase());
2279
+ }
2280
+ id = "" + this.options.uuid + "-" + this.options.label;
2281
+ opts = this.options;
2282
+ this.button = this._createButton(id, opts.command, opts.label, opts.icon);
2283
+ this.element.append(this.button);
2284
+ if (this.options.cssClass) {
2285
+ this.button.addClass(this.options.cssClass);
2286
+ }
2287
+ if (this.options.editable.options.touchScreen) {
2288
+ this.button.addClass('btn-large');
2289
+ }
2290
+ this.button.data('hallo-command', this.options.command);
2291
+ if (this.options.commandValue) {
2292
+ this.button.data('hallo-command-value', this.options.commandValue);
2293
+ }
2294
+ hoverclass = 'ui-state-hover';
2295
+ this.button.on('mouseenter', function(event) {
2296
+ if (_this.isEnabled()) {
2297
+ return _this.button.addClass(hoverclass);
2298
+ }
2299
+ });
2300
+ return this.button.on('mouseleave', function(event) {
2301
+ return _this.button.removeClass(hoverclass);
2302
+ });
2303
+ },
2304
+ _init: function() {
2305
+ var editableElement, events, queryState,
2306
+ _this = this;
2307
+
2308
+ if (!this.button) {
2309
+ this.button = this._prepareButton();
2310
+ }
2311
+ this.element.append(this.button);
2312
+ if (this.options.queryState === true) {
2313
+ queryState = function(event) {
2314
+ var compared, e, value;
2315
+
2316
+ if (!_this.options.command) {
2317
+ return;
2318
+ }
2319
+ try {
2320
+ if (_this.options.commandValue) {
2321
+ value = document.queryCommandValue(_this.options.command);
2322
+ compared = value.match(new RegExp(_this.options.commandValue, "i"));
2323
+ return _this.checked(compared ? true : false);
2324
+ } else {
2325
+ return _this.checked(document.queryCommandState(_this.options.command));
2326
+ }
2327
+ } catch (_error) {
2328
+ e = _error;
2329
+ }
2330
+ };
2331
+ } else {
2332
+ queryState = this.options.queryState;
2333
+ }
2334
+ if (this.options.command) {
2335
+ this.button.on('click', function(event) {
2336
+ if (_this.options.commandValue) {
2337
+ _this.options.editable.execute(_this.options.command, _this.options.commandValue);
2338
+ } else {
2339
+ _this.options.editable.execute(_this.options.command);
2340
+ }
2341
+ queryState();
2342
+ return false;
2343
+ });
2344
+ }
2345
+ if (!this.options.queryState) {
2346
+ return;
2347
+ }
2348
+ editableElement = this.options.editable.element;
2349
+ events = 'keyup paste change mouseup hallomodified';
2350
+ editableElement.on(events, queryState);
2351
+ editableElement.on('halloenabled', function() {
2352
+ return editableElement.on(events, queryState);
2353
+ });
2354
+ return editableElement.on('hallodisabled', function() {
2355
+ return editableElement.off(events, queryState);
2356
+ });
2357
+ },
2358
+ enable: function() {
2359
+ return this.button.removeAttr('disabled');
2360
+ },
2361
+ disable: function() {
2362
+ return this.button.attr('disabled', 'true');
2363
+ },
2364
+ isEnabled: function() {
2365
+ return this.button.attr('disabled') !== 'true';
2366
+ },
2367
+ refresh: function() {
2368
+ if (this.isChecked) {
2369
+ return this.button.addClass('ui-state-active');
2370
+ } else {
2371
+ return this.button.removeClass('ui-state-active');
2372
+ }
2373
+ },
2374
+ checked: function(checked) {
2375
+ this.isChecked = checked;
2376
+ return this.refresh();
2377
+ },
2378
+ _createButton: function(id, command, label, icon) {
2379
+ var classes;
2380
+
2381
+ classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only', "" + command + "_button"];
2382
+ return jQuery("<button id=\"" + id + "\" class=\"" + (classes.join(' ')) + "\" title=\"" + label + "\"> <span class=\"ui-button-text\"> <i class=\"" + icon + "\"></i> </span> </button>");
2383
+ }
2384
+ });
2385
+ return jQuery.widget('IKS.hallobuttonset', {
2386
+ buttons: null,
2387
+ _create: function() {
2388
+ return this.element.addClass('ui-buttonset');
2389
+ },
2390
+ _init: function() {
2391
+ return this.refresh();
2392
+ },
2393
+ refresh: function() {
2394
+ var rtl;
2395
+
2396
+ rtl = this.element.css('direction') === 'rtl';
2397
+ this.buttons = this.element.find('.ui-button');
2398
+ this.buttons.removeClass('ui-corner-all ui-corner-left ui-corner-right');
2399
+ if (rtl) {
2400
+ this.buttons.filter(':first').addClass('ui-corner-right');
2401
+ return this.buttons.filter(':last').addClass('ui-corner-left');
2402
+ } else {
2403
+ this.buttons.filter(':first').addClass('ui-corner-left');
2404
+ return this.buttons.filter(':last').addClass('ui-corner-right');
2405
+ }
2406
+ }
2407
+ });
2408
+ })(jQuery);
2409
+
2410
+ }).call(this);
2411
+
2412
+ (function() {
2413
+ (function(jQuery) {
2414
+ return jQuery.widget('IKS.hallodropdownbutton', {
2415
+ button: null,
2416
+ options: {
2417
+ uuid: '',
2418
+ label: null,
2419
+ icon: null,
2420
+ editable: null,
2421
+ target: '',
2422
+ cssClass: null
2423
+ },
2424
+ _create: function() {
2425
+ var _base, _ref;
2426
+
2427
+ return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "icon-" + (this.options.label.toLowerCase());
2428
+ },
2429
+ _init: function() {
2430
+ var target,
2431
+ _this = this;
2432
+
2433
+ target = jQuery(this.options.target);
2434
+ target.css('position', 'absolute');
2435
+ target.addClass('dropdown-menu');
2436
+ target.hide();
2437
+ if (!this.button) {
2438
+ this.button = this._prepareButton();
2439
+ }
2440
+ this.button.on('click', function() {
2441
+ if (target.hasClass('open')) {
2442
+ _this._hideTarget();
2443
+ return;
2444
+ }
2445
+ return _this._showTarget();
2446
+ });
2447
+ target.on('click', function() {
2448
+ return _this._hideTarget();
2449
+ });
2450
+ this.options.editable.element.on('hallodeactivated', function() {
2451
+ return _this._hideTarget();
2452
+ });
2453
+ return this.element.append(this.button);
2454
+ },
2455
+ _showTarget: function() {
2456
+ var target;
2457
+
2458
+ target = jQuery(this.options.target);
2459
+ this._updateTargetPosition();
2460
+ target.addClass('open');
2461
+ return target.show();
2462
+ },
2463
+ _hideTarget: function() {
2464
+ var target;
2465
+
2466
+ target = jQuery(this.options.target);
2467
+ target.removeClass('open');
2468
+ return target.hide();
2469
+ },
2470
+ _updateTargetPosition: function() {
2471
+ var left, target, top, _ref;
2472
+
2473
+ target = jQuery(this.options.target);
2474
+ _ref = this.button.position(), top = _ref.top, left = _ref.left;
2475
+ top += this.button.outerHeight();
2476
+ target.css('top', top);
2477
+ return target.css('left', left - 20);
2478
+ },
2479
+ _prepareButton: function() {
2480
+ var buttonEl, classes, id;
2481
+
2482
+ id = "" + this.options.uuid + "-" + this.options.label;
2483
+ classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only'];
2484
+ 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>");
2485
+ if (this.options.cssClass) {
2486
+ buttonEl.addClass(this.options.cssClass);
2487
+ }
2488
+ return buttonEl;
2489
+ }
2490
+ });
2491
+ })(jQuery);
2492
+
2493
+ }).call(this);