| 21627 |
kshitij.so |
1 |
//bootstrap wysiwyg
|
|
|
2 |
$(function(){
|
|
|
3 |
function initToolbarBootstrapBindings() {
|
|
|
4 |
var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
|
|
|
5 |
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
|
|
|
6 |
'Times New Roman', 'Verdana'],
|
|
|
7 |
fontTarget = $('[title=Font]').siblings('.dropdown-menu');
|
|
|
8 |
$.each(fonts, function (idx, fontName) {
|
|
|
9 |
fontTarget.append($('<li><a data-edit="fontName ' + fontName +'" style="font-family:\''+ fontName +'\'">'+fontName + '</a></li>'));
|
|
|
10 |
});
|
|
|
11 |
$('a[title]').tooltip({container:'body'});
|
|
|
12 |
$('.dropdown-menu input').click(function() {return false;})
|
|
|
13 |
.change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');})
|
|
|
14 |
.keydown('esc', function () {this.value='';$(this).change();});
|
|
|
15 |
|
|
|
16 |
$('[data-role=magic-overlay]').each(function () {
|
|
|
17 |
var overlay = $(this), target = $(overlay.data('target'));
|
|
|
18 |
overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
|
|
|
19 |
});
|
|
|
20 |
/* voiceBtn
|
|
|
21 |
if ("onwebkitspeechchange" in document.createElement("input")) {
|
|
|
22 |
var editorOffset = $('#editor').offset();
|
|
|
23 |
$('#voiceBtn').css('position','absolute').offset({top: editorOffset.top, left: editorOffset.left+$('#editor').innerWidth()-35});
|
|
|
24 |
} else {
|
|
|
25 |
$('#voiceBtn').hide();
|
|
|
26 |
}*/
|
|
|
27 |
};
|
|
|
28 |
function showErrorAlert (reason, detail) {
|
|
|
29 |
var msg='';
|
|
|
30 |
if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
|
|
|
31 |
else {
|
|
|
32 |
console.log("error uploading file", reason, detail);
|
|
|
33 |
}
|
|
|
34 |
$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">×</button>'+
|
|
|
35 |
'<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
|
|
|
36 |
};
|
|
|
37 |
initToolbarBootstrapBindings();
|
|
|
38 |
$('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
|
|
|
39 |
window.prettyPrint && prettyPrint();
|
|
|
40 |
});
|