File modules/editor/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js

Last commit: Tue Aug 28 00:33:27 2018 +0200	Jan Dankert	Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.
1 (function ($) { 2 'use strict'; 3 4 var defaultOptions = { 5 minSize: 32, 6 step: 4 7 }; 8 9 var preventDefault = function (ev) { 10 return ev.preventDefault(); 11 }; 12 13 $.extend(true, $.trumbowyg, { 14 plugins: { 15 resizimg: { 16 init: function (trumbowyg) { 17 trumbowyg.o.plugins.resizimg = $.extend(true, {}, 18 defaultOptions, 19 trumbowyg.o.plugins.resizimg || {}, 20 { 21 resizable: { 22 resizeWidth: false, 23 onDragStart: function (ev, $el) { 24 var opt = trumbowyg.o.plugins.resizimg; 25 var x = ev.pageX - $el.offset().left; 26 var y = ev.pageY - $el.offset().top; 27 if (x < $el.width() - opt.minSize || y < $el.height() - opt.minSize) { 28 return false; 29 } 30 }, 31 onDrag: function (ev, $el, newWidth, newHeight) { 32 var opt = trumbowyg.o.plugins.resizimg; 33 if (newHeight < opt.minSize) { 34 newHeight = opt.minSize; 35 } 36 newHeight -= newHeight % opt.step; 37 $el.height(newHeight); 38 return false; 39 }, 40 onDragEnd: function () { 41 trumbowyg.$c.trigger('tbwchange'); 42 } 43 } 44 } 45 ); 46 47 function initResizable() { 48 trumbowyg.$ed.find('img:not(.resizable)') 49 .resizable(trumbowyg.o.plugins.resizimg.resizable) 50 .on('mousedown', preventDefault); 51 } 52 53 function destroyResizable() { 54 trumbowyg.$ed.find('img.resizable') 55 .resizable('destroy') 56 .off('mousedown', preventDefault); 57 trumbowyg.syncTextarea(); 58 } 59 60 trumbowyg.$c.on('tbwinit', initResizable); 61 trumbowyg.$c.on('tbwfocus', initResizable); 62 trumbowyg.$c.on('tbwchange', initResizable); 63 trumbowyg.$c.on('tbwblur', destroyResizable); 64 trumbowyg.$c.on('tbwclose', destroyResizable); 65 } 66 } 67 } 68 }); 69 })(jQuery);
Download modules/editor/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js
History Tue, 28 Aug 2018 00:33:27 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.