ember-validations-rails-ja 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92d5f3435e21d6a474dde913e705ae382dfc17bd
4
- data.tar.gz: 69211bbd9258529f3b903e5378588534f8e2018b
3
+ metadata.gz: 8bae08bbfdf8bf5f23283b5004fa0c8bbdd2376e
4
+ data.tar.gz: 583f0b56dc824bfb1826ff4ef0e979ffaf64a2ea
5
5
  SHA512:
6
- metadata.gz: 561ffdbce15d070a53af2c0960c0b734d720f457d8b4c21e4316cc6fcca0cf92cc7d16b2009d49b05daed36dc25251dc422ab72da6d9d7c67232cdb279a60107
7
- data.tar.gz: b938c5c6c1855116890ae21b08da9d6f8bf6f13fe0003cf97cd19c1a52e1f95a3ad6cbf73b79d6607810d67e248a36e1565dec4a1bad9678cfaca39fa153c737
6
+ metadata.gz: d1b01bfdc2796f086a6db476f2dd3a8fdab39f46525842378de4019914b07be061ae5708b51a12cf8ed5603ce6f908c5730bdcd13c1ae2928d7f4b3564b5cb3c
7
+ data.tar.gz: 621609d5ceadada9fcc83e1fd86beaf95e49f97c1026c52153e8db77704674e836b910de7cfc88db102356ece09cd977d439aa6da3f6aa4299fec48c329bddf9
@@ -109,17 +109,26 @@
109
109
  },
110
110
 
111
111
  TranslateableProperties: Ember.Mixin.create({
112
- init: function() {
113
- var result = this._super.apply(this, arguments);
112
+ _translationObserver: function(sender, propWithSuffix) {
113
+ var prop = propWithSuffix.replace(/Translation$/, '');
114
+ set(this, prop, I18n.t(this.get(propWithSuffix)));
115
+ },
116
+
117
+ _addTranslationObservers: function() {
114
118
  eachTranslatedAttribute(this, function(attribute, translation) {
115
- this.addObserver(attribute + 'Translation', this, function(){
116
- set(this, attribute, I18n.t(this.get(attribute + 'Translation')));
117
- });
119
+ this.addObserver(attribute + 'Translation', this, this._translationObserver);
118
120
  set(this, attribute, translation);
119
121
  });
120
-
121
- return result;
122
- }
122
+ }.on('init'),
123
+
124
+ _removeTranslationObservers: function (){
125
+ eachTranslatedAttribute(this, function(attribute) {
126
+ var propWithSuffix = attribute + 'Translation';
127
+ if(this.hasObserverFor(propWithSuffix)) {
128
+ this.removeObserver(propWithSuffix, this._translationObserver);
129
+ }
130
+ });
131
+ }.on('willDestroyElement','willClearRender')
123
132
  }),
124
133
 
125
134
  TranslateableAttributes: Ember.Mixin.create({
@@ -139,21 +148,4 @@
139
148
  return new EmHandlebars.SafeString(I18n.t(key, options.hash));
140
149
  });
141
150
 
142
- var attrHelperFunction = function(options) {
143
- var attrs, result;
144
- attrs = options.hash;
145
- result = [];
146
-
147
- Ember.keys(attrs).forEach(function(property) {
148
- var translatedValue;
149
- translatedValue = I18n.t(attrs[property]);
150
- return result.push('%@="%@"'.fmt(property, translatedValue));
151
- });
152
-
153
- return new EmHandlebars.SafeString(result.join(' '));
154
- };
155
-
156
- EmHandlebars.registerHelper('translateAttr', attrHelperFunction);
157
- EmHandlebars.registerHelper('ta', attrHelperFunction);
158
-
159
151
  }).call(undefined);
@@ -1,3 +1,3 @@
1
1
  module EmberValidationsRailsJa
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-validations-rails-ja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kozo yamagata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler