Skip to content

Instantly share code, notes, and snippets.

@tommck
Created July 1, 2013 16:33
Show Gist options
  • Save tommck/5902406 to your computer and use it in GitHub Desktop.
Save tommck/5902406 to your computer and use it in GitHub Desktop.
an idea on how to add context-sensitive help to WinJS apps and Durandal apps. Just adding code like this to the "default.js" code .. "app" being the WinJS.Application object
// add Help link in settings
app.onsettings = function (e) {
var commands = {};
/****** HELP ******/
// To add Context-sensitive help
// set a default help URL (/help/index.html)
var helpUrl = '/help/index.html';
// grab the currently active vm and check for a "helpUrl" property on the vm.
// Also, we may be able to walk the "router.parent" chain if we're using child routers
var router = require('plugins/router');
var vm = router.activeItem();
if (vm && vm.helpUrl) {
helpUrl = vm.helpUrl;
}
// whichever file is being used, set it up for the "Help" link like this:
commands.help = { title: "Help", href: helpUrl };
e.detail.applicationcommands = commands;
WinJS.UI.SettingsFlyout.populateSettings(e);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment