Skip to content

Commit

Permalink
Merge pull request okjsp#89 from okjsp/v0.7.8
Browse files Browse the repository at this point in the history
V0.7.8
  • Loading branch information
1angerhans committed Aug 11, 2015
2 parents b87397b + 606dcae commit 9daa76b
Show file tree
Hide file tree
Showing 8 changed files with 404 additions and 576 deletions.
2 changes: 1 addition & 1 deletion application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#Sat Jun 06 15:51:33 KST 2015
app.grails.version=2.4.5
app.name=okky
app.version=0.7.7
app.version=0.7.8
55 changes: 43 additions & 12 deletions grails-app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//= require libs/summernote
//= require libs/summernote-ko-KR
//= require libs/summernote-ext-video
//= require libs/summernote-ext-fontstyle
//= require libs/summernote-ext-codeblock
//= require libs/spin
//= require libs/jquery.spin
Expand Down Expand Up @@ -72,24 +71,57 @@ if (typeof jQuery !== 'undefined') {
}
});

var onImagaUpload = function(files, editor, $editable) {
$.onImageUpload = function($editor) {

var $form = $('.note-image-dialog .note-modal-form');
return function(files) {

$('<iframe src="about:blank" style="display: none;" name="imageUploadHandlerFrame"></iframe>').appendTo('body');
var createImage = function (sUrl, filename) {
return $.Deferred(function (deferred) {
var $img = $('<img>');

$.imageUploaded = function(image) {
editor.insertImage($editable, image);
};
$img.one('load', function () {
$img.off('error abort');
deferred.resolve($img);
}).one('error abort', function () {
$img.off('load').detach();
deferred.reject($img);
}).css({
display: 'none'
}).appendTo(document.body).attr({
'src': sUrl,
'data-filename': filename
});
}).promise();
};

var $form = $('.note-image-dialog .note-modal-form');

$('<iframe src="about:blank" style="display: none;" name="imageUploadHandlerFrame"></iframe>').appendTo('body');

$.imageUploaded = function(sUrl, filename) {

createImage(sUrl, filename).then(function ($image) {
var width = $image.width() >= $editor.width() ? '100%' : $image.width();

$form.attr({
$image.css({
display: '',
width: width
});

$editor.summernote('insertNode', $image.get(0));
});
};

$form.attr({
enctype: 'multipart/form-data',
target: 'imageUploadHandlerFrame',
action: contextPath+'/file/image',
method: 'post'
});
});

$form[0].submit();
$form[0].submit();

};
};

$.extend($.summernote.options, {
Expand All @@ -107,8 +139,7 @@ if (typeof jQuery !== 'undefined') {
['para', ['ul', 'ol', 'table']],
['insert', ['codeblock', 'link', 'picture', 'video', 'hr']],
['view', ['fullscreen', 'codeview', 'help']]
],
onImageUpload : onImagaUpload
]
});

})(jQuery);
Expand Down
7 changes: 4 additions & 3 deletions grails-app/assets/javascripts/apps/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ $(function() {
var $editor = $(this);
$(this).summernote({lang: 'ko-KR',
focus: true,
oninit: function() {
onInit: function() {
if($(window).height() > 400)
$('#note-create-cancel-btn').show();
$('#btn-create-btn').prop('disabled', false);
$editor.find('.note-editable').css('max-height', $(window).height()-100);
}
},
onImageUpload: $.onImageUpload($editor)
});
});

Expand Down Expand Up @@ -85,7 +86,7 @@ $(function() {
sending = true;

$.ajax({
url:contextPath+'/content/edit/'+id+'.json',
url:contextPath+'/content/edit/'+id+'.json?_='+(new Date().getTime()),
dataType: 'json',
type: 'get',
success: function(result) {
Expand Down
Loading

0 comments on commit 9daa76b

Please sign in to comment.