Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.RadFileExplorer=function(_1){
var _2=["itemClick","directoryChange","gridDblClick","display","delete","move","createNewFolder"];
this._initializeEvents(_2);
Telerik.Web.UI.RadFileExplorer.initializeBase(this,[_1]);
this._grid=null;
this._tree=null;
this._ajaxLoadingPanel=null;
this._treeUpdatePanel=null;
this._gridContextMenu=null;
this._gridPane=null;
this._localization={};
this._uniqueId="";
this._initialPath=null;
this._currentGridFolder="";
};
Telerik.Web.UI.RadFileExplorer.prototype={initialize:function(){
Telerik.Web.UI.RadFileExplorer.callBaseMethod(this,"initialize");
var _3=this.get_tree();
var _4=_3.get_selectedNode();
if(_4){
_4.expand();
this.set_currentGridFolder(_4.get_value());
}
var _5=this.get_gridContextMenu();
_5.add_itemClicked(Function.createDelegate(this,this._onGridMenuItemClicked));
this._attachGridHandlers();
this._onTreePanelAjaxRequestStart();
this._onTreePanelAjaxResponseEnd();
},_initializeEvents:function(_6){
if(_6){
var _7=this;
for(var i=0,l=_6.length;i<l;i++){
var _a=_6[i];
this["add_"+_a]=function(_b){
return function(_c){
this.get_events().addHandler(_b,_c);
};
}(_a);
this["remove_"+_a]=function(_d){
return function(_e){
this.get_events().removeHandler(_d,_e);
};
}(_a);
}
}
},_callWebService:function(_f,_10,_11){
if(!_f){
return;
}
if(!_10){
if(this.get_currentGridFolder()==_f){
return;
}
}
this._showLoadingPanel(this.get_gridPane().get_id());
if(!_11){
_11="";
}
var _12=String.format("{{ path : \"{0}\", sortExpression : \"{1}\"}}",_f,_11);
var _13=Function.createDelegate(this,this._onCallbackResponse);
var _14=Function.createDelegate(this,this._onCallbackError);
WebForm_DoCallback(this._uniqueId,_12,_13,_f,_14,true);
},_onCallbackResponse:function(_15,_16){
var _17=this.get_grid();
_17.clearSelectedItems();
var _18=_17.get_masterTableView();
var _19=eval(_15);
_18.set_dataSource(_19);
_18.dataBind();
this._hideLoadingPanel(this.get_gridPane().get_id());
this.set_currentGridFolder(_16);
this.raiseEvent("display",new Telerik.Web.UI.RadFileExplorerEventArgs(_16,""));
},_onCallbackError:function(_1a,_1b){
alert("Callback Loading error:\n"+_1b+"\n"+_1a);
this._hideLoadingPanel(this.get_gridPane().get_id());
},dispose:function(){
Telerik.Web.UI.RadFileExplorer.callBaseMethod(this,"dispose");
},loadFolder:function(_1c){
this.raiseEvent("directoryChange",new Telerik.Web.UI.RadFileExplorerEventArgs(_1c,""));
this.set_currentGridFolder(_1c);
this._postbackTreeAjaxPanel("LoadFolder_"+_1c);
},_attachTreeHandlers:function(){
var _1d=this.get_tree();
_1d.add_nodeClicked(Function.createDelegate(this,this._onTreeNodeClicked));
_1d.add_contextMenuItemClicked(Function.createDelegate(this,this._onTreeContextMenuItemClicked));
_1d.add_nodeDropping(Function.createDelegate(this,this._onTreeNodeDropping));
},_onTreePanelAjaxRequestStart:function(){
this._panelId=this.get_treeUpdatePanel().get_id();
this._treeId=this.get_tree().get_id();
},_onTreePanelAjaxResponseEnd:function(){
this.set_treeUpdatePanel($find(this._panelId));
this.set_tree($find(this._treeId));
this._attachTreeHandlers();
var _1e=this._getSelectedTreeValue();
this._callWebService(_1e,true);
var _1f=this.get_treeUpdatePanel();
_1f.OnRequestStart=Function.createDelegate(this,this._onTreePanelAjaxRequestStart);
_1f.OnResponseEnd=Function.createDelegate(this,this._onTreePanelAjaxResponseEnd);
},_onTreeNodeDropping:function(_20,_21){
if(!_21.get_destNode()){
_21.set_cancel(true);
}else{
var _22=_21.get_sourceNode().get_value();
var _23=_21.get_destNode().get_value();
var _24=new Telerik.Web.UI.RadFileExplorerEventArgs(_22,_23);
this.raiseEvent("move",_24);
_21.set_cancel(_24.get_cancel());
}
},_onTreeContextMenuItemClicked:function(_25,_26){
var _27=_26.get_node();
var _28=_26.get_menuItem().get_value();
switch(_28){
case "Rename":
_27.startEdit();
break;
case "NewFolder":
var _29=this.get_localization()["CreateNewFolder"];
function propmptCallback(arg){
if(arg){
this._createFolder(_27.get_value(),arg);
}
}
radprompt(_29,Function.createDelegate(this,propmptCallback),330,100,null,_29,"NewFolder");
break;
case "Delete":
function confirmCallback(arg){
if(arg){
this._deleteFolder(_27.get_value());
}
}
radconfirm(this.get_localization()["ConfirmDelete"],Function.createDelegate(this,confirmCallback),330,100);
break;
}
},_onTreeNodeClicked:function(){
var _2c=this.get_tree().get_selectedNode();
var _2d=_2c.get_value();
_2c.expand();
if(this.get_currentGridFolder()!=_2d){
this._callWebService(_2d);
this.raiseEvent("directoryChange",new Telerik.Web.UI.RadFileExplorerEventArgs(_2d,""));
}
},_createFolder:function(_2e,_2f){
var _30=new Telerik.Web.UI.RadFileExplorerEventArgs(_2e,_2f);
this.raiseEvent("createNewFolder",_30);
if(_30.get_cancel()){
return false;
}
var _31=_2e+"***"+_2f;
this._postbackTreeAjaxPanel("CallbackFnCreate_"+_31);
},_deleteFolder:function(_32){
var _33=new Telerik.Web.UI.RadFileExplorerEventArgs(_32,"");
this.raiseEvent("delete",_33);
if(_33.get_cancel()){
return false;
}
this._postbackTreeAjaxPanel("CallbackFnDelete_"+_32);
},_postbackTreeAjaxPanel:function(arg){
var _35=this.get_treeUpdatePanel();
_35.ajaxRequest(arg);
},_getSelectedTreeValue:function(){
var _36=this.get_tree().get_selectedNode();
if(_36){
return _36.get_value();
}else{
return null;
}
},_attachGridHandlers:function(){
var _37=this.get_grid();
_37.add_rowClick(Function.createDelegate(this,this._onGridRowClick));
_37.add_rowDblClick(Function.createDelegate(this,this._onGridRowDblClick));
_37.add_rowDataBound(Function.createDelegate(this,this._onGridRowDataBound));
_37.add_rowContextMenu(Function.createDelegate(this,this._onGridRowContextMenu));
_37.add_command(Function.createDelegate(this,this._onGridCommand));
},_isGridRowFolder:function(_38){
if(_38["Length"]){
return false;
}
return true;
},_onGridRowClick:function(_39,_3a){
var _3b=_3a.get_gridDataItem().get_dataItem();
var _3c=_3b["FullPath"]||this.get_currentGridFolder()+"/"+_3b["Name"];
var _3a=new Telerik.Web.UI.RadFileExplorerEventArgs(_3c,"");
this.raiseEvent("itemClick",_3a);
if(_3a.get_cancel()){
return false;
}
},_onGridRowDataBound:function(_3d,_3e){
var _3f=_3e.get_dataItem();
var _40=_3f["Name"];
var _41=_3f["Length"];
var _42;
if(_41==null){
_42="fileextension folder";
_41="&nbsp;";
}else{
var _43=_40.split(".")[_40.split(".").length-1];
_43=_43.toLowerCase();
_42="fileextension "+_43;
}
var tr=_3e.get_item("Name").get_element();
while(tr.cells.length>0){
tr.deleteCell(0);
}
var _45=tr.insertCell(-1);
var _46=document.createElement("DIV");
_45.appendChild(_46);
_46.className=_42;
_46.innerHTML=_40;
_46.setAttribute("unselectable","on");
if(typeof (_46.style.MozUserSelect)!="undefined"){
_46.style.MozUserSelect="none";
}
if(typeof (_46.style.KhtmlUserSelect)!="undefined"){
_46.style.KhtmlUserSelect="none";
}
var _47=tr.insertCell(-1);
_47.style.width="auto";
_47.innerHTML=_41;
},_onGridCommand:function(_48,_49){
var _4a=_49.get_commandName();
if(_4a=="Sort"){
var _4b=_48.get_masterTableView().get_sortExpressions();
var _4c=_4b.toString();
var _4d=_49.get_commandArgument();
_49.set_cancel(true);
this._callWebService(this.get_currentGridFolder(),true,_4c);
}
},_onGridRowDblClick:function(_4e,_4f){
var _50=_4f.get_gridDataItem().get_dataItem();
var _51=_50["FullPath"]||this.get_currentGridFolder()+"/"+_50["Name"];
var _4f=new Telerik.Web.UI.RadFileExplorerEventArgs(_51,"");
this.raiseEvent("gridDblClick",_4f);
if(_4f.get_cancel()){
return false;
}
if(this._isGridRowFolder(_50)){
var _52=this.get_tree().findNodeByValue(_51);
if(_52){
_52.select();
_52.expand();
this._callWebService(_51);
}
}
},_onGridRowContextMenu:function(_53,_54){
var _55=this.get_gridContextMenu();
var evt=_54.get_domEvent();
var _57=_54.get_itemIndexHierarchical();
var _58=_53.get_masterTableView();
var _59=_58.get_dataItems()[_57];
this._gridContextMenuSelectedItem=_59;
_58.selectItem(_59.get_element(),true);
_55.show(evt);
return $telerik.cancelRawEvent(evt);
},_onGridMenuItemClicked:function(_5a,_5b){
var _5c=_5b.get_item().get_value();
var _5d=this._getGridItemDataString("FullPath")||this.get_currentGridFolder()+"/"+this._getGridItemDataString("Name");
switch(_5c){
case "Rename":
var _5e=this._getGridItemDataString("Name");
var _5f=this.get_localization()["Rename"];
function renamePropmptCallback(arg){
if(arg){
this._renameGridItem(_5d,arg);
}
}
radprompt(_5f,Function.createDelegate(this,renamePropmptCallback),330,100,null,_5f,_5e);
break;
case "NewFolder":
var _5f=this.get_localization()["CreateNewFolder"];
function propmptCallback(arg){
if(arg){
this._createFolder(this.get_currentGridFolder(),arg);
}
}
radprompt(_5f,Function.createDelegate(this,propmptCallback),330,100,null,_5f,"NewFolder");
break;
case "Delete":
function confirmCallback(arg){
if(arg){
this._deleteFolder(_5d);
}
}
radconfirm(this.get_localization()["ConfirmDelete"],Function.createDelegate(this,confirmCallback),330,100);
break;
}
this._gridContextMenuSelectedItem=null;
},_renameGridItem:function(_63,_64){
var _65=new Telerik.Web.UI.RadFileExplorerEventArgs(_63,_64);
this.raiseEvent("move",_65);
if(_65.get_cancel()){
return false;
}
this._postbackTreeAjaxPanel("CallbackFnRenameItem_"+_63+"***"+_64);
},_getGridItemDataString:function(key){
var _67=this._gridContextMenuSelectedItem;
if(_67){
var _68=_67.get_dataItem();
return _68[key];
}else{
return null;
}
},_hideLoadingPanel:function(_69){
var _6a=this.get_ajaxLoadingPanel();
if(_6a){
_6a.hide(_69);
}
},_showLoadingPanel:function(_6b){
var _6c=this.get_ajaxLoadingPanel();
if(_6c){
_6c.show(_6b);
}
},get_currentGridFolder:function(){
return this._currentGridFolder;
},set_currentGridFolder:function(_6d){
this._currentGridFolder=_6d;
},get_grid:function(){
return this._grid;
},set_grid:function(_6e){
this._grid=_6e;
},get_tree:function(){
return this._tree;
},set_tree:function(_6f){
this._tree=_6f;
},get_gridContextMenu:function(){
return this._gridContextMenu;
},set_gridContextMenu:function(_70){
this._gridContextMenu=_70;
},get_ajaxLoadingPanel:function(){
return this._ajaxLoadingPanel;
},set_ajaxLoadingPanel:function(_71){
this._ajaxLoadingPanel=_71;
},get_gridPane:function(){
return this._gridPane;
},set_gridPane:function(_72){
this._gridPane=_72;
},get_treeUpdatePanel:function(){
return this._treeUpdatePanel;
},set_treeUpdatePanel:function(_73){
this._treeUpdatePanel=_73;
},get_initialPath:function(){
return this._initialPath;
},set_initialPath:function(_74){
this._initialPath=_74;
},get_webServiceSettings:function(){
return this._webServiceSettings;
},set_webServiceSettings:function(_75){
var _76=Sys.Serialization.JavaScriptSerializer.deserialize(_75);
this._webServiceSettings=new Telerik.Web.UI.WebServiceSettings(_76);
},get_localization:function(){
return this._localization;
}};
Telerik.Web.UI.RadFileExplorer.registerClass("Telerik.Web.UI.RadFileExplorer",Telerik.Web.UI.RadWebControl);
Telerik.Web.UI.RadFileExplorerEventArgs=function(_77,_78){
Telerik.Web.UI.RadFileExplorerEventArgs.initializeBase(this);
this._path=_77;
this._newPath=_78;
};
Telerik.Web.UI.RadFileExplorerEventArgs.prototype={get_path:function(){
return this._path;
},get_newPath:function(){
return this._newPath;
}};
Telerik.Web.UI.RadFileExplorerEventArgs.registerClass("Telerik.Web.UI.RadFileExplorerEventArgs",Sys.CancelEventArgs);

