You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 lines
1.8 KiB

(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
var $dialog = $('#insertImageDialog').dialog({
autoOpen: false,
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
var $url = $('input[type=text]', $dialog);
var $file = $('input[type=file]', $dialog);
editor.hooks.set('insertImageDialog', function(callback) {
var dialogClose = function() {
$url.val('');
$file.val('');
$dialog.dialog('close');
};
$dialog.dialog({
buttons : {
"Insert" : {
text: "Insert",
id: "insert",
click: function(){
callback($url.val().length > 0 ? $url.val(): null);
dialogClose();
}
},
"Cancel" : {
text: "Cancel",
id: "cancel",
click: function(){
dialogClose();
callback(null);
}
}
}
});
var uploadComplete = function(response) {
if (response.error == '0') {
$url.val(base_path + response.path);
$("#insert").trigger('click');
} else {
alert(response.error);
$file.val('');
}
};
$file.ajaxfileupload({
'action': base_path + 'upload.php',
'onComplete': uploadComplete,
});
$dialog.dialog('open');
return true; // tell the editor that we'll take care of getting the image url
});
editor.run();
})();