Use dojo/on instead of dojo/topic for facet-xxx events'

https://fedorahosted.org/freeipa/ticket/3236
This commit is contained in:
Petr Vobornik 2013-03-28 16:39:15 +01:00
parent c0007704e8
commit cc92060e35
3 changed files with 14 additions and 15 deletions

View File

@ -71,11 +71,10 @@ define(['dojo/_base/declare',
on(this.app_widget, 'logout-click', lang.hitch(this, this.on_logout));
on(this.menu, 'selected', lang.hitch(this, this.on_menu_select));
topic.subscribe('facet-show', lang.hitch(this, this.on_facet_show));
topic.subscribe('facet-change', lang.hitch(this, this.on_facet_change));
topic.subscribe('facet-change-canceled', lang.hitch(this, this.on_facet_canceled));
on(this.router, 'facet-show', lang.hitch(this, this.on_facet_show));
on(this.router, 'facet-change', lang.hitch(this, this.on_facet_change));
on(this.router, 'facet-change-canceled', lang.hitch(this, this.on_facet_canceled));
topic.subscribe('phase-error', lang.hitch(this, this.on_phase_error));
topic.subscribe('facet-state-change', lang.hitch(this, this.on_facet_state_changed));
this.app_widget.render();
},
@ -223,6 +222,7 @@ define(['dojo/_base/declare',
if (!facet.container) {
facet.container_node = this.app_widget.content_node;
on(facet, 'facet-state-change', lang.hitch(this, this.on_facet_state_changed));
}
if (this.current_facet) {
this.current_facet.hide();

View File

@ -24,7 +24,6 @@
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/topic',
'dojo/dom-construct',
'dojo/on',
'dojo/Stateful',
@ -35,7 +34,7 @@ define([
'./dialog',
'./field',
'./widget'
], function(declare, lang, topic, construct, on, Stateful, Evented,
], function(declare, lang, construct, on, Stateful, Evented,
IPA, $, navigation) {
/**
@ -101,7 +100,7 @@ IPA.facet = function(spec, no_init) {
spec.state = spec.state || {};
$.extend(spec.state, { factory: IPA.state });
var that = {};
var that = new Evented();
that.entity = IPA.get_entity(spec.entity);
@ -321,7 +320,7 @@ IPA.facet = function(spec, no_init) {
};
that._notify_state_change = function(state) {
topic.publish('facet-state-change', {
that.emit('facet-state-change', {
facet: that,
state: state
});

View File

@ -19,16 +19,16 @@
*/
define(['dojo/_base/declare',
'dojo/router',
'dojo/_base/lang',
'dojo/_base/array',
'dojo/Evented',
'dojo/io-query',
'dojo/topic',
'dojo/router',
'../entities',
'../facets',
'../ipa' //TODO: remove dependancy
],
function(declare, router, lang, array, ioquery, topic, entities, facets, IPA) {
function(declare, lang, array, Evented, ioquery, router, entities, facets, IPA) {
/**
* Class navigation
@ -38,7 +38,7 @@ define(['dojo/_base/declare',
* displayed facet. This change can be canceled in 'facet-change'
* event handler.
*/
var navigation = declare(null, {
var navigation = declare([Evented], {
/**
* Holds references to register route handlers.
@ -212,9 +212,9 @@ define(['dojo/_base/declare',
navigate_to_hash: function(hash, facet) {
this.canceled = false;
topic.publish('facet-change', { facet: facet, hash: hash });
this.emit('facet-change', { facet: facet, hash: hash });
if (this.canceled) {
topic.publish('facet-change-canceled', { facet: facet, hash : hash });
this.emit('facet-change-canceled', { facet: facet, hash : hash });
return false;
}
this.update_hash(hash, false);
@ -288,7 +288,7 @@ define(['dojo/_base/declare',
*/
show_facet: function(facet) {
topic.publish('facet-show', {
this.emit('facet-show', {
facet: facet
});
},