rasti 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rasti.js +56 -116
- package/dist/rasti.min.js +1 -1
- package/es/Emitter.js +84 -105
- package/es/Model.js +94 -116
- package/es/View.js +237 -289
- package/es/index.js +0 -1
- package/lib/Emitter.js +86 -107
- package/lib/Model.js +99 -124
- package/lib/View.js +242 -298
- package/lib/index.js +8 -20
- package/package.json +36 -36
- package/src/View.js +3 -4
package/es/Model.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
6
|
-
|
|
1
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
3
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
4
|
import Emitter from './Emitter';
|
|
8
5
|
/**
|
|
9
6
|
* - Orchestrates data and business logic.
|
|
@@ -41,114 +38,95 @@ import Emitter from './Emitter';
|
|
|
41
38
|
* // Complete todo.
|
|
42
39
|
* todo.toggle(); // Completed: true
|
|
43
40
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
_this3.emit('change:' + key, _this3, attrs[key]);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return this;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Return object representation of the model to be used for JSON serialization.
|
|
142
|
-
* By default returns `this.attributes`.
|
|
143
|
-
* @return {object} Object representation of the model to be used for JSON serialization.
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Model.prototype.toJSON = function toJSON() {
|
|
148
|
-
return this.attributes;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return Model;
|
|
41
|
+
var Model = /*#__PURE__*/function (_Emitter) {
|
|
42
|
+
_inheritsLoose(Model, _Emitter);
|
|
43
|
+
function Model() {
|
|
44
|
+
var _this;
|
|
45
|
+
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
46
|
+
_this = _Emitter.call(this) || this;
|
|
47
|
+
// Call preinitialize.
|
|
48
|
+
_this.preinitialize.apply(_assertThisInitialized(_this), arguments);
|
|
49
|
+
// attributes object.
|
|
50
|
+
_this.attributes = Object.assign({}, _this.defaults || {}, attrs);
|
|
51
|
+
// Previous attributes.
|
|
52
|
+
_this.previous = {};
|
|
53
|
+
// Generate getters/setters for every attr.
|
|
54
|
+
Object.keys(_this.attributes).forEach(_this.defineAttribute.bind(_assertThisInitialized(_this)));
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* If you define a preinitialize method, it will be invoked when the Model is first created, before any instantiation logic is run for the Model.
|
|
60
|
+
* @param {object} attrs Object containing model attributes to extend `this.attributes`.
|
|
61
|
+
*/
|
|
62
|
+
var _proto = Model.prototype;
|
|
63
|
+
_proto.preinitialize = function preinitialize() {}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Generate getter/setter for the given key. In order to emit `change` events.
|
|
67
|
+
* This method is called internally by the constructor
|
|
68
|
+
* for `this.attributes`.
|
|
69
|
+
* @param {string} key Attribute key.
|
|
70
|
+
*/;
|
|
71
|
+
_proto.defineAttribute = function defineAttribute(key) {
|
|
72
|
+
var _this2 = this;
|
|
73
|
+
Object.defineProperty(this, key, {
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _this2.get(key);
|
|
76
|
+
},
|
|
77
|
+
set: function set(value) {
|
|
78
|
+
_this2.set(key, value);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get an attribute from `this.attributes`.
|
|
85
|
+
* This method is called internally by generated getters.
|
|
86
|
+
* @param {string} key Attribute key.
|
|
87
|
+
* @return {any} The attribute value.
|
|
88
|
+
*/;
|
|
89
|
+
_proto.get = function get(key) {
|
|
90
|
+
return this.attributes[key];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Set an attribute into `this.attributes`.
|
|
95
|
+
* Emit `change` and `change:attribute` if value change.
|
|
96
|
+
* Could be called in two forms, `this.set('key', value)` and
|
|
97
|
+
* `this.set({ key : value })`.
|
|
98
|
+
* This method is called internally by generated setters.
|
|
99
|
+
* @param {string} key Attribute key or object containing keys/values.
|
|
100
|
+
* @param [value] Attribute value.
|
|
101
|
+
* @return {this} This model.
|
|
102
|
+
* @emits change
|
|
103
|
+
* @emits change:attribute
|
|
104
|
+
*/;
|
|
105
|
+
_proto.set = function set(key, value) {
|
|
106
|
+
var _ref,
|
|
107
|
+
_this3 = this;
|
|
108
|
+
var attrs = typeof key === 'object' ? key : (_ref = {}, _ref[key] = value, _ref);
|
|
109
|
+
Object.keys(attrs).forEach(function (key) {
|
|
110
|
+
var changed = key in _this3.attributes && attrs[key] !== _this3.attributes[key];
|
|
111
|
+
_this3.previous[key] = _this3.attributes[key];
|
|
112
|
+
_this3.attributes[key] = attrs[key];
|
|
113
|
+
// Emit change events.
|
|
114
|
+
if (changed) {
|
|
115
|
+
_this3.emit('change', _this3, key, attrs[key]);
|
|
116
|
+
_this3.emit("change:" + key, _this3, attrs[key]);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Return object representation of the model to be used for JSON serialization.
|
|
124
|
+
* By default returns `this.attributes`.
|
|
125
|
+
* @return {object} Object representation of the model to be used for JSON serialization.
|
|
126
|
+
*/;
|
|
127
|
+
_proto.toJSON = function toJSON() {
|
|
128
|
+
return this.attributes;
|
|
129
|
+
};
|
|
130
|
+
return Model;
|
|
152
131
|
}(Emitter);
|
|
153
|
-
|
|
154
|
-
export default Model;
|
|
132
|
+
export { Model as default };
|