/** * EasyUI for jQuery 1.5.3 * * Copyright (c) 2009-2017 www.jeasyui.com. All rights reserved. * * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php * To use it on other terms please contact us: info@jeasyui.com * */ /** * resizable - EasyUI for jQuery * */ (function($){ function resize(e){ var resizeData = e.data; var options = $.data(resizeData.target, 'resizable').options; if (resizeData.dir.indexOf('e') != -1) { var width = resizeData.startWidth + e.pageX - resizeData.startX; width = Math.min( Math.max(width, options.minWidth), options.maxWidth ); resizeData.width = width; } if (resizeData.dir.indexOf('s') != -1) { var height = resizeData.startHeight + e.pageY - resizeData.startY; height = Math.min( Math.max(height, options.minHeight), options.maxHeight ); resizeData.height = height; } if (resizeData.dir.indexOf('w') != -1) { var width = resizeData.startWidth - e.pageX + resizeData.startX; width = Math.min( Math.max(width, options.minWidth), options.maxWidth ); resizeData.width = width; resizeData.left = resizeData.startLeft + resizeData.startWidth - resizeData.width; } if (resizeData.dir.indexOf('n') != -1) { var height = resizeData.startHeight - e.pageY + resizeData.startY; height = Math.min( Math.max(height, options.minHeight), options.maxHeight ); resizeData.height = height; resizeData.top = resizeData.startTop + resizeData.startHeight - resizeData.height; } } function applySize(e){ var resizeData = e.data; var t = $(resizeData.target); t.css({ left: resizeData.left, top: resizeData.top }); if (t.outerWidth() != resizeData.width){t._outerWidth(resizeData.width)} if (t.outerHeight() != resizeData.height){t._outerHeight(resizeData.height)} } function doDown(e){ $.fn.resizable.isResizing = true; $.data(e.data.target, 'resizable').options.onStartResize.call(e.data.target, e); return false; } function doMove(e){ resize(e); if ($.data(e.data.target, 'resizable').options.onResize.call(e.data.target, e) != false){ applySize(e) } return false; } function doUp(e){ $.fn.resizable.isResizing = false; resize(e, true); applySize(e); $.data(e.data.target, 'resizable').options.onStopResize.call(e.data.target, e); $(document).unbind('.resizable'); $('body').css('cursor',''); return false; } // get the resize direction function getDirection(e) { var opts = $(e.data.target).resizable('options'); var tt = $(e.data.target); var dir = ''; var offset = tt.offset(); var width = tt.outerWidth(); var height = tt.outerHeight(); var edge = opts.edge; if (e.pageY > offset.top && e.pageY < offset.top + edge) { dir += 'n'; } else if (e.pageY < offset.top + height && e.pageY > offset.top + height - edge) { dir += 's'; } if (e.pageX > offset.left && e.pageX < offset.left + edge) { dir += 'w'; } else if (e.pageX < offset.left + width && e.pageX > offset.left + width - edge) { dir += 'e'; } var handles = opts.handles.split(','); handles = $.map(handles, function(h){return $.trim(h).toLowerCase();}); if ($.inArray('all', handles) >= 0 || $.inArray(dir, handles) >= 0){ return dir; } for(var i=0; i