gui 에디터 추가

This commit is contained in:
2018-08-30 01:25:45 +09:00
parent 9e677f3871
commit accc083702
74 changed files with 7344 additions and 8 deletions
@@ -0,0 +1,69 @@
(function ($) {
'use strict';
var defaultOptions = {
minSize: 32,
step: 4
};
var preventDefault = function (ev) {
return ev.preventDefault();
};
$.extend(true, $.trumbowyg, {
plugins: {
resizimg: {
init: function (trumbowyg) {
trumbowyg.o.plugins.resizimg = $.extend(true, {},
defaultOptions,
trumbowyg.o.plugins.resizimg || {},
{
resizable: {
resizeWidth: false,
onDragStart: function (ev, $el) {
var opt = trumbowyg.o.plugins.resizimg;
var x = ev.pageX - $el.offset().left;
var y = ev.pageY - $el.offset().top;
if (x < $el.width() - opt.minSize || y < $el.height() - opt.minSize) {
return false;
}
},
onDrag: function (ev, $el, newWidth, newHeight) {
var opt = trumbowyg.o.plugins.resizimg;
if (newHeight < opt.minSize) {
newHeight = opt.minSize;
}
newHeight -= newHeight % opt.step;
$el.height(newHeight);
return false;
},
onDragEnd: function () {
trumbowyg.$c.trigger('tbwchange');
}
}
}
);
function initResizable() {
trumbowyg.$ed.find('img:not(.resizable)')
.resizable(trumbowyg.o.plugins.resizimg.resizable)
.on('mousedown', preventDefault);
}
function destroyResizable() {
trumbowyg.$ed.find('img.resizable')
.resizable('destroy')
.off('mousedown', preventDefault);
trumbowyg.syncTextarea();
}
trumbowyg.$c.on('tbwinit', initResizable);
trumbowyg.$c.on('tbwfocus', initResizable);
trumbowyg.$c.on('tbwchange', initResizable);
trumbowyg.$c.on('tbwblur', destroyResizable);
trumbowyg.$c.on('tbwclose', destroyResizable);
}
}
}
});
})(jQuery);
@@ -0,0 +1 @@
!function(i){"use strict";var e={minSize:32,step:4},n=function(i){return i.preventDefault()};i.extend(!0,i.trumbowyg,{plugins:{resizimg:{init:function(t){function o(){t.$ed.find("img:not(.resizable)").resizable(t.o.plugins.resizimg.resizable).on("mousedown",n)}function r(){t.$ed.find("img.resizable").resizable("destroy").off("mousedown",n),t.syncTextarea()}t.o.plugins.resizimg=i.extend(!0,{},e,t.o.plugins.resizimg||{},{resizable:{resizeWidth:!1,onDragStart:function(i,e){var n=t.o.plugins.resizimg,o=i.pageX-e.offset().left,r=i.pageY-e.offset().top;if(o<e.width()-n.minSize||r<e.height()-n.minSize)return!1},onDrag:function(i,e,n,o){var r=t.o.plugins.resizimg;return o<r.minSize&&(o=r.minSize),o-=o%r.step,e.height(o),!1},onDragEnd:function(){t.$c.trigger("tbwchange")}}}),t.$c.on("tbwinit",o),t.$c.on("tbwfocus",o),t.$c.on("tbwchange",o),t.$c.on("tbwblur",r),t.$c.on("tbwclose",r)}}}})}(jQuery);