(function() { (function($) { var methods; methods = { edit: function(isEditing) { return this.each(function() { return $(this).attr("contentEditable", isEditing || false); }); }, save: function(callback) { return this.each(function() { return callback($(this).attr('id'), $(this).html()); }); }, createlink: function() { var urlPrompt; urlPrompt = prompt("Enter URL:", "http://"); return document.execCommand("createlink", false, urlPrompt); }, insertimage: function() { var urlPrompt; urlPrompt = prompt("Enter Image URL:", "http://"); return document.execCommand("insertimage", false, urlPrompt); }, formatblock: function(block) { return document.execCommand("formatblock", null, block); }, init: function(opts) { var $toolbar, button, command, commands, excludes, font, font_list, fontnames, fontsize, fontsizes, group, groups, options, shortcuts, size_list, _i, _j, _k, _l, _len, _len2, _len3, _len4; options = opts || {}; groups = [ [ { name: 'bold', label: "B", title: 'Bold (Ctrl+B)', classname: 'toolbar_bold' }, { name: 'italic', label: "I", title: 'Italic (Ctrl+I)', classname: 'toolbar_italic' }, { name: 'underline', label: "U", title: 'Underline (Ctrl+U)', classname: 'toolbar_underline' }, { name: 'strikethrough', label: "ABC", title: 'Strikethrough', classname: 'toolbar_strikethrough' }, { name: 'removeFormat', label: "", title: 'Remove Formating (Ctrl+M)', classname: 'toolbar_remove' } ], [ { name: 'fontname', label: "F ", title: 'Select font name', classname: 'toolbar_fontname dropdown-toggle', dropdown: true } ], [ { name: 'FontSize', label: "AA ", title: 'Select font size', classname: 'toolbar_fontsize dropdown-toggle', dropdown: true } ], [ { name: 'forecolor', label: "
"]);
}
}, {
keys: 'Ctrl+Alt+k',
method: function() {
return methods.formatblock.apply(this, [""]);
}
}, {
keys: 'Ctrl+.',
method: function() {
return document.execCommand('superscript', false, null);
}
}, {
keys: 'Ctrl+Shift+.',
method: function() {
return document.execCommand('subscript', false, null);
}
}, {
keys: 'Ctrl+Alt+0',
method: function() {
return methods.formatblock.apply(this, ["p"]);
}
}, {
keys: 'Ctrl+b',
method: function() {
return document.execCommand('bold', false, null);
}
}, {
keys: 'Ctrl+i',
method: function() {
return document.execCommand('italic', false, null);
}
}, {
keys: 'Ctrl+Alt+1',
method: function() {
return methods.formatblock.apply(this, ["H1"]);
}
}, {
keys: 'Ctrl+Alt+2',
method: function() {
return methods.formatblock.apply(this, ["H2"]);
}
}, {
keys: 'Ctrl+Alt+3',
method: function() {
return methods.formatblock.apply(this, ["H3"]);
}
}, {
keys: 'Ctrl+Alt+4',
method: function() {
return methods.formatblock.apply(this, ["H4"]);
}
}, {
keys: 'Ctrl+m',
method: function() {
return document.execCommand("removeFormat", false, null);
}
}, {
keys: 'Ctrl+u',
method: function() {
return document.execCommand('underline', false, null);
}
}, {
keys: 'tab',
method: function() {
return document.execCommand('indent', false, null);
}
}, {
keys: 'Ctrl+tab',
method: function() {
return document.execCommand('indent', false, null);
}
}, {
keys: 'Shift+tab',
method: function() {
return document.execCommand('outdent', false, null);
}
}
];
$.each(shortcuts, function(index, elem) {
return shortcut.add(elem.keys, function() {
elem.method();
return false;
}, {
'type': 'keydown',
'propagate': false
});
});
return this.each(function() {
var $this, data, tooltip;
$this = $(this);
data = $this.data('fresheditor');
tooltip = $('', {
text: $this.attr('title')
});
if (!data) {
return $(this).data('fresheditor', {
target: $this,
tooltip: tooltip
});
}
});
}
};
return $.fn.freshereditor = function(method) {
if (methods[method]) {
methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.contentEditable');
}
};
})(jQuery);
}).call(this);