Resize player windows to correct dimensions on open

This commit is contained in:
Duncan Sommerville 2015-07-02 16:07:49 -04:00
parent 32f0f7fcec
commit e3101e90b2
2 changed files with 59 additions and 57 deletions

View file

@ -1,5 +1,6 @@
var _playlist_jplayer; var _playlist_jplayer;
var _idToPostionLookUp; var _idToPostionLookUp;
var URL_BAR_HEIGHT = 32;
/** /**
*When the page loads the ready function will get all the data it can from the hidden span elements *When the page loads the ready function will get all the data it can from the hidden span elements
@ -187,18 +188,11 @@ function buildplaylist(p_url, p_playIndex) {
_playlist_jplayer.option("autoPlay", true); _playlist_jplayer.option("autoPlay", true);
play(p_playIndex); play(p_playIndex);
var height = Math.min(143 + (26 * total), 400); window.scrollbars = false;
var width = 505;
if (height === 400) { var container = $("#jp_container_1");
window.scrollbars = true; // Add 2px to account for borders
} window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2);
else {
//there's no scrollbars so we don't need the window to be as wide.
width = 490;
}
window.resizeTo(width, height);
}); });
} }
@ -247,4 +241,8 @@ function playOne(uri, mime) {
_playlist_jplayer.setPlaylist(playlist); _playlist_jplayer.setPlaylist(playlist);
_playlist_jplayer.play(0); _playlist_jplayer.play(0);
} }
var container = $("#jp_container_1");
// Add 2px to account for borders
window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2);
} }

View file

@ -1,3 +1,6 @@
var previewWidth = 482,
previewHeight = 110;
$(document).ready(function() { $(document).ready(function() {
/* Removed as this is now (hopefully) unnecessary */ /* Removed as this is now (hopefully) unnecessary */
@ -95,7 +98,7 @@ function open_audio_preview(type, id) {
// The reason that we need to encode artist and title string is that // The reason that we need to encode artist and title string is that
// sometime they contain '/' or '\' and apache reject %2f or %5f // sometime they contain '/' or '\' and apache reject %2f or %5f
// so the work around is to encode it twice. // so the work around is to encode it twice.
openPreviewWindow(baseUrl+'audiopreview/audio-preview/audioFileID/'+id+'/type/'+type); openPreviewWindow(baseUrl+'audiopreview/audio-preview/audioFileID/'+id+'/type/'+type, previewWidth, previewHeight);
_preview_window.focus(); _preview_window.focus();
} }
@ -113,7 +116,7 @@ function open_playlist_preview(p_playlistID, p_playlistIndex) {
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playAllPlaylist(p_playlistID, p_playlistIndex); _preview_window.playAllPlaylist(p_playlistID, p_playlistIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/playlist-preview/playlistIndex/'+p_playlistIndex+'/playlistID/'+p_playlistID); openPreviewWindow(baseUrl+'audiopreview/playlist-preview/playlistIndex/'+p_playlistIndex+'/playlistID/'+p_playlistID, previewWidth, previewHeight);
_preview_window.focus(); _preview_window.focus();
} }
@ -124,7 +127,7 @@ function open_block_preview(p_blockId, p_blockIndex) {
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playBlock(p_blockId, p_blockIndex); _preview_window.playBlock(p_blockId, p_blockIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/block-preview/blockIndex/'+p_blockIndex+'/blockId/'+p_blockId); openPreviewWindow(baseUrl+'audiopreview/block-preview/blockIndex/'+p_blockIndex+'/blockId/'+p_blockId, previewWidth, previewHeight);
_preview_window.focus(); _preview_window.focus();
} }
@ -138,13 +141,14 @@ function open_show_preview(p_showID, p_showIndex) {
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playAllShow(p_showID, p_showIndex); _preview_window.playAllShow(p_showID, p_showIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/show-preview/showID/'+p_showID+'/showIndex/'+p_showIndex); openPreviewWindow(baseUrl+'audiopreview/show-preview/showID/'+p_showID+'/showIndex/'+p_showIndex, previewWidth, previewHeight);
_preview_window.focus(); _preview_window.focus();
} }
function openPreviewWindow(url) { function openPreviewWindow(url, w, h) {
var dim = (w && h) ? 'width=' + w + ',height=' + h + ',' : '';
// Hardcoding this here is kinda gross, but the alternatives aren't much better... // Hardcoding this here is kinda gross, but the alternatives aren't much better...
_preview_window = window.open(url, $.i18n._('Audio Player'), 'width=482,height=110,scrollbars=yes'); _preview_window = window.open(url, $.i18n._('Audio Player'), dim + 'scrollbars=yes');
return false; return false;
} }