Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
Open
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
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": ".."
}
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "firebase-element",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#master",
"firebase": "^2.2"
"polymer": "Polymer/polymer#0.8.0-rc.1",
"firebase": "^2.2",
"observe-js": "~0.5.5"
}
}
105 changes: 51 additions & 54 deletions demos/firebase.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<title>firebase-element</title>

<script src="../../webcomponentsjs/webcomponents.js"></script>

<link rel="import" href="../firebase-element.html">

</head>
<body unresolved>
<body>

<template is="auto-binding">
<template is="x-autobind">

<firebase-element id="base" on-data-change="{{dataChange}}" data="{{data}}" location="https://treedata-demo.firebaseio.com/demo" log></firebase-element>
<firebase-element id="base" on-data-change="dataChange" data="{{data}}" location="https://treedata-demo.firebaseio.com/demo" log></firebase-element>

<h3>Top-level properties persist automatically:</h3>

Expand All @@ -35,70 +35,67 @@ <h3>Top-level properties persist automatically:</h3>
<h3>Nested properties must be persisted manually:</h3>

<input value="{{data.more.color}}">
<button on-tap="{{commitMore}}">Commit data.more</button>

<button on-tap="commitMore">Commit data.more</button>

<hr>

<h3>Remote Data</h3>
<pre>{{json}}</pre>

<hr>

<button on-tap="{{resetLocal}}">Reset Local</button>
<button on-tap="{{removeLocal}}">Remove Local</button>
<button on-tap="{{resetRemote}}">Reset remote</button>
<button on-tap="{{removeRemote}}">Remove Remote</button>
<button on-tap="resetLocal">Reset Local</button>
<button on-tap="removeLocal">Remove Local</button>
<button on-tap="resetRemote">Reset remote</button>
<button on-tap="removeRemote">Remove Remote</button>


</template>

<script>

addEventListener('template-bound', function(e) {

scope = e.target;

scope.resetLocal = function() {
// direct setting of data is persisted automatically
this.data = {
name: 'anonymous',
info: 'none',
more: {
color: "yellow"
}
};
};

scope.removeLocal = function() {
this.data = null;
};

scope.resetRemote = function() {
// Simulate other actor setting data to same remote location
new Firebase('https://treedata-demo.firebaseio.com/demo').set({
name: 'anonymous',
info: 'none',
more: {
color: "yellow"
}
});
};
scope = document.querySelector('template');

scope.removeRemote = function() {
// Simulate other actor removing data from same remote location
new Firebase('https://treedata-demo.firebaseio.com/demo').remove();
scope.resetLocal = function() {
// direct setting of data is persisted automatically
this.data = {
name: 'anonymous',
info: 'none',
more: {
color: "yellow"
}
};
};

scope.removeLocal = function() {
this.data = null;
};

scope.resetRemote = function() {
// Simulate other actor setting data to same remote location
new Firebase('https://treedata-demo.firebaseio.com/demo').set({
name: 'anonymous',
info: 'none',
more: {
color: "yellow"
}
});
};

scope.removeRemote = function() {
// Simulate other actor removing data from same remote location
new Firebase('https://treedata-demo.firebaseio.com/demo').remove();
};

scope.commitMore = function() {
this.$.base.commitProperty('more');
};

scope.dataChange = function() {
this.json = JSON.stringify(this.data, null, '\t');
};

scope.commitMore = function() {
this.$.base.commitProperty('more');
};

scope.dataChange = function() {
this.json = JSON.stringify(this.data, null, '\t');
};

});
</script>

</body>
Expand Down
Loading