').css({
backgroundImage: "url(" + (jQuery(event.currentTarget).attr('src')) + ")"
}).addClass('customHelper').appendTo('body');
},
_initDraggable: function(elem, editable) {
var widget;
widget = this;
if (!elem.jquery_draggable_initialized) {
elem.jquery_draggable_initialized = true;
jQuery(elem).draggable({
cursor: 'move',
helper: function(event) {
return widget._createHelper(event);
},
drag: function(event, ui) {
return widget._handleDragEvent(event, ui);
},
start: function(event, ui) {
return widget._handleStartEvent(event, ui);
},
stop: function(event, ui) {
return widget._handleStopEvent(event, ui);
},
disabled: !editable.hasClass('inEditMode'),
cursorAt: {
top: 50,
left: 50
}
});
}
return widget.options.draggables.push(elem);
},
_initImage: function(editable) {
var widget;
widget = this;
return jQuery('.rotationWrapper img', this.options.dialog).each(function(index, elem) {
return widget._initDraggable(elem, editable);
});
},
_enableDragging: function() {
return jQuery.each(this.options.draggables, function(index, d) {
return jQuery(d).draggable('option', 'disabled', false);
});
},
_disableDragging: function() {
return jQuery.each(this.options.draggables, function(index, d) {
return jQuery(d).draggable('option', 'disabled', true);
});
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget("IKS.hallojustify", {
options: {
editable: null,
toolbar: null,
uuid: '',
buttonCssClass: null
},
populateToolbar: function(toolbar) {
var buttonize, buttonset,
_this = this;
buttonset = jQuery("
");
buttonize = function(alignment) {
var buttonElement;
buttonElement = jQuery('
');
buttonElement.hallobutton({
uuid: _this.options.uuid,
editable: _this.options.editable,
label: alignment,
command: "justify" + alignment,
icon: "fa fa-align-" + (alignment.toLowerCase()),
cssClass: _this.options.buttonCssClass
});
return buttonset.append(buttonElement);
};
buttonize("Left");
buttonize("Center");
buttonize("Right");
buttonset.hallobuttonset();
return toolbar.append(buttonset);
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget('IKS.halloblacklist', {
options: {
tags: []
},
_init: function() {
if (this.options.tags.indexOf('br') !== -1) {
return this.element.on('keydown', function(event) {
if (event.originalEvent.keyCode === 13) {
return event.preventDefault();
}
});
}
},
cleanupContentClone: function(el) {
var tag, _i, _len, _ref, _results;
_ref = this.options.tags;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
tag = _ref[_i];
_results.push(jQuery(tag, el).remove());
}
return _results;
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget("Liip.hallotoolbarlinebreak", {
options: {
editable: null,
uuid: "",
breakAfter: []
},
populateToolbar: function(toolbar) {
var buttonRow, buttonset, buttonsets, queuedButtonsets, row, rowcounter, _i, _j, _len, _len1, _ref;
buttonsets = jQuery('.ui-buttonset', toolbar);
queuedButtonsets = jQuery();
rowcounter = 0;
_ref = this.options.breakAfter;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
row = _ref[_i];
rowcounter++;
buttonRow = "
";
for (_j = 0, _len1 = buttonsets.length; _j < _len1; _j++) {
buttonset = buttonsets[_j];
queuedButtonsets = jQuery(queuedButtonsets).add(jQuery(buttonset));
if (jQuery(buttonset).hasClass(row)) {
queuedButtonsets.wrapAll(buttonRow);
buttonsets = buttonsets.not(queuedButtonsets);
queuedButtonsets = jQuery();
break;
}
}
}
if (buttonsets.length > 0) {
rowcounter++;
buttonRow = "
";
return buttonsets.wrapAll(buttonRow);
}
}
});
})(jQuery);
(function(jQuery) {
jQuery.widget('IKS.hallobutton', {
button: null,
isChecked: false,
options: {
uuid: '',
label: null,
icon: null,
editable: null,
command: null,
commandValue: null,
queryState: true,
cssClass: null
},
_create: function() {
var hoverclass, id, opts, _base, _ref,
_this = this;
if ((_ref = (_base = this.options).icon) == null) {
_base.icon = "fa fa-" + (this.options.label.toLowerCase());
}
id = "" + this.options.uuid + "-" + this.options.label;
opts = this.options;
this.button = this._createButton(id, opts.command, opts.label, opts.icon);
this.element.append(this.button);
if (this.options.cssClass) {
this.button.addClass(this.options.cssClass);
}
if (this.options.editable.options.touchScreen) {
this.button.addClass('btn-large');
}
this.button.data('hallo-command', this.options.command);
if (this.options.commandValue) {
this.button.data('hallo-command-value', this.options.commandValue);
}
hoverclass = 'ui-state-hover';
this.button.on('mouseenter', function(event) {
if (_this.isEnabled()) {
return _this.button.addClass(hoverclass);
}
});
return this.button.on('mouseleave', function(event) {
return _this.button.removeClass(hoverclass);
});
},
_init: function() {
var editableElement, events, queryState,
_this = this;
if (!this.button) {
this.button = this._prepareButton();
}
this.element.append(this.button);
if (this.options.queryState === true) {
queryState = function(event) {
var compared, value;
if (!_this.options.command) {
return;
}
try {
if (_this.options.commandValue) {
value = document.queryCommandValue(_this.options.command);
compared = value.match(new RegExp(_this.options.commandValue, "i"));
return _this.checked(compared ? true : false);
} else {
return _this.checked(document.queryCommandState(_this.options.command));
}
} catch (e) {
}
};
} else {
queryState = this.options.queryState;
}
if (this.options.command) {
this.button.on('click', function(event) {
if (_this.options.commandValue) {
_this.options.editable.execute(_this.options.command, _this.options.commandValue);
} else {
_this.options.editable.execute(_this.options.command);
}
queryState();
return false;
});
}
if (!this.options.queryState) {
return;
}
editableElement = this.options.editable.element;
events = 'keyup paste change mouseup hallomodified';
editableElement.on(events, queryState);
editableElement.on('halloenabled', function() {
return editableElement.on(events, queryState);
});
return editableElement.on('hallodisabled', function() {
return editableElement.off(events, queryState);
});
},
enable: function() {
return this.button.removeAttr('disabled');
},
disable: function() {
return this.button.attr('disabled', 'true');
},
isEnabled: function() {
return this.button.attr('disabled') !== 'true';
},
refresh: function() {
if (this.isChecked) {
return this.button.addClass('ui-state-active');
} else {
return this.button.removeClass('ui-state-active');
}
},
checked: function(checked) {
this.isChecked = checked;
return this.refresh();
},
_createButton: function(id, command, label, icon) {
var classes;
classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only', "" + command + "_button"];
return jQuery("
");
}
});
return jQuery.widget('IKS.hallobuttonset', {
buttons: null,
_create: function() {
return this.element.addClass('ui-buttonset');
},
_init: function() {
return this.refresh();
},
refresh: function() {
var rtl;
rtl = this.element.css('direction') === 'rtl';
this.buttons = this.element.find('.ui-button');
this.buttons.removeClass('ui-corner-all ui-corner-left ui-corner-right');
if (rtl) {
this.buttons.filter(':first').addClass('ui-corner-right');
return this.buttons.filter(':last').addClass('ui-corner-left');
} else {
this.buttons.filter(':first').addClass('ui-corner-left');
return this.buttons.filter(':last').addClass('ui-corner-right');
}
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget('IKS.hallodropdownbutton', {
button: null,
options: {
uuid: '',
label: null,
icon: null,
editable: null,
target: '',
cssClass: null
},
_create: function() {
var _base, _ref;
return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "fa fa-" + (this.options.label.toLowerCase());
},
_init: function() {
var target,
_this = this;
target = jQuery(this.options.target);
target.css('position', 'absolute');
target.addClass('dropdown-menu');
target.hide();
if (!this.button) {
this.button = this._prepareButton();
}
this.button.on('click', function() {
if (target.hasClass('open')) {
_this._hideTarget();
return;
}
return _this._showTarget();
});
target.on('click', function() {
return _this._hideTarget();
});
this.options.editable.element.on('hallodeactivated', function() {
return _this._hideTarget();
});
return this.element.append(this.button);
},
_showTarget: function() {
var target;
target = jQuery(this.options.target);
this._updateTargetPosition();
target.addClass('open');
return target.show();
},
_hideTarget: function() {
var target;
target = jQuery(this.options.target);
target.removeClass('open');
return target.hide();
},
_updateTargetPosition: function() {
var left, target, top, _ref;
target = jQuery(this.options.target);
_ref = this.button.position(), top = _ref.top, left = _ref.left;
top += this.button.outerHeight();
target.css('top', top);
return target.css('left', left - 20);
},
_prepareButton: function() {
var buttonEl, classes, id;
id = "" + this.options.uuid + "-" + this.options.label;
classes = ['ui-button', 'ui-widget', 'ui-state-default', 'ui-corner-all', 'ui-button-text-only'];
buttonEl = jQuery("
");
if (this.options.cssClass) {
buttonEl.addClass(this.options.cssClass);
}
return buttonEl;
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget('IKS.halloToolbarFixed', {
toolbar: null,
options: {
parentElement: 'body',
editable: null,
toolbar: null,
affix: true,
affixTopOffset: 2
},
_create: function() {
var el, widthToAdd,
_this = this;
this.toolbar = this.options.toolbar;
this.toolbar.show();
jQuery(this.options.parentElement).append(this.toolbar);
this._bindEvents();
jQuery(window).resize(function(event) {
return _this.setPosition();
});
jQuery(window).scroll(function(event) {
return _this.setPosition();
});
if (this.options.parentElement === 'body') {
el = jQuery(this.element);
widthToAdd = parseFloat(el.css('padding-left'));
widthToAdd += parseFloat(el.css('padding-right'));
widthToAdd += parseFloat(el.css('border-left-width'));
widthToAdd += parseFloat(el.css('border-right-width'));
widthToAdd += (parseFloat(el.css('outline-width'))) * 2;
widthToAdd += (parseFloat(el.css('outline-offset'))) * 2;
return jQuery(this.toolbar).css("width", el.width() + widthToAdd);
}
},
_getPosition: function(event, selection) {
var offset, position, width;
if (!event) {
return;
}
width = parseFloat(this.element.css('outline-width'));
offset = width + parseFloat(this.element.css('outline-offset'));
return position = {
top: this.element.offset().top - this.toolbar.outerHeight() - offset,
left: this.element.offset().left - offset
};
},
_getCaretPosition: function(range) {
var newRange, position, tmpSpan;
tmpSpan = jQuery("
");
newRange = rangy.createRange();
newRange.setStart(range.endContainer, range.endOffset);
newRange.insertNode(tmpSpan.get(0));
position = {
top: tmpSpan.offset().top,
left: tmpSpan.offset().left
};
tmpSpan.remove();
return position;
},
setPosition: function() {
var elementBottom, elementTop, height, offset, scrollTop, topOffset;
if (this.options.parentElement !== 'body') {
return;
}
this.toolbar.css('position', 'absolute');
this.toolbar.css('top', this.element.offset().top - this.toolbar.outerHeight());
if (this.options.affix) {
scrollTop = jQuery(window).scrollTop();
offset = this.element.offset();
height = this.element.height();
topOffset = this.options.affixTopOffset;
elementTop = offset.top - (this.toolbar.height() + this.options.affixTopOffset);
elementBottom = (height - topOffset) + (offset.top - this.toolbar.height());
if (scrollTop > elementTop && scrollTop < elementBottom) {
this.toolbar.css('position', 'fixed');
this.toolbar.css('top', this.options.affixTopOffset);
}
} else {
}
return this.toolbar.css('left', this.element.offset().left - 2);
},
_updatePosition: function(position) {},
_bindEvents: function() {
var _this = this;
this.element.on('halloactivated', function(event, data) {
_this.setPosition();
return _this.toolbar.show();
});
return this.element.on('hallodeactivated', function(event, data) {
return _this.toolbar.hide();
});
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget('IKS.halloToolbarContextual', {
toolbar: null,
options: {
parentElement: 'body',
editable: null,
toolbar: null,
positionAbove: false
},
_create: function() {
var _this = this;
this.toolbar = this.options.toolbar;
jQuery(this.options.parentElement).append(this.toolbar);
this._bindEvents();
return jQuery(window).resize(function(event) {
return _this._updatePosition(_this._getPosition(event));
});
},
_getPosition: function(event, selection) {
var eventType, position;
if (!event) {
return;
}
eventType = event.type;
switch (eventType) {
case 'keydown':
case 'keyup':
case 'keypress':
return this._getCaretPosition(selection);
case 'click':
case 'mousedown':
case 'mouseup':
return position = {
top: event.pageY,
left: event.pageX
};
}
},
_getCaretPosition: function(range) {
var newRange, position, tmpSpan;
tmpSpan = jQuery("
");
newRange = rangy.createRange();
newRange.setStart(range.endContainer, range.endOffset);
newRange.insertNode(tmpSpan.get(0));
position = {
top: tmpSpan.offset().top,
left: tmpSpan.offset().left
};
tmpSpan.remove();
return position;
},
setPosition: function() {
if (this.options.parentElement !== 'body') {
this.options.parentElement = 'body';
jQuery(this.options.parentElement).append(this.toolbar);
}
this.toolbar.css('position', 'absolute');
this.toolbar.css('top', this.element.offset().top - 20);
return this.toolbar.css('left', this.element.offset().left);
},
_updatePosition: function(position, selection) {
var left, selectionRect, toolbar_height_offset, top, top_offset;
if (selection == null) {
selection = null;
}
if (!position) {
return;
}
if (!(position.top && position.left)) {
return;
}
toolbar_height_offset = this.toolbar.outerHeight() + 10;
if (selection && !selection.collapsed && selection.nativeRange) {
selectionRect = selection.nativeRange.getBoundingClientRect();
if (this.options.positionAbove) {
top_offset = selectionRect.top - toolbar_height_offset;
} else {
top_offset = selectionRect.bottom + 10;
}
top = jQuery(window).scrollTop() + top_offset;
left = jQuery(window).scrollLeft() + selectionRect.left;
} else {
if (this.options.positionAbove) {
top_offset = -10 - toolbar_height_offset;
} else {
top_offset = 20;
}
top = position.top + top_offset;
left = position.left - this.toolbar.outerWidth() / 2 + 30;
}
this.toolbar.css('top', top);
return this.toolbar.css('left', left);
},
_bindEvents: function() {
var _this = this;
this.element.on('halloselected', function(event, data) {
var position;
position = _this._getPosition(data.originalEvent, data.selection);
if (!position) {
return;
}
_this._updatePosition(position, data.selection);
if (_this.toolbar.html() !== '') {
return _this.toolbar.show();
}
});
this.element.on('hallounselected', function(event, data) {
return _this.toolbar.hide();
});
return this.element.on('hallodeactivated', function(event, data) {
return _this.toolbar.hide();
});
}
});
})(jQuery);
/*
Hallo 1.0.2 - a rich text editing jQuery UI widget
(c) 2011 Henri Bergius, IKS Consortium
Hallo may be freely distributed under the MIT license
http://hallojs.org
*/
(function(jQuery) {
return jQuery.widget('IKS.hallo', {
toolbar: null,
bound: false,
originalContent: '',
previousContent: '',
uuid: '',
selection: null,
_keepActivated: false,
originalHref: null,
options: {
editable: true,
plugins: {},
toolbar: 'halloToolbarContextual',
parentElement: 'body',
buttonCssClass: null,
toolbarCssClass: null,
toolbarPositionAbove: false,
toolbarOptions: {},
placeholder: '',
forceStructured: true,
checkTouch: true,
touchScreen: null
},
_create: function() {
var options, plugin, _ref,
_this = this;
this.id = this._generateUUID();
if (this.options.checkTouch && this.options.touchScreen === null) {
this.checkTouch();
}
_ref = this.options.plugins;
for (plugin in _ref) {
options = _ref[plugin];
if (!jQuery.isPlainObject(options)) {
options = {};
}
jQuery.extend(options, {
editable: this,
uuid: this.id,
buttonCssClass: this.options.buttonCssClass
});
jQuery(this.element)[plugin](options);
}
this.element.one('halloactivated', function() {
return _this._prepareToolbar();
});
return this.originalContent = this.getContents();
},
_init: function() {
if (this.options.editable) {
return this.enable();
} else {
return this.disable();
}
},
destroy: function() {
var options, plugin, _ref;
this.disable();
if (this.toolbar) {
this.toolbar.remove();
this.element[this.options.toolbar]('destroy');
}
_ref = this.options.plugins;
for (plugin in _ref) {
options = _ref[plugin];
jQuery(this.element)[plugin]('destroy');
}
return jQuery.Widget.prototype.destroy.call(this);
},
disable: function() {
var _this = this;
this.element.attr("contentEditable", false);
this.element.off("focus", this._activated);
this.element.off("blur", this._deactivated);
this.element.off("keyup paste change", this._checkModified);
this.element.off("keyup", this._keys);
this.element.off("keyup mouseup", this._checkSelection);
this.bound = false;
jQuery(this.element).removeClass('isModified');
jQuery(this.element).removeClass('inEditMode');
this.element.parents('a').andSelf().each(function(idx, elem) {
var element;
element = jQuery(elem);
if (!element.is('a')) {
return;
}
if (!_this.originalHref) {
return;
}
return element.attr('href', _this.originalHref);
});
return this._trigger("disabled", null);
},
enable: function() {
var _this = this;
this.element.parents('a[href]').andSelf().each(function(idx, elem) {
var element;
element = jQuery(elem);
if (!element.is('a[href]')) {
return;
}
_this.originalHref = element.attr('href');
return element.removeAttr('href');
});
this.element.attr("contentEditable", true);
if (!this.element.html().trim()) {
this.element.html(this.options.placeholder);
this.element.css({
'min-width': this.element.innerWidth(),
'min-height': this.element.innerHeight()
});
}
if (!this.bound) {
this.element.on("focus", this, this._activated);
this.element.on("blur", this, this._deactivated);
this.element.on("keyup paste change", this, this._checkModified);
this.element.on("keyup", this, this._keys);
this.element.on("keyup mouseup", this, this._checkSelection);
this.bound = true;
}
if (this.options.forceStructured) {
this._forceStructured();
}
return this._trigger("enabled", null);
},
activate: function() {
return this.element.focus();
},
containsSelection: function() {
var range;
range = this.getSelection();
return this.element.has(range.startContainer).length > 0;
},
getSelection: function() {
var range, sel;
sel = rangy.getSelection();
range = null;
if (sel.rangeCount > 0) {
range = sel.getRangeAt(0);
} else {
range = rangy.createRange();
}
return range;
},
restoreSelection: function(range) {
var sel;
sel = rangy.getSelection();
return sel.setSingleRange(range);
},
replaceSelection: function(cb) {
var newTextNode, r, range, sel, t;
if (navigator.appName === 'Microsoft Internet Explorer') {
t = document.selection.createRange().text;
r = document.selection.createRange();
return r.pasteHTML(cb(t));
} else {
sel = window.getSelection();
range = sel.getRangeAt(0);
newTextNode = document.createTextNode(cb(range.extractContents()));
range.insertNode(newTextNode);
range.setStartAfter(newTextNode);
sel.removeAllRanges();
return sel.addRange(range);
}
},
removeAllSelections: function() {
if (navigator.appName === 'Microsoft Internet Explorer') {
return range.empty();
} else {
return window.getSelection().removeAllRanges();
}
},
getContents: function() {
var cleanup, contentClone, plugin;
contentClone = this.element.clone();
for (plugin in this.options.plugins) {
cleanup = jQuery(this.element).data('IKS-' + plugin).cleanupContentClone;
if (!jQuery.isFunction(cleanup)) {
continue;
}
jQuery(this.element)[plugin]('cleanupContentClone', contentClone);
}
return contentClone.html();
},
setContents: function(contents) {
return this.element.html(contents);
},
isModified: function() {
if (!this.previousContent) {
this.previousContent = this.originalContent;
}
return this.previousContent !== this.getContents();
},
setUnmodified: function() {
jQuery(this.element).removeClass('isModified');
return this.previousContent = this.getContents();
},
setModified: function() {
jQuery(this.element).addClass('isModified');
return this._trigger('modified', null, {
editable: this,
content: this.getContents()
});
},
restoreOriginalContent: function() {
return this.element.html(this.originalContent);
},
execute: function(command, value) {
if (document.execCommand(command, false, value)) {
return this.element.trigger("change");
}
},
protectFocusFrom: function(el) {
var _this = this;
return el.on("mousedown", function(event) {
event.preventDefault();
_this._protectToolbarFocus = true;
return setTimeout(function() {
return _this._protectToolbarFocus = false;
}, 300);
});
},
keepActivated: function(_keepActivated) {
this._keepActivated = _keepActivated;
},
_generateUUID: function() {
var S4;
S4 = function() {
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
};
return "" + (S4()) + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + (S4()) + (S4());
},
_prepareToolbar: function() {
var defaults, plugin, populate, toolbarOptions;
this.toolbar = jQuery('
').hide();
if (this.options.toolbarCssClass) {
this.toolbar.addClass(this.options.toolbarCssClass);
}
defaults = {
editable: this,
parentElement: this.options.parentElement,
toolbar: this.toolbar,
positionAbove: this.options.toolbarPositionAbove
};
toolbarOptions = $.extend({}, defaults, this.options.toolbarOptions);
this.element[this.options.toolbar](toolbarOptions);
for (plugin in this.options.plugins) {
populate = jQuery(this.element).data('IKS-' + plugin).populateToolbar;
if (!jQuery.isFunction(populate)) {
continue;
}
this.element[plugin]('populateToolbar', this.toolbar);
}
this.element[this.options.toolbar]('setPosition');
return this.protectFocusFrom(this.toolbar);
},
changeToolbar: function(element, toolbar, hide) {
var originalToolbar;
if (hide == null) {
hide = false;
}
originalToolbar = this.options.toolbar;
this.options.parentElement = element;
if (toolbar) {
this.options.toolbar = toolbar;
}
if (!this.toolbar) {
return;
}
this.element[originalToolbar]('destroy');
this.toolbar.remove();
this._prepareToolbar();
if (hide) {
return this.toolbar.hide();
}
},
_checkModified: function(event) {
var widget;
widget = event.data;
if (widget.isModified()) {
return widget.setModified();
}
},
_keys: function(event) {
var old, widget;
widget = event.data;
if (event.keyCode === 27) {
old = widget.getContents();
widget.restoreOriginalContent(event);
widget._trigger("restored", null, {
editable: widget,
content: widget.getContents(),
thrown: old
});
return widget.turnOff();
}
},
_rangesEqual: function(r1, r2) {
if (r1.startContainer !== r2.startContainer) {
return false;
}
if (r1.startOffset !== r2.startOffset) {
return false;
}
if (r1.endContainer !== r2.endContainer) {
return false;
}
if (r1.endOffset !== r2.endOffset) {
return false;
}
return true;
},
_checkSelection: function(event) {
var widget;
if (event.keyCode === 27) {
return;
}
widget = event.data;
return setTimeout(function() {
var sel;
sel = widget.getSelection();
if (widget._isEmptySelection(sel) || widget._isEmptyRange(sel)) {
if (widget.selection) {
widget.selection = null;
widget._trigger("unselected", null, {
editable: widget,
originalEvent: event
});
}
return;
}
if (!widget.selection || !widget._rangesEqual(sel, widget.selection)) {
widget.selection = sel.cloneRange();
return widget._trigger("selected", null, {
editable: widget,
selection: widget.selection,
ranges: [widget.selection],
originalEvent: event
});
}
}, 0);
},
_isEmptySelection: function(selection) {
if (selection.type === "Caret") {
return true;
}
return false;
},
_isEmptyRange: function(range) {
if (range.collapsed) {
return true;
}
if (range.isCollapsed) {
if (typeof range.isCollapsed === 'function') {
return range.isCollapsed();
}
return range.isCollapsed;
}
return false;
},
turnOn: function() {
if (this.getContents() === this.options.placeholder) {
this.setContents('');
}
jQuery(this.element).addClass('inEditMode');
return this._trigger("activated", null, this);
},
turnOff: function() {
jQuery(this.element).removeClass('inEditMode');
this._trigger("deactivated", null, this);
if (!this.getContents()) {
return this.setContents(this.options.placeholder);
}
},
_activated: function(event) {
return event.data.turnOn();
},
_deactivated: function(event) {
if (event.data._keepActivated) {
return;
}
if (event.data._protectToolbarFocus !== true) {
return event.data.turnOff();
} else {
return setTimeout(function() {
return jQuery(event.data.element).focus();
}, 300);
}
},
_forceStructured: function(event) {
try {
return document.execCommand('styleWithCSS', 0, false);
} catch (e) {
try {
return document.execCommand('useCSS', 0, true);
} catch (e) {
try {
return document.execCommand('styleWithCSS', false, false);
} catch (e) {
}
}
}
},
checkTouch: function() {
return this.options.touchScreen = !!('createTouch' in document);
}
});
})(jQuery);
}).call(this);