// YUI3 File Picker module for moodle // Author: Dongsheng Cai /** * * File Picker UI * ===== * this.rendered, it tracks if YUI Panel rendered * this.api, stores the URL to make ajax request * this.mainui, YUI Panel * this.treeview, YUI Treeview * this.viewbar, a button group to switch view mode * this.viewmode, store current view mode * * Filepicker options: * ===== * this.options.client_id, the instance id * this.options.contextid * this.options.itemid * this.options.repositories, stores all repositories displaied in file picker * this.options.formcallback * * Active repository options * ===== * this.active_repo.id * this.active_repo.nosearch * this.active_repo.norefresh * this.active_repo.nologin * this.active_repo.help * this.active_repo.manage * * Server responses * ===== * this.filelist, cached filelist * this.pages * this.page * this.filepath, current path * this.logindata, cached login form */ M.core_filepicker = M.core_filepicker || {}; /** * instances of file pickers used on page */ M.core_filepicker.instances = M.core_filepicker.instances || {}; /** * Init and show file picker */ M.core_filepicker.show = function(Y, options) { if (!M.core_filepicker.instances[options.client_id]) { M.core_filepicker.init(Y, options); } M.core_filepicker.instances[options.client_id].show(); }; /** * Add new file picker to current instances */ M.core_filepicker.init = function(Y, options) { var FilePickerHelper = function(options) { FilePickerHelper.superclass.constructor.apply(this, arguments); } FilePickerHelper.NAME = "FilePickerHelper"; FilePickerHelper.ATTRS = { options: {}, lang: {} }; Y.extend(FilePickerHelper, Y.Base, { api: M.cfg.wwwroot+'/repository/repository_ajax.php', initializer: function(options) { this.options = options; }, destructor: function() { }, request: function(args, redraw) { var api = this.api + '?action='+args.action; var params = {}; var scope = this; if (args['scope']) { scope = args['scope']; } params['repo_id']=args.repository_id; params['p'] = args.path?args.path:''; params['page'] = args.page?args.page:''; params['env']=this.options.env; // the form element only accept certain file types params['accepted_types']=this.options.accepted_types; params['sesskey']=M.cfg.sesskey; params['client_id'] = args.client_id; params['itemid'] = this.options.itemid?this.options.itemid:0; if (args['params']) { for (i in args['params']) { params[i] = args['params'][i]; } } var cfg = { method: 'POST', on: { complete: function(id,o,p) { if (!o) { alert('IO FATAL'); return; } var data = null; try { data = Y.JSON.parse(o.responseText); } catch(e) { alert(M.str.repository.invalidjson+' - |'+source+'| -'+stripHTML(o.responseText)); } args.callback(id,data,p); } }, arguments: { scope: scope }, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'User-Agent': 'MoodleFilePicker/3.0' }, data: build_querystring(params), context: this }; if (args.form) { cfg.form = args.form; } Y.io(api, cfg); if (redraw) { this.wait('load'); } }, build_tree: function(node, level) { var client_id = this.options.client_id; if(node.children) { node.title = ''+node.title+''; } var info = { label:node.title, //title:fp_lang.date+' '+node.date+fp_lang.size+' '+node.size, filename:node.title, source:node.source?node.source:'', thumbnail:node.thumbnail, path:node.path?node.path:[] }; var tmpNode = new YAHOO.widget.TextNode(info, level, false); //var tooltip = new YAHOO.widget.Tooltip(tmpNode.labelElId, { //context:tmpNode.labelElId, text:info.title}); if(node.repo_id) { tmpNode.repo_id=node.repo_id; }else{ tmpNode.repo_id=this.active_repo.id; } if(node.children) { if(node.expanded) { tmpNode.expand(); } tmpNode.isLeaf = false; tmpNode.client_id = client_id; if (node.path) { tmpNode.path = node.path; } else { tmpNode.path = ''; } for(var c in node.children) { this.build_tree(node.children[c], tmpNode); } } else { tmpNode.isLeaf = true; } }, view_files: function() { this.viewbar.set('disabled', false); if (this.viewmode == 1) { this.view_as_icons(); } else if (this.viewmode ==2) { this.view_as_list(); } else { this.view_as_icons(); } }, view_as_list: function() { var client_id = this.options.client_id; var list = this.filelist; var panel_id = '#panel-'+client_id; this.viewmode = 2; Y.one(panel_id).set('innerHTML', ''); this.print_header(); var tree = Y.Node.create('
'); Y.one(panel_id).appendChild(tree); this.treeview = new YAHOO.widget.TreeView('treeview-'+client_id); for(k in list) { this.build_tree(list[k], this.treeview.getRoot()); } var scope = this; this.treeview.subscribe('clickEvent', function(e){ if(e.node.isLeaf){ var fileinfo = {}; fileinfo['title'] = e.node.data.filename; fileinfo['source'] = e.node.data.source; fileinfo['thumbnail'] = e.node.data.thumbnail; scope.select_file(fileinfo); } }); this.treeview.draw(); }, view_as_icons: function() { var client_id = this.options.client_id; var list = this.filelist; var panel_id = '#panel-'+client_id; this.viewmode = 1; Y.one(panel_id).set('innerHTML', ''); this.print_header(); var gridpanel = Y.Node.create('
'); Y.one('#panel-'+client_id).appendChild(gridpanel); var count = 0; for(var k in list) { var node = list[k]; var grid = document.createElement('DIV'); grid.className='fp-grid'; // the file name var title = document.createElement('DIV'); title.id = 'grid-title-'+client_id+'-'+String(count); title.className = 'label'; if (node.shorttitle) { node.title = node.shorttitle; } title.innerHTML += ''+node.title+""; if(node.thumbnail_width){ grid.style.width = node.thumbnail_width+'px'; title.style.width = (node.thumbnail_width-10)+'px'; } else { grid.style.width = title.style.width = '90px'; } var frame = document.createElement('DIV'); frame.style.textAlign='center'; if(node.thumbnail_height){ frame.style.height = node.thumbnail_height+'px'; } var img = document.createElement('img'); img.src = node.thumbnail; if(node.thumbnail_alt) { img.alt = node.thumbnail_alt; } if(node.thumbnail_title) { img.title = node.thumbnail_title; } var link = document.createElement('A'); link.href='###'; link.id = 'img-id-'+client_id+'-'+String(count); if(node.url) { // hide //grid.innerHTML += '

