1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add more ui tooltips

This commit is contained in:
Nick O'Leary 2018-10-24 22:57:16 +01:00
parent e64f4e3f39
commit 70fb181b7b
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
9 changed files with 111 additions and 48 deletions

View File

@ -118,6 +118,7 @@ module.exports = function(grunt) {
src: [
// Ensure editor source files are concatenated in
// the right order
"packages/node_modules/@node-red/editor-client/src/js/jquery-addons.js",
"packages/node_modules/@node-red/editor-client/src/js/red.js",
"packages/node_modules/@node-red/editor-client/src/js/events.js",
"packages/node_modules/@node-red/editor-client/src/js/i18n.js",

View File

@ -329,6 +329,7 @@
"nudgeNode": "Move selected nodes (1px)",
"moveNode": "Move selected nodes (20px)",
"toggleSidebar": "Toggle sidebar",
"togglePalette": "Toggle palette",
"copyNode": "Copy selected nodes",
"cutNode": "Cut selected nodes",
"pasteNode": "Paste nodes",
@ -591,6 +592,11 @@
"versionControl": {
"unstagedChanges": "Unstaged changes",
"stagedChanges": "Staged changes",
"unstageChange": "Unstage change",
"stageChange": "Stage change",
"unstageAllChange": "Unstage all changes",
"stageAllChange": "Stage all changes",
"commitChanges": "Commit changes",
"resolveConflicts": "Resolve conflicts",
"head": "HEAD",
"staged": "Staged",
@ -654,7 +660,9 @@
"commitsAheadAndBehind2": "__count__ commit ahead of the remote. ",
"commitsAheadAndBehind2_plural": "__count__ commits ahead of the remote. ",
"commitsAheadAndBehind3": "You must pull the remote commit down before pushing.",
"commitsAheadAndBehind3_plural": "You must pull the remote commits down before pushing."
"commitsAheadAndBehind3_plural": "You must pull the remote commits down before pushing.",
"refreshCommitHistory": "Refresh commit history",
"refreshChanges": "Refresh changes"
}
}
},

View File

@ -0,0 +1,35 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Trigger enabled/disabled events when element.prop("disabled",false/true) is
* called.
* Used by RED.popover to hide a popover when the trigger element is disabled
* as a disabled element doesn't emit mouseleave
*/
jQuery.propHooks.disabled = {
set: function (element, value) {
if (element.disabled !== value) {
element.disabled = value;
if (value) {
$(element).trigger('disabled');
} else {
$(element).trigger('enabled');
}
}
}
};

View File

