Merge lp:~rharding/juju-gui/new-controls into lp:juju-gui/experimental

Proposed by Richard Harding
Status: Merged
Merged at revision: 792
Proposed branch: lp:~rharding/juju-gui/new-controls
Merge into: lp:juju-gui/experimental
Prerequisite: lp:~huwshimi/juju-gui/visual-update-1
Diff against target: 672 lines (+365/-121)
12 files modified
app/index.html (+6/-4)
app/modules-debug.js (+4/-0)
app/subapps/browser/views/view.js (+43/-19)
app/templates/browser-search.handlebars (+0/-1)
app/widgets/charm-search.js (+3/-49)
app/widgets/viewmode-controls.js (+170/-0)
lib/views/browser/main.less (+0/-15)
lib/views/stylesheet.less (+20/-0)
test/index.html (+1/-0)
test/test_browser_app.js (+18/-5)
test/test_browser_search_widget.js (+1/-28)
test/test_viewmode_controls_widget.js (+99/-0)
To merge this branch: bzr merge lp:~rharding/juju-gui/new-controls
Reviewer Review Type Date Requested Status
Richard Harding Approve
Review via email: mp+172631@code.launchpad.net

Commit message

Break up the search widget to work with updated UX.

- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.

This branch does not update the minimized search to work correctly in the grand scheme of things yet.

Description of the change

Break up the search widget to work with updated UX

- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.

This branch does not update the minimized search to work correctly in the grand scheme of things yet.

https://codereview.appspot.com/10877043/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Reviewers: mp+172631_code.launchpad.net,

Message:
Please take a look.

Description:
Break up the search widget to work with updated UX

- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct
fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.

This branch does not update the minimized search to work correctly in
the grand scheme of things yet.

https://code.launchpad.net/~rharding/juju-gui/new-controls/+merge/172631

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/10877043/

Affected files:
   A [revision details]
   M app/index.html
   M app/modules-debug.js
   M app/subapps/browser/templates/browser_charm.handlebars
   M app/subapps/browser/views/view.js
   M app/templates/browser-search.handlebars
   M app/templates/charm-token.handlebars
   M app/views/topology/importexport.js
   M app/views/topology/service.js
   M app/widgets/charm-search.js
   M app/widgets/charm-token.js
   A app/widgets/viewmode-controls.js
   M lib/views/stylesheet.less
   M test/data/browsercharm.json
   M test/data/related.json
   M test/index.html
   M test/test_browser_app.js
   M test/test_browser_charm_details.js
   M test/test_browser_search_widget.js
   M test/test_charm_token.js
   M test/test_charm_token_drag_and_drop.js
   M test/test_model.js
   A test/test_viewmode_controls_widget.js

lp:~rharding/juju-gui/new-controls updated
790. By Richard Harding

update per review

791. By Richard Harding

More @event docs

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you Rick. These changes LGTM with the additional changes that I
can see are already added at Lp.

I see the discussion about widget vs view. I think widget is fine at
this time. This is clearly more than a view. The widget might be too
heavy for this use, but that may change in the next few weeks. That is
to say, We are making this late change to accommodate a late design.
Given the urgency to get the UI looking good, I think it is wiser to
review what we don't need at the end of July.

https://codereview.appspot.com/10877043/

Revision history for this message
Richard Harding (rharding) wrote :

Curtis and Jeff approved. Will wait to land as part of Huw's work since this branch depends on his.

review: Approve
lp:~rharding/juju-gui/new-controls updated
792. By Richard Harding

Update from trunk

793. By Richard Harding

remove block of css no longer needed

Revision history for this message
Richard Harding (rharding) wrote :

*** Submitted:

Break up the search widget to work with updated UX

- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct
fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.

This branch does not update the minimized search to work correctly in
the grand scheme of things yet.

R=curtis
CC=
https://codereview.appspot.com/10877043

