From: zuber Date: Thu, 20 Aug 2009 19:51:37 +0000 (+0200) Subject: Ponowne dodanie możliwości zmieniania wielkości paneli. Tym razem działa dużo lepiej... X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/08eafa7ea0680c755be43561ba599c7ebf3b0fff?ds=sidebyside;hp=-c Ponowne dodanie możliwości zmieniania wielkości paneli. Tym razem działa dużo lepiej niż poprzednio, więc pewnie może zostać. --- 08eafa7ea0680c755be43561ba599c7ebf3b0fff diff --git a/project/static/js/jquery.resizable.js b/project/static/js/jquery.resizable.js index 415aa2da..fafddc9e 100644 --- a/project/static/js/jquery.resizable.js +++ b/project/static/js/jquery.resizable.js @@ -1,31 +1,45 @@ (function($){ $.resizable = { + settings: {}, element: {}, drag: function(event) { $.resizable.element.element.css({ - width: Math.max(event.pageX - $.resizable.element.mouseX + $.resizable.element.width, 0) + width: Math.max(event.pageX - $.resizable.element.mouseX + $.resizable.element.width, + $.resizable.settings.minWidth) }) $.resizable.element.element.trigger('resizable:resize'); return false; }, - stop: function() { + stop: function(event) { $.resizable.element.element.trigger('resizable:stop'); - $().unbind('mousemove', $.resizable.drag).unbind('mouseup', $.resizable.stop); + $(document).unbind('mousemove', $.resizable.drag).unbind('mouseup', $.resizable.stop) + .children('body').css({cursor: 'auto'}) return false; } }; - $.fn.resizable = function(handle) { + $.fn.resizable = function(handle, options) { + var settings = { + minWidth: 0, + maxWidth: $(window).width() + } + + $.extend(settings, options); + var element = $(this); + $(handle, element).mousedown(function(event) { var position = element.position(); + $.resizable.settings = settings; $.resizable.element = { element: element, width: parseInt(element.css('width')) || element[0].scrollWidth || 0, mouseX: event.pageX, }; - $().mousemove($.resizable.drag).mouseup($.resizable.stop); - }); + $(document).mousemove($.resizable.drag).mouseup($.resizable.stop) + .children('body').css({cursor: 'se-resize'}); + event.stopImmediatePropagation(); + }).bind('dragstart', function(event) { event.preventDefault() }); }; })(jQuery); diff --git a/project/templates/explorer/file_xml.html b/project/templates/explorer/file_xml.html index db00e6a8..c73f9d76 100644 --- a/project/templates/explorer/file_xml.html +++ b/project/templates/explorer/file_xml.html @@ -18,25 +18,12 @@ function resizePanels() { $('iframe').width($(window).width() - $('#sidebar').outerWidth()); - $('iframe').height($(window).height() - 100); - $('#toggle-sidebar').height($(window).height() - 55); - $('#images-wrap').height($(window).height() - 82) + $('iframe').height($(window).height() - $('#breadcrumbs').height() - $('toolbar').height()); + $('#toggle-sidebar').height($(window).height() - $('#breadcrumbs').height()); + $('#images-wrap').height($(window).height() - $('#breadcrumbs').height() - $('#sidebar-toolbar').height()) $('#images-wrap, #sidebar-toolbar').width($('#sidebar').width() - 10); } - $('#toggle-sidebar').toggle(function() { - $('#images-wrap').width(480); - $('#sidebar').width(488); - $('#images-wrap').data('lazyload:lastCheckedScrollTop', -10000); - $('#sidebar-toolbar').width(480); - resizePanels(); - }, function() { - $('#images-wrap').width(0); - $('#sidebar').width(8); - $('#sidebar-toolbar').width(0); - resizePanels(); - }) - $(window).resize(function() { resizePanels(); }) @@ -92,7 +79,8 @@ return event.ctrlKey && keys[event.keyCode]; }); - // $('#sidebar').bind('resizable:resize', resizePanels).resizable('#toggle-sidebar'); + $('#sidebar').bind('resizable:resize', resizePanels) + .resizable('#toggle-sidebar', {minWidth: 8}); resizePanels(); }