X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/82d463191442b0931e0c51c0cf4c2ef1383b400b..cb87c787916de7712a4f9fb638715e6185804711:/project/static/js/jquery.resizable.js?ds=inline diff --git a/project/static/js/jquery.resizable.js b/project/static/js/jquery.resizable.js index 415aa2da..3fae2bf0 100644 --- a/project/static/js/jquery.resizable.js +++ b/project/static/js/jquery.resizable.js @@ -1,31 +1,54 @@ (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) + $('body').css('cursor', 'auto'); return false; } }; - $.fn.resizable = function(handle) { + $.fn.resizable = function(options) { + var settings = { + minWidth: 0, + maxWidth: $(window).width() + } + + $.extend(settings, options); + var element = $(this); - $(handle, element).mousedown(function(event) { + var handle = $('.panel-slider', element) + + handle.mousedown(function(event) { var position = element.position(); - $.resizable.element = { + console.log('Mouse down on position: ' + position); + /* from this point on, the panel should resize events */ + + /* $.resizable.settings = settings; + $.resizable.data = { element: element, width: parseInt(element.css('width')) || element[0].scrollWidth || 0, mouseX: event.pageX, - }; - $().mousemove($.resizable.drag).mouseup($.resizable.stop); + }; */ + + $(document).mousemove($.resizable.ondrag, element).mouseup($.resizable.stop, element); + /* $('body').css('cursor', 'col-resize'); */ }); + + /* stop drag events */ + handle.bind('dragstart', function(event) { event.preventDefault(); }) + .bind('drag', function(event) { event.preventDefault(); }) + .bind('draggesture', function(event) { event.preventDefault(); }); }; })(jQuery);