sproutcore 1.9.1 → 1.9.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.
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +212 -11
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +17 -17
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +103 -86
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +33 -21
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +7 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +5 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +36 -30
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/many_array/core_methods.js +84 -42
- data/lib/frameworks/sproutcore/frameworks/desktop/{resources/debug → debug/resources}/a_sample_image.jpg +0 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/{resources/debug → debug/resources}/iframe.html +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/responder.js +68 -68
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/list_item.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu_item_view.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/slider.css +6 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/web/ui.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +45 -36
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/{gestureable.js → gesturable.js} +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/benchmark.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +4 -33
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +31 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +59 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/master-detail/master-detail.css +4 -0
- data/lib/gen/app/templates/apps/@target_name@/Buildfile +3 -1
- data/lib/gen/app/templates/apps/@target_name@/core.js +3 -3
- data/lib/gen/app/templates/apps/@target_name@/main.js +7 -5
- data/lib/gen/app/templates/apps/@target_name@/resources/main_page.css +20 -0
- data/lib/gen/app/templates/apps/@target_name@/resources/main_page.js +7 -7
- data/lib/gen/controller/templates/controllers/@filename@_controller.js +2 -2
- data/lib/gen/data-source/templates/data_sources/@filename@_data_source.js +21 -21
- data/lib/gen/design/templates/resources/@filename@.css +12 -0
- data/lib/gen/framework/templates/frameworks/@target_name@/core.js +3 -3
- data/lib/gen/framework/templates/frameworks/@target_name@/english.lproj/strings.js +1 -1
- data/lib/gen/language/templates/@filename@/strings.js +1 -1
- data/lib/gen/model/templates/models/@filename@_model.js +1 -1
- data/lib/gen/page/templates/pages/@target_name@/core.js +3 -3
- data/lib/gen/project/templates/@filename@/Buildfile +29 -5
- data/lib/gen/{responder → state}/Buildfile +3 -2
- data/lib/gen/state/README +1 -0
- data/lib/gen/state/USAGE +15 -0
- data/lib/gen/state/templates/states/@filename@_state.js +24 -0
- data/lib/gen/state/templates/tests/states/@filename@_test.js +12 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/Buildfile +3 -1
- data/lib/gen/statechart_app/templates/apps/@target_name@/core.js +3 -3
- data/lib/gen/statechart_app/templates/apps/@target_name@/main.js +3 -10
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.css +20 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.js +7 -7
- data/lib/gen/statechart_app/templates/apps/@target_name@/statechart.js +3 -3
- data/lib/sproutcore/models/generator.rb +1 -1
- data/spec/lib/models/generator/snake_case_spec.rb +26 -0
- data/sproutcore.gemspec +16 -16
- data/vendor/chance/lib/chance/instance/spriting.rb +32 -30
- metadata +30 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/debug/apple-logo1.jpeg +0 -0
- data/lib/gen/responder/README +0 -1
- data/lib/gen/responder/USAGE +0 -15
- data/lib/gen/responder/templates/states/@filename@_state.js +0 -36
|
@@ -51,7 +51,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
51
51
|
@type Boolean
|
|
52
52
|
@default YES
|
|
53
53
|
*/
|
|
54
|
-
acceptsFirstResponder: function() {
|
|
54
|
+
acceptsFirstResponder: function () {
|
|
55
55
|
if (SC.FOCUS_ALL_CONTROLS) { return this.get('isEnabled'); }
|
|
56
56
|
return NO;
|
|
57
57
|
}.property('isEnabled').cacheable(),
|
|
@@ -313,7 +313,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
313
313
|
Call itemsDidChange once to initialize segment child views for the items that exist at
|
|
314
314
|
creation time.
|
|
315
315
|
*/
|
|
316
|
-
init: function() {
|
|
316
|
+
init: function () {
|
|
317
317
|
sc_super();
|
|
318
318
|
|
|
319
319
|
var title = this.get('overflowTitle'),
|
|
@@ -339,7 +339,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
339
339
|
this.itemsDidChange();
|
|
340
340
|
},
|
|
341
341
|
|
|
342
|
-
shouldHandleOverflowDidChange: function() {
|
|
342
|
+
shouldHandleOverflowDidChange: function () {
|
|
343
343
|
if (this.get('shouldHandleOverflow')) {
|
|
344
344
|
// remeasure should show/hide it as needed
|
|
345
345
|
this.invokeLast(this.remeasure);
|
|
@@ -352,7 +352,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
352
352
|
Called whenever the number of items changes. This method populates SegmentedView's childViews, taking
|
|
353
353
|
care to re-use existing childViews if possible.
|
|
354
354
|
*/
|
|
355
|
-
itemsDidChange: function() {
|
|
355
|
+
itemsDidChange: function () {
|
|
356
356
|
var items = this.get('items') || [],
|
|
357
357
|
item,
|
|
358
358
|
localItem, // Used to avoid altering the original items
|
|
@@ -499,7 +499,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
499
499
|
This observer method is called whenever any of the relevant properties of an item change. This only applies
|
|
500
500
|
to SC.Object based items that may be observed.
|
|
501
501
|
*/
|
|
502
|
-
itemContentDidChange: function(item, key, alwaysNull, index) {
|
|
502
|
+
itemContentDidChange: function (item, key, alwaysNull, index) {
|
|
503
503
|
var items = this.get('items'),
|
|
504
504
|
childViews = this.get('childViews'),
|
|
505
505
|
childView;
|
|
@@ -522,7 +522,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
522
522
|
/** @private
|
|
523
523
|
Whenever the view resizes, we need to check to see if we're overflowing.
|
|
524
524
|
*/
|
|
525
|
-
viewDidResize: function() {
|
|
525
|
+
viewDidResize: function () {
|
|
526
526
|
var isHorizontal = this.get('layoutDirection') === SC.LAYOUT_HORIZONTAL,
|
|
527
527
|
visibleDim = isHorizontal ? this.$().width() : this.$().height();
|
|
528
528
|
|
|
@@ -535,7 +535,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
535
535
|
/** @private
|
|
536
536
|
Whenever visibility changes, we need to check to see if we're overflowing.
|
|
537
537
|
*/
|
|
538
|
-
isVisibleInWindowDidChange: function() {
|
|
538
|
+
isVisibleInWindowDidChange: function () {
|
|
539
539
|
if (this.get('shouldHandleOverflow')) {
|
|
540
540
|
this.invokeLast(this.remeasure);
|
|
541
541
|
}
|
|
@@ -545,7 +545,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
545
545
|
Calling this method forces the segments to be remeasured and will also adjust the
|
|
546
546
|
segments for overflow if necessary.
|
|
547
547
|
*/
|
|
548
|
-
remeasure: function() {
|
|
548
|
+
remeasure: function () {
|
|
549
549
|
if (!this.get('shouldHandleOverflow')) { return; }
|
|
550
550
|
var renderDelegate = this.get('renderDelegate'),
|
|
551
551
|
childViews = this.get('childViews'),
|
|
@@ -571,7 +571,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
571
571
|
/** @private
|
|
572
572
|
This method is called to adjust the segment views to see if we need to handle for overflow.
|
|
573
573
|
*/
|
|
574
|
-
adjustOverflow: function() {
|
|
574
|
+
adjustOverflow: function () {
|
|
575
575
|
if (!this.get('shouldHandleOverflow')) { return; }
|
|
576
576
|
|
|
577
577
|
var childViews = this.get('childViews'),
|
|
@@ -600,8 +600,17 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
600
600
|
dimToFit = (i === length - 1) ? curElementsDim : curElementsDim + this.cachedOverflowDim;
|
|
601
601
|
|
|
602
602
|
if (dimToFit > visibleDim) {
|
|
603
|
-
//
|
|
604
|
-
|
|
603
|
+
// Create a menu item based on the original item.
|
|
604
|
+
overflowItem = {};
|
|
605
|
+
localItem = childView.get('localItem');
|
|
606
|
+
|
|
607
|
+
overflowItem[this.get('itemTitleKey')] = localItem.get(this.get('itemTitleKey'));
|
|
608
|
+
overflowItem[this.get('itemIconKey')] = localItem.get(this.get('itemIconKey'));
|
|
609
|
+
overflowItem[this.get('itemIsEnabledKey')] = localItem.get(this.get('itemIsEnabledKey'));
|
|
610
|
+
overflowItem[this.get('itemKeyEquivalentKey')] = localItem.get(this.get('itemKeyEquivalentKey'));
|
|
611
|
+
overflowItem[this.get('itemValueKey')] = localItem.get(this.get('itemValueKey'));
|
|
612
|
+
|
|
613
|
+
this.overflowItems.pushObject(overflowItem);
|
|
605
614
|
|
|
606
615
|
// Record that we're now overflowing
|
|
607
616
|
this.isOverflowing = YES;
|
|
@@ -638,7 +647,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
638
647
|
|
|
639
648
|
It ignores the last segment (the overflow segment).
|
|
640
649
|
*/
|
|
641
|
-
segmentDimensions: function() {
|
|
650
|
+
segmentDimensions: function () {
|
|
642
651
|
var cv = this.get('childViews'),
|
|
643
652
|
v, f,
|
|
644
653
|
dims = [],
|
|
@@ -656,7 +665,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
656
665
|
/**
|
|
657
666
|
Return the dimension (height or width depending on the layout direction) over the overflow segment.
|
|
658
667
|
*/
|
|
659
|
-
overflowSegmentDim: function() {
|
|
668
|
+
overflowSegmentDim: function () {
|
|
660
669
|
var cv = this.get('childViews'),
|
|
661
670
|
v, f,
|
|
662
671
|
isHorizontal = this.get('layoutDirection') === SC.LAYOUT_HORIZONTAL;
|
|
@@ -673,7 +682,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
673
682
|
/**
|
|
674
683
|
Return the index of the segment view that is the target of the mouse click.
|
|
675
684
|
*/
|
|
676
|
-
indexForClientPosition: function(x, y) {
|
|
685
|
+
indexForClientPosition: function (x, y) {
|
|
677
686
|
var cv = this.get('childViews'),
|
|
678
687
|
length, i,
|
|
679
688
|
v, rect,
|
|
@@ -724,7 +733,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
724
733
|
Determines the index into the displayItems array where the passed mouse
|
|
725
734
|
event occurred.
|
|
726
735
|
*/
|
|
727
|
-
displayItemIndexForEvent: function(evt) {
|
|
736
|
+
displayItemIndexForEvent: function (evt) {
|
|
728
737
|
var renderDelegate = this.get('renderDelegate');
|
|
729
738
|
var x = evt.clientX;
|
|
730
739
|
var y = evt.clientY;
|
|
@@ -747,7 +756,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
747
756
|
},
|
|
748
757
|
|
|
749
758
|
/** @private */
|
|
750
|
-
keyDown: function(evt) {
|
|
759
|
+
keyDown: function (evt) {
|
|
751
760
|
var childViews,
|
|
752
761
|
childView,
|
|
753
762
|
i, length,
|
|
@@ -806,7 +815,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
806
815
|
},
|
|
807
816
|
|
|
808
817
|
/** @private */
|
|
809
|
-
mouseDown: function(evt) {
|
|
818
|
+
mouseDown: function (evt) {
|
|
810
819
|
var childViews = this.get('childViews'),
|
|
811
820
|
childView,
|
|
812
821
|
overflowIndex = childViews.get('length') - 1,
|
|
@@ -829,7 +838,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
829
838
|
},
|
|
830
839
|
|
|
831
840
|
/** @private */
|
|
832
|
-
mouseUp: function(evt) {
|
|
841
|
+
mouseUp: function (evt) {
|
|
833
842
|
var activeChildView,
|
|
834
843
|
index;
|
|
835
844
|
|
|
@@ -851,7 +860,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
851
860
|
},
|
|
852
861
|
|
|
853
862
|
/** @private */
|
|
854
|
-
mouseMoved: function(evt) {
|
|
863
|
+
mouseMoved: function (evt) {
|
|
855
864
|
var childViews = this.get('childViews'),
|
|
856
865
|
overflowIndex = childViews.get('length') - 1,
|
|
857
866
|
activeChildView,
|
|
@@ -881,7 +890,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
881
890
|
},
|
|
882
891
|
|
|
883
892
|
/** @private */
|
|
884
|
-
mouseEntered: function(evt) {
|
|
893
|
+
mouseEntered: function (evt) {
|
|
885
894
|
var childViews = this.get('childViews'),
|
|
886
895
|
childView,
|
|
887
896
|
overflowIndex = childViews.get('length') - 1,
|
|
@@ -906,7 +915,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
906
915
|
},
|
|
907
916
|
|
|
908
917
|
/** @private */
|
|
909
|
-
mouseExited: function(evt) {
|
|
918
|
+
mouseExited: function (evt) {
|
|
910
919
|
var activeChildView;
|
|
911
920
|
|
|
912
921
|
// if mouse was down, hide active index
|
|
@@ -921,7 +930,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
921
930
|
},
|
|
922
931
|
|
|
923
932
|
/** @private */
|
|
924
|
-
touchStart: function(touch) {
|
|
933
|
+
touchStart: function (touch) {
|
|
925
934
|
var childViews = this.get('childViews'),
|
|
926
935
|
childView,
|
|
927
936
|
overflowIndex = childViews.get('length') - 1,
|
|
@@ -945,7 +954,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
945
954
|
},
|
|
946
955
|
|
|
947
956
|
/** @private */
|
|
948
|
-
touchEnd: function(touch) {
|
|
957
|
+
touchEnd: function (touch) {
|
|
949
958
|
var activeChildView,
|
|
950
959
|
index;
|
|
951
960
|
|
|
@@ -966,7 +975,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
966
975
|
},
|
|
967
976
|
|
|
968
977
|
/** @private */
|
|
969
|
-
touchesDragged: function(evt, touches) {
|
|
978
|
+
touchesDragged: function (evt, touches) {
|
|
970
979
|
var isTouching = this.touchIsInBoundary(evt),
|
|
971
980
|
childViews = this.get('childViews'),
|
|
972
981
|
overflowIndex = childViews.get('length') - 1,
|
|
@@ -1005,7 +1014,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1005
1014
|
},
|
|
1006
1015
|
|
|
1007
1016
|
/** @private */
|
|
1008
|
-
_touchDidExit: function(evt) {
|
|
1017
|
+
_touchDidExit: function (evt) {
|
|
1009
1018
|
var activeChildView;
|
|
1010
1019
|
|
|
1011
1020
|
if (this.isTouching) {
|
|
@@ -1018,7 +1027,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1018
1027
|
},
|
|
1019
1028
|
|
|
1020
1029
|
/** @private */
|
|
1021
|
-
_touchDidEnter: function(evt) {
|
|
1030
|
+
_touchDidEnter: function (evt) {
|
|
1022
1031
|
var childViews = this.get('childViews'),
|
|
1023
1032
|
childView,
|
|
1024
1033
|
overflowIndex = childViews.get('length') - 1,
|
|
@@ -1042,7 +1051,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1042
1051
|
Simulates the user clicking on the segment at the specified index. This
|
|
1043
1052
|
will update the value if possible and fire the action.
|
|
1044
1053
|
*/
|
|
1045
|
-
triggerItemAtIndex: function(index) {
|
|
1054
|
+
triggerItemAtIndex: function (index) {
|
|
1046
1055
|
var childViews = this.get('childViews'),
|
|
1047
1056
|
childView,
|
|
1048
1057
|
sel, value, val, empty, mult;
|
|
@@ -1126,7 +1135,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1126
1135
|
/** @private
|
|
1127
1136
|
Invoked whenever an item is selected in the overflow menu.
|
|
1128
1137
|
*/
|
|
1129
|
-
selectOverflowItem: function(menu) {
|
|
1138
|
+
selectOverflowItem: function (menu) {
|
|
1130
1139
|
var item = menu.get('selectedItem');
|
|
1131
1140
|
|
|
1132
1141
|
this.triggerItemAtIndex(item.get('index'));
|
|
@@ -1141,7 +1150,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1141
1150
|
/** @private
|
|
1142
1151
|
Presents the popup menu containing overflowed segments.
|
|
1143
1152
|
*/
|
|
1144
|
-
showOverflowMenu: function() {
|
|
1153
|
+
showOverflowMenu: function () {
|
|
1145
1154
|
var childViews = this.get('childViews'),
|
|
1146
1155
|
overflowViewIndex = childViews.get('length') - 1,
|
|
1147
1156
|
overflowItems = this.overflowItems,
|
|
@@ -1157,16 +1166,16 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1157
1166
|
isArray = SC.isArray(value);
|
|
1158
1167
|
for (var i = 0; i < overflowItemsLength; i++) {
|
|
1159
1168
|
var item = overflowItems.objectAt(i),
|
|
1160
|
-
|
|
1169
|
+
itemValueKey = this.get('itemValueKey');
|
|
1161
1170
|
|
|
1162
|
-
if (isArray ? value.indexOf(item
|
|
1163
|
-
item.
|
|
1171
|
+
if (isArray ? value.indexOf(item[itemValueKey]) >= 0 : value === item[itemValueKey]) {
|
|
1172
|
+
item.isChecked = YES;
|
|
1164
1173
|
} else {
|
|
1165
|
-
item.
|
|
1174
|
+
item.isChecked = NO;
|
|
1166
1175
|
}
|
|
1167
1176
|
|
|
1168
1177
|
// Track the matching segment index
|
|
1169
|
-
item.
|
|
1178
|
+
item.index = startIndex + i;
|
|
1170
1179
|
}
|
|
1171
1180
|
|
|
1172
1181
|
// TODO: we can't pass a shortcut key to the menu, because it isn't a property of SegmentedView (yet?)
|
|
@@ -1183,7 +1192,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1183
1192
|
|
|
1184
1193
|
// We need to be able to update our overflow segment even if the user clicks outside of the menu. Since
|
|
1185
1194
|
// there is no callback method or observable property when the menu closes, override modalPaneDidClick().
|
|
1186
|
-
modalPaneDidClick: function() {
|
|
1195
|
+
modalPaneDidClick: function () {
|
|
1187
1196
|
sc_super();
|
|
1188
1197
|
|
|
1189
1198
|
// Cleanup
|
|
@@ -1204,7 +1213,7 @@ SC.SegmentedView = SC.View.extend(SC.Control,
|
|
|
1204
1213
|
/** @private
|
|
1205
1214
|
Whenever the value changes, update the segments accordingly.
|
|
1206
1215
|
*/
|
|
1207
|
-
valueDidChange: function() {
|
|
1216
|
+
valueDidChange: function () {
|
|
1208
1217
|
var value = this.get('value'),
|
|
1209
1218
|
overflowItemsLength,
|
|
1210
1219
|
childViews = this.get('childViews'),
|
data/lib/frameworks/sproutcore/frameworks/foundation/mixins/{gestureable.js → gesturable.js}
RENAMED
|
File without changes
|
|
@@ -106,7 +106,6 @@ SC.BaseTheme.labelRenderDelegate = SC.RenderDelegate.create({
|
|
|
106
106
|
htmlForTitleAndIcon: function(dataSource) {
|
|
107
107
|
var title = dataSource.get('title'),
|
|
108
108
|
hint = dataSource.get('hint'),
|
|
109
|
-
hintEnabled = dataSource.get('hintEnabled'),
|
|
110
109
|
escapeHTML = dataSource.get('escapeHTML'),
|
|
111
110
|
icon = dataSource.get('icon') || '';
|
|
112
111
|
|
|
@@ -115,9 +114,8 @@ SC.BaseTheme.labelRenderDelegate = SC.RenderDelegate.create({
|
|
|
115
114
|
if (title && escapeHTML) {
|
|
116
115
|
title = SC.RenderContext.escapeHTML(title) ;
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
if (escapeHTML) hint = SC.RenderContext.escapeHTML(hint);
|
|
117
|
+
if (escapeHTML) { hint = SC.RenderContext.escapeHTML(hint); }
|
|
118
|
+
if (hint && !title) {
|
|
121
119
|
title = "<span class='sc-hint'>" + hint + "</span>";
|
|
122
120
|
}
|
|
123
121
|
|
|
@@ -19,6 +19,11 @@ var pane = SC.ControlTestPane.design()
|
|
|
19
19
|
isEnabled: NO
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
+
.add("hint", SC.LabelView, {
|
|
23
|
+
hint: 'Get on with it!',
|
|
24
|
+
isEditable: true
|
|
25
|
+
})
|
|
26
|
+
|
|
22
27
|
.add("selectable", SC.LabelView, {
|
|
23
28
|
value:'hello',
|
|
24
29
|
isTextSelectable: YES
|
|
@@ -175,4 +180,12 @@ test("Check that the title is set or not and if it is in the appropriate element
|
|
|
175
180
|
equals(viewElem.text(), '', 'has correct empty value set');
|
|
176
181
|
});
|
|
177
182
|
|
|
183
|
+
test("The hint property should appear if the label is editable and has no value.", function () {
|
|
184
|
+
var viewElem = pane.view('hint').$();
|
|
185
|
+
|
|
186
|
+
viewElem = viewElem.find('.sc-hint');
|
|
187
|
+
equals(viewElem.length, 1, "has an .sc-hint span inside");
|
|
188
|
+
equals(viewElem.text(), 'Get on with it!', 'has correct hint value set');
|
|
189
|
+
});
|
|
190
|
+
|
|
178
191
|
})();
|
|
@@ -435,31 +435,14 @@ SC.InlineTextFieldView = SC.TextFieldView.extend(SC.InlineEditor,
|
|
|
435
435
|
return YES;
|
|
436
436
|
},
|
|
437
437
|
|
|
438
|
-
//
|
|
439
|
-
//
|
|
440
|
-
|
|
441
|
-
fieldValueDidChange: function(partialChange) {
|
|
442
|
-
arguments.callee.base.call(this, partialChange) ;
|
|
443
|
-
//this.resizeToFit(this.getFieldValue()) ;
|
|
444
|
-
},
|
|
445
|
-
|
|
446
|
-
// invoked when the user presses return. If this is a multi-line field,
|
|
447
|
-
// then allow the newine to proceed. Otherwise, try to commit the
|
|
448
|
-
// edit.
|
|
438
|
+
// Invoked when the user presses return. If this is a multi-line field,
|
|
439
|
+
// then allow the new line to proceed by calling the super class.
|
|
440
|
+
// Otherwise, try to commit the edit.
|
|
449
441
|
/** @private */
|
|
450
442
|
insertNewline: function(evt) {
|
|
451
443
|
if (this.get('isTextArea')) {
|
|
452
|
-
|
|
453
|
-
return arguments.callee.base.call(this, evt) ;
|
|
444
|
+
return sc_super();
|
|
454
445
|
} else {
|
|
455
|
-
// TODO : this is a work around. There is a bug where the
|
|
456
|
-
// last character would get dropped
|
|
457
|
-
// if the editing was completed by pressing return
|
|
458
|
-
// needs to be fixed
|
|
459
|
-
if (this.get('value') != this.$input().val()) {
|
|
460
|
-
this.set('value', this.$input().val());
|
|
461
|
-
}
|
|
462
|
-
|
|
463
446
|
this.commitEditing() ;
|
|
464
447
|
return YES ;
|
|
465
448
|
}
|
|
@@ -489,18 +472,6 @@ SC.InlineTextFieldView = SC.TextFieldView.extend(SC.InlineEditor,
|
|
|
489
472
|
if(prev && prev.beginEditing) prev.beginEditing();
|
|
490
473
|
}
|
|
491
474
|
return YES ;
|
|
492
|
-
},
|
|
493
|
-
|
|
494
|
-
/** @private */
|
|
495
|
-
deleteForward: function(evt) {
|
|
496
|
-
evt.allowDefault();
|
|
497
|
-
return YES;
|
|
498
|
-
},
|
|
499
|
-
|
|
500
|
-
/** @private */
|
|
501
|
-
deleteBackward: function(evt) {
|
|
502
|
-
evt.allowDefault();
|
|
503
|
-
return YES ;
|
|
504
475
|
}
|
|
505
476
|
});
|
|
506
477
|
|
|
@@ -30,7 +30,7 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditable,
|
|
|
30
30
|
|
|
31
31
|
classNames: ['sc-label-view'],
|
|
32
32
|
|
|
33
|
-
displayProperties: ['displayTitle', '
|
|
33
|
+
displayProperties: ['displayTitle', 'displayHint', 'escapeHTML', 'textAlign', 'fontWeight', 'icon', 'needsEllipsis', 'toolTip'],
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
The delegate that gets notified of events related to the editing process. Set
|
|
@@ -103,14 +103,11 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditable,
|
|
|
103
103
|
*/
|
|
104
104
|
hint: null,
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
Whether hint should be shown or not. By default this is tied to isEditable
|
|
108
|
-
so the hint will only show if isEditable is YES.
|
|
109
|
-
|
|
110
|
-
@type Boolean
|
|
111
|
-
@property
|
|
112
|
-
*/
|
|
106
|
+
/** @deprecated */
|
|
113
107
|
hintEnabled: function() {
|
|
108
|
+
//@if(debug)
|
|
109
|
+
SC.warn("Developer Warning: The hintEnabled property of SC.LabelView is deprecated. Please simply get the isEditable property to determine if the hint will be displayed instead.");
|
|
110
|
+
//@endif
|
|
114
111
|
return this.get('isEditable');
|
|
115
112
|
}.property('isEditable').cacheable(),
|
|
116
113
|
|
|
@@ -149,12 +146,12 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditable,
|
|
|
149
146
|
renderDelegateName: 'labelRenderDelegate',
|
|
150
147
|
|
|
151
148
|
/**
|
|
152
|
-
|
|
149
|
+
The value that will actually be displayed.
|
|
153
150
|
|
|
154
151
|
This property is dynamically computed by applying localization,
|
|
155
152
|
string conversion and other normalization utilities.
|
|
156
153
|
|
|
157
|
-
@
|
|
154
|
+
@type String
|
|
158
155
|
*/
|
|
159
156
|
displayTitle: function() {
|
|
160
157
|
var value, formatter;
|
|
@@ -187,20 +184,37 @@ SC.LabelView = SC.View.extend(SC.Control, SC.InlineEditable,
|
|
|
187
184
|
// 4. Localize
|
|
188
185
|
if (value && this.getDelegateProperty('localize', this.displayDelegate)) value = SC.String.loc(value) ;
|
|
189
186
|
|
|
190
|
-
return value
|
|
187
|
+
return value;
|
|
191
188
|
}.property('value', 'localize', 'formatter').cacheable(),
|
|
192
189
|
|
|
193
|
-
|
|
194
190
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
This property is dynamically computed by applying localization
|
|
198
|
-
and other normalization utilities.
|
|
191
|
+
The hint that will actually be displayed depending on localization and
|
|
192
|
+
sanitizing (or not).
|
|
199
193
|
|
|
194
|
+
@type String
|
|
200
195
|
*/
|
|
196
|
+
displayHint: function () {
|
|
197
|
+
var hint = this.get('hint'),
|
|
198
|
+
isEditable = this.get('isEditable');
|
|
199
|
+
|
|
200
|
+
if (isEditable) {
|
|
201
|
+
if (hint && this.getDelegateProperty('localize', this.displayDelegate)) {
|
|
202
|
+
hint = SC.String.loc(hint);
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
hint = null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return hint;
|
|
209
|
+
}.property('hint', 'localize', 'isEditable').cacheable(),
|
|
210
|
+
|
|
211
|
+
/** @deprecated */
|
|
201
212
|
hintValue: function() {
|
|
213
|
+
//@if(debug)
|
|
214
|
+
SC.warn("Developer Warning: The hintValue property of SC.LabelView is deprecated. Please simply get the hint or displayHint (localized) property instead.");
|
|
215
|
+
//@endif
|
|
202
216
|
var hintVal = this.get('hint');
|
|
203
|
-
return hintVal
|
|
217
|
+
return hintVal;
|
|
204
218
|
}.property('hint').cacheable(),
|
|
205
219
|
|
|
206
220
|
/**
|