'+M.str.repository.preview+'

'; } link.appendChild(img); frame.appendChild(link); grid.appendChild(frame); grid.appendChild(title); gridpanel.appendChild(grid); var y_title = Y.one('#'+title.id); var y_file = Y.one('#'+link.id); if(node.children) { y_file.on('click', function(e, p) { if(p.dynload) { var params = {}; }else{ this.filelist = p.children; this.view_files(); } }, this, node); y_title.on('click', function(e, p){ //Y.Event.simulate(y_file, 'click'); }, this, node); } else { var fileinfo = {}; fileinfo['title'] = list[k].title; fileinfo['source'] = list[k].source; fileinfo['thumbnail'] = list[k].thumbnail; y_title.on('click', function(e, args) { this.select_file(args); }, this, fileinfo); y_file.on('click', function(e, args) { this.select_file(args); }, this, fileinfo); } count++; } }, select_file: function(args) { var client_id = this.options.client_id; var thumbnail = Y.one('#fp-grid-panel-'+client_id); if(thumbnail){ thumbnail.setStyle('display', 'none'); } var header = Y.one('#fp-header-'+client_id); if (header) { header.setStyle('display', 'none'); } var footer = Y.one('#fp-footer-'+client_id); if (footer) { footer.setStyle('display', 'none'); } var path = Y.one('#path-'+client_id); if(path){ path.setStyle('display', 'none'); } var panel = Y.one('#panel-'+client_id); var html = '
'; html += '

'; html += '

'; html += '

'; var le_checked = ''; var le_style = ''; if (this.options.repositories[this.active_repo.id].return_types == 1) { // support external links only le_checked = 'checked'; le_style = ' style="display:none;"'; } else if(this.options.repositories[this.active_repo.id].return_types == 2) { // support internal files only le_style = ' style="display:none;"'; } if (this.options.externallink && this.options.env == 'editor') { html += ''+M.str.repository.linkexternal+'

'; } html += '

'; html += ''; html += '

