Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Toggle labels button #139

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions dev/js/main/main.controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var R6MMainControls = (function($, window, document, R6MLangTerms, undefined) {
$floorControl = $('#floor-control'),
$zoomControl = $('#zoom-range'),
$menuControl = $('#mmenu-link'),
$toggleControl = $('#toggle-control'),
$lockPanningControl,
$enableScreenshotsControl,
$roomLabelStylesControl,
Expand All @@ -14,7 +15,10 @@ var R6MMainControls = (function($, window, document, R6MLangTerms, undefined) {
$menuSelectMapsControl,
$sessionsControl,
$menuPanel = $('#menu-panel'),
ROOM_LABEL_STYLE_DEFAULT = 'Light',
ROOM_LABEL_STYLE_DISPLAY_NONE = 'DisplayNone',
SELECTED_CLASS = 'selected',
TOGGLE_TYPE_LABEL = 'label',
ZOOMED_IN_FAR_CLASS = 'zoomed-in-far',
ZOOMED_OUT_FAR_CLASS = 'zoomed-out-far',
CSS_TRANSITION_MS = 1800; // currently in highlighted-item mixin for .highlighted-item-in-transition
Expand Down Expand Up @@ -136,6 +140,8 @@ var R6MMainControls = (function($, window, document, R6MLangTerms, undefined) {
if (floorsTrySelect(0)) {
showSelectedFloorFn();
}
} else if (keyCode == 84) { // 't'
triggerToggleEvent(TOGGLE_TYPE_LABEL);
}
};
};
Expand Down Expand Up @@ -581,6 +587,47 @@ var R6MMainControls = (function($, window, document, R6MLangTerms, undefined) {
return R6MHelpers.trySelectOption($objectiveControl, objective);
};

var togglePopulate = function togglePopulate() {
var btns = '<button id="toggle-label" title="Toggle Labels (Shortcut: t)">'
+ '<span class="short">Labels</span>'
+ '<span class="full">Toggle Labels</span>'
+ '</button>';

$toggleControl.html(btns);
};

var setupToggleClickEvent = function setupToggleClickEvent(callback) {
$toggleControl.on('click', '#toggle-' + TOGGLE_TYPE_LABEL, function(e) {
var cur = $roomLabelStylesControl.val();
var prev = $(this).data('prevRoomStyle') ? $(this).data('prevRoomStyle') : ROOM_LABEL_STYLE_DISPLAY_NONE;

if (cur == prev){
prev = cur === ROOM_LABEL_STYLE_DISPLAY_NONE ? ROOM_LABEL_STYLE_DEFAULT : ROOM_LABEL_STYLE_DISPLAY_NONE;
}

$roomLabelStylesControl.val(prev).trigger('change');
$(this).data('prevRoomStyle', cur);
if (callback && typeof callback === 'function'){
callback();
}
});
};

var triggerToggleEvent = function triggerToggleEvent(type){
// Validate type and default to label
switch (type){
case TOGGLE_TYPE_LABEL:
break;
default:
type = TOGGLE_TYPE_LABEL;
}
$toggleControl.find('#toggle-' + type).trigger('click');
};

var toggleSetup = function toggleSetup(callback) {
setupToggleClickEvent(callback);
};

var removeLatestUpdateHighlight = function removeLatestUpdateHighlight(initialDelayMs) {
unhighlightControl($('#menu-latest-updates'), initialDelayMs);
};
Expand Down Expand Up @@ -674,6 +721,10 @@ var R6MMainControls = (function($, window, document, R6MLangTerms, undefined) {
enable: sessionsEnable,
setup: sessionsSetupClickEvent
},
toggle: {
populate: togglePopulate,
setup: toggleSetup
},
zoom: {
disable: zoomDisable,
enable: zoomEnable,
Expand Down
4 changes: 3 additions & 1 deletion dev/js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
setupMenu();
setupSelectMap();
R6MMainControls.maps.populate(R6MMainData.getMapData());
R6MMainControls.toggle.populate();

$sessionsDialog = $('#sessions-dialog');
R6MMainSessions.createJoinDialog.setup($sessionsDialog);
Expand Down Expand Up @@ -402,6 +403,7 @@
var setupEvents = function setupEvents() {
$mapMains.on('click', outputCoordinates);
R6MMainControls.objectives.setup(handleObjectiveChange);
R6MMainControls.toggle.setup();
R6MMainControls.maps.setup(handleMapChange);
R6MMainControls.floors.setup(handleFloorChange, showSelectedFloor);
R6MMainControls.roomLabelStyles.setup(setRoomLabelStyle);
Expand Down Expand Up @@ -460,7 +462,7 @@
R6MMainControls.setupLosOpacity(updateLosOpacity, getCameraLosOpacity(), DEFAULT_LOS_OPACITY);
};

var setupSelectMap = function seteupSelectMap() {
var setupSelectMap = function setupSelectMap() {
R6MMainSelectMaps.setup(
$('#select-map-grid'),
$('#select-map-heading'),
Expand Down
11 changes: 10 additions & 1 deletion dev/scss/main/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,16 @@ nav {
}
}

#floor-control {
#toggle-control {
button:focus {
background-color: #fff;
}
button:focus:hover {
background-color: $r6-blue;
}
}

#floor-control, #toggle-control {
display: inline-block;
margin-left: $control-padding-left-right;

Expand Down
Loading