Skip to content

Commit

Permalink
ENYO-872: made undocumented methods protected
Browse files Browse the repository at this point in the history
ENYO-873: documented getNodeProperty, setNodeProperty, getComputedStyleValue;
made other undocumented methods protected
cleaned up some JSHint issues for better style

Enyo-DCO-1.0-Signed-off-by: Ben Combee (ben.combee@palm.com)
  • Loading branch information
unwiredben committed Aug 24, 2012
1 parent b5ba4ea commit a5e14d8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
49 changes: 33 additions & 16 deletions source/dom/Control.js
Expand Up @@ -93,7 +93,7 @@ enyo.kind({
},
initProps: function(inPropNames) {
// for each named property, trigger the *Changed handler if the property value is truthy
for (var i=0, n, cf; n=inPropNames[i]; i++) {
for (var i=0, n, cf; (n=inPropNames[i]); i++) {
if (this[n]) {
// FIXME: awkward
cf = n + "Changed";
Expand Down Expand Up @@ -196,13 +196,23 @@ enyo.kind({
}
this.invalidateTags();
},
/**
Get the value of a property named _inName_ directly from the DOM node, with a
caller-specified default value, _inDefault_, returned when the DOM node has not
yet been created.
*/
getNodeProperty: function(inName, inDefault) {
if (this.hasNode()) {
return this.node[inName];
} else {
return inDefault;
}
},
/**
Set the propery _inName_ on the control's DOM node using value _inValue_
if and only if the DOM node has been rendered. This method does not alter
any value cached in local properties of the enyo.Control instance.
*/
setNodeProperty: function(inName, inValue) {
if (this.hasNode()) {
this.node[inName] = inValue;
Expand Down Expand Up @@ -286,6 +296,7 @@ enyo.kind({
//
// styles
//
//* @protected
initStyles: function() {
this.domStyles = this.domStyles || {};
enyo.Control.cssTextToDomStyles(this.kindStyle, this.domStyles);
Expand All @@ -307,6 +318,7 @@ enyo.kind({
this.invalidateTags();
this.renderStyles();
},
//* @public
/**
Applies a single style value to this object.
Expand All @@ -331,6 +343,12 @@ enyo.kind({
enyo.Control.cssTextToDomStyles(inCssText, this.domStyles);
this.domStylesChanged();
},
/**
Return the computed value of a CSS style named from _inStyle_
for the DOM node of the enyo.Control. If the node hasn't been generated,
return _inDefault_ as a default value. This uses JS style property
names, not CSS style, so use "fontFamily" instead of "font-family".
*/
getComputedStyleValue: function(inStyle, inDefault) {
if (this.hasNode()) {
return enyo.dom.getComputedStyleValue(this.node, inStyle);
Expand All @@ -346,6 +364,10 @@ enyo.kind({
stylesToNode: function() {
this.node.style.cssText = this.style + (this.style[this.style.length-1] == ';' ? ' ' : '; ') + this.domCssText;
},
setupBodyFitting: function() {
enyo.dom.applyBodyFit();
this.addClass("enyo-fit enyo-clip");
},
//
//
//* @public
Expand Down Expand Up @@ -414,10 +436,6 @@ enyo.kind({
// support method chaining
return this;
},
setupBodyFitting: function() {
enyo.dom.applyBodyFit();
this.addClass("enyo-fit enyo-clip");
},
/**
Override this method to perform tasks that require access to the DOM node.
Expand All @@ -430,7 +448,7 @@ enyo.kind({
// CAVEAT: Currently we use one entry point ('reflow') for
// post-render layout work *and* post-resize layout work.
this.reflow();
for (var i=0, c; c=this.children[i]; i++) {
for (var i=0, c; (c=this.children[i]); i++) {
c.rendered();
}
},
Expand Down Expand Up @@ -472,7 +490,7 @@ enyo.kind({
setBounds: function(inBounds, inUnit) {
var s = this.domStyles, unit = inUnit || "px";
var extents = ["width", "height", "left", "top", "right", "bottom"];
for (var i=0, b, e; e=extents[i]; i++) {
for (var i=0, b, e; (e=extents[i]); i++) {
b = inBounds[e];
if (b || b === 0) {
s[e] = b + (!enyo.isString(b) ? unit : '');
Expand Down Expand Up @@ -543,7 +561,7 @@ enyo.kind({
},
generateChildHtml: function() {
var results = '';
for (var i=0, c; c=this.children[i]; i++) {
for (var i=0, c; (c=this.children[i]); i++) {
var h = c.generateHtml();
if (c.prepend) {
// FIXME: does webkit's fast string-consing work in reverse?
Expand All @@ -568,11 +586,10 @@ enyo.kind({
},
prepareTags: function() {
var htmlStyle = this.domCssText + this.style;
this._openTag = '<'
+ this.tag
+ (htmlStyle ? ' style="' + htmlStyle + '"' : "")
+ enyo.Control.attributesToHtml(this.attributes)
;
this._openTag = '<' +
this.tag +
(htmlStyle ? ' style="' + htmlStyle + '"' : "") +
enyo.Control.attributesToHtml(this.attributes);
if (enyo.Control.selfClosing[this.tag]) {
this._openTag += '/>';
this._closeTag = '';
Expand Down Expand Up @@ -625,7 +642,7 @@ enyo.kind({
this.generated = false;
},
teardownChildren: function() {
for (var i=0, c; c=this.children[i]; i++) {
for (var i=0, c; (c=this.children[i]); i++) {
c.teardownRender();
}
},
Expand Down Expand Up @@ -718,7 +735,7 @@ enyo.kind({
// remove spaces between rules, then split rules on delimiter (;)
var rules = inText.replace(/; /g, ";").split(";");
// parse string styles into name/value pairs
for (var i=0, s, n, v, rule; rule=rules[i]; i++) {
for (var i=0, s, n, v, rule; (rule=rules[i]); i++) {
// "background-image: url(http://foo.com/foo.png)" => ["background-image", "url(http", "//foo.com/foo.png)"]
s = rule.split(":");
// n = "background-image", s = ["url(http", "//foo.com/foo.png)"]
Expand Down Expand Up @@ -802,4 +819,4 @@ enyo.Control.subclass = function(ctor, props) {
proto.kindAttributes = enyo.mixin(enyo.clone(ka), proto.attributes);
proto.attributes = null;
}
};
};
19 changes: 11 additions & 8 deletions source/kernel/Component.js
Expand Up @@ -146,6 +146,7 @@ enyo.kind({
}
});
},
//* @protected
makeId: function() {
var delim = "_", pre = this.owner && this.owner.getId();
return this.name ? (pre ? pre + delim : "") + this.name : "";
Expand Down Expand Up @@ -175,6 +176,7 @@ enyo.kind({
// set and return
return inComponent.name = n;
},
//* @public
/**
Adds _inComponent_ to the list of components owned by the current
component (i.e., _this.$_).
Expand Down Expand Up @@ -309,14 +311,6 @@ enyo.kind({
}
return this.dispatchBubble(inEventName, e, inSender);
},
dispatchBubble: function(inEventName, inEvent, inSender) {
// Try to dispatch from here, stop bubbling on truthy return value
if (this.dispatchEvent(inEventName, inEvent, inSender)) {
return true;
}
// Bubble to next target
return this.bubbleUp(inEventName, inEvent, inSender);
},
/**
Bubbles an event up an object chain, starting <b>above</b> _this_.
Expand Down Expand Up @@ -375,6 +369,15 @@ enyo.kind({
return this.bubbleDelegation(this.owner, this[inEventName], inEventName, inEvent, this);
}
},
// internal - try dispatching event to self, if that fails bubble it up the tree
dispatchBubble: function(inEventName, inEvent, inSender) {
// Try to dispatch from here, stop bubbling on truthy return value
if (this.dispatchEvent(inEventName, inEvent, inSender)) {
return true;
}
// Bubble to next target
return this.bubbleUp(inEventName, inEvent, inSender);
},
decorateEvent: function(inEventName, inEvent, inSender) {
// an event may float by us as part of a dispatchEvent chain or delegateEvent
// both call this method so intermediaries can decorate inEvent
Expand Down

0 comments on commit a5e14d8

Please sign in to comment.