Skip to content

Commit

Permalink
documentation for core ui kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Feb 29, 2012
1 parent a0c1c3c commit 248e1a4
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 21 deletions.
6 changes: 6 additions & 0 deletions source/ui/Button.js
@@ -1,10 +1,16 @@
/**
Implements an HTML button, with support for grouping
*/
enyo.kind({ enyo.kind({
name: "enyo.Button", name: "enyo.Button",
//* @protected
kind: enyo.ToolDecorator, kind: enyo.ToolDecorator,
tag: "Button", tag: "Button",
//* @public
published: { published: {
disabled: false disabled: false
}, },
//* @protected
create: function() { create: function() {
this.inherited(arguments); this.inherited(arguments);
this.disabledChanged(); this.disabledChanged();
Expand Down
8 changes: 8 additions & 0 deletions source/ui/Checkbox.js
@@ -1,16 +1,24 @@
/**
Implements an HTML checkbox input, with support for grouping
*/
enyo.kind({ enyo.kind({
name: "enyo.Checkbox", name: "enyo.Checkbox",
//* @protected
kind: enyo.Input, kind: enyo.Input,
attributes: { attributes: {
type: "checkbox" type: "checkbox"
}, },
events: { events: {
onActivate: "" onActivate: ""
}, },
//* @public
published: { published: {
//* Value of the checkbox
checked: false, checked: false,
//* Group API requirement for determining selected item
active: false active: false
}, },
//* @protected
handlers: { handlers: {
onchange: "change", onchange: "change",
onclick: "click" onclick: "click"
Expand Down
11 changes: 7 additions & 4 deletions source/ui/Group.js
@@ -1,15 +1,18 @@
/**
Provides a wrapper around multiple elements. Enables creation of radio groups from arbitrary components supporting the [GroupItem](#enyo.GroupItem) api.
*/
enyo.kind({ enyo.kind({
name: "enyo.Group", name: "enyo.Group",
published: { published: {
//* Can there be only one?
highlander: true, highlander: true,
//* The control that is selected
active: null active: null
}, },
//* @protected
handlers: { handlers: {
onActivate: "activate" onActivate: "activate"
}, },
create: function() {
this.inherited(arguments);
},
activate: function(inSender, inEvent) { activate: function(inSender, inEvent) {
if (this.highlander) { if (this.highlander) {
// deactivation messages are ignored unless it's an attempt // deactivation messages are ignored unless it's an attempt
Expand All @@ -35,4 +38,4 @@ enyo.kind({
this.active.addClass("active"); this.active.addClass("active");
} }
} }
}); });
4 changes: 3 additions & 1 deletion source/ui/GroupItem.js
@@ -1,13 +1,15 @@
//* Base kind for the Grouping api
enyo.kind({ enyo.kind({
name: "enyo.GroupItem", name: "enyo.GroupItem",
published: { published: {
active: false active: false
}, },
//* @protected
create: function() { create: function() {
this.inherited(arguments); this.inherited(arguments);
this.activeChanged(); this.activeChanged();
}, },
activeChanged: function() { activeChanged: function() {
this.bubble("onActivate"); this.bubble("onActivate");
} }
}); });
4 changes: 4 additions & 0 deletions source/ui/Image.js
@@ -1,5 +1,9 @@
/**
Implements an HTML img element, and bubbles the onload, and onerror events
*/
enyo.kind({ enyo.kind({
name: "Image", name: "Image",
//* @protected
tag: "img", tag: "img",
attributes: { attributes: {
onload: enyo.bubbler, onload: enyo.bubbler,
Expand Down
8 changes: 8 additions & 0 deletions source/ui/Input.js
@@ -1,14 +1,22 @@
/**
Implements an HTML input element with cross platform support for change events
*/
enyo.kind({ enyo.kind({
name: "enyo.Input", name: "enyo.Input",
published: { published: {
//* Default value of the input
value: "", value: "",
//* Text to display when the input is empty
placeholder: "", placeholder: "",
disabled: false disabled: false
}, },
events: { events: {
//* Sent when the input's value has changed, support for IE included.
onInputChange: "", onInputChange: "",
//* Sent when the input's is disabled or enabled.
onDisabledChange: "" onDisabledChange: ""
}, },
//* @protected
tag: "input", tag: "input",
classes: "enyo-input", classes: "enyo-input",
attributes: { attributes: {
Expand Down
5 changes: 4 additions & 1 deletion source/ui/NoDom.js
@@ -1,6 +1,9 @@
/**
A control that returns as its components HTML as its own.
*/
enyo.kind({ enyo.kind({
name: "enyo.NoDom", name: "enyo.NoDom",
generateOuterHtml: function(inHtml) { generateOuterHtml: function(inHtml) {
return inHtml; return inHtml;
} }
}); });
38 changes: 23 additions & 15 deletions source/ui/Repeater.js
@@ -1,37 +1,45 @@
enyo.kind({ /**
A simple control for making lists of items.
Components of Repeater are copied for each row created, wrapped in a control keeping state of the row index.
Example:
{kind: "Repeater", rows: 2, onSetupRow: "setImageSource", components: [
{kind: "Image"}
]}
setImageSource: function(inSender, inEvent) {
var index = inEvent.index;
var rowControl = inEvent.row;
rowControl.$.image.setSrc(this.imageSources[index]);
}
*/
enyo.kind({
name: "enyo.Repeater", name: "enyo.Repeater",
kind: enyo.Control, kind: enyo.Control,
published: { published: {
//* How many rows to render
rows: 0 rows: 0
}, },
events: { events: {
//* Sends the row index, and the row control, for decoration
onSetupRow: "" onSetupRow: ""
}, },
//* @protected
initComponents: function() { initComponents: function() {
this.rowComponents = this.components; this.rowComponents = this.components;
this.components = null; this.components = null;
this.inherited(arguments); this.inherited(arguments);
}, },
//* @protected //* @public
generateInnerHtml: function() { //* Render the list
//this.build();
return this.inherited(arguments);
},
build: function() { build: function() {
this.destroyClientControls(); this.destroyClientControls();
for (var i=0; i<this.rows; i++) { for (var i=0; i<this.rows; i++) {
var c = this.createComponent({kind: "NoDom", rowIndex: i}); var c = this.createComponent({kind: "NoDom", rowIndex: i});
c.createComponents(this.rowComponents); c.createComponents(this.rowComponents);
this.doSetupRow({index: i, row: c}); this.doSetupRow({index: i, row: c});
} }
},
XdispatchEvent: function(inEventName, inEvent, inSender) {
if (inSender && inSender.owner == this) {
var delegate = inEvent.originator[inEventName];
if (delegate && this.dispatch(this.owner, delegate, inEvent, inSender)) {
return true;
}
}
return this.inherited(arguments);
} }
}); });
2 changes: 2 additions & 0 deletions source/ui/ToolDecorator.js
@@ -1,5 +1,7 @@
//* Lines up components in a row, centered vertically
enyo.kind({ enyo.kind({
name: "enyo.ToolDecorator", name: "enyo.ToolDecorator",
//* @protected
kind: enyo.GroupItem, kind: enyo.GroupItem,
classes: "enyo-tool-decorator" classes: "enyo-tool-decorator"
}); });

0 comments on commit 248e1a4

Please sign in to comment.