@ -96,7 +96,11 @@ RED.popover = (function() {
} else if (d === 'bottom') {
top = targetPos.top+targetHeight+deltaSizes[size].top;
left = targetPos.left+targetWidth/2-divWidth/2 - deltaSizes[size].leftBottom;
if (left+divWidth > viewportRight) {
if (left < 0) {
d = "right";
top = targetPos.top+targetHeight/2-divHeight/2-deltaSizes[size].top;
left = targetPos.left+targetWidth+deltaSizes[size].leftRight;
} else if (left+divWidth > viewportRight) {
d = "left";
top = targetPos.top+targetHeight/2-divHeight/2-deltaSizes[size].top;
left = targetPos.left-deltaSizes[size].leftLeft-divWidth;
@ -147,12 +151,14 @@ RED.popover = (function() {
active = true;
timer = setTimeout(openPopup,delay.show);
});
target.on('mouseleave', function(e) {
target.on('mouseleave disabled', function(e) {
if (timer) {
clearTimeout(timer);
}
if (active) {
active = false;
setTimeout(closePopup,delay.hide);
}
});
} else if (trigger === 'click') {
target.click(function(e) {
@ -205,13 +211,13 @@ RED.popover = (function() {
return label;
}
}
RED.popover.create({
return RED.popover.create({
target:target,
trigger: "hover",
size: "small",
direction: "bottom",
content: label,
delay: { show: 350, hide: 10 }
delay: { show: 750, hide: 50 }
});
}
}

View File

@ -503,6 +503,8 @@ RED.palette = (function() {
})
sidebarControls = $('<div class="sidebar-control-left"><i class="fa fa-chevron-left"</div>').appendTo($("#palette"));
RED.popover.tooltip(sidebarControls,RED._("keyboard.togglePalette"),"core:toggle-palette");
sidebarControls.click(function() {
RED.menu.toggleSelected("menu-item-palette");
})

View File

@ -200,12 +200,12 @@ RED.sidebar.versionControl = (function() {
]
})
});
RED.popover.tooltip(revertButton,RED._("sidebar.project.versionControl.revertChanges"));
}
bg = $('<span class="button-group"></span>').appendTo(entryTools);
if (state !== 'unmerged') {
$('<button class="editor-button editor-button-small"><i class="fa fa-'+((state==='unstaged')?"plus":"minus")+'"></i></button>')
var stageButton = $('<button class="editor-button editor-button-small"><i class="fa fa-'+((state==='unstaged')?"plus":"minus")+'"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
@ -231,6 +231,7 @@ RED.sidebar.versionControl = (function() {
}
},{});
});
RED.popover.tooltip(stageButton,RED._("sidebar.project.versionControl."+((state==='unstaged')?"stage":"unstage")+"Change"));
}
entry["update"+((state==='unstaged')?"Unstaged":"Staged")] = function(entry,status) {
container.removeClass();
@ -321,12 +322,13 @@ RED.sidebar.versionControl = (function() {
localChanges.content.css({height:"100%"});
var bg = $('<div style="float: right"></div>').appendTo(localChanges.header);
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
var refreshButton = $('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
refresh(true);
})
});
RED.popover.tooltip(refreshButton,RED._("sidebar.project.versionControl.refreshChanges"));
emptyStagedItem = { label: RED._("sidebar.project.versionControl.none") };
emptyMergedItem = { label: RED._("sidebar.project.versionControl.conflictResolve") };
@ -343,6 +345,7 @@ RED.sidebar.versionControl = (function() {
});
updateBulk(toStage,true);
});
RED.popover.tooltip(stageAllButton,RED._("sidebar.project.versionControl.stageAllChange"));
unstagedChangesList = $("<ol>",{style:"position: absolute; top: 30px; bottom: 0; right:0; left:0;"}).appendTo(unstagedContent);
unstagedChangesList.editableList({
addButton: false,
@ -432,7 +435,7 @@ RED.sidebar.versionControl = (function() {
bg = $('<div style="float: right"></div>').appendTo(header);
var showCommitBox = function() {
commitMessage.val("");
submitCommitButton.attr("disabled",true);
submitCommitButton.prop("disabled",true);
unstagedContent.css("height","30px");
if (unmergedContent.is(":visible")) {
unmergedContent.css("height","30px");
@ -444,10 +447,10 @@ RED.sidebar.versionControl = (function() {
setTimeout(function() {
commitBox.css("height","175px");
},10);
stageAllButton.attr("disabled",true);
unstageAllButton.attr("disabled",true);
commitButton.attr("disabled",true);
abortMergeButton.attr("disabled",true);
stageAllButton.prop("disabled",true);
unstageAllButton.prop("disabled",true);
commitButton.prop("disabled",true);
abortMergeButton.prop("disabled",true);
commitMessage.focus();
}
commitButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">'+RED._("sidebar.project.versionControl.commit")+'</button>')
@ -457,6 +460,7 @@ RED.sidebar.versionControl = (function() {
evt.stopPropagation();
showCommitBox();
});
RED.popover.tooltip(commitButton,RED._("sidebar.project.versionControl.commitChanges"));
unstageAllButton = $('<button class="editor-button editor-button-small"><i class="fa fa-minus"></i> '+RED._("sidebar.project.versionControl.all")+'</button>')
.appendTo(bg)
.click(function(evt) {
@ -468,6 +472,7 @@ RED.sidebar.versionControl = (function() {
updateBulk(toUnstage,false);
});
RED.popover.tooltip(unstageAllButton,RED._("sidebar.project.versionControl.unstageAllChange"));
stagedChangesList = $("<ol>",{style:"position: absolute; top: 30px; bottom: 0; right:0; left:0;"}).appendTo(stagedContent);
@ -487,7 +492,7 @@ RED.sidebar.versionControl = (function() {
var commitMessage = $('<textarea placeholder='+RED._("sidebar.project.versionControl.commitPlaceholder")+'></textarea>')
.appendTo(commitBox)
.on("change keyup paste",function() {
submitCommitButton.attr('disabled',$(this).val().trim()==="");
submitCommitButton.prop('disabled',$(this).val().trim()==="");
});
var commitToolbar = $('<div class="sidebar-version-control-slide-box-toolbar button-group">').appendTo(commitBox);
@ -503,10 +508,10 @@ RED.sidebar.versionControl = (function() {
setTimeout(function() {
commitBox.hide();
},200);
stageAllButton.attr("disabled",false);
unstageAllButton.attr("disabled",false);
commitButton.attr("disabled",false);
abortMergeButton.attr("disabled",false);
stageAllButton.prop("disabled",false);
unstageAllButton.prop("disabled",false);
commitButton.prop("disabled",false);
abortMergeButton.prop("disabled",false);
})
var submitCommitButton = $('<button class="editor-button">'+RED._("sidebar.project.versionControl.commitCapital")+'</button>')
@ -549,13 +554,14 @@ RED.sidebar.versionControl = (function() {
collapsible: true
});
var bg = $('<div style="float: right"></div>').appendTo(localHistory.header);
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
bg = $('<div style="float: right"></div>').appendTo(localHistory.header);
refreshButton = $('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
refresh(true,true);
})
RED.popover.tooltip(refreshButton,RED._("sidebar.project.versionControl.refreshCommitHistory"))
var localBranchToolbar = $('<div class="sidebar-version-control-change-header" style="text-align: right;"></div>').appendTo(localHistory.content);
@ -578,6 +584,7 @@ RED.sidebar.versionControl = (function() {
},100);
}
})
RED.popover.tooltip(localBranchButton,RED._("sidebar.project.versionControl.changeLocalBranch"))
var repoStatusButton = $('<button class="editor-button editor-button-small" style="margin-left: 10px;" id="sidebar-version-control-repo-status-button">'+
'<span id="sidebar-version-control-repo-status-stats">'+
'<i class="fa fa-long-arrow-up"></i> <span id="sidebar-version-control-commits-ahead"></span> '+
@ -606,6 +613,7 @@ RED.sidebar.versionControl = (function() {
}
});
RED.popover.tooltip(repoStatusButton,RED._("sidebar.project.versionControl.manageRemoteBranch"))
localCommitList = $("<ol>",{style:"position: absolute; top: 30px; bottom: 0px; right:0; left:0;"}).appendTo(localHistory.content);
localCommitListShade = $('<div class="component-shade" style="z-Index: 3"></div>').css('top',"30px").hide().appendTo(localHistory.content);
@ -855,8 +863,8 @@ RED.sidebar.versionControl = (function() {
} else {
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.selectUpstreamBranch"));
}
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',false);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',false);
}
});
}
@ -1247,9 +1255,9 @@ RED.sidebar.versionControl = (function() {
var unstagedCount = unstagedChangesList.editableList('length');
var unmergedCount = unmergedChangesList.editableList('length');
commitButton.attr('disabled',(isMerging && unmergedCount > 0)||(!isMerging && stagedCount === 0));
stageAllButton.attr('disabled',unstagedCount === 0);
unstageAllButton.attr('disabled',stagedCount === 0);
commitButton.prop('disabled',(isMerging && unmergedCount > 0)||(!isMerging && stagedCount === 0));
stageAllButton.prop('disabled',unstagedCount === 0);
unstageAllButton.prop('disabled',stagedCount === 0);
if (stagedCount === 0) {
stagedChangesList.editableList('addItem',emptyStagedItem);
@ -1299,9 +1307,9 @@ RED.sidebar.versionControl = (function() {
if (result.branches.hasOwnProperty("remoteError") && result.branches.remoteError.code !== 'git_remote_gone') {
$("#sidebar-version-control-repo-status-auth-issue").show();
$("#sidebar-version-control-repo-status-stats").hide();
$('#sidebar-version-control-repo-branch').attr('disabled',true);
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$('#sidebar-version-control-repo-branch').prop('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',true);
$('#sidebar-version-control-repo-toolbar-message').hide();
$('#sidebar-version-control-repo-toolbar-error-message').show();
} else {
@ -1311,7 +1319,7 @@ RED.sidebar.versionControl = (function() {
$("#sidebar-version-control-repo-status-auth-issue").hide();
$("#sidebar-version-control-repo-status-stats").show();
$('#sidebar-version-control-repo-branch').attr('disabled',false);
$('#sidebar-version-control-repo-branch').prop('disabled',false);
$("#sidebar-version-control-repo-status-button").show();
if (result.branches.hasOwnProperty('remote')) {
@ -1321,8 +1329,8 @@ RED.sidebar.versionControl = (function() {
$('#sidebar-version-control-commits-behind').text("");
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.notTracking"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',true);
}
}
} else {
@ -1347,27 +1355,27 @@ RED.sidebar.versionControl = (function() {
$('#sidebar-version-control-commits-behind').text(commitsBehind);
if (isMerging) {
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.statusUnmergedChanged"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',true);
} else if (commitsAhead > 0 && commitsBehind === 0) {
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.commitsAhead", {count:commitsAhead}));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',false);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',false);
} else if (commitsAhead === 0 && commitsBehind > 0) {
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.commitsBehind",{ count: commitsBehind }));
$("#sidebar-version-control-repo-pull").attr('disabled',false);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',false);
$("#sidebar-version-control-repo-push").prop('disabled',true);
} else if (commitsAhead > 0 && commitsBehind > 0) {
$('#sidebar-version-control-repo-toolbar-message').text(
RED._("sidebar.project.versionControl.commitsAheadAndBehind1",{ count:commitsBehind })+
RED._("sidebar.project.versionControl.commitsAheadAndBehind2",{ count:commitsAhead })+
RED._("sidebar.project.versionControl.commitsAheadAndBehind3",{ count:commitsBehind }));
$("#sidebar-version-control-repo-pull").attr('disabled',false);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',false);
$("#sidebar-version-control-repo-push").prop('disabled',true);
} else if (commitsAhead === 0 && commitsBehind === 0) {
$('#sidebar-version-control-repo-toolbar-message').text(RED._("sidebar.project.versionControl.repositoryUpToDate"));
$("#sidebar-version-control-repo-pull").attr('disabled',true);
$("#sidebar-version-control-repo-push").attr('disabled',true);
$("#sidebar-version-control-repo-pull").prop('disabled',true);
$("#sidebar-version-control-repo-push").prop('disabled',true);
}
}
function show() {

View File

@ -204,7 +204,7 @@ RED.sidebar = (function() {
if (!sidebarSeparator.dragging) {
sidebarControls.hide();
}
})
});
function toggleSidebar(state) {
if (!state) {
@ -240,6 +240,7 @@ RED.sidebar = (function() {
toggleSidebar(state);
}
});
RED.popover.tooltip($("#sidebar-separator").find(".sidebar-control-right"),RED._("keyboard.toggleSidebar"),"core:toggle-sidebar");
showSidebar();
RED.sidebar.info.init();
RED.sidebar.config.init();

View File

@ -215,7 +215,8 @@ RED.debug = (function() {
refreshDebugNodeList();
filterDialog.slideDown(200);
}
})
});
RED.popover.tooltip(toolbar.find('#debug-tab-filter'),RED._('node-red:debug.sidebar.filterLog'));
toolbar.find("#debug-tab-clear").click(function(e) {
e.preventDefault();

View File

@ -123,8 +123,9 @@
"filterSelected": "selected nodes",
"filterCurrent": "current flow",
"debugNodes": "Debug nodes",
"clearLog": "clear log",
"openWindow": "open in new window"
"clearLog": "Clear log",
"filterLog": "Filter log",
"openWindow": "Open in new window"
},
"messageMenu": {
"collapseAll": "Collapse all paths",