Skip to content

Commit 9daa76b

Browse files
committed
Merge pull request #89 from okjsp/v0.7.8
V0.7.8
2 parents b87397b + 606dcae commit 9daa76b

File tree

8 files changed

+404
-576
lines changed

8 files changed

+404
-576
lines changed

application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#Sat Jun 06 15:51:33 KST 2015
33
app.grails.version=2.4.5
44
app.name=okky
5-
app.version=0.7.7
5+
app.version=0.7.8

grails-app/assets/javascripts/application.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//= require libs/summernote
1212
//= require libs/summernote-ko-KR
1313
//= require libs/summernote-ext-video
14-
//= require libs/summernote-ext-fontstyle
1514
//= require libs/summernote-ext-codeblock
1615
//= require libs/spin
1716
//= require libs/jquery.spin
@@ -72,24 +71,57 @@ if (typeof jQuery !== 'undefined') {
7271
}
7372
});
7473

75-
var onImagaUpload = function(files, editor, $editable) {
74+
$.onImageUpload = function($editor) {
7675

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

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

81-
$.imageUploaded = function(image) {
82-
editor.insertImage($editable, image);
83-
};
82+
$img.one('load', function () {
83+
$img.off('error abort');
84+
deferred.resolve($img);
85+
}).one('error abort', function () {
86+
$img.off('load').detach();
87+
deferred.reject($img);
88+
}).css({
89+
display: 'none'
90+
}).appendTo(document.body).attr({
91+
'src': sUrl,
92+
'data-filename': filename
93+
});
94+
}).promise();
95+
};
96+
97+
var $form = $('.note-image-dialog .note-modal-form');
98+
99+
$('<iframe src="about:blank" style="display: none;" name="imageUploadHandlerFrame"></iframe>').appendTo('body');
100+
101+
$.imageUploaded = function(sUrl, filename) {
102+
103+
createImage(sUrl, filename).then(function ($image) {
104+
var width = $image.width() >= $editor.width() ? '100%' : $image.width();
84105

85-
$form.attr({
106+
$image.css({
107+
display: '',
108+
width: width
109+
});
110+
111+
$editor.summernote('insertNode', $image.get(0));
112+
});
113+
};
114+
115+
$form.attr({
86116
enctype: 'multipart/form-data',
87117
target: 'imageUploadHandlerFrame',
88118
action: contextPath+'/file/image',
89119
method: 'post'
90-
});
120+
});
91121

92-
$form[0].submit();
122+
$form[0].submit();
123+
124+
};
93125
};
94126

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

114145
})(jQuery);

grails-app/assets/javascripts/apps/note.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ $(function() {
77
var $editor = $(this);
88
$(this).summernote({lang: 'ko-KR',
99
focus: true,
10-
oninit: function() {
10+
onInit: function() {
1111
if($(window).height() > 400)
1212
$('#note-create-cancel-btn').show();
1313
$('#btn-create-btn').prop('disabled', false);
1414
$editor.find('.note-editable').css('max-height', $(window).height()-100);
15-
}
15+
},
16+
onImageUpload: $.onImageUpload($editor)
1617
});
1718
});
1819

@@ -85,7 +86,7 @@ $(function() {
8586
sending = true;
8687

8788
$.ajax({
88-
url:contextPath+'/content/edit/'+id+'.json',
89+
url:contextPath+'/content/edit/'+id+'.json?_='+(new Date().getTime()),
8990
dataType: 'json',
9091
type: 'get',
9192
success: function(result) {

0 commit comments

Comments
 (0)