sproutcore 1.10.2 → 1.10.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +11 -0
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +34 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +79 -80
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +115 -22
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +54 -17
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +76 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/methods.js +18 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +14 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +42 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +41 -41
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/transitions/view_transitions_test.js +235 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/bounce_transition.js +8 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/fade_transition.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/pop_transition.js +8 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/scale_transition.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/slide_transition.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/spring_transition.js +8 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +5 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +124 -80
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +134 -0
- data/lib/sproutcore.rb +1 -1
- data/lib/sproutcore/models/manifest.rb +12 -6
- data/lib/sproutcore/rack/builder.rb +20 -12
- data/lib/sproutcore/tools.rb +3 -3
- data/lib/sproutcore/tools/build.rb +22 -22
- data/sproutcore.gemspec +2 -5
- data/vendor/sproutcore/lib/yuicompressor-2.4.8.jar +0 -0
- metadata +10 -23
- data/vendor/sproutcore/lib/yuicompressor-2.4.6.jar +0 -0
@@ -291,8 +291,21 @@ SC.View.reopen(
|
|
291
291
|
|
292
292
|
// In the case of zero duration, just adjust and call the callback.
|
293
293
|
if (options.duration === 0) {
|
294
|
-
|
295
|
-
|
294
|
+
this.adjust(hash);
|
295
|
+
this.runAnimationCallback(options, null, NO);
|
296
|
+
return this;
|
297
|
+
}
|
298
|
+
|
299
|
+
// In the case that the view is not in the standard visible state, don't animate.
|
300
|
+
if (!this.get('isVisibleInWindow')) {
|
301
|
+
//@if(debug)
|
302
|
+
SC.warn("Developer Warning: SC.View:animate() was called on %@ which is not visible in the window. The animation will be cancelled.".fmt(this));
|
303
|
+
//@endif
|
304
|
+
|
305
|
+
this.invokeNext(function () {
|
306
|
+
this.adjust(hash);
|
307
|
+
this.runAnimationCallback(options, null, true); // Cancelled
|
308
|
+
});
|
296
309
|
return this;
|
297
310
|
}
|
298
311
|
|
@@ -378,6 +391,7 @@ SC.View.reopen(
|
|
378
391
|
pendingAnimations.centerY = options;
|
379
392
|
}
|
380
393
|
}
|
394
|
+
|
381
395
|
if (!SC.none(pendingAnimations.width) && !SC.none(layout.centerX) && SC.none(pendingAnimations.centerX)) {
|
382
396
|
// Don't animate less than 2px difference b/c the margin-left value won't differ.
|
383
397
|
if (Math.abs(hash.width - this.get('layout').width) >= 2) {
|
@@ -389,8 +403,15 @@ SC.View.reopen(
|
|
389
403
|
|
390
404
|
// Always run the animation asynchronously so that the original layout is guaranteed to be applied to the DOM.
|
391
405
|
this.invokeNext('_animate');
|
406
|
+
|
407
|
+
// Route.
|
408
|
+
if (this.get('viewState') === SC.CoreView.ATTACHED_SHOWN) {
|
409
|
+
this.set('viewState', SC.CoreView.ATTACHED_SHOWN_ANIMATING);
|
410
|
+
}
|
392
411
|
} else if (!optionsDidChange) {
|
393
|
-
this.
|
412
|
+
this.invokeNext(function () {
|
413
|
+
this.runAnimationCallback(options, null, false);
|
414
|
+
});
|
394
415
|
}
|
395
416
|
|
396
417
|
return this;
|
@@ -401,14 +422,15 @@ SC.View.reopen(
|
|
401
422
|
// Check for _animateLayout. If an invokeNext call to animate *this* occurs
|
402
423
|
// while flushing the invokeNext queue *before* this method runs, an extra
|
403
424
|
// call to _animate will run. Has unit test.
|
404
|
-
|
425
|
+
var animationLayout = this._animateLayout;
|
426
|
+
if (animationLayout) {
|
405
427
|
this.willRenderAnimations();
|
406
428
|
|
407
|
-
//
|
408
|
-
this.set('layout', this._animateLayout);
|
409
|
-
|
410
|
-
// Clear the layout cache value.
|
429
|
+
// Clear the layout cache value first so that it is not present when layout changes next.
|
411
430
|
this._animateLayout = null;
|
431
|
+
|
432
|
+
// Apply the animation layout.
|
433
|
+
this.set('layout', animationLayout);
|
412
434
|
}
|
413
435
|
},
|
414
436
|
|
@@ -484,6 +506,11 @@ SC.View.reopen(
|
|
484
506
|
layout = this._animateLayout;
|
485
507
|
}
|
486
508
|
|
509
|
+
// Route.
|
510
|
+
if (this.get('viewState') === SC.CoreView.ATTACHED_SHOWN_ANIMATING) {
|
511
|
+
this.set('viewState', SC.CoreView.ATTACHED_SHOWN);
|
512
|
+
}
|
513
|
+
|
487
514
|
// Immediately remove the pending animations while calling the callbacks.
|
488
515
|
for (key in pendingAnimations) {
|
489
516
|
animation = pendingAnimations[key];
|
@@ -528,9 +555,8 @@ SC.View.reopen(
|
|
528
555
|
immediately and the animations removed from the queue.
|
529
556
|
*/
|
530
557
|
didRenderAnimations: function () {
|
531
|
-
|
532
|
-
|
533
|
-
if (!SC.platform.supportsCSSTransitions) {
|
558
|
+
// Transitions not supported or the document is not visible.
|
559
|
+
if (!SC.platform.supportsCSSTransitions || document.hidden) {
|
534
560
|
var pendingAnimations = this._pendingAnimations;
|
535
561
|
|
536
562
|
for (var key in pendingAnimations) {
|
@@ -538,6 +564,11 @@ SC.View.reopen(
|
|
538
564
|
this.runAnimationCallback(pendingAnimations[key], null, NO);
|
539
565
|
}
|
540
566
|
|
567
|
+
// Route.
|
568
|
+
if (this.get('viewState') === SC.CoreView.ATTACHED_SHOWN_ANIMATING) {
|
569
|
+
this.set('viewState', SC.CoreView.ATTACHED_SHOWN);
|
570
|
+
}
|
571
|
+
|
541
572
|
// Reset the placeholder variables now that the layout style has been applied.
|
542
573
|
this._activeAnimations = this._pendingAnimations = null;
|
543
574
|
}
|
@@ -648,9 +679,9 @@ SC.View.reopen(
|
|
648
679
|
if (method) {
|
649
680
|
// We're using invokeNext so we don't trigger any layout changes from
|
650
681
|
// the callback until the current layout is updated.
|
651
|
-
this.invokeNext(function () {
|
682
|
+
// this.invokeNext(function () {
|
652
683
|
method.call(target, { event: evt, view: this, isCancelled: cancelled });
|
653
|
-
}, this);
|
684
|
+
// }, this);
|
654
685
|
|
655
686
|
// Always clear the method from the hash to prevent it being called
|
656
687
|
// multiple times for animations in the group.
|
@@ -679,14 +710,19 @@ SC.View.reopen(
|
|
679
710
|
// Remove the animation style without triggering a layout change.
|
680
711
|
this.removeAnimationFromLayout(propertyName, YES);
|
681
712
|
|
682
|
-
// Run the callback.
|
683
|
-
this.runAnimationCallback(animation, evt, NO);
|
684
|
-
|
685
713
|
// Clean up the internal hash.
|
686
714
|
this._activeAnimationsLength -= 1;
|
687
715
|
if (this._activeAnimationsLength === 0) {
|
716
|
+
// Route.
|
717
|
+
if (this.get('viewState') === SC.CoreView.ATTACHED_SHOWN_ANIMATING) {
|
718
|
+
this.set('viewState', SC.CoreView.ATTACHED_SHOWN);
|
719
|
+
}
|
720
|
+
|
688
721
|
this._activeAnimations = this._prevLayout = null;
|
689
722
|
}
|
723
|
+
|
724
|
+
// Run the callback.
|
725
|
+
this.runAnimationCallback(animation, evt, NO);
|
690
726
|
}
|
691
727
|
},
|
692
728
|
|
@@ -697,7 +733,8 @@ SC.View.reopen(
|
|
697
733
|
pending and active animations.
|
698
734
|
*/
|
699
735
|
willRenderAnimations: function () {
|
700
|
-
if
|
736
|
+
// Only apply the style if supported by the platform and the document is visible.
|
737
|
+
if (SC.platform.supportsCSSTransitions && !document.hidden) {
|
701
738
|
var pendingAnimations = this._pendingAnimations;
|
702
739
|
|
703
740
|
if (pendingAnimations) {
|
@@ -8,6 +8,7 @@ SC.LOG_VIEW_STATES_STYLE = {
|
|
8
8
|
0x0300: 'color: #67b7db; font-style: italic;', // UNATTACHED
|
9
9
|
0x0301: 'color: #67b7db; font-style: italic;', // UNATTACHED_BY_PARENT
|
10
10
|
0x03C0: 'color: #23abf5; font-style: italic;', // ATTACHED_SHOWN
|
11
|
+
0x03C3: 'color: #1fe7a8; font-style: italic;', // ATTACHED_SHOWN_ANIMATING
|
11
12
|
0x03A0: 'color: #67b7db; font-style: italic;', // ATTACHED_HIDDEN
|
12
13
|
0x03A1: 'color: #67b7db; font-style: italic;', // ATTACHED_HIDDEN_BY_PARENT
|
13
14
|
0x03C1: 'color: #b800db; font-style: italic;', // ATTACHED_BUILDING_IN
|
@@ -104,6 +105,15 @@ SC.CoreView.mixin(
|
|
104
105
|
*/
|
105
106
|
ATTACHED_SHOWN: 0x03C0, // 960
|
106
107
|
|
108
|
+
/**
|
109
|
+
The view has been created, rendered and attached, is visible in the
|
110
|
+
display and is being animated via a call to `animate()`.
|
111
|
+
|
112
|
+
@static
|
113
|
+
@constant
|
114
|
+
*/
|
115
|
+
ATTACHED_SHOWN_ANIMATING: 0x03C3, // 963
|
116
|
+
|
107
117
|
/**
|
108
118
|
The view has been created, rendered and attached, but is not visible in the
|
109
119
|
display.
|
@@ -235,6 +245,7 @@ SC.CoreView.reopen(
|
|
235
245
|
* SC.CoreView.UNATTACHED_BY_PARENT
|
236
246
|
* SC.CoreView.ATTACHED_SHOWING
|
237
247
|
* SC.CoreView.ATTACHED_SHOWN
|
248
|
+
* SC.CoreView.ATTACHED_SHOWN_ANIMATING
|
238
249
|
* SC.CoreView.ATTACHED_HIDING
|
239
250
|
* SC.CoreView.ATTACHED_HIDDEN
|
240
251
|
* SC.CoreView.ATTACHED_HIDDEN_BY_PARENT
|
@@ -493,6 +504,7 @@ SC.CoreView.reopen(
|
|
493
504
|
|
494
505
|
// Improper states that have no effect, but should be discouraged.
|
495
506
|
case SC.CoreView.ATTACHED_SHOWN:
|
507
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
496
508
|
//@if(debug)
|
497
509
|
// This should be avoided, because moving the view layer without explicitly removing it first is a dangerous practice.
|
498
510
|
SC.warn("Developer Warning: You can not attach the view, %@, to a new node without properly detaching it first.".fmt(this));
|
@@ -530,6 +542,7 @@ SC.CoreView.reopen(
|
|
530
542
|
case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:
|
531
543
|
case SC.CoreView.ATTACHED_SHOWING:
|
532
544
|
case SC.CoreView.ATTACHED_SHOWN:
|
545
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
533
546
|
case SC.CoreView.UNATTACHED_BY_PARENT:
|
534
547
|
case SC.CoreView.ATTACHED_BUILDING_OUT:
|
535
548
|
break;
|
@@ -582,6 +595,11 @@ SC.CoreView.reopen(
|
|
582
595
|
immediately = true;
|
583
596
|
break;
|
584
597
|
|
598
|
+
// Near normal case: Attached visible view that is in the middle of an animation.
|
599
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
600
|
+
this.cancelAnimation();
|
601
|
+
break;
|
602
|
+
|
585
603
|
// Near normal case: Attached showing view. We cancel the incoming animation
|
586
604
|
// rather than swapping to a build out (difficult to get right, because we lose track of the correct final layout).
|
587
605
|
case SC.CoreView.ATTACHED_SHOWING:
|
@@ -718,10 +736,17 @@ SC.CoreView.reopen(
|
|
718
736
|
return true;
|
719
737
|
case SC.CoreView.ATTACHED_BUILDING_IN:
|
720
738
|
case SC.CoreView.ATTACHED_SHOWING:
|
721
|
-
|
722
|
-
|
723
|
-
|
739
|
+
// Cancel the animation and revert to hidden.
|
740
|
+
this.cancelAnimation();
|
741
|
+
this._teardownTransition();
|
742
|
+
this._gotoAttachedHiddenState();
|
724
743
|
break;
|
744
|
+
|
745
|
+
// Near normal case: Attached visible view that is in the middle of an animation.
|
746
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
747
|
+
this.cancelAnimation();
|
748
|
+
break;
|
749
|
+
|
725
750
|
case SC.CoreView.ATTACHED_SHOWN:
|
726
751
|
break;
|
727
752
|
default:
|
@@ -799,6 +824,7 @@ SC.CoreView.reopen(
|
|
799
824
|
switch (state) {
|
800
825
|
case SC.CoreView.ATTACHED_SHOWING: // FAST PATHS!
|
801
826
|
case SC.CoreView.ATTACHED_SHOWN:
|
827
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
802
828
|
case SC.CoreView.ATTACHED_HIDING:
|
803
829
|
case SC.CoreView.ATTACHED_HIDDEN:
|
804
830
|
case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:
|
@@ -877,9 +903,10 @@ SC.CoreView.reopen(
|
|
877
903
|
break;
|
878
904
|
|
879
905
|
case SC.CoreView.ATTACHED_HIDING:
|
880
|
-
|
881
|
-
|
882
|
-
|
906
|
+
// Cancel the animation and revert to shown.
|
907
|
+
this.cancelAnimation();
|
908
|
+
this._teardownTransition();
|
909
|
+
this._gotoAttachedShownState();
|
883
910
|
break;
|
884
911
|
|
885
912
|
// Special case: Layer exists but is not attached. Queue an update to the visibility style.
|
@@ -892,6 +919,7 @@ SC.CoreView.reopen(
|
|
892
919
|
// Invalid states that have no effect.
|
893
920
|
case SC.CoreView.UNRENDERED: // FAST PATH!
|
894
921
|
case SC.CoreView.ATTACHED_SHOWN: // FAST PATH!
|
922
|
+
case SC.CoreView.ATTACHED_SHOWN_ANIMATING:
|
895
923
|
case SC.CoreView.ATTACHED_SHOWING: // FAST PATH!
|
896
924
|
case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT: // FAST PATH!
|
897
925
|
case SC.CoreView.ATTACHED_BUILDING_IN: // FAST PATH!
|
@@ -1173,7 +1201,7 @@ SC.CoreView.reopen(
|
|
1173
1201
|
|
1174
1202
|
/** @private Clear building in transition. */
|
1175
1203
|
_cancelTransition: function () {
|
1176
|
-
// Cancel conflicting transitions.
|
1204
|
+
// Cancel conflicting transitions. This causes the animation callback to fire.
|
1177
1205
|
this.cancelAnimation();
|
1178
1206
|
// this._teardownTransition();
|
1179
1207
|
},
|
@@ -1603,34 +1631,43 @@ SC.CoreView.reopen(
|
|
1603
1631
|
|
1604
1632
|
/** @private */
|
1605
1633
|
_teardownTransition: function () {
|
1606
|
-
//
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1634
|
+
// Some transition plugins will send a didTransitionIn/Out event even
|
1635
|
+
// if the transition was cancelled. In either case, the transition can't
|
1636
|
+
// be cleaned up multiple times.
|
1637
|
+
if (this._preTransitionLayout) {
|
1638
|
+
// Reset the layout to its original value.
|
1639
|
+
this.set('layout', this._preTransitionLayout);
|
1640
|
+
|
1641
|
+
// Clean up.
|
1642
|
+
this._preTransitionLayout = null;
|
1643
|
+
this._preTransitionFrame = null;
|
1644
|
+
}
|
1612
1645
|
},
|
1613
1646
|
|
1614
1647
|
/** @private Attempts to run a transition hide, ensuring any incoming transitions are stopped in place. */
|
1615
1648
|
_transitionHide: function () {
|
1616
|
-
var
|
1617
|
-
|
1618
|
-
options = this.get('transitionHideOptions') || {},
|
1619
|
-
inPlace = false;
|
1649
|
+
var transitionHide = this.get('transitionHide'),
|
1650
|
+
options = this.get('transitionHideOptions') || {};
|
1620
1651
|
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
this.cancelAnimation(SC.LayoutState.CURRENT);
|
1625
|
-
inPlace = true;
|
1626
|
-
break;
|
1627
|
-
default:
|
1628
|
-
this._setupTransition();
|
1652
|
+
//@if (debug)
|
1653
|
+
if (SC.LOG_VIEW_STATES) {
|
1654
|
+
SC.Logger.log('%c%@ — _transitionHide()'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
|
1629
1655
|
}
|
1656
|
+
//@endif
|
1657
|
+
|
1658
|
+
// switch (state) {
|
1659
|
+
// case SC.CoreView.ATTACHED_SHOWING:
|
1660
|
+
// case SC.CoreView.ATTACHED_BUILDING_IN:
|
1661
|
+
// this.cancelAnimation(SC.LayoutState.CURRENT);
|
1662
|
+
// inPlace = true;
|
1663
|
+
// break;
|
1664
|
+
// default:
|
1665
|
+
this._setupTransition();
|
1666
|
+
// }
|
1630
1667
|
|
1631
1668
|
// Set up the hiding transition.
|
1632
1669
|
if (transitionHide.setup) {
|
1633
|
-
transitionHide.setup(this, options
|
1670
|
+
transitionHide.setup(this, options);
|
1634
1671
|
}
|
1635
1672
|
|
1636
1673
|
// Execute the hiding transition.
|
@@ -1686,17 +1723,21 @@ SC.CoreView.reopen(
|
|
1686
1723
|
|
1687
1724
|
/** @private Attempts to run a transition show, ensuring any hiding transitions are stopped in place. */
|
1688
1725
|
_transitionShow: function () {
|
1689
|
-
var
|
1690
|
-
transitionShow = this.get('transitionShow'),
|
1726
|
+
var transitionShow = this.get('transitionShow'),
|
1691
1727
|
options = this.get('transitionShowOptions') || {},
|
1692
1728
|
inPlace = false;
|
1693
1729
|
|
1694
|
-
if (
|
1695
|
-
|
1696
|
-
|
1697
|
-
} else {
|
1698
|
-
this._setupTransition();
|
1730
|
+
//@if (debug)
|
1731
|
+
if (SC.LOG_VIEW_STATES) {
|
1732
|
+
SC.Logger.log('%c%@ — _transitionShow()'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
|
1699
1733
|
}
|
1734
|
+
//@endif
|
1735
|
+
// if (state === SC.CoreView.ATTACHED_HIDING) {
|
1736
|
+
// this.cancelAnimation(SC.LayoutState.CURRENT);
|
1737
|
+
// inPlace = true;
|
1738
|
+
// } else {
|
1739
|
+
this._setupTransition();
|
1740
|
+
// }
|
1700
1741
|
|
1701
1742
|
// Set up the showing transition.
|
1702
1743
|
if (transitionShow.setup) {
|
@@ -1719,11 +1760,12 @@ SC.CoreView.reopen(
|
|
1719
1760
|
// Route.
|
1720
1761
|
var transitionIn = this.get('transitionIn');
|
1721
1762
|
if (transitionIn) {
|
1763
|
+
this._gotoAttachedBuildingInState();
|
1764
|
+
|
1722
1765
|
// this.invokeNext(function () {
|
1723
1766
|
this._transitionIn();
|
1724
1767
|
// });
|
1725
1768
|
|
1726
|
-
this._gotoAttachedBuildingInState();
|
1727
1769
|
} else {
|
1728
1770
|
this._gotoAttachedShownState();
|
1729
1771
|
}
|
@@ -19,10 +19,10 @@ module("SC.SelectView",{
|
|
19
19
|
//pane
|
20
20
|
pane = SC.MainPane.create({
|
21
21
|
objs : ["Around","The","World"],
|
22
|
-
objs2 : [{ title: "Around", pos: 3},
|
23
|
-
{ title: "The", pos: 1},
|
24
|
-
{ title: "World", pos: 2 },
|
25
|
-
{ title: "Again", pos: 4}],
|
22
|
+
objs2 : [{ title: "Around", icon: 'around-icon', pos: 3},
|
23
|
+
{ title: "The", icon: 'the-icon', pos: 1},
|
24
|
+
{ title: "World", icon: 'world-icon', pos: 2 },
|
25
|
+
{ title: "Again", icon: 'again-icon', pos: 4}],
|
26
26
|
selectedValue: "World",
|
27
27
|
isDue: YES,
|
28
28
|
childViews: [
|
@@ -51,6 +51,7 @@ module("SC.SelectView",{
|
|
51
51
|
valueBinding: '*owner.selectedValue',
|
52
52
|
itemValueKey: 'title',
|
53
53
|
itemTitleKey: 'title',
|
54
|
+
itemIconKey: 'icon',
|
54
55
|
itemSortKey: 'pos'
|
55
56
|
}),
|
56
57
|
|
@@ -81,7 +82,7 @@ module("SC.SelectView",{
|
|
81
82
|
|
82
83
|
//teardown
|
83
84
|
teardown: function() {
|
84
|
-
pane.
|
85
|
+
pane.destroy() ;
|
85
86
|
pane = view = null ;
|
86
87
|
}
|
87
88
|
});
|
@@ -156,3 +157,15 @@ test("The content of the popup should be recalculated correctly when the list of
|
|
156
157
|
equals(view4.get("_itemList")[0].title, "Moving", "The list should start with new item Moving");
|
157
158
|
equals(view3.get("_itemList")[2].title, "Again", "The list should have on the 3rd position the title Again");
|
158
159
|
});
|
160
|
+
|
161
|
+
test("Setting the value of the view should change the title & icon properties", function () {
|
162
|
+
equals(view4.get('value'), "World", "The view gets a default value by sort");
|
163
|
+
equals(view4.get('title'), "World", "The view's title should originally be");
|
164
|
+
equals(view4.get('icon'), "world-icon", "The view's icon should originally be");
|
165
|
+
SC.run(function () {
|
166
|
+
view4.set('value', 'Around');
|
167
|
+
});
|
168
|
+
|
169
|
+
equals(view4.get('title'), "Around", "The view's title should now be");
|
170
|
+
equals(view4.get('icon'), "around-icon", "The view's icon should now be");
|
171
|
+
});
|
@@ -25,6 +25,9 @@ sc_require('views/list');
|
|
25
25
|
SC.GridView = SC.ListView.extend(
|
26
26
|
/** @scope SC.GridView.prototype */ {
|
27
27
|
|
28
|
+
/** @private */
|
29
|
+
_lastFrameWidth: null,
|
30
|
+
|
28
31
|
/**
|
29
32
|
@type Array
|
30
33
|
@default ['sc-grid-view']
|
@@ -110,6 +113,12 @@ SC.GridView = SC.ListView.extend(
|
|
110
113
|
row = Math.floor(contentIndex / itemsPerRow),
|
111
114
|
col = contentIndex - (itemsPerRow * row);
|
112
115
|
|
116
|
+
// If the frame is not ready, then just return an empty layout.
|
117
|
+
// Otherwise, NaN will be entered into layout values.
|
118
|
+
if (frameWidth === 0 || itemsPerRow === 0) {
|
119
|
+
return {};
|
120
|
+
}
|
121
|
+
|
113
122
|
return {
|
114
123
|
left: col * columnWidth,
|
115
124
|
top: row * rowHeight,
|
@@ -127,15 +136,15 @@ SC.GridView = SC.ListView.extend(
|
|
127
136
|
count = (content) ? content.get('length') : 0,
|
128
137
|
rowHeight = this.get('rowHeight') || 48,
|
129
138
|
itemsPerRow = this.get('itemsPerRow'),
|
130
|
-
|
139
|
+
// Check that itemsPerRow isn't 0 to prevent Infinite rows.
|
140
|
+
rows = itemsPerRow ? Math.ceil(count / itemsPerRow) : 0;
|
131
141
|
|
132
142
|
// use this cached layout hash to avoid allocing memory...
|
133
143
|
var ret = this._cachedLayoutHash;
|
134
144
|
if (!ret) ret = this._cachedLayoutHash = {};
|
135
145
|
|
136
|
-
|
137
|
-
|
138
|
-
this.set('calculatedHeight', ret.minHeight);
|
146
|
+
ret.height = rows * rowHeight;
|
147
|
+
|
139
148
|
return ret;
|
140
149
|
},
|
141
150
|
|
@@ -197,7 +206,7 @@ SC.GridView = SC.ListView.extend(
|
|
197
206
|
top = layout.top;
|
198
207
|
left = layout.left;
|
199
208
|
if (dropOperation & SC.DROP_AFTER) left += layout.width;
|
200
|
-
height = layout.height;
|
209
|
+
var height = layout.height;
|
201
210
|
|
202
211
|
// Adjust the position of the insertion point.
|
203
212
|
insertionPoint.adjust({ top: top, left: left, height: height });
|