Skip to content

Instantly share code, notes, and snippets.

@ericf
Forked from apipkin/gist:459271
Created June 30, 2010 21:49
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 ericf/459274 to your computer and use it in GitHub Desktop.
Save ericf/459274 to your computer and use it in GitHub Desktop.
YUI.add('gallery-file-manager',function(Y){
Y.namespace('FileManager').Base = Y.Base.create('file-manager', Y.Widget, [Y.WidgetParent], {
renderUI : function() {
var i,l,layout = this.get('layout');
for(i=0, l=layout.length; i<l; i++) {
switch(layout[i]) {
case 'toolbar': break;
case 'explorer': break;
case 'list':
case 'viewer':
if(!this.get(layout[i]).get('rendered')) {
this.get(layout[i]).render(this.get('contentBox'));
} else {
this.get('contentBox').append(this.get(layout[i]).get('boundingBox').remove());
}
break;
}
}
},
bindUI : function() {
this.get('list').after('file-manager-list:selectedRowChange', function(e){
Y.log('changing from within file-manager.js');
Y.log(e.newVal.getAttribute('fileId'));
this.loadFileIntoViewer(e.newVal.getAttribute('fileId'));
}, this);
},
loadFileIntoViewer : function(fileId) {
Y.io('data/files.php?id=' + fileId, {
context : this,
on : {
success : function(id, o, args) {
this.get('viewer').load(Y.JSON.parse(o.responseText));
}
}
});
}
}, {
ATTRS : {
layout : {
value : ['list','viewer']
},
toolbar : {
getter : function(val) {
if(val instanceof Y.FileManager.Toolbar) {
return val;
}
return new Y.FileManager.Toolbar();
}
},
explorer : {
getter : function(val) {
if(val instanceof Y.FileManager.Explorer) {
return val;
}
return new Y.FileManager.Explorer();
}
},
list : {
getter : function(val) {
if(val instanceof Y.FileManager.List) {
return val;
}
return new Y.FileManager.List();
}
},
viewer : {
getter : function(val) {
if(val instanceof Y.FileManager.Viewer) {
return val;
}
return new Y.FileManager.Viewer();
}
}
}
});
},'0.1', {requires:['widget','widget-parent','gallery-file-manager-toolbar','gallery-file-manager-explorer','gallery-file-manager-list','gallery-file-manager-viewer']});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment