Skip to content

Instantly share code, notes, and snippets.

@asicfr
Created May 13, 2014 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asicfr/69f4275b9c49f0fdc0a4 to your computer and use it in GitHub Desktop.
Save asicfr/69f4275b9c49f0fdc0a4 to your computer and use it in GitHub Desktop.
(function() {
// Start polymer
Polymer('polymer-filesystem', {
created: function() {
console.log("created");
// bind function 'callBackRefreshList' and 'callBackFsmChangeState' with 'this' current context
this.fsm = new fileSystemManager(this.callBackFsmChangeState.bind(this));
this.fsm.setCallBackAfterLoad(this.callBackRefreshList.bind(this));
console.log("fin created");
},
ready: function() {
console.log("ready");
this.myfiles = [];
},
refreshList: function(event, detail, sender) {
console.log("refreshList");
this.fsm.loadFiles();
},
callBackFsmChangeState: function() {
console.log("callBackFsmChangeState");
this.systemOk = this.fsm.isInit();
this.systemError = this.fsm.getError();
if (this.systemOk) {
this.fsm.loadFiles();
}
},
callBackRefreshList: function(newList) {
console.log("newList size : " + newList.length);
this.myfiles = newList;
},
openSomeFile: function(event, detail, sender) {
console.log("openSomeFile");
window.open(sender.templateInstance.model.onefile.fileURL)
},
removeSomeFile: function(event, detail, sender) {
console.log("removeSomeFile");
// access the current named model instance that in a template repeat
var fileName = sender.templateInstance.model.onefile.name;
this.fsm.removeFile(fileName);
},
addSomeFile: function(event, detail, sender) {
console.log("addSomeFile");
this.fsm.addFile(sender);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment