Created
June 30, 2010 21:47
-
-
Save apipkin/459271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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').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