diff options
author | Dominik Eckelmann <deckelmann@gmail.com> | 2011-11-19 14:44:48 +0100 |
---|---|---|
committer | Dominik Eckelmann <deckelmann@gmail.com> | 2011-11-19 14:44:48 +0100 |
commit | 402e0951b7e3ccf567702515bfe0b09cca8a5a93 (patch) | |
tree | b5c4526d2d7ca1482fe8a67aa12125b065c478be /lib/scripts/media.js | |
parent | 5446f3ffde77013d4eaea1fb166bcbd905a777a4 (diff) | |
parent | 1017f6f159386699a10d2529c50fb5e28b5c1889 (diff) | |
download | rpg-402e0951b7e3ccf567702515bfe0b09cca8a5a93.tar.gz rpg-402e0951b7e3ccf567702515bfe0b09cca8a5a93.tar.bz2 |
Merge branch 'master' of github.com:dom-mel/dokuwiki
Diffstat (limited to 'lib/scripts/media.js')
-rw-r--r-- | lib/scripts/media.js | 99 |
1 files changed, 36 insertions, 63 deletions
diff --git a/lib/scripts/media.js b/lib/scripts/media.js index aa369657d..7f5514f56 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -427,6 +427,10 @@ var dw_mediamanager = { function (data) { dw_mediamanager.$resizables().resizable('destroy'); + if (update_list) { + dw_mediamanager.list.call(jQuery('input[value="Apply"]')[0]); + } + $content.html(data); dw_mediamanager.prepare_content($content); @@ -442,9 +446,6 @@ var dw_mediamanager = { dw_mediamanager.init_ajax_uploader(); dw_mediamanager.init_options(); - if (update_list) { - dw_mediamanager.list.call(jQuery('a.files')[0]); - } }, 'html' ); @@ -456,44 +457,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(); @@ -512,32 +475,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(); @@ -549,7 +517,7 @@ var dw_mediamanager = { resize: function () { var $contents = jQuery('#mediamanager__page div.panelContent'), - height = jQuery(window).height() - jQuery(document).height() + + height = jQuery(window).height() - jQuery(document.body).height() + Math.max.apply(null, jQuery.map($contents, function (v) { return jQuery(v).height(); })); @@ -682,12 +650,17 @@ var dw_mediamanager = { }); }, + /** + * Parse a URI query string to an associative array + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ params_toarray: function (str) { var vars = [], hash; var hashes = str.split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); - vars[hash[0]] = hash[1]; + vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]); } return vars; }, |