Evan You 13 лет назад
Родитель
Сommit
9546965ae0
5 измененных файлов с 12 добавлено и 1637 удалено
  1. 1 0
      TODO.md
  2. 4 1629
      dist/seed.js
  3. 1 1
      examples/todomvc/index.html
  4. 2 7
      examples/todomvc/js/app.js
  5. 4 0
      src/filters.js

+ 1 - 0
TODO.md

@@ -1,5 +1,6 @@
 - tests
 - docs
+- validation as filter, e.g. sd-value="email | validate email"
 - sd-with
 - standarized way to reuse components (sd-component?)
 - plugins: seed-touch, seed-storage, seed-router

Разница между файлами не показана из-за своего большого размера
+ 4 - 1629
dist/seed.js


+ 1 - 1
examples/todomvc/index.html

@@ -53,7 +53,7 @@
             </section>
             <footer id="footer" sd-show="total">
                 <span id="todo-count">
-                    <strong sd-text="remaining"></strong> {{itemLabel}} left
+                    <strong sd-text="remaining"></strong> {{remaining | pluralize item}} left
                 </span>
                 <ul id="filters">
                     <li><a href="#/all" sd-class="selected:checkFilter">All</a></li>

+ 2 - 7
examples/todomvc/js/app.js

@@ -15,8 +15,7 @@ Seed.controller('Todos', function (scope) {
     updateFilter()
     window.addEventListener('hashchange', updateFilter)
     function updateFilter () {
-        if (!location.hash) return
-        scope.filter = location.hash.slice(2) || 'all'
+        scope.filter = location.hash ? location.hash.slice(2) : 'all'
     }
 
     // regular properties -----------------------------------------------------
@@ -34,10 +33,6 @@ Seed.controller('Todos', function (scope) {
         return scope.total - scope.remaining
     }}
 
-    scope.itemLabel = {get: function () {
-        return scope.remaining > 1 ? 'items' : 'item'
-    }}
-
     // dynamic context computed property using info from target scope
     scope.filterTodo = {get: function (e) {
         return filters[scope.filter](e.scope.completed)
@@ -63,7 +58,7 @@ Seed.controller('Todos', function (scope) {
 
     // event handlers ---------------------------------------------------------
     scope.addTodo = function () {
-        var value = scope.newTodo.trim()
+        var value = scope.newTodo && scope.newTodo.trim()
         if (value) {
             scope.todos.unshift({ title: value, completed: false })
             scope.newTodo = ''

+ 4 - 0
src/filters.js

@@ -29,6 +29,10 @@ module.exports = {
         return value ? value.toString().toLowerCase() : ''
     },
 
+    pluralize: function (value, args) {
+        return value === 1 ? args[0] : (args[1] || args[0] + 's')
+    },
+
     currency: function (value, args) {
         if (!value) return ''
         var sign = (args && args[0]) || '$',

Некоторые файлы не были показаны из-за большого количества измененных файлов