-
Notifications
You must be signed in to change notification settings - Fork 2
/
featureimage.js
executable file
·43 lines (36 loc) · 1.15 KB
/
featureimage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(function($)
$.Redactor.prototype.featureimage = function()
{
return {
opts: {
featureimage: {
linkSelector : '.redactor-featureimage'
previewSelector : '.feature-image-preview',
inputSelector : '.feature-image-input',
}
}
init: function()
{
if (!this.opts.imageManagerJson) return;
var _this = this;
/* merge settings */
this.opts = $.extend({}, this.featureimage.opts, this.opts);
$(this.opts.featureimage.linkSelector).on('click', function(e){
e.preventDefault();
_this.modal.addTemplate('featureimage', _this.modal.getTemplate('image'));
_this.modal.load('featureimage', "Feature Image", 700);
/* callback after uploaded */
_this.upload.init('#redactor-modal-image-droparea', _this.opts.imageUpload, _this.featureimage.insert);
_this.selection.save();
_this.modal.show();
$('#redactor-modal-image-droparea').focus();
});
},
insert: function(json, direct, e){
$(this.opts.featureimage.previewSelector).html('<img src="' + json.url + '">');
$(this.opts.featureimage.inputSelector).val(json.url);
this.modal.close();
}
};
};
})(jQuery);