From 09e1ebc972cf3ba02281fd6f75ff5176b547d00e Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 30 May 2011 09:56:10 -0500 Subject: [PATCH] Add 'sidebaropened' option to auto-pin sidebar --- configuration.txt | 3 + .../dynmap/ClientConfigurationComponent.java | 1 + web/js/map.js | 74 +++++++++++-------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/configuration.txt b/configuration.txt index 159ef936..3dd74ef8 100644 --- a/configuration.txt +++ b/configuration.txt @@ -95,6 +95,9 @@ updaterate: 2000 showplayerfacesinmenu: true +# Set sidebaropened: true to pin menu sidebar opened +#sidebaropened: true + joinmessage: "%playername% joined" quitmessage: "%playername% quit" spammessage: "You may only chat once every %interval% seconds." diff --git a/src/main/java/org/dynmap/ClientConfigurationComponent.java b/src/main/java/org/dynmap/ClientConfigurationComponent.java index 195859e1..cf9356cc 100644 --- a/src/main/java/org/dynmap/ClientConfigurationComponent.java +++ b/src/main/java/org/dynmap/ClientConfigurationComponent.java @@ -20,6 +20,7 @@ public class ClientConfigurationComponent extends Component { s(t, "quitmessage", c.getString("quitmessage", "%playername% quit")); s(t, "spammessage", c.getString("spammessage", "You may only chat once every %interval% seconds.")); s(t, "defaultzoom", c.getInteger("defaultzoom", 0)); + s(t, "sidebaropened", c.getBoolean("sidebaropened", false)); DynmapWorld defaultWorld = null; for(DynmapWorld world : plugin.mapManager.getWorlds()) { diff --git a/web/js/map.js b/web/js/map.js index 114bb19a..c96ac9d8 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -165,22 +165,36 @@ DynMap.prototype = { */ // Sidebar - var sidebar = me.sidebar = $('
') - .addClass('sidebar') - .appendTo(container); + var panel; + var sidebar; + var pinbutton; + if(!me.options.sidebaropened) { + sidebar = me.sidebar = $('
') + .addClass('sidebar') + .appendTo(container); - var panel = $('
') - .addClass('panel') - .appendTo(sidebar); + panel = $('
') + .addClass('panel') + .appendTo(sidebar); - // Pin button. - var pinbutton = $('
') - .addClass('pin') - .click(function() { - sidebar.toggleClass('pinned'); - }) - .appendTo(panel); + // Pin button. + pinbutton = $('
') + .addClass('pin') + .click(function() { + sidebar.toggleClass('pinned'); + }) + .appendTo(panel); + } + else { + sidebar = me.sidebar = $('
') + .addClass('sidebar pinned') + .appendTo(container); + panel = $('
') + .addClass('panel') + .appendTo(sidebar); + } + // Worlds var worldlist; $('
') @@ -275,11 +289,12 @@ DynMap.prototype = { .append(link=$('')) .data('link', link) .appendTo(container);*/ - - $('
') - .addClass('hitbar') - .appendTo(panel); - + if(!me.options.sidebaropened) { + $('
') + .addClass('hitbar') + .appendTo(panel); + } + var alertbox = me.alertbox = $('
') .addClass('alertbox') .hide() @@ -371,22 +386,13 @@ DynMap.prototype = { if (!me.options.jsonfile) { me.lasttimestamp = update.timestamp; } - - me.servertime = update.servertime; + + me.servertime = update.servertime; var oldday = me.serverday; if(me.servertime > 23100 || me.servertime < 12900) me.serverday = true; else me.serverday = false; - if(me.serverday != oldday) { - var mtid = me.map.mapTypeId; - if(me.map.mapTypes[mtid].nightandday) { - me.map.setMapTypeId('none'); - window.setTimeout(function() { - me.map.setMapTypeId(mtid); - }, 1); - } - } var newplayers = {}; $.each(update.players, function(index, playerUpdate) { @@ -429,6 +435,16 @@ DynMap.prototype = { //var divs = $('div[rel]'); //divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove(); }); + + if(me.serverday != oldday) { + var mtid = me.map.mapTypeId; + if(me.map.mapTypes[mtid].nightandday) { + me.map.setMapTypeId('none'); + window.setTimeout(function() { + me.map.setMapTypeId(mtid); + }, 1); + } + } $(me).trigger('worldupdated', [ update ]);