Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for adding and deleting todo items

Initial setup of Dojo 1.7, using DojoX MVC to bind between a stateful
model and UI elements. Use dojox.mvc.Repeat to render model items as
a series of list items.
  • Loading branch information...
commit d2bd11298aca399c2de10b3a20e99abb99823f77 1 parent 04c1756
James Thomas authored
View
4 todo-example/dojo/TODO
@@ -0,0 +1,4 @@
+- Support local storage using custom Dojo Store
+- Editing of existing todos
+- Allow checking of completed items
+- Use local Dojo JS version
View
BIN  todo-example/dojo/css/destroy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
532 todo-example/dojo/css/todos.css
@@ -0,0 +1,532 @@
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-weight: inherit;
+ font-style: inherit;
+ font-size: 100%;
+ font-family: inherit;
+ vertical-align: baseline;
+}
+body {
+ line-height: 1;
+ color: black;
+ background: white;
+}
+ol, ul {
+ list-style: none;
+}
+a img {
+ border: none;
+}
+
+html {
+ background: #eeeeee;
+}
+body {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ line-height: 1.4em;
+ background: #eeeeee;
+ color: #333333;
+}
+
+#todoapp {
+ width: 480px;
+ margin: 0 auto 40px;
+ background: white;
+ padding: 20px;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0;
+}
+#todoapp h1 {
+ font-size: 36px;
+ font-weight: bold;
+ text-align: center;
+ padding: 20px 0 30px 0;
+ line-height: 1;
+}
+
+#create-todo {
+ position: relative;
+}
+#create-todo input {
+ width: 466px;
+ font-size: 24px;
+ font-family: inherit;
+ line-height: 1.4em;
+ border: 0;
+ outline: none;
+ padding: 6px;
+ border: 1px solid #999999;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+}
+
+#create-todo span {
+ position: absolute;
+ z-index: 999;
+ width: 170px;
+ left: 50%;
+ margin-left: -85px;
+}
+
+#todo-list {
+ margin-top: 10px;
+}
+#todo-list li {
+ padding: 12px 20px 11px 0;
+ position: relative;
+ font-size: 24px;
+ line-height: 1.1em;
+ border-bottom: 1px solid #cccccc;
+}
+#todo-list li:after {
+ content: "\0020";
+ display: block;
+ height: 0;
+ clear: both;
+ overflow: hidden;
+ visibility: hidden;
+}
+#todo-list li.editing {
+ padding: 0;
+ border-bottom: 0;
+}
+#todo-list .editing .display,
+#todo-list .edit {
+ display: none;
+}
+#todo-list .editing .edit {
+ display: block;
+}
+#todo-list .editing input {
+ width: 444px;
+ font-size: 24px;
+ font-family: inherit;
+ margin: 0;
+ line-height: 1.6em;
+ border: 0;
+ outline: none;
+ padding: 10px 7px 0px 27px;
+ border: 1px solid #999999;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+}
+#todo-list .check {
+ position: relative;
+ top: 9px;
+ margin: 0 10px 0 7px;
+ float: left;
+}
+#todo-list .done .todo-content {
+ text-decoration: line-through;
+ color: #777777;
+}
+#todo-list .todo-destroy {
+ position: absolute;
+ right: 5px;
+ top: 14px;
+ display: none;
+ cursor: pointer;
+ width: 20px;
+ height: 20px;
+ background: url(destroy.png) no-repeat 0 0;
+}
+#todo-list li:hover .todo-destroy {
+ display: block;
+}
+#todo-list .todo-destroy:hover {
+ background-position: 0 -20px;
+}
+
+#todo-stats {
+ *zoom: 1;
+ margin-top: 10px;
+ color: #777777;
+}
+#todo-stats:after {
+ content: "\0020";
+ display: block;
+ height: 0;
+ clear: both;
+ overflow: hidden;
+ visibility: hidden;
+}
+#todo-stats .todo-count {
+ float: left;
+}
+#todo-stats .todo-count .number {
+ font-weight: bold;
+ color: #333333;
+}
+#todo-stats .todo-clear {
+ float: right;
+}
+#todo-stats .todo-clear a {
+ color: #777777;
+ font-size: 12px;
+}
+#todo-stats .todo-clear a:visited {
+ color: #777777;
+}
+#todo-stats .todo-clear a:hover {
+ color: #336699;
+}
+
+#instructions {
+ width: 520px;
+ margin: 10px auto;
+ color: #777777;
+ text-shadow: rgba(255, 255, 255, 0.8) 0 1px 0;
+ text-align: center;
+}
+#instructions a {
+ color: #336699;
+}
+
+#credits {
+ width: 520px;
+ margin: 30px auto;
+ color: #999;
+ text-shadow: rgba(255, 255, 255, 0.8) 0 1px 0;
+ text-align: center;
+}
+#credits a {
+ color: #888;
+}
+
+
+/*
+* François 'cahnory' Germain
+*/
+.ui-tooltip, .ui-tooltip-top, .ui-tooltip-right, .ui-tooltip-bottom, .ui-tooltip-left {
+ color:#ffffff;
+ cursor:normal;
+ display:-moz-inline-stack;
+ display:inline-block;
+ font-size:12px;
+ font-family:arial;
+ padding:.5em 1em;
+ position:relative;
+ text-align:center;
+ text-shadow:0 -1px 1px #111111;
+ -webkit-border-top-left-radius:4px ;
+ -webkit-border-top-right-radius:4px ;
+ -webkit-border-bottom-right-radius:4px ;
+ -webkit-border-bottom-left-radius:4px ;
+ -khtml-border-top-left-radius:4px ;
+ -khtml-border-top-right-radius:4px ;
+ -khtml-border-bottom-right-radius:4px ;
+ -khtml-border-bottom-left-radius:4px ;
+ -moz-border-radius-topleft:4px ;
+ -moz-border-radius-topright:4px ;
+ -moz-border-radius-bottomright:4px ;
+ -moz-border-radius-bottomleft:4px ;
+ border-top-left-radius:4px ;
+ border-top-right-radius:4px ;
+ border-bottom-right-radius:4px ;
+ border-bottom-left-radius:4px ;
+ -o-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444;
+ -moz-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444;
+ -khtml-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444;
+ -webkit-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444;
+ box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444;
+ background-color:#3b3b3b;
+ background-image:-moz-linear-gradient(top,#555555,#222222);
+ background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#555555),color-stop(1,#222222));
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#555555,EndColorStr=#222222);
+ -ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#555555,EndColorStr=#222222);
+}
+.ui-tooltip:after, .ui-tooltip-top:after, .ui-tooltip-right:after, .ui-tooltip-bottom:after, .ui-tooltip-left:after {
+ content:"\25B8";
+ display:block;
+ font-size:2em;
+ height:0;
+ line-height:0;
+ position:absolute;
+}
+.ui-tooltip:after, .ui-tooltip-bottom:after {
+ color:#2a2a2a;
+ bottom:0;
+ left:1px;
+ text-align:center;
+ text-shadow:1px 0 2px #000000;
+ -o-transform:rotate(90deg);
+ -moz-transform:rotate(90deg);
+ -khtml-transform:rotate(90deg);
+ -webkit-transform:rotate(90deg);
+ width:100%;
+}
+.ui-tooltip-top:after {
+ bottom:auto;
+ color:#4f4f4f;
+ left:-2px;
+ top:0;
+ text-align:center;
+ text-shadow:none;
+ -o-transform:rotate(-90deg);
+ -moz-transform:rotate(-90deg);
+ -khtml-transform:rotate(-90deg);
+ -webkit-transform:rotate(-90deg);
+ width:100%;
+}
+.ui-tooltip-right:after {
+ color:#222222;
+ right:-0.375em;
+ top:50%;
+ margin-top:-.05em;
+ text-shadow:0 1px 2px #000000;
+ -o-transform:rotate(0);
+ -moz-transform:rotate(0);
+ -khtml-transform:rotate(0);
+ -webkit-transform:rotate(0);
+}
+.ui-tooltip-left:after {
+ color:#222222;
+ left:-0.375em;
+ top:50%;
+ margin-top:.1em;
+ text-shadow:0 -1px 2px #000000;
+ -o-transform:rotate(180deg);
+ -moz-transform:rotate(180deg);
+ -khtml-transform:rotate(180deg);
+ -webkit-transform:rotate(180deg);
+}
+
+
+
+/*the following changes require some cleanup and integration with the above.**/
+
+/* line 9 */
+
+
+/* line 17 */
+#todoapp {
+ background: white;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
+ -moz-border-radius-bottomleft: 5px;
+ -webkit-border-bottom-left-radius: 5px;
+ -o-border-bottom-left-radius: 5px;
+ -ms-border-bottom-left-radius: 5px;
+ -khtml-border-bottom-left-radius: 5px;
+ border-bottom-left-radius: 5px;
+ -moz-border-radius-bottomright: 5px;
+ -webkit-border-bottom-right-radius: 5px;
+ -o-border-bottom-right-radius: 5px;
+ -ms-border-bottom-right-radius: 5px;
+ -khtml-border-bottom-right-radius: 5px;
+ border-bottom-right-radius: 5px;
+}
+/* line 24 */
+
+
+/* line 32 */
+#todoapp .content #create-todo {
+ position: relative;
+}
+/* line 34 */
+#todoapp .content #create-todo input {
+ font-size: 24px;
+ font-family: inherit;
+ line-height: 1.4em;
+ border: 0;
+ outline: none;
+ padding: 6px;
+ border: 1px solid #999999;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+}
+
+/* line 47 */
+#todoapp .content #create-todo span {
+ position: absolute;
+ z-index: 999;
+ width: 170px;
+ left: 50%;
+ margin-left: -85px;
+ opacity: 0;
+}
+/* line 55 */
+#todoapp .content ul#todo-list {
+ margin-top: 10px;
+}
+/* line 57 */
+#todoapp .content ul#todo-list li {
+ padding: 15px 20px 15px 0;
+ position: relative;
+ font-size: 24px;
+ border-bottom: 1px solid #cccccc;
+ *zoom: 1;
+ cursor: move;
+}
+/* line 22, /opt/ree/lib/ruby/gems/1.8/gems/compass-0.10.5/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
+#todoapp .content ul#todo-list li:after {
+ content: "\0020";
+ display: block;
+ height: 0;
+ clear: both;
+ overflow: hidden;
+ visibility: hidden;
+}
+/* line 64 */
+#todoapp .content ul#todo-list li.editing {
+ padding: 0;
+ border-bottom: 0;
+}
+/* line 67 */
+#todoapp .content ul#todo-list li.editing .todo-input {
+ display: block;
+ width: 466px;
+ font-size: 24px;
+ font-family: inherit;
+ line-height: 1.4em;
+ border: 0;
+ outline: none;
+ padding: 6px;
+ border: 1px solid #999999;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
+}
+/* line 79 */
+#todoapp .content ul#todo-list li.editing .todo-content {
+ display: none;
+}
+/* line 81 */
+#todoapp .content ul#todo-list li.editing .todo-check {
+ display: none;
+}
+/* line 83 */
+#todoapp .content ul#todo-list li.editing .todo-destroy {
+ display: none !important;
+}
+/* line 85 */
+#todoapp .content ul#todo-list li .todo-input {
+ display: none;
+}
+/* line 87 */
+#todoapp .content ul#todo-list li .todo-check {
+ position: relative;
+ top: 6px;
+ margin: 0 10px 0 7px;
+ float: left;
+}
+/* line 93 */
+#todoapp .content ul#todo-list li.done .todo-content {
+ text-decoration: line-through;
+ color: #777777;
+}
+/* line 96 */
+#todoapp .content ul#todo-list li .todo-destroy {
+ position: absolute;
+ right: 0px;
+ top: 16px;
+ display: none;
+ cursor: pointer;
+ width: 20px;
+ height: 20px;
+}
+/* line 106 */
+#todoapp .content ul#todo-list li:hover .todo-destroy {
+ display: block;
+}
+/* line 109 */
+#todoapp #todo-stats {
+ *zoom: 1;
+ margin-top: 10px;
+ color: #555555;
+ -moz-border-radius-bottomleft: 5px;
+ -webkit-border-bottom-left-radius: 5px;
+ -o-border-bottom-left-radius: 5px;
+ -ms-border-bottom-left-radius: 5px;
+ -khtml-border-bottom-left-radius: 5px;
+ border-bottom-left-radius: 5px;
+ -moz-border-radius-bottomright: 5px;
+ -webkit-border-bottom-right-radius: 5px;
+ -o-border-bottom-right-radius: 5px;
+ -ms-border-bottom-right-radius: 5px;
+ -khtml-border-bottom-right-radius: 5px;
+ border-bottom-right-radius: 5px;
+ background: #f4fce8;
+ border-top: 1px solid #ededed;
+ padding: 0 20px;
+ line-height: 36px;
+}
+/* line 22, /opt/ree/lib/ruby/gems/1.8/gems/compass-0.10.5/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
+#todoapp #todo-stats:after {
+ content: "\0020";
+ display: block;
+ height: 0;
+ clear: both;
+ overflow: hidden;
+ visibility: hidden;
+}
+/* line 118 */
+#todoapp #todo-stats .todo-count {
+ float: left;
+}
+/* line 120 */
+#todoapp #todo-stats .todo-count .number {
+ font-weight: bold;
+ color: #555555;
+}
+/* line 123 */
+#todoapp #todo-stats .todo-clear {
+ float: right;
+}
+/* line 125 */
+#todoapp #todo-stats .todo-clear a {
+ display: block;
+ line-height: 20px;
+ text-decoration: none;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ -o-border-radius: 12px;
+ -ms-border-radius: 12px;
+ -khtml-border-radius: 12px;
+ border-radius: 12px;
+ background: rgba(0, 0, 0, 0.1);
+ color: #555555;
+ font-size: 11px;
+ margin-top: 8px;
+ padding: 0 10px 1px;
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
+ box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
+}
+/* line 136 */
+#todoapp #todo-stats .todo-clear a:hover {
+ background: rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
+ -webkit-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
+ -o-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
+ box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
+}
+/* line 139 */
+#todoapp #todo-stats .todo-clear a:active {
+ position: relative;
+ top: 1px;
+}
+
View
96 todo-example/dojo/index.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+
+ <head>
+ <title>Dojo</title>
+ <link href="css/todos.css" media="all" rel="stylesheet" type="text/css"/>
+ <script data-dojo-config="async:true, parseOnLoad:true" src="/code/dtk/dojotoolkit/dojo/dojo.js"></script>
+ <script>
+ require(["dojo/parser", "dojox/mvc", "dojox/mvc/Group", "dojox/mvc/Repeat", "dojox/mvc/Output"], function (parser, mvc) {
+ var data = {
+ todos : [
+ { content: "First" },
+ { content: "Second" },
+ { content: "Third" }
+ ],
+ };
+
+ model = mvc.newStatefulModel({ data : data });
+
+ window.addToModel = function addToModel (input, event) {
+ if (event.keyCode !== 13) return;
+
+ var insert = mvc.newStatefulModel({ "data" : {
+ content: input.value
+ } });
+ model.todos.add(model.todos.length, insert);
+ input.value = "";
+ }
+
+ window.removeFromModel = function (id) {
+ console.log(id);
+ model.todos.remove(id);
+ }
+
+ });
+ </script>
+ </head>
+
+ <body>
+
+ <!-- Todo App Interface -->
+
+ <div id="todoapp">
+
+ <div class="title">
+ <h1>Todos</h1>
+ </div>
+
+ <div class="content">
+
+ <div id="create-todo">
+ <input id="new-todo" placeholder="What needs to be done?" type="text" onkeypress="addToModel(this, event)"/>
+ <span class="ui-tooltip-top" style="display:none;">Press Enter to save this task</span>
+ </div>
+
+ <div id="todos">
+ <ul id="todo-list" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'model.todos'">
+ <li data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'">
+ <div class="todo">
+ <div class="display">
+ <input class="check" type="checkbox" />
+ <div data-dojo-type="dojox.mvc.Output" data-dojo-props="ref:'content'" class="todo-content"></div>
+ <span class="todo-destroy" data-model-id="${this.index}" onclick="removeFromModel(this.dataset.modelId)">
+ </span>
+ </div>
+ </li>
+ </ul>
+ </div>
+
+ <div id="todo-stats"></div>
+
+ </div>
+
+ </div>
+
+
+ <div id="credits">
+ Created by
+ <br />
+ <a href="http://jamesthom.as/">James Thomas</a>.
+ </div>
+<!--
+ <div class="todo">
+ <div class="display">
+ <input class="check" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
+ <div class="todo-content"></div>
+ <span class="todo-destroy"></span>
+ </div>
+ <div class="edit">
+ <input class="todo-input" type="text" value="" />
+ </div>
+ </div>-->
+
+ </body>
+
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.