From 2b3f85e17a574cd9c6bcd35e2b69f093375f81f3 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Mon, 14 Jul 2014 19:52:42 +0800 Subject: [PATCH] Update bootstrap and Ractive. --- bootstrap.md | 10 ++++++++++ ractive.md | 55 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/bootstrap.md b/bootstrap.md index 9b49bb05d..34fd068ba 100644 --- a/bootstrap.md +++ b/bootstrap.md @@ -31,3 +31,13 @@ layout: default .col-sm-1 .col-md-1 .col-lg-1 + + .make-xs-column(12) + .make-sm-column(6) + .make-md-column(3) + .make-lg-column(3) + +### Utilities + + .pull-left + .pull-right diff --git a/ractive.md b/ractive.md index 73d5c3d1f..eae22e85c 100644 --- a/ractive.md +++ b/ractive.md @@ -5,7 +5,7 @@ vim: ft=javascript --- {% raw %} -### [Initialization](http://docs.ractivejs.org/latest/initialisation-options) +### [Initialization](http://docs.ractivejs.org/latest/options) new Ractive({ el: $('..'), @@ -34,18 +34,23 @@ vim: ft=javascript sanitize: false }) -### [Instance methods](http://docs.ractivejs.org/latest/initialisation-options) +### Instance methods + +Updating values: + + view.add('count', 1) //=> promise + view.subtract('count', 1) //=> promise + view.toggle('shown') //=> promise view.set('a', true) view.set({ a: true }) - view.merge(...) + view.reset({ a: true }) + view.merge('list', [a,b,c]) + view.get('a') + view.data.a - view.on('event', function() { ... }); - view.fire('event'); - - view.update() - view.updateModel() +Nodes and components: view.find('.klass') view.findAll('.klass') @@ -53,6 +58,25 @@ vim: ft=javascript view.nodes['hello'] // .find('#hello') view.findComponent('photo') + view.findAllComponents('photo') + +Events: + + view.on('event', function() { ... }) + view.off('event', fn) + view.fire('event') + +Etc: + + view.update() + view.updateModel() + + view.insert('.node .path') + + view.observe({ 'name': function() { ... } }) + + view.toHTML() //=> String + view.render() ### Extend @@ -196,4 +220,19 @@ This transforms the `list` attribute via a helper function called `sort()`. }; } }; + +### [Computed properties](http://docs.ractivejs.org/latest/computed-properties) + + new Ractive({ + template: '{{area}}', + computed: { + area: function () { return this.get('width') * this.get('height'); } + area: '${width} * ${height}' + fullname: { + get: '${first} + " " + ${last}" + set: function (name) { ... } + } + } + }); + {% endraw %}