Commit 8ad56184 authored by asudoh's avatar asudoh

Simplified app template.

parent 0c824957
...@@ -2,11 +2,12 @@ define([ ...@@ -2,11 +2,12 @@ define([
"dojo/_base/array", "dojo/_base/array",
"dojo/_base/declare", "dojo/_base/declare",
"dojo/_base/lang", "dojo/_base/lang",
"dojo/dom-class" "dojo/dom-class",
], function(array, declare, lang, domClass){ "dijit/_WidgetBase"
return declare(null, { ], function(array, declare, lang, domClass, _WidgetBase){
return declare(_WidgetBase, {
// summary: // summary:
// Mixin class to support widget attributes with classExists type. // Widget supporting widget attributes with classExists type.
// classExists type allows boolean value of an attribute to reflect existence of a CSS class in a DOM node in the widget. // classExists type allows boolean value of an attribute to reflect existence of a CSS class in a DOM node in the widget.
// example: // example:
// In this example, the text will be bold when the check box is checked. // In this example, the text will be bold when the check box is checked.
...@@ -25,8 +26,7 @@ define([ ...@@ -25,8 +26,7 @@ define([
// | <body> // | <body>
// | <script type="dojo/require">at: "dojox/mvc/at"</script> // | <script type="dojo/require">at: "dojox/mvc/at"</script>
// | <input id="checkbox" data-dojo-type="dijit/form/CheckBox"> // | <input id="checkbox" data-dojo-type="dijit/form/CheckBox">
// | <div data-dojo-type="dijit/_WidgetBase" // | <div data-dojo-type="todo/CssToggleWidget"
// | data-dojo-mixins="todo/_CssToggleMixin"
// | data-dojo-props="_setBoldAttr: {type: 'classExists', className: 'boldText'}, // | data-dojo-props="_setBoldAttr: {type: 'classExists', className: 'boldText'},
// | bold: at('widget:checkbox', 'checked')">This text will be bold when above check box is checked.</div> // | bold: at('widget:checkbox', 'checked')">This text will be bold when above check box is checked.</div>
// | </body> // | </body>
......
define([
"dojo/_base/declare",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojox/mvc/WidgetList",
"dojox/mvc/_InlineTemplateMixin",
"todo/CssToggleWidget",
"todo/ctrl/_HashCompletedMixin"
], function(declare, _TemplatedMixin, _WidgetsInTemplateMixin, WidgetList, _InlineTemplateMixin, CssToggleWidget, _HashCompletedMixin){
return declare([WidgetList, _InlineTemplateMixin], {
childClz: declare([CssToggleWidget, _TemplatedMixin, _WidgetsInTemplateMixin, _HashCompletedMixin], {
_setCompletedAttr: {type: "classExists", className: "completed"},
_setHiddenAttr: {type: "classExists", className: "hidden"},
onRemoveClick: function(){
this.parent.listCtrl.removeItem(this.uniqueId);
},
onEditBoxChange: function(){
if(!this.editBox.value){
this.parent.listCtrl.removeItem(this.uniqueId);
}
}
})
});
});
...@@ -4,19 +4,16 @@ define([ ...@@ -4,19 +4,16 @@ define([
"dojo/_base/unload", "dojo/_base/unload",
"dojo/keys", "dojo/keys",
"dojo/string", "dojo/string",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin", "dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin", "dijit/_WidgetsInTemplateMixin",
"todo/_CssToggleMixin", "todo/CssToggleWidget",
"dojo/text!./app18.html", "dojo/text!./app18.html",
// Below modules are referred in template. // Below modules are referred in template.
// dijit/_WidgetsInTemplateMixin requires all modules referred in template to have been loaded before it's instantiated. // dijit/_WidgetsInTemplateMixin requires all modules referred in template to have been loaded before it's instantiated.
"dijit/form/CheckBox", "dijit/form/CheckBox",
"dijit/form/TextBox", "dijit/form/TextBox",
"dojox/mvc/at", "dojox/mvc/at",
"dojox/mvc/_InlineTemplateMixin", "todo/TodoList",
"dojox/mvc/WidgetList",
"todo/ctrl/_HashCompletedMixin",
"todo/ctrl/RouteController", "todo/ctrl/RouteController",
"todo/ctrl/TodoListRefController", "todo/ctrl/TodoListRefController",
"todo/ctrl/TodoRefController", "todo/ctrl/TodoRefController",
...@@ -25,22 +22,22 @@ define([ ...@@ -25,22 +22,22 @@ define([
"todo/misc/LessThanOrEqualToConverter", "todo/misc/LessThanOrEqualToConverter",
"todo/model/SimpleTodoModel", "todo/model/SimpleTodoModel",
"todo/store/LocalStorage" "todo/store/LocalStorage"
], function(declare, lang, unload, keys, string, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _CssToggleMixin, template){ ], function(declare, lang, unload, keys, string, _TemplatedMixin, _WidgetsInTemplateMixin, CssToggleWidget, template){
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _CssToggleMixin], { return declare([CssToggleWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
// summary: // summary:
// A widgets-in-template widget that composes the application UI of TodoMVC (Dojo 1.8 version). // A widgets-in-template widget that composes the application UI of TodoMVC (Dojo 1.8 version).
// Also, this class inherits todo/_CssToggleMixin so that it can react to change in "present"/"complete" attributes and add/remove CSS class to the root DOM node of this widget. // Also, this class inherits todo/CssToggleWidget so that it can react to change in "present"/"complete" attributes and add/remove CSS class to the root DOM node of this widget.
// templateString: String // templateString: String
// The HTML of widget template. // The HTML of widget template.
templateString: template, templateString: template,
// _setPresentAttr: Object // _setPresentAttr: Object
// A object used by todo/_CssToggleMixin to reflect true/false state of "present" attribute to existence of "todos_present" CSS class in this widget's root DOM. // A object used by todo/CssToggleWidget to reflect true/false state of "present" attribute to existence of "todos_present" CSS class in this widget's root DOM.
_setPresentAttr: {type: "classExists", className: "todos_present"}, _setPresentAttr: {type: "classExists", className: "todos_present"},
// _setCompleteAttr: Object // _setCompleteAttr: Object
// A object used by todo/_CssToggleMixin to reflect true/false state of "complete" attribute to existence of "todos_selected" CSS class in this widget's root DOM. // A object used by todo/CssToggleWidget to reflect true/false state of "complete" attribute to existence of "todos_selected" CSS class in this widget's root DOM.
_setCompleteAttr: {type: "classExists", className: "todos_selected"}, _setCompleteAttr: {type: "classExists", className: "todos_selected"},
startup: function(){ startup: function(){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment