webui: make Evented a part of base IPA.object

1. All framework objects to use event interface
2. Framework objects can be part of specification objects but they are not deep-cloned as the rest of specification objects - usually it would cause infinite loop. This make easier to add context as a $pre-op object without a need for $pre-op function.

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik 2014-10-10 10:21:30 +02:00
parent 741c31c2b4
commit 896d47c92f
7 changed files with 15 additions and 22 deletions

View File

@ -363,7 +363,7 @@ define(['dojo/_base/declare',
if (preop_t === 'function') { if (preop_t === 'function') {
spec = preop(spec, context); spec = preop(spec, context);
} else if (preop_t === 'object') { } else if (preop_t === 'object') {
var temp = lang.clone(preop); var temp = construct.clone(preop);
this.spec_mod.mod(spec, temp); this.spec_mod.mod(spec, temp);
this.spec_mod.del_rules(temp); this.spec_mod.del_rules(temp);
lang.mixin(spec, temp); lang.mixin(spec, temp);

View File

@ -43,18 +43,14 @@ define(['dojo/_base/declare',
/** /**
* Finds out if object is a spec object. * Finds out if object is a spec object.
* *
* Object is not a spec object when any of following applies: * Object is not a spec object when it has an `isInstanceOf` function.
* *
* - has `__fw_obj === true`
* - has `isInstanceOf` function - basically tells if it's a instance of
* dojo-based class
* @param {Object} obj * @param {Object} obj
*/ */
is_spec: function(obj) { is_spec: function(obj) {
var ret = false; var ret = false;
if (typeof obj === 'object') { if (typeof obj === 'object') {
ret = obj.__fw_obj === true || ret = typeof obj.isInstanceOf === 'function';
typeof obj.isInstanceOf === 'function';
} }
return !ret; return !ret;
}, },

View File

@ -221,7 +221,7 @@ IPA.dialog = function(spec) {
spec = spec || {}; spec = spec || {};
var that = new Evented(); var that = IPA.object();
/** @property {entity.entity} entity Entity */ /** @property {entity.entity} entity Entity */
that.entity = IPA.get_entity(spec.entity); that.entity = IPA.get_entity(spec.entity);

View File

@ -124,7 +124,7 @@ exp.facet = IPA.facet = function(spec, no_init) {
spec = spec || {}; spec = spec || {};
var that = new Evented(); var that = IPA.object();
/** /**
* Name of preferred facet container * Name of preferred facet container

View File

@ -60,7 +60,7 @@ var field = {};
field.field = IPA.field = function(spec) { field.field = IPA.field = function(spec) {
spec = spec || {}; spec = spec || {};
var that = new Evented(); var that = IPA.object();
/** /**
* Entity * Entity

View File

@ -23,7 +23,9 @@
*/ */
define([ define([
'dojo/_base/declare',
'dojo/Deferred', 'dojo/Deferred',
'dojo/Evented',
'dojo/keys', 'dojo/keys',
'dojo/topic', 'dojo/topic',
'./jquery', './jquery',
@ -38,8 +40,8 @@ define([
'./text', './text',
'./util', './util',
'exports' 'exports'
], function(Deferred, keys, topic, $, JSON, i18n, auth, datetime, ], function(declare, Deferred, Evented, keys, topic, $, JSON, i18n, auth,
metadata_provider, builder, reg, rpc, text, util, exports) { datetime, metadata_provider, builder, reg, rpc, text, util, exports) {
/** /**
* @class * @class
@ -337,19 +339,14 @@ var IPA = function () {
} }
}; };
that.obj_cls = function() {}; that.obj_cls = declare([Evented]);
that.obj_cls.prototype.__fw_obj = true;
return that; return that;
}(); }();
/** /**
* Framework objects created by factories should use this * Framework objects created by factories should use this
* instead of empty object when creating base objects. As an alternative * instead of empty object when creating base objects.
* they can just set __fw_obj property.
*
* __fw_obj property serves for telling the framework that it's instantiated
* object and not an object specification (spec).
* *
* @class * @class
*/ */

View File

@ -83,7 +83,7 @@ IPA.widget = function(spec) {
spec = spec || {}; spec = spec || {};
var that = new Evented(); var that = IPA.object();
/** /**
* Normalize tooltip * Normalize tooltip
@ -1419,7 +1419,7 @@ IPA.option_widget_base = function(spec, that) {
spec = spec || {}; spec = spec || {};
// when that is specified, this constructor behaves like a mixin // when that is specified, this constructor behaves like a mixin
that = that || new Evented(); that = that || IPA.object();
// classic properties // classic properties
that.name = spec.name; that.name = spec.name;
@ -5230,7 +5230,7 @@ IPA.widget_container = function(spec) {
spec = spec || {}; spec = spec || {};
var that = new Evented(); var that = IPA.object();
that.new_container_for_child = spec.new_container_for_child !== undefined ? that.new_container_for_child = spec.new_container_for_child !== undefined ?
spec.new_container_for_child : true; spec.new_container_for_child : true;