tao_on_rails 0.4.2 → 0.4.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2c52090217d1afbb2ea09d6bd75ebb4f951b331
4
- data.tar.gz: 5547a8276990108cf1a331d4576aa57838606c85
3
+ metadata.gz: d309da59b2b2ea5952c511f4702ba742820de4e1
4
+ data.tar.gz: e0bded6341243ff51aca7036ac9c80cdb6d00ccd
5
5
  SHA512:
6
- metadata.gz: 5bca2623f74409b2affd8658810d1bc12f6b4b8f4d7754d253d04e8e74597e00055c324334a5e593ad7118bbfd9727c803782c809fd3cfbdeb025a36719c3720
7
- data.tar.gz: 1048ee0cfe7851b6a83520be75df5e8a2d7c8e38cc5e9c0e493945d5e9d43008a1e45a49ba1ad670618e1ed38a51f85e8812a50f91b1dcf64e70874fdbbbc51f
6
+ metadata.gz: 372be4e55958f14e566bc3febaffcbfee13d59f5426d3bda7c924988f0d6dc413ece7e1b72505babd2cd05ced003c9e5bffb84266e1eb18b9894185ddc51e2a1
7
+ data.tar.gz: 6d714d2b9cce76a7523abe3c9d89048b6e32efe2c83e5a698d30681dfcd7efcd25c2dc77eda248465681ca8dde046cb1a47b1e9d449248597376e059818fc898
data/dist/tao.js CHANGED
@@ -27746,15 +27746,62 @@ return jQuery;
27746
27746
  return this;
27747
27747
  };
27748
27748
 
27749
- function TaoModule(opts) {
27750
- this._setOptions(opts);
27751
- this._init();
27752
- }
27749
+ TaoModule.prototype._properties = {};
27750
+
27751
+ TaoModule.get = function(propertyName, getMethod) {
27752
+ return Object.defineProperty(this.prototype, propertyName, {
27753
+ get: getMethod,
27754
+ configurable: true
27755
+ });
27756
+ };
27753
27757
 
27754
- TaoModule.prototype._setOptions = function(opts) {
27755
- return this.opts = $.extend({}, TaoModule.opts, opts);
27758
+ TaoModule.set = function(propertyName, setMethod) {
27759
+ return Object.defineProperty(this.prototype, propertyName, {
27760
+ set: setMethod,
27761
+ configurable: true
27762
+ });
27763
+ };
27764
+
27765
+ TaoModule.property = function() {
27766
+ var i, names, options;
27767
+ names = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), options = arguments[i++];
27768
+ if (options == null) {
27769
+ options = {};
27770
+ }
27771
+ if (typeof options !== 'object') {
27772
+ names.push(options);
27773
+ options = {};
27774
+ }
27775
+ return names.forEach((function(_this) {
27776
+ return function(name) {
27777
+ _this.get(name, function() {
27778
+ var ref;
27779
+ return (ref = this._properties[name]) != null ? ref : options["default"];
27780
+ });
27781
+ return _this.set(name, function(val) {
27782
+ var name1;
27783
+ if (this._properties[name] === val) {
27784
+ return;
27785
+ }
27786
+ this._properties[name] = val;
27787
+ return typeof this[name1 = "_" + name + "Changed"] === "function" ? this[name1]() : void 0;
27788
+ });
27789
+ };
27790
+ })(this));
27756
27791
  };
27757
27792
 
27793
+ function TaoModule(options) {
27794
+ var key, val;
27795
+ if (options == null) {
27796
+ options = {};
27797
+ }
27798
+ for (key in options) {
27799
+ val = options[key];
27800
+ this[key] = val;
27801
+ }
27802
+ this._init();
27803
+ }
27804
+
27758
27805
  TaoModule.prototype._init = function() {};
27759
27806
 
27760
27807
  TaoModule.prototype.on = function() {
@@ -30969,9 +31016,9 @@ var Deferred = void 0;
30969
31016
  return this._disconnect();
30970
31017
  };
30971
31018
 
30972
- _Class.prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
31019
+ _Class.prototype.attributeChangedCallback = function(attrName) {
30973
31020
  var name1;
30974
- return typeof this[name1 = "_" + (_.camelCase(attrName)) + "Changed"] === "function" ? this[name1](newValue, oldValue) : void 0;
31021
+ return typeof this[name1 = "_" + (_.camelCase(attrName)) + "Changed"] === "function" ? this[name1]() : void 0;
30975
31022
  };
30976
31023
 
30977
31024
  _Class.prototype.on = function() {
@@ -85,8 +85,8 @@ TaoComponentBasedOn = (superClass = 'HTMLElement') ->
85
85
  @connected = false
86
86
  @_disconnect()
87
87
 
88
- attributeChangedCallback: (attrName, oldValue, newValue) ->
89
- @["_#{_.camelCase attrName}Changed"]?(newValue, oldValue)
88
+ attributeChangedCallback: (attrName) ->
89
+ @["_#{_.camelCase attrName}Changed"]?()
90
90
 
91
91
  on: (args...) ->
92
92
  $(@).on args...
@@ -20,14 +20,39 @@ class TaoModule
20
20
  obj.included?.call(@)
21
21
  @
22
22
 
23
- constructor: (opts) ->
24
- @_setOptions opts
25
- @_init()
23
+ @get: (propertyName, getMethod) ->
24
+ Object.defineProperty @prototype, propertyName,
25
+ get: getMethod
26
+ configurable: true
27
+
28
+ @set: (propertyName, setMethod) ->
29
+ Object.defineProperty @prototype, propertyName,
30
+ set: setMethod
31
+ configurable: true
32
+
33
+ @property: (names..., options = {}) ->
34
+ unless typeof options == 'object'
35
+ names.push(options)
36
+ options = {}
26
37
 
27
- _setOptions: (opts) ->
28
- @opts = $.extend {}, TaoModule.opts, opts
38
+ names.forEach (name) =>
39
+ @get name, ->
40
+ @_properties[name] ? options.default
41
+ @set name, (val) ->
42
+ return if @_properties[name] == val
43
+ @_properties[name] = val
44
+ @["_#{name}Changed"]?()
45
+
46
+ constructor: (options = {}) ->
47
+ @_properties = {}
48
+
49
+ if typeof options == 'object'
50
+ @[key] = val for key, val of options
51
+
52
+ @_init()
29
53
 
30
54
  _init: ->
55
+ # to be implemented
31
56
 
32
57
  on: (args...) ->
33
58
  $(@).on args...
@@ -1,5 +1,5 @@
1
1
  module TaoOnRails
2
2
  module Rails
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siyuan Liu