diff options
Diffstat (limited to 'lib/scripts/media.js')
-rw-r--r-- | lib/scripts/media.js | 95 |
1 files changed, 34 insertions, 61 deletions
diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 48bfdbbe8..841baa93f 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -135,7 +135,7 @@ var dw_mediamanager = { }); $sortBy.children('input').change(function (event) { dw_mediamanager.set_fileview_sort(); - dw_mediamanager.list.call(this, event); + dw_mediamanager.list.call(jQuery('#dw__mediasearch')[0] || this, event); }); }, @@ -253,8 +253,10 @@ var dw_mediamanager = { } } } - alignleft = dw_mediamanager.align === '2' ? '' : ' '; - alignright = dw_mediamanager.align === '4' ? '' : ' '; + if (dw_mediamanager.align !== '1') { + alignleft = dw_mediamanager.align === '2' ? '' : ' '; + alignright = dw_mediamanager.align === '4' ? '' : ' '; + } } } edid = String.prototype.match.call(document.location, /&edid=([^&]+)/); @@ -371,6 +373,10 @@ var dw_mediamanager = { if (typeof new_val === 'undefined') { new_val = jQuery('form.options li.' + opt[1] + ' input') .filter(':checked').val(); + // if new_val is still undefined (because form.options is not in active tab), set to most spacious option + if (typeof new_val === 'undefined') { + new_val = 'thumbs'; + } } if (new_val !== dw_mediamanager.view_opts[opt[0]]) { @@ -457,44 +463,6 @@ var dw_mediamanager = { }, window_resize: function () { - if (jQuery('#mediamanager__page').width() == dw_mediamanager.layout_width) { - return; - } - - dw_mediamanager.layout_width = jQuery('#mediamanager__page').width(); - $r = jQuery("#mediamanager__page div.panel"); - - 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__page').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__page').width()); - w += "%"; - jQuery(this).width(w); - }); - dw_mediamanager.resize(); dw_mediamanager.opacity_slider(); @@ -513,32 +481,37 @@ var dw_mediamanager = { update_resizable: function () { $resizables = dw_mediamanager.$resizables(); - $resizables.resizable({ handles: 'e' , + $resizables.resizable({ + handles: 'e', resize: function(event, ui){ - var w = 0; + var widthFull = jQuery('#mediamanager__page').width(); + var widthResizables = 0; $resizables.each(function() { - w += jQuery(this).width(); + widthResizables += jQuery(this).width(); }); - wSum = w + parseFloat(jQuery('#mediamanager__page div.file').css("min-width")); + var $filePanel = jQuery('#mediamanager__page div.panel.file'); - // max width of resizable column - var maxWidth = 0.95 * jQuery('#mediamanager__page').width() - wSum + jQuery(this).width() - 30; + // set max width of resizable column + var widthOtherResizable = widthResizables - jQuery(this).width(); + var minWidthNonResizable = parseFloat($filePanel.css("min-width")); + var maxWidth = widthFull - (widthOtherResizable + minWidthNonResizable); $resizables.resizable( "option", "maxWidth", maxWidth ); - // percentage width of the first two columns - var wLeft = ( 100*(w+30) / jQuery('#mediamanager__page').width() ); - - // width of the third column - var wRight = 95-wLeft; - wRight += "%"; - jQuery('#mediamanager__page div.file').width(wRight); - - $resizables.each(function() { - w = jQuery(this).width(); - w = (100 * w / jQuery('#mediamanager__page').width()); - w += "%"; - jQuery(this).width(w); - }); + // width of file panel in % = 100% - width of resizables in % + // this calculates with 99.99 and not 100 to overcome rounding errors + var relWidthNonResizable = 99.99 - (100 * widthResizables / widthFull); + // set width of file panel + $filePanel.width(relWidthNonResizable+'%'); + + // FIXME: please fix without browser sniffing + if (!jQuery.browser.webkit) { + $resizables.each(function() { + w = jQuery(this).width(); + w = (99.99 * w / widthFull); + w += "%"; + jQuery(this).width(w); + }); + } dw_mediamanager.opacity_slider(); dw_mediamanager.portions_slider(); |