{I"
class:ETI"BundledAsset; FI"logical_path; TI"mercury/regions/full.js; FI"
pathname; TI"Œ/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/regions/full.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+½¡9RI"length; Ti–kI"digest; TI"%d3dd1da10f365190b99d4dd1f0dc1b60; FI"source; TI"–k(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
this.Mercury.Regions.Full = (function(_super) {
var type;
__extends(Full, _super);
Full.supported = document.designMode && !jQuery.browser.konqueror && (!jQuery.browser.msie || (jQuery.browser.msie && parseFloat(jQuery.browser.version, 10) >= 10));
Full.supportedText = "Chrome 10+, Firefox 4+, Safari 5+, Opera 11.64+";
type = 'full';
Full.prototype.type = function() {
return type;
};
function Full(element, window, options) {
this.element = element;
this.window = window;
this.options = options != null ? options : {};
Full.__super__.constructor.apply(this, arguments);
}
Full.prototype.build = function() {
var e, element, _i, _len, _ref;
if (jQuery.browser.mozilla && this.content() === '') {
this.content(' ');
}
this.element.data({
originalOverflow: this.element.css('overflow')
});
this.element.css({
overflow: 'auto'
});
this.specialContainer = jQuery.browser.mozilla && this.element.get(0).tagName !== 'DIV';
this.element.get(0).contentEditable = true;
_ref = this.element.find('[data-snippet]');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
element = _ref[_i];
element.contentEditable = false;
jQuery(element).attr('data-version', '1');
}
if (!this.document.mercuryEditing) {
this.document.mercuryEditing = true;
try {
this.document.execCommand('styleWithCSS', false, false);
this.document.execCommand('insertBROnReturn', false, true);
this.document.execCommand('enableInlineTableEditing', false, false);
return this.document.execCommand('enableObjectResizing', false, false);
} catch (_error) {
e = _error;
}
}
};
Full.prototype.bindEvents = function() {
var _this = this;
Full.__super__.bindEvents.apply(this, arguments);
Mercury.on('region:update', function() {
var anchor, currentElement, table;
if (_this.previewing || Mercury.region !== _this) {
return;
}
setTimeout((function() {
return _this.selection().forceSelection(_this.element.get(0));
}), 1);
currentElement = _this.currentElement();
if (currentElement.length) {
table = currentElement.closest('table', _this.element);
if (table.length) {
Mercury.tableEditor(table, currentElement.closest('tr, td'), '
');
}
anchor = currentElement.closest('a', _this.element);
if (anchor.length && anchor.attr('href')) {
return Mercury.tooltip(anchor, "" + (anchor.attr('href')) + "", {
position: 'below'
});
} else {
return Mercury.tooltip.hide();
}
}
});
this.element.on('dragenter', function(event) {
if (_this.previewing) {
return;
}
if (!Mercury.snippet) {
event.preventDefault();
}
return event.originalEvent.dataTransfer.dropEffect = 'copy';
});
this.element.on('dragover', function(event) {
if (_this.previewing) {
return;
}
if (!Mercury.snippet) {
event.preventDefault();
}
return event.originalEvent.dataTransfer.dropEffect = 'copy';
});
this.element.on('drop', function(event) {
if (_this.previewing) {
return;
}
clearTimeout(_this.dropTimeout);
_this.dropTimeout = setTimeout((function() {
return _this.element.trigger('possible:drop');
}), 1);
if (!event.originalEvent.dataTransfer.files.length) {
return;
}
event.preventDefault();
_this.focus();
return Mercury.uploader(event.originalEvent.dataTransfer.files[0]);
});
this.element.on('possible:drop', function() {
if (_this.previewing) {
return;
}
if (Mercury.snippet) {
_this.focus();
Mercury.Snippet.displayOptionsFor(Mercury.snippet.name, {}, Mercury.snippet.hasOptions);
return _this.document.execCommand('undo', false, null);
}
});
this.element.on('paste', function(event) {
if (_this.previewing || Mercury.region !== _this) {
return;
}
if (_this.specialContainer) {
event.preventDefault();
return;
}
if (_this.pasting) {
return;
}
Mercury.changes = true;
return _this.handlePaste(event.originalEvent);
});
this.element.on('focus', function() {
if (_this.previewing) {
return;
}
Mercury.region = _this;
setTimeout((function() {
return _this.selection().forceSelection(_this.element.get(0));
}), 1);
return Mercury.trigger('region:focused', {
region: _this
});
});
this.element.on('blur', function() {
if (_this.previewing) {
return;
}
Mercury.trigger('region:blurred', {
region: _this
});
return Mercury.tooltip.hide();
});
this.element.on('click', function(event) {
if (_this.previewing) {
return jQuery(event.target).closest('a').attr('target', '_parent');
}
});
this.element.on('dblclick', function(event) {
var image;
if (_this.previewing) {
return;
}
image = jQuery(event.target).closest('img', _this.element);
if (image.length) {
_this.selection().selectNode(image.get(0), true);
return Mercury.trigger('button', {
action: 'insertMedia'
});
}
});
this.element.on('mouseup', function() {
if (_this.previewing) {
return;
}
_this.pushHistory();
return Mercury.trigger('region:update', {
region: _this
});
});
this.element.on('keydown', function(event) {
var container;
if (_this.previewing) {
return;
}
switch (event.keyCode) {
case 90:
if (!event.metaKey) {
return;
}
event.preventDefault();
if (event.shiftKey) {
_this.execCommand('redo');
} else {
_this.execCommand('undo');
}
return;
case 13:
if (jQuery.browser.webkit && _this.selection().commonAncestor().closest('li, ul, ol', _this.element).length === 0) {
event.preventDefault();
_this.document.execCommand('insertParagraph', false, null);
} else if (_this.specialContainer || jQuery.browser.opera) {
event.preventDefault();
_this.document.execCommand('insertHTML', false, '
');
}
break;
case 9:
event.preventDefault();
container = _this.selection().commonAncestor();
if (container.closest('li', _this.element).length) {
if (!event.shiftKey) {
_this.execCommand('indent');
} else if (container.parents('ul, ol').length > 1) {
_this.execCommand('outdent');
}
} else {
_this.execCommand('insertHTML', {
value: ' '
});
}
}
if (event.metaKey) {
switch (event.keyCode) {
case 66:
_this.execCommand('bold');
event.preventDefault();
break;
case 73:
_this.execCommand('italic');
event.preventDefault();
break;
case 85:
_this.execCommand('underline');
event.preventDefault();
}
}
return _this.pushHistory(event.keyCode);
});
return this.element.on('keyup', function() {
if (_this.previewing) {
return;
}
Mercury.trigger('region:update', {
region: _this
});
return Mercury.changes = true;
});
};
Full.prototype.focus = function() {
var e,
_this = this;
if (Mercury.region !== this) {
setTimeout((function() {
return _this.element.focus();
}), 10);
try {
this.selection().selection.collapseToStart();
} catch (_error) {
e = _error;
}
} else {
setTimeout((function() {
return _this.element.focus();
}), 10);
}
Mercury.trigger('region:focused', {
region: this
});
return Mercury.trigger('region:update', {
region: this
});
};
Full.prototype.content = function(value, filterSnippets, includeMarker) {
var container, content, element, error, index, selection, snippet, version, _i, _j, _len, _len1, _ref, _ref1;
if (value == null) {
value = null;
}
if (filterSnippets == null) {
filterSnippets = true;
}
if (includeMarker == null) {
includeMarker = false;
}
if (value !== null) {
container = jQuery('