Commit 5ee43a60 authored by Marco Mariani's avatar Marco Mariani

bootstrap-wysiwyg: fixed font menu

parent f92987b5
...@@ -4,24 +4,65 @@ ...@@ -4,24 +4,65 @@
(function (window, $, rJS) { (function (window, $, rJS) {
function initToolbarBootstrapBindings() {
var fonts = [
'Serif', 'Sans', 'Arial', 'Arial Black', 'Courier', 'Courier New', 'Comic Sans MS', 'Helvetica',
'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times', 'Times New Roman', 'Verdana'
], fontTarget = $('[title=Font]').siblings('.dropdown-menu');
$.each(fonts, function (idx, fontName) {
/*jslint unparam: true */
fontTarget.append($('<li><a data-edit="fontName ' + fontName + '" style="font-family:\'' + fontName + '\'">' + fontName + '</a></li>'));
});
$('.dropdown-menu input').
click(function () {
return false;
}).
change(function () {
$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');
}).
keydown('esc', function () {
this.value = '';
$(this).change();
});
$('[data-role=magic-overlay]').each(function () {
var overlay = $(this), target = $(overlay.data('target'));
overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
});
}
function showErrorAlert(reason, detail) {
var msg = '';
if (reason === 'unsupported-file-type') {
msg = "Unsupported format " + detail;
} else {
console.log("error uploading file", reason, detail);
}
$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>' +
'<strong>File upload error</strong> ' + msg + ' </div>').prependTo('#alerts');
}
function init() { function init() {
this.editor = $('#editor'); this.editor = $('#editor');
this.editor.wysiwyg(); initToolbarBootstrapBindings();
this.editor.wysiwyg({
fileUploadError: showErrorAlert
});
} }
rJS(window).declareMethod('getContent', function () { rJS(window).
declareMethod('getContent', function () {
return rJS(this).editor.html(); return rJS(this).editor.html();
}) })
.declareMethod('setContent', function (content) { .declareMethod('setContent', function (content) {
//console.log('setcontent:' + content); //console.log('setcontent:' + content);
rJS(this).editor.html(content); rJS(this).editor.html(content);
}) })
.declareMethod('clearContent', function () { .declareMethod('clearContent', function () {
rJS(this).editor.html(''); rJS(this).editor.html('');
}) })
.ready(function (g) { .ready(function (g) {
init.apply(g); init.apply(g);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment