sproutcore 0.9.3 → 0.9.4
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/History.txt +19 -0
- data/Manifest.txt +15 -1
- data/clients/view_builder/builders/builder.js +339 -0
- data/clients/view_builder/builders/button.js +81 -0
- data/clients/view_builder/controllers/document.js +21 -0
- data/clients/view_builder/core.js +19 -0
- data/clients/view_builder/english.lproj/body.css +77 -0
- data/clients/view_builder/english.lproj/body.rhtml +39 -0
- data/clients/view_builder/english.lproj/controls.css +0 -0
- data/clients/view_builder/english.lproj/strings.js +14 -0
- data/clients/view_builder/main.js +38 -0
- data/clients/view_builder/mixins/design_mode.js +92 -0
- data/clients/view_builder/tests/controllers/document.rhtml +20 -0
- data/clients/view_builder/tests/views/builder.rhtml +20 -0
- data/clients/view_builder/tests/views/palette.rhtml +21 -0
- data/clients/view_builder/views/builder.js +26 -0
- data/clients/view_builder/views/palette.js +30 -0
- data/frameworks/sproutcore/Core.js +6 -4
- data/frameworks/sproutcore/README +1 -3
- data/frameworks/sproutcore/controllers/array.js +5 -5
- data/frameworks/sproutcore/drag/drag.js +2 -0
- data/frameworks/sproutcore/english.lproj/panes.css +16 -35
- data/frameworks/sproutcore/foundation/application.js +29 -8
- data/frameworks/sproutcore/foundation/object.js +5 -1
- data/frameworks/sproutcore/foundation/run_loop.js +65 -2
- data/frameworks/sproutcore/foundation/timer.js +1 -0
- data/frameworks/sproutcore/globals/window.js +23 -18
- data/frameworks/sproutcore/mixins/array.js +2 -2
- data/frameworks/sproutcore/mixins/observable.js +127 -52
- data/frameworks/sproutcore/panes/dialog.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +6 -2
- data/frameworks/sproutcore/panes/pane.js +27 -0
- data/frameworks/sproutcore/views/collection/collection.js +1 -1
- data/frameworks/sproutcore/views/collection/grid.js +3 -15
- data/frameworks/sproutcore/views/collection/source_list.js +10 -5
- data/frameworks/sproutcore/views/field/select_field.js +11 -2
- data/frameworks/sproutcore/views/field/text_field.js +1 -1
- data/frameworks/sproutcore/views/label.js +2 -7
- data/frameworks/sproutcore/views/view.js +254 -213
- data/generators/client/README +2 -2
- data/generators/client/USAGE +2 -2
- data/lib/sproutcore/build_tools/html_builder.rb +2 -2
- data/lib/sproutcore/bundle_manifest.rb +28 -22
- data/lib/sproutcore/merb/bundle_controller.rb +4 -3
- data/lib/sproutcore/version.rb +1 -1
- metadata +17 -3
- data/frameworks/sproutcore/animation/animation.js +0 -411
@@ -147,7 +147,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.Editable,
|
|
147
147
|
|
148
148
|
/** @private */
|
149
149
|
setFieldValue: function(value) {
|
150
|
-
if (this._value == value) return ;
|
150
|
+
if (this._value == value || value == undefined) return ;
|
151
151
|
this._value = value ;
|
152
152
|
this._updateFieldHint() ;
|
153
153
|
},
|
@@ -35,7 +35,7 @@ SC.LabelView = SC.View.extend(SC.DelegateSupport, SC.Control, SC.InlineEditorDel
|
|
35
35
|
This is a default value that can be overridden by the
|
36
36
|
settings on the owner view.
|
37
37
|
*/
|
38
|
-
|
38
|
+
escapeHTML: true,
|
39
39
|
|
40
40
|
/**
|
41
41
|
If true, then the value will be localized.
|
@@ -113,11 +113,6 @@ SC.LabelView = SC.View.extend(SC.DelegateSupport, SC.Control, SC.InlineEditorDel
|
|
113
113
|
isEditing: NO,
|
114
114
|
|
115
115
|
|
116
|
-
/**
|
117
|
-
set to true to have any markup in the content escaped.
|
118
|
-
*/
|
119
|
-
escapeHTML: true,
|
120
|
-
|
121
116
|
/**
|
122
117
|
set to true to have the value you set automatically localized.
|
123
118
|
*/
|
@@ -237,7 +232,7 @@ SC.LabelView = SC.View.extend(SC.DelegateSupport, SC.Control, SC.InlineEditorDel
|
|
237
232
|
var value = this.get('displayValue') ;
|
238
233
|
|
239
234
|
// Escape HTML
|
240
|
-
if (this.getDelegateProperty(this.displayDelegate, '
|
235
|
+
if (this.getDelegateProperty(this.displayDelegate, 'escapeHTML')) {
|
241
236
|
this.set('innerText', value || '') ;
|
242
237
|
} else this.set('innerHTML', value || '') ;
|
243
238
|
|
@@ -26,13 +26,14 @@ SC.BENCHMARK_CONFIGURE_OUTLETS = NO ;
|
|
26
26
|
the general concepts you need to understand when working with views, though
|
27
27
|
most often you will want to work with one of the subclasses instead.
|
28
28
|
|
29
|
+
h2. Working with DOM Elements
|
30
|
+
|
31
|
+
h2. Handling Events
|
29
32
|
|
30
33
|
@extends SC.Responder
|
31
34
|
@extends SC.PathModule
|
32
35
|
@extends SC.DelegateSupport
|
33
|
-
|
34
|
-
@author Charles Jolley
|
35
|
-
@version 1.0
|
36
|
+
@since SproutCore 1.0
|
36
37
|
*/
|
37
38
|
SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
38
39
|
/** @scope SC.View.prototype */ {
|
@@ -99,6 +100,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
99
100
|
// document somwhere.
|
100
101
|
if (updateDom) {
|
101
102
|
var beforeElement = (beforeView) ? beforeView.rootElement : null;
|
103
|
+
|
102
104
|
(this.containerElement || this.rootElement).insertBefore(view.rootElement,beforeElement);
|
103
105
|
|
104
106
|
// regenerate the childNodes array.
|
@@ -205,7 +207,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
205
207
|
elements managed by the views are also directl children of the
|
206
208
|
containerElement for the receiver.
|
207
209
|
|
208
|
-
@
|
210
|
+
@field
|
209
211
|
@type Array
|
210
212
|
*/
|
211
213
|
childNodes: [],
|
@@ -214,7 +216,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
214
216
|
The first child view in the childNodes array. If the view does not have
|
215
217
|
any children, this property will be null.
|
216
218
|
|
217
|
-
@
|
219
|
+
@field
|
218
220
|
@type SC.View
|
219
221
|
*/
|
220
222
|
firstChild: null,
|
@@ -223,7 +225,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
223
225
|
The last child view in the childNodes array. If the view does not have any children,
|
224
226
|
this property will be null.
|
225
227
|
|
226
|
-
@
|
228
|
+
@field
|
227
229
|
@type SC.View
|
228
230
|
*/
|
229
231
|
lastChild: null,
|
@@ -233,7 +235,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
233
235
|
If the receiver is the last view in the array or if the receiver does not
|
234
236
|
belong to a parent view this property will be null.
|
235
237
|
|
236
|
-
@
|
238
|
+
@field
|
237
239
|
@type SC.View
|
238
240
|
*/
|
239
241
|
nextSibling: null,
|
@@ -243,7 +245,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
243
245
|
parentNode. If the receiver is the first view in the array or if the
|
244
246
|
receiver does not belong to a parent view this property will be null.
|
245
247
|
|
246
|
-
@
|
248
|
+
@field
|
247
249
|
@type SC.View
|
248
250
|
*/
|
249
251
|
previousSibling: null,
|
@@ -252,7 +254,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
252
254
|
The parent view this view belongs to. If the receiver does not belong to a parent view
|
253
255
|
then this property is null.
|
254
256
|
|
255
|
-
@
|
257
|
+
@field
|
256
258
|
@type SC.View
|
257
259
|
*/
|
258
260
|
parentNode: null,
|
@@ -267,7 +269,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
267
269
|
If the view does not belong to a parentNode or if the view is not
|
268
270
|
onscreen, this property will be null.
|
269
271
|
|
270
|
-
@
|
272
|
+
@field
|
271
273
|
@type SC.View
|
272
274
|
*/
|
273
275
|
pane: function()
|
@@ -416,6 +418,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
416
418
|
}
|
417
419
|
return null;
|
418
420
|
},
|
421
|
+
|
419
422
|
previousValidKeyView: function()
|
420
423
|
{
|
421
424
|
var view = this;
|
@@ -465,12 +468,13 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
465
468
|
// ..........................................
|
466
469
|
// ELEMENT API
|
467
470
|
//
|
468
|
-
// The methods in this section provide compatibility with the most common
|
469
|
-
// Prototype methods used on elements. These methods are generally primitives
|
470
|
-
// for modifying the underlying DOM element. You should only use them for
|
471
|
-
// INTERNAL VIEW CODE.
|
472
471
|
|
473
|
-
|
472
|
+
/**
|
473
|
+
Read-only array of currently applied classNames.
|
474
|
+
|
475
|
+
@field
|
476
|
+
@type {Array}
|
477
|
+
*/
|
474
478
|
classNames: function() {
|
475
479
|
if (!this._classNames) {
|
476
480
|
var classNames = this.rootElement.className;
|
@@ -478,13 +482,23 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
478
482
|
}
|
479
483
|
return this._classNames ;
|
480
484
|
}.property(),
|
481
|
-
|
482
|
-
|
485
|
+
|
486
|
+
/**
|
487
|
+
Detects the presence of the class name on the root element.
|
488
|
+
|
489
|
+
@param className {String} the class name
|
490
|
+
@returns {Boolean} YES if class name is currently applied, NO otherwise
|
491
|
+
*/
|
483
492
|
hasClassName: function(className) {
|
484
493
|
return (this._classNames || this.get('classNames')).indexOf(className) >= 0 ;
|
485
494
|
},
|
486
495
|
|
487
|
-
|
496
|
+
/**
|
497
|
+
Adds the class name to the element.
|
498
|
+
|
499
|
+
@param className {String} the class name to add.
|
500
|
+
@returns {String} the class name
|
501
|
+
*/
|
488
502
|
addClassName: function(className) {
|
489
503
|
if (this.hasClassName(className)) return ; // nothing to do
|
490
504
|
|
@@ -495,8 +509,13 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
495
509
|
this.propertyDidChange('classNames') ;
|
496
510
|
return className ;
|
497
511
|
},
|
498
|
-
|
499
|
-
|
512
|
+
|
513
|
+
/**
|
514
|
+
Removes the specified class name from the element.
|
515
|
+
|
516
|
+
@param className {String} the class name to remove
|
517
|
+
@returns {String} the class name
|
518
|
+
*/
|
500
519
|
removeClassName: function(className) {
|
501
520
|
if (!this.hasClassName(className)) return ; // nothing to do
|
502
521
|
|
@@ -508,16 +527,44 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
508
527
|
return className ;
|
509
528
|
},
|
510
529
|
|
530
|
+
/**
|
531
|
+
Adds or removes the class name according to flag.
|
532
|
+
|
533
|
+
This is a simple way to add or remove a class from the root element.
|
534
|
+
|
535
|
+
@param className {String} the class name
|
536
|
+
@param flag {Boolean} YES to add class name, NO to remove it.
|
537
|
+
@returns {String} The class Name.
|
538
|
+
*/
|
511
539
|
setClassName: function(className, flag) {
|
512
540
|
return (!!flag) ? this.addClassName(className) : this.removeClassName(className);
|
513
541
|
},
|
514
|
-
|
515
|
-
|
542
|
+
|
543
|
+
/**
|
544
|
+
Toggles the presence of the class name.
|
545
|
+
|
546
|
+
If the specified CSS class is applied, it will be removed. If it is not
|
547
|
+
present, it will be added. Note that if this changes the potential
|
548
|
+
layout of the view, you must wrap calls to this in viewFrameDidChange()
|
549
|
+
and viewFrameWillChange().
|
550
|
+
|
551
|
+
@param className {String} the class name
|
552
|
+
@returns {Boolean} YES if classname is now applied
|
553
|
+
*/
|
516
554
|
toggleClassName: function(className) {
|
517
555
|
return this.setClassName(className, !this.hasClassName(className)) ;
|
518
556
|
},
|
519
557
|
|
520
|
-
|
558
|
+
/**
|
559
|
+
Retrieves the current value of the named CSS style.
|
560
|
+
|
561
|
+
This method is designed to work cross platform and uses the current
|
562
|
+
computed style, which is the combination of all applied CSS class names
|
563
|
+
and inline styles.
|
564
|
+
|
565
|
+
@param style {String} the style key.
|
566
|
+
@returns {Object} the style value or null if not-applied/auto
|
567
|
+
*/
|
521
568
|
getStyle: function(style) {
|
522
569
|
var element = this.rootElement ;
|
523
570
|
if (!this._computedStyle) {
|
@@ -538,33 +585,113 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
538
585
|
|
539
586
|
return value ;
|
540
587
|
},
|
541
|
-
|
542
|
-
|
588
|
+
|
589
|
+
|
590
|
+
/**
|
591
|
+
Sets the passed hash of CSS styles and values on the element. You should
|
592
|
+
pass your properties pre-camelized.
|
593
|
+
|
594
|
+
@param styles {Hash} hash of keys and values
|
595
|
+
@param camelized {Boolean} optional bool set to NO if you did not camelize.
|
596
|
+
@returns {Boolean} YES if set succeeded.
|
597
|
+
*/
|
543
598
|
setStyle: function(styles, camelized) {
|
544
599
|
return Element.setStyle(this.rootElement, styles, camelized) ;
|
545
600
|
},
|
546
601
|
|
547
|
-
|
548
|
-
|
549
|
-
|
602
|
+
/**
|
603
|
+
Updates the HTML of an element.
|
604
|
+
|
605
|
+
This method takes care of nasties like processing scripts and inserting
|
606
|
+
HTML into a table. It is also somewhat slow. If you control the HTML
|
607
|
+
being inserted and you are not working with table elements, you should use
|
608
|
+
the innerHTML property instead. If you are setting content generated by
|
609
|
+
users, this method can insert the content safely.
|
610
|
+
|
611
|
+
@param html {String} the html to insert.
|
612
|
+
*/
|
550
613
|
update: function(html) {
|
551
614
|
Element.update((this.containerElement || this.rootElement),html) ;
|
552
615
|
this.propertyDidChange('innerHTML') ;
|
553
616
|
},
|
554
617
|
|
555
|
-
|
556
|
-
|
618
|
+
/**
|
619
|
+
Retrieves the value for an attribute on the DOM element
|
620
|
+
|
621
|
+
@param attrName {String} the attribute name
|
622
|
+
@returns {String} attribute value
|
623
|
+
*/
|
557
624
|
getAttribute: function(attrName) {
|
558
625
|
return Element.readAttribute(this.rootElement,attrName) ;
|
559
626
|
},
|
560
|
-
|
627
|
+
|
628
|
+
/**
|
629
|
+
Sets an attribute on the root DOM element.
|
630
|
+
|
631
|
+
@param attrName {String} the attribute name
|
632
|
+
@param value {String} the new attribute value
|
633
|
+
@returns {String} the set attribute name
|
634
|
+
*/
|
561
635
|
setAttribute: function(attrName, value) {
|
562
636
|
this.rootElement.setAttribute(atrrName, value) ;
|
563
637
|
},
|
564
638
|
|
639
|
+
/**
|
640
|
+
Returns true if the named attributes is defined on the views root element.
|
641
|
+
|
642
|
+
@param attrName {String} the attribute name
|
643
|
+
@returns {Boolean} YES if attribute is present.
|
644
|
+
*/
|
565
645
|
hasAttribute: function(attrName) {
|
566
646
|
return Element.hasAttribute(this.rootElement, attrName) ;
|
567
647
|
},
|
648
|
+
|
649
|
+
// ..........................................
|
650
|
+
// STYLE API
|
651
|
+
//
|
652
|
+
// These properties can be used to directly manipulate various CSS
|
653
|
+
// styles on the view. These properties are required for animation
|
654
|
+
// support. Values are typically assumed to be in px.
|
655
|
+
|
656
|
+
/**
|
657
|
+
SC.View's unknown property is used to implement a large class of
|
658
|
+
properties beginning with the the world "style". You can get or set
|
659
|
+
any of these properties to edit individual CSS style properties.
|
660
|
+
*/
|
661
|
+
unknownProperty: function(key, value) {
|
662
|
+
if (key.match(/^style/)) {
|
663
|
+
key = key.slice(5,key.length).replace(/^./, function(x) {
|
664
|
+
return x.toLowerCase();
|
665
|
+
});
|
666
|
+
|
667
|
+
var ret = null ;
|
668
|
+
|
669
|
+
// handle dimensional properties
|
670
|
+
if (key.match(/height$|width$|top$|bottom$|left$|right$/i)) {
|
671
|
+
if (value !== undefined) {
|
672
|
+
this.viewFrameWillChange() ;
|
673
|
+
var props = {} ;
|
674
|
+
props[key] = (value) ? value + 'px' : 'auto' ;
|
675
|
+
this.setStyle(props) ;
|
676
|
+
this.viewFrameDidChange() ;
|
677
|
+
}
|
678
|
+
ret = this.getStyle(key) ;
|
679
|
+
ret = (ret === 'auto') ? null : parseInt(ret, 0) ;
|
680
|
+
|
681
|
+
// all other properties just pass through (and do not change frame)
|
682
|
+
} else {
|
683
|
+
if (value !== undefined) {
|
684
|
+
var props = {} ;
|
685
|
+
props[key] = value ;
|
686
|
+
this.setStyle(props) ;
|
687
|
+
}
|
688
|
+
ret = this.getStyle(key) ;
|
689
|
+
}
|
690
|
+
console.log('get Style: %@ -> %@'.fmt(key, ret)) ;
|
691
|
+
return ret;
|
692
|
+
|
693
|
+
} else return arguments.callee.base.call(this, key, value) ;
|
694
|
+
},
|
568
695
|
|
569
696
|
// ..........................................
|
570
697
|
// DOM API
|
@@ -583,7 +710,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
583
710
|
property. It is not currently safe to edit this property once the view
|
584
711
|
has been createde.
|
585
712
|
|
586
|
-
@
|
713
|
+
@field
|
587
714
|
@type {Element}
|
588
715
|
*/
|
589
716
|
rootElement: null,
|
@@ -600,7 +727,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
600
727
|
methods you write on an SC.View subclass, never from outside the view.
|
601
728
|
Unlike most properties, it is not necessary to use get()/set().
|
602
729
|
|
603
|
-
@
|
730
|
+
@field
|
604
731
|
@type {Element}
|
605
732
|
*/
|
606
733
|
containerElement: null,
|
@@ -618,11 +745,13 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
618
745
|
clippingFrameDidChange method.
|
619
746
|
|
620
747
|
If this property returns false, then notifications about changes to the
|
621
|
-
clippingFrame will probably not be called on the receiver. Normally if
|
622
|
-
do not need to worry about this property since implementing the
|
623
|
-
method will change its value and cause your
|
748
|
+
clippingFrame will probably not be called on the receiver. Normally if
|
749
|
+
you do not need to worry about this property since implementing the
|
750
|
+
clippingFrameDidChange() method will change its value and cause your
|
751
|
+
method to be invoked.
|
624
752
|
|
625
|
-
This property is automatically updated whenever you add or remove a child
|
753
|
+
This property is automatically updated whenever you add or remove a child
|
754
|
+
view.
|
626
755
|
*/
|
627
756
|
needsClippingFrame: function() {
|
628
757
|
if (this._needsClippingFrame == null) {
|
@@ -638,17 +767,18 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
638
767
|
}.property(),
|
639
768
|
|
640
769
|
/**
|
641
|
-
Returns true if the view or any of its contained views implements any
|
642
|
-
methods.
|
770
|
+
Returns true if the view or any of its contained views implements any
|
771
|
+
resize methods.
|
643
772
|
|
644
773
|
If this property returns false, changes to your frame view may not be
|
645
|
-
relayed to child methods. This may mean that your various frame
|
646
|
-
become stale unless you call refreshFrames() first.
|
774
|
+
relayed to child methods. This may mean that your various frame
|
775
|
+
properties could become stale unless you call refreshFrames() first.
|
647
776
|
|
648
777
|
If you want you make sure your frames are up to date, see hasManualLayout.
|
649
778
|
|
650
|
-
This property is automatically updated whenever you add or remove a child
|
651
|
-
returns true if you implement any of the resize methods or if
|
779
|
+
This property is automatically updated whenever you add or remove a child
|
780
|
+
view. It returns true if you implement any of the resize methods or if
|
781
|
+
hasManualLayout is true.
|
652
782
|
*/
|
653
783
|
needsFrameChanges: function() {
|
654
784
|
if (this._needsFrameChanges == null) {
|
@@ -665,13 +795,15 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
665
795
|
|
666
796
|
|
667
797
|
/**
|
668
|
-
Returns true if the receiver manages the layout for itself or its
|
798
|
+
Returns true if the receiver manages the layout for itself or its
|
799
|
+
children.
|
669
800
|
|
670
801
|
Normally this property returns true automatically if you implement
|
671
|
-
resizeChildrenWithOldSize() or resizeWithOldParentSize() or
|
802
|
+
resizeChildrenWithOldSize() or resizeWithOldParentSize() or
|
803
|
+
clippingFrameDidChange().
|
672
804
|
|
673
|
-
If you do not implement these methods but need to make sure your frame is
|
674
|
-
anyway, set this property to true.
|
805
|
+
If you do not implement these methods but need to make sure your frame is
|
806
|
+
always up-to-date anyway, set this property to true.
|
675
807
|
*/
|
676
808
|
hasManualLayout: function() {
|
677
809
|
return (this.resizeChildrenWithOldSize != SC.View.prototype.resizeChildrenWithOldSize) ||
|
@@ -680,7 +812,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
680
812
|
}.property(),
|
681
813
|
|
682
814
|
/**
|
683
|
-
Convert a point _from_ the offset parent of the passed view to the current
|
815
|
+
Convert a point _from_ the offset parent of the passed view to the current
|
816
|
+
view.
|
684
817
|
|
685
818
|
This is a useful utility for converting points in the coordinate system of
|
686
819
|
another view to the coordinate system of the receiver. Pass null for
|
@@ -690,7 +823,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
690
823
|
Note that if your view is not visible on the screen, this may not work.
|
691
824
|
|
692
825
|
@param {Point} f The point or frame to convert
|
693
|
-
@param {SC.
|
826
|
+
@param {SC.View} targetView The view to convert from. Pass null to convert from window coordinates.
|
694
827
|
|
695
828
|
@returns {Point} The converted point or frame
|
696
829
|
*/
|
@@ -707,7 +840,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
707
840
|
},
|
708
841
|
|
709
842
|
/**
|
710
|
-
Convert a point _to_ the offset parent of the passed view from the current
|
843
|
+
Convert a point _to_ the offset parent of the passed view from the current
|
844
|
+
view.
|
711
845
|
|
712
846
|
This is a useful utility for converting points in the coordinate system of
|
713
847
|
the receiver to the coordinate system of another view. Pass null for
|
@@ -717,7 +851,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
717
851
|
Note that if your view is not visible on the screen, this may not work.
|
718
852
|
|
719
853
|
@param {Point} f The point or frame to convert
|
720
|
-
@param {SC.
|
854
|
+
@param {SC.View} targetView The view to convert to. Pass null to convert to window coordinates.
|
721
855
|
|
722
856
|
@returns {Point} The converted point or frame
|
723
857
|
*/
|
@@ -740,7 +874,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
740
874
|
@example
|
741
875
|
offsetView = $view(this.get('offsetParent')) ;
|
742
876
|
|
743
|
-
@
|
877
|
+
@field
|
744
878
|
@type {Element}
|
745
879
|
*/
|
746
880
|
offsetParent: function() {
|
@@ -748,11 +882,11 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
748
882
|
}.property(),
|
749
883
|
|
750
884
|
/**
|
751
|
-
The inner bounds for the content shown inside of this frame. Reflects
|
752
|
-
and other properties.
|
885
|
+
The inner bounds for the content shown inside of this frame. Reflects
|
886
|
+
scroll position and other properties.
|
753
887
|
|
754
|
-
The inner frame returns the actual available frame for child elements,
|
755
|
-
or scroll bars.
|
888
|
+
The inner frame returns the actual available frame for child elements,
|
889
|
+
less any borders or scroll bars.
|
756
890
|
|
757
891
|
This value can change when:
|
758
892
|
- the receiver's frame changes
|
@@ -953,111 +1087,6 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
953
1087
|
return this.get('frame') ;
|
954
1088
|
}.property('frame'),
|
955
1089
|
|
956
|
-
/**
|
957
|
-
Style-width for the views rootElement
|
958
|
-
|
959
|
-
Setting this property will also notify of a view frame change.
|
960
|
-
|
961
|
-
@field
|
962
|
-
*/
|
963
|
-
styleWidth: function(key, value) {
|
964
|
-
if (value !== undefined) {
|
965
|
-
this.viewFrameWillChange() ;
|
966
|
-
this.setStyle({ width: ((value != null) ? value+'px' : 'auto') }) ;
|
967
|
-
this.viewFrameDidChange() ;
|
968
|
-
this._styleWidth = null;
|
969
|
-
}
|
970
|
-
|
971
|
-
var ret = this.getStyle('width') ;
|
972
|
-
ret = (ret == 'auto') ? null : parseInt(ret, 0) ;
|
973
|
-
}.property(),
|
974
|
-
|
975
|
-
/**
|
976
|
-
Style-height for the views rootElement
|
977
|
-
|
978
|
-
Setting this property will also notify of a view frame change.
|
979
|
-
|
980
|
-
@field
|
981
|
-
*/
|
982
|
-
styleHeight: function(key, value) {
|
983
|
-
if (value !== undefined) {
|
984
|
-
this.viewFrameWillChange() ;
|
985
|
-
this.setStyle({ height: ((value != null) ? value+'px' : 'auto') }) ;
|
986
|
-
this.viewFrameDidChange() ;
|
987
|
-
}
|
988
|
-
var ret = this.getStyle('height') ;
|
989
|
-
return (ret == 'auto') ? null : parseInt(ret, 0) ;
|
990
|
-
}.property(),
|
991
|
-
|
992
|
-
/**
|
993
|
-
Style-top for the views rootElement
|
994
|
-
|
995
|
-
Setting this property will also notify of a view frame change.
|
996
|
-
|
997
|
-
@field
|
998
|
-
*/
|
999
|
-
styleTop: function(key, value) {
|
1000
|
-
if (value !== undefined) {
|
1001
|
-
this.viewFrameWillChange() ;
|
1002
|
-
this.setStyle({ top: ((value != null) ? value+'px' : 'auto') }) ;
|
1003
|
-
this.viewFrameDidChange() ;
|
1004
|
-
}
|
1005
|
-
var ret = this.getStyle('top') ;
|
1006
|
-
return (ret == 'auto') ? null : parseInt(ret, 0) ;
|
1007
|
-
}.property(),
|
1008
|
-
|
1009
|
-
/**
|
1010
|
-
Style-bottom for the views rootElement
|
1011
|
-
|
1012
|
-
Setting this property will also notify of a view frame change.
|
1013
|
-
|
1014
|
-
@field
|
1015
|
-
*/
|
1016
|
-
styleBottom: function(key, value) {
|
1017
|
-
if (value !== undefined) {
|
1018
|
-
this.viewFrameWillChange() ;
|
1019
|
-
this.setStyle({ bottom: ((value != null) ? value+'px' : 'auto') }) ;
|
1020
|
-
this.viewFrameDidChange() ;
|
1021
|
-
}
|
1022
|
-
var ret = this.getStyle('bottom') ;
|
1023
|
-
return (ret == 'auto') ? null : parseInt(ret, 0) ;
|
1024
|
-
}.property(),
|
1025
|
-
|
1026
|
-
/**
|
1027
|
-
Style-left for the views rootElement
|
1028
|
-
|
1029
|
-
Setting this property will also notify of a view frame change.
|
1030
|
-
|
1031
|
-
@field
|
1032
|
-
*/
|
1033
|
-
styleLeft: function(key, value) {
|
1034
|
-
if (value !== undefined) {
|
1035
|
-
this.viewFrameWillChange() ;
|
1036
|
-
this.setStyle({ left: ((value != null) ? value+'px' : 'auto') }) ;
|
1037
|
-
this.viewFrameDidChange() ;
|
1038
|
-
}
|
1039
|
-
var ret = this.getStyle('left') ;
|
1040
|
-
return (ret == 'auto') ? null : parseInt(ret, 0) ;
|
1041
|
-
}.property(),
|
1042
|
-
|
1043
|
-
/**
|
1044
|
-
Style-right for the views rootElement
|
1045
|
-
|
1046
|
-
Setting this property will also notify of a view frame change.
|
1047
|
-
|
1048
|
-
@field
|
1049
|
-
*/
|
1050
|
-
styleRight: function(key, value) {
|
1051
|
-
if (value !== undefined) {
|
1052
|
-
this.viewFrameWillChange() ;
|
1053
|
-
this.setStyle({ right: ((value != null) ? value+'px' : 'auto') }) ;
|
1054
|
-
this.viewFrameDidChange() ;
|
1055
|
-
}
|
1056
|
-
var ret = this.getStyle('right') ;
|
1057
|
-
return (ret == 'auto') ? null : parseInt(ret, 0) ;
|
1058
|
-
}.property(),
|
1059
|
-
|
1060
|
-
|
1061
1090
|
/**
|
1062
1091
|
Call this method before you make a change that will impact the frame of
|
1063
1092
|
the view such as changing the border thickness or adding/removing a CSS
|
@@ -1084,11 +1113,12 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1084
1113
|
},
|
1085
1114
|
|
1086
1115
|
/**
|
1087
|
-
Call this method just after you finish making changes that will impace the
|
1088
|
-
of the view such as changing the border thickness or adding/removing
|
1116
|
+
Call this method just after you finish making changes that will impace the
|
1117
|
+
frame of the view such as changing the border thickness or adding/removing
|
1118
|
+
a CSS style.
|
1089
1119
|
|
1090
|
-
It is safe to next multiple calls to this method. This method is called
|
1091
|
-
anytime you set the frame.
|
1120
|
+
It is safe to next multiple calls to this method. This method is called
|
1121
|
+
automatically anytime you set the frame.
|
1092
1122
|
|
1093
1123
|
@returns {void}
|
1094
1124
|
*/
|
@@ -1135,9 +1165,10 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1135
1165
|
/**
|
1136
1166
|
Clears any cached frames so the next get will recompute them.
|
1137
1167
|
|
1138
|
-
This method does not notify any observers of changes to the frames. It
|
1139
|
-
only be used when you need to make sure your frame info is up to
|
1140
|
-
not expect anything to have happened that frame observers
|
1168
|
+
This method does not notify any observers of changes to the frames. It
|
1169
|
+
should only be used when you need to make sure your frame info is up to
|
1170
|
+
date but you do not expect anything to have happened that frame observers
|
1171
|
+
would be interested in.
|
1141
1172
|
*/
|
1142
1173
|
recacheFrames: function() {
|
1143
1174
|
this._innerFrame = this._frame = this._clippingFrame = this._scrollFrame = null ;
|
@@ -1146,12 +1177,12 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1146
1177
|
/**
|
1147
1178
|
Set to true if you expect this view to have scrollable content.
|
1148
1179
|
|
1149
|
-
Normally views do not monitor their onscroll event. If you set this
|
1150
|
-
however, the view will observe its onscroll event and
|
1151
|
-
clippedFrame.
|
1180
|
+
Normally views do not monitor their onscroll event. If you set this
|
1181
|
+
property to true, however, the view will observe its onscroll event and
|
1182
|
+
update its scrollFrame and clippedFrame.
|
1152
1183
|
|
1153
|
-
This will also register the view as a scrollable area that can be
|
1154
|
-
a drag/drop event.
|
1184
|
+
This will also register the view as a scrollable area that can be
|
1185
|
+
auto-scrolled during a drag/drop event.
|
1155
1186
|
*/
|
1156
1187
|
isScrollable: false,
|
1157
1188
|
|
@@ -1161,8 +1192,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1161
1192
|
x,y => offset from the innerFrame root.
|
1162
1193
|
width,height => total size of the frame
|
1163
1194
|
|
1164
|
-
If the frame does not have scrollable content, then the size will be equal
|
1165
|
-
innerFrame size.
|
1195
|
+
If the frame does not have scrollable content, then the size will be equal
|
1196
|
+
to the innerFrame size.
|
1166
1197
|
|
1167
1198
|
This frame changes when:
|
1168
1199
|
- the receiver's innerFrame changes
|
@@ -1207,8 +1238,9 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1207
1238
|
/**
|
1208
1239
|
The visible portion of the view.
|
1209
1240
|
|
1210
|
-
Returns the subset of the receivers frame that is actually visible on
|
1211
|
-
This frame is automatically updated whenever one of the following
|
1241
|
+
Returns the subset of the receivers frame that is actually visible on
|
1242
|
+
screen. This frame is automatically updated whenever one of the following
|
1243
|
+
changes:
|
1212
1244
|
|
1213
1245
|
- A parent view is resized
|
1214
1246
|
- A parent view's scrollFrame changes.
|
@@ -1256,14 +1288,16 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1256
1288
|
}.property('frame', 'scrollFrame'),
|
1257
1289
|
|
1258
1290
|
/**
|
1259
|
-
Called whenever the receivers clippingFrame has changed. You can override
|
1260
|
-
method to perform partial rendering or other clippingFrame-dependent
|
1291
|
+
Called whenever the receivers clippingFrame has changed. You can override
|
1292
|
+
this method to perform partial rendering or other clippingFrame-dependent
|
1293
|
+
actions.
|
1261
1294
|
|
1262
|
-
The default implementation does nothing (and may not even be called do to
|
1263
|
-
Note that this is the preferred way to respond to changes
|
1264
|
-
of using an observer since this method is gauranteed
|
1265
|
-
order. You can use observers and bindings as
|
1266
|
-
that need not be handled
|
1295
|
+
The default implementation does nothing (and may not even be called do to
|
1296
|
+
optimizations). Note that this is the preferred way to respond to changes
|
1297
|
+
in the clippingFrame of using an observer since this method is gauranteed
|
1298
|
+
to happen in the correct order. You can use observers and bindings as
|
1299
|
+
well if you wish to handle anything that need not be handled
|
1300
|
+
synchronously.
|
1267
1301
|
*/
|
1268
1302
|
clippingFrameDidChange: function() {
|
1269
1303
|
|
@@ -1274,8 +1308,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1274
1308
|
method to perform your own layout of your child views.
|
1275
1309
|
|
1276
1310
|
If you do not override this method, the view will assume you are using
|
1277
|
-
CSS to layout your child views. As an optimization the view may not
|
1278
|
-
call this method if it determines that you have not overridden it.
|
1311
|
+
CSS to layout your child views. As an optimization the view may not
|
1312
|
+
always call this method if it determines that you have not overridden it.
|
1279
1313
|
|
1280
1314
|
This default version simply calls resizeWithOldParentSize() on all of its
|
1281
1315
|
children.
|
@@ -1308,8 +1342,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1308
1342
|
},
|
1309
1343
|
|
1310
1344
|
/** @private
|
1311
|
-
Handler for the onscroll event. Hooked in on init if isScrollable is
|
1312
|
-
Notify children that their clipping frame has changed.
|
1345
|
+
Handler for the onscroll event. Hooked in on init if isScrollable is
|
1346
|
+
true. Notify children that their clipping frame has changed.
|
1313
1347
|
*/
|
1314
1348
|
_onscroll: function() {
|
1315
1349
|
this._scrollFrame = null ;
|
@@ -1322,9 +1356,9 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1322
1356
|
_frameChangeLevel: 0,
|
1323
1357
|
|
1324
1358
|
/** @private
|
1325
|
-
Used internally to collect client offset and location info. If the
|
1326
|
-
not in the main window or hidden, it will be added temporarily
|
1327
|
-
function will be called.
|
1359
|
+
Used internally to collect client offset and location info. If the
|
1360
|
+
element is not in the main window or hidden, it will be added temporarily
|
1361
|
+
and then the passed function will be called.
|
1328
1362
|
*/
|
1329
1363
|
_collectFrame: function(func) {
|
1330
1364
|
var el = this.rootElement ;
|
@@ -1335,6 +1369,8 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1335
1369
|
var isVisibleInWindow = this.get('isVisibleInWindow') ;
|
1336
1370
|
if (!isVisibleInWindow) {
|
1337
1371
|
var pn = el.parentNode || el ;
|
1372
|
+
if (pn === SC.window.rootElement) pn = el ;
|
1373
|
+
|
1338
1374
|
var pnParent = pn.parentNode ; // cache former parent node
|
1339
1375
|
var pnSib = pn.nextSibling ; // cache next sibling
|
1340
1376
|
SC.window.rootElement.insertBefore(pn, null) ;
|
@@ -1410,19 +1446,19 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1410
1446
|
//
|
1411
1447
|
|
1412
1448
|
/**
|
1413
|
-
|
1449
|
+
Used to show or hide the view.
|
1414
1450
|
|
1415
|
-
If
|
1416
|
-
often want to bind this property to some setting
|
1417
|
-
to make various parts of your app visible as needed.
|
1451
|
+
If this property is set to NO, then the DOM element will be hidden using
|
1452
|
+
display:none. You will often want to bind this property to some setting
|
1453
|
+
in your application to make various parts of your app visible as needed.
|
1418
1454
|
|
1419
1455
|
If you have animation enabled, then changing this property will actually
|
1420
1456
|
trigger the animation to bring the view in or out.
|
1421
1457
|
|
1422
1458
|
The default binding format is SC.Binding.Bool
|
1423
1459
|
|
1424
|
-
@
|
1425
|
-
@type Boolean
|
1460
|
+
@field
|
1461
|
+
@type {Boolean}
|
1426
1462
|
*/
|
1427
1463
|
isVisible: true,
|
1428
1464
|
|
@@ -1448,15 +1484,15 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1448
1484
|
is visible.
|
1449
1485
|
|
1450
1486
|
@type {Boolean}
|
1451
|
-
@
|
1487
|
+
@field
|
1452
1488
|
*/
|
1453
|
-
isVisibleInWindow:
|
1489
|
+
isVisibleInWindow: NO,
|
1454
1490
|
|
1455
1491
|
/**
|
1456
1492
|
If true, the tooltip will be localized. Also used by some subclasses.
|
1457
1493
|
|
1458
1494
|
@type {Boolean}
|
1459
|
-
@
|
1495
|
+
@field
|
1460
1496
|
*/
|
1461
1497
|
localize: false,
|
1462
1498
|
|
@@ -1466,7 +1502,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1466
1502
|
If localize is true, then the toolTip will be localized first.
|
1467
1503
|
|
1468
1504
|
@type {String}
|
1469
|
-
@
|
1505
|
+
@field
|
1470
1506
|
*/
|
1471
1507
|
toolTip: '',
|
1472
1508
|
|
@@ -1477,15 +1513,15 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1477
1513
|
You can specify the HTML as a string of text, using the NodeDescriptor, or
|
1478
1514
|
by pointing directly to an element.
|
1479
1515
|
|
1480
|
-
Note that as an optimization, SC.View will actually convert the value of
|
1481
|
-
property to an actual DOM structure the first time you create a view
|
1482
|
-
clone the DOM structure for future views.
|
1516
|
+
Note that as an optimization, SC.View will actually convert the value of
|
1517
|
+
this property to an actual DOM structure the first time you create a view
|
1518
|
+
and then clone the DOM structure for future views.
|
1483
1519
|
|
1484
|
-
This means that in general you should only set the value of emptyElement
|
1485
|
-
you create a view subclass. Changing this property value at other
|
1486
|
-
often have no effect.
|
1520
|
+
This means that in general you should only set the value of emptyElement
|
1521
|
+
when you create a view subclass. Changing this property value at other
|
1522
|
+
times will often have no effect.
|
1487
1523
|
|
1488
|
-
@
|
1524
|
+
@field
|
1489
1525
|
@type {String}
|
1490
1526
|
*/
|
1491
1527
|
emptyElement: "<div></div>",
|
@@ -1493,7 +1529,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1493
1529
|
/**
|
1494
1530
|
If true, view will display in a lightbox when you show it.
|
1495
1531
|
|
1496
|
-
@
|
1532
|
+
@field
|
1497
1533
|
@type {Boolean}
|
1498
1534
|
*/
|
1499
1535
|
isPanel: false,
|
@@ -1501,7 +1537,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1501
1537
|
/**
|
1502
1538
|
If true, the view should be modal when shown as a panel.
|
1503
1539
|
|
1504
|
-
@
|
1540
|
+
@field
|
1505
1541
|
@type {Boolean}
|
1506
1542
|
*/
|
1507
1543
|
isModal: true,
|
@@ -1615,7 +1651,7 @@ SC.View = SC.Responder.extend(SC.PathModule, SC.DelegateSupport,
|
|
1615
1651
|
if(toolTip && (toolTip != '')) this._updateToolTipObserver();
|
1616
1652
|
|
1617
1653
|
// if container element is a string, convert it to an actual DOM element.
|
1618
|
-
if (this.containerElement && ($type(this.containerElement)
|
1654
|
+
if (this.containerElement && ($type(this.containerElement) === T_STRING)) {
|
1619
1655
|
this.containerElement = this.$sel(this.containerElement);
|
1620
1656
|
}
|
1621
1657
|
|
@@ -2049,12 +2085,17 @@ SC.View.mixin({
|
|
2049
2085
|
} ;
|
2050
2086
|
func.isOutlet = true ;
|
2051
2087
|
return func ;
|
2052
|
-
}
|
2088
|
+
},
|
2089
|
+
|
2090
|
+
automaticOutletFor: function() {
|
2091
|
+
var ret = this.outletFor.apply(this, arguments) ;
|
2092
|
+
ret.autoconfiguredOutlet = YES ;
|
2093
|
+
return ret ;
|
2094
|
+
}
|
2053
2095
|
|
2054
2096
|
}) ;
|
2055
2097
|
|
2056
2098
|
// IE Specfic Overrides
|
2057
|
-
console.log('SC.Platform.IE = %@'.fmt(SC.Platform.IE));
|
2058
2099
|
if (SC.Platform.IE) {
|
2059
2100
|
SC.View.prototype.getStyle = function(style) {
|
2060
2101
|
var element = this.rootElement ;
|