diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-07-31 22:47:47 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-07-31 22:47:47 +0300 |
commit | 9bd9c4373f31bb381fd80564decd8671d942fdc8 (patch) | |
tree | 60252561fd137fdb306e83199d6ca899a0f5bf44 /lib/scripts | |
parent | d971ea8b02ccca4dd879a5db966670e0f3b4f102 (diff) | |
download | rpg-9bd9c4373f31bb381fd80564decd8671d942fdc8.tar.gz rpg-9bd9c4373f31bb381fd80564decd8671d942fdc8.tar.bz2 |
issue #32 calculation of the panels width is redone when browser window is resized
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/media.js | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/lib/scripts/media.js b/lib/scripts/media.js index ff87299cf..17006e289 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -25,6 +25,8 @@ var dw_mediamanager = { // File list view type view: false, + layout_width: 0, + init: function () { var $content, $tree; $content = jQuery('#media__content'); @@ -417,7 +419,7 @@ var dw_mediamanager = { dw_mediamanager.prepare_content($content); dw_mediamanager.updatehide(); - dw_mediamanager.update_resizable(0); + dw_mediamanager.update_resizable(); addInitEvent(revisionsForm); jQuery('#mediamanager__form_sort').find('input[type=submit]').hide(); dw_mediamanager.set_filelist_view(dw_mediamanager.view, false); @@ -427,12 +429,53 @@ var dw_mediamanager = { ); }, + window_resize: function () { + if (jQuery('#mediamanager__layout').width() == dw_mediamanager.layout_width) { + return; + } + + dw_mediamanager.layout_width = jQuery('#mediamanager__layout').width(); + + $r = jQuery("#mediamanager__layout .layout-resizable, #mediamanager__layout .layout"); + + var w = 0, wSum = 0, mCount = 0, mArray = []; + $r.each(function() { + w = jQuery(this).width(); + if (w == parseFloat(jQuery(this).css("min-width"))) { + wSum += w; + } else { + mArray[mCount] = jQuery(this); + mCount++; + } + }); + + if (mCount > 0) { + var width = (0.95 * jQuery('#mediamanager__layout').width() - wSum - 30); + wSum = 0; + for(var i = 0; i < mArray.length; i++) { + wSum += mArray[i].width(); + } + for(var i = 0; i < mArray.length; i++) { + w = mArray[i].width(); + w = 100*w / wSum; + mArray[i].width(width*w/100); + } + } + + $r.each(function() { + w = jQuery(this).width(); + w = (100 * w / jQuery('#mediamanager__layout').width()); + w += "%"; + jQuery(this).width(w); + }); + }, + /** * Updates mediamanager layout * * @author Kate Arzamastseva <pshns@ukr.net> */ - update_resizable: function (count_width) { + update_resizable: function () { $resizable = jQuery("#mediamanager__layout .layout-resizable"); $resizable.resizable({ handles: 'e' , @@ -454,6 +497,13 @@ var dw_mediamanager = { var wRight = 95-wLeft; wRight += "%"; jQuery('#mediamanager__layout_detail').width(wRight); + + $resizable.each(function() { + w = jQuery(this).width(); + w = (100 * w / jQuery('#mediamanager__layout').width()); + w += "%"; + jQuery(this).width(w); + }); } }); @@ -828,8 +878,9 @@ function hasFlash(version){ } jQuery(document).ready(function() { - dw_mediamanager.update_resizable(1); - jQuery(window).resize(dw_mediamanager.update_resizable); + dw_mediamanager.update_resizable(); + dw_mediamanager.layout_width = jQuery("#mediamanager__layout").width(); + jQuery(window).resize(dw_mediamanager.window_resize); }); jQuery(dw_mediamanager.init); |