14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
1 |
/**
|
2 |
* Copyright 2011 Canonical Ltd. This software is licensed under the
|
|
3 |
* GNU Affero General Public License version 3 (see the file LICENSE).
|
|
4 |
*
|
|
5 |
* @module lp.app.inlinehelp
|
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
6 |
*
|
7 |
* Usage:
|
|
8 |
* lp.app.inlinehelp.init_help();
|
|
9 |
*
|
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
10 |
*/
|
11 |
YUI.add('lp.app.inlinehelp', function (Y) { |
|
12 |
||
13 |
var module = Y.namespace('lp.app.inlinehelp'); |
|
14 |
var HELP_LINK_SELECTOR = 'a[target=help]'; |
|
15 |
var HELP_CSS = 'help'; |
|
14565.3.2
by Rick harding
Add tests making sure ini_help can be run multiple times |
16 |
var CLICK_DELEGATE = false; |
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
17 |
|
18 |
/**
|
|
14565.3.16
by Rick Harding
Updates per review |
19 |
* Handle the clicking of a help link in the body.
|
20 |
* This is a delegated handler so this == the object clicked.
|
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
21 |
*
|
22 |
* @method _show_help
|
|
23 |
* @private
|
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
24 |
*/
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
25 |
module._show_help = function (e) { |
14565.3.2
by Rick harding
Add tests making sure ini_help can be run multiple times |
26 |
e.preventDefault(); |
14565.3.5
by Rick harding
Update to use the inline help on the site, need css/cleanup |
27 |
var target_link = e.currentTarget; |
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
28 |
|
29 |
// init the overlay and show it
|
|
14565.3.5
by Rick harding
Update to use the inline help on the site, need css/cleanup |
30 |
var overlay = new module.InlineHelpOverlay({ |
31 |
'contentUrl': target_link.get('href'), |
|
14565.3.6
by Rick harding
Add css for the inlinehelp widget and add to combine |
32 |
'centered': true, |
14565.3.17
by Rick Harding
Update user of inline help that bypassed the usual init methods |
33 |
'constrain': true, |
34 |
// we need our help overlay to have a higher zindex than usual
|
|
35 |
// overlays so that any help on them appear above them
|
|
36 |
'zIndex': 1050 |
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
37 |
});
|
38 |
overlay.render(); |
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
39 |
};
|
40 |
||
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
41 |
/**
|
14565.3.16
by Rick Harding
Updates per review |
42 |
* The single entry point used to bind the buttons for launching help.
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
43 |
*
|
44 |
* @method init_help
|
|
45 |
* @public
|
|
46 |
*/
|
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
47 |
module.init_help = function () { |
14565.3.16
by Rick Harding
Updates per review |
48 |
// Find the help links.
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
49 |
var links = Y.all(HELP_LINK_SELECTOR); |
50 |
||
14565.3.16
by Rick Harding
Updates per review |
51 |
// Add the help class.
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
52 |
links.addClass(HELP_CSS); |
53 |
||
14565.3.16
by Rick Harding
Updates per review |
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).
|
|
14565.3.2
by Rick harding
Add tests making sure ini_help can be run multiple times |
56 |
var body = Y.one('body'); |
57 |
if (CLICK_DELEGATE !== false) { |
|
58 |
CLICK_DELEGATE.detach(); |
|
59 |
}
|
|
60 |
CLICK_DELEGATE = body.delegate( |
|
61 |
'click', |
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
62 |
module._show_help, |
14565.3.2
by Rick harding
Add tests making sure ini_help can be run multiple times |
63 |
HELP_LINK_SELECTOR
|
64 |
);
|
|
14565.3.1
by Rick harding
Start process of adding an inline help YUI module with first passing test |
65 |
};
|
66 |
||
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
67 |
module.InlineHelpOverlay = Y.Base.create( |
68 |
'inlinehelp-overlay', |
|
69 |
Y.lazr.PrettyOverlay, |
|
70 |
[],
|
|
71 |
{
|
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
72 |
/**
|
73 |
* Generate the iframe used for displaying help content in the
|
|
74 |
* overlay.
|
|
75 |
*
|
|
76 |
* @method _getContent
|
|
77 |
* @private
|
|
78 |
*/
|
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
79 |
_getContent: function () { |
14565.3.8
by Rick harding
Ok, back to iframe...hate it |
80 |
var help_page = Y.Node.create('<iframe/>'); |
81 |
help_page.set('src', this.get('contentUrl')); |
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
82 |
|
14565.3.16
by Rick Harding
Updates per review |
83 |
// Use the overlay bodyContent as the home of the iframe.
|
14565.3.8
by Rick harding
Ok, back to iframe...hate it |
84 |
this.set('bodyContent', help_page); |
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
85 |
},
|
86 |
||
14565.3.5
by Rick harding
Update to use the inline help on the site, need css/cleanup |
87 |
initializer: function (cfg) { |
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
88 |
this._getContent(); |
14565.3.5
by Rick harding
Update to use the inline help on the site, need css/cleanup |
89 |
},
|
90 |
||
91 |
hide: function() { |
|
92 |
this.constructor.superclass.hide.call(this); |
|
93 |
this.get('boundingBox').setStyle('display', 'none'); |
|
94 |
},
|
|
95 |
||
96 |
show: function() { |
|
97 |
this.constructor.superclass.show.call(this); |
|
98 |
this.get('boundingBox').setStyle('display', 'block'); |
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
99 |
}
|
100 |
},
|
|
101 |
{
|
|
102 |
ATTRS: { |
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
103 |
/**
|
104 |
* URI of the location of the help content.
|
|
105 |
*
|
|
106 |
* This is loaded into our iFrame and should be a full page vs
|
|
107 |
* a data payload.
|
|
108 |
*
|
|
109 |
* @attribute contentUrl
|
|
110 |
* @type string
|
|
111 |
* @default ''
|
|
112 |
*/
|
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
113 |
contentUrl: { |
14565.3.4
by Rick harding
Update some tests to make sure we get the overlay built |
114 |
value: '' |
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
115 |
},
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
116 |
|
117 |
/**
|
|
118 |
* There's no multi steps so hard code the underlying overlays
|
|
14565.3.16
by Rick Harding
Updates per review |
119 |
* bar to false.
|
14565.3.10
by Rick harding
Update the tests for the iframe based inline help |
120 |
*
|
121 |
* @attribute progressbar
|
|
122 |
* @type bool
|
|
123 |
* @default false
|
|
124 |
*/
|
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
125 |
progressbar: { |
126 |
value: false |
|
14565.3.13
by Rick harding
Garden |
127 |
}
|
14565.3.3
by Rick harding
Update for doing the ajax call to collect the help content |
128 |
}
|
129 |
}
|
|
130 |
);
|
|
131 |
||
14565.3.13
by Rick harding
Garden |
132 |
}, "0.1", { "requires": ['lazr.overlay', 'io', 'log'] }); |