X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c7917ce18f0f62eac89e1eb4b6ae6d8c48133600..308aa7c7d75b50a4b36a70681b5e012dbd023c11:/project/static/js/jquery.hpanel.js?ds=sidebyside diff --git a/project/static/js/jquery.hpanel.js b/project/static/js/jquery.hpanel.js index d33e47fb..1ad0d17f 100644 --- a/project/static/js/jquery.hpanel.js +++ b/project/static/js/jquery.hpanel.js @@ -5,14 +5,13 @@ settings: {}, current_data: {}, resize_start: function(event, mydata) { - $.log('Overlay: ' + mydata.overlay); $(document).bind('mousemove', mydata, $.hpanel.resize_changed). bind('mouseup', mydata, $.hpanel.resize_stop); $('.panel-overlay', mydata.root).css('display', 'block'); return false; }, - resize_changed: function(event) { + resize_changed: function(event) { var old_width = parseInt(event.data.overlay.css('width')); var delta = event.pageX + event.data.hotspot_x - old_width; event.data.overlay.css({'width': old_width + delta}); @@ -36,17 +35,14 @@ $(this).data('panel').css({ 'left': $(this).css('left'), 'width': $(this).css('width')}); }); - $('.panel-overlay', event.data.root).css('display', 'none'); + $(event.data.root).trigger('stopResize'); } }; $.fn.makeHorizPanel = function(options) { - $.log('Making an hpanel out of "#' + $(this).attr('id') + '"'); var root = $(this) - var all_panels = $('.panel-wrap', root) - $.log('Panels: ' + all_panels); /* create an overlay */ var overlay_root = $("
"); @@ -54,23 +50,24 @@ var prev = null; - all_panels.each(function(i) { - var panel = $(all_panels[i]); + $('*.panel-wrap', root).each( function() + { + var panel = $(this); var handle = $('.panel-slider', panel); - - var overlay = $("

Panel #"+i+"

"); + var overlay = $("
 
"); overlay_root.append(overlay); overlay.data('panel', panel); overlay.data('next', null); + if (prev) prev.next = overlay; + if( panel.hasClass('last-panel') ) + { overlay.css({'left': panel.css('left'), 'right': panel.css('right')}); - else + } + else { overlay.css({'left': panel.css('left'), 'width': panel.css('width')}); - - if (prev) prev.next = overlay; - - if(handle) { + $.log('Has handle: ' + panel.attr('id')); overlay.append(handle.clone()); /* attach the trigger */ handle.mousedown(function(event) { @@ -86,12 +83,12 @@ (handle.outerWidth() || 10) + 'px'); $('.panel-content-overlay', panel).css('right', (handle.outerWidth() || 10) + 'px'); - } - + }; + prev = overlay; }); - root.bind('hpanel:panel-resize-start', $.hpanel.resize_start); + root.bind('hpanel:panel-resize-start', $.hpanel.resize_start); }; })(jQuery);