1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

WebUI Save user's resized window sizes

This commit is contained in:
Thomas Piccirello 2018-01-23 22:15:44 -05:00
parent 98a1c111b9
commit d1c4b1599a

View File

@ -35,6 +35,20 @@ var pauseFN = function() {};
initializeWindows = function() { initializeWindows = function() {
saveWindowSize = function(windowId) {
var size = $(windowId).getSize();
localStorage.setItem('window_' + windowId + '_width', size.x);
localStorage.setItem('window_' + windowId + '_height', size.y);
};
loadWindowWidth = function(windowId, defaultValue) {
return getLocalStorageItem('window_' + windowId + '_width', defaultValue);
};
loadWindowHeight = function(windowId, defaultValue) {
return getLocalStorageItem('window_' + windowId + '_height', defaultValue);
};
function addClickEvent(el, fn) { function addClickEvent(el, fn) {
['Link', 'Button'].each(function(item) { ['Link', 'Button'].each(function(item) {
if ($(el + item)) { if ($(el + item)) {
@ -45,8 +59,9 @@ initializeWindows = function() {
addClickEvent('download', function(e) { addClickEvent('download', function(e) {
new Event(e).stop(); new Event(e).stop();
var id = 'downloadPage';
new MochaUI.Window({ new MochaUI.Window({
id: 'downloadPage', id: id,
title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]", title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]",
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'download.html', contentURL: 'download.html',
@ -56,16 +71,20 @@ initializeWindows = function() {
closable: true, closable: true,
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 500, width: loadWindowWidth(id, 500),
height: 420 height: loadWindowHeight(id, 420),
onResize: function() {
saveWindowSize(id);
}
}); });
updateMainData(); updateMainData();
}); });
addClickEvent('preferences', function(e) { addClickEvent('preferences', function(e) {
new Event(e).stop(); new Event(e).stop();
var id = 'preferencesPage';
new MochaUI.Window({ new MochaUI.Window({
id: 'preferencesPage', id: id,
title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]", title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
loadMethod: 'xhr', loadMethod: 'xhr',
toolbar: true, toolbar: true,
@ -79,15 +98,19 @@ initializeWindows = function() {
closable: true, closable: true,
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 700, width: loadWindowWidth(id, 700),
height: 300 height: loadWindowHeight(id, 300),
onResize: function() {
saveWindowSize(id);
}
}); });
}); });
addClickEvent('upload', function(e) { addClickEvent('upload', function(e) {
new Event(e).stop(); new Event(e).stop();
var id = 'uploadPage';
new MochaUI.Window({ new MochaUI.Window({
id: 'uploadPage', id: id,
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]", title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'upload.html', contentURL: 'upload.html',
@ -96,8 +119,11 @@ initializeWindows = function() {
maximizable: false, maximizable: false,
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 500, width: loadWindowWidth(id, 500),
height: 260 height: loadWindowHeight(id, 260),
onResize: function() {
saveWindowSize(id);
}
}); });
updateMainData(); updateMainData();
}); });
@ -593,14 +619,18 @@ initializeWindows = function() {
addClickEvent('about', function(e) { addClickEvent('about', function(e) {
new Event(e).stop(); new Event(e).stop();
var id = 'aboutpage';
new MochaUI.Window({ new MochaUI.Window({
id: 'aboutpage', id: id,
title: 'QBT_TR(About)QBT_TR[CONTEXT=AboutDlg]', title: 'QBT_TR(About)QBT_TR[CONTEXT=AboutDlg]',
loadMethod: 'xhr', loadMethod: 'xhr',
contentURL: 'about.html', contentURL: 'about.html',
width: 550, padding: 10,
height: 290, width: loadWindowWidth(id, 550),
padding: 10 height: loadWindowHeight(id, 290),
onResize: function() {
saveWindowSize(id);
}
}); });
}); });