diff --git a/core/src/components/MainMenu.js b/core/src/components/MainMenu.js index 3b7fef6afca6e..23b75c1610ee5 100644 --- a/core/src/components/MainMenu.js +++ b/core/src/components/MainMenu.js @@ -72,7 +72,7 @@ export const setUp = () => { if (!$app.is('a')) { $app = $app.closest('a') } - if (event.which === 1 && !event.ctrlKey && !event.metaKey) { + if (event.which === 1 && !event.ctrlKey && !event.metaKey && $app.attr('target') !== '_blank') { $app.find('svg').remove() $app.find('div').remove() // prevent odd double-clicks // no need for theming, loader is already inverted on dark mode @@ -100,7 +100,7 @@ export const setUp = () => { $app = $app.closest('a') } - if (event.which === 1 && !event.ctrlKey && !event.metaKey && $app.parent('#more-apps').length === 0) { + if (event.which === 1 && !event.ctrlKey && !event.metaKey && $app.parent('#more-apps').length === 0 && $app.attr('target') !== '_blank') { $app.find('svg').remove() $app.find('div').remove() // prevent odd double-clicks $app.prepend($('
').addClass( diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index c9ca4e23110cc..3440358c61f90 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -69,6 +69,7 @@
  • target="_blank" rel="noreferrer noopener" class="active" aria-label=""> class="has-unread"> diff --git a/dist/core-main.js b/dist/core-main.js index 83120056014bd..66cb1221fc22b 100644 --- a/dist/core-main.js +++ b/dist/core-main.js @@ -1,3 +1,3 @@ /*! For license information please see core-main.js.LICENSE.txt */ -!function(){var e,i={6772:function(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null})},97782:function(){if("undefined"==typeof console||void 0===console.log){window.console||(window.console={});for(var e=function(){},t=["log","debug","warn","info","error","assert","time","timeEnd"],n=0;n").join(">").split('"').join(""").split("'").join("'")}(e),t);return n.toastElement.toastify=n,c()(n.toastElement)},showUpdate:function(e){return this.updatableNotification&&this.updatableNotification.hideToast(),this.updatableNotification=(0,g.PV)(e,{timeout:g.Rl}),this.updatableNotification.toastElement.toastify=this.updatableNotification,c()(this.updatableNotification.toastElement)},showTemporary:function(e,t){(t=t||{}).timeout=t.timeout||g.TN;var n=(0,g.PV)(e,t);return n.toastElement.toastify=n,c()(n.toastElement)},isHidden:function(){return!c()("#content").find(".toastify").length}},m=h.default.throttle((function(){A.showTemporary(t("core","Connection to server lost"))}),7e3,{trailing:!1}),v=!1,w={enableDynamicSlideToggle:function(){v=!0},showAppSidebar:function(e){(e||c()("#app-sidebar")).removeClass("disappear").show(),c()("#app-content").trigger(new(c().Event)("appresized"))},hideAppSidebar:function(e){(e||c()("#app-sidebar")).hide().addClass("disappear"),c()("#app-content").trigger(new(c().Event)("appresized"))}};function C(e,t,n){"post"!==e&&"delete"!==e||!Ge.PasswordConfirmation.requiresPasswordConfirmation()?(n=n||{},c().ajax({type:e.toUpperCase(),url:(0,d.generateOcsUrl)("apps/provisioning_api/api/v1/config/apps")+t,data:n.data||{},success:n.success,error:n.error})):Ge.PasswordConfirmation.requirePasswordConfirmation(_.bind(C,this,e,t,n))}function b(e){C("get","",e)}function y(e,t){C("get","/"+e,t)}function k(e,t,n,i){(i=i||{}).data={defaultValue:n},C("get","/"+e+"/"+t,i)}function x(e,t,n,i){(i=i||{}).data={value:n},C("post","/"+e+"/"+t,i)}function E(e,t,n){C("delete","/"+e+"/"+t,n)}var P=window.oc_appconfig||{},B={getValue:function(e,t,n,i){k(e,t,n,{success:i})},setValue:function(e,t,n){x(e,t,n)},getApps:function(e){b({success:e})},getKeys:function(e,t){y(e,{success:t})},deleteKey:function(e,t){E(e,t)}},O=void 0!==window._oc_appswebroots&&window._oc_appswebroots,T=o(72316),j=o.n(T),I=o(87240),D={create:"POST",update:"PROPPATCH",patch:"PROPPATCH",delete:"DELETE",read:"PROPFIND"};function z(e,t){if(h.default.isArray(e))return h.default.map(e,(function(e){return z(e,t)}));var n={href:e.href};return h.default.each(e.propStat,(function(e){if("HTTP/1.1 200 OK"===e.status)for(var i in e.properties){var o=i;i in t&&(o=t[i]),n[o]=e.properties[i]}})),n.id||(n.id=N(n.href)),n}function N(e){var t=e.indexOf("?");t>0&&(e=e.substr(0,t));var n,i=e.split("/");do{n=i[i.length-1],i.pop()}while(!n&&i.length>0);return n}function S(e){return e>=200&&e<=299}function M(e,t,n,i){return e.propPatch(t.url,function(e,t){var n,i={};for(n in e){var o=t[n],a=e[n];o||(console.warn('No matching DAV property for property "'+n),o=n),(h.default.isBoolean(a)||h.default.isNumber(a))&&(a=""+a),i[o]=a}return i}(n.changed,t.davProperties),i).then((function(e){S(e.status)?h.default.isFunction(t.success)&&t.success(n.toJSON()):h.default.isFunction(t.error)&&t.error(e)}))}var U=j().noConflict();Object.assign(U,{davCall:function(e,t){var n=new I.dav.Client({baseUrl:e.url,xmlNamespaces:h.default.extend({"DAV:":"d","http://owncloud.org/ns":"oc"},e.xmlNamespaces||{})});n.resolveUrl=function(){return e.url};var i=h.default.extend({"X-Requested-With":"XMLHttpRequest",requesttoken:OC.requestToken},e.headers);return"PROPFIND"===e.type?function(e,t,n,i){return e.propFind(t.url,h.default.values(t.davProperties)||[],t.depth,i).then((function(e){if(S(e.status)){if(h.default.isFunction(t.success)){var n=h.default.invert(t.davProperties),i=z(e.body,n);t.depth>0&&i.shift(),t.success(i)}}else h.default.isFunction(t.error)&&t.error(e)}))}(n,e,0,i):"PROPPATCH"===e.type?M(n,e,t,i):"MKCOL"===e.type?function(e,t,n,i){return e.request(t.type,t.url,i,null).then((function(o){S(o.status)?M(e,t,n,i):h.default.isFunction(t.error)&&t.error(o)}))}(n,e,t,i):function(e,t,n,i){return i["Content-Type"]="application/json",e.request(t.type,t.url,i,t.data).then((function(e){if(S(e.status)){if(h.default.isFunction(t.success)){if("PUT"===t.type||"POST"===t.type||"MKCOL"===t.type){var i=e.body||n.toJSON(),o=e.xhr.getResponseHeader("Content-Location");return"POST"===t.type&&o&&(i.id=N(o)),void t.success(i)}if(207===e.status){var a=h.default.invert(t.davProperties);t.success(z(e.body,a))}else t.success(e.body)}}else h.default.isFunction(t.error)&&t.error(e)}))}(n,e,t,i)},davSync:function(e){return function(t,n,i){var o={type:D[t]||t},a=n instanceof e.Collection;if("update"===t&&(n.hasInnerCollection?o.type="MKCOL":(n.usePUT||n.collection&&n.collection.usePUT)&&(o.type="PUT")),i.url||(o.url=h.default.result(n,"url")||function(){throw new Error('A "url" property or function must be specified')}()),null!=i.data||!n||"create"!==t&&"update"!==t&&"patch"!==t||(o.data=JSON.stringify(i.attrs||n.toJSON(i))),"PROPFIND"!==o.type&&(o.processData=!1),"PROPFIND"===o.type||"PROPPATCH"===o.type){var r=n.davProperties;!r&&n.model&&(r=n.model.prototype.davProperties),r&&(h.default.isFunction(r)?o.davProperties=r.call(n):o.davProperties=r),o.davProperties=h.default.extend(o.davProperties||{},i.davProperties),h.default.isUndefined(i.depth)&&(i.depth=a?1:0)}var s=i.error;i.error=function(e,t,n){i.textStatus=t,i.errorThrown=n,s&&s.call(i.context,e,t,n)};var l=i.xhr=e.davCall(h.default.extend(o,i),n);return n.trigger("request",n,l,i),l}}(U)});var L=U,F=o(76632),R=window._oc_config||{},Q=T.Model.extend({defaults:{fullName:"",lastMessage:"",actions:[],hasOneAction:!1,hasTwoActions:!1,hasManyActions:!1},initialize:function(){0===this.get("actions").length?this.set("hasOneAction",!0):1===this.get("actions").length?(this.set("hasTwoActions",!0),this.set("secondAction",this.get("actions")[0])):this.set("hasManyActions",!0)}}),G=T.Collection.extend({model:Q}),H=T.View.extend({_collection:void 0,_subViews:[],initialize:function(e){this._collection=e.collection},render:function(){var e=this;return e.$el.html(""),e._subViews=[],e._collection.forEach((function(t){var n=new K({model:t});n.render(),e.$el.append(n.$el),n.on("toggle:actionmenu",e._onChildActionMenuToggle,e),e._subViews.push(n)})),e},_onChildActionMenuToggle:function(e){this._subViews.forEach((function(t){t.trigger("parent:toggle:actionmenu",e)}))}}),K=T.View.extend({className:"contact",_template:void 0,_model:void 0,_actionMenuShown:!1,events:{"click .icon-more":"_onToggleActionsMenu"},contactTemplate:o(10944),template:function(e){return this.contactTemplate(e)},initialize:function(e){this._model=e.model,this.on("parent:toggle:actionmenu",this._onOtherActionMenuOpened,this)},render:function(){return this.$el.html(this.template({contact:this._model.toJSON()})),this.delegateEvents(),this.$("div.avatar").imageplaceholder(this._model.get("fullName")),this.$(".top-action").tooltip({placement:"left"}),this.$(".second-action").tooltip({placement:"left"}),this},_onToggleActionsMenu:function(){this._actionMenuShown=!this._actionMenuShown,this._actionMenuShown?this.$(".menu").show():this.$(".menu").hide(),this.trigger("toggle:actionmenu",this.$el)},_onOtherActionMenuOpened:function(e){this.$el.is(e)||(this._actionMenuShown=!1,this.$(".menu").hide())}}),Y=T.View.extend({_loadingTemplate:void 0,_errorTemplate:void 0,_contentTemplate:void 0,_contactsTemplate:void 0,_contacts:void 0,_searchTerm:"",events:{"input #contactsmenu-search":"_onSearch"},templates:{loading:o(95386),error:o(20421),menu:o(66115),list:o(34083)},_onSearch:h.default.debounce((function(e){var t=this.$("#contactsmenu-search").val();t!==this._searchTerm&&(this.trigger("search",this.$("#contactsmenu-search").val()),this._searchTerm=t)}),700),loadingTemplate:function(e){return this.templates.loading(e)},errorTemplate:function(e){return this.templates.error(h.default.extend({couldNotLoadText:t("core","Could not load your contacts")},e))},contentTemplate:function(e){return this.templates.menu(h.default.extend({searchContactsText:t("core","Search contacts …")},e))},contactsTemplate:function(e){return this.templates.list(h.default.extend({noContactsFoundText:t("core","No contacts found"),showAllContactsText:t("core","Show all contacts …"),contactsAppMgmtText:t("core","Install the Contacts app")},e))},initialize:function(e){this.options=e},showLoading:function(e){this.render(),this._contacts=void 0,this.$(".content").html(this.loadingTemplate({loadingText:e}))},showError:function(){this.render(),this._contacts=void 0,this.$(".content").html(this.errorTemplate())},showContacts:function(e,t){this._contacts=e.contacts,this.render({contacts:e.contacts});var n=new H({collection:e.contacts});n.render(),this.$(".content").html(this.contactsTemplate({contacts:e.contacts,searchTerm:t,contactsAppEnabled:e.contactsAppEnabled,contactsAppURL:Ge.generateUrl("/apps/contacts"),canInstallApp:Ge.isUserAdmin(),contactsAppMgmtURL:Ge.generateUrl("/settings/apps/social/contacts")})),this.$("#contactsmenu-contacts").html(n.$el)},render:function(e){var t=this.$("#contactsmenu-search").val();return this.$el.html(this.contentTemplate(e)),this.$("#contactsmenu-search").val(t),this.$("#contactsmenu-search").focus(),this}}),q=function(e){this.initialize(e)};q.prototype={$el:void 0,_$trigger:void 0,_view:void 0,_contactsPromise:void 0,initialize:function(e){this.$el=e.el,this._$trigger=e.trigger,this._view=new Y({el:this.$el}),this._view.on("search",(function(e){this._loadContacts(e)}),this),Ge.registerMenu(this._$trigger,this.$el,function(){this._toggleVisibility(!0)}.bind(this),!0),this.$el.on("beforeHide",function(){this._toggleVisibility(!1)}.bind(this))},_toggleVisibility:function(e){return e?this._loadContacts():(this.$el.html(""),Promise.resolve())},_getContacts:function(e){var t=Ge.generateUrl("/contactsmenu/contacts");return Promise.resolve(c().ajax(t,{method:"POST",data:{filter:e}}))},_loadContacts:function(e){var n=this;return n._contactsPromise||(n._contactsPromise=n._getContacts(e)),h.default.isUndefined(e)||""===e?n._view.showLoading(t("core","Loading your contacts …")):n._view.showLoading(t("core","Looking for {term} …",{term:e})),n._contactsPromise.then((function(t){t.contacts=new G(t.contacts),n._view.showContacts(t,e)}),(function(e){n._view.showError(),console.error("There was an error loading your contacts",e)})).then((function(){delete n._contactsPromise})).catch(console.error.bind(this))}};var W=q,J=document.getElementsByTagName("head")[0].getAttribute("data-user"),V=document.getElementsByTagName("head")[0].getAttribute("data-user-displayname"),Z=void 0!==J&&J;function X(e,t){for(var n=0;n");f.attr("type",r?"password":"text").attr("id",l+"-input").attr("placeholder",a);var p=c()("").attr("for",l+"-input").text(a+": ");d.append(p),d.append(f),void 0===o&&(o=!1),c()("body").append(d),void 0!==i&&(i=h.default.once(i));var g=[{text:t("core","No"),click:function(){void 0!==i&&i(!1,f.val()),c()(u).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==i&&i(!0,f.val()),c()(u).ocdialog("close")},defaultButton:!0}];c()(u).ocdialog({closeOnEscape:!0,modal:o,buttons:g,close:function(){void 0!==i&&i(!1,f.val())}}),f.focus(),ae.dialogsCounter++}))},filepicker:function(e,n,i,o,a,r,s,l){var u=this;if(this.filepicker.sortField="name",this.filepicker.sortOrder="asc",!this.filepicker.loading){void 0===r&&(r=this.FILEPICKER_TYPE_CHOOSE);var d=t("core","No files in here"),f=t("files","New folder");r!==this.FILEPICKER_TYPE_COPY&&r!==this.FILEPICKER_TYPE_MOVE&&r!==this.FILEPICKER_TYPE_COPY_MOVE||(d=t("core","No more subfolders in here")),this.filepicker.loading=!0,this.filepicker.filesClient=ee.Sharing&&ee.Sharing.PublicApp&&ee.Sharing.PublicApp.fileList?ee.Sharing.PublicApp.fileList.filesClient:Ge.Files.getClient(),this.filelist=null,s=s||"",l=Object.assign({allowDirectoryChooser:!1},l),c().when(this._getFilePickerTemplate()).then((function(p){u.filepicker.loading=!1,u.$filePicker&&u.$filePicker.ocdialog("close"),null==o&&(o=[]),"string"==typeof o&&(o=[o]),u.$filePicker=p.octemplate({dialog_name:"oc-dialog-filepicker-content",title:e,emptytext:d,newtext:f,nameCol:t("core","Name"),sizeCol:t("core","Size"),modifiedCol:t("core","Modified")}).data("path",s).data("multiselect",i).data("mimetype",o).data("allowDirectoryChooser",l.allowDirectoryChooser),void 0===a&&(a=!1),void 0===i&&(i=!1),u.$filePicker.find("#picker-view-toggle").remove(),u.$filePicker.find("#picker-filestable").removeClass("view-grid"),c()("body").append(u.$filePicker),u.$showGridView=c()("input#picker-showgridview"),u.$showGridView.on("change",h.default.bind(u._onGridviewChange,u)),u._getGridSettings();var g=u.$filePicker.find(".actions.creatable .button-add");r!==u.FILEPICKER_TYPE_CHOOSE||l.allowDirectoryChooser||g.hide(),g.on("focus",(function(){u.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),g.click()}))})),g.on("blur",(function(){u.$filePicker.ocdialog("unsetEnterCallback")})),Ge.registerMenu(g,u.$filePicker.find(".menu"),(function(){m.tooltip("hide"),m.focus(),u.$filePicker.ocdialog("setEnterCallback",(function(){event.stopImmediatePropagation(),event.preventDefault(),u.$filePicker.submit()}));var e=m.val(),t=e.lastIndexOf(".");-1===t&&(t=e.length),m.selectRange(0,t)}));var A=u.$filePicker.find(".filenameform"),m=A.find("input[type='text']");A.find("input[type='submit']").on("click",(function(e){e.stopImmediatePropagation(),e.preventDefault(),A.submit()}));A.on("submit",(function(e){if(e.stopPropagation(),e.preventDefault(),function(){var e=m.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(Ge.config.blacklist_files_regex))throw t("files",'"{name}" is not an allowed filetype',{name:e});return!0}(e)){if(u.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){m.attr("title",e),m.tooltip({placement:"right",trigger:"manual",container:".newFolderMenu"}),m.tooltip("_fixTitle"),m.tooltip("show"),m.addClass("error")}return!1}()){var n=m.val();u.filepicker.filesClient.createDirectory(u.$filePicker.data("path")+"/"+n).always((function(e){u._fillFilePicker(u.$filePicker.data("path")+"/"+n)})),Ge.hideMenus(),u.$filePicker.ocdialog("unsetEnterCallback"),u.$filePicker.click(),m.val(f)}})),m.keypress((function(e){13!==e.keyCode&&13!==e.which||(e.stopImmediatePropagation(),e.preventDefault(),A.submit())})),m.on("input",(function(e){m.tooltip("hide")})),u.$filePicker.ready((function(){u.$fileListHeader=u.$filePicker.find(".filelist thead tr"),u.$filelist=u.$filePicker.find(".filelist tbody"),u.$filelistContainer=u.$filePicker.find(".filelist-container"),u.$dirTree=u.$filePicker.find(".dirtree"),u.$dirTree.on("click","div:not(:last-child)",u,(function(e){u._handleTreeListSelect(e,r)})),u.$filelist.on("click","tr",(function(e){u._handlePickerClick(e,c()(this),r)})),u.$fileListHeader.on("click","a",(function(e){var t=u.$filePicker.data("path");u.filepicker.sortField=c()(e.currentTarget).data("sort"),u.filepicker.sortOrder="asc"===u.filepicker.sortOrder?"desc":"asc",u._fillFilePicker(t)})),u._fillFilePicker(s)}));var v=function(e){if(void 0!==n){var t;if(!0===i)t=[],u.$filelist.find("tr.filepicker_element_selected").each((function(e,n){t.push(u.$filePicker.data("path")+"/"+c()(n).data("entryname"))}));else{t=u.$filePicker.data("path");var o=u.$filelist.find("tr.filepicker_element_selected").data("entryname");o&&(t+="/"+o)}n(t,e),u.$filePicker.ocdialog("close")}},w=[];r===ae.FILEPICKER_TYPE_CHOOSE?w.push({text:t("core","Choose"),click:function(){v(ae.FILEPICKER_TYPE_CHOOSE)},defaultButton:!0}):r===ae.FILEPICKER_TYPE_CUSTOM?l.buttons.forEach((function(e){w.push({text:e.text,click:function(){v(e.type)},defaultButton:e.defaultButton})})):(r!==ae.FILEPICKER_TYPE_COPY&&r!==ae.FILEPICKER_TYPE_COPY_MOVE||w.push({text:t("core","Copy"),click:function(){v(ae.FILEPICKER_TYPE_COPY)},defaultButton:!1}),r!==ae.FILEPICKER_TYPE_MOVE&&r!==ae.FILEPICKER_TYPE_COPY_MOVE||w.push({text:t("core","Move"),click:function(){v(ae.FILEPICKER_TYPE_MOVE)},defaultButton:!0})),u.$filePicker.ocdialog({closeOnEscape:!0,width:600,height:500,modal:a,buttons:w,style:{buttons:"aside"},close:function(){try{c()(this).ocdialog("destroy").remove()}catch(e){}u.$filePicker=null}});var C=u.$filePicker.closest(".oc-dialog").find(".primary");-1!==u.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||u.$filePicker.data("allowDirectoryChooser")?C.prop("disabled",!1):C.prop("disabled",!0)})).fail((function(e,n){u.filepicker.loading=!1,0!==e&&alert(t("core","Error loading file picker template: {error}",{error:n}))}))}},message:function(e,n,i,o,a,r,s){return c().when(this._getMessageTemplate()).then((function(l){var u="oc-dialog-"+ae.dialogsCounter+"-content",d="#"+u,f=l.octemplate({dialog_name:u,title:n,message:e,type:i},s?{escapeFunction:""}:{});void 0===r&&(r=!1),c()("body").append(f);var p=[];switch(o){case ae.YES_NO_BUTTONS:p=[{text:t("core","No"),click:function(){void 0!==a&&a(!1),c()(d).ocdialog("close")}},{text:t("core","Yes"),click:function(){void 0!==a&&a(!0),c()(d).ocdialog("close")},defaultButton:!0}];break;case ae.OK_BUTTON:p[0]={text:t("core","OK"),click:function(){c()(d).ocdialog("close"),void 0!==a&&a()},defaultButton:!0};break;default:"object"===te(o)&&o.type===ae.YES_NO_BUTTONS&&(p=[{text:o.cancel||t("core","No"),click:function(){void 0!==a&&a(!1),c()(d).ocdialog("close")}},{text:o.confirm||t("core","Yes"),click:function(){void 0!==a&&a(!0),c()(d).ocdialog("close")},defaultButton:!0,classes:o.confirmClasses}])}c()(d).ocdialog({closeOnEscape:!0,closeCallback:function(){a&&a(!1)},modal:r,buttons:p}),ae.dialogsCounter++})).fail((function(i,o){0===i?alert(n+": "+e):alert(t("core","Error loading message template: {error}",{error:o}))}))},_fileexistsshown:!1,fileexists:function(e,i,o,a){var r=this,s=new(c().Deferred),l=function(e,t,n,i,o){i=Math.round(i),o=Math.round(o);for(var a=e.getContext("2d").getImageData(0,0,t,n),r=e.getContext("2d").getImageData(0,0,i,o),s=a.data,l=r.data,c=t/i,u=n/o,d=Math.ceil(c/2),f=Math.ceil(u/2),p=0;p=-1&&j<=1&&(A=2*j*j*j-3*j*j+1)>0&&(y+=A*s[3+(T=4*(O+x*t))],v+=A,s[T+3]<255&&(A=A*s[T+3]/250),w+=A*s[T],C+=A*s[T+1],b+=A*s[T+2],m+=A)}l[g]=w/m,l[g+1]=C/m,l[g+2]=b/m,l[g+3]=y/v}e.getContext("2d").clearRect(0,0,Math.max(t,i),Math.max(n,o)),e.width=i,e.height=o,e.getContext("2d").putImageData(r,0,0)},u=function(n,i,o){var a=n.find(".template").clone().removeClass("template").addClass("conflict"),r=a.find(".original"),s=a.find(".replacement");a.data("data",e),a.find(".filename").text(i.name),r.find(".size").text(Ge.Util.humanFileSize(i.size)),r.find(".mtime").text(Ge.Util.formatDate(i.mtime)),o.size&&o.lastModified&&(s.find(".size").text(Ge.Util.humanFileSize(o.size)),s.find(".mtime").text(Ge.Util.formatDate(o.lastModified)));var u=i.directory+"/"+i.name,d={file:u,x:96,y:96,c:i.etag,forceIcon:0},f=Files.generatePreviewUrl(d);f=f.replace(/'/g,"%27"),r.find(".icon").css({"background-image":"url('"+f+"')"}),function(e){var t=new(c().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),o=new Image;o.src=i,o.onload=function(){var e,n,i,a,r,s,c,u=(e=o,r=document.createElement("canvas"),s=e.width,c=e.height,s>c?(i=0,n=(s-c)/2):(i=(c-s)/2,n=0),a=Math.min(s,c),r.width=a,r.height=a,r.getContext("2d").drawImage(e,n,i,a,a,0,0,a,a),l(r,a,a,96,96),r.toDataURL("image/png",.7));t.resolve(u)}},i.readAsArrayBuffer(e)}else t.reject();return t}(o).then((function(e){s.find(".icon").css("background-image","url("+e+")")}),(function(){u=Ge.MimeType.getIconUrl(o.type),s.find(".icon").css("background-image","url("+u+")")}));var p=n.find(".conflict").length;r.find("input:checkbox").attr("id","checkbox_original_"+p),s.find("input:checkbox").attr("id","checkbox_replacement_"+p),n.append(a),o.lastModified>i.mtime?s.find(".mtime").css("font-weight","bold"):o.lastModifiedi.size?s.find(".size").css("font-weight","bold"):o.size&&o.size0?(c()(f).find(".allnewfiles").prop("checked",!1),c()(f).find(".allnewfiles + .count").text(t("core","({count} selected)",{count:e}))):(c()(f).find(".allnewfiles").prop("checked",!1),c()(f).find(".allnewfiles + .count").text("")),m()})),c()(f).on("click",".original,.allexistingfiles",(function(){var e=c()(f).find('.conflict .original input[type="checkbox"]:checked').length;e===c()(f+" .conflict").length?(c()(f).find(".allexistingfiles").prop("checked",!0),c()(f).find(".allexistingfiles + .count").text(t("core","(all selected)"))):e>0?(c()(f).find(".allexistingfiles").prop("checked",!1),c()(f).find(".allexistingfiles + .count").text(t("core","({count} selected)",{count:e}))):(c()(f).find(".allexistingfiles").prop("checked",!1),c()(f).find(".allexistingfiles + .count").text("")),m()})),s.resolve()})).fail((function(){s.reject(),alert(t("core","Error loading file exists template"))}));return s.promise()},_getGridSettings:function(){var e=this;c().get(Ge.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"),c()(".list-container").toggleClass("view-grid",t.gridview)}))},_onGridviewChange:function(){var e=this.$showGridView.is(":checked");Ge.currentUser&&c().post(Ge.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"),c()(".list-container").toggleClass("view-grid",e)},_getFilePickerTemplate:function(){var e=c().Deferred();if(this.$filePickerTemplate)e.resolve(this.$filePickerTemplate);else{var t=this;c().get(Ge.filePath("core","templates","filepicker.html"),(function(n){t.$filePickerTemplate=c()(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=c().Deferred();if(this.$messageTemplate)e.resolve(this.$messageTemplate);else{var t=this;c().get(Ge.filePath("core","templates","message.html"),(function(n){t.$messageTemplate=c()(n),e.resolve(t.$messageTemplate)})).fail((function(t,n,i){e.reject(t.status,i)}))}return e.promise()},_getFileExistsTemplate:function(){var e=c().Deferred();if(this.$fileexistsTemplate)e.resolve(this.$fileexistsTemplate);else{var t=this;c().get(Ge.filePath("files","templates","fileexists.html"),(function(n){t.$fileexistsTemplate=c()(n),e.resolve(t.$fileexistsTemplate)})).fail((function(){e.reject()}))}return e.promise()},_getFileList:function(e,t){return"string"==typeof t&&(t=[t]),c().getJSON(Ge.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(o,a){n.filelist=a,i&&i.length>0&&-1===i.indexOf("*")&&(a=a.filter((function(e){return"dir"===e.type||-1!==i.indexOf(e.mimetype)})));var r=document.getElementById("showHiddenFiles");null===r||"1"===r.value||(a=a.filter((function(e){return!e.name.startsWith(".")})));var s={name:function(e,t){return"dir"===e.type&&"dir"!==t.type?-1:"dir"!==e.type&&"dir"===t.type?1:Ge.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=s[n.filepicker.sortField]||s.name;a=a.sort((function(e,t){var i=function(e){return e.tags&&e.tags.indexOf(Ge.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===a.length?(n.$filePicker.find(".emptycontent").show(),n.$fileListHeader.hide()):(n.$filePicker.find(".emptycontent").hide(),n.$fileListHeader.show()),n.$filelist.empty(),c().each(a,(function(i,o){var a,r;if(o.icon=Ge.MimeType.getIconUrl(o.mimetype),void 0!==o.size&&o.size>=0?(a=Ge.Util.humanFileSize(parseInt(o.size,10),!0),r=Math.round(160-Math.pow(o.size/1048576,2))):(a=t("files","Pending"),r=80),o.name.length>=10)var s=Math.min(Math.floor(o.name.length/2),10),l=o.name.substr(0,o.name.length-s),u=o.name.substr(o.name.length-s);else l=o.name,u="";var d=n.$listTmpl.octemplate({type:o.type,dir:e,filename:o.name,filename1:l,filename2:u,date:Ge.Util.relativeModifiedDate(o.mtime),size:a,sizeColor:r,icon:o.icon});if("file"===o.type){var f={file:e+"/"+o.name,x:100,y:100},p=new Image,h=Ge.generateUrl("/core/preview.png?")+c().param(f);p.onload=function(){p.width>5&&d.find("td.filename").attr("style","background-image:url("+h+")")},p.src=h}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=c()('
    {name}
    ').addClass("crumb");if(n){var o=n.split("/");c().each(o,(function(e,n){if(""===(n=o.pop()))return!1;t.$dirTree.prepend(i.octemplate({dir:o.join("/")+"/"+n,name:n}))}))}i.octemplate({dir:"",name:""},{escapeFunction:null}).prependTo(this.$dirTree)},_handleTreeListSelect:function(e,t){var n=e.data,i=c()(e.target).closest(".crumb").data("dir");n._fillFilePicker(i);var o=e.target.closest(".oc-dialog"),a=c()(".primary",o);this._changeButtonsText(t,i.split(/[/]+/).pop()),-1!==this.$filePicker.data("mimetype").indexOf("httpd/unix-directory")||this.$filePicker.data("allowDirectoryChooser")?a.prop("disabled",!1):a.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}),o=""===n?t("core","Move"):t("core","Move to {folder}",{folder:n}),a=c()(".oc-dialog-buttonrow button");switch(e){case this.FILEPICKER_TYPE_CHOOSE:case this.FILEPICKER_TYPE_CUSTOM:break;case this.FILEPICKER_TYPE_COPY:a.text(i);break;case this.FILEPICKER_TYPE_MOVE:a.text(o);break;case this.FILEPICKER_TYPE_COPY_MOVE:a.eq(0).text(i),a.eq(1).text(o)}}},re=ae,se=(ne=document,ie=u.emit,oe=ne.getElementsByTagName("head")[0].getAttribute("data-requesttoken"),{getToken:function(){return oe},setToken:function(e){ie("csrf-token-update",{token:oe=e})}}),le=se.getToken,ce=se.setToken,ue=function e(t,n){var i,o,a="";if(this.typelessListeners=[],this.closed=!1,this.listeners={},n)for(i in n)a+=i+"="+encodeURIComponent(n[i])+"&";if(a+="requesttoken="+encodeURIComponent(le()),this.useFallBack||"undefined"==typeof EventSource){var r="oc_eventsource_iframe_"+e.iframeCount;e.fallBackSources[e.iframeCount]=this,this.iframe=c()("