2
* Copyright 2011 Canonical Ltd. This software is licensed under the
3
* GNU Affero General Public License version 3 (see the file LICENSE).
5
* @module lp.app.inlinehelp
8
* lp.app.inlinehelp.init_help();
11
YUI.add('lp.app.inlinehelp', function (Y) {
13
var module = Y.namespace('lp.app.inlinehelp');
14
var HELP_LINK_SELECTOR = 'a[target=help]';
15
var HELP_CSS = 'help';
16
var CLICK_DELEGATE = false;
19
* Handle the clicking of a help link in the body.
20
* This is a delegated handler so this == the object clicked.
25
module._show_help = function (e) {
27
var target_link = e.currentTarget;
29
// init the overlay and show it
30
var overlay = new module.InlineHelpOverlay({
31
'contentUrl': target_link.get('href'),
34
// we need our help overlay to have a higher zindex than usual
35
// overlays so that any help on them appear above them
42
* The single entry point used to bind the buttons for launching help.
47
module.init_help = function () {
48
// Find the help links.
49
var links = Y.all(HELP_LINK_SELECTOR);
51
// Add the help class.
52
links.addClass(HELP_CSS);
54
// Bind the click events but unbind it first in case we're re-running
55
// init more than once (say on ajax loading of new help content).
56
var body = Y.one('body');
57
if (CLICK_DELEGATE !== false) {
58
CLICK_DELEGATE.detach();
60
CLICK_DELEGATE = body.delegate(
67
module.InlineHelpOverlay = Y.Base.create(
73
* Generate the iframe used for displaying help content in the
79
_getContent: function () {
80
var help_page = Y.Node.create('<iframe/>');
81
help_page.set('src', this.get('contentUrl'));
83
// Use the overlay bodyContent as the home of the iframe.
84
this.set('bodyContent', help_page);
87
initializer: function (cfg) {
92
this.constructor.superclass.hide.call(this);
93
this.get('boundingBox').setStyle('display', 'none');
97
this.constructor.superclass.show.call(this);
98
this.get('boundingBox').setStyle('display', 'block');
104
* URI of the location of the help content.
106
* This is loaded into our iFrame and should be a full page vs
109
* @attribute contentUrl
118
* There's no multi steps so hard code the underlying overlays
121
* @attribute progressbar
132
}, "0.1", { "requires": ['lazr.overlay', 'io', 'log'] });