diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-12-17 07:24:38 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-12-20 20:14:39 +0100 |
commit | 3fa91ecf68888362ea980dd934b74b7b729219e3 (patch) | |
tree | 84a9324c4b9c43593a06a7f400967a7abaf96b0c /core/js/dist/main.js | |
parent | 59290060c77b2ec19e418992d8e3efa2c67cda4b (diff) | |
download | nextcloud-server-3fa91ecf68888362ea980dd934b74b7b729219e3.tar.gz nextcloud-server-3fa91ecf68888362ea980dd934b74b7b729219e3.zip |
Fix persistent tooltip in the "new folder" input of the file picker
When a new folder is tried to be created in the file picker dialog a
tooltip is shown on the input if the folder name exists already.
However, this tooltip was not cleared, so it was still shown even if the
name was fixed, the folder was created and then the "New folder" input
was shown again.
Now the tooltip is cleared as soon as the input changes, as keeping it
shown in that case did not provide any benefit either (and it is
consistent with how the "new folder" input works in the Files app view).
The input is also cleared whenever the menu that shows the input is
opened again, as otherwise the tooltip would be still shown if the menu
was closed and opened again without changing the input (and the menu
could be opened again after changing to another directory where the new
folder name is no longer duplicated).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js/dist/main.js')
-rw-r--r-- | core/js/dist/main.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/js/dist/main.js b/core/js/dist/main.js index f98111541b8..aa3037d5951 100644 --- a/core/js/dist/main.js +++ b/core/js/dist/main.js @@ -232,7 +232,7 @@ const C={create:"POST",update:"PROPPATCH",patch:"PROPPATCH",delete:"DELETE",read * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - */const H={YES_NO_BUTTONS:70,OK_BUTTONS:71,FILEPICKER_TYPE_CHOOSE:1,FILEPICKER_TYPE_MOVE:2,FILEPICKER_TYPE_COPY:3,FILEPICKER_TYPE_COPY_MOVE:4,FILEPICKER_TYPE_CUSTOM:5,dialogsCounter:0,alert:function(e,t,n,i){this.message(e,t,"alert",H.OK_BUTTON,n,i)},info:function(e,t,n,i){this.message(e,t,"info",H.OK_BUTTON,n,i)},confirm:function(e,t,n,i){return this.message(e,t,"notice",H.YES_NO_BUTTONS,n,i)},confirmDestructive:function(e,t,n,i,r){return this.message(e,t,"none",n,i,void 0===r||r)},confirmHtml:function(e,t,n,i){return this.message(e,t,"notice",H.YES_NO_BUTTONS,n,i,!0)},prompt:function(e,n,i,r,o,a){return s.a.when(this._getMessageTemplate()).then((function(l){var u="oc-dialog-"+H.dialogsCounter+"-content",c="#"+u,h=l.octemplate({dialog_name:u,title:n,message:e,type:"notice"}),p=s()("<input/>");p.attr("type",a?"password":"text").attr("id",u+"-input").attr("placeholder",o);var f=s()("<label/>").attr("for",u+"-input").text(o+": ");h.append(f),h.append(p),void 0===r&&(r=!1),s()("body").append(h),void 0!==i&&(i=d.default.once(i));var m=[{text:t("core","No"),click:function(){void 0!==i&&i(!1,p.val()),s()(c).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==i&&i(!0,p.val()),s()(c).ocdialog("close")},defaultButton:!0}];s()(c).ocdialog({closeOnEscape:!0,modal:r,buttons:m,close:function(){void 0!==i&&i(!1,p.val())}}),p.focus(),H.dialogsCounter++}))},filepicker:function(e,n,i,r,o,a,l,u){var c=this;if(this.filepicker.sortField="name",this.filepicker.sortOrder="asc",!this.filepicker.loading){void 0===a&&(a=this.FILEPICKER_TYPE_CHOOSE);var d=t("core","No files in here"),h=t("files","New folder");a!==this.FILEPICKER_TYPE_COPY&&a!==this.FILEPICKER_TYPE_MOVE&&a!==this.FILEPICKER_TYPE_COPY_MOVE||(d=t("core","No more subfolders in here")),this.filepicker.loading=!0,this.filepicker.filesClient=j.a.Sharing&&j.a.Sharing.PublicApp&&j.a.Sharing.PublicApp.fileList?j.a.Sharing.PublicApp.fileList.filesClient:le.Files.getClient(),this.filelist=null,l=l||"",u=Object.assign({allowDirectoryChooser:!1},u),s.a.when(this._getFilePickerTemplate()).then((function(p){c.filepicker.loading=!1;c.$filePicker&&c.$filePicker.ocdialog("close"),null==r&&(r=[]),"string"==typeof r&&(r=[r]),c.$filePicker=p.octemplate({dialog_name:"oc-dialog-filepicker-content",title:e,emptytext:d,newtext:h,nameCol:t("core","Name"),sizeCol:t("core","Size"),modifiedCol:t("core","Modified")}).data("path",l).data("multiselect",i).data("mimetype",r).data("allowDirectoryChooser",u.allowDirectoryChooser),void 0===o&&(o=!1),void 0===i&&(i=!1),c.$filePicker.find("#picker-view-toggle").remove(),c.$filePicker.find("#picker-filestable").removeClass("view-grid"),s()("body").append(c.$filePicker),c._getGridSettings();var f=c.$filePicker.find(".actions.creatable .button-add");a!==c.FILEPICKER_TYPE_CHOOSE||u.allowDirectoryChooser||f.hide(),f.on("focus",(function(){c.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),f.click()}))})),f.on("blur",(function(){c.$filePicker.ocdialog("unsetEnterCallback")})),le.registerMenu(f,c.$filePicker.find(".menu"),(function(){g.focus(),c.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),c.$filePicker.submit()}));var e=g.val(),t=e.lastIndexOf(".");-1===t&&(t=e.length),g.selectRange(0,t)}));var m=c.$filePicker.find(".filenameform"),g=m.find("input[type='text']");m.find("input[type='submit']").on("click",(function(e){e.stopImmediatePropagation(),e.preventDefault(),m.submit()}));var A=function(){var e=g.val();try{if(function(e){var n=e.trim();if("."===n||".."===n)throw t("files",'"{name}" is an invalid file name.',{name:e});if(0===n.length)throw t("files","File name cannot be empty.");if(-1!==n.indexOf("/"))throw t("files",'"/" is not allowed inside a file name.');if(n.match(le.config.blacklist_files_regex))throw t("files",'"{name}" is not an allowed filetype',{name:e});return!0}(e)){if(c.filelist.find((function(e){return e.name===this}),e))throw t("files","{newName} already exists",{newName:e},void 0,{escape:!1});return!0}}catch(e){g.attr("title",e),g.tooltip({placement:"right",trigger:"manual",container:".newFolderMenu"}),g.tooltip("_fixTitle"),g.tooltip("show"),g.addClass("error")}return!1};m.on("submit",(function(e){if(e.stopPropagation(),e.preventDefault(),A()){var t=g.val();c.filepicker.filesClient.createDirectory(c.$filePicker.data("path")+"/"+t).always((function(e){c._fillFilePicker(c.$filePicker.data("path")+"/"+t)})),le.hideMenus(),c.$filePicker.ocdialog("unsetEnterCallback"),c.$filePicker.click(),g.val(h)}})),g.keypress((function(e){13!==e.keyCode&&13!==e.which||(e.stopImmediatePropagation(),e.preventDefault(),m.submit())})),c.$filePicker.ready((function(){c.$fileListHeader=c.$filePicker.find(".filelist thead tr"),c.$filelist=c.$filePicker.find(".filelist tbody"),c.$filelistContainer=c.$filePicker.find(".filelist-container"),c.$dirTree=c.$filePicker.find(".dirtree"),c.$dirTree.on("click","div:not(:last-child)",c,(function(e){c._handleTreeListSelect(e,a)})),c.$filelist.on("click","tr",(function(e){c._handlePickerClick(e,s()(this),a)})),c.$fileListHeader.on("click","a",(function(e){var t=c.$filePicker.data("path");c.filepicker.sortField=s()(e.currentTarget).data("sort"),c.filepicker.sortOrder="asc"===c.filepicker.sortOrder?"desc":"asc",c._fillFilePicker(t)})),c._fillFilePicker(l)}));var v=function(e){if(void 0!==n){var t;if(!0===i)t=[],c.$filelist.find("tr.filepicker_element_selected").each((function(e,n){t.push(c.$filePicker.data("path")+"/"+s()(n).data("entryname"))}));else{t=c.$filePicker.data("path");var r=c.$filelist.find("tr.filepicker_element_selected").data("entryname");r&&(t+="/"+r)}n(t,e),c.$filePicker.ocdialog("close")}},_=[];a===H.FILEPICKER_TYPE_CHOOSE?_.push({text:t("core","Choose"),click:function(){v(H.FILEPICKER_TYPE_CHOOSE)},defaultButton:!0}):a===H.FILEPICKER_TYPE_CUSTOM?u.buttons.forEach((function(e){_.push({text:e.text,click:function(){v(e.type)},defaultButton:e.defaultButton})})):(a!==H.FILEPICKER_TYPE_COPY&&a!==H.FILEPICKER_TYPE_COPY_MOVE||_.push({text:t("core","Copy"),click:function(){v(H.FILEPICKER_TYPE_COPY)},defaultButton:!1}),a!==H.FILEPICKER_TYPE_MOVE&&a!==H.FILEPICKER_TYPE_COPY_MOVE||_.push({text:t("core","Move"),click:function(){v(H.FILEPICKER_TYPE_MOVE)},defaultButton:!0})),c.$filePicker.ocdialog({closeOnEscape:!0,width:600,height:500,modal:o,buttons:_,style:{buttons:"aside"},close:function(){try{s()(this).ocdialog("destroy").remove()}catch(e){}c.$filePicker=null}});var b=c.$filePicker.closest(".oc-dialog").find(".primary");-1!==c.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||c.$filePicker.data("allowDirectoryChooser")?b.prop("disabled",!1):b.prop("disabled",!0)})).fail((function(e,n){c.filepicker.loading=!1,0!==e&&alert(t("core","Error loading file picker template: {error}",{error:n}))}))}},message:function(e,n,i,r,o,a,l){return s.a.when(this._getMessageTemplate()).then((function(u){var c="oc-dialog-"+H.dialogsCounter+"-content",d="#"+c,h=u.octemplate({dialog_name:c,title:n,message:e,type:i},l?{escapeFunction:""}:{});void 0===a&&(a=!1),s()("body").append(h);var p=[];switch(r){case H.YES_NO_BUTTONS:p=[{text:t("core","No"),click:function(){void 0!==o&&o(!1),s()(d).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==o&&o(!0),s()(d).ocdialog("close")},defaultButton:!0}];break;case H.OK_BUTTON:p[0]={text:t("core","OK"),click:function(){s()(d).ocdialog("close"),void 0!==o&&o()},defaultButton:!0};break;default:if("object"==typeof r)switch(r.type){case H.YES_NO_BUTTONS:p=[{text:r.cancel||t("core","No"),click:function(){void 0!==o&&o(!1),s()(d).ocdialog("close")}},{text:r.confirm||t("core","Yes"),click:function(){void 0!==o&&o(!0),s()(d).ocdialog("close")},defaultButton:!0,classes:r.confirmClasses}]}}s()(d).ocdialog({closeOnEscape:!0,closeCallback:()=>{o&&o(!1)},modal:a,buttons:p}),H.dialogsCounter++})).fail((function(i,r){0===i?alert(n+": "+e):alert(t("core","Error loading message template: {error}",{error:r}))}))},_fileexistsshown:!1,fileexists:function(e,i,r,o){var a=this,l=new s.a.Deferred,u=function(e){var t,n,i,r=document.createElement("canvas"),o=e.width,a=e.height;return o>a?(n=0,t=(o-a)/2):(n=(a-o)/2,t=0),i=Math.min(o,a),r.width=i,r.height=i,r.getContext("2d").drawImage(e,t,n,i,i,0,0,i,i),c(r,i,i,96,96),r.toDataURL("image/png",.7)},c=function(e,t,n,i,r){i=Math.round(i),r=Math.round(r);for(var o=e.getContext("2d").getImageData(0,0,t,n),a=e.getContext("2d").getImageData(0,0,i,r),s=o.data,l=a.data,u=t/i,c=n/r,d=Math.ceil(u/2),h=Math.ceil(c/2),p=0;p<r;p++)for(var f=0;f<i;f++){for(var m=4*(f+p*i),g=0,A=0,v=0,_=0,b=0,y=0,w=0,C=(p+.5)*c,x=Math.floor(p*c);x<(p+1)*c;x++)for(var k=Math.abs(C-(x+.5))/h,M=(f+.5)*u,E=k*k,L=Math.floor(f*u);L<(f+1)*u;L++){var T=Math.abs(M-(L+.5))/d,D=Math.sqrt(E+T*T);D>=-1&&D<=1&&(g=2*D*D*D-3*D*D+1)>0&&(w+=g*s[(T=4*(L+x*t))+3],v+=g,s[T+3]<255&&(g=g*s[T+3]/250),_+=g*s[T],b+=g*s[T+1],y+=g*s[T+2],A+=g)}l[m]=_/A,l[m+1]=b/A,l[m+2]=y/A,l[m+3]=w/v}e.getContext("2d").clearRect(0,0,Math.max(t,i),Math.max(n,r)),e.width=i,e.height=r,e.getContext("2d").putImageData(a,0,0)},d=function(n,i,r){var o=n.find(".template").clone().removeClass("template").addClass("conflict"),a=o.find(".original"),l=o.find(".replacement");o.data("data",e),o.find(".filename").text(i.name),a.find(".size").text(le.Util.humanFileSize(i.size)),a.find(".mtime").text(le.Util.formatDate(i.mtime)),r.size&&r.lastModified&&(l.find(".size").text(le.Util.humanFileSize(r.size)),l.find(".mtime").text(le.Util.formatDate(r.lastModified)));var c=i.directory+"/"+i.name,d={file:c,x:96,y:96,c:i.etag,forceIcon:0},h=Files.generatePreviewUrl(d);h=h.replace(/'/g,"%27"),a.find(".icon").css({"background-image":"url('"+h+"')"}),function(e){var t=new s.a.Deferred,n=e.type&&e.type.split("/").shift();if(window.FileReader&&"image"===n){var i=new FileReader;i.onload=function(e){var n=new Blob([e.target.result]);window.URL=window.URL||window.webkitURL;var i=window.URL.createObjectURL(n),r=new Image;r.src=i,r.onload=function(){var e=u(r);t.resolve(e)}},i.readAsArrayBuffer(e)}else t.reject();return t}(r).then((function(e){l.find(".icon").css("background-image","url("+e+")")}),(function(){c=le.MimeType.getIconUrl(r.type),l.find(".icon").css("background-image","url("+c+")")}));var p=n.find(".conflict").length;a.find("input:checkbox").attr("id","checkbox_original_"+p),l.find("input:checkbox").attr("id","checkbox_replacement_"+p),n.append(o),r.lastModified>i.mtime?l.find(".mtime").css("font-weight","bold"):r.lastModified<i.mtime&&a.find(".mtime").css("font-weight","bold"),r.size&&r.size>i.size?l.find(".size").css("font-weight","bold"):r.size&&r.size<i.size&&a.find(".size").css("font-weight","bold"),"readonly"===i.status&&(a.addClass("readonly").find('input[type="checkbox"]').prop("checked",!0).prop("disabled",!0),a.find(".message").text(t("core","read-only")))},h="#oc-dialog-fileexists-content";if(this._fileexistsshown){var p=s()(h+" .conflicts");d(p,i,r);var f=s()(h+" .conflict").length,m=n("core","{count} file conflict","{count} file conflicts",f,{count:f});s()(h).parent().children(".oc-dialog-title").text(m),s()(window).trigger("resize"),l.resolve()}else this._fileexistsshown=!0,s.a.when(this._getFileExistsTemplate()).then((function(n){var u=t("core","One file conflict"),c=n.octemplate({dialog_name:"oc-dialog-fileexists-content",title:u,type:"fileexists",allnewfiles:t("core","New Files"),allexistingfiles:t("core","Already existing files"),why:t("core","Which files do you want to keep?"),what:t("core","If you select both versions, the copied file will have a number added to its name.")});if(s()("body").append(c),i&&r){var p=c.find(".conflicts");d(p,i,r)}var f=[{text:t("core","Cancel"),classes:"cancel",click:function(){void 0!==o.onCancel&&o.onCancel(e),s()(h).ocdialog("close")}},{text:t("core","Continue"),classes:"continue",click:function(){void 0!==o.onContinue&&o.onContinue(s()(h+" .conflict")),s()(h).ocdialog("close")}}];s()(h).ocdialog({width:500,closeOnEscape:!0,modal:!0,buttons:f,closeButton:null,close:function(){a._fileexistsshown=!1;try{s()(this).ocdialog("destroy").remove()}catch(e){}}}),s()(h).css("height","auto");var m=c.closest(".oc-dialog").find("button.continue");function g(){var e=c.find(".conflicts .checkbox:checked").length;m.prop("disabled",0===e)}m.prop("disabled",!0),s()(h).find(".allnewfiles").on("click",(function(){s()(h).find('.conflict .replacement input[type="checkbox"]').prop("checked",s()(this).prop("checked"))})),s()(h).find(".allexistingfiles").on("click",(function(){s()(h).find('.conflict .original:not(.readonly) input[type="checkbox"]').prop("checked",s()(this).prop("checked"))})),s()(h).find(".conflicts").on("click",".replacement,.original:not(.readonly)",(function(){var e=s()(this).find('input[type="checkbox"]');e.prop("checked",!e.prop("checked"))})),s()(h).find(".conflicts").on("click",'.replacement input[type="checkbox"],.original:not(.readonly) input[type="checkbox"]',(function(){var e=s()(this);e.prop("checked",!e.prop("checked"))})),s()(h).on("click",".replacement,.allnewfiles",(function(){var e=s()(h).find('.conflict .replacement input[type="checkbox"]:checked').length;e===s()(h+" .conflict").length?(s()(h).find(".allnewfiles").prop("checked",!0),s()(h).find(".allnewfiles + .count").text(t("core","(all selected)"))):e>0?(s()(h).find(".allnewfiles").prop("checked",!1),s()(h).find(".allnewfiles + .count").text(t("core","({count} selected)",{count:e}))):(s()(h).find(".allnewfiles").prop("checked",!1),s()(h).find(".allnewfiles + .count").text("")),g()})),s()(h).on("click",".original,.allexistingfiles",(function(){var e=s()(h).find('.conflict .original input[type="checkbox"]:checked').length;e===s()(h+" .conflict").length?(s()(h).find(".allexistingfiles").prop("checked",!0),s()(h).find(".allexistingfiles + .count").text(t("core","(all selected)"))):e>0?(s()(h).find(".allexistingfiles").prop("checked",!1),s()(h).find(".allexistingfiles + .count").text(t("core","({count} selected)",{count:e}))):(s()(h).find(".allexistingfiles").prop("checked",!1),s()(h).find(".allexistingfiles + .count").text("")),g()})),l.resolve()})).fail((function(){l.reject(),alert(t("core","Error loading file exists template"))}));return l.promise()},_getGridSettings:function(){var e=this;s.a.get(le.generateUrl("/apps/files/api/v1/showgridview"),(function(t){e.$showGridView.get(0).checked=t.gridview,e.$showGridView.next("#picker-view-toggle").removeClass("icon-toggle-filelist icon-toggle-pictures").addClass(t.gridview?"icon-toggle-filelist":"icon-toggle-pictures"),s()(".list-container").toggleClass("view-grid",t.gridview)}))},_onGridviewChange:function(){var e=this.$showGridView.is(":checked");le.currentUser&&s.a.post(le.generateUrl("/apps/files/api/v1/showgridview"),{show:e}),this.$showGridView.next("#picker-view-toggle").removeClass("icon-toggle-filelist icon-toggle-pictures").addClass(e?"icon-toggle-filelist":"icon-toggle-pictures"),s()(".list-container").toggleClass("view-grid",e)},_getFilePickerTemplate:function(){var e=s.a.Deferred();if(this.$filePickerTemplate)e.resolve(this.$filePickerTemplate);else{var t=this;s.a.get(le.filePath("core","templates","filepicker.html"),(function(n){t.$filePickerTemplate=s()(n),t.$listTmpl=t.$filePickerTemplate.find(".filelist tbody tr:first-child").detach(),e.resolve(t.$filePickerTemplate)})).fail((function(t,n,i){e.reject(t.status,i)}))}return e.promise()},_getMessageTemplate:function(){var e=s.a.Deferred();if(this.$messageTemplate)e.resolve(this.$messageTemplate);else{var t=this;s.a.get(le.filePath("core","templates","message.html"),(function(n){t.$messageTemplate=s()(n),e.resolve(t.$messageTemplate)})).fail((function(t,n,i){e.reject(t.status,i)}))}return e.promise()},_getFileExistsTemplate:function(){var e=s.a.Deferred();if(this.$fileexistsTemplate)e.resolve(this.$fileexistsTemplate);else{var t=this;s.a.get(le.filePath("files","templates","fileexists.html"),(function(n){t.$fileexistsTemplate=s()(n),e.resolve(t.$fileexistsTemplate)})).fail((function(){e.reject()}))}return e.promise()},_getFileList:function(e,t){return"string"==typeof t&&(t=[t]),s.a.getJSON(le.filePath("files","ajax","list.php"),{dir:e,mimetypes:JSON.stringify(t)})},_fillFilePicker:function(e){var n=this;this.$filelist.empty(),this.$filePicker.find(".emptycontent").hide(),this.$filelistContainer.addClass("icon-loading"),this.$filePicker.data("path",e);var i=this.$filePicker.data("mimetype");"string"==typeof i&&(i=[i]),n.$fileListHeader.find(".sort-indicator").addClass("hidden").removeClass("icon-triangle-n").removeClass("icon-triangle-s"),n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").removeClass("hidden"),"asc"===n.filepicker.sortOrder?n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").addClass("icon-triangle-n"):n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").addClass("icon-triangle-s"),n.filepicker.filesClient.getFolderContents(e).then((function(r,o){n.filelist=o,i&&i.length>0&&-1===i.indexOf("*")&&(o=o.filter((function(e){return"dir"===e.type||-1!==i.indexOf(e.mimetype)})));var a={name:function(e,t){return"dir"===e.type&&"dir"!==t.type?-1:"dir"!==e.type&&"dir"===t.type?1:le.Util.naturalSortCompare(e.name,t.name)},size:function(e,t){return e.size-t.size},mtime:function(e,t){return e.mtime-t.mtime}},l=a[n.filepicker.sortField]||a.name;o=o.sort((function(e,t){var i=function(e){return e.tags&&e.tags.indexOf(le.TAG_FAVORITE)>=0};return i(e)&&!i(t)?-1:!i(e)&&i(t)?1:"asc"===n.filepicker.sortOrder?l(e,t):-l(e,t)})),n._fillSlug(),0===o.length?(n.$filePicker.find(".emptycontent").show(),n.$fileListHeader.hide()):(n.$filePicker.find(".emptycontent").hide(),n.$fileListHeader.show()),n.$filelist.empty(),s.a.each(o,(function(i,r){var o,a;if(r.icon=le.MimeType.getIconUrl(r.mimetype),void 0!==r.size&&r.size>=0?(o=le.Util.humanFileSize(parseInt(r.size,10),!0),a=Math.round(160-Math.pow(r.size/1048576,2))):(o=t("files","Pending"),a=80),r.name.length>=10)var l=Math.min(Math.floor(r.name.length/2),10),u=r.name.substr(0,r.name.length-l),c=r.name.substr(r.name.length-l);else u=r.name,c="";var d=n.$listTmpl.octemplate({type:r.type,dir:e,filename:r.name,filename1:u,filename2:c,date:le.Util.relativeModifiedDate(r.mtime),size:o,sizeColor:a,icon:r.icon});if("file"===r.type){var h={file:e+"/"+r.name,x:100,y:100},p=new Image,f=le.generateUrl("/core/preview.png?")+s.a.param(h);p.onload=function(){p.width>5&&d.find("td.filename").attr("style","background-image:url("+f+")")},p.src=f}n.$filelist.append(d)})),n.$filelistContainer.removeClass("icon-loading")}))},_fillSlug:function(){var e=this.$dirTree.find(".actions.creatable").detach();this.$dirTree.empty();var t=this;t.$dirTree.append(e);var n=this.$filePicker.data("path"),i=s()('<div data-dir="{dir}"><a>{name}</a></div>').addClass("crumb");if(n){var r=n.split("/");s.a.each(r,(function(e,n){if(""===(n=r.pop()))return!1;t.$dirTree.prepend(i.octemplate({dir:r.join("/")+"/"+n,name:n}))}))}i.octemplate({dir:"",name:""},{escapeFunction:null}).prependTo(this.$dirTree)},_handleTreeListSelect:function(e,t){var n=e.data,i=s()(e.target).closest(".crumb").data("dir");n._fillFilePicker(i);var r=e.target.closest(".oc-dialog"),o=s()(".primary",r);this._changeButtonsText(t,i.split(/[/]+/).pop()),-1!==this.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||this.$filePicker.data("allowDirectoryChooser")?o.prop("disabled",!1):o.prop("disabled",!0)},_handlePickerClick:function(e,t,n){var i=this.$filePicker.closest(".oc-dialog").find(".primary");"file"===t.data("type")?(!0===this.$filePicker.data("multiselect")&&e.ctrlKey||this.$filelist.find(".filepicker_element_selected").removeClass("filepicker_element_selected"),t.toggleClass("filepicker_element_selected"),i.prop("disabled",!1)):"dir"===t.data("type")&&(this._fillFilePicker(this.$filePicker.data("path")+"/"+t.data("entryname")),this._changeButtonsText(n,t.data("entryname")),-1!==this.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||this.$filePicker.data("allowDirectoryChooser")?i.prop("disabled",!1):i.prop("disabled",!0))},_changeButtonsText:function(e,n){var i=""===n?t("core","Copy"):t("core","Copy to {folder}",{folder:n}),r=""===n?t("core","Move"):t("core","Move to {folder}",{folder:n}),o=s()(".oc-dialog-buttonrow button");switch(e){case this.FILEPICKER_TYPE_CHOOSE:case this.FILEPICKER_TYPE_CUSTOM:break;case this.FILEPICKER_TYPE_COPY:o.text(i);break;case this.FILEPICKER_TYPE_MOVE:o.text(r);break;case this.FILEPICKER_TYPE_COPY_MOVE:o.eq(0).text(i),o.eq(1).text(r)}}};var N=H,F=r(104); + */const H={YES_NO_BUTTONS:70,OK_BUTTONS:71,FILEPICKER_TYPE_CHOOSE:1,FILEPICKER_TYPE_MOVE:2,FILEPICKER_TYPE_COPY:3,FILEPICKER_TYPE_COPY_MOVE:4,FILEPICKER_TYPE_CUSTOM:5,dialogsCounter:0,alert:function(e,t,n,i){this.message(e,t,"alert",H.OK_BUTTON,n,i)},info:function(e,t,n,i){this.message(e,t,"info",H.OK_BUTTON,n,i)},confirm:function(e,t,n,i){return this.message(e,t,"notice",H.YES_NO_BUTTONS,n,i)},confirmDestructive:function(e,t,n,i,r){return this.message(e,t,"none",n,i,void 0===r||r)},confirmHtml:function(e,t,n,i){return this.message(e,t,"notice",H.YES_NO_BUTTONS,n,i,!0)},prompt:function(e,n,i,r,o,a){return s.a.when(this._getMessageTemplate()).then((function(l){var u="oc-dialog-"+H.dialogsCounter+"-content",c="#"+u,h=l.octemplate({dialog_name:u,title:n,message:e,type:"notice"}),p=s()("<input/>");p.attr("type",a?"password":"text").attr("id",u+"-input").attr("placeholder",o);var f=s()("<label/>").attr("for",u+"-input").text(o+": ");h.append(f),h.append(p),void 0===r&&(r=!1),s()("body").append(h),void 0!==i&&(i=d.default.once(i));var m=[{text:t("core","No"),click:function(){void 0!==i&&i(!1,p.val()),s()(c).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==i&&i(!0,p.val()),s()(c).ocdialog("close")},defaultButton:!0}];s()(c).ocdialog({closeOnEscape:!0,modal:r,buttons:m,close:function(){void 0!==i&&i(!1,p.val())}}),p.focus(),H.dialogsCounter++}))},filepicker:function(e,n,i,r,o,a,l,u){var c=this;if(this.filepicker.sortField="name",this.filepicker.sortOrder="asc",!this.filepicker.loading){void 0===a&&(a=this.FILEPICKER_TYPE_CHOOSE);var d=t("core","No files in here"),h=t("files","New folder");a!==this.FILEPICKER_TYPE_COPY&&a!==this.FILEPICKER_TYPE_MOVE&&a!==this.FILEPICKER_TYPE_COPY_MOVE||(d=t("core","No more subfolders in here")),this.filepicker.loading=!0,this.filepicker.filesClient=j.a.Sharing&&j.a.Sharing.PublicApp&&j.a.Sharing.PublicApp.fileList?j.a.Sharing.PublicApp.fileList.filesClient:le.Files.getClient(),this.filelist=null,l=l||"",u=Object.assign({allowDirectoryChooser:!1},u),s.a.when(this._getFilePickerTemplate()).then((function(p){c.filepicker.loading=!1;c.$filePicker&&c.$filePicker.ocdialog("close"),null==r&&(r=[]),"string"==typeof r&&(r=[r]),c.$filePicker=p.octemplate({dialog_name:"oc-dialog-filepicker-content",title:e,emptytext:d,newtext:h,nameCol:t("core","Name"),sizeCol:t("core","Size"),modifiedCol:t("core","Modified")}).data("path",l).data("multiselect",i).data("mimetype",r).data("allowDirectoryChooser",u.allowDirectoryChooser),void 0===o&&(o=!1),void 0===i&&(i=!1),c.$filePicker.find("#picker-view-toggle").remove(),c.$filePicker.find("#picker-filestable").removeClass("view-grid"),s()("body").append(c.$filePicker),c._getGridSettings();var f=c.$filePicker.find(".actions.creatable .button-add");a!==c.FILEPICKER_TYPE_CHOOSE||u.allowDirectoryChooser||f.hide(),f.on("focus",(function(){c.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),f.click()}))})),f.on("blur",(function(){c.$filePicker.ocdialog("unsetEnterCallback")})),le.registerMenu(f,c.$filePicker.find(".menu"),(function(){g.tooltip("hide"),g.focus(),c.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),c.$filePicker.submit()}));var e=g.val(),t=e.lastIndexOf(".");-1===t&&(t=e.length),g.selectRange(0,t)}));var m=c.$filePicker.find(".filenameform"),g=m.find("input[type='text']");m.find("input[type='submit']").on("click",(function(e){e.stopImmediatePropagation(),e.preventDefault(),m.submit()}));var A=function(){var e=g.val();try{if(function(e){var n=e.trim();if("."===n||".."===n)throw t("files",'"{name}" is an invalid file name.',{name:e});if(0===n.length)throw t("files","File name cannot be empty.");if(-1!==n.indexOf("/"))throw t("files",'"/" is not allowed inside a file name.');if(n.match(le.config.blacklist_files_regex))throw t("files",'"{name}" is not an allowed filetype',{name:e});return!0}(e)){if(c.filelist.find((function(e){return e.name===this}),e))throw t("files","{newName} already exists",{newName:e},void 0,{escape:!1});return!0}}catch(e){g.attr("title",e),g.tooltip({placement:"right",trigger:"manual",container:".newFolderMenu"}),g.tooltip("_fixTitle"),g.tooltip("show"),g.addClass("error")}return!1};m.on("submit",(function(e){if(e.stopPropagation(),e.preventDefault(),A()){var t=g.val();c.filepicker.filesClient.createDirectory(c.$filePicker.data("path")+"/"+t).always((function(e){c._fillFilePicker(c.$filePicker.data("path")+"/"+t)})),le.hideMenus(),c.$filePicker.ocdialog("unsetEnterCallback"),c.$filePicker.click(),g.val(h)}})),g.keypress((function(e){13!==e.keyCode&&13!==e.which||(e.stopImmediatePropagation(),e.preventDefault(),m.submit())})),g.on("input",(function(e){g.tooltip("hide")})),c.$filePicker.ready((function(){c.$fileListHeader=c.$filePicker.find(".filelist thead tr"),c.$filelist=c.$filePicker.find(".filelist tbody"),c.$filelistContainer=c.$filePicker.find(".filelist-container"),c.$dirTree=c.$filePicker.find(".dirtree"),c.$dirTree.on("click","div:not(:last-child)",c,(function(e){c._handleTreeListSelect(e,a)})),c.$filelist.on("click","tr",(function(e){c._handlePickerClick(e,s()(this),a)})),c.$fileListHeader.on("click","a",(function(e){var t=c.$filePicker.data("path");c.filepicker.sortField=s()(e.currentTarget).data("sort"),c.filepicker.sortOrder="asc"===c.filepicker.sortOrder?"desc":"asc",c._fillFilePicker(t)})),c._fillFilePicker(l)}));var v=function(e){if(void 0!==n){var t;if(!0===i)t=[],c.$filelist.find("tr.filepicker_element_selected").each((function(e,n){t.push(c.$filePicker.data("path")+"/"+s()(n).data("entryname"))}));else{t=c.$filePicker.data("path");var r=c.$filelist.find("tr.filepicker_element_selected").data("entryname");r&&(t+="/"+r)}n(t,e),c.$filePicker.ocdialog("close")}},_=[];a===H.FILEPICKER_TYPE_CHOOSE?_.push({text:t("core","Choose"),click:function(){v(H.FILEPICKER_TYPE_CHOOSE)},defaultButton:!0}):a===H.FILEPICKER_TYPE_CUSTOM?u.buttons.forEach((function(e){_.push({text:e.text,click:function(){v(e.type)},defaultButton:e.defaultButton})})):(a!==H.FILEPICKER_TYPE_COPY&&a!==H.FILEPICKER_TYPE_COPY_MOVE||_.push({text:t("core","Copy"),click:function(){v(H.FILEPICKER_TYPE_COPY)},defaultButton:!1}),a!==H.FILEPICKER_TYPE_MOVE&&a!==H.FILEPICKER_TYPE_COPY_MOVE||_.push({text:t("core","Move"),click:function(){v(H.FILEPICKER_TYPE_MOVE)},defaultButton:!0})),c.$filePicker.ocdialog({closeOnEscape:!0,width:600,height:500,modal:o,buttons:_,style:{buttons:"aside"},close:function(){try{s()(this).ocdialog("destroy").remove()}catch(e){}c.$filePicker=null}});var b=c.$filePicker.closest(".oc-dialog").find(".primary");-1!==c.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||c.$filePicker.data("allowDirectoryChooser")?b.prop("disabled",!1):b.prop("disabled",!0)})).fail((function(e,n){c.filepicker.loading=!1,0!==e&&alert(t("core","Error loading file picker template: {error}",{error:n}))}))}},message:function(e,n,i,r,o,a,l){return s.a.when(this._getMessageTemplate()).then((function(u){var c="oc-dialog-"+H.dialogsCounter+"-content",d="#"+c,h=u.octemplate({dialog_name:c,title:n,message:e,type:i},l?{escapeFunction:""}:{});void 0===a&&(a=!1),s()("body").append(h);var p=[];switch(r){case H.YES_NO_BUTTONS:p=[{text:t("core","No"),click:function(){void 0!==o&&o(!1),s()(d).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==o&&o(!0),s()(d).ocdialog("close")},defaultButton:!0}];break;case H.OK_BUTTON:p[0]={text:t("core","OK"),click:function(){s()(d).ocdialog("close"),void 0!==o&&o()},defaultButton:!0};break;default:if("object"==typeof r)switch(r.type){case H.YES_NO_BUTTONS:p=[{text:r.cancel||t("core","No"),click:function(){void 0!==o&&o(!1),s()(d).ocdialog("close")}},{text:r.confirm||t("core","Yes"),click:function(){void 0!==o&&o(!0),s()(d).ocdialog("close")},defaultButton:!0,classes:r.confirmClasses}]}}s()(d).ocdialog({closeOnEscape:!0,closeCallback:()=>{o&&o(!1)},modal:a,buttons:p}),H.dialogsCounter++})).fail((function(i,r){0===i?alert(n+": "+e):alert(t("core","Error loading message template: {error}",{error:r}))}))},_fileexistsshown:!1,fileexists:function(e,i,r,o){var a=this,l=new s.a.Deferred,u=function(e){var t,n,i,r=document.createElement("canvas"),o=e.width,a=e.height;return o>a?(n=0,t=(o-a)/2):(n=(a-o)/2,t=0),i=Math.min(o,a),r.width=i,r.height=i,r.getContext("2d").drawImage(e,t,n,i,i,0,0,i,i),c(r,i,i,96,96),r.toDataURL("image/png",.7)},c=function(e,t,n,i,r){i=Math.round(i),r=Math.round(r);for(var o=e.getContext("2d").getImageData(0,0,t,n),a=e.getContext("2d").getImageData(0,0,i,r),s=o.data,l=a.data,u=t/i,c=n/r,d=Math.ceil(u/2),h=Math.ceil(c/2),p=0;p<r;p++)for(var f=0;f<i;f++){for(var m=4*(f+p*i),g=0,A=0,v=0,_=0,b=0,y=0,w=0,C=(p+.5)*c,x=Math.floor(p*c);x<(p+1)*c;x++)for(var k=Math.abs(C-(x+.5))/h,M=(f+.5)*u,E=k*k,L=Math.floor(f*u);L<(f+1)*u;L++){var T=Math.abs(M-(L+.5))/d,D=Math.sqrt(E+T*T);D>=-1&&D<=1&&(g=2*D*D*D-3*D*D+1)>0&&(w+=g*s[(T=4*(L+x*t))+3],v+=g,s[T+3]<255&&(g=g*s[T+3]/250),_+=g*s[T],b+=g*s[T+1],y+=g*s[T+2],A+=g)}l[m]=_/A,l[m+1]=b/A,l[m+2]=y/A,l[m+3]=w/v}e.getContext("2d").clearRect(0,0,Math.max(t,i),Math.max(n,r)),e.width=i,e.height=r,e.getContext("2d").putImageData(a,0,0)},d=function(n,i,r){var o=n.find(".template").clone().removeClass("template").addClass("conflict"),a=o.find(".original"),l=o.find(".replacement");o.data("data",e),o.find(".filename").text(i.name),a.find(".size").text(le.Util.humanFileSize(i.size)),a.find(".mtime").text(le.Util.formatDate(i.mtime)),r.size&&r.lastModified&&(l.find(".size").text(le.Util.humanFileSize(r.size)),l.find(".mtime").text(le.Util.formatDate(r.lastModified)));var c=i.directory+"/"+i.name,d={file:c,x:96,y:96,c:i.etag,forceIcon:0},h=Files.generatePreviewUrl(d);h=h.replace(/'/g,"%27"),a.find(".icon").css({"background-image":"url('"+h+"')"}),function(e){var t=new s.a.Deferred,n=e.type&&e.type.split("/").shift();if(window.FileReader&&"image"===n){var i=new FileReader;i.onload=function(e){var n=new Blob([e.target.result]);window.URL=window.URL||window.webkitURL;var i=window.URL.createObjectURL(n),r=new Image;r.src=i,r.onload=function(){var e=u(r);t.resolve(e)}},i.readAsArrayBuffer(e)}else t.reject();return t}(r).then((function(e){l.find(".icon").css("background-image","url("+e+")")}),(function(){c=le.MimeType.getIconUrl(r.type),l.find(".icon").css("background-image","url("+c+")")}));var p=n.find(".conflict").length;a.find("input:checkbox").attr("id","checkbox_original_"+p),l.find("input:checkbox").attr("id","checkbox_replacement_"+p),n.append(o),r.lastModified>i.mtime?l.find(".mtime").css("font-weight","bold"):r.lastModified<i.mtime&&a.find(".mtime").css("font-weight","bold"),r.size&&r.size>i.size?l.find(".size").css("font-weight","bold"):r.size&&r.size<i.size&&a.find(".size").css("font-weight","bold"),"readonly"===i.status&&(a.addClass("readonly").find('input[type="checkbox"]').prop("checked",!0).prop("disabled",!0),a.find(".message").text(t("core","read-only")))},h="#oc-dialog-fileexists-content";if(this._fileexistsshown){var p=s()(h+" .conflicts");d(p,i,r);var f=s()(h+" .conflict").length,m=n("core","{count} file conflict","{count} file conflicts",f,{count:f});s()(h).parent().children(".oc-dialog-title").text(m),s()(window).trigger("resize"),l.resolve()}else this._fileexistsshown=!0,s.a.when(this._getFileExistsTemplate()).then((function(n){var u=t("core","One file conflict"),c=n.octemplate({dialog_name:"oc-dialog-fileexists-content",title:u,type:"fileexists",allnewfiles:t("core","New Files"),allexistingfiles:t("core","Already existing files"),why:t("core","Which files do you want to keep?"),what:t("core","If you select both versions, the copied file will have a number added to its name.")});if(s()("body").append(c),i&&r){var p=c.find(".conflicts");d(p,i,r)}var f=[{text:t("core","Cancel"),classes:"cancel",click:function(){void 0!==o.onCancel&&o.onCancel(e),s()(h).ocdialog("close")}},{text:t("core","Continue"),classes:"continue",click:function(){void 0!==o.onContinue&&o.onContinue(s()(h+" .conflict")),s()(h).ocdialog("close")}}];s()(h).ocdialog({width:500,closeOnEscape:!0,modal:!0,buttons:f,closeButton:null,close:function(){a._fileexistsshown=!1;try{s()(this).ocdialog("destroy").remove()}catch(e){}}}),s()(h).css("height","auto");var m=c.closest(".oc-dialog").find("button.continue");function g(){var e=c.find(".conflicts .checkbox:checked").length;m.prop("disabled",0===e)}m.prop("disabled",!0),s()(h).find(".allnewfiles").on("click",(function(){s()(h).find('.conflict .replacement input[type="checkbox"]').prop("checked",s()(this).prop("checked"))})),s()(h).find(".allexistingfiles").on("click",(function(){s()(h).find('.conflict .original:not(.readonly) input[type="checkbox"]').prop("checked",s()(this).prop("checked"))})),s()(h).find(".conflicts").on("click",".replacement,.original:not(.readonly)",(function(){var e=s()(this).find('input[type="checkbox"]');e.prop("checked",!e.prop("checked"))})),s()(h).find(".conflicts").on("click",'.replacement input[type="checkbox"],.original:not(.readonly) input[type="checkbox"]',(function(){var e=s()(this);e.prop("checked",!e.prop("checked"))})),s()(h).on("click",".replacement,.allnewfiles",(function(){var e=s()(h).find('.conflict .replacement input[type="checkbox"]:checked').length;e===s()(h+" .conflict").length?(s()(h).find(".allnewfiles").prop("checked",!0),s()(h).find(".allnewfiles + .count").text(t("core","(all selected)"))):e>0?(s()(h).find(".allnewfiles").prop("checked",!1),s()(h).find(".allnewfiles + .count").text(t("core","({count} selected)",{count:e}))):(s()(h).find(".allnewfiles").prop("checked",!1),s()(h).find(".allnewfiles + .count").text("")),g()})),s()(h).on("click",".original,.allexistingfiles",(function(){var e=s()(h).find('.conflict .original input[type="checkbox"]:checked').length;e===s()(h+" .conflict").length?(s()(h).find(".allexistingfiles").prop("checked",!0),s()(h).find(".allexistingfiles + .count").text(t("core","(all selected)"))):e>0?(s()(h).find(".allexistingfiles").prop("checked",!1),s()(h).find(".allexistingfiles + .count").text(t("core","({count} selected)",{count:e}))):(s()(h).find(".allexistingfiles").prop("checked",!1),s()(h).find(".allexistingfiles + .count").text("")),g()})),l.resolve()})).fail((function(){l.reject(),alert(t("core","Error loading file exists template"))}));return l.promise()},_getGridSettings:function(){var e=this;s.a.get(le.generateUrl("/apps/files/api/v1/showgridview"),(function(t){e.$showGridView.get(0).checked=t.gridview,e.$showGridView.next("#picker-view-toggle").removeClass("icon-toggle-filelist icon-toggle-pictures").addClass(t.gridview?"icon-toggle-filelist":"icon-toggle-pictures"),s()(".list-container").toggleClass("view-grid",t.gridview)}))},_onGridviewChange:function(){var e=this.$showGridView.is(":checked");le.currentUser&&s.a.post(le.generateUrl("/apps/files/api/v1/showgridview"),{show:e}),this.$showGridView.next("#picker-view-toggle").removeClass("icon-toggle-filelist icon-toggle-pictures").addClass(e?"icon-toggle-filelist":"icon-toggle-pictures"),s()(".list-container").toggleClass("view-grid",e)},_getFilePickerTemplate:function(){var e=s.a.Deferred();if(this.$filePickerTemplate)e.resolve(this.$filePickerTemplate);else{var t=this;s.a.get(le.filePath("core","templates","filepicker.html"),(function(n){t.$filePickerTemplate=s()(n),t.$listTmpl=t.$filePickerTemplate.find(".filelist tbody tr:first-child").detach(),e.resolve(t.$filePickerTemplate)})).fail((function(t,n,i){e.reject(t.status,i)}))}return e.promise()},_getMessageTemplate:function(){var e=s.a.Deferred();if(this.$messageTemplate)e.resolve(this.$messageTemplate);else{var t=this;s.a.get(le.filePath("core","templates","message.html"),(function(n){t.$messageTemplate=s()(n),e.resolve(t.$messageTemplate)})).fail((function(t,n,i){e.reject(t.status,i)}))}return e.promise()},_getFileExistsTemplate:function(){var e=s.a.Deferred();if(this.$fileexistsTemplate)e.resolve(this.$fileexistsTemplate);else{var t=this;s.a.get(le.filePath("files","templates","fileexists.html"),(function(n){t.$fileexistsTemplate=s()(n),e.resolve(t.$fileexistsTemplate)})).fail((function(){e.reject()}))}return e.promise()},_getFileList:function(e,t){return"string"==typeof t&&(t=[t]),s.a.getJSON(le.filePath("files","ajax","list.php"),{dir:e,mimetypes:JSON.stringify(t)})},_fillFilePicker:function(e){var n=this;this.$filelist.empty(),this.$filePicker.find(".emptycontent").hide(),this.$filelistContainer.addClass("icon-loading"),this.$filePicker.data("path",e);var i=this.$filePicker.data("mimetype");"string"==typeof i&&(i=[i]),n.$fileListHeader.find(".sort-indicator").addClass("hidden").removeClass("icon-triangle-n").removeClass("icon-triangle-s"),n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").removeClass("hidden"),"asc"===n.filepicker.sortOrder?n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").addClass("icon-triangle-n"):n.$fileListHeader.find("[data-sort="+n.filepicker.sortField+"] .sort-indicator").addClass("icon-triangle-s"),n.filepicker.filesClient.getFolderContents(e).then((function(r,o){n.filelist=o,i&&i.length>0&&-1===i.indexOf("*")&&(o=o.filter((function(e){return"dir"===e.type||-1!==i.indexOf(e.mimetype)})));var a={name:function(e,t){return"dir"===e.type&&"dir"!==t.type?-1:"dir"!==e.type&&"dir"===t.type?1:le.Util.naturalSortCompare(e.name,t.name)},size:function(e,t){return e.size-t.size},mtime:function(e,t){return e.mtime-t.mtime}},l=a[n.filepicker.sortField]||a.name;o=o.sort((function(e,t){var i=function(e){return e.tags&&e.tags.indexOf(le.TAG_FAVORITE)>=0};return i(e)&&!i(t)?-1:!i(e)&&i(t)?1:"asc"===n.filepicker.sortOrder?l(e,t):-l(e,t)})),n._fillSlug(),0===o.length?(n.$filePicker.find(".emptycontent").show(),n.$fileListHeader.hide()):(n.$filePicker.find(".emptycontent").hide(),n.$fileListHeader.show()),n.$filelist.empty(),s.a.each(o,(function(i,r){var o,a;if(r.icon=le.MimeType.getIconUrl(r.mimetype),void 0!==r.size&&r.size>=0?(o=le.Util.humanFileSize(parseInt(r.size,10),!0),a=Math.round(160-Math.pow(r.size/1048576,2))):(o=t("files","Pending"),a=80),r.name.length>=10)var l=Math.min(Math.floor(r.name.length/2),10),u=r.name.substr(0,r.name.length-l),c=r.name.substr(r.name.length-l);else u=r.name,c="";var d=n.$listTmpl.octemplate({type:r.type,dir:e,filename:r.name,filename1:u,filename2:c,date:le.Util.relativeModifiedDate(r.mtime),size:o,sizeColor:a,icon:r.icon});if("file"===r.type){var h={file:e+"/"+r.name,x:100,y:100},p=new Image,f=le.generateUrl("/core/preview.png?")+s.a.param(h);p.onload=function(){p.width>5&&d.find("td.filename").attr("style","background-image:url("+f+")")},p.src=f}n.$filelist.append(d)})),n.$filelistContainer.removeClass("icon-loading")}))},_fillSlug:function(){var e=this.$dirTree.find(".actions.creatable").detach();this.$dirTree.empty();var t=this;t.$dirTree.append(e);var n=this.$filePicker.data("path"),i=s()('<div data-dir="{dir}"><a>{name}</a></div>').addClass("crumb");if(n){var r=n.split("/");s.a.each(r,(function(e,n){if(""===(n=r.pop()))return!1;t.$dirTree.prepend(i.octemplate({dir:r.join("/")+"/"+n,name:n}))}))}i.octemplate({dir:"",name:""},{escapeFunction:null}).prependTo(this.$dirTree)},_handleTreeListSelect:function(e,t){var n=e.data,i=s()(e.target).closest(".crumb").data("dir");n._fillFilePicker(i);var r=e.target.closest(".oc-dialog"),o=s()(".primary",r);this._changeButtonsText(t,i.split(/[/]+/).pop()),-1!==this.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||this.$filePicker.data("allowDirectoryChooser")?o.prop("disabled",!1):o.prop("disabled",!0)},_handlePickerClick:function(e,t,n){var i=this.$filePicker.closest(".oc-dialog").find(".primary");"file"===t.data("type")?(!0===this.$filePicker.data("multiselect")&&e.ctrlKey||this.$filelist.find(".filepicker_element_selected").removeClass("filepicker_element_selected"),t.toggleClass("filepicker_element_selected"),i.prop("disabled",!1)):"dir"===t.data("type")&&(this._fillFilePicker(this.$filePicker.data("path")+"/"+t.data("entryname")),this._changeButtonsText(n,t.data("entryname")),-1!==this.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||this.$filePicker.data("allowDirectoryChooser")?i.prop("disabled",!1):i.prop("disabled",!0))},_changeButtonsText:function(e,n){var i=""===n?t("core","Copy"):t("core","Copy to {folder}",{folder:n}),r=""===n?t("core","Move"):t("core","Move to {folder}",{folder:n}),o=s()(".oc-dialog-buttonrow button");switch(e){case this.FILEPICKER_TYPE_CHOOSE:case this.FILEPICKER_TYPE_CUSTOM:break;case this.FILEPICKER_TYPE_COPY:o.text(i);break;case this.FILEPICKER_TYPE_MOVE:o.text(r);break;case this.FILEPICKER_TYPE_COPY_MOVE:o.eq(0).text(i),o.eq(1).text(r)}}};var N=H,F=r(104); /** * @copyright 2012 Robin Appelman icewind1991@gmail.com * |