'; html += '
'; var getfile_form = Y.Node.create(html); panel.appendChild(getfile_form); var getfile = Y.one('#fp-confirm-'+client_id); getfile.on('click', function(e) { var client_id = this.options.client_id; var scope = this; var repository_id = this.active_repo.id; var title = Y.one('#newname-'+client_id).get('value'); var filesource = Y.one('#filesource-'+client_id).get('value'); var params = {'title':title, 'file':filesource, 'savepath': this.options.savepath}; if (this.options.env == 'editor') { var linkexternal = Y.one('#linkexternal-'+client_id).get('checked'); if (linkexternal) { params['linkexternal'] = 'yes'; } } if (this.options.env == 'url') { params['linkexternal'] = 'yes'; } this.wait('download', title); this.request({ action:'download', client_id: client_id, repository_id: repository_id, 'params': params, callback: function(id, obj, args) { if (scope.options.editor_target&&scope.options.env=='editor') { scope.options.editor_target.value=obj.url; scope.options.editor_target.onchange(); } scope.hide(); obj.client_id = client_id; var formcallback_scope = null; if (args.scope.options.magicscope) { formcallback_scope = args.scope.options.magicscope; } else { formcallback_scope = args.scope; } scope.options.formcallback.apply(formcallback_scope, [obj]); } }, true); }, this); var cancel = Y.one('#fp-cancel-'+client_id); cancel.on('click', function(e) { this.view_files(); }, this); var treeview = Y.one('#treeview-'+client_id); if (treeview){ treeview.setStyle('display', 'none'); } }, wait: function(type) { var panel = Y.one('#panel-'+this.options.client_id); panel.set('innerHTML', ''); var name = ''; var str = '
'; if(type=='load') { str += ''; str += '

'+M.str.repository.loading+'

'; }else{ str += ''; str += '

'+M.str.repository.copying+' '+name+'

