hallo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +18 -0
- data/Rakefile +33 -0
- data/lib/hallo.rb +7 -0
- data/lib/hallo/version.rb +3 -0
- data/lib/tasks/hallo_tasks.rake +4 -0
- data/test/hallo_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/vendor/assets/javascripts/hallo.js +1853 -0
- metadata +120 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
hallo.js web editor for Rails
|
2
|
+
==========================
|
3
|
+
|
4
|
+
http://hallojs.org/
|
5
|
+
|
6
|
+
https://github.com/bergie/hallo
|
7
|
+
|
8
|
+
gem "hallo"
|
9
|
+
|
10
|
+
//= require hallo
|
11
|
+
|
12
|
+
This gem also includes [font-awesome-rails](https://github.com/bokmann/font-awesome-rails) and [jquery-ui-themes-rails](https://github.com/fatdude/jquery-ui-themes-rails)
|
13
|
+
|
14
|
+
*= require font-awesome
|
15
|
+
|
16
|
+
*= require jquery-ui/THEME-NAME
|
17
|
+
|
18
|
+
Rails 3.1 and higher, or anything that uses the asset pipeline.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Hallo'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
task :default => :test
|
data/lib/hallo.rb
ADDED
data/test/hallo_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
@@ -0,0 +1,1853 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.1
|
2
|
+
|
3
|
+
/*
|
4
|
+
Hallo 1.0.0 - a rich text editing jQuery UI widget
|
5
|
+
(c) 2011 Henri Bergius, IKS Consortium
|
6
|
+
Hallo may be freely distributed under the MIT license
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
(function() {
|
11
|
+
|
12
|
+
(function(jQuery) {
|
13
|
+
return jQuery.widget("IKS.hallo", {
|
14
|
+
toolbar: null,
|
15
|
+
toolbarMoved: false,
|
16
|
+
bound: false,
|
17
|
+
originalContent: "",
|
18
|
+
uuid: "",
|
19
|
+
selection: null,
|
20
|
+
options: {
|
21
|
+
editable: true,
|
22
|
+
plugins: {},
|
23
|
+
floating: true,
|
24
|
+
offset: {
|
25
|
+
x: 0,
|
26
|
+
y: 0
|
27
|
+
},
|
28
|
+
fixed: false,
|
29
|
+
showAlways: false,
|
30
|
+
activated: function() {},
|
31
|
+
deactivated: function() {},
|
32
|
+
selected: function() {},
|
33
|
+
unselected: function() {},
|
34
|
+
enabled: function() {},
|
35
|
+
disabled: function() {},
|
36
|
+
placeholder: '',
|
37
|
+
parentElement: 'body',
|
38
|
+
forceStructured: true,
|
39
|
+
buttonCssClass: null
|
40
|
+
},
|
41
|
+
_create: function() {
|
42
|
+
var options, plugin, _ref, _results;
|
43
|
+
this.originalContent = this.getContents();
|
44
|
+
this.id = this._generateUUID();
|
45
|
+
this._prepareToolbar();
|
46
|
+
_ref = this.options.plugins;
|
47
|
+
_results = [];
|
48
|
+
for (plugin in _ref) {
|
49
|
+
options = _ref[plugin];
|
50
|
+
if (!jQuery.isPlainObject(options)) {
|
51
|
+
options = {};
|
52
|
+
}
|
53
|
+
options['editable'] = this;
|
54
|
+
options['toolbar'] = this.toolbar;
|
55
|
+
options['uuid'] = this.id;
|
56
|
+
options['buttonCssClass'] = this.options.buttonCssClass;
|
57
|
+
_results.push(jQuery(this.element)[plugin](options));
|
58
|
+
}
|
59
|
+
return _results;
|
60
|
+
},
|
61
|
+
_init: function() {
|
62
|
+
this._setToolbarPosition();
|
63
|
+
if (this.options.editable) {
|
64
|
+
return this.enable();
|
65
|
+
} else {
|
66
|
+
return this.disable();
|
67
|
+
}
|
68
|
+
},
|
69
|
+
disable: function() {
|
70
|
+
this.element.attr("contentEditable", false);
|
71
|
+
this.element.unbind("focus", this._activated);
|
72
|
+
this.element.unbind("blur", this._deactivated);
|
73
|
+
this.element.unbind("keyup paste change", this._checkModified);
|
74
|
+
this.element.unbind("keyup", this._keys);
|
75
|
+
this.element.unbind("keyup mouseup", this._checkSelection);
|
76
|
+
this.bound = false;
|
77
|
+
return this._trigger("disabled", null);
|
78
|
+
},
|
79
|
+
enable: function() {
|
80
|
+
var widget;
|
81
|
+
this.element.attr("contentEditable", true);
|
82
|
+
if (!this.element.html()) {
|
83
|
+
this.element.html(this.options.placeholder);
|
84
|
+
}
|
85
|
+
if (!this.bound) {
|
86
|
+
this.element.bind("focus", this, this._activated);
|
87
|
+
this.element.bind("blur", this, this._deactivated);
|
88
|
+
this.element.bind("keyup paste change", this, this._checkModified);
|
89
|
+
this.element.bind("keyup", this, this._keys);
|
90
|
+
this.element.bind("keyup mouseup", this, this._checkSelection);
|
91
|
+
widget = this;
|
92
|
+
this.bound = true;
|
93
|
+
}
|
94
|
+
if (this.options.forceStructured) {
|
95
|
+
this._forceStructured();
|
96
|
+
}
|
97
|
+
return this._trigger("enabled", null);
|
98
|
+
},
|
99
|
+
activate: function() {
|
100
|
+
return this.element.focus();
|
101
|
+
},
|
102
|
+
getSelection: function() {
|
103
|
+
var range, userSelection;
|
104
|
+
if (jQuery.browser.msie) {
|
105
|
+
range = document.selection.createRange();
|
106
|
+
} else {
|
107
|
+
if (window.getSelection) {
|
108
|
+
userSelection = window.getSelection();
|
109
|
+
} else if (document.selection) {
|
110
|
+
userSelection = document.selection.createRange();
|
111
|
+
} else {
|
112
|
+
throw "Your browser does not support selection handling";
|
113
|
+
}
|
114
|
+
if (userSelection.rangeCount > 0) {
|
115
|
+
range = userSelection.getRangeAt(0);
|
116
|
+
} else {
|
117
|
+
range = userSelection;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
return range;
|
121
|
+
},
|
122
|
+
restoreSelection: function(range) {
|
123
|
+
if (jQuery.browser.msie) {
|
124
|
+
return range.select();
|
125
|
+
} else {
|
126
|
+
window.getSelection().removeAllRanges();
|
127
|
+
return window.getSelection().addRange(range);
|
128
|
+
}
|
129
|
+
},
|
130
|
+
replaceSelection: function(cb) {
|
131
|
+
var newTextNode, r, range, sel, t;
|
132
|
+
if (jQuery.browser.msie) {
|
133
|
+
t = document.selection.createRange().text;
|
134
|
+
r = document.selection.createRange();
|
135
|
+
return r.pasteHTML(cb(t));
|
136
|
+
} else {
|
137
|
+
sel = window.getSelection();
|
138
|
+
range = sel.getRangeAt(0);
|
139
|
+
newTextNode = document.createTextNode(cb(range.extractContents()));
|
140
|
+
range.insertNode(newTextNode);
|
141
|
+
range.setStartAfter(newTextNode);
|
142
|
+
sel.removeAllRanges();
|
143
|
+
return sel.addRange(range);
|
144
|
+
}
|
145
|
+
},
|
146
|
+
removeAllSelections: function() {
|
147
|
+
if (jQuery.browser.msie) {
|
148
|
+
return range.empty();
|
149
|
+
} else {
|
150
|
+
return window.getSelection().removeAllRanges();
|
151
|
+
}
|
152
|
+
},
|
153
|
+
getContents: function() {
|
154
|
+
var contentClone, plugin;
|
155
|
+
contentClone = this.element.clone();
|
156
|
+
for (plugin in this.options.plugins) {
|
157
|
+
jQuery(this.element)[plugin]('cleanupContentClone', contentClone);
|
158
|
+
}
|
159
|
+
return contentClone.html();
|
160
|
+
},
|
161
|
+
setContents: function(contents) {
|
162
|
+
return this.element.html(contents);
|
163
|
+
},
|
164
|
+
isModified: function() {
|
165
|
+
return this.originalContent !== this.getContents();
|
166
|
+
},
|
167
|
+
setUnmodified: function() {
|
168
|
+
return this.originalContent = this.getContents();
|
169
|
+
},
|
170
|
+
setModified: function() {
|
171
|
+
return this._trigger('modified', null, {
|
172
|
+
editable: this,
|
173
|
+
content: this.getContents()
|
174
|
+
});
|
175
|
+
},
|
176
|
+
restoreOriginalContent: function() {
|
177
|
+
return this.element.html(this.originalContent);
|
178
|
+
},
|
179
|
+
execute: function(command, value) {
|
180
|
+
if (document.execCommand(command, false, value)) {
|
181
|
+
return this.element.trigger("change");
|
182
|
+
}
|
183
|
+
},
|
184
|
+
protectFocusFrom: function(el) {
|
185
|
+
var widget;
|
186
|
+
widget = this;
|
187
|
+
return el.bind("mousedown", function(event) {
|
188
|
+
event.preventDefault();
|
189
|
+
widget._protectToolbarFocus = true;
|
190
|
+
return setTimeout(function() {
|
191
|
+
return widget._protectToolbarFocus = false;
|
192
|
+
}, 300);
|
193
|
+
});
|
194
|
+
},
|
195
|
+
_generateUUID: function() {
|
196
|
+
var S4;
|
197
|
+
S4 = function() {
|
198
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
199
|
+
};
|
200
|
+
return "" + (S4()) + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + (S4()) + (S4());
|
201
|
+
},
|
202
|
+
_getToolbarPosition: function(event, selection) {
|
203
|
+
var offset;
|
204
|
+
if (!event) {
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
if (this.options.floating) {
|
208
|
+
if (event.originalEvent instanceof KeyboardEvent) {
|
209
|
+
return this._getCaretPosition(selection);
|
210
|
+
} else if (event.originalEvent instanceof MouseEvent) {
|
211
|
+
return {
|
212
|
+
top: event.pageY,
|
213
|
+
left: event.pageX
|
214
|
+
};
|
215
|
+
}
|
216
|
+
} else {
|
217
|
+
offset = parseFloat(this.element.css('outline-width')) + parseFloat(this.element.css('outline-offset'));
|
218
|
+
return {
|
219
|
+
top: this.element.offset().top - this.toolbar.outerHeight() - offset,
|
220
|
+
left: this.element.offset().left - offset
|
221
|
+
};
|
222
|
+
}
|
223
|
+
},
|
224
|
+
_getCaretPosition: function(range) {
|
225
|
+
var newRange, position, tmpSpan;
|
226
|
+
tmpSpan = jQuery("<span/>");
|
227
|
+
newRange = document.createRange();
|
228
|
+
newRange.setStart(range.endContainer, range.endOffset);
|
229
|
+
newRange.insertNode(tmpSpan.get(0));
|
230
|
+
position = {
|
231
|
+
top: tmpSpan.offset().top,
|
232
|
+
left: tmpSpan.offset().left
|
233
|
+
};
|
234
|
+
tmpSpan.remove();
|
235
|
+
return position;
|
236
|
+
},
|
237
|
+
_bindToolbarEventsFixed: function() {
|
238
|
+
var _this = this;
|
239
|
+
this.options.floating = false;
|
240
|
+
this.element.bind("halloactivated", function(event, data) {
|
241
|
+
_this._updateToolbarPosition(_this._getToolbarPosition(event));
|
242
|
+
return _this.toolbar.show();
|
243
|
+
});
|
244
|
+
return this.element.bind("hallodeactivated", function(event, data) {
|
245
|
+
return _this.toolbar.hide();
|
246
|
+
});
|
247
|
+
},
|
248
|
+
_bindToolbarEventsRegular: function() {
|
249
|
+
var _this = this;
|
250
|
+
this.element.bind("halloselected", function(event, data) {
|
251
|
+
var position;
|
252
|
+
position = _this._getToolbarPosition(data.originalEvent, data.selection);
|
253
|
+
if (!position) {
|
254
|
+
return;
|
255
|
+
}
|
256
|
+
_this._updateToolbarPosition(position);
|
257
|
+
return _this.toolbar.show();
|
258
|
+
});
|
259
|
+
this.element.bind("hallounselected", function(event, data) {
|
260
|
+
return _this.toolbar.hide();
|
261
|
+
});
|
262
|
+
return this.element.bind("hallodeactivated", function(event, data) {
|
263
|
+
return _this.toolbar.hide();
|
264
|
+
});
|
265
|
+
},
|
266
|
+
_setToolbarPosition: function() {
|
267
|
+
if (this.options.fixed) {
|
268
|
+
this.toolbar.css('position', 'static');
|
269
|
+
if (this.toolbarMoved) {
|
270
|
+
jQuery(this.options.parentElement).append(this.toolbar);
|
271
|
+
}
|
272
|
+
this.toolbarMoved = false;
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
if (this.options.parentElement !== 'body') {
|
276
|
+
jQuery('body').append(this.toolbar);
|
277
|
+
this.toolbarMoved = true;
|
278
|
+
}
|
279
|
+
this.toolbar.css('position', 'absolute');
|
280
|
+
this.toolbar.css('top', this.element.offset().top - 20);
|
281
|
+
return this.toolbar.css('left', this.element.offset().left);
|
282
|
+
},
|
283
|
+
_prepareToolbar: function() {
|
284
|
+
var widget,
|
285
|
+
_this = this;
|
286
|
+
this.toolbar = jQuery('<div class="hallotoolbar"></div>').hide();
|
287
|
+
this._setToolbarPosition();
|
288
|
+
jQuery(this.options.parentElement).append(this.toolbar);
|
289
|
+
widget = this;
|
290
|
+
if (this.options.showAlways) {
|
291
|
+
this._bindToolbarEventsFixed();
|
292
|
+
}
|
293
|
+
if (!this.options.showAlways) {
|
294
|
+
this._bindToolbarEventsRegular();
|
295
|
+
}
|
296
|
+
jQuery(window).resize(function(event) {
|
297
|
+
return _this._updateToolbarPosition(_this._getToolbarPosition(event));
|
298
|
+
});
|
299
|
+
return this.protectFocusFrom(this.toolbar);
|
300
|
+
},
|
301
|
+
_updateToolbarPosition: function(position) {
|
302
|
+
if (this.options.fixed) {
|
303
|
+
return;
|
304
|
+
}
|
305
|
+
if (!position) {
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
if (!(position.top && position.left)) {
|
309
|
+
return;
|
310
|
+
}
|
311
|
+
this.toolbar.css("top", position.top);
|
312
|
+
return this.toolbar.css("left", position.left);
|
313
|
+
},
|
314
|
+
_checkModified: function(event) {
|
315
|
+
var widget;
|
316
|
+
widget = event.data;
|
317
|
+
if (widget.isModified()) {
|
318
|
+
return widget.setModified();
|
319
|
+
}
|
320
|
+
},
|
321
|
+
_keys: function(event) {
|
322
|
+
var old, widget;
|
323
|
+
widget = event.data;
|
324
|
+
if (event.keyCode === 27) {
|
325
|
+
old = widget.getContents();
|
326
|
+
widget.restoreOriginalContent(event);
|
327
|
+
widget._trigger("restored", null, {
|
328
|
+
editable: widget,
|
329
|
+
content: widget.getContents(),
|
330
|
+
thrown: old
|
331
|
+
});
|
332
|
+
return widget.turnOff();
|
333
|
+
}
|
334
|
+
},
|
335
|
+
_rangesEqual: function(r1, r2) {
|
336
|
+
return r1.startContainer === r2.startContainer && r1.startOffset === r2.startOffset && r1.endContainer === r2.endContainer && r1.endOffset === r2.endOffset;
|
337
|
+
},
|
338
|
+
_checkSelection: function(event) {
|
339
|
+
var widget;
|
340
|
+
if (event.keyCode === 27) {
|
341
|
+
return;
|
342
|
+
}
|
343
|
+
widget = event.data;
|
344
|
+
return setTimeout(function() {
|
345
|
+
var sel;
|
346
|
+
sel = widget.getSelection();
|
347
|
+
if (widget._isEmptySelection(sel) || widget._isEmptyRange(sel)) {
|
348
|
+
if (widget.selection) {
|
349
|
+
widget.selection = null;
|
350
|
+
widget._trigger("unselected", null, {
|
351
|
+
editable: widget,
|
352
|
+
originalEvent: event
|
353
|
+
});
|
354
|
+
}
|
355
|
+
return;
|
356
|
+
}
|
357
|
+
if (!widget.selection || !widget._rangesEqual(sel, widget.selection)) {
|
358
|
+
widget.selection = sel.cloneRange();
|
359
|
+
return widget._trigger("selected", null, {
|
360
|
+
editable: widget,
|
361
|
+
selection: widget.selection,
|
362
|
+
ranges: [widget.selection],
|
363
|
+
originalEvent: event
|
364
|
+
});
|
365
|
+
}
|
366
|
+
}, 0);
|
367
|
+
},
|
368
|
+
_isEmptySelection: function(selection) {
|
369
|
+
if (selection.type === "Caret") {
|
370
|
+
return true;
|
371
|
+
}
|
372
|
+
return false;
|
373
|
+
},
|
374
|
+
_isEmptyRange: function(range) {
|
375
|
+
if (range.collapsed) {
|
376
|
+
return true;
|
377
|
+
}
|
378
|
+
if (range.isCollapsed) {
|
379
|
+
if (typeof range.isCollapsed === 'function') {
|
380
|
+
return range.isCollapsed();
|
381
|
+
}
|
382
|
+
return range.isCollapsed;
|
383
|
+
}
|
384
|
+
return false;
|
385
|
+
},
|
386
|
+
turnOn: function() {
|
387
|
+
var el, widthToAdd;
|
388
|
+
if (this.getContents() === this.options.placeholder) {
|
389
|
+
this.setContents('');
|
390
|
+
}
|
391
|
+
jQuery(this.element).addClass('inEditMode');
|
392
|
+
if (!this.options.floating) {
|
393
|
+
el = jQuery(this.element);
|
394
|
+
widthToAdd = parseFloat(el.css('padding-left'));
|
395
|
+
widthToAdd += parseFloat(el.css('padding-right'));
|
396
|
+
widthToAdd += parseFloat(el.css('border-left-width'));
|
397
|
+
widthToAdd += parseFloat(el.css('border-right-width'));
|
398
|
+
widthToAdd += (parseFloat(el.css('outline-width'))) * 2;
|
399
|
+
widthToAdd += (parseFloat(el.css('outline-offset'))) * 2;
|
400
|
+
jQuery(this.toolbar).css("width", el.width() + widthToAdd);
|
401
|
+
} else {
|
402
|
+
this.toolbar.css("width", "auto");
|
403
|
+
}
|
404
|
+
return this._trigger("activated", this);
|
405
|
+
},
|
406
|
+
turnOff: function() {
|
407
|
+
jQuery(this.element).removeClass('inEditMode');
|
408
|
+
this._trigger("deactivated", this);
|
409
|
+
if (!this.getContents()) {
|
410
|
+
return this.setContents(this.options.placeholder);
|
411
|
+
}
|
412
|
+
},
|
413
|
+
_activated: function(event) {
|
414
|
+
return event.data.turnOn();
|
415
|
+
},
|
416
|
+
_deactivated: function(event) {
|
417
|
+
if (event.data._protectToolbarFocus !== true) {
|
418
|
+
return event.data.turnOff();
|
419
|
+
} else {
|
420
|
+
return setTimeout(function() {
|
421
|
+
return jQuery(event.data.element).focus();
|
422
|
+
}, 300);
|
423
|
+
}
|
424
|
+
},
|
425
|
+
_forceStructured: function(event) {
|
426
|
+
try {
|
427
|
+
return document.execCommand('styleWithCSS', 0, false);
|
428
|
+
} catch (e) {
|
429
|
+
try {
|
430
|
+
return document.execCommand('useCSS', 0, true);
|
431
|
+
} catch (e) {
|
432
|
+
try {
|
433
|
+
return document.execCommand('styleWithCSS', false, false);
|
434
|
+
} catch (e) {
|
435
|
+
|
436
|
+
}
|
437
|
+
}
|
438
|
+
}
|
439
|
+
}
|
440
|
+
});
|
441
|
+
})(jQuery);
|
442
|
+
|
443
|
+
(function(jQuery) {
|
444
|
+
return jQuery.widget("IKS.hallolists", {
|
445
|
+
options: {
|
446
|
+
editable: null,
|
447
|
+
toolbar: null,
|
448
|
+
uuid: '',
|
449
|
+
lists: {
|
450
|
+
ordered: false,
|
451
|
+
unordered: true
|
452
|
+
},
|
453
|
+
buttonCssClass: null
|
454
|
+
},
|
455
|
+
_create: function() {
|
456
|
+
var buttonize, buttonset,
|
457
|
+
_this = this;
|
458
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
459
|
+
buttonize = function(type, label) {
|
460
|
+
var buttonElement;
|
461
|
+
buttonElement = jQuery('<span></span>');
|
462
|
+
buttonElement.hallobutton({
|
463
|
+
uuid: _this.options.uuid,
|
464
|
+
editable: _this.options.editable,
|
465
|
+
label: label,
|
466
|
+
command: "insert" + type + "List",
|
467
|
+
icon: 'icon-list',
|
468
|
+
cssClass: _this.options.buttonCssClass
|
469
|
+
});
|
470
|
+
return buttonset.append(buttonElement);
|
471
|
+
};
|
472
|
+
if (this.options.lists.ordered) {
|
473
|
+
buttonize("Ordered", "OL");
|
474
|
+
}
|
475
|
+
if (this.options.lists.unordered) {
|
476
|
+
buttonize("Unordered", "UL");
|
477
|
+
}
|
478
|
+
buttonset.buttonset();
|
479
|
+
return this.options.toolbar.append(buttonset);
|
480
|
+
},
|
481
|
+
_init: function() {}
|
482
|
+
});
|
483
|
+
})(jQuery);
|
484
|
+
|
485
|
+
(function(jQuery) {
|
486
|
+
return jQuery.widget("IKS.halloheadings", {
|
487
|
+
options: {
|
488
|
+
editable: null,
|
489
|
+
toolbar: null,
|
490
|
+
uuid: "",
|
491
|
+
headers: [1, 2, 3]
|
492
|
+
},
|
493
|
+
_create: function() {
|
494
|
+
var button, buttonize, buttonset, header, id, label, widget, _i, _len, _ref,
|
495
|
+
_this = this;
|
496
|
+
widget = this;
|
497
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
498
|
+
id = "" + this.options.uuid + "-paragraph";
|
499
|
+
label = "P";
|
500
|
+
buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"p_button\">" + label + "</label>").button());
|
501
|
+
button = jQuery("#" + id, buttonset);
|
502
|
+
button.attr("hallo-command", "formatBlock");
|
503
|
+
button.bind("change", function(event) {
|
504
|
+
var cmd;
|
505
|
+
cmd = jQuery(this).attr("hallo-command");
|
506
|
+
return widget.options.editable.execute(cmd, "P");
|
507
|
+
});
|
508
|
+
buttonize = function(headerSize) {
|
509
|
+
label = "H" + headerSize;
|
510
|
+
id = "" + _this.options.uuid + "-" + headerSize;
|
511
|
+
buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"h" + headerSize + "_button\">" + label + "</label>").button());
|
512
|
+
button = jQuery("#" + id, buttonset);
|
513
|
+
button.attr("hallo-size", "H" + headerSize);
|
514
|
+
return button.bind("change", function(event) {
|
515
|
+
var size;
|
516
|
+
size = jQuery(this).attr("hallo-size");
|
517
|
+
return widget.options.editable.execute("formatBlock", size);
|
518
|
+
});
|
519
|
+
};
|
520
|
+
_ref = this.options.headers;
|
521
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
522
|
+
header = _ref[_i];
|
523
|
+
buttonize(header);
|
524
|
+
}
|
525
|
+
buttonset.buttonset();
|
526
|
+
this.element.bind("keyup paste change mouseup", function(event) {
|
527
|
+
var format, formatNumber, labelParent, matches, selectedButton;
|
528
|
+
try {
|
529
|
+
format = document.queryCommandValue("formatBlock").toUpperCase();
|
530
|
+
} catch (e) {
|
531
|
+
format = '';
|
532
|
+
}
|
533
|
+
if (format === "P") {
|
534
|
+
selectedButton = jQuery("#" + widget.options.uuid + "-paragraph");
|
535
|
+
} else if (matches = format.match(/\d/)) {
|
536
|
+
formatNumber = matches[0];
|
537
|
+
selectedButton = jQuery("#" + widget.options.uuid + "-" + formatNumber);
|
538
|
+
}
|
539
|
+
labelParent = jQuery(buttonset);
|
540
|
+
labelParent.children("input").attr("checked", false);
|
541
|
+
labelParent.children("label").removeClass("ui-state-clicked");
|
542
|
+
labelParent.children("input").button("widget").button("refresh");
|
543
|
+
if (selectedButton) {
|
544
|
+
selectedButton.attr("checked", true);
|
545
|
+
selectedButton.next("label").addClass("ui-state-clicked");
|
546
|
+
return selectedButton.button("refresh");
|
547
|
+
}
|
548
|
+
});
|
549
|
+
return this.options.toolbar.append(buttonset);
|
550
|
+
},
|
551
|
+
_init: function() {}
|
552
|
+
});
|
553
|
+
})(jQuery);
|
554
|
+
|
555
|
+
(function(jQuery) {
|
556
|
+
return jQuery.widget("Liip.hallooverlay", {
|
557
|
+
options: {
|
558
|
+
editable: null,
|
559
|
+
toolbar: null,
|
560
|
+
uuid: "",
|
561
|
+
overlay: null,
|
562
|
+
padding: 10,
|
563
|
+
background: null
|
564
|
+
},
|
565
|
+
_create: function() {
|
566
|
+
var widget;
|
567
|
+
widget = this;
|
568
|
+
if (!this.options.bound) {
|
569
|
+
this.options.bound = true;
|
570
|
+
widget.options.editable.element.bind("halloactivated", function(event, data) {
|
571
|
+
widget.options.currentEditable = jQuery(event.target);
|
572
|
+
if (!widget.options.visible) {
|
573
|
+
return widget.showOverlay();
|
574
|
+
}
|
575
|
+
});
|
576
|
+
widget.options.editable.element.bind("hallomodified", function(event, data) {
|
577
|
+
widget.options.currentEditable = jQuery(event.target);
|
578
|
+
if (widget.options.visible) {
|
579
|
+
return widget.resizeOverlay();
|
580
|
+
}
|
581
|
+
});
|
582
|
+
return widget.options.editable.element.bind("hallodeactivated", function(event, data) {
|
583
|
+
widget.options.currentEditable = jQuery(event.target);
|
584
|
+
if (widget.options.visible) {
|
585
|
+
return widget.hideOverlay();
|
586
|
+
}
|
587
|
+
});
|
588
|
+
}
|
589
|
+
},
|
590
|
+
_init: function() {},
|
591
|
+
showOverlay: function() {
|
592
|
+
this.options.visible = true;
|
593
|
+
if (this.options.overlay === null) {
|
594
|
+
if (jQuery("#halloOverlay").length > 0) {
|
595
|
+
this.options.overlay = jQuery("#halloOverlay");
|
596
|
+
} else {
|
597
|
+
this.options.overlay = jQuery('<div id="halloOverlay" class="halloOverlay">');
|
598
|
+
jQuery(document.body).append(this.options.overlay);
|
599
|
+
}
|
600
|
+
this.options.overlay.bind('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable));
|
601
|
+
}
|
602
|
+
this.options.overlay.show();
|
603
|
+
if (this.options.background === null) {
|
604
|
+
if (jQuery("#halloBackground").length > 0) {
|
605
|
+
this.options.background = jQuery("#halloBackground");
|
606
|
+
} else {
|
607
|
+
this.options.background = jQuery('<div id="halloBackground" class="halloBackground">');
|
608
|
+
jQuery(document.body).append(this.options.background);
|
609
|
+
}
|
610
|
+
}
|
611
|
+
this.resizeOverlay();
|
612
|
+
this.options.background.show();
|
613
|
+
if (!this.options.originalZIndex) {
|
614
|
+
this.options.originalZIndex = this.options.currentEditable.css("z-index");
|
615
|
+
}
|
616
|
+
return this.options.currentEditable.css('z-index', '350');
|
617
|
+
},
|
618
|
+
resizeOverlay: function() {
|
619
|
+
var offset;
|
620
|
+
offset = this.options.currentEditable.offset();
|
621
|
+
this.options.background.css({
|
622
|
+
top: offset.top - this.options.padding,
|
623
|
+
left: offset.left - this.options.padding
|
624
|
+
});
|
625
|
+
this.options.background.width(this.options.currentEditable.width() + 2 * this.options.padding);
|
626
|
+
return this.options.background.height(this.options.currentEditable.height() + 2 * this.options.padding);
|
627
|
+
},
|
628
|
+
hideOverlay: function() {
|
629
|
+
this.options.visible = false;
|
630
|
+
this.options.overlay.hide();
|
631
|
+
this.options.background.hide();
|
632
|
+
return this.options.currentEditable.css('z-index', this.options.originalZIndex);
|
633
|
+
},
|
634
|
+
_findBackgroundColor: function(jQueryfield) {
|
635
|
+
var color;
|
636
|
+
color = jQueryfield.css("background-color");
|
637
|
+
if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') {
|
638
|
+
return color;
|
639
|
+
}
|
640
|
+
if (jQueryfield.is("body")) {
|
641
|
+
return "white";
|
642
|
+
} else {
|
643
|
+
return this._findBackgroundColor(jQueryfield.parent());
|
644
|
+
}
|
645
|
+
}
|
646
|
+
});
|
647
|
+
})(jQuery);
|
648
|
+
|
649
|
+
(function(jQuery) {
|
650
|
+
return jQuery.widget("Liip.hallotoolbarlinebreak", {
|
651
|
+
options: {
|
652
|
+
editable: null,
|
653
|
+
toolbar: null,
|
654
|
+
uuid: "",
|
655
|
+
breakAfter: []
|
656
|
+
},
|
657
|
+
_create: function() {
|
658
|
+
var buttonset, buttonsets, queuedButtonsets, row, rowcounter, _i, _j, _len, _len1, _ref;
|
659
|
+
buttonsets = jQuery('.ui-buttonset', this.options.toolbar);
|
660
|
+
queuedButtonsets = jQuery();
|
661
|
+
rowcounter = 0;
|
662
|
+
_ref = this.options.breakAfter;
|
663
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
664
|
+
row = _ref[_i];
|
665
|
+
rowcounter++;
|
666
|
+
for (_j = 0, _len1 = buttonsets.length; _j < _len1; _j++) {
|
667
|
+
buttonset = buttonsets[_j];
|
668
|
+
queuedButtonsets = jQuery(queuedButtonsets).add(jQuery(buttonset));
|
669
|
+
if (jQuery(buttonset).hasClass(row)) {
|
670
|
+
queuedButtonsets.wrapAll('<div class="halloButtonrow halloButtonrow-' + rowcounter + '" />');
|
671
|
+
buttonsets = buttonsets.not(queuedButtonsets);
|
672
|
+
queuedButtonsets = jQuery();
|
673
|
+
break;
|
674
|
+
}
|
675
|
+
}
|
676
|
+
}
|
677
|
+
if (buttonsets.length > 0) {
|
678
|
+
rowcounter++;
|
679
|
+
return buttonsets.wrapAll('<div class="halloButtonrow halloButtonrow-' + rowcounter + '" />');
|
680
|
+
}
|
681
|
+
},
|
682
|
+
_init: function() {}
|
683
|
+
});
|
684
|
+
})(jQuery);
|
685
|
+
|
686
|
+
(function(jQuery) {
|
687
|
+
var z;
|
688
|
+
z = null;
|
689
|
+
if (this.VIE !== void 0) {
|
690
|
+
z = new VIE;
|
691
|
+
z.use(new z.StanbolService({
|
692
|
+
proxyDisabled: true,
|
693
|
+
url: 'http://dev.iks-project.eu:8081'
|
694
|
+
}));
|
695
|
+
}
|
696
|
+
return jQuery.widget('IKS.halloannotate', {
|
697
|
+
options: {
|
698
|
+
vie: z,
|
699
|
+
editable: null,
|
700
|
+
toolbar: null,
|
701
|
+
uuid: '',
|
702
|
+
select: function() {},
|
703
|
+
decline: function() {},
|
704
|
+
remove: function() {},
|
705
|
+
buttonCssClass: null
|
706
|
+
},
|
707
|
+
_create: function() {
|
708
|
+
var buttonHolder, editableElement, turnOffAnnotate, widget,
|
709
|
+
_this = this;
|
710
|
+
widget = this;
|
711
|
+
if (this.options.vie === void 0) {
|
712
|
+
throw 'The halloannotate plugin requires VIE to be loaded';
|
713
|
+
return;
|
714
|
+
}
|
715
|
+
if (typeof this.element.annotate !== 'function') {
|
716
|
+
throw 'The halloannotate plugin requires annotate.js to be loaded';
|
717
|
+
return;
|
718
|
+
}
|
719
|
+
this.state = 'off';
|
720
|
+
buttonHolder = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
721
|
+
this.button = buttonHolder.hallobutton({
|
722
|
+
label: 'Annotate',
|
723
|
+
icon: 'icon-tags',
|
724
|
+
editable: this.options.editable,
|
725
|
+
command: null,
|
726
|
+
uuid: this.options.uuid,
|
727
|
+
cssClass: this.options.buttonCssClass,
|
728
|
+
queryState: false
|
729
|
+
});
|
730
|
+
buttonHolder.bind('change', function(event) {
|
731
|
+
if (_this.state === "pending") {
|
732
|
+
return;
|
733
|
+
}
|
734
|
+
if (_this.state === "off") {
|
735
|
+
return _this.turnOn();
|
736
|
+
}
|
737
|
+
return _this.turnOff();
|
738
|
+
});
|
739
|
+
buttonHolder.buttonset();
|
740
|
+
this.options.toolbar.append(this.button);
|
741
|
+
this.instantiate();
|
742
|
+
turnOffAnnotate = function() {
|
743
|
+
var editable;
|
744
|
+
editable = this;
|
745
|
+
return jQuery(editable).halloannotate('turnOff');
|
746
|
+
};
|
747
|
+
editableElement = this.options.editable.element;
|
748
|
+
return editableElement.bind('hallodisabled', turnOffAnnotate);
|
749
|
+
},
|
750
|
+
cleanupContentClone: function(el) {
|
751
|
+
if (this.state === 'on') {
|
752
|
+
return el.find(".entity:not([about])").each(function() {
|
753
|
+
return jQuery(this).replaceWith(jQuery(this).html());
|
754
|
+
});
|
755
|
+
}
|
756
|
+
},
|
757
|
+
instantiate: function() {
|
758
|
+
var widget;
|
759
|
+
widget = this;
|
760
|
+
return this.options.editable.element.annotate({
|
761
|
+
vie: this.options.vie,
|
762
|
+
debug: false,
|
763
|
+
showTooltip: true,
|
764
|
+
select: this.options.select,
|
765
|
+
remove: this.options.remove,
|
766
|
+
success: this.options.success,
|
767
|
+
error: this.options.error
|
768
|
+
}).bind('annotateselect', function() {
|
769
|
+
return widget.options.editable.setModified();
|
770
|
+
}).bind('annotateremove', function() {
|
771
|
+
return jQuery.noop();
|
772
|
+
});
|
773
|
+
},
|
774
|
+
turnPending: function() {
|
775
|
+
this.state = 'pending';
|
776
|
+
this.button.hallobutton('checked', false);
|
777
|
+
return this.button.hallobutton('disable');
|
778
|
+
},
|
779
|
+
turnOn: function() {
|
780
|
+
var widget,
|
781
|
+
_this = this;
|
782
|
+
this.turnPending();
|
783
|
+
widget = this;
|
784
|
+
try {
|
785
|
+
return this.options.editable.element.annotate('enable', function(success) {
|
786
|
+
if (success) {
|
787
|
+
_this.state = 'on';
|
788
|
+
_this.button.hallobutton('checked', true);
|
789
|
+
return _this.button.hallobutton('enable');
|
790
|
+
}
|
791
|
+
});
|
792
|
+
} catch (e) {
|
793
|
+
return alert(e);
|
794
|
+
}
|
795
|
+
},
|
796
|
+
turnOff: function() {
|
797
|
+
this.options.editable.element.annotate('disable');
|
798
|
+
this.button.attr('checked', false);
|
799
|
+
this.button.find("label").removeClass("ui-state-clicked");
|
800
|
+
this.button.button('refresh');
|
801
|
+
return this.state = 'off';
|
802
|
+
}
|
803
|
+
});
|
804
|
+
})(jQuery);
|
805
|
+
|
806
|
+
(function(jQuery) {
|
807
|
+
return jQuery.widget("Liip.halloimage", {
|
808
|
+
options: {
|
809
|
+
editable: null,
|
810
|
+
toolbar: null,
|
811
|
+
uuid: "",
|
812
|
+
limit: 8,
|
813
|
+
search: null,
|
814
|
+
suggestions: null,
|
815
|
+
loaded: null,
|
816
|
+
upload: null,
|
817
|
+
uploadUrl: null,
|
818
|
+
dialogOpts: {
|
819
|
+
autoOpen: false,
|
820
|
+
width: 270,
|
821
|
+
height: "auto",
|
822
|
+
title: "Insert Images",
|
823
|
+
modal: false,
|
824
|
+
resizable: false,
|
825
|
+
draggable: true,
|
826
|
+
dialogClass: 'halloimage-dialog',
|
827
|
+
close: function(ev, ui) {
|
828
|
+
return jQuery('.image_button').removeClass('ui-state-clicked');
|
829
|
+
}
|
830
|
+
},
|
831
|
+
dialog: null,
|
832
|
+
buttonCssClass: null
|
833
|
+
},
|
834
|
+
_create: function() {
|
835
|
+
var button, buttonHolder, buttonset, dialogId, id, widget;
|
836
|
+
widget = this;
|
837
|
+
dialogId = "" + this.options.uuid + "-image-dialog";
|
838
|
+
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>");
|
839
|
+
if (widget.options.uploadUrl && !widget.options.upload) {
|
840
|
+
widget.options.upload = widget._iframeUpload;
|
841
|
+
}
|
842
|
+
if (widget.options.suggestions) {
|
843
|
+
this._addGuiTabSuggestions(jQuery(".tabs", this.options.dialog), jQuery(".dialogcontent", this.options.dialog));
|
844
|
+
}
|
845
|
+
if (widget.options.search) {
|
846
|
+
this._addGuiTabSearch(jQuery(".tabs", this.options.dialog), jQuery(".dialogcontent", this.options.dialog));
|
847
|
+
}
|
848
|
+
if (widget.options.upload) {
|
849
|
+
this._addGuiTabUpload(jQuery(".tabs", this.options.dialog), jQuery(".dialogcontent", this.options.dialog));
|
850
|
+
}
|
851
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
852
|
+
id = "" + this.options.uuid + "-image";
|
853
|
+
buttonHolder = jQuery('<span></span>');
|
854
|
+
buttonHolder.hallobutton({
|
855
|
+
label: 'Images',
|
856
|
+
icon: 'icon-picture',
|
857
|
+
editable: this.options.editable,
|
858
|
+
command: null,
|
859
|
+
queryState: false,
|
860
|
+
uuid: this.options.uuid,
|
861
|
+
cssClass: this.options.buttonCssClass
|
862
|
+
});
|
863
|
+
buttonset.append(buttonHolder);
|
864
|
+
button = buttonHolder;
|
865
|
+
button.bind("change", function(event) {
|
866
|
+
if (widget.options.dialog.dialog("isOpen")) {
|
867
|
+
return widget._closeDialog();
|
868
|
+
} else {
|
869
|
+
return widget._openDialog();
|
870
|
+
}
|
871
|
+
});
|
872
|
+
this.options.editable.element.bind("hallodeactivated", function(event) {
|
873
|
+
return widget._closeDialog();
|
874
|
+
});
|
875
|
+
jQuery(this.options.editable.element).delegate("img", "click", function(event) {
|
876
|
+
return widget._openDialog();
|
877
|
+
});
|
878
|
+
jQuery(this.options.dialog).find(".nav li").click(function() {
|
879
|
+
jQuery("." + widget.widgetName + "-tab").each(function() {
|
880
|
+
return jQuery(this).hide();
|
881
|
+
});
|
882
|
+
id = jQuery(this).attr("id");
|
883
|
+
jQuery("#" + id + "-content").show();
|
884
|
+
return jQuery("#" + widget.options.uuid + "-tab-activeIndicator").css("margin-left", jQuery(this).position().left + (jQuery(this).width() / 2));
|
885
|
+
});
|
886
|
+
jQuery("." + widget.widgetName + "-tab .imageThumbnail").live("click", function(event) {
|
887
|
+
var scope;
|
888
|
+
scope = jQuery(this).closest("." + widget.widgetName + "-tab");
|
889
|
+
jQuery(".imageThumbnail", scope).removeClass("imageThumbnailActive");
|
890
|
+
jQuery(this).addClass("imageThumbnailActive");
|
891
|
+
jQuery(".activeImage", scope).attr("src", jQuery(this).attr("src"));
|
892
|
+
return jQuery(".activeImageBg", scope).attr("src", jQuery(this).attr("src"));
|
893
|
+
});
|
894
|
+
buttonset.buttonset();
|
895
|
+
this.options.toolbar.append(buttonset);
|
896
|
+
this.options.dialog.dialog(this.options.dialogOpts);
|
897
|
+
return this._addDragnDrop();
|
898
|
+
},
|
899
|
+
_init: function() {},
|
900
|
+
_openDialog: function() {
|
901
|
+
var articleTags, cleanUp, i, repoImagesFound, showResults, tagType, thumbId, tmpArticleTags, vie, widget, xposition, yposition;
|
902
|
+
widget = this;
|
903
|
+
cleanUp = function() {
|
904
|
+
return window.setTimeout((function() {
|
905
|
+
var thumbnails;
|
906
|
+
thumbnails = jQuery(".imageThumbnail");
|
907
|
+
return jQuery(thumbnails).each(function() {
|
908
|
+
var size;
|
909
|
+
size = jQuery("#" + this.id).width();
|
910
|
+
if (size <= 20) {
|
911
|
+
return jQuery("#" + this.id).parent("li").remove();
|
912
|
+
}
|
913
|
+
});
|
914
|
+
}), 15000);
|
915
|
+
};
|
916
|
+
repoImagesFound = false;
|
917
|
+
showResults = function(response) {
|
918
|
+
jQuery.each(response.assets, function(key, val) {
|
919
|
+
jQuery(".imageThumbnailContainer ul").append("<li><img src=\"" + val.url + "\" class=\"imageThumbnail\"></li>");
|
920
|
+
return repoImagesFound = true;
|
921
|
+
});
|
922
|
+
if (response.assets.length > 0) {
|
923
|
+
return jQuery("#activitySpinner").hide();
|
924
|
+
}
|
925
|
+
};
|
926
|
+
jQuery('.image_button').addClass('ui-state-clicked');
|
927
|
+
jQuery("#" + this.options.uuid + "-sugg-activeImage").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
|
928
|
+
jQuery("#" + this.options.uuid + "-sugg-activeImageBg").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
|
929
|
+
this.lastSelection = this.options.editable.getSelection();
|
930
|
+
xposition = jQuery(this.options.editable.element).offset().left + jQuery(this.options.editable.element).outerWidth() - 3;
|
931
|
+
yposition = jQuery(this.options.toolbar).offset().top - jQuery(document).scrollTop() - 29;
|
932
|
+
this.options.dialog.dialog("option", "position", [xposition, yposition]);
|
933
|
+
if (widget.options.loaded === null && widget.options.suggestions) {
|
934
|
+
articleTags = [];
|
935
|
+
jQuery("#activitySpinner").show();
|
936
|
+
tmpArticleTags = jQuery(".inEditMode").parent().find(".articleTags input").val();
|
937
|
+
tmpArticleTags = tmpArticleTags.split(",");
|
938
|
+
for (i in tmpArticleTags) {
|
939
|
+
tagType = typeof tmpArticleTags[i];
|
940
|
+
if ("string" === tagType && tmpArticleTags[i].indexOf("http") !== -1) {
|
941
|
+
articleTags.push(tmpArticleTags[i]);
|
942
|
+
}
|
943
|
+
}
|
944
|
+
jQuery(".imageThumbnailContainer ul").empty();
|
945
|
+
widget.options.suggestions(jQuery(".inEditMode").parent().find(".articleTags input").val(), widget.options.limit, 0, showResults);
|
946
|
+
vie = new VIE();
|
947
|
+
vie.use(new vie.DBPediaService({
|
948
|
+
url: "http://dev.iks-project.eu/stanbolfull",
|
949
|
+
proxyDisabled: true
|
950
|
+
}));
|
951
|
+
thumbId = 1;
|
952
|
+
if (articleTags.length === 0) {
|
953
|
+
jQuery("#activitySpinner").html("No images found.");
|
954
|
+
}
|
955
|
+
jQuery(articleTags).each(function() {
|
956
|
+
return vie.load({
|
957
|
+
entity: this + ""
|
958
|
+
}).using("dbpedia").execute().done(function(entity) {
|
959
|
+
jQuery(entity).each(function() {
|
960
|
+
var img, responseType;
|
961
|
+
if (this.attributes["<http://dbpedia.org/ontology/thumbnail>"]) {
|
962
|
+
responseType = typeof this.attributes["<http://dbpedia.org/ontology/thumbnail>"];
|
963
|
+
if (responseType === "string") {
|
964
|
+
img = this.attributes["<http://dbpedia.org/ontology/thumbnail>"];
|
965
|
+
img = img.substring(1, img.length - 1);
|
966
|
+
}
|
967
|
+
if (responseType === "object") {
|
968
|
+
img = "";
|
969
|
+
img = this.attributes["<http://dbpedia.org/ontology/thumbnail>"][0].value;
|
970
|
+
}
|
971
|
+
jQuery(".imageThumbnailContainer ul").append("<li><img id=\"si-" + thumbId + "\" src=\"" + img + "\" class=\"imageThumbnail\"></li>");
|
972
|
+
return thumbId++;
|
973
|
+
}
|
974
|
+
});
|
975
|
+
return jQuery("#activitySpinner").hide();
|
976
|
+
});
|
977
|
+
});
|
978
|
+
}
|
979
|
+
cleanUp();
|
980
|
+
widget.options.loaded = 1;
|
981
|
+
this.options.dialog.dialog("open");
|
982
|
+
return this.options.editable.protectFocusFrom(this.options.dialog);
|
983
|
+
},
|
984
|
+
_closeDialog: function() {
|
985
|
+
return this.options.dialog.dialog("close");
|
986
|
+
},
|
987
|
+
_addGuiTabSuggestions: function(tabs, element) {
|
988
|
+
var widget;
|
989
|
+
widget = this;
|
990
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-suggestions\" class=\"" + widget.widgetName + "-tabselector " + widget.widgetName + "-tab-suggestions\"><span>Suggestions</span></li>"));
|
991
|
+
return element.append(jQuery("<div id=\"" + this.options.uuid + "-tab-suggestions-content\" class=\"" + widget.widgetName + "-tab tab-suggestions\"> <div class=\"imageThumbnailContainer fixed\"><div id=\"activitySpinner\">Loading Images...</div><ul><li> <img src=\"http://imagesus.homeaway.com/mda01/badf2e69babf2f6a0e4b680fc373c041c705b891\" class=\"imageThumbnail imageThumbnailActive\" /> </li></ul><br style=\"clear:both\"/> </div> <div class=\"activeImageContainer\"> <div class=\"rotationWrapper\"> <div class=\"hintArrow\"></div> <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImage\" class=\"activeImage\" /> </div> <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImageBg\" class=\"activeImage activeImageBg\" /> </div> <div class=\"metadata\"> <label for=\"caption-sugg\">Caption</label><input type=\"text\" id=\"caption-sugg\" /> </div> </div>"));
|
992
|
+
},
|
993
|
+
_addGuiTabSearch: function(tabs, element) {
|
994
|
+
var dialogId, widget;
|
995
|
+
widget = this;
|
996
|
+
dialogId = "" + this.options.uuid + "-image-dialog";
|
997
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-search\" class=\"" + widget.widgetName + "-tabselector " + widget.widgetName + "-tab-search\"><span>Search</span></li>"));
|
998
|
+
element.append(jQuery("<div id=\"" + this.options.uuid + "-tab-search-content\" class=\"" + widget.widgetName + "-tab tab-search\"> <form type=\"get\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchForm\"> <input type=\"text\" class=\"searchInput\" /><input type=\"submit\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchButton\" class=\"button searchButton\" value=\"OK\"/> </form> <div class=\"searchResults imageThumbnailContainer\"></div> <div id=\"" + this.options.uuid + "-search-activeImageContainer\" class=\"search-activeImageContainer activeImageContainer\"> <div class=\"rotationWrapper\"> <div class=\"hintArrow\"></div> <img src=\"\" id=\"" + this.options.uuid + "-search-activeImageBg\" class=\"activeImage\" /> </div> <img src=\"\" id=\"" + this.options.uuid + "-search-activeImage\" class=\"activeImage activeImageBg\" /> </div> <div class=\"metadata\" id=\"metadata-search\" style=\"display: none;\"> <label for=\"caption-search\">Caption</label><input type=\"text\" id=\"caption-search\" /> <!--<button id=\"" + this.options.uuid + "-" + widget.widgetName + "-addimage\">Add Image</button>--> </div> </div>"));
|
999
|
+
return jQuery(".tab-search form", element).submit(function(event) {
|
1000
|
+
var showResults, that;
|
1001
|
+
event.preventDefault();
|
1002
|
+
that = this;
|
1003
|
+
showResults = function(response) {
|
1004
|
+
var container, firstimage, items;
|
1005
|
+
items = [];
|
1006
|
+
items.push("<div class=\"pager-prev\" style=\"display:none\"></div>");
|
1007
|
+
jQuery.each(response.assets, function(key, val) {
|
1008
|
+
return items.push("<img src=\"" + val.url + "\" class=\"imageThumbnail " + widget.widgetName + "-search-imageThumbnail\" /> ");
|
1009
|
+
});
|
1010
|
+
items.push("<div class=\"pager-next\" style=\"display:none\"></div>");
|
1011
|
+
container = jQuery("#" + dialogId + " .tab-search .searchResults");
|
1012
|
+
container.html(items.join(""));
|
1013
|
+
if (response.offset > 0) {
|
1014
|
+
jQuery('.pager-prev', container).show();
|
1015
|
+
}
|
1016
|
+
if (response.offset < response.total) {
|
1017
|
+
jQuery('.pager-next', container).show();
|
1018
|
+
}
|
1019
|
+
jQuery('.pager-prev', container).click(function(event) {
|
1020
|
+
return widget.options.search(null, widget.options.limit, response.offset - widget.options.limit, showResults);
|
1021
|
+
});
|
1022
|
+
jQuery('.pager-next', container).click(function(event) {
|
1023
|
+
return widget.options.search(null, widget.options.limit, response.offset + widget.options.limit, showResults);
|
1024
|
+
});
|
1025
|
+
jQuery("#" + widget.options.uuid + "-search-activeImageContainer").show();
|
1026
|
+
firstimage = jQuery("." + widget.widgetName + "-search-imageThumbnail").first().addClass("imageThumbnailActive");
|
1027
|
+
jQuery("#" + widget.options.uuid + "-search-activeImage, #" + widget.options.uuid + "-search-activeImageBg").attr("src", firstimage.attr("src"));
|
1028
|
+
return jQuery("#metadata-search").show();
|
1029
|
+
};
|
1030
|
+
return widget.options.search(null, widget.options.limit, 0, showResults);
|
1031
|
+
});
|
1032
|
+
},
|
1033
|
+
_prepareIframe: function(widget) {
|
1034
|
+
var iframe;
|
1035
|
+
widget.options.iframeName = "" + widget.options.uuid + "-" + widget.widgetName + "-postframe";
|
1036
|
+
iframe = jQuery("<iframe name=\"" + widget.options.iframeName + "\" id=\"" + widget.options.iframeName + "\" class=\"hidden\" src=\"javascript:false;\" style=\"display:none\" />");
|
1037
|
+
jQuery("#" + widget.options.uuid + "-" + widget.widgetName + "-iframe").append(iframe);
|
1038
|
+
return iframe.get(0).name = widget.options.iframeName;
|
1039
|
+
},
|
1040
|
+
_iframeUpload: function(data) {
|
1041
|
+
var uploadForm, widget;
|
1042
|
+
widget = data.widget;
|
1043
|
+
widget._prepareIframe(widget);
|
1044
|
+
jQuery("#" + widget.options.uuid + "-" + widget.widgetName + "-tags").val(jQuery(".inEditMode").parent().find(".articleTags input").val());
|
1045
|
+
uploadForm = jQuery("#" + widget.options.uuid + "-" + widget.widgetName + "-uploadform");
|
1046
|
+
uploadForm.attr("action", widget.options.uploadUrl);
|
1047
|
+
uploadForm.attr("method", "post");
|
1048
|
+
uploadForm.attr("userfile", data.file);
|
1049
|
+
uploadForm.attr("enctype", "multipart/form-data");
|
1050
|
+
uploadForm.attr("encoding", "multipart/form-data");
|
1051
|
+
uploadForm.attr("target", widget.options.iframeName);
|
1052
|
+
uploadForm.submit();
|
1053
|
+
return jQuery("#" + widget.options.iframeName).load(function() {
|
1054
|
+
return data.success(jQuery("#" + widget.options.iframeName)[0].contentWindow.location.href);
|
1055
|
+
});
|
1056
|
+
},
|
1057
|
+
_addGuiTabUpload: function(tabs, element) {
|
1058
|
+
var iframe, insertImage, widget;
|
1059
|
+
widget = this;
|
1060
|
+
tabs.append(jQuery("<li id=\"" + this.options.uuid + "-tab-upload\" class=\"" + widget.widgetName + "-tabselector " + widget.widgetName + "-tab-upload\"><span>Upload</span></li>"));
|
1061
|
+
element.append(jQuery("<div id=\"" + this.options.uuid + "-tab-upload-content\" class=\"" + widget.widgetName + "-tab tab-upload\"> <form id=\"" + this.options.uuid + "-" + widget.widgetName + "-uploadform\"> <input id=\"" + this.options.uuid + "-" + widget.widgetName + "-file\" name=\"" + this.options.uuid + "-" + widget.widgetName + "-file\" type=\"file\" class=\"file\" accept=\"image/*\"> <input id=\"" + this.options.uuid + "-" + widget.widgetName + "-tags\" name=\"tags\" type=\"hidden\" /> <br /> <input type=\"submit\" value=\"Upload\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-upload\"> </form> <div id=\"" + this.options.uuid + "-" + widget.widgetName + "-iframe\"></div> </div>"));
|
1062
|
+
iframe = jQuery("<iframe name=\"postframe\" id=\"postframe\" class=\"hidden\" src=\"about:none\" style=\"display:none\" />");
|
1063
|
+
jQuery("#" + widget.options.uuid + "-" + widget.widgetName + "-upload").live("click", function(e) {
|
1064
|
+
var userFile;
|
1065
|
+
e.preventDefault();
|
1066
|
+
userFile = jQuery("#" + widget.options.uuid + "-" + widget.widgetName + "-file").val();
|
1067
|
+
widget.options.upload({
|
1068
|
+
widget: widget,
|
1069
|
+
file: userFile,
|
1070
|
+
success: function(imageUrl) {
|
1071
|
+
var imageID, list;
|
1072
|
+
imageID = "si" + Math.floor(Math.random() * (400 - 300 + 1) + 400) + "ab";
|
1073
|
+
if (jQuery(".imageThumbnailContainer ul", widget.options.dialog).length === 0) {
|
1074
|
+
list = jQuery('<ul></ul>');
|
1075
|
+
jQuery('.imageThumbnailContainer').append(list);
|
1076
|
+
}
|
1077
|
+
jQuery(".imageThumbnailContainer ul", widget.options.dialog).append("<li><img src=\"" + imageUrl + "\" id=\"" + imageID + "\" class=\"imageThumbnail\"></li>");
|
1078
|
+
jQuery("#" + imageID).trigger("click");
|
1079
|
+
return jQuery(widget.options.dialog).find(".nav li").first().trigger("click");
|
1080
|
+
}
|
1081
|
+
});
|
1082
|
+
return false;
|
1083
|
+
});
|
1084
|
+
insertImage = function() {
|
1085
|
+
var img, triggerModified;
|
1086
|
+
try {
|
1087
|
+
if (!widget.options.editable.getSelection()) {
|
1088
|
+
throw new Error("SelectionNotSet");
|
1089
|
+
}
|
1090
|
+
} catch (error) {
|
1091
|
+
widget.options.editable.restoreSelection(widget.lastSelection);
|
1092
|
+
}
|
1093
|
+
document.execCommand("insertImage", null, jQuery(this).attr('src'));
|
1094
|
+
img = document.getSelection().anchorNode.firstChild;
|
1095
|
+
jQuery(img).attr("alt", jQuery(".caption").value);
|
1096
|
+
triggerModified = function() {
|
1097
|
+
return widget.element.trigger("hallomodified");
|
1098
|
+
};
|
1099
|
+
window.setTimeout(triggerModified, 100);
|
1100
|
+
return widget._closeDialog();
|
1101
|
+
};
|
1102
|
+
return this.options.dialog.find(".halloimage-activeImage, #" + widget.options.uuid + "-" + widget.widgetName + "-addimage").click(insertImage);
|
1103
|
+
},
|
1104
|
+
_addDragnDrop: function() {
|
1105
|
+
var dnd, draggables, editable, helper, offset, overlay, overlayMiddleConfig, third, widgetOptions;
|
1106
|
+
helper = {
|
1107
|
+
delayAction: function(functionToCall, delay) {
|
1108
|
+
var timer;
|
1109
|
+
timer = clearTimeout(timer);
|
1110
|
+
if (!timer) {
|
1111
|
+
return timer = setTimeout(functionToCall, delay);
|
1112
|
+
}
|
1113
|
+
},
|
1114
|
+
calcPosition: function(offset, event) {
|
1115
|
+
var position;
|
1116
|
+
position = offset.left + third;
|
1117
|
+
if (event.pageX >= position && event.pageX <= (offset.left + third * 2)) {
|
1118
|
+
return "middle";
|
1119
|
+
} else if (event.pageX < position) {
|
1120
|
+
return "left";
|
1121
|
+
} else if (event.pageX > (offset.left + third * 2)) {
|
1122
|
+
return "right";
|
1123
|
+
}
|
1124
|
+
},
|
1125
|
+
createInsertElement: function(image, tmp) {
|
1126
|
+
var altText, height, imageInsert, maxHeight, maxWidth, ratio, tmpImg, width;
|
1127
|
+
maxWidth = 250;
|
1128
|
+
maxHeight = 250;
|
1129
|
+
tmpImg = new Image();
|
1130
|
+
tmpImg.src = image.src;
|
1131
|
+
if (!tmp) {
|
1132
|
+
if (this.startPlace.parents(".tab-suggestions").length > 0) {
|
1133
|
+
altText = jQuery("#caption-sugg").val();
|
1134
|
+
} else if (this.startPlace.parents(".tab-search").length > 0) {
|
1135
|
+
altText = jQuery("#caption-search").val();
|
1136
|
+
} else {
|
1137
|
+
altText = jQuery(image).attr("alt");
|
1138
|
+
}
|
1139
|
+
}
|
1140
|
+
width = tmpImg.width;
|
1141
|
+
height = tmpImg.height;
|
1142
|
+
if (width > maxWidth || height > maxHeight) {
|
1143
|
+
if (width > height) {
|
1144
|
+
ratio = (tmpImg.width / maxWidth).toFixed();
|
1145
|
+
} else {
|
1146
|
+
ratio = (tmpImg.height / maxHeight).toFixed();
|
1147
|
+
}
|
1148
|
+
width = (tmpImg.width / ratio).toFixed();
|
1149
|
+
height = (tmpImg.height / ratio).toFixed();
|
1150
|
+
}
|
1151
|
+
imageInsert = jQuery("<img>").attr({
|
1152
|
+
src: tmpImg.src,
|
1153
|
+
width: width,
|
1154
|
+
height: height,
|
1155
|
+
alt: altText,
|
1156
|
+
"class": (tmp ? "tmp" : "")
|
1157
|
+
}).show();
|
1158
|
+
return imageInsert;
|
1159
|
+
},
|
1160
|
+
createLineFeedbackElement: function() {
|
1161
|
+
return jQuery("<div/>").addClass("tmpLine");
|
1162
|
+
},
|
1163
|
+
removeFeedbackElements: function() {
|
1164
|
+
return jQuery('.tmp, .tmpLine', editable).remove();
|
1165
|
+
},
|
1166
|
+
removeCustomHelper: function() {
|
1167
|
+
return jQuery(".customHelper").remove();
|
1168
|
+
},
|
1169
|
+
showOverlay: function(position) {
|
1170
|
+
var eHeight;
|
1171
|
+
eHeight = editable.height() + parseFloat(editable.css('paddingTop')) + parseFloat(editable.css('paddingBottom'));
|
1172
|
+
overlay.big.css({
|
1173
|
+
height: eHeight
|
1174
|
+
});
|
1175
|
+
overlay.left.css({
|
1176
|
+
height: eHeight
|
1177
|
+
});
|
1178
|
+
overlay.right.css({
|
1179
|
+
height: eHeight
|
1180
|
+
});
|
1181
|
+
switch (position) {
|
1182
|
+
case "left":
|
1183
|
+
overlay.big.addClass("bigOverlayLeft").removeClass("bigOverlayRight").css({
|
1184
|
+
left: third
|
1185
|
+
}).show();
|
1186
|
+
overlay.left.hide();
|
1187
|
+
return overlay.right.hide();
|
1188
|
+
case "middle":
|
1189
|
+
overlay.big.removeClass("bigOverlayLeft bigOverlayRight");
|
1190
|
+
overlay.big.hide();
|
1191
|
+
overlay.left.show();
|
1192
|
+
return overlay.right.show();
|
1193
|
+
case "right":
|
1194
|
+
overlay.big.addClass("bigOverlayRight").removeClass("bigOverlayLeft").css({
|
1195
|
+
left: 0
|
1196
|
+
}).show();
|
1197
|
+
overlay.left.hide();
|
1198
|
+
return overlay.right.hide();
|
1199
|
+
}
|
1200
|
+
},
|
1201
|
+
checkOrigin: function(event) {
|
1202
|
+
if (jQuery(event.target).parents("[contenteditable]").length !== 0) {
|
1203
|
+
return true;
|
1204
|
+
} else {
|
1205
|
+
return false;
|
1206
|
+
}
|
1207
|
+
},
|
1208
|
+
startPlace: ""
|
1209
|
+
};
|
1210
|
+
dnd = {
|
1211
|
+
createTmpFeedback: function(image, position) {
|
1212
|
+
var el;
|
1213
|
+
if (position === 'middle') {
|
1214
|
+
return helper.createLineFeedbackElement();
|
1215
|
+
} else {
|
1216
|
+
el = helper.createInsertElement(image, true);
|
1217
|
+
return el.addClass("inlineImage-" + position);
|
1218
|
+
}
|
1219
|
+
},
|
1220
|
+
handleOverEvent: function(event, ui) {
|
1221
|
+
var postPone;
|
1222
|
+
postPone = function() {
|
1223
|
+
var position;
|
1224
|
+
window.waitWithTrash = clearTimeout(window.waitWithTrash);
|
1225
|
+
position = helper.calcPosition(offset, event);
|
1226
|
+
jQuery('.trashcan', ui.helper).remove();
|
1227
|
+
editable.append(overlay.big);
|
1228
|
+
editable.append(overlay.left);
|
1229
|
+
editable.append(overlay.right);
|
1230
|
+
helper.removeFeedbackElements();
|
1231
|
+
jQuery(event.target).prepend(dnd.createTmpFeedback(ui.draggable[0], position));
|
1232
|
+
if (position === "middle") {
|
1233
|
+
jQuery(event.target).prepend(dnd.createTmpFeedback(ui.draggable[0], 'right'));
|
1234
|
+
jQuery('.tmp', jQuery(event.target)).hide();
|
1235
|
+
} else {
|
1236
|
+
jQuery(event.target).prepend(dnd.createTmpFeedback(ui.draggable[0], 'middle'));
|
1237
|
+
jQuery('.tmpLine', jQuery(event.target)).hide();
|
1238
|
+
}
|
1239
|
+
return helper.showOverlay(position);
|
1240
|
+
};
|
1241
|
+
return setTimeout(postPone, 5);
|
1242
|
+
},
|
1243
|
+
handleDragEvent: function(event, ui) {
|
1244
|
+
var position, tmpFeedbackLR, tmpFeedbackMiddle;
|
1245
|
+
position = helper.calcPosition(offset, event);
|
1246
|
+
if (position === dnd.lastPositionDrag) {
|
1247
|
+
return;
|
1248
|
+
}
|
1249
|
+
dnd.lastPositionDrag = position;
|
1250
|
+
tmpFeedbackLR = jQuery('.tmp', editable);
|
1251
|
+
tmpFeedbackMiddle = jQuery('.tmpLine', editable);
|
1252
|
+
if (position === "middle") {
|
1253
|
+
tmpFeedbackMiddle.show();
|
1254
|
+
tmpFeedbackLR.hide();
|
1255
|
+
} else {
|
1256
|
+
tmpFeedbackMiddle.hide();
|
1257
|
+
tmpFeedbackLR.removeClass("inlineImage-left inlineImage-right").addClass("inlineImage-" + position).show();
|
1258
|
+
}
|
1259
|
+
return helper.showOverlay(position);
|
1260
|
+
},
|
1261
|
+
handleLeaveEvent: function(event, ui) {
|
1262
|
+
var func;
|
1263
|
+
func = function() {
|
1264
|
+
if (!jQuery('div.trashcan', ui.helper).length) {
|
1265
|
+
jQuery(ui.helper).append(jQuery('<div class="trashcan"></div>'));
|
1266
|
+
}
|
1267
|
+
return jQuery('.bigOverlay, .smallOverlay').remove();
|
1268
|
+
};
|
1269
|
+
window.waitWithTrash = setTimeout(func, 200);
|
1270
|
+
return helper.removeFeedbackElements();
|
1271
|
+
},
|
1272
|
+
handleStartEvent: function(event, ui) {
|
1273
|
+
var internalDrop;
|
1274
|
+
internalDrop = helper.checkOrigin(event);
|
1275
|
+
if (internalDrop) {
|
1276
|
+
jQuery(event.target).remove();
|
1277
|
+
}
|
1278
|
+
jQuery(document).trigger('startPreventSave');
|
1279
|
+
return helper.startPlace = jQuery(event.target);
|
1280
|
+
},
|
1281
|
+
handleStopEvent: function(event, ui) {
|
1282
|
+
var internalDrop;
|
1283
|
+
internalDrop = helper.checkOrigin(event);
|
1284
|
+
if (internalDrop) {
|
1285
|
+
jQuery(event.target).remove();
|
1286
|
+
} else {
|
1287
|
+
editable.trigger('change');
|
1288
|
+
}
|
1289
|
+
overlay.big.hide();
|
1290
|
+
overlay.left.hide();
|
1291
|
+
overlay.right.hide();
|
1292
|
+
return jQuery(document).trigger('stopPreventSave');
|
1293
|
+
},
|
1294
|
+
handleDropEvent: function(event, ui) {
|
1295
|
+
var imageInsert, internalDrop, position;
|
1296
|
+
internalDrop = helper.checkOrigin(event);
|
1297
|
+
position = helper.calcPosition(offset, event);
|
1298
|
+
helper.removeFeedbackElements();
|
1299
|
+
helper.removeCustomHelper();
|
1300
|
+
imageInsert = helper.createInsertElement(ui.draggable[0], false);
|
1301
|
+
if (position === "middle") {
|
1302
|
+
imageInsert.show();
|
1303
|
+
imageInsert.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-" + position).css({
|
1304
|
+
position: "relative",
|
1305
|
+
left: ((editable.width() + parseFloat(editable.css('paddingLeft')) + parseFloat(editable.css('paddingRight'))) - imageInsert.attr('width')) / 2
|
1306
|
+
});
|
1307
|
+
imageInsert.insertBefore(jQuery(event.target));
|
1308
|
+
} else {
|
1309
|
+
imageInsert.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-" + position).css("display", "block");
|
1310
|
+
jQuery(event.target).prepend(imageInsert);
|
1311
|
+
}
|
1312
|
+
overlay.big.hide();
|
1313
|
+
overlay.left.hide();
|
1314
|
+
overlay.right.hide();
|
1315
|
+
editable.trigger('change');
|
1316
|
+
return dnd.init(editable);
|
1317
|
+
},
|
1318
|
+
createHelper: function(event) {
|
1319
|
+
return jQuery('<div>').css({
|
1320
|
+
backgroundImage: "url(" + jQuery(event.currentTarget).attr('src') + ")"
|
1321
|
+
}).addClass('customHelper').appendTo('body');
|
1322
|
+
},
|
1323
|
+
init: function() {
|
1324
|
+
var draggable, initDraggable;
|
1325
|
+
draggable = [];
|
1326
|
+
initDraggable = function(elem) {
|
1327
|
+
if (!elem.jquery_draggable_initialized) {
|
1328
|
+
elem.jquery_draggable_initialized = true;
|
1329
|
+
jQuery(elem).draggable({
|
1330
|
+
cursor: "move",
|
1331
|
+
helper: dnd.createHelper,
|
1332
|
+
drag: dnd.handleDragEvent,
|
1333
|
+
start: dnd.handleStartEvent,
|
1334
|
+
stop: dnd.handleStopEvent,
|
1335
|
+
disabled: !editable.hasClass('inEditMode'),
|
1336
|
+
cursorAt: {
|
1337
|
+
top: 50,
|
1338
|
+
left: 50
|
1339
|
+
}
|
1340
|
+
});
|
1341
|
+
}
|
1342
|
+
return draggables.push(elem);
|
1343
|
+
};
|
1344
|
+
jQuery(".rotationWrapper img", widgetOptions.dialog).each(function(index, elem) {
|
1345
|
+
if (!elem.jquery_draggable_initialized) {
|
1346
|
+
return initDraggable(elem);
|
1347
|
+
}
|
1348
|
+
});
|
1349
|
+
jQuery('img', editable).each(function(index, elem) {
|
1350
|
+
elem.contentEditable = false;
|
1351
|
+
if (!elem.jquery_draggable_initialized) {
|
1352
|
+
return initDraggable(elem);
|
1353
|
+
}
|
1354
|
+
});
|
1355
|
+
return jQuery('p', editable).each(function(index, elem) {
|
1356
|
+
if (jQuery(elem).data('jquery_droppable_initialized')) {
|
1357
|
+
return;
|
1358
|
+
}
|
1359
|
+
jQuery(elem).droppable({
|
1360
|
+
tolerance: "pointer",
|
1361
|
+
drop: dnd.handleDropEvent,
|
1362
|
+
over: dnd.handleOverEvent,
|
1363
|
+
out: dnd.handleLeaveEvent
|
1364
|
+
});
|
1365
|
+
return jQuery(elem).data('jquery_droppable_initialized', true);
|
1366
|
+
});
|
1367
|
+
},
|
1368
|
+
enableDragging: function() {
|
1369
|
+
return jQuery.each(draggables, function(index, d) {
|
1370
|
+
return jQuery(d).draggable('option', 'disabled', false);
|
1371
|
+
});
|
1372
|
+
},
|
1373
|
+
disableDragging: function() {
|
1374
|
+
return jQuery.each(draggables, function(index, d) {
|
1375
|
+
return jQuery(d).draggable('option', 'disabled', true);
|
1376
|
+
});
|
1377
|
+
}
|
1378
|
+
};
|
1379
|
+
draggables = [];
|
1380
|
+
editable = jQuery(this.options.editable.element);
|
1381
|
+
widgetOptions = this.options;
|
1382
|
+
offset = editable.offset();
|
1383
|
+
third = parseFloat(editable.width() / 3);
|
1384
|
+
overlayMiddleConfig = {
|
1385
|
+
width: third,
|
1386
|
+
height: editable.height()
|
1387
|
+
};
|
1388
|
+
overlay = {
|
1389
|
+
big: jQuery("<div/>").addClass("bigOverlay").css({
|
1390
|
+
width: third * 2,
|
1391
|
+
height: editable.height()
|
1392
|
+
}),
|
1393
|
+
left: jQuery("<div/>").addClass("smallOverlay smallOverlayLeft").css(overlayMiddleConfig),
|
1394
|
+
right: jQuery("<div/>").addClass("smallOverlay smallOverlayRight").css(overlayMiddleConfig).css("left", third * 2)
|
1395
|
+
};
|
1396
|
+
dnd.init();
|
1397
|
+
editable.bind('halloactivated', dnd.enableDragging);
|
1398
|
+
return editable.bind('hallodeactivated', dnd.disableDragging);
|
1399
|
+
}
|
1400
|
+
});
|
1401
|
+
})(jQuery);
|
1402
|
+
|
1403
|
+
(function(jQuery) {
|
1404
|
+
return jQuery.widget("IKS.halloformat", {
|
1405
|
+
options: {
|
1406
|
+
editable: null,
|
1407
|
+
toolbar: null,
|
1408
|
+
uuid: "",
|
1409
|
+
formattings: {
|
1410
|
+
bold: true,
|
1411
|
+
italic: true,
|
1412
|
+
strikeThrough: false,
|
1413
|
+
underline: false
|
1414
|
+
},
|
1415
|
+
buttonCssClass: null
|
1416
|
+
},
|
1417
|
+
_create: function() {
|
1418
|
+
var buttonize, buttonset, enabled, format, widget, _ref,
|
1419
|
+
_this = this;
|
1420
|
+
widget = this;
|
1421
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
1422
|
+
buttonize = function(format) {
|
1423
|
+
var buttonHolder;
|
1424
|
+
buttonHolder = jQuery('<span></span>');
|
1425
|
+
buttonHolder.hallobutton({
|
1426
|
+
label: format,
|
1427
|
+
editable: _this.options.editable,
|
1428
|
+
command: format,
|
1429
|
+
uuid: _this.options.uuid,
|
1430
|
+
cssClass: _this.options.buttonCssClass
|
1431
|
+
});
|
1432
|
+
return buttonset.append(buttonHolder);
|
1433
|
+
};
|
1434
|
+
_ref = this.options.formattings;
|
1435
|
+
for (format in _ref) {
|
1436
|
+
enabled = _ref[format];
|
1437
|
+
if (enabled) {
|
1438
|
+
buttonize(format);
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
buttonset.buttonset();
|
1442
|
+
return this.options.toolbar.append(buttonset);
|
1443
|
+
},
|
1444
|
+
_init: function() {}
|
1445
|
+
});
|
1446
|
+
})(jQuery);
|
1447
|
+
|
1448
|
+
(function(jQuery) {
|
1449
|
+
return jQuery.widget("IKS.halloreundo", {
|
1450
|
+
options: {
|
1451
|
+
editable: null,
|
1452
|
+
toolbar: null,
|
1453
|
+
uuid: '',
|
1454
|
+
buttonCssClass: null
|
1455
|
+
},
|
1456
|
+
_create: function() {
|
1457
|
+
var buttonize, buttonset,
|
1458
|
+
_this = this;
|
1459
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
1460
|
+
buttonize = function(cmd, label) {
|
1461
|
+
var buttonElement;
|
1462
|
+
buttonElement = jQuery('<span></span>');
|
1463
|
+
buttonElement.hallobutton({
|
1464
|
+
uuid: _this.options.uuid,
|
1465
|
+
editable: _this.options.editable,
|
1466
|
+
label: label,
|
1467
|
+
icon: cmd === 'undo' ? 'icon-arrow-left' : 'icon-arrow-right',
|
1468
|
+
command: cmd,
|
1469
|
+
queryState: false,
|
1470
|
+
cssClass: _this.options.buttonCssClass
|
1471
|
+
});
|
1472
|
+
return buttonset.append(buttonElement);
|
1473
|
+
};
|
1474
|
+
buttonize("undo", "Undo");
|
1475
|
+
buttonize("redo", "Redo");
|
1476
|
+
buttonset.buttonset();
|
1477
|
+
return this.options.toolbar.append(buttonset);
|
1478
|
+
},
|
1479
|
+
_init: function() {}
|
1480
|
+
});
|
1481
|
+
})(jQuery);
|
1482
|
+
|
1483
|
+
(function(jQuery) {
|
1484
|
+
return jQuery.widget('IKS.halloblock', {
|
1485
|
+
options: {
|
1486
|
+
editable: null,
|
1487
|
+
toolbar: null,
|
1488
|
+
uuid: '',
|
1489
|
+
elements: ['h1', 'h2', 'h3', 'p', 'pre', 'blockquote'],
|
1490
|
+
buttonCssClass: null
|
1491
|
+
},
|
1492
|
+
_create: function() {
|
1493
|
+
var buttonset, contentId, target;
|
1494
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
1495
|
+
contentId = "" + this.options.uuid + "-" + this.widgetName + "-data";
|
1496
|
+
target = this._prepareDropdown(contentId);
|
1497
|
+
buttonset.append(target);
|
1498
|
+
buttonset.append(this._prepareButton(target));
|
1499
|
+
return this.options.toolbar.append(buttonset);
|
1500
|
+
},
|
1501
|
+
_prepareDropdown: function(contentId) {
|
1502
|
+
var addElement, containingElement, contentArea, element, _i, _len, _ref,
|
1503
|
+
_this = this;
|
1504
|
+
contentArea = jQuery("<div id=\"" + contentId + "\"></div>");
|
1505
|
+
containingElement = this.options.editable.element.get(0).tagName.toLowerCase();
|
1506
|
+
addElement = function(element) {
|
1507
|
+
var el, queryState;
|
1508
|
+
el = jQuery("<" + element + " class=\"menu-item\">" + element + "</" + element + ">");
|
1509
|
+
if (containingElement === element) {
|
1510
|
+
el.addClass('selected');
|
1511
|
+
}
|
1512
|
+
if (containingElement !== 'div') {
|
1513
|
+
el.addClass('disabled');
|
1514
|
+
}
|
1515
|
+
el.bind('click', function() {
|
1516
|
+
if (el.hasClass('disabled')) {
|
1517
|
+
return;
|
1518
|
+
}
|
1519
|
+
return _this.options.editable.execute('formatBlock', element.toUpperCase());
|
1520
|
+
});
|
1521
|
+
queryState = function(event) {
|
1522
|
+
var block;
|
1523
|
+
block = document.queryCommandValue('formatBlock');
|
1524
|
+
if (block.toLowerCase() === element) {
|
1525
|
+
el.addClass('selected');
|
1526
|
+
return;
|
1527
|
+
}
|
1528
|
+
return el.removeClass('selected');
|
1529
|
+
};
|
1530
|
+
_this.options.editable.element.bind('halloenabled', function() {
|
1531
|
+
return _this.options.editable.element.bind('keyup paste change mouseup', queryState);
|
1532
|
+
});
|
1533
|
+
_this.options.editable.element.bind('hallodisabled', function() {
|
1534
|
+
return _this.options.editable.element.unbind('keyup paste change mouseup', queryState);
|
1535
|
+
});
|
1536
|
+
return el;
|
1537
|
+
};
|
1538
|
+
_ref = this.options.elements;
|
1539
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1540
|
+
element = _ref[_i];
|
1541
|
+
contentArea.append(addElement(element));
|
1542
|
+
}
|
1543
|
+
return contentArea;
|
1544
|
+
},
|
1545
|
+
_prepareButton: function(target) {
|
1546
|
+
var buttonElement;
|
1547
|
+
buttonElement = jQuery('<span></span>');
|
1548
|
+
buttonElement.hallodropdownbutton({
|
1549
|
+
uuid: this.options.uuid,
|
1550
|
+
editable: this.options.editable,
|
1551
|
+
label: 'block',
|
1552
|
+
icon: 'icon-text-height',
|
1553
|
+
target: target,
|
1554
|
+
cssClass: this.options.buttonCssClass
|
1555
|
+
});
|
1556
|
+
return buttonElement;
|
1557
|
+
}
|
1558
|
+
});
|
1559
|
+
})(jQuery);
|
1560
|
+
|
1561
|
+
(function(jQuery) {
|
1562
|
+
return jQuery.widget("IKS.hallolink", {
|
1563
|
+
options: {
|
1564
|
+
editable: null,
|
1565
|
+
toolbar: null,
|
1566
|
+
uuid: "",
|
1567
|
+
link: true,
|
1568
|
+
image: true,
|
1569
|
+
defaultUrl: 'http://',
|
1570
|
+
dialogOpts: {
|
1571
|
+
autoOpen: false,
|
1572
|
+
width: 540,
|
1573
|
+
height: 95,
|
1574
|
+
title: "Enter Link",
|
1575
|
+
modal: true,
|
1576
|
+
resizable: false,
|
1577
|
+
draggable: false,
|
1578
|
+
dialogClass: 'hallolink-dialog'
|
1579
|
+
}
|
1580
|
+
},
|
1581
|
+
_create: function() {
|
1582
|
+
var buttonize, buttonset, dialog, dialogId, dialogSubmitCb, urlInput, widget,
|
1583
|
+
_this = this;
|
1584
|
+
widget = this;
|
1585
|
+
dialogId = "" + this.options.uuid + "-dialog";
|
1586
|
+
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=\"Insert\" /></form></div>");
|
1587
|
+
urlInput = jQuery('input[name=url]', dialog).focus(function(e) {
|
1588
|
+
return this.select();
|
1589
|
+
});
|
1590
|
+
dialogSubmitCb = function() {
|
1591
|
+
var link;
|
1592
|
+
link = urlInput.val();
|
1593
|
+
widget.options.editable.restoreSelection(widget.lastSelection);
|
1594
|
+
if (((new RegExp(/^\s*$/)).test(link)) || link === widget.options.defaultUrl) {
|
1595
|
+
if (widget.lastSelection.collapsed) {
|
1596
|
+
widget.lastSelection.setStartBefore(widget.lastSelection.startContainer);
|
1597
|
+
widget.lastSelection.setEndAfter(widget.lastSelection.startContainer);
|
1598
|
+
window.getSelection().addRange(widget.lastSelection);
|
1599
|
+
}
|
1600
|
+
document.execCommand("unlink", null, "");
|
1601
|
+
} else {
|
1602
|
+
if (widget.lastSelection.startContainer.parentNode.href === void 0) {
|
1603
|
+
document.execCommand("createLink", null, link);
|
1604
|
+
} else {
|
1605
|
+
widget.lastSelection.startContainer.parentNode.href = link;
|
1606
|
+
}
|
1607
|
+
}
|
1608
|
+
widget.options.editable.element.trigger('change');
|
1609
|
+
widget.options.editable.removeAllSelections();
|
1610
|
+
dialog.dialog('close');
|
1611
|
+
return false;
|
1612
|
+
};
|
1613
|
+
dialog.find("form").submit(dialogSubmitCb);
|
1614
|
+
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
|
1615
|
+
buttonize = function(type) {
|
1616
|
+
var button, id;
|
1617
|
+
id = "" + _this.options.uuid + "-" + type;
|
1618
|
+
buttonset.append(jQuery("<input id=\"" + id + "\" type=\"checkbox\" /><label for=\"" + id + "\" class=\"btn anchor_button\" ><i class=\"icon-bookmark\"></i></label>").button());
|
1619
|
+
button = jQuery("#" + id, buttonset);
|
1620
|
+
button.bind("change", function(event) {
|
1621
|
+
widget.lastSelection = widget.options.editable.getSelection();
|
1622
|
+
urlInput = jQuery('input[name=url]', dialog);
|
1623
|
+
if (widget.lastSelection.startContainer.parentNode.href === void 0) {
|
1624
|
+
urlInput.val(widget.options.defaultUrl);
|
1625
|
+
} else {
|
1626
|
+
urlInput.val(jQuery(widget.lastSelection.startContainer.parentNode).attr('href'));
|
1627
|
+
jQuery(urlInput[0].form).find('input[type=submit]').val('update');
|
1628
|
+
}
|
1629
|
+
dialog.dialog('open');
|
1630
|
+
return widget.options.editable.protectFocusFrom(dialog);
|
1631
|
+
});
|
1632
|
+
return _this.element.bind("keyup paste change mouseup", function(event) {
|
1633
|
+
var nodeName, start;
|
1634
|
+
start = jQuery(widget.options.editable.getSelection().startContainer);
|
1635
|
+
nodeName = start.prop('nodeName') ? start.prop('nodeName') : start.parent().prop('nodeName');
|
1636
|
+
if (nodeName && nodeName.toUpperCase() === "A") {
|
1637
|
+
button.attr("checked", true);
|
1638
|
+
button.next().addClass("ui-state-clicked");
|
1639
|
+
return button.button("refresh");
|
1640
|
+
} else {
|
1641
|
+
button.attr("checked", false);
|
1642
|
+
button.next().removeClass("ui-state-clicked");
|
1643
|
+
return button.button("refresh");
|
1644
|
+
}
|
1645
|
+
});
|
1646
|
+
};
|
1647
|
+
if (this.options.link) {
|
1648
|
+
buttonize("A");
|
1649
|
+
}
|
1650
|
+
if (this.options.link) {
|
1651
|
+
buttonset.buttonset();
|
1652
|
+
this.options.toolbar.append(buttonset);
|
1653
|
+
return dialog.dialog(this.options.dialogOpts);
|
1654
|
+
}
|
1655
|
+
},
|
1656
|
+
_init: function() {}
|
1657
|
+
});
|
1658
|
+
})(jQuery);
|
1659
|
+
|
1660
|
+
(function(jQuery) {
|
1661
|
+
return jQuery.widget("IKS.hallojustify", {
|
1662
|
+
options: {
|
1663
|
+
editable: null,
|
1664
|
+
toolbar: null,
|
1665
|
+
uuid: '',
|
1666
|
+
buttonCssClass: null
|
1667
|
+
},
|
1668
|
+
_create: function() {
|
1669
|
+
var buttonize, buttonset,
|
1670
|
+
_this = this;
|
1671
|
+
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
|
1672
|
+
buttonize = function(alignment) {
|
1673
|
+
var buttonElement;
|
1674
|
+
buttonElement = jQuery('<span></span>');
|
1675
|
+
buttonElement.hallobutton({
|
1676
|
+
uuid: _this.options.uuid,
|
1677
|
+
editable: _this.options.editable,
|
1678
|
+
label: alignment,
|
1679
|
+
command: "justify" + alignment,
|
1680
|
+
icon: "icon-align-" + (alignment.toLowerCase()),
|
1681
|
+
cssClass: _this.options.buttonCssClass
|
1682
|
+
});
|
1683
|
+
return buttonset.append(buttonElement);
|
1684
|
+
};
|
1685
|
+
buttonize("Left");
|
1686
|
+
buttonize("Center");
|
1687
|
+
buttonize("Right");
|
1688
|
+
buttonset.buttonset();
|
1689
|
+
return this.options.toolbar.append(buttonset);
|
1690
|
+
},
|
1691
|
+
_init: function() {}
|
1692
|
+
});
|
1693
|
+
})(jQuery);
|
1694
|
+
|
1695
|
+
(function(jQuery) {
|
1696
|
+
return jQuery.widget('IKS.hallobutton', {
|
1697
|
+
button: null,
|
1698
|
+
options: {
|
1699
|
+
uuid: '',
|
1700
|
+
label: null,
|
1701
|
+
icon: null,
|
1702
|
+
editable: null,
|
1703
|
+
command: null,
|
1704
|
+
queryState: true,
|
1705
|
+
cssClass: null
|
1706
|
+
},
|
1707
|
+
_create: function() {
|
1708
|
+
var id, _base;
|
1709
|
+
if ((_base = this.options).icon == null) {
|
1710
|
+
_base.icon = "icon-" + (this.options.label.toLowerCase());
|
1711
|
+
}
|
1712
|
+
id = "" + this.options.uuid + "-" + this.options.label;
|
1713
|
+
this.element.append(this._createButton(id, this.options.command));
|
1714
|
+
this.element.append(this._createLabel(id, this.options.command, this.options.label, this.options.icon));
|
1715
|
+
if (this.options.cssClass) {
|
1716
|
+
this.element.find('label').addClass(this.options.cssClass);
|
1717
|
+
}
|
1718
|
+
this.button = this.element.find('input');
|
1719
|
+
this.button.button();
|
1720
|
+
if (this.options.cssClass) {
|
1721
|
+
this.button.addClass(this.options.cssClass);
|
1722
|
+
}
|
1723
|
+
return this.button.data('hallo-command', this.options.command);
|
1724
|
+
},
|
1725
|
+
_init: function() {
|
1726
|
+
var editableElement, queryState,
|
1727
|
+
_this = this;
|
1728
|
+
if (!this.button) {
|
1729
|
+
this.button = this._prepareButton();
|
1730
|
+
}
|
1731
|
+
this.element.append(this.button);
|
1732
|
+
if (this.options.command) {
|
1733
|
+
this.button.bind('change', function(event) {
|
1734
|
+
return _this.options.editable.execute(_this.options.command);
|
1735
|
+
});
|
1736
|
+
}
|
1737
|
+
if (!this.options.queryState) {
|
1738
|
+
return;
|
1739
|
+
}
|
1740
|
+
editableElement = this.options.editable.element;
|
1741
|
+
queryState = function(event) {
|
1742
|
+
if (!_this.options.command) {
|
1743
|
+
return;
|
1744
|
+
}
|
1745
|
+
try {
|
1746
|
+
return _this.checked(document.queryCommandState(_this.options.command));
|
1747
|
+
} catch (e) {
|
1748
|
+
|
1749
|
+
}
|
1750
|
+
};
|
1751
|
+
editableElement.bind('halloenabled', function() {
|
1752
|
+
return editableElement.bind('keyup paste change mouseup hallomodified', queryState);
|
1753
|
+
});
|
1754
|
+
return editableElement.bind('hallodisabled', function() {
|
1755
|
+
return editableElement.unbind('keyup paste change mouseup hallomodified', queryState);
|
1756
|
+
});
|
1757
|
+
},
|
1758
|
+
enable: function() {
|
1759
|
+
return this.button.button('enable');
|
1760
|
+
},
|
1761
|
+
disable: function() {
|
1762
|
+
return this.button.button('disable');
|
1763
|
+
},
|
1764
|
+
refresh: function() {
|
1765
|
+
return this.button.button('refresh');
|
1766
|
+
},
|
1767
|
+
checked: function(checked) {
|
1768
|
+
this.button.attr('checked', checked);
|
1769
|
+
return this.refresh();
|
1770
|
+
},
|
1771
|
+
_createButton: function(id) {
|
1772
|
+
return jQuery("<input id=\"" + id + "\" type=\"checkbox\" />");
|
1773
|
+
},
|
1774
|
+
_createLabel: function(id, command, label, icon) {
|
1775
|
+
return jQuery("<label for=\"" + id + "\" class=\"" + command + "_button\" title=\"" + label + "\"><i class=\"" + icon + "\"></i></label>");
|
1776
|
+
}
|
1777
|
+
});
|
1778
|
+
})(jQuery);
|
1779
|
+
|
1780
|
+
(function(jQuery) {
|
1781
|
+
return jQuery.widget('IKS.hallodropdownbutton', {
|
1782
|
+
button: null,
|
1783
|
+
options: {
|
1784
|
+
uuid: '',
|
1785
|
+
label: null,
|
1786
|
+
icon: null,
|
1787
|
+
editable: null,
|
1788
|
+
target: '',
|
1789
|
+
cssClass: null
|
1790
|
+
},
|
1791
|
+
_create: function() {
|
1792
|
+
var _base, _ref;
|
1793
|
+
return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "icon-" + (this.options.label.toLowerCase());
|
1794
|
+
},
|
1795
|
+
_init: function() {
|
1796
|
+
var target,
|
1797
|
+
_this = this;
|
1798
|
+
target = jQuery(this.options.target);
|
1799
|
+
target.css('position', 'absolute');
|
1800
|
+
target.addClass('dropdown-menu');
|
1801
|
+
target.hide();
|
1802
|
+
if (!this.button) {
|
1803
|
+
this.button = this._prepareButton();
|
1804
|
+
}
|
1805
|
+
this.button.bind('click', function() {
|
1806
|
+
if (target.hasClass('open')) {
|
1807
|
+
_this._hideTarget();
|
1808
|
+
return;
|
1809
|
+
}
|
1810
|
+
return _this._showTarget();
|
1811
|
+
});
|
1812
|
+
target.bind('click', function() {
|
1813
|
+
return _this._hideTarget();
|
1814
|
+
});
|
1815
|
+
this.options.editable.element.bind('hallodeactivated', function() {
|
1816
|
+
return _this._hideTarget();
|
1817
|
+
});
|
1818
|
+
return this.element.append(this.button);
|
1819
|
+
},
|
1820
|
+
_showTarget: function() {
|
1821
|
+
var target;
|
1822
|
+
target = jQuery(this.options.target);
|
1823
|
+
this._updateTargetPosition();
|
1824
|
+
target.addClass('open');
|
1825
|
+
return target.show();
|
1826
|
+
},
|
1827
|
+
_hideTarget: function() {
|
1828
|
+
var target;
|
1829
|
+
target = jQuery(this.options.target);
|
1830
|
+
target.removeClass('open');
|
1831
|
+
return target.hide();
|
1832
|
+
},
|
1833
|
+
_updateTargetPosition: function() {
|
1834
|
+
var bottom, left, target, _ref;
|
1835
|
+
target = jQuery(this.options.target);
|
1836
|
+
_ref = this.element.position(), bottom = _ref.bottom, left = _ref.left;
|
1837
|
+
target.css('top', bottom);
|
1838
|
+
return target.css('left', left - 20);
|
1839
|
+
},
|
1840
|
+
_prepareButton: function() {
|
1841
|
+
var button, buttonEl, id;
|
1842
|
+
id = "" + this.options.uuid + "-" + this.options.label;
|
1843
|
+
buttonEl = jQuery("<button id=\"" + id + "\" data-toggle=\"dropdown\" data-target=\"#" + (this.options.target.attr('id')) + "\" title=\"" + this.options.label + "\">\n <span class=\"ui-button-text\"><i class=\"" + this.options.icon + "\"></i></span>\n</button>");
|
1844
|
+
if (this.options.cssClass) {
|
1845
|
+
buttonEl.addClass(this.options.cssClass);
|
1846
|
+
}
|
1847
|
+
button = buttonEl.button();
|
1848
|
+
return button;
|
1849
|
+
}
|
1850
|
+
});
|
1851
|
+
})(jQuery);
|
1852
|
+
|
1853
|
+
}).call(this);
|