rasputin 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -62,7 +62,9 @@ In your javascript asset manifest (app/assets/javascripts/application.js) add th
62
62
 
63
63
  And any of the following you want to include:
64
64
 
65
+ //= require sproutcore-datetime
65
66
  //= require sproutcore-datastore
67
+ //= require sproutcore-utils
66
68
  //= require sproutcore-statechart
67
69
  //= require sproutcore-touch
68
70
  //= require sproutcore-routing
@@ -77,6 +79,11 @@ In your stylesheet asset manifest (app/assets/stylesheets/application.css) add t
77
79
  ChangeLog
78
80
  ----------
79
81
 
82
+ 0.10.3
83
+
84
+ * update sproutcore to latest master
85
+ * update Handlebars compiler (thank's to @MichaelRykov)
86
+
80
87
  0.10.1
81
88
 
82
89
  * update with built in metamorph
@@ -1,3 +1,3 @@
1
1
  module Rasputin
2
- VERSION = "0.10.3"
2
+ VERSION = "0.10.4"
3
3
  end
@@ -2057,6 +2057,17 @@ SC.meta = function meta(obj, writable) {
2057
2057
  return ret;
2058
2058
  };
2059
2059
 
2060
+ SC.getMeta = function getMeta(obj, property) {
2061
+ var meta = SC.meta(obj, false);
2062
+ return meta[property];
2063
+ };
2064
+
2065
+ SC.setMeta = function setMeta(obj, property, value) {
2066
+ var meta = SC.meta(obj, true);
2067
+ meta[property] = value;
2068
+ return value;
2069
+ };
2070
+
2060
2071
  /**
2061
2072
  @private
2062
2073
 
@@ -3772,7 +3783,7 @@ var timerMark; // used by timers...
3772
3783
  var K = function() {};
3773
3784
  var RunLoop = function(prev) {
3774
3785
  var self;
3775
-
3786
+
3776
3787
  if (this instanceof RunLoop) {
3777
3788
  self = this;
3778
3789
  } else {
@@ -3781,7 +3792,7 @@ var RunLoop = function(prev) {
3781
3792
 
3782
3793
  self._prev = prev || null;
3783
3794
  self.onceTimers = {};
3784
-
3795
+
3785
3796
  return self;
3786
3797
  }
3787
3798
 
@@ -3979,7 +3990,7 @@ function autorun() {
3979
3990
  }
3980
3991
 
3981
3992
  /**
3982
- Begins a new RunLoop is necessary and schedules a timer to flush the
3993
+ Begins a new RunLoop if necessary and schedules a timer to flush the
3983
3994
  RunLoop at a later time. This method is used by parts of SproutCore to
3984
3995
  ensure the RunLoop always finishes. You normally do not need to call this
3985
3996
  method directly. Instead use SC.run().
@@ -4040,7 +4051,7 @@ function invokeLaterTimers() {
4040
4051
  }
4041
4052
 
4042
4053
  // schedule next timeout to fire...
4043
- if (earliest>0) setTimeout(invokeLaterTimers, earliest-(+ new Date()));
4054
+ if (earliest>0) setTimeout(invokeLaterTimers, earliest-(+ new Date()));
4044
4055
  }
4045
4056
 
4046
4057
  /**
@@ -4082,7 +4093,7 @@ SC.run.later = function(target, method) {
4082
4093
  args = slice.call(arguments);
4083
4094
  wait = args.pop();
4084
4095
  }
4085
-
4096
+
4086
4097
  expires = (+ new Date())+wait;
4087
4098
  timer = { target: target, method: method, expires: expires, args: args };
4088
4099
  guid = SC.guidFor(timer);
@@ -5598,7 +5609,7 @@ var o_create = SC.platform.create;
5598
5609
  function meta(obj, writable) {
5599
5610
  var m = SC.meta(obj, writable!==false), ret = m.mixins;
5600
5611
  if (writable===false) return ret || EMPTY_META;
5601
-
5612
+
5602
5613
  if (!ret) {
5603
5614
  ret = m.mixins = { __scproto__: obj };
5604
5615
  } else if (ret.__scproto__ !== obj) {
@@ -5612,8 +5623,8 @@ function initMixin(mixin, args) {
5612
5623
  if (args && args.length > 0) {
5613
5624
  mixin.mixins = a_map.call(args, function(x) {
5614
5625
  if (x instanceof Mixin) return x;
5615
-
5616
- // Note: Manually setup a primitive mixin here. This is the only
5626
+
5627
+ // Note: Manually setup a primitive mixin here. This is the only
5617
5628
  // way to actually get a primitive mixin. This way normal creation
5618
5629
  // of mixins will give you combined mixins...
5619
5630
  var mixin = new Mixin();
@@ -5622,7 +5633,7 @@ function initMixin(mixin, args) {
5622
5633
  });
5623
5634
  }
5624
5635
  return mixin;
5625
- }
5636
+ }
5626
5637
 
5627
5638
  var NATIVES = [Boolean, Object, Number, Array, Date, String];
5628
5639
  function isMethod(obj) {
@@ -5632,14 +5643,14 @@ function isMethod(obj) {
5632
5643
 
5633
5644
  function mergeMixins(mixins, m, descs, values, base) {
5634
5645
  var len = mixins.length, idx, mixin, guid, props, value, key, ovalue, concats;
5635
-
5646
+
5636
5647
  function removeKeys(keyName) {
5637
5648
  delete descs[keyName];
5638
5649
  delete values[keyName];
5639
5650
  }
5640
-
5651
+
5641
5652
  for(idx=0;idx<len;idx++) {
5642
-
5653
+
5643
5654
  mixin = mixins[idx];
5644
5655
  if (!mixin) throw new Error('Null value found in SC.mixin()');
5645
5656
 
@@ -5647,13 +5658,13 @@ function mergeMixins(mixins, m, descs, values, base) {
5647
5658
  guid = SC.guidFor(mixin);
5648
5659
  if (m[guid]) continue;
5649
5660
  m[guid] = mixin;
5650
- props = mixin.properties;
5661
+ props = mixin.properties;
5651
5662
  } else {
5652
5663
  props = mixin; // apply anonymous mixin properties
5653
5664
  }
5654
5665
 
5655
5666
  if (props) {
5656
-
5667
+
5657
5668
  // reset before adding each new mixin to pickup concats from previous
5658
5669
  concats = values.concatenatedProperties || base.concatenatedProperties;
5659
5670
  if (props.concatenatedProperties) {
@@ -5669,14 +5680,14 @@ function mergeMixins(mixins, m, descs, values, base) {
5669
5680
  descs[key] = value;
5670
5681
  values[key] = undefined;
5671
5682
  } else {
5672
-
5683
+
5673
5684
  // impl super if needed...
5674
5685
  if (isMethod(value)) {
5675
5686
  ovalue = (descs[key] === SC.SIMPLE_PROPERTY) && values[key];
5676
5687
  if (!ovalue) ovalue = base[key];
5677
5688
  if ('function' !== typeof ovalue) ovalue = null;
5678
5689
  if (ovalue) {
5679
- var o = value.__sc_observes__, ob = value.__sc_observesBefore__;
5690
+ var o = value.__sc_observes__, ob = value.__sc_observesBefore__;
5680
5691
  value = SC.wrap(value, ovalue);
5681
5692
  value.__sc_observes__ = o;
5682
5693
  value.__sc_observesBefore__ = ob;
@@ -5685,7 +5696,7 @@ function mergeMixins(mixins, m, descs, values, base) {
5685
5696
  var baseValue = values[key] || base[key];
5686
5697
  value = baseValue ? baseValue.concat(value) : SC.makeArray(value);
5687
5698
  }
5688
-
5699
+
5689
5700
  descs[key] = SC.SIMPLE_PROPERTY;
5690
5701
  values[key] = value;
5691
5702
  }
@@ -5695,7 +5706,7 @@ function mergeMixins(mixins, m, descs, values, base) {
5695
5706
  if (props.hasOwnProperty('toString')) {
5696
5707
  base.toString = props.toString;
5697
5708
  }
5698
-
5709
+
5699
5710
  } else if (mixin.mixins) {
5700
5711
  mergeMixins(mixin.mixins, m, descs, values, base);
5701
5712
  if (mixin._without) mixin._without.forEach(removeKeys);
@@ -5729,9 +5740,9 @@ SC._mixinBindings = function(obj, key, value, m) {
5729
5740
  function applyMixin(obj, mixins, partial) {
5730
5741
  var descs = {}, values = {}, m = SC.meta(obj), req = m.required;
5731
5742
  var key, willApply, didApply, value, desc;
5732
-
5743
+
5733
5744
  var mixinBindings = SC._mixinBindings;
5734
-
5745
+
5735
5746
  mergeMixins(mixins, meta(obj), descs, values, obj);
5736
5747
 
5737
5748
  if (MixinDelegate.detect(obj)) {
@@ -5741,25 +5752,25 @@ function applyMixin(obj, mixins, partial) {
5741
5752
 
5742
5753
  for(key in descs) {
5743
5754
  if (!descs.hasOwnProperty(key)) continue;
5744
-
5755
+
5745
5756
  desc = descs[key];
5746
5757
  value = values[key];
5747
-
5758
+
5748
5759
  if (desc === REQUIRED) {
5749
5760
  if (!(key in obj)) {
5750
5761
  if (!partial) throw new Error('Required property not defined: '+key);
5751
-
5762
+
5752
5763
  // for partial applies add to hash of required keys
5753
5764
  req = writableReq(obj);
5754
5765
  req.__sc_count__++;
5755
5766
  req[key] = true;
5756
5767
  }
5757
-
5768
+
5758
5769
  } else {
5759
-
5770
+
5760
5771
  while (desc instanceof Alias) {
5761
-
5762
- var altKey = desc.methodName;
5772
+
5773
+ var altKey = desc.methodName;
5763
5774
  if (descs[altKey]) {
5764
5775
  value = values[altKey];
5765
5776
  desc = descs[altKey];
@@ -5771,15 +5782,15 @@ function applyMixin(obj, mixins, partial) {
5771
5782
  desc = SC.SIMPLE_PROPERTY;
5772
5783
  }
5773
5784
  }
5774
-
5785
+
5775
5786
  if (willApply) willApply.call(obj, key);
5776
-
5787
+
5777
5788
  var observerPaths = getObserverPaths(value),
5778
5789
  curObserverPaths = observerPaths && getObserverPaths(obj[key]),
5779
5790
  beforeObserverPaths = getBeforeObserverPaths(value),
5780
5791
  curBeforeObserverPaths = beforeObserverPaths && getBeforeObserverPaths(obj[key]),
5781
5792
  len, idx;
5782
-
5793
+
5783
5794
  if (curObserverPaths) {
5784
5795
  len = curObserverPaths.length;
5785
5796
  for(idx=0;idx<len;idx++) {
@@ -5796,9 +5807,9 @@ function applyMixin(obj, mixins, partial) {
5796
5807
 
5797
5808
  // TODO: less hacky way for sproutcore-runtime to add bindings.
5798
5809
  value = mixinBindings(obj, key, value, m);
5799
-
5810
+
5800
5811
  defineProperty(obj, key, desc, value);
5801
-
5812
+
5802
5813
  if (observerPaths) {
5803
5814
  len = observerPaths.length;
5804
5815
  for(idx=0;idx<len;idx++) {
@@ -5812,7 +5823,7 @@ function applyMixin(obj, mixins, partial) {
5812
5823
  SC.addBeforeObserver(obj, beforeObserverPaths[idx], null, key);
5813
5824
  }
5814
5825
  }
5815
-
5826
+
5816
5827
  if (req && req[key]) {
5817
5828
  req = writableReq(obj);
5818
5829
  req.__sc_count__--;
@@ -5823,7 +5834,7 @@ function applyMixin(obj, mixins, partial) {
5823
5834
 
5824
5835
  }
5825
5836
  }
5826
-
5837
+
5827
5838
  // Make sure no required attrs remain
5828
5839
  if (!partial && req && req.__sc_count__>0) {
5829
5840
  var keys = [];
@@ -5858,16 +5869,16 @@ Mixin.create = function() {
5858
5869
  };
5859
5870
 
5860
5871
  Mixin.prototype.reopen = function() {
5861
-
5872
+
5862
5873
  var mixin, tmp;
5863
-
5874
+
5864
5875
  if (this.properties) {
5865
5876
  mixin = Mixin.create();
5866
5877
  mixin.properties = this.properties;
5867
5878
  delete this.properties;
5868
5879
  this.mixins = [mixin];
5869
5880
  }
5870
-
5881
+
5871
5882
  var len = arguments.length, mixins = this.mixins, idx;
5872
5883
 
5873
5884
  for(idx=0;idx<len;idx++) {
@@ -5880,7 +5891,7 @@ Mixin.prototype.reopen = function() {
5880
5891
  mixins.push(tmp);
5881
5892
  }
5882
5893
  }
5883
-
5894
+
5884
5895
  return this;
5885
5896
  };
5886
5897
 
@@ -5902,7 +5913,7 @@ function _detect(curMixin, targetMixin, seen) {
5902
5913
 
5903
5914
  if (seen[guid]) return false;
5904
5915
  seen[guid] = true;
5905
-
5916
+
5906
5917
  if (curMixin === targetMixin) return true;
5907
5918
  var mixins = curMixin.mixins, loc = mixins ? mixins.length : 0;
5908
5919
  while(--loc >= 0) {
@@ -5926,7 +5937,7 @@ Mixin.prototype.without = function() {
5926
5937
  function _keys(ret, mixin, seen) {
5927
5938
  if (seen[SC.guidFor(mixin)]) return;
5928
5939
  seen[SC.guidFor(mixin)] = true;
5929
-
5940
+
5930
5941
  if (mixin.properties) {
5931
5942
  var props = mixin.properties;
5932
5943
  for(var key in props) {
@@ -5969,6 +5980,24 @@ function processNames(paths, root, seen) {
5969
5980
  paths.length = idx; // cut out last item
5970
5981
  }
5971
5982
 
5983
+ function findNamespaces() {
5984
+ var Namespace = SC.Namespace, obj;
5985
+
5986
+ if (Namespace.PROCESSED) { return; }
5987
+
5988
+ for (var prop in window) {
5989
+ if (!window.hasOwnProperty(prop)) { continue; }
5990
+
5991
+ obj = window[prop];
5992
+
5993
+ if (obj instanceof Namespace) {
5994
+ obj[NAME_KEY] = prop;
5995
+ }
5996
+ }
5997
+ }
5998
+
5999
+ SC.identifyNamespaces = findNamespaces;
6000
+
5972
6001
  superClassString = function(mixin) {
5973
6002
  var superclass = mixin.superclass;
5974
6003
  if (superclass) {
@@ -5980,9 +6009,24 @@ superClassString = function(mixin) {
5980
6009
  }
5981
6010
 
5982
6011
  classToString = function() {
5983
- if (!this[NAME_KEY] && !classToString.processed) {
5984
- classToString.processed = true;
5985
- processNames([], window, {});
6012
+ var Namespace = SC.Namespace, namespace;
6013
+
6014
+ // TODO: Namespace should really be in Metal
6015
+ if (Namespace) {
6016
+ if (!this[NAME_KEY] && !classToString.processed) {
6017
+ if (!Namespace.PROCESSED) {
6018
+ findNamespaces();
6019
+ Namespace.PROCESSED = true;
6020
+ }
6021
+
6022
+ classToString.processed = true;
6023
+
6024
+ var namespaces = Namespace.NAMESPACES;
6025
+ for (var i=0, l=namespaces.length; i<l; i++) {
6026
+ namespace = namespaces[i];
6027
+ processNames([namespace.toString()], namespace, {});
6028
+ }
6029
+ }
5986
6030
  }
5987
6031
 
5988
6032
  if (this[NAME_KEY]) {
@@ -5995,8 +6039,6 @@ classToString = function() {
5995
6039
  return "(unknown mixin)";
5996
6040
  }
5997
6041
  }
5998
-
5999
- return this[NAME_KEY] || "(unknown mixin)";
6000
6042
  };
6001
6043
 
6002
6044
  Mixin.prototype.toString = classToString;
@@ -6008,7 +6050,7 @@ Mixin.mixins = function(obj) {
6008
6050
  for(key in mixins) {
6009
6051
  if (META_SKIP[key]) continue;
6010
6052
  mixin = mixins[key];
6011
-
6053
+
6012
6054
  // skip primitive mixins since these are always anonymous
6013
6055
  if (!mixin.properties) ret.push(mixins[key]);
6014
6056
  }
@@ -6037,7 +6079,7 @@ MixinDelegate = Mixin.create({
6037
6079
 
6038
6080
  willApplyProperty: SC.required(),
6039
6081
  didApplyProperty: SC.required()
6040
-
6082
+
6041
6083
  });
6042
6084
 
6043
6085
  SC.MixinDelegate = MixinDelegate;
@@ -6045,7 +6087,7 @@ SC.MixinDelegate = MixinDelegate;
6045
6087
 
6046
6088
  // ..........................................................
6047
6089
  // OBSERVER HELPER
6048
- //
6090
+ //
6049
6091
 
6050
6092
  SC.observer = function(func) {
6051
6093
  var paths = Array.prototype.slice.call(arguments, 1);
@@ -6662,13 +6704,11 @@ SC.Enumerable = SC.Mixin.create( /** @lends SC.Enumerable */ {
6662
6704
  @returns {SC.Enumerable}
6663
6705
  */
6664
6706
  uniq: function() {
6665
- var ret = [], hasDups = false;
6707
+ var ret = [];
6666
6708
  this.forEach(function(k){
6667
- if (ret.indexOf(k)<0) ret[ret.length] = k;
6668
- else hasDups = true;
6709
+ if (ret.indexOf(k)<0) ret.push(k);
6669
6710
  });
6670
-
6671
- return hasDups ? ret : this ;
6711
+ return ret;
6672
6712
  },
6673
6713
 
6674
6714
  /**
@@ -8091,7 +8131,7 @@ if (typeof console === 'undefined') {
8091
8131
 
8092
8132
  In general we recommend leaving this option set to true since it rarely
8093
8133
  conflicts with other code. If you need to turn it off however, you can
8094
- define an ENV.ENHANCE_PROTOTYPES config to disable it.
8134
+ define an ENV.EXTEND_PROTOTYPES config to disable it.
8095
8135
  */
8096
8136
  SC.EXTEND_PROTOTYPES = (SC.ENV.EXTEND_PROTOTYPES !== false);
8097
8137
 
@@ -9259,10 +9299,8 @@ SC.ArrayProxy = SC.Object.extend(SC.MutableArray, {
9259
9299
  this.arrayContentDidChange(idx, removedCnt, addedCnt);
9260
9300
  },
9261
9301
 
9262
- init: function(content) {
9302
+ init: function() {
9263
9303
  this._super();
9264
- // TODO: Why is init getting called with a parameter? --TD
9265
- if (content) set(this, 'content', content);
9266
9304
  this.contentDidChange();
9267
9305
  }
9268
9306
 
@@ -9544,7 +9582,7 @@ SC.TargetActionSupport = SC.Mixin.create({
9544
9582
  target: null,
9545
9583
  action: null,
9546
9584
 
9547
- targetObject: function() {
9585
+ targetObject: SC.computed(function() {
9548
9586
  var target = get(this, 'target');
9549
9587
 
9550
9588
  if (SC.typeOf(target) === "string") {
@@ -9552,7 +9590,7 @@ SC.TargetActionSupport = SC.Mixin.create({
9552
9590
  } else {
9553
9591
  return target;
9554
9592
  }
9555
- }.property('target').cacheable(),
9593
+ }).property('target').cacheable(),
9556
9594
 
9557
9595
  triggerAction: function() {
9558
9596
  var action = get(this, 'action'),
@@ -9591,18 +9629,38 @@ SC.TargetActionSupport = SC.Mixin.create({
9591
9629
  // ==========================================================================
9592
9630
  /**
9593
9631
  @private
9594
- A Namespace is an object usually used to contain other objects or methods
9632
+ A Namespace is an object usually used to contain other objects or methods
9595
9633
  such as an application or framework. Create a namespace anytime you want
9596
9634
  to define one of these new containers.
9597
-
9635
+
9598
9636
  # Example Usage
9599
-
9637
+
9600
9638
  MyFramework = SC.Namespace.create({
9601
9639
  VERSION: '1.0.0'
9602
9640
  });
9603
-
9641
+
9604
9642
  */
9605
- SC.Namespace = SC.Object.extend();
9643
+ SC.Namespace = SC.Object.extend({
9644
+ init: function() {
9645
+ SC.Namespace.NAMESPACES.push(this);
9646
+ SC.Namespace.PROCESSED = false;
9647
+ },
9648
+
9649
+ toString: function() {
9650
+ SC.identifyNamespaces();
9651
+ return this[SC.GUID_KEY+'_name'];
9652
+ },
9653
+
9654
+ destroy: function() {
9655
+ var namespaces = SC.Namespace.NAMESPACES;
9656
+ window[this.toString()] = undefined;
9657
+ namespaces.splice(namespaces.indexOf(this), 1);
9658
+ this._super();
9659
+ }
9660
+ });
9661
+
9662
+ SC.Namespace.NAMESPACES = [];
9663
+ SC.Namespace.PROCESSED = true;
9606
9664
 
9607
9665
  })({});
9608
9666
 
@@ -9664,10 +9722,10 @@ var EachArray = SC.Object.extend(SC.Array, {
9664
9722
  return item && get(item, this._keyName);
9665
9723
  },
9666
9724
 
9667
- length: function() {
9725
+ length: SC.computed(function() {
9668
9726
  var content = this._content;
9669
9727
  return content ? get(content, 'length') : 0;
9670
- }.property('[]').cacheable()
9728
+ }).property('[]').cacheable()
9671
9729
 
9672
9730
  });
9673
9731
 
@@ -10112,10 +10170,10 @@ SC._RenderBuffer = SC.Object.extend(
10112
10170
  init: function() {
10113
10171
  this._super();
10114
10172
 
10115
- set(this ,'elementClasses', []);
10173
+ set(this ,'elementClasses', SC.NativeArray.apply([]));
10116
10174
  set(this, 'elementAttributes', {});
10117
10175
  set(this, 'elementStyle', {});
10118
- set(this, 'childBuffers', []);
10176
+ set(this, 'childBuffers', SC.NativeArray.apply([]));
10119
10177
  set(this, 'elements', {});
10120
10178
  },
10121
10179
 
@@ -10649,7 +10707,7 @@ SC.Application = SC.Namespace.extend(
10649
10707
  // Add a new named queue for rendering views that happens
10650
10708
  // after bindings have synced.
10651
10709
  var queues = SC.run.queues;
10652
- queues.insertAt(queues.indexOf('actions')+1, 'render');
10710
+ queues.splice(jQuery.inArray('actions', queues)+1, 0, 'render');
10653
10711
 
10654
10712
  })({});
10655
10713
 
@@ -10678,11 +10736,11 @@ var getPath = SC.getPath, meta = SC.meta, fmt = SC.String.fmt;
10678
10736
  var childViewsProperty = SC.computed(function() {
10679
10737
  var childViews = get(this, '_childViews');
10680
10738
 
10681
- var ret = [];
10739
+ var ret = SC.NativeArray.apply([]);
10682
10740
 
10683
10741
  childViews.forEach(function(view) {
10684
10742
  if (view.isVirtual) {
10685
- ret = ret.concat(get(view, 'childViews'));
10743
+ ret.pushObjects(get(view, 'childViews'));
10686
10744
  } else {
10687
10745
  ret.push(view);
10688
10746
  }
@@ -10755,7 +10813,7 @@ SC.View = SC.Object.extend(
10755
10813
  @field
10756
10814
  @type Function
10757
10815
  */
10758
- template: function(key, value) {
10816
+ template: SC.computed(function(key, value) {
10759
10817
  if (value !== undefined) { return value; }
10760
10818
 
10761
10819
  var templateName = get(this, 'templateName'), template;
@@ -10770,13 +10828,13 @@ SC.View = SC.Object.extend(
10770
10828
  }
10771
10829
 
10772
10830
  if (!template) {
10773
- throw new SC.Error('%@ - Unable to find template "%@".'.fmt(this, templateName));
10831
+ throw new SC.Error(fmt('%@ - Unable to find template "%@".', this, templateName));
10774
10832
  }
10775
10833
  }
10776
10834
 
10777
10835
  // return the template, or undefined if no template was found
10778
10836
  return template || get(this, 'defaultTemplate');
10779
- }.property('templateName').cacheable(),
10837
+ }).property('templateName').cacheable(),
10780
10838
 
10781
10839
  /**
10782
10840
  The object from which templates should access properties.
@@ -10789,9 +10847,9 @@ SC.View = SC.Object.extend(
10789
10847
 
10790
10848
  @type Object
10791
10849
  */
10792
- templateContext: function(key, value) {
10850
+ templateContext: SC.computed(function(key, value) {
10793
10851
  return value !== undefined ? value : this;
10794
- }.property().cacheable(),
10852
+ }).cacheable(),
10795
10853
 
10796
10854
  /**
10797
10855
  If the view is currently inserted into the DOM of a parent view, this
@@ -10802,7 +10860,7 @@ SC.View = SC.Object.extend(
10802
10860
  */
10803
10861
  _parentView: null,
10804
10862
 
10805
- parentView: function() {
10863
+ parentView: SC.computed(function() {
10806
10864
  var parent = get(this, '_parentView');
10807
10865
 
10808
10866
  if (parent && parent.isVirtual) {
@@ -10810,7 +10868,7 @@ SC.View = SC.Object.extend(
10810
10868
  } else {
10811
10869
  return parent;
10812
10870
  }
10813
- }.property('_parentView'),
10871
+ }).property('_parentView'),
10814
10872
 
10815
10873
  /**
10816
10874
  If false, the view will appear hidden in DOM.
@@ -10830,7 +10888,7 @@ SC.View = SC.Object.extend(
10830
10888
  */
10831
10889
  childViews: childViewsProperty,
10832
10890
 
10833
- _childViews: [],
10891
+ _childViews: SC.NativeArray.apply([]),
10834
10892
 
10835
10893
  /**
10836
10894
  Return the nearest ancestor that is an instance of the provided
@@ -10884,9 +10942,9 @@ SC.View = SC.Object.extend(
10884
10942
 
10885
10943
  @returns SC.CollectionView
10886
10944
  */
10887
- collectionView: function() {
10945
+ collectionView: SC.computed(function() {
10888
10946
  return this.nearestInstanceOf(SC.CollectionView);
10889
- }.property().cacheable(),
10947
+ }).cacheable(),
10890
10948
 
10891
10949
  /**
10892
10950
  Return the nearest ancestor that is a direct child of
@@ -10894,9 +10952,9 @@ SC.View = SC.Object.extend(
10894
10952
 
10895
10953
  @returns SC.View
10896
10954
  */
10897
- itemView: function() {
10955
+ itemView: SC.computed(function() {
10898
10956
  return this.nearestChildOf(SC.CollectionView);
10899
- }.property().cacheable(),
10957
+ }).cacheable(),
10900
10958
 
10901
10959
  /**
10902
10960
  Return the nearest ancestor that has the property
@@ -10904,9 +10962,9 @@ SC.View = SC.Object.extend(
10904
10962
 
10905
10963
  @returns SC.View
10906
10964
  */
10907
- contentView: function() {
10965
+ contentView: SC.computed(function() {
10908
10966
  return this.nearestWithProperty('content');
10909
- }.property().cacheable(),
10967
+ }).cacheable(),
10910
10968
 
10911
10969
  /**
10912
10970
  @private
@@ -10914,13 +10972,13 @@ SC.View = SC.Object.extend(
10914
10972
  When the parent view changes, recursively invalidate
10915
10973
  collectionView, itemView, and contentView
10916
10974
  */
10917
- _parentViewDidChange: function() {
10975
+ _parentViewDidChange: SC.observer(function() {
10918
10976
  this.invokeRecursively(function(view) {
10919
10977
  view.propertyDidChange('collectionView');
10920
10978
  view.propertyDidChange('itemView');
10921
10979
  view.propertyDidChange('contentView');
10922
10980
  });
10923
- }.observes('_parentView'),
10981
+ }, '_parentView'),
10924
10982
 
10925
10983
  /**
10926
10984
  Called on your view when it should push strings of HTML into a
@@ -11149,7 +11207,8 @@ SC.View = SC.Object.extend(
11149
11207
  // Normalize property path to be suitable for use
11150
11208
  // as a class name. For exaple, content.foo.barBaz
11151
11209
  // becomes bar-baz.
11152
- return SC.String.dasherize(get(property.split('.'), 'lastObject'));
11210
+ parts = property.split('.');
11211
+ return SC.String.dasherize(parts[parts.length-1]);
11153
11212
 
11154
11213
  // If the value is not NO, undefined, or null, return the current
11155
11214
  // value of the property.
@@ -11173,13 +11232,13 @@ SC.View = SC.Object.extend(
11173
11232
  @field
11174
11233
  @type DOMElement
11175
11234
  */
11176
- element: function(key, value) {
11235
+ element: SC.computed(function(key, value) {
11177
11236
  if (value !== undefined) {
11178
11237
  return this.invokeForState('setElement', value);
11179
11238
  } else {
11180
11239
  return this.invokeForState('getElement');
11181
11240
  }
11182
- }.property('_parentView').cacheable(),
11241
+ }).property('_parentView').cacheable(),
11183
11242
 
11184
11243
  /**
11185
11244
  Returns a jQuery object for this view's element. If you pass in a selector
@@ -11311,9 +11370,9 @@ SC.View = SC.Object.extend(
11311
11370
  @type String
11312
11371
  @readOnly
11313
11372
  */
11314
- elementId: function(key, value) {
11373
+ elementId: SC.computed(function(key, value) {
11315
11374
  return value !== undefined ? value : SC.guidFor(this);
11316
- }.property().cacheable(),
11375
+ }).cacheable(),
11317
11376
 
11318
11377
  /**
11319
11378
  Attempts to discover the element in the parent element. The default
@@ -11363,9 +11422,7 @@ SC.View = SC.Object.extend(
11363
11422
  },
11364
11423
 
11365
11424
  /**
11366
- Called when the element of the view is created but before it is inserted
11367
- into the DOM. Override this function to do any set up that requires an
11368
- element.
11425
+ Called when a view is going to insert an element into the DOM.
11369
11426
  */
11370
11427
  willInsertElement: SC.K,
11371
11428
 
@@ -11403,10 +11460,15 @@ SC.View = SC.Object.extend(
11403
11460
 
11404
11461
  Invokes the receiver's willInsertElement() method if it exists and then
11405
11462
  invokes the same on all child views.
11463
+
11464
+ NOTE: In some cases this was called when the element existed. This no longer
11465
+ works so we let people know. We can remove this warning code later.
11406
11466
  */
11407
- _notifyWillInsertElement: function() {
11467
+ _notifyWillInsertElement: function(fromPreRender) {
11408
11468
  this.invokeRecursively(function(view) {
11469
+ if (fromPreRender) { view._willInsertElementAccessUnsupported = true; }
11409
11470
  view.willInsertElement();
11471
+ view._willInsertElementAccessUnsupported = false;
11410
11472
  });
11411
11473
  },
11412
11474
 
@@ -11462,11 +11524,11 @@ SC.View = SC.Object.extend(
11462
11524
  },
11463
11525
 
11464
11526
  /** @private (nodoc) */
11465
- _elementWillChange: function() {
11527
+ _elementWillChange: SC.beforeObserver(function() {
11466
11528
  this.forEachChildView(function(view) {
11467
11529
  SC.propertyWillChange(view, 'element');
11468
11530
  });
11469
- }.observesBefore('element'),
11531
+ }, 'element'),
11470
11532
 
11471
11533
  /**
11472
11534
  @private
@@ -11477,11 +11539,11 @@ SC.View = SC.Object.extend(
11477
11539
 
11478
11540
  @observes element
11479
11541
  */
11480
- _elementDidChange: function() {
11542
+ _elementDidChange: SC.observer(function() {
11481
11543
  this.forEachChildView(function(view) {
11482
11544
  SC.propertyDidChange(view, 'element');
11483
11545
  });
11484
- }.observes('element'),
11546
+ }, 'element'),
11485
11547
 
11486
11548
  /**
11487
11549
  Called when the parentView property has changed.
@@ -11703,15 +11765,15 @@ SC.View = SC.Object.extend(
11703
11765
  // SC.RootResponder to dispatch incoming events.
11704
11766
  SC.View.views[get(this, 'elementId')] = this;
11705
11767
 
11706
- var childViews = get(this, '_childViews').slice();
11768
+ var childViews = SC.NativeArray.apply(get(this, '_childViews').slice());
11707
11769
  // setup child views. be sure to clone the child views array first
11708
11770
  set(this, '_childViews', childViews);
11709
11771
 
11710
11772
 
11711
- this.classNameBindings = get(this, 'classNameBindings').slice();
11712
- this.classNames = get(this, 'classNames').slice();
11773
+ this.classNameBindings = SC.NativeArray.apply(get(this, 'classNameBindings').slice());
11774
+ this.classNames = SC.NativeArray.apply(get(this, 'classNames').slice());
11713
11775
 
11714
- this.set('domManager', this.domManagerClass.create({ view: this }));
11776
+ set(this, 'domManager', this.domManagerClass.create({ view: this }));
11715
11777
 
11716
11778
  meta(this)["SC.View"] = {};
11717
11779
  },
@@ -11826,6 +11888,10 @@ SC.View = SC.Object.extend(
11826
11888
  createChildView: function(view, attrs) {
11827
11889
  if (SC.View.detect(view)) {
11828
11890
  view = view.create(attrs || {}, { _parentView: this });
11891
+
11892
+ if (attrs && attrs.viewName) {
11893
+ set(this, attrs.viewName, view);
11894
+ }
11829
11895
  } else {
11830
11896
  sc_assert('must pass instance of View', view instanceof SC.View);
11831
11897
  set(view, '_parentView', this);
@@ -11839,9 +11905,9 @@ SC.View = SC.Object.extend(
11839
11905
  When the view's `isVisible` property changes, toggle the visibility
11840
11906
  element of the actual DOM element.
11841
11907
  */
11842
- _isVisibleDidChange: function() {
11908
+ _isVisibleDidChange: SC.observer(function() {
11843
11909
  this.$().toggle(get(this, 'isVisible'));
11844
- }.observes('isVisible'),
11910
+ }, 'isVisible'),
11845
11911
 
11846
11912
  clearBuffer: function() {
11847
11913
  this.invokeRecursively(function(view) {
@@ -11954,7 +12020,7 @@ SC.View.childViewsProperty = childViewsProperty;
11954
12020
  var get = SC.get, set = SC.set;
11955
12021
 
11956
12022
  SC.View.states = {
11957
- "default": {
12023
+ _default: {
11958
12024
  // appendChild is only legal while rendering the buffer.
11959
12025
  appendChild: function() {
11960
12026
  throw "You can't use appendChild outside of the rendering process";
@@ -11985,23 +12051,35 @@ SC.View.reopen({
11985
12051
  // License: Licensed under MIT license (see license.js)
11986
12052
  // ==========================================================================
11987
12053
  SC.View.states.preRender = {
11988
- parentState: SC.View.states['default'],
12054
+ parentState: SC.View.states._default,
11989
12055
 
11990
12056
  // a view leaves the preRender state once its element has been
11991
12057
  // created (createElement).
11992
12058
  insertElement: function(view, fn) {
11993
- // If we don't have an element, guarantee that it exists before
11994
- // invoking the willInsertElement event.
12059
+ view._notifyWillInsertElement(true);
11995
12060
  view.createElement();
11996
-
11997
12061
  // after createElement, the view will be in the hasElement state.
11998
-
11999
- view._notifyWillInsertElement();
12000
12062
  fn.call(view);
12001
12063
  view.transitionTo('inDOM');
12002
12064
  view._notifyDidInsertElement();
12003
12065
  },
12004
12066
 
12067
+ // This exists for the removal warning, remove later
12068
+ $: function(view){
12069
+ if (view._willInsertElementAccessUnsupported) {
12070
+ console.error("Getting element from willInsertElement is unreliable and no longer supported.");
12071
+ }
12072
+ return SC.$();
12073
+ },
12074
+
12075
+ // This exists for the removal warning, remove later
12076
+ getElement: function(view){
12077
+ if (view._willInsertElementAccessUnsupported) {
12078
+ console.error("Getting element from willInsertElement is unreliable and no longer supported.");
12079
+ }
12080
+ return null;
12081
+ },
12082
+
12005
12083
  setElement: function(view, value) {
12006
12084
  view.beginPropertyChanges();
12007
12085
  view.invalidateRecursively('element');
@@ -12029,7 +12107,7 @@ SC.View.states.preRender = {
12029
12107
  var get = SC.get, set = SC.set, meta = SC.meta;
12030
12108
 
12031
12109
  SC.View.states.inBuffer = {
12032
- parentState: SC.View.states['default'],
12110
+ parentState: SC.View.states._default,
12033
12111
 
12034
12112
  $: function(view, sel) {
12035
12113
  // if we don't have an element yet, someone calling this.$() is
@@ -12106,7 +12184,7 @@ SC.View.states.inBuffer = {
12106
12184
  var get = SC.get, set = SC.set, meta = SC.meta;
12107
12185
 
12108
12186
  SC.View.states.hasElement = {
12109
- parentState: SC.View.states['default'],
12187
+ parentState: SC.View.states._default,
12110
12188
 
12111
12189
  $: function(view, sel) {
12112
12190
  var elem = get(view, 'element');
@@ -12174,7 +12252,7 @@ SC.View.states.inDOM = {
12174
12252
  var destroyedError = "You can't call %@ on a destroyed view", fmt = SC.String.fmt;
12175
12253
 
12176
12254
  SC.View.states.destroyed = {
12177
- parentState: SC.View.states['default'],
12255
+ parentState: SC.View.states._default,
12178
12256
 
12179
12257
  appendChild: function() {
12180
12258
  throw fmt(destroyedError, ['appendChild']);
@@ -12469,13 +12547,13 @@ SC.CollectionView = SC.ContainerView.extend(
12469
12547
  return ret;
12470
12548
  },
12471
12549
 
12472
- _contentWillChange: function() {
12550
+ _contentWillChange: SC.beforeObserver(function() {
12473
12551
  var content = this.get('content');
12474
12552
 
12475
12553
  if (content) { content.removeArrayObserver(this); }
12476
12554
  var len = content ? get(content, 'length') : 0;
12477
12555
  this.arrayWillChange(content, 0, len);
12478
- }.observesBefore('content'),
12556
+ }, 'content'),
12479
12557
 
12480
12558
  /**
12481
12559
  @private
@@ -12485,7 +12563,7 @@ SC.CollectionView = SC.ContainerView.extend(
12485
12563
  asynchronously, to allow the element to be created before
12486
12564
  bindings have synchronized and vice versa.
12487
12565
  */
12488
- _contentDidChange: function() {
12566
+ _contentDidChange: SC.observer(function() {
12489
12567
  var content = get(this, 'content');
12490
12568
 
12491
12569
  if (content) {
@@ -12495,7 +12573,7 @@ SC.CollectionView = SC.ContainerView.extend(
12495
12573
 
12496
12574
  var len = content ? get(content, 'length') : 0;
12497
12575
  this.arrayDidChange(content, 0, null, len);
12498
- }.observes('content'),
12576
+ }, 'content'),
12499
12577
 
12500
12578
  destroy: function() {
12501
12579
  var content = get(this, 'content');
@@ -13307,13 +13385,13 @@ SC.TextArea = SC.View.extend(SC.TextSupport, {
13307
13385
  /**
13308
13386
  @private
13309
13387
  */
13310
- willInsertElement: function() {
13388
+ didInsertElement: function() {
13311
13389
  this._updateElementValue();
13312
13390
  },
13313
13391
 
13314
- _updateElementValue: function() {
13392
+ _updateElementValue: SC.observer(function() {
13315
13393
  this.$().val(get(this, 'value'));
13316
- }.observes('value')
13394
+ }, 'value')
13317
13395
 
13318
13396
  });
13319
13397
 
@@ -13884,7 +13962,8 @@ SC.Handlebars.bindClasses = function(context, classBindings, view, id) {
13884
13962
  // Normalize property path to be suitable for use
13885
13963
  // as a class name. For exaple, content.foo.barBaz
13886
13964
  // becomes bar-baz.
13887
- return SC.String.dasherize(get(property.split('.'), 'lastObject'));
13965
+ var parts = property.split('.');
13966
+ return SC.String.dasherize(parts[parts.length-1]);
13888
13967
 
13889
13968
  // If the value is not NO, undefined, or null, return the current
13890
13969
  // value of the property.
@@ -14104,7 +14183,7 @@ SC.Handlebars.registerHelper('view', function(path, options) {
14104
14183
  /*globals Handlebars sc_assert */
14105
14184
 
14106
14185
  // TODO: Don't require all of this module
14107
- var get = SC.get;
14186
+ var get = SC.get, fmt = SC.String.fmt;
14108
14187
 
14109
14188
  /**
14110
14189
  @name Handlebars.helpers.collection
@@ -14130,7 +14209,7 @@ SC.Handlebars.registerHelper('collection', function(path, options) {
14130
14209
  // Otherwise, just default to the standard class.
14131
14210
  var collectionClass;
14132
14211
  collectionClass = path ? SC.getPath(this, path) : SC.CollectionView;
14133
- sc_assert("%@ #collection: Could not find %@".fmt(data.view, path), !!collectionClass);
14212
+ sc_assert(fmt("%@ #collection: Could not find %@", data.view, path), !!collectionClass);
14134
14213
 
14135
14214
  var hash = options.hash, itemHash = {}, match;
14136
14215
 
@@ -14139,7 +14218,7 @@ SC.Handlebars.registerHelper('collection', function(path, options) {
14139
14218
  var collectionPrototype = get(collectionClass, 'proto');
14140
14219
  delete hash.itemViewClass;
14141
14220
  itemViewClass = itemViewPath ? SC.getPath(collectionPrototype, itemViewPath) : collectionPrototype.itemViewClass;
14142
- sc_assert("%@ #collection: Could not find %@".fmt(data.view, itemViewPath), !!itemViewClass);
14221
+ sc_assert(fmt("%@ #collection: Could not find %@", data.view, itemViewPath), !!itemViewClass);
14143
14222
 
14144
14223
  // Go through options passed to the {{collection}} helper and extract options
14145
14224
  // that configure item views instead of the collection itself.
@@ -14172,9 +14251,9 @@ SC.Handlebars.registerHelper('collection', function(path, options) {
14172
14251
  }
14173
14252
 
14174
14253
  if (hash.preserveContext) {
14175
- itemHash.templateContext = function() {
14254
+ itemHash.templateContext = SC.computed(function() {
14176
14255
  return get(this, 'content');
14177
- }.property('content');
14256
+ }).property('content');
14178
14257
  delete hash.preserveContext;
14179
14258
  }
14180
14259
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasputin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-16 00:00:00.000000000 Z
12
+ date: 2011-11-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70095015952600 !ruby/object:Gem::Requirement
16
+ requirement: &70289493748480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70095015952600
24
+ version_requirements: *70289493748480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &70095015950600 !ruby/object:Gem::Requirement
27
+ requirement: &70289493747800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70095015950600
35
+ version_requirements: *70289493747800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sprockets
38
- requirement: &70095015949940 !ruby/object:Gem::Requirement
38
+ requirement: &70289493747280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70095015949940
46
+ version_requirements: *70289493747280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jquery-rails
49
- requirement: &70095015965180 !ruby/object:Gem::Requirement
49
+ requirement: &70289493746600 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '1.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70095015965180
57
+ version_requirements: *70289493746600
58
58
  description: SproutCore 2.0 for the Rails asset pipeline.
59
59
  email:
60
60
  - paul@chavard.net
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project: rasputin
108
- rubygems_version: 1.8.11
108
+ rubygems_version: 1.8.10
109
109
  signing_key:
110
110
  specification_version: 3
111
111
  summary: SproutCore 2.0 adapter for the Rails asset pipeline.