diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-07-19 02:38:53 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-07-19 02:38:53 +0200 |
commit | 8446e16346ece5a934550f69e81d0cad528f7fba (patch) | |
tree | a67e2564a6facbe9e307f619e5f98289009e6941 /module/web/themes/default/js/filemanager.min.js | |
parent | Rename pyLoadCore as pyload and pyLoadCli as pyload-cli (diff) | |
download | pyload-8446e16346ece5a934550f69e81d0cad528f7fba.tar.xz |
New web structure + related code improvements and fixes + added flat and dark themes + updated js
Diffstat (limited to 'module/web/themes/default/js/filemanager.min.js')
-rw-r--r-- | module/web/themes/default/js/filemanager.min.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/module/web/themes/default/js/filemanager.min.js b/module/web/themes/default/js/filemanager.min.js new file mode 100644 index 000000000..d518e44ea --- /dev/null +++ b/module/web/themes/default/js/filemanager.min.js @@ -0,0 +1 @@ +function indicateLoad(){load.start("opacity",1)}function indicateFinish(){load.start("opacity",0)}function indicateSuccess(){indicateFinish(),notify.alert('{{_("Success")}}.',{className:"success"})}function indicateFail(){indicateFinish(),notify.alert('{{_("Failed")}}.',{className:"error"})}function show_rename_box(){bg_show(),$("rename_box").setStyle("display","block"),rename_box.start("opacity",1)}function hide_rename_box(){bg_hide(),rename_box.start("opacity",0).chain(function(){$("rename_box").setStyle("display","none")})}function show_confirm_box(){bg_show(),$("confirm_box").setStyle("display","block"),confirm_box.start("opacity",1)}function hide_confirm_box(){bg_hide(),confirm_box.start("opacity",0).chain(function(){$("confirm_box").setStyle("display","none")})}var load,rename_box,confirm_box;document.addEvent("domready",function(){load=new Fx.Tween($("load-indicator"),{link:"cancel"}),load.set("opacity",0),rename_box=new Fx.Tween($("rename_box")),confirm_box=new Fx.Tween($("confirm_box")),$("rename_reset").addEvent("click",function(){hide_rename_box()}),$("delete_reset").addEvent("click",function(){hide_confirm_box()})});var FilemanagerUI=new Class({initialize:function(e,t){this.url=e,this.type=t,this.directories=[],this.files=[],this.parseChildren()},parseChildren:function(){$("directories-list").getChildren("li.folder").each(function(e){var t=e.getElements("input.path")[0].get("value"),i=e.getElements("input.name")[0].get("value");this.directories.push(new Item(this,t,i,e))}.bind(this)),$("directories-list").getChildren("li.file").each(function(e){var t=e.getElements("input.path")[0].get("value"),i=e.getElements("input.name")[0].get("value");this.files.push(new Item(this,t,i,e))}.bind(this))}}),Item=new Class({initialize:function(e,t,i,n){this.ui=e,this.path=t,this.name=i,this.ele=n,this.directories=[],this.files=[],this.actions=new Array,this.actions["delete"]=this.del,this.actions.rename=this.rename,this.actions.mkdir=this.mkdir,this.parseElement();var s=this.ele.getElements("span")[0];this.buttons=new Fx.Tween(this.ele.getElements(".buttons")[0],{link:"cancel"}),this.buttons.set("opacity",0),s.addEvent("mouseenter",function(){this.buttons.start("opacity",1)}.bind(this)),s.addEvent("mouseleave",function(){this.buttons.start("opacity",0)}.bind(this))},parseElement:function(){this.ele.getChildren("span span.buttons img").each(function(e){e.addEvent("click",this.actions[e.className].bind(this))},this),this.ele.getElements("b")[0].addEvent("click",this.toggle.bind(this));var e=this.ele.getElements("ul");e.length>0&&(e[0].getChildren("li.folder").each(function(e){var t=e.getElements("input.path")[0].get("value"),i=e.getElements("input.name")[0].get("value");this.directories.push(new Item(this,t,i,e))}.bind(this)),e[0].getChildren("li.file").each(function(e){var t=e.getElements("input.path")[0].get("value"),i=e.getElements("input.name")[0].get("value");this.files.push(new Item(this,t,i,e))}.bind(this)))},reorderElements:function(){},del:function(e){$("confirm_form").removeEvents("submit"),$("confirm_form").addEvent("submit",this.deleteDirectory.bind(this)),$$("#confirm_form p").set("html",'{{_(("Are you sure you want to delete the selected item?"))}}'),show_confirm_box(),e.stop()},deleteDirectory:function(e){hide_confirm_box(),new Request.JSON({method:"POST",url:"/json/filemanager/delete",data:{path:this.path,name:this.name},onSuccess:function(e){if("success"==e.response){new Fx.Tween(this.ele).start("opacity",0);var t=this.ele.parentNode;if(this.ele.dispose(),!t.getChildren("li")[0]){var i=new Element("div",{html:'{{ _("Folder is empty") }}'});i.replaces(t)}indicateSuccess()}else indicateFail()}.bind(this),onFailure:indicateFail}).send(),e.stop()},rename:function(e){$("rename_form").removeEvents("submit"),$("rename_form").addEvent("submit",this.renameDirectory.bind(this)),$("path").set("value",this.path),$("old_name").set("value",this.name),$("new_name").set("value",this.name),show_rename_box(),e.stop()},renameDirectory:function(e){hide_rename_box(),new Request.JSON({method:"POST",url:"/json/filemanager/rename",onSuccess:function(e){"success"==e.response?(this.name=$("new_name").get("value"),this.ele.getElements("b")[0].set("html",$("new_name").get("value")),this.reorderElements(),indicateSuccess()):indicateFail()}.bind(this),onFailure:indicateFail}).send($("rename_form").toQueryString()),e.stop()},mkdir:function(e){new Request.JSON({method:"POST",url:"/json/filemanager/mkdir",data:{path:this.path+"/"+this.name,name:'{{_("New folder")}}'},onSuccess:function(e){"success"==e.response?(new Request.HTML({method:"POST",url:"/filemanager/get_dir",data:{path:e.path,name:e.name},onSuccess:function(t){var i=this.ele.getChildren("ul")[0];i||(this.ele.getChildren("div").dispose(),i=new Element("ul"),i.inject(this.ele,"bottom")),t[0].inject(i,"top"),this.directories.push(new Item(this.ui,e.path,e.name,i.firstChild))}.bind(this),onFailure:indicateFail}).send(),indicateSuccess()):indicateFail()}.bind(this),onFailure:indicateFail}).send(),e.stop()},toggle:function(){var e=this.ele.getElement("ul");null==e&&(e=this.ele.getElement("div")),null!=e&&("block"==e.getStyle("display")?e.dissolve():e.reveal())}});
\ No newline at end of file |