(function($) { $.event.special.destroyed = { remove: function(o) { if (o.handler) { o.handler(); } } }; })(jQuery); (function($) { var $body, $doc, $html, F; $.fn.draggable = function(method) { if (F[method]) { return F[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === "object" || !method) { return F.init.apply(this, arguments); } else { return $.error('Метод с именем ' + method + ' не существует для jQuery.draggable'); } }; $doc = $(document); $html = $("html"); $body = null; return F = { offsetLeft: 0, offsetTop: 0, startX: 0, startY: 0, target: null, started: false, init: function(o = {}) { if (o.clone == null) { o.clone = false; } if (o.cloneConnect == null) { o.cloneConnect = ''; } if (o.dragPosition == null) { o.dragPosition = ''; } if (o.distance == null) { o.distance = 0; } $body = $("body"); return $(this).each(function() { var $handle, $t; $t = $(this); $t.data('drag_options', o); //$t = $(@).css // position:'fixed' $handle = null; if (o.handle !== void 0) { if (o.handle.length > 0) { $handle = $(o.handle, $t); } else { $handle = $t; } } $handle = $handle != null ? $handle : $t; $handle.data('draggable_object', $t); $handle.on('mousedown', F.mouseDown); $t.trigger('created'); return $t.on('destroyed', F.destroyed); }); }, mouseUp: function(e) { var $target, isStopEvent, options; if (F.started) { options = F.target.data('drag_options'); isStopEvent = true; if (options.cloneConnect) { $target = $(e.target); if (!($target.is(options.cloneConnect) || $target.closest(options.cloneConnect).length > 0)) { F.target.remove(); isStopEvent = false; } } if (isStopEvent) { if (typeof options.stop === "function") { options.stop(e, F.target, $target); } } if (options.dragPosition !== '') { F.target.css('position', F.target.data('bufferPosition')); } } return F.clearData(); }, clearData: function() { $doc.off('mousemove', F.move); $doc.off('mouseup', F.mouseUp); F.offsetLeft = 0; F.offsetTop = 0; //F.target.css 'pointer-events','all' F.target = null; F.started = false; F.distance = 0; return $html.css({ 'user-select': F.htmlUserSelect, 'pointer-events': 'all' }); }, move: function(e) { var dx, dy, options, x, y; x = e.clientX - F.startX + F.offsetLeft; y = e.clientY - F.startY + F.offsetTop; if (F.started) { F.target.css({ transform: 'translate(' + x + 'px,' + y + 'px)' }); } else { dx = Math.abs(e.clientX - F.startX); dy = Math.abs(e.clientY - F.startY); if (dx >= F.distance || dy >= F.distance) { F.startDrag(); } } options = F.target.data('drag_options'); return typeof options.move === "function" ? options.move(e, F.target) : void 0; }, destroyed: function() { return F.clearData(); }, startDrag: function() { var $clone, $t, options; $t = F.target; options = $t.data('drag_options'); if (options.clone) { $clone = $t.clone(); $clone.css({ position: 'fixed', top: 0, left: 0, transform: 'translate(' + $t.offset().left + 'px,' + $t.offset().top + 'px)', zIndex: 1000, 'pointer-events': 'none' }); $clone.data('drag_options', options); if (options.cloneConnect != null) { $(options.cloneConnect).data('bufferPointerEvents', $(options.cloneConnect).css('pointer-events')); $(options.cloneConnect).css({ 'pointer-events': 'all' }); } $body.append($clone); $t = $clone; F.target = $t; } F.started = true; $t.trigger('draggable:start'); return typeof options.start === "function" ? options.start(typeof e !== "undefined" && e !== null ? e : null, F.target) : void 0; }, mouseDown: function(e) { var $t, matrix, options, trans; $t = $(e.currentTarget).data('draggable_object'); options = $t.data('drag_options'); if (options.dragPosition !== '') { $t.data('bufferPosition', $t.css('position')).css('position', options.dragPosition); } trans = $t.css('transform'); if (trans !== 'none') { matrix = trans.replace(/[^,.\d]/gi, '').split(','); F.offsetLeft = parseFloat(matrix[4]); F.offsetTop = parseFloat(matrix[5]); } else { F.offsetLeft = parseFloat($t.offset().left); F.offsetTop = parseFloat($t.offset().top); } //$t.css 'pointer-events','none' F.target = $t; F.startX = e.clientX; F.startY = e.clientY; F.distance = options.distance; F.htmlUserSelect = $html.css('user-select'); $html.css({ 'user-select': 'none' }); //'pointer-events':'none' $doc.on('mousemove', F.move); $doc.on('mouseup', F.mouseUp); if (options.distance === 0) { return F.startDrag(); } } }; })(jQuery); var indexOf = [].indexOf; (function($) { var $doc, $html, F, mode; $.fn.resizable = function(method) { if (F[method]) { return F[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === "object" || !method) { return F.init.apply(this, arguments); } else { return $.error('Метод с именем ' + method + ' не существует для jQuery.resizable'); } }; $doc = $(document); $html = $("html"); mode = { left: 0, right: 1, top: 2, bottom: 3, top_left: 4, top_right: 5, bottom_left: 6, bottom_right: 7 }; return F = { translateX: 0, translateY: 0, offsetLeft: 0, offsetTop: 0, startWidth: 0, startHeight: 0, target: null, init: function(options = {}) { return $(this).each(function() { return F.create(this, options); }); }, clearData: function() { $doc.off('mousemove', F.move); $doc.off('mouseup', F.mouseUp); F.target = null; return $html.css({ 'user-select': F.htmlUserSelect, 'pointer-events': 'all' }); }, move: function(e) { var dx, dy, h, w; dx = e.clientX - F.startX; dy = e.clientY - F.startY; // Расширение направо switch (F.mode) { case mode.right: case mode.top_right: case mode.bottom_right: w = F.startWidth + dx; F.target.width(w); } // Расширение вниз switch (F.mode) { case mode.bottom: case mode.bottom_left: case mode.bottom_right: h = F.startHeight + dy; F.target.height(h); } // Расширение налево switch (F.mode) { case mode.left: case mode.bottom_left: w = F.startWidth - dx; F.target.css({ width: w, transform: 'translate(' + (F.translateX + dx) + 'px,' + F.translateY + 'px)' }); break; case mode.top_left: w = F.startWidth - dx; F.target.css({ width: w, transform: 'translate(' + (F.translateX + dx) + 'px,' + (F.translateY + dy) + 'px)' }); } // Расширение наверх switch (F.mode) { case mode.top: case mode.top_right: h = F.startHeight - dy; return F.target.css({ height: h, transform: 'translate(' + F.translateX + 'px,' + (F.translateY + dy) + 'px)' }); case mode.top_left: h = F.startHeight - dy; return F.target.css({ height: h, transform: 'translate(' + (F.translateX + dx) + 'px,' + (F.translateY + dy) + 'px)' }); } }, getDirections: function($x) { return $("> [class^=resize_]", $x); }, enable: function() { return F.getDirections($(this)).show(); }, disable: function() { return F.getDirections($(this)).hide(); }, mouseDown: function(e) { var $t, matrix, options, trans; e.stopPropagation(); //$bar = $(e.currentTarget) //$t = $bar.data('resize_object') $t = $(this); F.target = $t.data('resize_object'); F.mode = $t.data('resize_mode'); options = F.target.data('resizableOptions'); trans = F.target.css('transform'); if (trans !== 'none') { matrix = trans.replace(/[^,.\d]/gi, '').split(','); F.translateX = parseFloat(matrix[4]); F.translateY = parseFloat(matrix[5]); } else { F.offsetLeft = parseFloat($t.offset().left); F.offsetTop = parseFloat($t.offset().top); } F.startX = e.clientX; F.startY = e.clientY; F.startWidth = F.target.width(); F.startHeight = F.target.height(); F.htmlUserSelect = $html.css('user-select'); $html.css({ 'user-select': 'none', 'pointer-events': 'none' }); $doc.on('mousemove', F.move); $doc.on('mouseup', F.mouseUp); return typeof options.start === "function" ? options.start(e, F.target) : void 0; }, mouseUp: function(e) { var options; options = F.target.data('resizableOptions'); if (typeof options.stop === "function") { options.stop(e, F.target); } return F.clearData(); }, create: function(node, o = {}) { var $i, $t, dir, i, j, len, results; if (o.directions == null) { o.directions = 'all'; } $t = $(node); $t.addClass('resizable'); $t.data('resizableOptions', o); $t.on('destroyed', F.clearData); dir = ['left', 'right', 'top', 'bottom', 'top_left', 'top_right', 'bottom_left', 'bottom_right']; results = []; for (j = 0, len = dir.length; j < len; j++) { i = dir[j]; if (o.directions === 'all' || indexOf.call(o.directions, i) >= 0) { $i = $('
'); $i.data('resize_mode', mode[i]); $i.data('resize_object', $t); $t.append($i); results.push($i.on('mousedown', F.mouseDown)); } else { results.push(void 0); } } return results; } }; })(jQuery); (function($) { var F; $.fn.sortable = function(method) { if (F[method]) { return F[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === "object" || !method) { return F.init.apply(this, arguments); } else { return $.error('Метод с именем ' + method + ' не существует для jQuery.sortable'); } }; return F = { init: function(o = {}) { return $(this).each(function() { return F.initSortable($(this), o); }); }, initSortable: function($t, o = {}) { var $a; $a = $t.children(); return $a.each(function() { return F.initChild($(this), o); }); }, initChild: function($t, o = {}) { var $children, $connect, $parent, isEmpty, replaceMe; if (o.distance == null) { o.distance = 0; } if (o.handle == null) { o.handle = ''; } if (o.behavior == null) { o.behavior = ''; } if (o.opacity == null) { o.opacity = 0.5; } $children = null; $parent = $t.parent(); $connect = null; if (o.connectWith !== void 0) { $connect = $(o.connectWith); } isEmpty = function(e) { var $c; $c = $(e.currentTarget); if ($c.has($t).length === 0) { if ($c.children().length === 0) { return $c.append($t); } else { return $t.insertAfter($c.children().last()); } } }; replaceMe = function(e) { var $c, x, y; $c = $(this); if (o.behavior === 'hover') { if ($t.index() < $c.index()) { return $t.insertAfter($c); } else { return $t.insertBefore($c); } } else { x = e.offsetX; if ($c !== $t) { if (x < ($c.width() / 2)) { $t.insertBefore($c); } else { $t.insertAfter($c); } } y = e.offsetY; if ($c !== $t) { if (y < ($c.height() / 2)) { return $t.insertBefore($c); } else { return $t.insertAfter($c); } } } }; return $t.draggable({ clone: true, distance: o.distance, handle: o.handle, start: function(e, $target) { $t.css('opacity', o.opacity); $children = $parent.children(); $parent.css('pointer-events', 'all'); $children.on('mousemove', replaceMe); if ($connect !== null) { $connect.children().on('mousemove', replaceMe); $connect.on('mousemove', isEmpty); } return typeof o.start === "function" ? o.start(e, $t, $target, $t.parent()) : void 0; }, //move:(e,$target)-> stop: function(e, $target) { $target.remove(); $t.css('opacity', 1); $children.off('mousemove', replaceMe); if ($connect !== null) { $connect.children().off('mousemove', replaceMe); $connect.off('mousemove', isEmpty); } return typeof o.stop === "function" ? o.stop(e, $t, $t.parent()) : void 0; } }); } }; })(jQuery);