sproutcore 1.0.1009 → 1.0.1024
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.
- data/DISTRIBUTION.yml +14 -0
- data/Rakefile +150 -23
- data/VERSION.yml +4 -2
- data/frameworks/sproutcore/Buildfile +1 -1
- data/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +1 -0
- data/frameworks/sproutcore/frameworks/datastore/models/record.js +66 -5
- data/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +14 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +28 -3
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +1 -1
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu_item_view.css +22 -2
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/panel.css +5 -1
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/well.css +72 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/alert.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/panes/picker.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/panes/select_button.js +33 -7
- data/frameworks/sproutcore/frameworks/desktop/system/root_responder.js +24 -23
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_alternatingrows.js +130 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +9 -10
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +4 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +18 -9
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +7 -6
- data/frameworks/sproutcore/frameworks/desktop/tests/views/well/ui.js +54 -0
- data/frameworks/sproutcore/frameworks/desktop/views/button.js +21 -9
- data/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +4 -3
- data/frameworks/sproutcore/frameworks/desktop/views/collection.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/grid.js +23 -14
- data/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
- data/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +3 -3
- data/frameworks/sproutcore/frameworks/desktop/views/radio.js +1 -2
- data/frameworks/sproutcore/frameworks/desktop/views/scroll.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/segmented.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/slider.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/well.js +80 -0
- data/frameworks/sproutcore/frameworks/foundation/fixtures/malformed.json +11 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/button.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +5 -1
- data/frameworks/sproutcore/frameworks/foundation/panes/pane.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/system/cursor.js +11 -10
- data/frameworks/sproutcore/frameworks/foundation/system/event.js +16 -15
- data/frameworks/sproutcore/frameworks/foundation/system/render_context.js +3 -3
- data/frameworks/sproutcore/frameworks/foundation/system/request.js +6 -5
- data/frameworks/sproutcore/frameworks/foundation/system/response.js +26 -8
- data/frameworks/sproutcore/frameworks/foundation/system/root_responder.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/system/timer.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/system/utils.js +122 -13
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_core.js +2 -3
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/tag.js +9 -9
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/update.js +3 -3
- data/frameworks/sproutcore/frameworks/foundation/tests/system/request.js +27 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/utils/rect.js +99 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/updateLayer.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/views/image.js +3 -1
- data/frameworks/sproutcore/frameworks/foundation/views/label.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/system/cookie.js +160 -0
- data/frameworks/sproutcore/frameworks/runtime/system/object.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/system/cookie.js +163 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/pane.css +12 -2
- data/lib/sproutcore/rack/proxy.rb +4 -2
- data/sproutcore-abbot.gemspec +23 -9
- metadata +32 -5
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/standard_fade/000000.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/standard_fade/ffffff.png +0 -0
@@ -17,8 +17,12 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
.sc-menu-item a{
|
20
|
+
position: absolute;
|
20
21
|
display: block;
|
21
22
|
top: 0;
|
23
|
+
bottom: 0px;
|
24
|
+
left: 0px;
|
25
|
+
right: 0px;
|
22
26
|
line-height: 22px;
|
23
27
|
text-shadow: #b0b0b0 0px 1px 0px;
|
24
28
|
text-decoration: none ;
|
@@ -95,16 +99,32 @@
|
|
95
99
|
background-image: sc_static('icons/mini_ffffff');
|
96
100
|
}
|
97
101
|
|
102
|
+
|
98
103
|
.sc-menu-item.disabled div.checkbox,
|
99
104
|
.sc-menu-item div.checkbox.inactive {
|
100
|
-
background-image:
|
105
|
+
background-image: url(data:image/gif;base64,R0lGODlhAQABAJAAAP///wAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==) top left no-repeat;
|
106
|
+
*background-image: sc_static('blank.gif') top left no-repeat; /* IE < 8 */
|
101
107
|
}
|
102
108
|
|
103
109
|
.sc-menu-item span.value {
|
104
|
-
|
110
|
+
position: absolute;
|
111
|
+
top: 0px;
|
112
|
+
bottom: 0px;
|
113
|
+
left: 15px;
|
114
|
+
right: 5px;
|
115
|
+
display: inline-block;
|
116
|
+
text-align:left;
|
105
117
|
margin-left:30px;
|
106
118
|
}
|
107
119
|
|
120
|
+
.sc-menu-item a.shortcutkey span.value {
|
121
|
+
right: 55px;
|
122
|
+
}
|
123
|
+
|
124
|
+
.sc-menu-item a.hasIcon span.value {
|
125
|
+
margin-left: 45px;
|
126
|
+
}
|
127
|
+
|
108
128
|
.sc-menu-item span.hasBranch {
|
109
129
|
position:absolute;
|
110
130
|
text-align:center;
|
@@ -6,7 +6,11 @@
|
|
6
6
|
}
|
7
7
|
|
8
8
|
.sc-pane.sc-modal.for-sc-panel {
|
9
|
-
background:
|
9
|
+
background: black;
|
10
|
+
opacity: 0.3;
|
11
|
+
-moz-opacity: 0.3;
|
12
|
+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
|
13
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=30);
|
10
14
|
}
|
11
15
|
|
12
16
|
.sc-pane.sc-panel > .sc-view {
|
@@ -0,0 +1,72 @@
|
|
1
|
+
.sc-well-view .top-right-edge {
|
2
|
+
position: absolute;
|
3
|
+
width: 7px;
|
4
|
+
height: 7px;
|
5
|
+
top: 0px;
|
6
|
+
right: 0px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.sc-well-view .top-left-edge {
|
10
|
+
position: absolute;
|
11
|
+
width: 7px;
|
12
|
+
height: 7px;
|
13
|
+
top: 0px;
|
14
|
+
left: 0px;
|
15
|
+
}
|
16
|
+
|
17
|
+
.sc-well-view .bottom-left-edge {
|
18
|
+
position: absolute;
|
19
|
+
width: 7px;
|
20
|
+
height: 7px;
|
21
|
+
bottom: 0px;
|
22
|
+
left: 0px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.sc-well-view .bottom-right-edge {
|
26
|
+
position: absolute;
|
27
|
+
width: 7px;
|
28
|
+
height: 7px;
|
29
|
+
bottom: 0px;
|
30
|
+
right: 0px;
|
31
|
+
}
|
32
|
+
|
33
|
+
.sc-well-view .top-edge {
|
34
|
+
position: absolute;
|
35
|
+
height: 5px;
|
36
|
+
top: 0px;
|
37
|
+
right: 7px;
|
38
|
+
left: 7px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.sc-well-view .bottom-edge {
|
42
|
+
position: absolute;
|
43
|
+
height: 5px;
|
44
|
+
bottom: 0px;
|
45
|
+
right: 7px;
|
46
|
+
left: 7px;
|
47
|
+
}
|
48
|
+
|
49
|
+
.sc-well-view .left-edge {
|
50
|
+
position: absolute;
|
51
|
+
width: 7px;
|
52
|
+
top: 7px;
|
53
|
+
bottom: 7px;
|
54
|
+
left: 0px;
|
55
|
+
}
|
56
|
+
|
57
|
+
.sc-well-view .right-edge {
|
58
|
+
position: absolute;
|
59
|
+
width: 7px;
|
60
|
+
top: 7px;
|
61
|
+
bottom: 7px;
|
62
|
+
right: 0px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.sc-well-view .content-background {
|
66
|
+
position: absolute;
|
67
|
+
top: 5px;
|
68
|
+
bottom: 5px;
|
69
|
+
right: 7px;
|
70
|
+
left: 7px;
|
71
|
+
z-index:-1;
|
72
|
+
}
|
@@ -216,7 +216,7 @@ SC.AlertPane = SC.PanelPane.extend({
|
|
216
216
|
|
217
217
|
render: function(context, firstTime) {
|
218
218
|
var pane = this.get('pane');
|
219
|
-
var blank =
|
219
|
+
var blank = SC.BLANK_IMAGE_URL ;
|
220
220
|
if(pane.get('icon') == 'blank') context.addClass('plain');
|
221
221
|
context.push('<img src="%@" class="icon %@" />'.fmt(blank, pane.get('icon')));
|
222
222
|
context.begin('h1').text(pane.get('message') || '').end();
|
@@ -299,7 +299,7 @@ SC.PickerPane = SC.PalettePane.extend({
|
|
299
299
|
*/
|
300
300
|
fitPositionToScreenMenu: function(w, f) {
|
301
301
|
// min left/right padding to the window
|
302
|
-
if( (f.x + f.width) > (w.width-
|
302
|
+
if( (f.x + f.width) > (w.width-9) ) f.x = w.width - f.width - 9;
|
303
303
|
if( f.x < 7 ) f.x = 7;
|
304
304
|
|
305
305
|
// if the height of the menu is bigger than the window height resize it.
|
@@ -263,11 +263,11 @@ SC.SelectButtonView = SC.ButtonView.extend(
|
|
263
263
|
@default YES
|
264
264
|
*/
|
265
265
|
needsEllipsis: YES,
|
266
|
-
|
266
|
+
|
267
267
|
/**
|
268
|
-
This property allows you at add extra padding to the height
|
268
|
+
This property allows you at add extra padding to the height
|
269
269
|
of the menu pane.
|
270
|
-
|
270
|
+
|
271
271
|
@default 0
|
272
272
|
@property {Number} heightPadding for menu pane.
|
273
273
|
*/
|
@@ -403,6 +403,7 @@ SC.SelectButtonView = SC.ButtonView.extend(
|
|
403
403
|
|
404
404
|
//Set the items in the itemList array
|
405
405
|
itemList.push(item);
|
406
|
+
|
406
407
|
}
|
407
408
|
|
408
409
|
idx += 1 ;
|
@@ -441,18 +442,43 @@ SC.SelectButtonView = SC.ButtonView.extend(
|
|
441
442
|
_action: function( evt )
|
442
443
|
{
|
443
444
|
var buttonLabel = this.$('.sc-button-label')[0] ;
|
444
|
-
|
445
|
+
// Get the length of the text on the button in pixels
|
446
|
+
var menuWidth = this.get('layer').offsetWidth ;
|
445
447
|
var scrollWidth = buttonLabel.scrollWidth ;
|
446
448
|
var lastMenuWidth = this.get('lastMenuWidth') ;
|
447
449
|
if(scrollWidth) {
|
448
|
-
|
450
|
+
// Get the original width of the label in the button
|
451
|
+
var offsetWidth = buttonLabel.offsetWidth ;
|
449
452
|
if(scrollWidth && offsetWidth) {
|
450
|
-
menuWidth = menuWidth + scrollWidth - offsetWidth ;
|
453
|
+
menuWidth = menuWidth + scrollWidth - offsetWidth ;
|
451
454
|
}
|
452
455
|
}
|
453
456
|
if (!lastMenuWidth || (menuWidth > lastMenuWidth)) {
|
454
457
|
lastMenuWidth = menuWidth ;
|
455
458
|
}
|
459
|
+
|
460
|
+
var items = this.get('itemList') ;
|
461
|
+
var elementOffsetWidth, largestMenuWidth ;
|
462
|
+
|
463
|
+
for (var idx = 0; idx < items.length; ++idx) {
|
464
|
+
//getting the width of largest menu item
|
465
|
+
var item = items.objectAt(idx) ;
|
466
|
+
var element = document.createElement('div') ;
|
467
|
+
element.style.cssText = 'top:-10000px; left: -10000px; position: absolute;' ;
|
468
|
+
element.className = 'sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button sc-scroll-view sc-menu-scroll-view sc-container-view menuContainer sc-button-view sc-menu-item sc-regular-size' ;
|
469
|
+
element.innerHTML = item.title ;
|
470
|
+
document.body.appendChild(element) ;
|
471
|
+
elementOffsetWidth = element.offsetWidth ;
|
472
|
+
|
473
|
+
if (!largestMenuWidth || (elementOffsetWidth > largestMenuWidth)) {
|
474
|
+
largestMenuWidth = elementOffsetWidth ;
|
475
|
+
}
|
476
|
+
document.body.removeChild(element) ;
|
477
|
+
}
|
478
|
+
|
479
|
+
lastMenuWidth = (largestMenuWidth > lastMenuWidth) ?
|
480
|
+
largestMenuWidth: lastMenuWidth ;
|
481
|
+
|
456
482
|
this.set('lastMenuWidth',lastMenuWidth) ;
|
457
483
|
var currSel = this.get('currentSelItem') ;
|
458
484
|
var itemList = this.get('itemList') ;
|
@@ -491,7 +517,7 @@ SC.SelectButtonView = SC.ButtonView.extend(
|
|
491
517
|
@property
|
492
518
|
*/
|
493
519
|
isEnabled: YES,
|
494
|
-
|
520
|
+
|
495
521
|
menuHeightPadding: menuHeightPadding,
|
496
522
|
|
497
523
|
preferType: SC.PICKER_MENU,
|
@@ -67,9 +67,9 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
67
67
|
@returns {SC.RootResponder} receiver
|
68
68
|
*/
|
69
69
|
orderBefore: function(pane, beforePane) {
|
70
|
-
var currentFocus = this.get('focusedPane')
|
71
|
-
|
72
|
-
|
70
|
+
var currentFocus = this.get('focusedPane'),
|
71
|
+
panes = this.get('orderedPanes').without(pane),
|
72
|
+
len, idx, currentOrder, newFocus ;
|
73
73
|
|
74
74
|
// adjust the beforePane to match orderLayer
|
75
75
|
var orderLayer = pane.get('orderLayer');
|
@@ -396,17 +396,16 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
396
396
|
// This code is to check for the simulated keypressed event
|
397
397
|
if(!evt.kindOf) this._ffevt=null;
|
398
398
|
else evt=this._ffevt;
|
399
|
-
if (evt
|
400
|
-
|
399
|
+
if (SC.none(evt)) return YES;
|
401
400
|
// Firefox does NOT handle delete here...
|
402
|
-
if (SC.browser.mozilla
|
401
|
+
if (SC.browser.mozilla && (evt.which === 8)) return true ;
|
403
402
|
|
404
403
|
// modifier keys are handled separately by the 'flagsChanged' event
|
405
404
|
// send event for modifier key changes, but only stop processing if this
|
406
405
|
// is only a modifier change
|
407
|
-
var ret = this._handleModifierChanges(evt)
|
408
|
-
|
409
|
-
|
406
|
+
var ret = this._handleModifierChanges(evt),
|
407
|
+
target = evt.target || evt.srcElement,
|
408
|
+
forceBlock = (evt.which === 8) && !SC.allowsBackspaceToPreviousPage && (target === document.body);
|
410
409
|
|
411
410
|
if (this._isModifierKey(evt)) return (forceBlock ? NO : ret);
|
412
411
|
|
@@ -421,7 +420,7 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
421
420
|
if (SC.browser.mozilla && evt.keyCode>=37 && evt.keyCode<=40){
|
422
421
|
this._ffevt=evt;
|
423
422
|
SC.RunLoop.begin();
|
424
|
-
this.invokeLater(this.keydown,
|
423
|
+
this.invokeLater(this.keydown, 100);
|
425
424
|
SC.RunLoop.end();
|
426
425
|
}
|
427
426
|
// otherwise, send as keyDown event. If no one was interested in this
|
@@ -453,7 +452,7 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
453
452
|
var ret ;
|
454
453
|
|
455
454
|
// delete is handled in keydown() for most browsers
|
456
|
-
if (SC.browser.mozilla
|
455
|
+
if (SC.browser.mozilla && (evt.which === 8)) {
|
457
456
|
ret = this.sendEvent('keyDown', evt);
|
458
457
|
return ret ? (SC.allowsBackspaceToPreviousPage || evt.hasCustomEventHandling) : YES ;
|
459
458
|
|
@@ -491,12 +490,11 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
491
490
|
}
|
492
491
|
evt.clickCount = this._clickCount ;
|
493
492
|
|
494
|
-
var view = this.targetViewForEvent(evt) ;
|
493
|
+
var fr, view = this.targetViewForEvent(evt) ;
|
495
494
|
// InlineTextField needs to loose firstResponder whenever you click outside
|
496
495
|
// the view. This is a special case as textfields are not supposed to loose
|
497
496
|
// focus unless you click on a list, another textfield or an special
|
498
497
|
// view/control.
|
499
|
-
var fr=null;
|
500
498
|
if(view) fr=view.get('pane').get('firstResponder');
|
501
499
|
|
502
500
|
if(fr && fr.kindOf(SC.InlineTextFieldView) && fr!==view){
|
@@ -587,8 +585,8 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
587
585
|
|
588
586
|
mousewheel: function(evt) {
|
589
587
|
try {
|
590
|
-
var view = this.targetViewForEvent(evt)
|
591
|
-
|
588
|
+
var view = this.targetViewForEvent(evt) ,
|
589
|
+
handler = this.sendEvent('mouseWheel', evt, view) ;
|
592
590
|
} catch (e) {
|
593
591
|
throw e;
|
594
592
|
}
|
@@ -607,13 +605,19 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
607
605
|
trigger calls to mouseDragged.
|
608
606
|
*/
|
609
607
|
mousemove: function(evt) {
|
608
|
+
if(SC.browser.msie){
|
609
|
+
if(this._lastMoveX === evt.clientX && this._lastMoveY === evt.clientY) return;
|
610
|
+
else {
|
611
|
+
this._lastMoveX = evt.clientX;
|
612
|
+
this._lastMoveY = evt.clientY;
|
613
|
+
}
|
614
|
+
}
|
615
|
+
|
610
616
|
SC.RunLoop.begin();
|
611
617
|
try {
|
612
|
-
|
613
618
|
// make sure the view gets focus no matter what. FF is inconsistant
|
614
619
|
// about this.
|
615
620
|
this.focus();
|
616
|
-
|
617
621
|
// only do mouse[Moved|Entered|Exited|Dragged] if not in a drag session
|
618
622
|
// drags send their own events, e.g. drag[Moved|Entered|Exited]
|
619
623
|
if (this._drag) {
|
@@ -627,11 +631,8 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
627
631
|
this._drag.tryToPerform('mouseDragged', evt);
|
628
632
|
}
|
629
633
|
} else {
|
630
|
-
|
631
|
-
|
632
|
-
var nh = [] ;
|
633
|
-
var view = this.targetViewForEvent(evt) ;
|
634
|
-
var exited;
|
634
|
+
var lh = this._lastHovered || [] , nh = [] , exited, loc, len,
|
635
|
+
view = this.targetViewForEvent(evt) ;
|
635
636
|
|
636
637
|
// work up the view chain. Notify of mouse entered and
|
637
638
|
// mouseMoved if implemented.
|
@@ -648,7 +649,7 @@ SC.RootResponder = SC.RootResponder.extend(
|
|
648
649
|
}
|
649
650
|
// now find those views last hovered over that were no longer found
|
650
651
|
// in this chain and notify of mouseExited.
|
651
|
-
for(
|
652
|
+
for(loc=0, len=lh.length; loc < len; loc++) {
|
652
653
|
view = lh[loc] ;
|
653
654
|
exited = view.respondsTo('mouseExited') ;
|
654
655
|
if (exited && !(nh.indexOf(view) !== -1)) {
|
@@ -0,0 +1,130 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
|
4
|
+
// portions copyright @2009 Apple Inc.
|
5
|
+
// License: Licened under MIT license (see license.js)
|
6
|
+
// ==========================================================================
|
7
|
+
|
8
|
+
/*
|
9
|
+
This test evaluates the creation of list item views with alternating rows
|
10
|
+
*/
|
11
|
+
|
12
|
+
module("SC.ListView - alternating rows");
|
13
|
+
|
14
|
+
// create a fake content array. Generates a list with whatever length you
|
15
|
+
// want of objects with a title based on the index. Cannot mutate.
|
16
|
+
var ContentArray = SC.Object.extend(SC.Array, {
|
17
|
+
|
18
|
+
length: 0,
|
19
|
+
|
20
|
+
objectAt: function(idx) {
|
21
|
+
if (idx >= this.get('length')) return undefined;
|
22
|
+
|
23
|
+
var content = this._content, ret ;
|
24
|
+
if (!content) content = this._content = [];
|
25
|
+
|
26
|
+
ret = content[idx];
|
27
|
+
if (!ret) {
|
28
|
+
ret = content[idx] = SC.Object.create({
|
29
|
+
title: "ContentItem %@".fmt(idx)
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
return ret ;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
var pane = SC.ControlTestPane.design()
|
38
|
+
.add("basic-even", SC.ScrollView.design({
|
39
|
+
layout: { left: 0, right: 0, top: 0, height: 180 },
|
40
|
+
hasHorizontalScroller: NO,
|
41
|
+
contentView: SC.ListView.design({
|
42
|
+
content: ContentArray.create({ length: 10 }),
|
43
|
+
showAlternatingRows: YES,
|
44
|
+
rowHeight: 20
|
45
|
+
})
|
46
|
+
}))
|
47
|
+
.add("basic-odd", SC.ScrollView.design({
|
48
|
+
layout: { left: 0, right: 0, top: 0, height: 180 },
|
49
|
+
hasHorizontalScroller: NO,
|
50
|
+
contentView: SC.ListView.design({
|
51
|
+
content: ContentArray.create({ length: 11 }),
|
52
|
+
showAlternatingRows: YES,
|
53
|
+
rowHeight: 20
|
54
|
+
})
|
55
|
+
}));
|
56
|
+
|
57
|
+
pane.show(); // add a test to show the test pane
|
58
|
+
window.pane = pane ;
|
59
|
+
|
60
|
+
function verifyClasses(views) {
|
61
|
+
var evens = SC.IndexSet.create(0).addEach([2,4,6,8,10]);
|
62
|
+
var odds = SC.IndexSet.create(1).addEach([3,5,7,9]);
|
63
|
+
|
64
|
+
views.forEach(function(item) {
|
65
|
+
var cq = item.$();
|
66
|
+
var idx = item.get('contentIndex');
|
67
|
+
|
68
|
+
if (evens.contains(idx)) {
|
69
|
+
ok(!cq.hasClass('odd'), "item %@ doesn't have 'odd' CSS class".fmt(idx));
|
70
|
+
ok(cq.hasClass('even'), "item %@ has 'even' CSS class".fmt(idx));
|
71
|
+
}
|
72
|
+
else if (odds.contains(idx)) {
|
73
|
+
ok(cq.hasClass('odd'), "item %@ has 'odd' CSS class".fmt(idx));
|
74
|
+
ok(!cq.hasClass('even'), "item %@ doesn't have 'even' CSS class".fmt(idx));
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
test("alternating class set on list view", function() {
|
80
|
+
var listView = pane.view("basic-even").contentView;
|
81
|
+
var cq = listView.$();
|
82
|
+
|
83
|
+
ok(cq.hasClass('alternating'), "ListView instance should have 'alternating' CSS class");
|
84
|
+
});
|
85
|
+
|
86
|
+
test("even/odd classes on ListItemView children - even", function() {
|
87
|
+
var items = pane.view("basic-even").contentView.childViews;
|
88
|
+
verifyClasses(items);
|
89
|
+
});
|
90
|
+
|
91
|
+
test("even/odd classes on ListItemView children - odd", function() {
|
92
|
+
items = pane.view("basic-odd").contentView.childViews;
|
93
|
+
verifyClasses(items);
|
94
|
+
});
|
95
|
+
|
96
|
+
test("even/odd classes with incremental rendering - even", function() {
|
97
|
+
var scrollView = pane.view("basic-even"),
|
98
|
+
listView = scrollView.contentView,
|
99
|
+
item = listView.childViews;
|
100
|
+
|
101
|
+
SC.run(function() {
|
102
|
+
scrollView.scrollTo(0,21);
|
103
|
+
});
|
104
|
+
|
105
|
+
verifyClasses(items);
|
106
|
+
|
107
|
+
SC.run(function() {
|
108
|
+
scrollView.scrollTo(0,0);
|
109
|
+
});
|
110
|
+
|
111
|
+
verifyClasses(items);
|
112
|
+
});
|
113
|
+
|
114
|
+
test("even/odd classes with incremental rendering - odd", function() {
|
115
|
+
var scrollView = pane.view("basic-odd"),
|
116
|
+
listView = scrollView.contentView,
|
117
|
+
item = listView.childViews;
|
118
|
+
|
119
|
+
SC.run(function() {
|
120
|
+
scrollView.scrollTo(0,21);
|
121
|
+
});
|
122
|
+
|
123
|
+
verifyClasses(items);
|
124
|
+
|
125
|
+
SC.run(function() {
|
126
|
+
scrollView.scrollTo(0,0);
|
127
|
+
});
|
128
|
+
|
129
|
+
verifyClasses(items);
|
130
|
+
});
|