diff --git a/core/js/dist/share_backend.js b/core/js/dist/share_backend.js index 707d96e88df50..f5c9fc2d3d027 100644 --- a/core/js/dist/share_backend.js +++ b/core/js/dist/share_backend.js @@ -20,5 +20,5 @@ * 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(),l="";return l=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:l,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,hasPasswordChanged:!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,n){var t,l=e.previous("linkShares");if(l.length===n.length)for(t=0;t .icon-loading-small");if(!i.hasClass("hidden")&&""===this.password)return!1;n.find(".icon").addClass("hidden"),i.removeClass("hidden"),OC.hideMenus();var s={},o=this.configModel.get("enforcePasswordForPublicLink");if(this.configModel.get("isDefaultExpireDateEnforced")){var r=this.configModel.get("defaultExpireDate"),c=moment().add(r,"day").format("DD-MM-YYYY");s.expireDate=c}o&&""!==this.password&&(s.password=this.password);var d=!1;o&&!this.showPending&&""===this.password?(this.showPending=l,(a=this.render()).$el.find(".pending #enforcedPassText").focus()):$.when(this.model.saveLinkShare(s,{success:function(){if(i.addClass("hidden"),n.find(".icon").removeClass("hidden"),a.render(),d)a.$el.find("li[data-share-id]"),a.$el.find('li[data-share-id="'+d+'"]')},error:function(){}})).fail(function(e){if(a.password="",o&&e&&e.responseJSON&&e.responseJSON.ocs.meta&&e.responseJSON.ocs.meta.message){var l=a.$el.find(".pending #enforcedPassText");l.tooltip("destroy"),l.attr("title",e.responseJSON.ocs.meta.message),l.tooltip({placement:"bottom",trigger:"manual"}),l.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){d=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"),l=a.find(".hideDownloadCheckbox");l.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=!1;l.is(":checked")&&(i=!0),this.model.saveLinkShare({hideDownload:i,cid:n},{success:function(){l.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),l.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")}})},onShowPasswordClick:function(e){var a=$(e.target).closest("li[data-share-id]"),n=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:n}),this.hasPasswordChanged=!1)},onPasswordKeyUp:function(e){var a=$(e.target).closest("li[data-share-id]").data("share-id");13===e.keyCode?this.onPasswordEntered(e):this.hasPasswordChanged=a},onPasswordEntered:function(n){var t=$(n.target).closest("li[data-share-id]"),l=t.data("share-id"),i=t.find(".linkPassMenu .icon-loading-small");if(i.hasClass("hidden")){var s=t.find(".linkPassText");s.removeClass("error"),s.parent().find("input").removeClass("error");var o=s.val();if(t.find(".linkPassText").attr("placeholder")===a)o===a&&(o="");else if(""===o||"**********"===o||o===e)return;i.removeClass("hidden").addClass("inlineblock"),this.hasPasswordChanged=!1,this.model.saveLinkShare({password:o,cid:l},{complete:function(e){i.removeClass("inlineblock").addClass("hidden")},error:function(e,a){s.parent().find("input").addClass("error");var n=s.parent();n.tooltip("destroy"),s.addClass("error"),n.attr("title",a),n.tooltip({placement:"bottom",trigger:"manual"}),n.tooltip("show")}})}},onPasswordByTalkChange:function(e){var a=$(e.target).closest("li[data-share-id]"),n=a.data("share-id"),l=a.find(".passwordByTalkCheckbox");l.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=!1;l.is(":checked")&&(i=!0),this.model.saveLinkShare({sendPasswordByTalk:i,cid:n},{success:function(){l.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),l.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"),l=a.find(".publicEditingCheckbox");l.siblings(".icon-loading-small").removeClass("hidden").addClass("inlineblock");var i=OC.PERMISSION_READ;l.is(":checked")&&(i=OC.PERMISSION_UPDATE|OC.PERMISSION_READ),this.model.saveLinkShare({permissions:i,cid:n},{success:function(){l.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")},error:function(e,a){OC.Notification.showTemporary(t("core","Unable to toggle this option")),l.siblings(".icon-loading-small").addClass("hidden").removeClass("inlineblock")}})},onPublicUploadChange:function(e){var a=$(e.target).closest("li[data-share-id]").data("share-id"),n=e.currentTarget.value;this.model.saveLinkShare({permissions:n,cid:a})},showNoteForm:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),n=(a.closest("li[data-share-id]"),a.closest("li")),t=n.next("li.share-note-form");n.find(".share-note-delete").toggleClass("hidden"),t.toggleClass("hidden"),t.find("textarea").focus()},deleteNote:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),n=a.closest("li[data-share-id]").data("share-id"),t=a.closest("li"),l=t.next("li.share-note-form");l.find(".share-note").val(""),l.addClass("hidden"),t.find(".share-note-delete").addClass("hidden"),this.sendNote("",n,t)},updateNote:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),n=a.closest("li[data-share-id]").data("share-id"),t=a.closest("li.share-note-form"),l=t.prev("li"),i=t.find(".share-note").val().trim();i.length<1||this.sendNote(i,n,l)},sendNote:function(e,a,n){var t=n.next("li.share-note-form"),l=t.find("input.share-note-submit"),i=t.find("input.share-note-error");l.prop("disabled",!0),n.find(".icon-loading-small").removeClass("hidden"),n.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(){l.prop("disabled",!1),n.find(".icon-loading-small").addClass("hidden"),n.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(),l=this.model.sharePermissionPossible();if(!l||!this.showLink||!this.configModel.isShareWithLinkAllowed()){var i={shareAllowed:!1};return l||(i.noSharingPlaceholder=t("core","Resharing is not allowed")),this.$el.html(n(i)),this}var s=this.model.isFolder()&&this.model.createPermissionPossible()&&this.configModel.isPublicUploadEnabled(),o="";this.model.isPublicEditingAllowed()&&(o='checked="checked"');var r=this.configModel.get("enforcePasswordForPublicLink"),c=(this.configModel.get("enableLinkPasswordByDefault"),this.configModel.get("enforcePasswordForPublicLink")?e:a),d=!this.model.isFolder()&&this.model.updatePermissionPossible(),h=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 m=4;OC.getCapabilities().password_policy&&OC.getCapabilities().password_policy.minLength&&(m=OC.getCapabilities().password_policy.minLength);var p={urlLabel:t("core","Link"),hideDownloadLabel:t("core","Hide download"),enablePasswordLabel:r?t("core","Password protection enforced"):t("core","Password protect"),passwordLabel:t("core","Password"),passwordPlaceholderInitial:c,publicUpload:s,publicEditing:d,publicEditingChecked:o,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:h?t("core","Expiration date enforced"):t("core","Set expiration date"),expirationLabel:t("core","Expiration"),expirationDatePlaceholder:t("core","Expiration date"),isExpirationEnforced:h,isPasswordEnforced:r,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:r,enforcedPasswordLabel:t("core","Password protection for links is mandatory"),passwordPlaceholder:c,minPasswordLength:m},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"),n=e.data("share-type");e.find("div.avatar, span.username").contactsMenu(a,n,e)});var t=this;if(this.getShareeList().forEach(function(e){var a=t.$("#canEdit-"+t.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(){t._menuOpen=!1}),this.$(".popovermenu").on("beforeHide",function(){var e=parseInt(t._menuOpen,10);if(!_.isNaN(e)){var a=".expirationDateContainer-"+t.cid+"-"+e,n="#expirationDatePicker-"+t.cid+"-"+e,l="#expireDate-"+t.cid+"-"+e;$(l).prop("checked")&&($(n).removeClass("hidden-visually"),$(a).removeClass("hasDatepicker"),$(a+" .ui-datepicker").hide())}}),!1!==this._menuOpen){var l=parseInt(this._menuOpen,10);if(!_.isNaN(l)){var i="li[data-share-id="+l+"]";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 n=0;n0)}}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 d=function(){n.find("input[type=checkbox]").prop("disabled",!1)};this.model.updateShare(l,{permissions:i},{error:function(e,a){OC.dialogs.alert(a,t("core","Error while sharing")),d()},success:d}),this._renderPermissionChange=l},onSecureDropChange:function(e){e.preventDefault(),e.stopPropagation();var a=$(e.target),n=a.closest("li[data-share-id]"),l=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 s=function(){n.find("input[type=checkbox]").prop("disabled",!1)};this.model.updateShare(l,{permissions:i},{error:function(e,a){OC.dialogs.alert(a,t("core","Error while sharing")),s()},success:s}),this._renderPermissionChange=l}});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},l={resharerInfoView:"ShareDialogResharerInfoView",linkShareView:"ShareDialogLinkShareView",shareeListView:"ShareDialogShareeListView"};for(var i in l){var s=l[i];this[i]=_.isUndefined(e[i])?new OC.Share[s](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,l){if(this._lastSuggestions&&this._lastSuggestions.searchTerm===e&&this._lastSuggestions.lookup===l&&this._lastSuggestions.perPage===a&&this._lastSuggestions.model===n)return this._lastSuggestions.promise;var i=$.Deferred(),s=this,o=OC.getCapabilities();return o.files_sharing&&o.files_sharing.sharee&&o.files_sharing.sharee.query_lookup_default&&(this._lookup=!0),$.get(OC.linkToOCS("apps/files_sharing/api/v1")+"sharees",{format:"json",search:e,lookup:l,perPage:a,itemType:n.get("itemType")},function(l){if(100===l.ocs.meta.statuscode){var o=function(e,a,t,l,i,s,o){var r,c,d,h,u,m,p,f,g;for(void 0===i&&(i=[]),void 0===s&&(s=[]),void 0===o&&(o=[]),r=e.length,f=0;ft?1:0})),O=null,x=k.length,y=(l=[],0);y0&&Math.min(a,OC.config["sharing.maxAutocompleteResults"])<=Math.max(g.length+r.length,v.length+c.length,C.length+h.length,S.length+d.length,P.length+u.length,E.length+m.length,_.length+p.length,w.length);!s._lookup&&b&&l.push({label:t("core","Search globally"),value:{},lookup:!0}),i.resolve(l,f,T,b)}else i.reject(l.ocs.meta.message);var R}).fail(function(){i.reject()}),this._lastSuggestions={searchTerm:e,lookup:l,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(n){if(100===n.ocs.meta.statuscode){var t=function(a,n,t,l,i,s,o){var r,c,d,h,u,m,p,f,g;for(void 0===i&&(i=[]),void 0===s&&(s=[]),void 0===o&&(o=[]),r=a.length,f=0;ft?1:0})),b=null,P=w.length,E=(n=[],0);E0?(a.autocomplete("option","autoFocus",!0),e(n)):(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 l=$(".shareWithField"),i=this,s=this.$el.find(".shareWithLoading"),o=this.$el.find(".shareWithConfirm"),r=OC.config["sharing.minSearchStringLength"];if(e.term.trim().length0){if(l.autocomplete("option","autoFocus",!0),a(e),r){var c=t("core","This list is maybe truncated - please refine your search term to see more results.");$(".ui-autocomplete").append('
  • '+c+"
  • ")}}else{var d=t("core","No users or groups found for {search}",{search:l.val()});i.configModel.get("allowGroupSharing")||(d=t("core","No users found for {search}",{search:$(".shareWithField").val()})),l.addClass("error").attr("data-original-title",d).tooltip("hide").tooltip({placement:"top",trigger:"manual"}).tooltip("fixTitle").tooltip("show"),a()}}).fail(function(e){i._pendingOperationsCount--,0===i._pendingOperationsCount&&(s.addClass("hidden"),s.removeClass("inlineblock"),o.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",l=escapeHTML(a.label),i="",s="";void 0!==a.type&&null!==a.type&&(s=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&&(l=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?(l=t("core","{sharee} (remote group)",{sharee:l},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?(l=t("core","{sharee} ({type}, {owner})",{sharee:l,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 o=$("