diff --git a/examples/unfinished/shark/client/shark.html b/examples/unfinished/shark/client/shark.html index 4e847e8296..9e9abcbd4e 100644 --- a/examples/unfinished/shark/client/shark.html +++ b/examples/unfinished/shark/client/shark.html @@ -3,22 +3,13 @@ -
+

Hello {{name}}

{{#each items}} - {{#item}} - {{text}} - {{/item}} +
{{text}}
{{else}} Empty {{/each}} -
+ - - - diff --git a/examples/unfinished/shark/client/shark.js b/examples/unfinished/shark/client/shark.js index 3c04c031f6..ea60383f50 100644 --- a/examples/unfinished/shark/client/shark.js +++ b/examples/unfinished/shark/client/shark.js @@ -8,167 +8,9 @@ Meteor.startup(function () { Items.insert({ text: 'Qux' }); Items.remove({ text: 'Foo' }); Items.update({ text: 'Bar' }, { text: 'Coke' }); - - //Items.remove({}); - //Items.insert({ text: 'Foo' }); - //Items.insert({ text: 'Bar' }); - //Items.insert({ text: 'Beef' }); }, 1000); }); -UI.Body.include({ - items: function () { - return Items.find({}, { sort: { text: 1 }}); - }, - name: 'David', - containerClass: function () { - return Session.get('containerClass'); - } -}); +UI.body.name = 'David'; -Template.item.include({ - foo: function () { return Session.get('foo'); }, - rand: function () { return Math.random(); } -// itemClick: function (evt) { -// console.log(this.getData()); -// } -}); - - -//Meteor.startup(function () { -// var body = document.body; -// var table = document.createElement("TABLE"); -// TABLE = table; - - /*var tr = document.createElement("TR"); - var td = document.createElement("TD"); - var hello = document.createTextNode("hello"); - tr.appendChild(td); - td.appendChild(hello); - body.appendChild(table); - table.appendChild(tr);*/ - -// var frag = $.parseHTML("hello")[0].parentNode; -// console.log(frag.firstChild.nodeName); -// $(table).append(frag); -// -// console.log(TABLE.rows.length); -//}); - -Span = UI.Component.extend({ - typeName: 'Span', - render: function (buf) { - buf("
Hello
"); - } -}); - -Div = UI.Component.extend({ - typeName: 'Div', - render: function (buf) { - buf("
World", - "", - "
"); - } -}); - -Either = UI.Component.extend({ - typeName: 'Either', - render: function (buf) { - buf(Div.create(), - { - type: function () { return window[Session.get('which')]; }, - args: { - built: function () { - var self = this; - self.$("*").on('click', function (evt) { - Session.set( - 'which', - Session.get('which') === 'Div' ? 'Span' : 'Div'); - }); - } - } - }, - new UI.If({ - data: function () { return Session.get('which') === 'Div'; }, - content: Div, - elseContent: Span - }), - { type: Span }); - buf(new UI.Each({ - data: function () { - var sess = Session.get('items'); - return sess != null ? sess : - Items.find({}, { sort: { text: 1 }}); - }, - content: UI.Component.extend({ - render: function (buf) { - var self = this; - buf("
Each ", - UI.Text(function () { return self.data().text; }), - " ", String(Math.random()), - "
"); - } - }) - })); - } -}); - -Meteor.startup(function () { - Session.set('which', 'Span'); - - // leak `x` for fooling around in the console - x = Either.create({isRoot: true}); - x.attach(document.body); - - // leak `c` - (c = UI.Counter.create({isRoot:true})).attach(document.body); -}); - -Meteor.startup(function () { - var c = UI.Component.extend({ - render: function(buf) { - buf(String(this.data())); - } - }); - - L = UI.List({elseContent: function () { - return c(function () { return 'else'; }); - }}); - - L.addItemBefore('a', c, 1); - L.addItemBefore('b', c, 2); - L.addItemBefore('c', c, 3); - L.makeRoot(); - L.attach(document.body); - L.addItemBefore('d', c, 4); - L.addItemBefore('e', c, 5, 'b'); - L.moveItemBefore('d', 'c'); - L.moveItemBefore('a'); - L.removeItem('b'); - L.removeItem('a'); - L.removeItem('c'); - L.removeItem('d'); - L.removeItem('e'); - L.addItemBefore('a', c, 1); - L.addItemBefore('b', c, 2, 'a'); - L.addItemBefore('c', c, 3); - L.moveItemBefore('c', 'a'); -}); \ No newline at end of file +UI.body.items = Items.find({}, { sort: { text: 1 }});