https://codereview.appspot.com/10877043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/index.html'
--- app/index.html 2013-07-02 05:47:25 +0000
+++ app/index.html 2013-07-03 12:47:32 +0000
@@ -126,10 +126,12 @@
126 <i class="sprite juju_logo_dark" title="Juju GUI"></i>126 <i class="sprite juju_logo_dark" title="Juju GUI"></i>
127 </a>127 </a>
128 </div>128 </div>
129 <ul id="browser-nav">129 <div id="browser-nav">
130 <li><a href="">Browse</a></li>130 <ul>
131 <li><a href="">Build</a></li>131 <li><a class="fullscreen" href="">Browse</a></li>
132 </ul>132 <li><a class="sidebar" href="">Build</a></li>
133 </ul>
134 </div>
133 <div id="environment-switcher">135 <div id="environment-switcher">
134 <i class="sprite environment_icon"> </i>136 <i class="sprite environment_icon"> </i>
135 <span id="environment-name" draggable="true"></span>137 <span id="environment-name" draggable="true"></span>
136138
=== modified file 'app/modules-debug.js'
--- app/modules-debug.js 2013-06-24 22:53:39 +0000
+++ app/modules-debug.js 2013-07-03 12:47:32 +0000
@@ -153,6 +153,10 @@
153 fullpath: '/juju-ui/widgets/charm-search.js'153 fullpath: '/juju-ui/widgets/charm-search.js'
154 },154 },
155155
156 'viewmode-controls': {
157 fullpath: '/juju-ui/widgets/viewmode-controls.js'
158 },
159
156 'browser-tabview': {160 'browser-tabview': {
157 fullpath: '/juju-ui/widgets/browser-tabview.js'161 fullpath: '/juju-ui/widgets/browser-tabview.js'
158 },162 },
159163
=== modified file 'app/subapps/browser/views/view.js'
--- app/subapps/browser/views/view.js 2013-06-10 15:04:39 +0000
+++ app/subapps/browser/views/view.js 2013-07-03 12:47:32 +0000
@@ -85,13 +85,17 @@
85 */85 */
86 _bindSearchWidgetEvents: function() {86 _bindSearchWidgetEvents: function() {
87 this.addEvent(87 this.addEvent(
88 this.search.on(88 this.controls.on(
89 this.search.EVT_TOGGLE_VIEWABLE, this._toggleBrowser, this)89 this.controls.EVT_TOGGLE_VIEWABLE, this._toggleBrowser, this)
90 );90 );
9191
92 this.addEvent(92 this.addEvent(
93 this.search.on(93 this.controls.on(
94 this.search.EVT_TOGGLE_FULLSCREEN, this._toggleFullscreen, this)94 this.controls.EVT_FULLSCREEN, this._goFullscreen, this)
95 );
96 this.addEvent(
97 this.controls.on(
98 this.controls.EVT_SIDEBAR, this._goSidebar, this)
95 );99 );
96100
97 this.addEvent(101 this.addEvent(
@@ -114,6 +118,9 @@
114 fullscreenTarget: this._fullscreenTarget118 fullscreenTarget: this._fullscreenTarget
115 });119 });
116 this.search.render(node.one('.bws-header'));120 this.search.render(node.one('.bws-header'));
121
122 this.controls = new widgets.ViewmodeControls();
123 this.controls.render();
117 },124 },
118125
119 /**126 /**
@@ -153,20 +160,36 @@
153 },160 },
154161
155 /**162 /**
156 Upon clicking the fullscreen toggle icon make sure we re-route to the163 Upon clicking the browser icon make sure we re-route to the
157 new form of the UX.164 new form of the UX.
158165
159 @method _toggleFullscreen166 @method _goFullscreen
160 @param {Event} ev the click event handler on the button.167 @param {Event} ev the click event handler on the button.
161168
162 */169 */
163 _toggleFullscreen: function(ev) {170 _goFullscreen: function(ev) {
164 ev.halt();171 ev.halt();
165 var change = {172 this.fire('viewNavigate', {
166 viewmode: this.isFullscreen() ? 'sidebar' : 'fullscreen'173 change: {
167 };174 viewmode: 'fullscreen'
168 this.fire('viewNavigate', {175 }
169 change: change176 });
177 },
178
179 /**
180 Upon clicking the build icon make sure we re-route to the
181 new form of the UX.
182
183 @method _goSidebar
184 @param {Event} ev the click event handler on the button.
185
186 */
187 _goSidebar: function(ev) {
188 ev.halt();
189 this.fire('viewNavigate', {
190 change: {
191 viewmode: 'sidebar'
192 }
170 });193 });
171 },194 },
172195
@@ -263,6 +286,7 @@
263 'juju-charm-store',286 'juju-charm-store',
264 'juju-models',287 'juju-models',
265 'querystring-stringify',288 'querystring-stringify',
266 'view'289 'view',
290 'viewmode-controls'
267 ]291 ]
268});292});
269293
=== modified file 'app/templates/browser-search.handlebars'
--- app/templates/browser-search.handlebars 2013-07-02 05:47:25 +0000
+++ app/templates/browser-search.handlebars 2013-07-03 12:47:32 +0000
@@ -1,3 +1,2 @@
1<a href="" class="bws-icon"></a>1<a href="" class="bws-icon"></a>
2<a href="" class="toggle-fullscreen"></a>
3{{> bws-searchbox }}2{{> bws-searchbox }}
43
=== modified file 'app/widgets/charm-search.js'
--- app/widgets/charm-search.js 2013-07-02 05:47:25 +0000
+++ app/widgets/charm-search.js 2013-07-03 12:47:32 +0000
@@ -38,14 +38,15 @@
38 *38 *
39 * @class Search39 * @class Search
40 * @extends {Y.Widget}40 * @extends {Y.Widget}
41 * @event EV_CLEAR_SEARCH the widget requests all search reset.
42 * @event EV_SEARCH_CHANGED the widgets notifies that the search input has
43 * changed.
41 *44 *
42 */45 */
43 ns.Search = Y.Base.create('search-widget', Y.Widget, [46 ns.Search = Y.Base.create('search-widget', Y.Widget, [
44 Y.Event.EventTracker47 Y.Event.EventTracker
45 ], {48 ], {
46 EVT_CLEAR_SEARCH: 'clear_search',49 EVT_CLEAR_SEARCH: 'clear_search',
47 EVT_TOGGLE_VIEWABLE: 'toggle_viewable',
48 EVT_TOGGLE_FULLSCREEN: 'toggle_fullscreen',
49 EVT_SEARCH_CHANGED: 'search_changed',50 EVT_SEARCH_CHANGED: 'search_changed',
5051
51 TEMPLATE: templates['browser-search'],52 TEMPLATE: templates['browser-search'],
@@ -68,33 +69,6 @@
68 },69 },
6970
70 /**71 /**
71 * Expose to the outside world that we've got a request to go fullscreen.
72 *
73 * @method _toggleFullScreen
74 * @param {Event} ev the click event from the control.
75 * @private
76 *
77 */
78 _toggleFullScreen: function(ev) {
79 ev.halt();
80 this.fire(this.EVT_TOGGLE_FULLSCREEN);
81 },
82
83 /**
84 * Expose to the outside world that we've got a request to hide from
85 * sight.
86 *
87 * @method _toggleViewable
88 * @param {Event} ev the click event from the control.
89 * @private
90 *
91 */
92 _toggleViewable: function(ev) {
93 ev.halt();
94 this.fire(this.EVT_TOGGLE_VIEWABLE);
95 },
96
97 /**
98 * Set the form to active so that we can change the search appearance.72 * Set the form to active so that we can change the search appearance.
99 *73 *
100 * @method _setActive74 * @method _setActive
@@ -134,14 +108,6 @@
134 var container = this.get('boundingBox');108 var container = this.get('boundingBox');
135109
136 this.addEvent(110 this.addEvent(
137 container.one('.bws-icon').on(
138 'click', this._toggleViewable, this)
139 );
140 this.addEvent(
141 container.one('.toggle-fullscreen').on(
142 'click', this._toggleFullScreen, this)
143 );
144 this.addEvent(
145 container.one('form').on(111 container.one('form').on(
146 'submit', this._handleSubmit, this)112 'submit', this._handleSubmit, this)
147 );113 );
@@ -170,8 +136,6 @@
170 * widget only needs to clear the search input box.136 * widget only needs to clear the search input box.
171 *137 *
172 */138 */
173 this.publish(this.EVT_TOGGLE_VIEWABLE);
174 this.publish(this.EVT_TOGGLE_FULLSCREEN);
175 this.publish(this.EVT_SEARCH_CHANGED);139 this.publish(this.EVT_SEARCH_CHANGED);
176 },140 },
177141
@@ -220,16 +184,6 @@
220 value: {184 value: {
221 text: ''185 text: ''
222 }186 }
223 },
224 /**
225 @attribute fullscreeTarget
226 @default undefined
227 @type {Node}
228 @required true
229
230 */
231 fullscreenTarget: {
232 required: true
233 }187 }
234 }188 }
235 });189 });
236190
=== added file 'app/widgets/viewmode-controls.js'
--- app/widgets/viewmode-controls.js 1970-01-01 00:00:00 +0000
+++ app/widgets/viewmode-controls.js 2013-07-03 12:47:32 +0000
@@ -0,0 +1,170 @@
1/*
2This file is part of the Juju GUI, which lets users view and manage Juju
3environments within a graphical interface (https://launchpad.net/juju-gui).
4Copyright (C) 2012-2013 Canonical Ltd.
5
6This program is free software: you can redistribute it and/or modify it under
7the terms of the GNU Affero General Public License version 3, as published by
8the Free Software Foundation.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
12SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
13General Public License for more details.
14
15You should have received a copy of the GNU Affero General Public License along
16with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19'use strict';
20
21
22/**
23 * The widget used across Browser view to manage the search box and the
24 * controls for selecting which view you're in.
25 *
26 * @module widgets
27 * @submodule browser
28 *
29 */
30YUI.add('viewmode-controls', function(Y) {
31 var ns = Y.namespace('juju.widgets');
32
33
34 /**
35 * Search widget present in the Charm browser across both fullscreen and
36 * sidebar views.
37 *
38 * @class ViewmodeControls
39 * @extends {Y.Widget}
40 * @event EV_TOGGLE_VIEWABLE toggle if the browser is visible.
41 * @event EV_FULLSCREEN force fullscreen viewmode.
42 * @event EV_SIDEBAR force the sidebar viewmode.
43 *
44 */
45 ns.ViewmodeControls = Y.Base.create('viewmode-controls', Y.Widget, [
46 Y.Event.EventTracker
47 ], {
48 CONTENT_TEMPLATE: null,
49 EVT_TOGGLE_VIEWABLE: 'toggle_viewable',
50 EVT_FULLSCREEN: 'fullscreen',
51 EVT_SIDEBAR: 'sidebar',
52
53 /**
54 * Expose to the outside world that we've got a request to go fullscreen.
55 *
56 * @method _goFullscreen
57 * @param {Event} ev the click event from the control.
58 * @private
59 *
60 */
61 _goFullscreen: function(ev) {
62 ev.halt();
63 this.fire(this.EVT_FULLSCREEN);
64 },
65
66 /**
67 * Expose to the outside world that we've got a request to go sidebar.
68 *
69 * @method _goSidebar
70 * @param {Event} ev the click event from the control.
71 * @private
72 *
73 */
74 _goSidebar: function(ev) {
75 ev.halt();
76 this.fire(this.EVT_SIDEBAR);
77 },
78
79 /**
80 * Expose to the outside world that we've got a request to hide from
81 * sight.
82 *
83 * @method _toggleViewable
84 * @param {Event} ev the click event from the control.
85 * @private
86 *
87 */
88 _toggleViewable: function(ev) {
89 ev.halt();
90 this.fire(this.EVT_TOGGLE_VIEWABLE);
91 },
92
93 /**
94 * bind the UI events to the DOM making up the widget control.
95 *
96 * @method bindUI
97 *
98 */
99 bindUI: function() {
100 var container = this.get('boundingBox');
101
102 this.addEvent(
103 Y.one('#content').delegate(
104 'click',
105 this._toggleViewable,
106 '.bws-icon',
107 this
108 )
109 );
110 this.addEvent(
111 container.one('.fullscreen').on(
112 'click', this._goFullscreen, this)
113 );
114 this.addEvent(
115 container.one('.sidebar').on(
116 'click', this._goSidebar, this)
117 );
118
119 },
120
121 /**
122 * Generic initializer for the widget. Publish events we expose for
123 * outside use.
124 *
125 * @method initializer
126 * @param {Object} cfg configuration override object.
127 *
128 */
129 initializer: function(cfg) {
130 /*
131 * Fires when the "Charm Browser" link is checked. Needs to communicate
132 * with the parent view so that it can handle filters and the like. This
133 * widget only needs to clear the search input box.
134 *
135 */
136 this.publish(this.EVT_TOGGLE_VIEWABLE);
137 this.publish(this.EVT_SIDEBAR);
138 this.publish(this.EVT_FULLSCREEN);
139 }
140
141 }, {
142 ATTRS: {
143 /**
144 * @attribute boundingBox
145 * @default {Node} the .browser-nav ul
146 * @type {Node}
147 *
148 */
149 boundingBox: {
150 /**
151 * @method boundingBox.valueFn
152 * @return {Node} The already present browser-nav node.
153 *
154 */
155 valueFn: function() {
156 return Y.one('#browser-nav');
157 }
158 }
159
160 }
161 });
162
163}, '0.1.0', {
164 requires: [
165 'base',
166 'event',
167 'event-tracker',
168 'widget'
169 ]
170});
0171
=== modified file 'lib/views/browser/main.less'
--- lib/views/browser/main.less 2013-07-02 05:47:25 +0000
+++ lib/views/browser/main.less 2013-07-03 12:47:32 +0000
@@ -41,21 +41,6 @@
41 .bws-header {41 .bws-header {
42 padding: 20px;42 padding: 20px;
43 border-bottom: 1px solid @bws-border;43 border-bottom: 1px solid @bws-border;
44
45 //XXX: this can be removed once the control has been moved to the header.
46 .toggle-fullscreen {
47 position: absolute;
48 display: block;
49 right: -40px;
50 top: 20px;
51 width: 40px;
52 height: 40px;
53 background: @bws-dark url(/juju-ui/assets/images/browser_min_max.png)
54 no-repeat 0 0;
55 box-shadow: 3px 0 2px rgba(0, 0, 0, 0.1);
56 border-top-right-radius: 4px;
57 border-bottom-right-radius: 4px;
58 }
59 }44 }
60 #bws-search {45 #bws-search {
61 .search-title {46 .search-title {
6247
=== modified file 'lib/views/stylesheet.less'
--- lib/views/stylesheet.less 2013-07-03 12:38:35 +0000
+++ lib/views/stylesheet.less 2013-07-03 12:47:32 +0000
@@ -255,6 +255,26 @@
255 }255 }
256 }256 }
257 }257 }
258 #browser-nav {
259 float: left;
260
261 ul {
262 margin: 0 20px 0 0;
263 padding: 0;
264 list-style: none;
265 }
266
267 li {
268 float: left;
269
270 a {
271 display: block;
272 padding: 25px 10px 0 10px;
273 font-size: 12pt;
274 color: #9b9b9b;
275 }
276 }
277 }
258 #environment-switcher {278 #environment-switcher {
259 float: left;279 float: left;
260 height: 47px;280 height: 47px;
261281
=== modified file 'test/index.html'
--- test/index.html 2013-06-28 13:54:34 +0000
+++ test/index.html 2013-07-03 12:47:32 +0000
@@ -131,6 +131,7 @@
131131
132 <script src="test_utils.js"></script>132 <script src="test_utils.js"></script>
133 <script src="test_view_container.js"></script>133 <script src="test_view_container.js"></script>
134 <script src="test_viewmode_controls_widget.js"></script>
134 <script src="test_viewport_module.js"></script>135 <script src="test_viewport_module.js"></script>
135 <script src="test_websocket_logging.js"></script>136 <script src="test_websocket_logging.js"></script>
136 <script>137 <script>
137138
=== modified file 'test/test_browser_app.js'
--- test/test_browser_app.js 2013-06-27 17:40:21 +0000
+++ test/test_browser_app.js 2013-07-03 12:47:32 +0000
@@ -47,8 +47,15 @@
47 });47 });
4848
49 var addBrowserContainer = function(Y) {49 var addBrowserContainer = function(Y) {
50 Y.Node.create('<div id="subapp-browser">' +50 Y.Node.create([
51 '</div>').appendTo(container);51 '<div id="content">',
52 '<div id="browser-nav">',
53 '<div class="sidebar"></div>',
54 '<div class="fullscreen"</div>',
55 '</div>',
56 '<div id="subapp-browser"></div>',
57 '</div>'
58 ].join('')).appendTo(container);
52 };59 };
5360
54 afterEach(function() {61 afterEach(function() {
@@ -128,11 +135,17 @@
128 });135 });
129136
130 var addBrowserContainer = function(Y) {137 var addBrowserContainer = function(Y) {
131 Y.Node.create('<div id="subapp-browser">' +138 Y.Node.create([
132 '</div>').appendTo(container);139 '<div id="content">',
140 '<div id="browser-nav">',
141 '<div class="sidebar"></div>',
142 '<div class="fullscreen"</div>',
143 '</div>',
144 '<div id="subapp-browser"></div>',
145 '</div>'
146 ].join('')).appendTo(container);
133 };147 };
134148
135
136 it('knows that it is not fullscreen', function() {149 it('knows that it is not fullscreen', function() {
137 view = new Sidebar();150 view = new Sidebar();
138 view.isFullscreen().should.equal(false);151 view.isFullscreen().should.equal(false);
139152
=== modified file 'test/test_browser_search_widget.js'
--- test/test_browser_search_widget.js 2013-07-02 05:47:25 +0000
+++ test/test_browser_search_widget.js 2013-07-03 12:47:32 +0000
@@ -24,7 +24,7 @@
2424
25 before(function(done) {25 before(function(done) {
26 Y = YUI(GlobalConfig).use(['browser-search-widget',26 Y = YUI(GlobalConfig).use(['browser-search-widget',
27 'juju-tests-utils',27 'juju-tests-utils',
28 'event-simulate',28 'event-simulate',
29 'node-event-simulate',29 'node-event-simulate',
30 'node'], function(Y) {30 'node'], function(Y) {
@@ -56,31 +56,4 @@
56 container.one('input').get('value').should.eql('test');56 container.one('input').get('value').should.eql('test');
57 });57 });
5858
59 it('should fire a toggle fullscreen event when expand clicked', function() {
60 var search = new Search(),
61 triggered = false;
62 search.render(container);
63
64 search.on(search.EVT_TOGGLE_FULLSCREEN, function(ev) {
65 triggered = true;
66 });
67
68 var toggle = container.one('.toggle-fullscreen');
69 toggle.simulate('click');
70 triggered.should.eql(true);
71 });
72
73 it('should fire a toggle viewable event when icon clicked', function() {
74 var search = new Search(),
75 triggered = false;
76 search.render(container);
77
78 search.on(search.EVT_TOGGLE_VIEWABLE, function(ev) {
79 triggered = true;
80 });
81
82 var toggle = container.one('.bws-icon');
83 toggle.simulate('click');
84 triggered.should.eql(true);
85 });
86});59});
8760
=== added file 'test/test_viewmode_controls_widget.js'
--- test/test_viewmode_controls_widget.js 1970-01-01 00:00:00 +0000
+++ test/test_viewmode_controls_widget.js 2013-07-03 12:47:32 +0000
@@ -0,0 +1,99 @@
1/*
2This file is part of the Juju GUI, which lets users view and manage Juju
3environments within a graphical interface (https://launchpad.net/juju-gui).
4Copyright (C) 2012-2013 Canonical Ltd.
5
6This program is free software: you can redistribute it and/or modify it under
7the terms of the GNU Affero General Public License version 3, as published by
8the Free Software Foundation.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
12SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
13General Public License for more details.
14
15You should have received a copy of the GNU Affero General Public License along
16with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19'use strict';
20
21
22describe('viewmode controls widgets', function() {
23 var Y, container, controls, ViewmodeControls;
24
25 before(function(done) {
26 Y = YUI(GlobalConfig).use(['viewmode-controls',
27 'juju-tests-utils',
28 'event-simulate',
29 'node-event-simulate',
30 'node'], function(Y) {
31 ViewmodeControls = Y.juju.widgets.ViewmodeControls;
32 done();
33 });
34 });
35
36 beforeEach(function() {
37 container = Y.namespace('juju-tests.utils').makeContainer('container');
38 Y.Node.create([
39 '<div id="content">',
40 '<div id="browser-nav">',
41 '<div class="sidebar"></div>',
42 '<div class="fullscreen"</div>',
43 '</div>'
44 ].join('')).appendTo(container);
45 });
46
47 afterEach(function() {
48 container.remove(true);
49 if (controls) {
50 controls.destroy();
51 }
52 });
53
54 it('should fire a fullscreen event when expand clicked', function() {
55 var triggered = false;
56 controls = new ViewmodeControls();
57 controls.render();
58
59 controls.on(controls.EVT_FULLSCREEN, function(ev) {
60 triggered = true;
61 });
62
63 var toggle = container.one('.fullscreen');
64 toggle.simulate('click');
65 triggered.should.eql(true);
66 });
67
68 it('should fire a sidebar event when expand clicked', function() {
69 var triggered = false;
70 controls = new ViewmodeControls();
71 controls.render();
72
73 controls.on(controls.EVT_SIDEBAR, function(ev) {
74 triggered = true;
75 });
76
77 var toggle = container.one('.sidebar');
78 toggle.simulate('click');
79 triggered.should.eql(true);
80 });
81
82 it('should fire a toggle viewable event when icon clicked', function() {
83 var triggered = false;
84 controls = new ViewmodeControls();
85 controls.render();
86
87 controls.on(controls.EVT_TOGGLE_VIEWABLE, function(ev) {
88 triggered = true;
89 });
90
91 // The toggle button is a delegate, so verify it works for a node inserted
92 // after the instance of the widget is created.
93 container.one('#content').append(Y.Node.create('<a class="bws-icon"/>'));
94 var toggle = container.one('.bws-icon');
95
96 toggle.simulate('click');
97 triggered.should.eql(true);
98 });
99});

Subscribers

People subscribed via source and target branches