Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.8 simplex #1028

Merged
merged 7 commits into from
Dec 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 0 additions & 237 deletions src/annotations/annotations-.html

This file was deleted.

18 changes: 0 additions & 18 deletions src/bind/bind-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@
// flow-down:
// node.on.<property>-changed: <model[.path]> = e.detail.value

bind: function(model, hostProperty, targetPath) {
var parts = targetPath.split('.');
var id = parts[0], property = parts[1];
if (!property) {
property = 'textContent';
// textContent never flows-up
} else {
// flow-up
_Bind._addBindListener(model, id, property, hostProperty);
}
//
// flow-down
//
//console.log('[_bindEffectBuilder]: [%s] %=% [%s].[%s]', hostProperty, id, property);
return 'this.$.' + id + '.' + property + ' = '
+ 'this._data.' + hostProperty + ';'
},

notify: function(model, source) {
model._notifyChange = Bind._notifyChange;
return 'this._notifyChange(\'' + source + '\')';
Expand Down
44 changes: 11 additions & 33 deletions src/bind/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script>

modulate('bind', function() {

var Bind = {

// for instances
Expand All @@ -23,13 +24,22 @@
// <node>.on.<property>-changed: <path]> = e.detail.value
//console.log('[_setupBindListener]: [%s][%s] listening for [%s][%s-changed]', this.localName, info.path, info.id || info.index, info.property);
var fn = new Function('e', 'this.' + info.path + ' = e.detail.value;');
var node = info.id ? inst.$[info.id] : inst._nodes[info.index];
var node = inst._nodes[info.index];
node.addEventListener(info.property + '-changed', fn.bind(inst));
});
},

// for prototypes

_addAnnotatedListener: function(model, index, property, path) {
// <node>.on.<property>-changed: <path> = e.detail.value
model._bindListeners.push({
index: index,
property: property,
path: path
});
},

_builders: {},

addBuilder: function(kind, builder) {
Expand Down Expand Up @@ -150,40 +160,8 @@
}
Object.defineProperty(model, property, defun);
//console.log(prop.set ? prop.set.toString() : '(read-only)');
},

// end of builders

_addAnnotatedListener: function(model, index, property, path) {
// <node>.on.<property>-changed: <path> = e.detail.value
model._bindListeners.push({
index: index,
property: property,
path: path
});
},

_addBindListener: function(model, id, property, path) {
model._bindListeners.push({
id: id,
property: property,
path: path
});
}
/*
_bindAnnotationProperty: function(name, path, index) {
return 'this._nodes[' + index + '].' + name
+ ' = this._data.' + path + ';';
},

_addBindListener: function(property, path, id) {
var bl = this._requireBindListeners(property);
bl.targets.push({
id: id,
path: path
});
}
*/
};

return Bind;
Expand Down
24 changes: 12 additions & 12 deletions src/bind/demo/src/annotations-bind-demo.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<link rel="import" href="../../../module.html">
<link rel="import" href="../../../lang.html">
<link rel="import" href="../../../annotations/annotations.html">

<link rel="import" href="../../bind.html">
<link rel="import" href="../../bind-effects.html">

<link rel="import" href="../../../template/template.html">
<link rel="import" href="../../annotations-bind.html">

<link rel="import" href="../../../lang.html">
<link rel="import" href="../../bind-annotations.html">

<template>

Expand All @@ -18,9 +16,11 @@

<script>

using(['template', 'bind', 'annotations-bind'],
// TODO(sjmiles): should 'bind-annotations' blend the other two modules
// somehow so we don't need to include all three here?
using(['Annotations', 'bind', 'bind-annotations'],

function(Template, Bind, Annotations) {
function(Annotations, Bind, BindAnnotations) {

var out = document.querySelector('#abd');
out.innerHTML += '<hr><h3>annotations-bind demo</h3><hr>';
Expand Down Expand Up @@ -57,17 +57,17 @@

function Templabindinate(model, template) {
Bind.prepareModel(model);
var list = Template.parseAnnotations(template);
Annotations.preprocessBindAnnotations(model, list);
var list = Annotations.parseAnnotations(template);
BindAnnotations.preprocessBindAnnotations(model, list);
return list;
}

function Instancinance(model, template) {
Bind.prepareInstance(model);
Bind.createBindings(model);
var dom = Template.instanceTemplate(template);
model._nodes = Annotations.marshalAnnotatedNodes(model._nodes, dom,
Template.findAnnotatedNode);
var dom = Annotations.instanceTemplate(template);
model._nodes = BindAnnotations.marshalAnnotatedNodes(model._nodes, dom,
Annotations.findAnnotatedNode);
return dom;
}

Expand Down
Loading