Skip to content

Commit

Permalink
#2665 add custom toolbar position, now defaults to 'top'
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26357 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 16, 2020
1 parent aded5af commit a0a44b8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
20 changes: 18 additions & 2 deletions src/html5/connect.html
Expand Up @@ -241,6 +241,14 @@ <h4 class="panel-title">Advanced options</h4>
</li>
<li class="list-group-item">
<input type="checkbox" id="floating_menu"> <span>Floating Menu</span>, <input type="checkbox" id="autohide"> <span>Auto Hide</span>, <input type="checkbox" id="clock"> <span>Server clock</span>
<br />
<li class="list-group-item">
Menu position:
<select id="toolbar_position">
<option value="top-left">Top Left</option>
<option value="top">Top</option>
<option value="top-right">Top Right</option>
</select>
</li>
<li class="list-group-item">
<input type="checkbox" id="video"> <span>Video <input type="checkbox" id="mediasource_video"> Native decoding</span>
Expand Down Expand Up @@ -295,7 +303,7 @@ <h4 class="panel-title">Advanced options</h4>
}
}
add_prop("submit", true);
const val_props = ["server", "port", "path", "username", "password", "bandwidth_limit", "encoding", "keyboard_layout", "audio_codec"];
const val_props = ["server", "port", "path", "username", "password", "bandwidth_limit", "encoding", "keyboard_layout", "audio_codec", "toolbar_position"];
for (let i = 0; i < val_props.length; i++) {
const prop = val_props[i];
const value = document.getElementById(prop).value;
Expand Down Expand Up @@ -375,9 +383,13 @@ <h4 class="panel-title">Advanced options</h4>
if (pathname && pathname=="/") {
pathname = "";
}
var path = getparam("path")
if (path && path.endsWith("/index.html")) {
path = path.substr(0, path.lastIndexOf("/"));
}
document.getElementById("server").value = getparam("server") || link.hostname;
document.getElementById("port").value = getparam("port") || link.port;
document.getElementById("path").value = getparam("path") || pathname;
document.getElementById("path").value = path || pathname;
document.getElementById("username").value = getparam("username") || "";
const https = document.location.protocol=="https:";
const ssl = getboolparam("ssl", https);
Expand Down Expand Up @@ -566,6 +578,10 @@ <h4 class="panel-title">Advanced options</h4>
}
floating_menu_checkbox.change(set_menu_attributes_visibility);
set_menu_attributes_visibility();
let toolbar_position = getparam("toolbar_position") || "top";
if (toolbar_position) {
document.getElementById('toolbar_position').value = toolbar_position;
}

//this may override default values (ie: terminate flags are off for connect mode):
set_exit_actions(action=="connect" || action=="");
Expand Down
53 changes: 45 additions & 8 deletions src/html5/index.html
Expand Up @@ -452,6 +452,10 @@ <h2>Xpra Bug Report</h2>
const swap_keys = getboolparam("swap_keys", Utilities.isMacOS());
const scroll_reverse_x = getboolparam("scroll_reverse_x", false);
const scroll_reverse_y = getboolparam("scroll_reverse_y", Utilities.isMacOS());
const floating_menu = getboolparam("floating_menu", true);
const toolbar_position = getparam("toolbar_position");
const autohide = getboolparam("autohide", false);

try {
sessionStorage.removeItem("password");
}
Expand Down Expand Up @@ -648,13 +652,24 @@ <h2>Xpra Bug Report</h2>
"insecure" : insecure,
"server" : server,
"port" : port,
"ssl" : ssl,
"path" : path,
"encryption" : encryption,
//"key" : key,
"encoding" : encoding,
"bandwidth_limit" : bandwidth_limit,
"keyboard_layout" : keyboard_layout,
"swap_keys" : swap_keys,
"scroll_reverse_x" : scroll_reverse_x,
"scroll_reverse_y" : scroll_reverse_y,
"reconnect" : reconnect,
"action" : action,
"start" : start,
"sound" : sound,
"audio_codec" : audio_codec,
"clipboard" : clipboard,
"printing" : printing,
"file_transfer" : file_transfer,
"exit_with_children": exit_with_children,
"exit_with_client" : exit_with_client,
"sharing" : sharing,
Expand All @@ -663,6 +678,9 @@ <h2>Xpra Bug Report</h2>
"mediasource_video" : mediasource_video,
"remote_logging" : remote_logging,
"ignore_audio_blacklist" : ignore_audio_blacklist,
"floating_menu" : floating_menu,
"toolbar_position" : toolbar_position,
"autohide" : autohide,
};
for (let i=0; i<client.debug_categories.length; i++) {
const category = client.debug_categories[i];
Expand Down Expand Up @@ -992,17 +1010,36 @@ <h2>Xpra Bug Report</h2>

let client;
function init_page() {
const floating_menu = getboolparam("floating_menu", true);
const autohide = getboolparam("autohide", false);
const toolbar_position = getparam("toolbar_position");
const float_menu_element = $('#float_menu');
if (!getboolparam("floating_menu", true)) {
if (!floating_menu) {
float_menu_element.hide();
}

if (getboolparam("autohide", false)) {
float_menu_element.on('mouseover', expand_float_menu);
float_menu_element.on('mouseout', retract_float_menu);
}
else {
expand_float_menu();
var toolbar_width = float_menu_element.width();
var left = 0;
var top = float_menu_element.offset().top || 0;
var screen_width = $('#screen').width();
if (toolbar_position=="top-left") {
//no calculations needed
}
else if (toolbar_position=="top") {
left = screen_width/2-toolbar_width/2;
}
else if (toolbar_position=="top-right") {
left = screen_width-toolbar_width-100;
}
float_menu_element.offset({ top: top, left: left });

if (autohide) {
float_menu_element.on('mouseover', expand_float_menu);
float_menu_element.on('mouseout', retract_float_menu);
}
else {
expand_float_menu();
}
}

const touchaction = getparam("touchaction") || "scroll";
Expand Down Expand Up @@ -1080,7 +1117,7 @@ <h2>Xpra Bug Report</h2>
//so getparam will look there
for (const key in tmp_default_settings) {
default_settings[key] = tmp_default_settings[key];
}
}
init_page();
};
xhr.onerror = function() {
Expand Down

0 comments on commit a0a44b8

Please sign in to comment.