\n'},compiler:[8,">= 4.3.0"],main:function(e,a,t,n,s){var i;return e.propertyIsEnumerable,'\n'+(null!=(i=t.if.call(null!=a?a:e.nullContext||{},null!=a?a.isSharingAllowed:a,{name:"if",hash:{},fn:e.program(1,s,0),inverse:e.noop,data:s}))?i:"")+'\n\n\n'},useData:!0})},function(e,a){!function(){OC.Share||(OC.Share={},OC.Share.Types={});var e=["id","file_parent","mail_send","file_source","item_source","permissions","storage","share_type","parent","stime"],a=OC.Backbone.Model.extend({_linkShareId:null,initialize:function(e,a){_.isUndefined(a.configModel)||(this.configModel=a.configModel),_.isUndefined(a.fileInfoModel)||(this.fileInfoModel=a.fileInfoModel),_.bindAll(this,"addShare")},defaults:{allowPublicUploadStatus:!1,permissions:0,linkShares:[]},saveLinkShare:function(e,a){a=a||{};var t,n=null;(e=_.extend({},e)).expiration&&(e.expireDate=e.expiration,delete e.expiration);var s=this.get("linkShares"),i=_.findIndex(s,(function(a){return a.id===e.cid}));return s.length>0&&-1!==i?(n=s[i].id,t=this.updateShare(n,e,a)):(e=_.defaults(e,{hideDownload:!1,password:"",passwordChanged:!1,sendPasswordByTalk:!1,permissions:OC.PERMISSION_READ,expireDate:this.configModel.getDefaultExpirationDateString(),shareType:OC.Share.SHARE_TYPE_LINK}),t=this.addShare(e,a)),t},addShare:function(e,a){e.shareType;e=_.extend({},e);var t=OC.getCapabilities().files_sharing.default_permissions||OC.PERMISSION_ALL,n=OC.PERMISSION_READ;return this.updatePermissionPossible()&&(n|=OC.PERMISSION_UPDATE),this.createPermissionPossible()&&(n|=OC.PERMISSION_CREATE),this.deletePermissionPossible()&&(n|=OC.PERMISSION_DELETE),this.configModel.get("isResharingAllowed")&&this.sharePermissionPossible()&&(n|=OC.PERMISSION_SHARE),e.permissions=t&n,_.isUndefined(e.path)&&(e.path=this.fileInfoModel.getFullPath()),this._addOrUpdateShare({type:"POST",url:this._getUrl("shares"),data:e,dataType:"json"},a)},updateShare:function(e,a,t){return this._addOrUpdateShare({type:"PUT",url:this._getUrl("shares/"+encodeURIComponent(e)),data:a,dataType:"json"},t)},_addOrUpdateShare:function(e,a){var n=this;return a=a||{},$.ajax(e).always((function(){_.isFunction(a.complete)&&a.complete(n)})).done((function(){n.fetch().done((function(){_.isFunction(a.success)&&a.success(n)}))})).fail((function(e){var s=t("core","Error"),i=e.responseJSON;i&&i.ocs&&i.ocs.meta&&(s=i.ocs.meta.message),_.isFunction(a.error)?a.error(n,s):OC.dialogs.alert(s,t("core","Error while sharing"))}))},removeShare:function(e,a){var n=this;return a=a||{},$.ajax({type:"DELETE",url:this._getUrl("shares/"+encodeURIComponent(e))}).done((function(){n.fetch({success:function(){_.isFunction(a.success)&&a.success(n)}})})).fail((function(e){var s=t("core","Error"),i=e.responseJSON;i.ocs&&i.ocs.meta&&(s=i.ocs.meta.message),_.isFunction(a.error)?a.error(n,s):OC.dialogs.alert(s,t("core","Error removing share"))}))},isPublicUploadAllowed:function(){return this.get("allowPublicUploadStatus")},isPublicEditingAllowed:function(){return this.get("allowPublicEditingStatus")},isHideFileListSet:function(){return this.get("hideFileListStatus")},isFolder:function(){return"folder"===this.get("itemType")},isFile:function(){return"file"===this.get("itemType")},hasReshare:function(){var e=this.get("reshare");return _.isObject(e)&&!_.isUndefined(e.uid_owner)},hasUserShares:function(){return this.getSharesWithCurrentItem().length>0},hasLinkShares:function(){var e=this.get("linkShares");return!!(e&&e.length>0)},getReshareOwner:function(){return this.get("reshare").uid_owner},getReshareOwnerDisplayname:function(){return this.get("reshare").displayname_owner},getReshareNote:function(){return this.get("reshare").note},getReshareWith:function(){return this.get("reshare").share_with},getReshareWithDisplayName:function(){var e=this.get("reshare");return e.share_with_displayname||e.share_with},getReshareType:function(){return this.get("reshare").share_type},getExpireDate:function(e){return this._shareExpireDate(e)},getNote:function(e){return this._shareNote(e)},getSharesWithCurrentItem:function(){var e=this.get("shares")||[],a=this.fileInfoModel.get("id");return _.filter(e,(function(e){return e.item_source===a}))},getShareWith:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.share_with},getShareWithDisplayName:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.share_with_displayname},getShareWithAvatar:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.share_with_avatar},getSharedBy:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.uid_owner},getSharedByDisplayName:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.displayname_owner},getFileOwnerUid:function(e){var a=this.get("shares")[e];if(!_.isObject(a))throw"Unknown Share";return a.uid_file_owner},findShareWithIndex:function(e){var a=this.get("shares");if(!_.isArray(a))throw"Unknown Share";for(var t=0;t0&&-1!==t?a[t].permissions:-1},_getUrl:function(e,a){return a=_.extend({format:"json"},a||{}),OC.linkToOCS("apps/files_sharing/api/v1",2)+e+"?"+OC.buildQueryString(a)},_fetchShares:function(){var e=this.fileInfoModel.getFullPath();return $.ajax({type:"GET",url:this._getUrl("shares",{path:e,reshares:!0})})},_fetchReshare:function(){if(this._reshareFetched)return $.Deferred().resolve([{ocs:{data:[this.get("reshare")]}}]);var e=this.fileInfoModel.getFullPath();return this._reshareFetched=!0,$.ajax({type:"GET",url:this._getUrl("shares",{path:e,shared_with_me:!0})})},_groupReshares:function(e){if(!e||!e.length)return!1;var a=e.shift(),t=a.permissions;return _.each(e,(function(e){e.share_type===OC.Share.SHARE_TYPE_USER&&a.share_type===OC.Share.SHARE_TYPE_GROUP&&(a=e),t|=e.permissions})),a.permissions=t,a},fetch:function(e){var a=this;this.trigger("request",this);var t=$.when(this._fetchShares(),this._fetchReshare());return t.done((function(t,n){a.trigger("sync","GET",this);var s={};_.each(t[0].ocs.data,(function(e){s[e.id]=e}));var i=!1;n[0].ocs.data.length&&(i=a._groupReshares(n[0].ocs.data)),a.set(a.parse({shares:s,reshare:i})),!_.isUndefined(e)&&_.isFunction(e.success)&&e.success()})),t},_legacyFillCurrentShares:function(e){var a=this.fileInfoModel.get("id");if(!e||!e.length)return delete OC.Share.statuses[a],OC.Share.currentShares={},void(OC.Share.itemShares=[]);var t=OC.Share.statuses[a];t||(t={link:!1},OC.Share.statuses[a]=t),t.link=!1,OC.Share.currentShares={},OC.Share.itemShares=[],_.each(e,(function(e){e.share_type===OC.Share.SHARE_TYPE_LINK?(OC.Share.itemShares[e.share_type]=!0,t.link=!0):(OC.Share.itemShares[e.share_type]||(OC.Share.itemShares[e.share_type]=[]),OC.Share.itemShares[e.share_type].push(e.share_with))}))},parse:function(a){if(!1===a)return console.warn("no data was returned"),this.trigger("fetchError"),{};var t=this.fileInfoModel.get("permissions");_.isUndefined(a.reshare)||_.isUndefined(a.reshare.permissions)||a.reshare.uid_owner===OC.currentUser||(t&=a.reshare.permissions);var n=!1;_.isUndefined(a.shares)||$.each(a.shares,(function(e,a){if(a.share_type===OC.Share.SHARE_TYPE_LINK)return n=!!(a.permissions&OC.PERMISSION_CREATE),!0}));var s=!0;_.isUndefined(a.shares)||$.each(a.shares,(function(e,a){if(a.share_type===OC.Share.SHARE_TYPE_LINK)return s=!!(a.permissions&OC.PERMISSION_UPDATE),!0}));var i=!1;_.isUndefined(a.shares)||$.each(a.shares,(function(e,a){if(a.share_type===OC.Share.SHARE_TYPE_LINK)return i=!(a.permissions&OC.PERMISSION_READ),!0}));var l=_.map(a.shares,(function(a){var t;for(t=0;t1&&"0"===e[0]&&"x"===e[1])return null;e=parseInt(e,10),isNaN(e)&&(e=null)}return e},getShareTypes:function(){var e;return e=_.pluck(this.getSharesWithCurrentItem(),"share_type"),this.hasLinkShares()&&e.push(OC.Share.SHARE_TYPE_LINK),_.uniq(e)}});OC.Share.ShareItemModel=a}()},function(e,a){
/**
* @copyright 2017, Roeland Jago Douma
*
* @author Roeland Jago Douma
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*
*/
!function(){OC.Share||(OC.Share={}),OC.Share.Social={};var e=OC.Backbone.Model.extend({defaults:{key:null,url:null,name:null,iconClass:null,newWindow:!0}});OC.Share.Social.Model=e;var a=OC.Backbone.Collection.extend({model:OC.Share.Social.Model,comparator:"key"});OC.Share.Social.Collection=new a}()},function(e,a){!function(){OC.Share||(OC.Share={});var e=OC.Backbone.View.extend({id:"shareDialogResharerInfo",tagName:"div",className:"reshare",configModel:void 0,_template:void 0,initialize:function(e){var a=this;if(this.model.on("change:reshare",(function(){a.render()})),_.isUndefined(e.configModel))throw"missing OC.Share.ShareConfigModel";this.configModel=e.configModel},render:function(){if(!this.model.hasReshare()||this.model.getReshareOwner()===OC.currentUser)return this.$el.empty(),this;var e=this.template(),a=this.model.getReshareOwnerDisplayname(),n=this.model.getReshareNote(),s="";return s=this.model.getReshareType()===OC.Share.SHARE_TYPE_GROUP?t("core","Shared with you and the group {group} by {owner}",{group:this.model.getReshareWithDisplayName(),owner:a},void 0,{escape:!1}):this.model.getReshareType()===OC.Share.SHARE_TYPE_CIRCLE?t("core","Shared with you and {circle} by {owner}",{circle:this.model.getReshareWithDisplayName(),owner:a},void 0,{escape:!1}):this.model.getReshareType()===OC.Share.SHARE_TYPE_ROOM?this.model.get("reshare").share_with_displayname?t("core","Shared with you and the conversation {conversation} by {owner}",{conversation:this.model.getReshareWithDisplayName(),owner:a},void 0,{escape:!1}):t("core","Shared with you in a conversation by {owner}",{owner:a},void 0,{escape:!1}):t("core","Shared with you by {owner}",{owner:a},void 0,{escape:!1}),this.$el.html(e({reshareOwner:this.model.getReshareOwner(),sharedByText:s,shareNote:n,hasShareNote:""!==n})),this.$el.find(".avatar").each((function(){var e=$(this);e.avatar(e.data("username"),32)})),this.$el.find(".reshare").contactsMenu(this.model.getReshareOwner(),OC.Share.SHARE_TYPE_USER,this.$el),this},template:function(){return OC.Share.Templates.sharedialogresharerinfoview}});OC.Share.ShareDialogResharerInfoView=e}()},function(e,a){!function(){OC.Share||(OC.Share={});var e=t("core","Choose a password for the public link"),a=t("core",'Choose a password for the public link or press the "Enter" key'),n=OC.Backbone.View.extend({id:"shareDialogLinkShare",configModel:void 0,showLink:!0,showPending:!1,password:"",newShareId:"new-share",events:{"click .share-menu .icon-more":"onToggleMenu","change .hideDownloadCheckbox":"onHideDownloadChange","click input.share-pass-submit":"onPasswordEntered","keyup input.linkPassText":"onPasswordKeyUp","change .showPasswordCheckbox":"onShowPasswordClick","change .passwordByTalkCheckbox":"onPasswordByTalkChange","change .publicEditingCheckbox":"onAllowPublicEditingChange","click .linkText":"onLinkTextClick","click .pop-up":"onPopUpClick","change .publicUploadRadio":"onPublicUploadChange","click .expireDate":"onExpireDateChange","change .datepicker":"onChangeExpirationDate","click .datepicker":"showDatePicker","click .share-add":"showNoteForm","click .share-note-delete":"deleteNote","click .share-note-submit":"updateNote","click .unshare":"onUnshare","click .new-share":"newShare","submit .enforcedPassForm":"enforcedPasswordSet"},initialize:function(e){var a=this;if(this.model.on("change:permissions",(function(){a.render()})),this.model.on("change:itemType",(function(){a.render()})),this.model.on("change:allowPublicUploadStatus",(function(){a.render()})),this.model.on("change:hideFileListStatus",(function(){a.render()})),this.model.on("change:linkShares",(function(e,t){var n,s=e.previous("linkShares");if(s.length===t.length)for(n=0;n .icon-loading-small");if(!i.hasClass("hidden")&&""===this.password)return!1;n.find(".icon").addClass("hidden"),i.removeClass("hidden"),OC.hideMenus();var l={},r=this.configModel.get("enforcePasswordForPublicLink");if(this.configModel.get("isDefaultExpireDateEnforced")){var o=this.configModel.get("defaultExpireDate"),d=moment().add(o,"day").format("DD-MM-YYYY");l.expireDate=d}r&&""!==this.password&&(l.password=this.password);var h=!1;r&&!this.showPending&&""===this.password?(this.showPending=s,(a=this.render()).$el.find(".pending #enforcedPassText").focus()):$.when(this.model.saveLinkShare(l,{success:function(){if(i.addClass("hidden"),n.find(".icon").removeClass("hidden"),a.render(),h)a.$el.find("li[data-share-id]"),a.$el.find('li[data-share-id="'+h+'"]')},error:function(){}})).fail((function(e){if(a.password="",r&&e&&e.responseJSON&&e.responseJSON.ocs.meta&&e.responseJSON.ocs.meta.message){var s=a.$el.find(".pending #enforcedPassText");s.tooltip("destroy"),s.attr("title",e.responseJSON.ocs.meta.message),s.tooltip({placement:"bottom",trigger:"manual"}),s.tooltip("show")}else OC.Notification.showTemporary(t("core","Unable to create a link share")),i.addClass("hidden"),n.find(".icon").removeClass("hidden")})).then((function(e){h=e.ocs.data.id}))},enforcedPasswordSet:function(e){e.preventDefault();var a=$(e.target).find("input.enforcedPassText");this.password=a.val(),this.showPending=!1,this.newShare(e)},onLinkTextClick:function(e){var a=$(e.target).closest("li[data-share-id]").find(".linkText");a.focus(),a.select()},onHideDownloadChange:function(e){var a=$(e.target).closest("li[data-share-id]"),n=a.data("share-id"),s=a.find(".hideDownloadCheckbox");s.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=!1;s.is(":checked")&&(i=!0),this.model.saveLinkShare({hideDownload:i,cid:n},{success:function(){s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")}})},onShowPasswordClick:function(e){var a=$(e.target).closest("li[data-share-id]"),t=a.data("share-id");a.find(".linkPass").slideToggle(OC.menuSpeed),a.find(".linkPassMenu").toggleClass("hidden"),a.find(".showPasswordCheckbox").is(":checked")?OC.Util.isIE()||a.find(".linkPassText").focus():this.model.saveLinkShare({password:"",cid:t})},onPasswordKeyUp:function(e){13===e.keyCode&&this.onPasswordEntered(e)},onPasswordEntered:function(t){var n=$(t.target).closest("li[data-share-id]"),s=n.data("share-id"),i=n.find(".linkPassMenu .icon-loading-small");if(i.hasClass("hidden")){var l=n.find(".linkPassText");l.removeClass("error"),l.parent().find("input").removeClass("error");var r=l.val();if(n.find(".linkPassText").attr("placeholder")===a)r===a&&(r="");else if(""===r||"**********"===r||r===e)return;i.removeClass("hidden").addClass("inlineblock"),this.model.saveLinkShare({password:r,cid:s},{complete:function(e){i.removeClass("inlineblock").addClass("hidden")},error:function(e,a){l.parent().find("input").addClass("error");var t=l.parent();t.tooltip("destroy"),l.addClass("error"),t.attr("title",a),t.tooltip({placement:"bottom",trigger:"manual"}),t.tooltip("show")}})}},onPasswordByTalkChange:function(e){var a=$(e.target).closest("li[data-share-id]"),n=a.data("share-id"),s=a.find(".passwordByTalkCheckbox");s.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=!1;s.is(":checked")&&(i=!0),this.model.saveLinkShare({sendPasswordByTalk:i,cid:n},{success:function(){s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")}})},onAllowPublicEditingChange:function(e){var a=$(e.target).closest("li[data-share-id]"),n=a.data("share-id"),s=a.find(".publicEditingCheckbox");s.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=OC.PERMISSION_READ;s.is(":checked")&&(i=OC.PERMISSION_UPDATE|OC.PERMISSION_READ),this.model.saveLinkShare({permissions:i,cid:n},{success:function(){s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),s.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")}})},onPublicUploadChange:function(e){var a=$(e.target).closest("li[data-share-id]").data("share-id"),t=e.currentTarget.value;this.model.saveLinkShare({permissions:t,cid:a})},showNoteForm:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),t=(a.closest("li[data-share-id]"),a.closest("li")),n=t.next("li.share-note-form");t.find(".share-note-delete").toggleClass("hidden"),n.toggleClass("hidden"),n.find("textarea").focus()},deleteNote:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),t=a.closest("li[data-share-id]").data("share-id"),n=a.closest("li"),s=n.next("li.share-note-form");s.find(".share-note").val(""),s.addClass("hidden"),n.find(".share-note-delete").addClass("hidden"),this.sendNote("",t,n)},updateNote:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),t=a.closest("li[data-share-id]").data("share-id"),n=a.closest("li.share-note-form"),s=n.prev("li"),i=n.find(".share-note").val().trim();i.length<1||this.sendNote(i,t,s)},sendNote:function(e,a,t){var n=t.next("li.share-note-form"),s=n.find("input.share-note-submit"),i=n.find("input.share-note-error");s.prop("disabled",!0),t.find(".icon-loading-small").removeClass("hidden"),t.find(".icon-edit").hide();$.ajax({method:"PUT",url:OC.linkToOCS("apps/files_sharing/api/v1/shares",2)+a+"?"+OC.buildQueryString({format:"json"}),data:{note:e},complete:function(){s.prop("disabled",!1),t.find(".icon-loading-small").addClass("hidden"),t.find(".icon-edit").show()},error:function(){i.show(),setTimeout((function(){i.hide()}),3e3)}})},render:function(){this.$el.find(".has-tooltip").tooltip(),this.password="";var n=this.template(),s=this.model.sharePermissionPossible();if(!s||!this.showLink||!this.configModel.isShareWithLinkAllowed()){var i={shareAllowed:!1};return s||(i.noSharingPlaceholder=t("core","Resharing is not allowed")),this.$el.html(n(i)),this}var l=this.model.isFolder()&&this.model.createPermissionPossible()&&this.configModel.isPublicUploadEnabled(),r="";this.model.isPublicEditingAllowed()&&(r='checked="checked"');var o=this.configModel.get("enforcePasswordForPublicLink"),d=(this.configModel.get("enableLinkPasswordByDefault"),this.configModel.get("enforcePasswordForPublicLink")?e:a),h=!this.model.isFolder()&&this.model.updatePermissionPossible(),c=this.configModel.get("isDefaultExpireDateEnforced"),u=new Date;u.setDate(u.getDate()+1),$.datepicker.setDefaults({minDate:u}),this.$el.find(".datepicker").datepicker({dateFormat:"dd-mm-yy"});var p=4;OC.getCapabilities().password_policy&&OC.getCapabilities().password_policy.minLength&&(p=OC.getCapabilities().password_policy.minLength);var m={urlLabel:t("core","Link"),hideDownloadLabel:t("core","Hide download"),enablePasswordLabel:o?t("core","Password protection enforced"):t("core","Password protect"),passwordLabel:t("core","Password"),passwordPlaceholderInitial:d,publicUpload:l,publicEditing:h,publicEditingChecked:r,publicEditingLabel:t("core","Allow editing"),mailPrivatePlaceholder:t("core","Email link to person"),mailButtonText:t("core","Send"),publicUploadRWLabel:t("core","Allow upload and editing"),publicUploadRLabel:t("core","Read only"),publicUploadWLabel:t("core","File drop (upload only)"),publicUploadRWValue:OC.PERMISSION_UPDATE|OC.PERMISSION_CREATE|OC.PERMISSION_READ|OC.PERMISSION_DELETE,publicUploadRValue:OC.PERMISSION_READ,publicUploadWValue:OC.PERMISSION_CREATE,expireDateLabel:c?t("core","Expiration date enforced"):t("core","Set expiration date"),expirationLabel:t("core","Expiration"),expirationDatePlaceholder:t("core","Expiration date"),isExpirationEnforced:c,isPasswordEnforced:o,defaultExpireDate:moment().add(1,"day").format("DD-MM-YYYY"),addNoteLabel:t("core","Note to recipient"),unshareLabel:t("core","Unshare"),unshareLinkLabel:t("core","Delete share link"),newShareLabel:t("core","Add another link")},f={isPasswordEnforced:o,enforcedPasswordLabel:t("core","Password protection for links is mandatory"),passwordPlaceholder:d,minPasswordLength:p},g=this.pendingPopoverMenuTemplate(_.extend({},f)),v=this.getShareeList();if(_.isArray(v))for(var S=0;S li").each((function(){var e=$(this),a=e.data("share-with"),t=e.data("share-type");e.find("div.avatar, span.username").contactsMenu(a,t,e)}));var n=this;if(this.getShareeList().forEach((function(e){var a=n.$("#canEdit-"+n.cid+"-"+e.shareId);1===a.length&&(a.prop("checked","checked"===e.editPermissionState),e.isFolder&&a.prop("indeterminate","indeterminate"===e.editPermissionState))})),this.$(".popovermenu").on("afterHide",(function(){n._menuOpen=!1})),this.$(".popovermenu").on("beforeHide",(function(){var e=parseInt(n._menuOpen,10);if(!_.isNaN(e)){var a=".expirationDateContainer-"+n.cid+"-"+e,t="#expirationDatePicker-"+n.cid+"-"+e,s="#expireDate-"+n.cid+"-"+e;$(s).prop("checked")&&($(t).removeClass("hidden-visually"),$(a).removeClass("hasDatepicker"),$(a+" .ui-datepicker").hide())}})),!1!==this._menuOpen){var s=parseInt(this._menuOpen,10);if(!_.isNaN(s)){var i="li[data-share-id="+s+"]";OC.showMenu(null,this.$(i+" .sharingOptionsGroup .popovermenu"))}}return this._renderPermissionChange=!1,autosize(this.$el.find(".share-note-form .share-note")),this.delegateEvents(),this},template:function(e){var a=e.sharees;if(_.isArray(a))for(var t=0;t0)}}else"edit"===a.attr("name")&&a.is(":checked")&&(i|=OC.PERMISSION_UPDATE);$(".permissions",n).not('input[name="edit"]').filter(":checked").each((function(e,a){i|=$(a).data("permissions")})),n.find("input[type=checkbox]").prop("disabled",!0);var h=function(){n.find("input[type=checkbox]").prop("disabled",!1)};this.model.updateShare(s,{permissions:i},{error:function(e,a){OC.dialogs.alert(a,t("core","Error while sharing")),h()},success:h}),this._renderPermissionChange=s},onSecureDropChange:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),n=a.closest("li[data-share-id]"),s=n.data("share-id"),i=OC.PERMISSION_CREATE|OC.PERMISSION_UPDATE|OC.PERMISSION_DELETE|OC.PERMISSION_READ;a.is(":checked")&&(i=OC.PERMISSION_CREATE|OC.PERMISSION_UPDATE|OC.PERMISSION_DELETE),n.find("input[type=checkbox]").prop("disabled",!0);var l=function(){n.find("input[type=checkbox]").prop("disabled",!1)};this.model.updateShare(s,{permissions:i},{error:function(e,a){OC.dialogs.alert(a,t("core","Error while sharing")),l()},success:l}),this._renderPermissionChange=s}});OC.Share.ShareDialogShareeListView=a}()},function(e,a){!function(){OC.Share||(OC.Share={});var e=OC.Backbone.View.extend({_templates:{},_showLink:!0,_lookup:!1,_lookupAllowed:!1,tagName:"div",configModel:void 0,resharerInfoView:void 0,linkShareView:void 0,shareeListView:void 0,_lastSuggestions:void 0,_lastRecommendations:void 0,_pendingOperationsCount:0,events:{"focus .shareWithField":"onShareWithFieldFocus","input .shareWithField":"onShareWithFieldChanged","click .shareWithConfirm":"_confirmShare"},initialize:function(e){var a=this;if(this.model.on("fetchError",(function(){OC.Notification.showTemporary(t("core","Share details could not be loaded for this item."))})),_.isUndefined(e.configModel))throw"missing OC.Share.ShareConfigModel";this.configModel=e.configModel,this.configModel.on("change:isRemoteShareAllowed",(function(){a.render()})),this.configModel.on("change:isRemoteGroupShareAllowed",(function(){a.render()})),this.model.on("change:permissions",(function(){a.render()})),this.model.on("request",this._onRequest,this),this.model.on("sync",this._onEndRequest,this);var n={model:this.model,configModel:this.configModel},s={resharerInfoView:"ShareDialogResharerInfoView",linkShareView:"ShareDialogLinkShareView",shareeListView:"ShareDialogShareeListView"};for(var i in s){var l=s[i];this[i]=_.isUndefined(e[i])?new OC.Share[l](n):e[i]}_.bindAll(this,"autocompleteHandler","_onSelectRecipient","onShareWithFieldChanged","onShareWithFieldFocus"),OC.Plugins.attach("OC.Share.ShareDialogView",this)},onShareWithFieldChanged:function(){var e=this.$el.find(".shareWithField");e.val().length<2&&e.removeClass("error").tooltip("hide")},onShareWithFieldFocus:function(){var e=this.$el.find(".shareWithField");e.autocomplete("search",e.val())},_getSuggestions:function(e,a,n,s){if(this._lastSuggestions&&this._lastSuggestions.searchTerm===e&&this._lastSuggestions.lookup===s&&this._lastSuggestions.perPage===a&&this._lastSuggestions.model===n)return this._lastSuggestions.promise;var i=$.Deferred(),l=this;return $.get(OC.linkToOCS("apps/files_sharing/api/v1")+"sharees",{format:"json",search:e,lookup:s,perPage:a,itemType:n.get("itemType")},(function(s){if(100===s.ocs.meta.statuscode){var r=function(e,a,t,s,i,l,r){var o,d,h,c,u,p,m,f,g;for(void 0===i&&(i=[]),void 0===l&&(l=[]),void 0===r&&(r=[]),o=e.length,f=0;fn?1:0})),O=null,y=k.length,x=(s=[],0);x0&&Math.min(a,OC.config["sharing.maxAutocompleteResults"])<=Math.max(g.length+o.length,v.length+d.length,C.length+c.length,S.length+h.length,E.length+u.length,P.length+p.length,_.length+m.length,b.length);!l._lookup&&w&&s.push({label:t("core","Search globally"),value:{},lookup:!0}),i.resolve(s,f,I,w)}else i.reject(s.ocs.meta.message);var T})).fail((function(){i.reject()})),this._lastSuggestions={searchTerm:e,lookup:s,perPage:a,model:n,promise:i.promise()},this._lastSuggestions.promise},_getRecommendations:function(e){if(this._lastRecommendations&&this._lastRecommendations.model===e)return this._lastRecommendations.promise;var a=$.Deferred();return $.get(OC.linkToOCS("apps/files_sharing/api/v1")+"sharees_recommended",{format:"json",itemType:e.get("itemType")},(function(t){if(100===t.ocs.meta.statuscode){var n=function(a,t,n,s,i,l,r){var o,d,h,c,u,p,m,f,g;for(void 0===i&&(i=[]),void 0===l&&(l=[]),void 0===r&&(r=[]),o=a.length,f=0;fn?1:0})),w=null,E=b.length,P=(t=[],0);P0?(a.autocomplete("option","autoFocus",!0),e(t)):(console.info("no sharing recommendations found"),e())})).fail((function(e){console.error("could not load recommendations",e)}))},autocompleteHandler:function(e,a){if(0===e.term.length)return console.info(e.term,"empty search term -> using recommendations"),void this.recommendationHandler(a);var s=$(".shareWithField"),i=this,l=this.$el.find(".shareWithLoading"),r=this.$el.find(".shareWithConfirm"),o=OC.config["sharing.minSearchStringLength"];if(e.term.trim().length0){if(s.autocomplete("option","autoFocus",!0),a(e),o){var d=t("core","This list is maybe truncated - please refine your search term to see more results.");$(".ui-autocomplete").append('
'+d+"
")}}else{var h=t("core","No users or groups found for {search}",{search:s.val()});i.configModel.get("allowGroupSharing")||(h=t("core","No users found for {search}",{search:$(".shareWithField").val()})),s.addClass("error").attr("data-original-title",h).tooltip("hide").tooltip({placement:"top",trigger:"manual"}).tooltip("fixTitle").tooltip("show"),a()}})).fail((function(e){i._pendingOperationsCount--,0===i._pendingOperationsCount&&(l.addClass("hidden"),l.removeClass("inlineblock"),r.removeClass("hidden")),e?OC.Notification.showTemporary(t("core",'An error occurred ("{message}"). Please try again',{message:e})):OC.Notification.showTemporary(t("core","An error occurred. Please try again"))}))},autocompleteRenderItem:function(e,a){var n="icon-user",s=escapeHTML(a.label),i="",l="";void 0!==a.type&&null!==a.type&&(l=function(e){switch(e){case"HOME":return t("core","Home");case"WORK":return t("core","Work");case"OTHER":return t("core","Other");default:return""+e}}(a.type)+" "),void 0!==a.name&&(s=escapeHTML(a.name)),a.value.shareType===OC.Share.SHARE_TYPE_GROUP?n="icon-contacts-dark":a.value.shareType===OC.Share.SHARE_TYPE_REMOTE?(n="icon-shared",i+=a.value.shareWith):a.value.shareType===OC.Share.SHARE_TYPE_REMOTE_GROUP?(s=t("core","{sharee} (remote group)",{sharee:s},void 0,{escape:!1}),n="icon-shared",i+=a.value.shareWith):a.value.shareType===OC.Share.SHARE_TYPE_EMAIL?(n="icon-mail",i+=a.value.shareWith):a.value.shareType===OC.Share.SHARE_TYPE_CIRCLE?(s=t("core","{sharee} ({type}, {owner})",{sharee:s,type:a.value.circleInfo,owner:a.value.circleOwner},void 0,{escape:!1}),n="icon-circle"):a.value.shareType===OC.Share.SHARE_TYPE_ROOM&&(n="icon-talk");var r=$("");if(a.merged)r.addClass("merged"),s=a.value.shareWith,i=l;else if(a.lookup)s=a.label,n=!1,r.append('');else{var o=$("").appendTo(r);a.value.shareType===OC.Share.SHARE_TYPE_USER||a.value.shareType===OC.Share.SHARE_TYPE_CIRCLE?o.avatar(a.value.shareWith,32,void 0,void 0,void 0,a.label):(void 0===a.uuid&&(a.uuid=s),o.imageplaceholder(a.uuid,s,32)),i=l+i}return""!==i&&r.addClass("with-description"),$("").html(s.replace(new RegExp(this.term,"gi"),"$&")+''+i+"").appendTo(r),r.attr("title",a.value.shareWith),n&&r.append(''),r=$("").append(r),$("