'; } str += '
'; try { panel.set('innerHTML', str); } catch(e) { alert(e.toString()); } }, render: function() { var client_id = this.options.client_id; var filepicker_id = 'filepicker-'+client_id; var fpnode = Y.Node.create('
'); Y.one(document.body).appendChild(fpnode); // render file picker panel this.mainui = new YAHOO.widget.Panel(filepicker_id, { draggable: true, close: true, underlay: 'none', zindex: 9999999, monitorresize: false, xy: [50, YAHOO.util.Dom.getDocumentScrollTop()+20] }); var layout = null; this.mainui.beforeRenderEvent.subscribe(function() { YAHOO.util.Event.onAvailable('layout-'+client_id, function() { layout = new YAHOO.widget.Layout('layout-'+client_id, { height: 480, width: 700, units: [ {position: 'top', height: 32, resize: false, body:'
', gutter: '2'}, {position: 'left', width: 200, resize: true, scroll:true, body:'', gutter: '0 5 0 2', minWidth: 150, maxWidth: 300 }, {position: 'center', body: '
', scroll: true, gutter: '0 2 0 0' } ] }); layout.render(); }); }); this.mainui.setHeader('File Picker'); this.mainui.setBody('
'); this.mainui.render(); this.rendered = true; var scope = this; // adding buttons var view_icons = {label: M.str.repository.iconview, value: 't', onclick: { fn: function(){ scope.view_as_icons(); } } }; var view_listing = {label: M.str.repository.listview, value: 'l', onclick: { fn: function(){ scope.view_as_list(); } } }; this.viewbar = new YAHOO.widget.ButtonGroup({ id: 'btngroup-'+client_id, name: 'buttons', disabled: true, container: 'fp-viewbar-'+client_id }); this.viewbar.addButtons([view_icons, view_listing]); // processing repository listing var r = this.options.repositories; Y.on('contentready', function(el) { var list = Y.one(el); var count = 0; for (var i in r) { var id = 'repository-'+client_id+'-'+count; var link_id = id + '-link'; list.append('
  • '+r[i].name+'
  • '); Y.one('#'+link_id).prepend(' '); Y.one('#'+link_id).on('click', function(e, scope, repository_id) { scope.repository_id = repository_id; Y.all(el+' li a').setStyle('backgroundColor', 'transparent'); e.currentTarget.setStyle('backgroundColor', '#CCC'); this.list({'repo_id':repository_id}); }, this /*handler running scope*/, this/*second argument*/, r[i].id/*third argument of handler*/); count++; } }, '#fp-list-'+client_id, this /* handler running scope */, '#fp-list-'+client_id /*first argument of handler*/); }, parse_repository_options: function(data) { this.filelist = data.list?data.list:null; this.filepath = data.path?data.path:null; this.active_repo = {}; this.active_repo.issearchresult = Boolean(data.issearchresult); this.active_repo.pages = Number(data.pages?data.pages:null); this.active_repo.page = Number(data.page?data.page:null); this.active_repo.id = data.repo_id?data.repo_id:null; this.active_repo.nosearch = data.nosearch?true:false; this.active_repo.norefresh = data.norefresh?true:false; this.active_repo.nologin = data.nologin?true:false; this.active_repo.help = data.help?data.help:null; this.active_repo.manage = data.manage?data.manage:null; }, print_login: function(data) { var client_id = this.options.client_id; var repository_id = data.repo_id; var l = this.logindata = data.login; var loginurl = ''; var panel = Y.one('#panel-'+client_id); var action = 'login'; if (data['login_btn_action']) { action=data['login_btn_action']; } var form_id = 'fp-form-'+client_id; var download_button_id = 'fp-form-download-button-'+client_id; var search_button_id = 'fp-form-search-button-'+client_id; var login_button_id = 'fp-form-login-button-'+client_id; var popup_button_id = 'fp-form-popup-button-'+client_id; var str = '
    '; str += '
    '; var has_pop = false; str +=''; for(var k in l) { str +=''; if(l[k].type=='popup') { // pop element loginurl = l[k].url; str += ''; action = 'popup'; }else if(l[k].type=='textarea') { // textarea element str += ''; }else if(l[k].type=='select') { // select element str += ''; str += ''; }else{ // input element var label_id = ''; var field_id = ''; var field_value = ''; if(l[k].id) { label_id = ' for="'+l[k].id+'"'; field_id = ' id="'+l[k].id+'"'; } if (l[k].label) { str += ''; } else { str += ''; } if(l[k].value) { field_value = ' value="'+l[k].value+'"'; } if(l[k].type=='radio'){ var list = l[k].value.split('|'); var labels = l[k].value_label.split('|'); str += ''; }else{ str += ''; } } str +=''; } str +='

    '+M.str.repository.popup+'

    '; str += '

    '; str += '

    '; str += ''+l[k].label+' '; for(var item in list) { str +=''+labels[item]+'
    '; } str += '
    '; str += ''; str += '
    '; str += '
    '; // custom lable text var btn_label = data['login_btn_label']?data['login_btn_label']:M.str.repository.submit; if (action != 'popup') { str += '

    '; } str += '
    '; // insert login form try { panel.set('innerHTML', str); } catch(e) { alert(e.toString()+M.str.quiz.xhtml); } // register buttons // process login action var login_button = Y.one('#'+login_button_id); var scope = this; if (login_button) { login_button.on('click', function(){ // collect form data var data = this.logindata; var scope = this; var params = {}; for (var k in data) { if(data[k].type!='popup') { var el = Y.one('[name='+data[k].name+']'); var type = el.get('type'); params[data[k].name] = ''; if(type == 'checkbox') { params[data[k].name] = el.get('checked'); } else { params[data[k].name] = el.get('value'); } } } // start ajax request this.request({ 'params': params, 'scope': scope, 'action':'signin', 'path': '', 'client_id': client_id, 'repository_id': repository_id, 'callback': function(id, o, args) { scope.parse_repository_options(o); scope.view_files(); if (o.msg) { // do something } } }, true); }, this); } var search_button = Y.one('#'+search_button_id); if (search_button) { search_button.on('click', function(){ var data = this.logindata; var params = {}; for (var k in data) { if(data[k].type!='popup') { var el = document.getElementsByName(data[k].name)[0]; params[data[k].name] = ''; if(el.type == 'checkbox') { params[data[k].name] = el.checked; } else if(el.type == 'radio') { var tmp = document.getElementsByName(data[k].name); for(var i in tmp) { if (tmp[i].checked) { params[data[k].name] = tmp[i].value; } } } else { params[data[k].name] = el.value; } } } this.request({ scope: scope, action:'search', client_id: client_id, repository_id: repository_id, form: {id: 'fp-form-'+scope.options.client_id,upload:false,useDisabled:true}, callback: function(id, o, args) { o.issearchresult = true; scope.parse_repository_options(o); scope.view_files(); } }, true); }, this); } var download_button = Y.one('#'+download_button_id); if (download_button) { download_button.on('click', function(){ alert('download'); }); } var popup_button = Y.one('#'+popup_button_id); if (popup_button) { popup_button.on('click', function(){ window.open(loginurl, 'repo_auth', 'location=0,status=0,scrollbars=0,width=500,height=300'); active_filepicker = this; }, this); } }, search: function(args) { var data = this.logindata; var params = {}; for (var k in data) { if(data[k].type!='popup') { var el = document.getElementsByName(data[k].name)[0]; params[data[k].name] = ''; if(el.type == 'checkbox') { params[data[k].name] = el.checked; } else if(el.type == 'radio') { var tmp = document.getElementsByName(data[k].name); for(var i in tmp) { if (tmp[i].checked) { params[data[k].name] = tmp[i].value; } } } else { params[data[k].name] = el.value; } } } this.request({ scope: scope, action:'search', client_id: client_id, repository_id: repository_id, form: {id: 'fp-form-'+scope.options.client_id,upload:false,useDisabled:true}, callback: function(id, o, args) { o.issearchresult = true; scope.parse_repository_options(o); scope.view_files(); } }, true); }, list: function(args) { var scope = this; if (!args) { args = {}; } if (!args.repo_id) { args.repo_id = scope.active_repo.id; } scope.request({ action:'list', client_id: scope.options.client_id, repository_id: args.repo_id, path:args.path?args.path:'', page:args.page?args.page:'', callback: function(id, obj, args) { if (obj.login) { scope.viewbar.set('disabled', true); scope.print_login(obj); } else if (obj.upload) { scope.viewbar.set('disabled', true); scope.parse_repository_options(obj); scope.create_upload_form(obj); } else if (obj.iframe) { } else if (obj.list) { obj.issearchresult = false; scope.viewbar.set('disabled', false); scope.parse_repository_options(obj); scope.view_files(); } if (obj.msg) { // TODO: Print message } } }, true); }, create_upload_form: function(data) { var client_id = this.options.client_id; Y.one('#panel-'+client_id).set('innerHTML', ''); this.print_header(); var id = data.upload.id+'_'+client_id; var str = '
    '; str += '
    '; str += ''; str += ''; str += ''; str += ''; str += '
    '; str += '
    '; var upload_form = Y.Node.create(str); Y.one('#panel-'+client_id).appendChild(upload_form); var scope = this; Y.one('#'+id+'_action').on('click', function() { Y.use('io-upload-iframe', function() { scope.request({ scope: scope, action:'upload', client_id: client_id, params: {'savepath':scope.options.savepath}, repository_id: scope.active_repo.id, form: {id: id, upload:true}, callback: function(id, o, args) { if (scope.options.editor_target&&scope.options.env=='editor') { scope.options.editor_target.value=o.url; scope.options.editor_target.onchange(); } scope.hide(); o.client_id = client_id; var formcallback_scope = null; if (args.scope.options.magicscope) { formcallback_scope = args.scope.options.magicscope; } else { formcallback_scope = args.scope; } scope.options.formcallback.apply(formcallback_scope, [o]); } }, true); }); }, this); }, print_header: function() { var r = this.active_repo; var scope = this; var client_id = this.options.client_id; var repository_id = this.active_repo.id; var panel = Y.one('#panel-'+client_id); var str = '
    '; str += '
    '; str += '
    '; var head = Y.Node.create(str); panel.appendChild(head); //if(this.active_repo.pages < 8){ this.print_paging('header'); //} var toolbar = Y.one('#repo-tb-'+client_id); if(!r.nosearch) { var html = ' '+M.str.repository.search+''; var search = Y.Node.create(html); search.on('click', function() { scope.request({ scope: scope, action:'searchform', repository_id: repository_id, callback: function(id, obj, args) { var scope = args.scope; var client_id = scope.options.client_id; var repository_id = scope.active_repo.id; var container = document.getElementById('fp-search-dlg'); if(container) { container.innerHTML = ''; container.parentNode.removeChild(container); } var container = document.createElement('DIV'); container.id = 'fp-search-dlg'; var dlg_title = document.createElement('DIV'); dlg_title.className = 'hd'; dlg_title.innerHTML = 'filepicker'; var dlg_body = document.createElement('DIV'); dlg_body.className = 'bd'; var sform = document.createElement('FORM'); sform.method = 'POST'; sform.id = "fp-search-form"; sform.innerHTML = obj.form; dlg_body.appendChild(sform); container.appendChild(dlg_title); container.appendChild(dlg_body); Y.one(document.body).appendChild(container); var search_dialog= null; function dialog_handler() { scope.viewbar.set('disabled', false); scope.request({ scope: scope, action:'search', client_id: client_id, repository_id: repository_id, form: {id: 'fp-search-form',upload:false,useDisabled:true}, callback: function(id, o, args) { scope.parse_repository_options(o); scope.view_files(); } }, true); search_dialog.cancel(); } var search_dialog = new YAHOO.widget.Dialog("fp-search-dlg", { postmethod: 'async', draggable: true, width : "30em", fixedcenter : true, zindex: 766667, visible : false, constraintoviewport : true, buttons: [ { text:M.str.repository.submit, handler:dialog_handler, isDefault:true }, { text:M.str.moodle.cancel, handler:function(){ this.destroy() } }] }); search_dialog.render(); search_dialog.show(); } }); },this); toolbar.appendChild(search); } // weather we use cache for this instance, this button will reload listing anyway if(!r.norefresh) { var html = ' '+M.str.repository.refresh+''; var refresh = Y.Node.create(html); refresh.on('click', function() { this.list(); }, this); toolbar.appendChild(refresh); } if(!r.nologin) { var html = ' '+M.str.repository.logout+''; var logout = Y.Node.create(html); logout.on('click', function() { this.request({ action:'logout', client_id: client_id, repository_id: repository_id, path:'', callback: function(id, obj, args) { scope.viewbar.set('disabled', true); scope.print_login(obj); } }, true); }, this); toolbar.appendChild(logout); } if(r.manage) { var mgr = document.createElement('A'); mgr.href = r.manage; mgr.target = "_blank"; mgr.innerHTML = ' '+M.str.repository.manageurl; toolbar.appendChild(mgr); } if(r.help) { var help = document.createElement('A'); help.href = r.help; help.target = "_blank"; help.innerHTML = ' '+M.str.repository.help; toolbar.appendChild(help); } // only show in icons view if (this.viewmode == 1) { this.print_path(); } }, get_page_button: function(page) { var r = this.active_repo; var css = ''; if (page == r.page) { css = 'class="cur_page" '; } var str = ''; return str; }, print_paging: function(html_id) { var client_id = this.options.client_id; var scope = this; var r = this.active_repo; var str = ''; var action = ''; if(r.pages) { str += '
    '; str += this.get_page_button(1)+'1 '; var span = 5; var ex = (span-1)/2; if (r.page+ex>=r.pages) { var max = r.pages; } else { if (r.page= span) { str += ' ... '; for(var i=r.page-ex; i'; } else { str += this.get_page_button(max)+max+''; str += ' ... '+this.get_page_button(r.pages)+r.pages+''; } str += '
    '; } if (str) { var a = Y.Node.create(str); Y.one('#fp-header-'+client_id).appendChild(a); Y.all('#fp-header-'+client_id+' .fp-paging a').each( function(node, id) { node.on('click', function(e) { var id = node.get('id'); var re = new RegExp("repo-page-(\\d+)", "i"); var result = id.match(re); var args = {}; args.page = result[1]; if (scope.active_repo.issearchresult) { scope.request({ scope: scope, action:'search', client_id: client_id, repository_id: r.id, params: {'page':result[1]}, callback: function(id, o, args) { o.issearchresult = true; scope.parse_repository_options(o); scope.view_files(); } }, true); } else { scope.list(args); } }); }); } }, print_path: function() { var client_id = this.options.client_id; if (this.viewmode == 2) { return; } var panel = Y.one('#panel-'+client_id); var p = this.filepath; if (p && p.length!=0) { var path = Y.Node.create('
    '); panel.appendChild(path); for(var i = 0; i < p.length; i++) { var link = document.createElement('A'); link.href = "###"; link.innerHTML = p[i].name; //link.id = 'path-'+client_id+'-'+repo_id; var sep = Y.Node.create('/'); path.appendChild(link); path.appendChild(sep); } } }, hide: function() { this.mainui.hide(); }, show: function() { if (this.rendered) { var panel = Y.one('#panel-'+this.options.client_id); panel.set('innerHTML', ''); this.mainui.show(); } else { this.launch(); } }, launch: function() { this.render(); } }); M.core_filepicker.instances[options.client_id] = new FilePickerHelper(options); };