Browse Source

Merge pull request #8228 from Piccirello/webui-save-window-size

WebUI Save user's resized windows
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
6d44075662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      src/webui/www/private/scripts/mocha-init.js

59
src/webui/www/private/scripts/mocha-init.js

@ -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,27 +59,31 @@ 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',
scrollbars: true, scrollbars: true,
resizable: false,
maximizable: false, maximizable: false,
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,
@ -74,30 +92,35 @@ initializeWindows = function() {
css: ['css/Tabs.css'] css: ['css/Tabs.css']
}, },
toolbarURL: 'preferences.html', toolbarURL: 'preferences.html',
resizable: true,
maximizable: false, maximizable: false,
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',
scrollbars: true, scrollbars: true,
resizable: false,
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 +616,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);
}
}); });
}); });

Loading…
Cancel
Save