OLD | NEW |
1 /* | 1 /* |
2 This file is part of the Juju GUI, which lets users view and manage Juju | 2 This file is part of the Juju GUI, which lets users view and manage Juju |
3 environments within a graphical interface (https://launchpad.net/juju-gui). | 3 environments within a graphical interface (https://launchpad.net/juju-gui). |
4 Copyright (C) 2012-2013 Canonical Ltd. | 4 Copyright (C) 2012-2013 Canonical Ltd. |
5 | 5 |
6 This program is free software: you can redistribute it and/or modify it under | 6 This program is free software: you can redistribute it and/or modify it under |
7 the terms of the GNU Affero General Public License version 3, as published by | 7 the terms of the GNU Affero General Public License version 3, as published by |
8 the Free Software Foundation. | 8 the Free Software Foundation. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, but WITHOUT | 10 This program is distributed in the hope that it will be useful, but WITHOUT |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 @param {Model} model to associate with the viewlet in its slot. | 321 @param {Model} model to associate with the viewlet in its slot. |
322 */ | 322 */ |
323 showViewlet: function(viewletName, model) { | 323 showViewlet: function(viewletName, model) { |
324 var container = this.get('container'); | 324 var container = this.get('container'); |
325 // This method can be called directly but it is also an event handler | 325 // This method can be called directly but it is also an event handler |
326 // for clicking on the view container tab handles | 326 // for clicking on the view container tab handles |
327 if (typeof viewletName !== 'string') { | 327 if (typeof viewletName !== 'string') { |
328 viewletName = viewletName.currentTarget.getData('viewlet'); | 328 viewletName = viewletName.currentTarget.getData('viewlet'); |
329 } | 329 } |
330 var viewlet = this.viewlets[viewletName]; | 330 var viewlet = this.viewlets[viewletName]; |
| 331 if (!viewlet) { |
| 332 console.warn('Attempted to load a viewlet that does nto exist'); |
| 333 } |
331 if (!model) { | 334 if (!model) { |
332 model = this.get('model'); | 335 model = this.get('model'); |
333 } | 336 } |
334 // If the viewlet has a slot, use fillSlot to manage the slot. Otherwise, | 337 // If the viewlet has a slot, use fillSlot to manage the slot. Otherwise, |
335 // hide existing viewlets in the default slot before showing the new one. | 338 // hide existing viewlets in the default slot before showing the new one. |
336 if (viewlet.slot) { | 339 if (viewlet.slot) { |
337 this.fillSlot(viewlet, model); | 340 this.fillSlot(viewlet, model); |
338 } else { | 341 } else { |
339 Y.Object.each(this.viewlets, function(viewletToCheck) { | 342 Y.Object.each(this.viewlets, function(viewletToCheck) { |
340 if (!viewletToCheck.slot) { | 343 if (!viewletToCheck.slot) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 }); | 551 }); |
549 | 552 |
550 }, '', { | 553 }, '', { |
551 requires: [ | 554 requires: [ |
552 'juju-databinding', | 555 'juju-databinding', |
553 'view', | 556 'view', |
554 'node', | 557 'node', |
555 'base-build', | 558 'base-build', |
556 'handlebars' | 559 'handlebars' |
557 ]}); | 560 ]}); |
OLD | NEW |