Skip to content

Commit

Permalink
Move a few more things out of view.js into constituent parts
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Feb 3, 2011
1 parent 987b9d0 commit c3b4d2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
11 changes: 10 additions & 1 deletion frameworks/amber/views/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,5 +1126,14 @@ SC.View.mixin(
*/
convertLayoutToCustomLayout: function(layout, layoutParams, parentFrame){
// TODO: [EG] Create Top/Left/Width/Height to a Custom Layout conversion
}
},

applyAttributesToContext: function(original, context) {
original(context);

if (this.get('useStaticLayout')) { context.addClass('sc-static-layout'); }
if (this.get('backgroundColor')) {
context.css('backgroundColor', this.get('backgroundColor'));
}
}.enhance()
});
7 changes: 7 additions & 0 deletions frameworks/amber/views/theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ SC.View.reopen(
},

applyAttributesToContext: function(original, context) {
var theme = this.get('theme');
var themeClassNames = theme.classNames, idx, len = themeClassNames.length;

for (idx = 0; idx < len; idx++) {
context.addClass(themeClassNames[idx]);
}

original(context);

var renderDelegate = this.get('renderDelegate');
Expand Down
23 changes: 6 additions & 17 deletions frameworks/amber/views/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ SC.View.reopen(
// For historical reasons, we'll also layout the child views if
// necessary.
if (current) {
if (this.get('childViewsNeedLayout')) this.invokeOnce(this.layoutChildViewsIfNeeded);
if (this.get('childViewsNeedLayout')) { this.invokeOnce(this.layoutChildViewsIfNeeded); }
}
else {
// Also, if we were previously visible and were the first responder,
Expand All @@ -203,7 +203,7 @@ SC.View.reopen(
// this work is not strictly related to computing the visibility, but
// view performance is critical, so avoiding the extra observer is
// worthwhile.
if (this.get('isFirstResponder')) this.resignFirstResponder();
if (this.get('isFirstResponder')) { this.resignFirstResponder(); }
}
}

Expand Down Expand Up @@ -770,28 +770,17 @@ SC.View.reopen(
},

applyAttributesToContext: function(context) {
var theme = this.get('theme');
var themeClassNames = theme.classNames, idx, len = themeClassNames.length;

for (idx = 0; idx < len; idx++) {
context.addClass(themeClassNames[idx]);
}

context.addClass(this.get('classNames'));

var cursor = this.get('cursor');
if (cursor) context.addClass(cursor.get('className'));
if (cursor) { context.addClass(cursor.get('className')); }

if (this.get('isTextSelectable')) context.addClass('allow-select');
if (!this.get('isVisible')) context.addClass('hidden');
if (this.get('isFirstResponder')) context.addClass('focus');
if (this.get('useStaticLayout')) context.addClass('sc-static-layout');
if (this.get('isTextSelectable')) { context.addClass('allow-select'); }
if (!this.get('isVisible')) { context.addClass('hidden'); }
if (this.get('isFirstResponder')) { context.addClass('focus'); }

context.id(this.get('layerId'));
context.attr('role', this.get('ariaRole'));
if (this.get('backgroundColor')) {
context.css('backgroundColor', this.get('backgroundColor'));
}
},

/**
Expand Down

0 comments on commit c3b4d2a

Please sign in to comment.