2015-08-21 16:40:50 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-08-19 22:03:25 +03:00
|
|
|
/* globals Clipboard, Handlebars */
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
}
|
|
|
|
|
2015-10-16 12:55:23 +03:00
|
|
|
var PASSWORD_PLACEHOLDER = '**********';
|
|
|
|
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link');
|
2017-06-12 17:30:08 +03:00
|
|
|
var PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL = t('core', 'Choose a password for the public link or press the "Enter" key');
|
2015-10-16 12:55:23 +03:00
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
var TEMPLATE =
|
2015-08-21 21:29:12 +03:00
|
|
|
'{{#if shareAllowed}}' +
|
2018-07-20 12:22:24 +03:00
|
|
|
'<ul id="shareLink" class="shareWithList">' +
|
2018-07-19 11:04:37 +03:00
|
|
|
' <li data-share-id="{{cid}}">' +
|
|
|
|
' <div class="avatar icon-public-white"></div><span class="username" title="{{linkShareLabel}}">{{linkShareLabel}}</span>' +
|
|
|
|
' <span class="sharingOptionsGroup">' +
|
|
|
|
' <span class="shareOption"> ' +
|
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
|
|
|
' <input id="linkCheckbox-{{cid}}" {{#if isLinkShare}}checked="checked"{{/if}} type="checkbox" name="linkCheckbox" class="linkCheckbox permissions checkbox">' +
|
|
|
|
' <label for="linkCheckbox-{{cid}}">{{linkShareEnableLabel}}</label>' +
|
|
|
|
' </span>' +
|
2018-08-15 12:50:48 +03:00
|
|
|
' {{#if showMenu}}' +
|
2018-07-19 11:04:37 +03:00
|
|
|
' <div class="share-menu" tabindex="0"><span class="icon icon-more"></span>' +
|
2018-08-15 12:50:48 +03:00
|
|
|
' {{#if showPending}}' +
|
|
|
|
' {{{pendingPopoverMenu}}}' +
|
|
|
|
' {{else}}' +
|
|
|
|
' {{{popoverMenu}}}' +
|
|
|
|
' {{/if}}' +
|
2018-07-19 11:04:37 +03:00
|
|
|
' </div>' +
|
|
|
|
' {{/if}}' +
|
|
|
|
' </span>' +
|
|
|
|
' </li>' +
|
|
|
|
'</ul>' +
|
2015-08-21 21:29:12 +03:00
|
|
|
'{{else}}' +
|
2015-10-16 11:54:45 +03:00
|
|
|
// FIXME: this doesn't belong in this view
|
2015-12-07 18:53:56 +03:00
|
|
|
'{{#if noSharingPlaceholder}}<input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{noSharingPlaceholder}}" disabled="disabled"/>{{/if}}' +
|
2015-08-21 21:29:12 +03:00
|
|
|
'{{/if}}'
|
2015-08-21 16:40:50 +03:00
|
|
|
;
|
2017-03-03 15:27:06 +03:00
|
|
|
var TEMPLATE_POPOVER_MENU =
|
2018-07-19 11:04:37 +03:00
|
|
|
'<div class="popovermenu menu">' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'<ul>' +
|
|
|
|
'<li>' +
|
2018-07-19 11:04:37 +03:00
|
|
|
'<a href="#" class="menuitem clipboardButton" data-clipboard-text="{{shareLinkURL}}">' +
|
2017-03-15 07:50:32 +03:00
|
|
|
'<span class="icon icon-clippy" ></span>' +
|
|
|
|
'<span>{{copyLabel}}</span>' +
|
|
|
|
'</a>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'</li>' +
|
2018-07-19 11:04:37 +03:00
|
|
|
'<li class="hidden linkTextMenu">' +
|
|
|
|
'<span class="menuitem icon-link-text">' +
|
|
|
|
'<input id="linkText-{{cid}}" class="linkText" type="text" readonly="readonly" value="{{shareLinkURL}}" />' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
|
|
|
'{{#if publicUpload}}' +
|
|
|
|
'<li><span class="shareOption menuitem">' +
|
|
|
|
'<span class="icon-loading-small hidden"></span>' +
|
|
|
|
'<input type="radio" name="publicUpload" value="{{publicUploadRValue}}" id="sharingDialogAllowPublicUpload-r-{{cid}}" class="radio publicUploadRadio" {{{publicUploadRChecked}}} />' +
|
|
|
|
'<label for="sharingDialogAllowPublicUpload-r-{{cid}}">{{publicUploadRLabel}}</label>' +
|
|
|
|
'</span></li>' +
|
|
|
|
'<li><span class="shareOption menuitem">' +
|
|
|
|
'<span class="icon-loading-small hidden"></span>' +
|
|
|
|
'<input type="radio" name="publicUpload" value="{{publicUploadRWValue}}" id="sharingDialogAllowPublicUpload-rw-{{cid}}" class="radio publicUploadRadio" {{{publicUploadRWChecked}}} />' +
|
|
|
|
'<label for="sharingDialogAllowPublicUpload-rw-{{cid}}">{{publicUploadRWLabel}}</label>' +
|
|
|
|
'</span></li>' +
|
|
|
|
'<li><span class="shareOption menuitem">' +
|
|
|
|
'<span class="icon-loading-small hidden"></span>' +
|
|
|
|
'<input type="radio" name="publicUpload" value="{{publicUploadWValue}}" id="sharingDialogAllowPublicUpload-w-{{cid}}" class="radio publicUploadRadio" {{{publicUploadWChecked}}} />' +
|
|
|
|
'<label for="sharingDialogAllowPublicUpload-w-{{cid}}">{{publicUploadWLabel}}</label>' +
|
|
|
|
'</span></li>' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'{{#if publicEditing}}' +
|
|
|
|
' <li id="allowPublicEditingWrapper"><span class="shareOption menuitem">' +
|
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
|
|
|
' <input type="checkbox" name="allowPublicEditing" id="sharingDialogAllowPublicEditing-{{cid}}" class="checkbox publicEditingCheckbox" {{{publicEditingChecked}}} />' +
|
|
|
|
' <label for="sharingDialogAllowPublicEditing-{{cid}}">{{publicEditingLabel}}</label>' +
|
|
|
|
' </span></li>' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'{{#if showPasswordCheckBox}}' +
|
|
|
|
' <li><span class="shareOption menuitem">' +
|
2018-08-16 08:31:17 +03:00
|
|
|
' <input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox"' +
|
|
|
|
' {{#if isPasswordSet}}checked="checked"{{/if}} {{#if isPasswordEnforced}}disabled="disabled"{{/if}} value="1" />' +
|
2018-07-19 11:04:37 +03:00
|
|
|
' <label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
|
|
|
' </span></li>' +
|
|
|
|
' <li class="{{#unless isPasswordSet}}hidden{{/unless}} linkPassMenu"><span class="shareOption menuitem icon-share-pass">' +
|
|
|
|
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" autocomplete="new-password" />' +
|
|
|
|
' <span class="icon icon-loading-small hidden"></span>' +
|
|
|
|
' </span></li>' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'<li>' +
|
2018-08-16 08:31:17 +03:00
|
|
|
' <span class="shareOption menuitem">' +
|
|
|
|
' <input id="expireDate-{{cid}}" type="checkbox" name="expirationDate" class="expireDate checkbox"' +
|
|
|
|
' {{#if hasExpireDate}}checked="checked"{{/if}} {{#if isExpirationEnforced}}disabled="disabled"{{/if}}" />' +
|
|
|
|
' <label for="expireDate-{{cid}}">{{expireDateLabel}}</label>' +
|
|
|
|
' </span>' +
|
2018-07-19 11:04:37 +03:00
|
|
|
'</li>' +
|
|
|
|
'<li class="{{#unless hasExpireDate}}hidden{{/unless}}">' +
|
2018-08-16 08:31:17 +03:00
|
|
|
' <span class="menuitem icon-expiredate expirationDateContainer-{{cid}}">' +
|
|
|
|
' <label for="expirationDatePicker-{{cid}}" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
|
|
|
|
' <input id="expirationDatePicker-{{cid}}" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{#if hasExpireDate}}{{expireDate}}{{else}}{{defaultExpireDate}}{{/if}}" />' +
|
|
|
|
' </span>' +
|
2018-07-19 11:04:37 +03:00
|
|
|
'</li>' +
|
|
|
|
'<li>' +
|
|
|
|
'<a href="#" class="share-add"><span class="icon-loading-small hidden"></span>' +
|
|
|
|
' <span class="icon icon-edit"></span>' +
|
|
|
|
' <span>{{addNoteLabel}}</span>' +
|
|
|
|
' <input type="button" class="share-note-delete icon-delete">' +
|
|
|
|
'</a>' +
|
|
|
|
'</li>' +
|
|
|
|
'<li class="share-note-form share-note-link hidden">' +
|
|
|
|
'<span class="menuitem icon-note">' +
|
|
|
|
' <textarea class="share-note">{{shareNote}}</textarea>' +
|
|
|
|
' <input type="submit" class="icon-confirm share-note-submit" value="" id="add-note-{{shareId}}" />' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'{{#each social}}' +
|
|
|
|
'<li>' +
|
2017-04-20 17:32:46 +03:00
|
|
|
'<a href="#" class="shareOption menuitem pop-up" data-url="{{url}}" data-window="{{newWindow}}">' +
|
2017-03-15 07:50:32 +03:00
|
|
|
'<span class="icon {{iconClass}}"' +
|
2018-07-19 21:05:37 +03:00
|
|
|
'></span><span>{{label}}' +
|
2017-03-15 07:50:32 +03:00
|
|
|
'</span>' +
|
|
|
|
'</a>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'</li>' +
|
|
|
|
'{{/each}}' +
|
|
|
|
'</ul>' +
|
|
|
|
'</div>';
|
2015-08-21 16:40:50 +03:00
|
|
|
|
2018-08-15 12:50:48 +03:00
|
|
|
// popovermenu waiting for password or expiration date before saving the share
|
|
|
|
var TEMPLATE_POPOVER_MENU_PENDING =
|
|
|
|
'<div class="popovermenu pendingpopover menu">' +
|
|
|
|
'<ul>' +
|
|
|
|
'{{#if isPasswordEnforced}}' +
|
|
|
|
' <li><span class="shareOption menuitem">' +
|
2018-08-16 08:31:17 +03:00
|
|
|
' <input type="checkbox" name="showPassword" id="showPassword-{{cid}}" checked="checked" disabled class="checkbox showPasswordCheckbox" value="1" />' +
|
2018-08-15 12:50:48 +03:00
|
|
|
' <label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
|
|
|
' </span></li>' +
|
|
|
|
' <li class="linkPassMenu"><span class="shareOption menuitem icon-share-pass">' +
|
|
|
|
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" autocomplete="new-password" />' +
|
|
|
|
' <span class="icon icon-loading-small hidden"></span>' +
|
|
|
|
' </span></li>' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'</ul>' +
|
|
|
|
'</div>';
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
/**
|
|
|
|
* @class OCA.Share.ShareDialogLinkShareView
|
|
|
|
* @member {OC.Share.ShareItemModel} model
|
|
|
|
* @member {jQuery} $el
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Represents the GUI of the share dialogue
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var ShareDialogLinkShareView = OC.Backbone.View.extend({
|
|
|
|
/** @type {string} **/
|
|
|
|
id: 'shareDialogLinkShare',
|
|
|
|
|
|
|
|
/** @type {OC.Share.ShareConfigModel} **/
|
|
|
|
configModel: undefined,
|
|
|
|
|
|
|
|
/** @type {Function} **/
|
|
|
|
_template: undefined,
|
|
|
|
|
2017-03-03 15:27:06 +03:00
|
|
|
/** @type {Function} **/
|
|
|
|
_popoverMenuTemplate: undefined,
|
|
|
|
|
2018-08-15 12:50:48 +03:00
|
|
|
/** @type {Function} **/
|
|
|
|
_pendingPopoverMenuTemplate: undefined,
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
/** @type {boolean} **/
|
|
|
|
showLink: true,
|
|
|
|
|
2018-08-15 12:50:48 +03:00
|
|
|
/** @type {boolean} **/
|
|
|
|
showPending: false,
|
|
|
|
|
2015-09-14 19:24:58 +03:00
|
|
|
events: {
|
2018-08-15 12:50:48 +03:00
|
|
|
// enable/disable
|
|
|
|
'change .linkCheckbox': 'onLinkCheckBoxChange',
|
|
|
|
// open menu
|
|
|
|
'click .share-menu .icon-more': 'onToggleMenu',
|
|
|
|
// password
|
2015-10-16 11:54:45 +03:00
|
|
|
'focusout input.linkPassText': 'onPasswordEntered',
|
|
|
|
'keyup input.linkPassText': 'onPasswordKeyUp',
|
2018-08-16 08:31:17 +03:00
|
|
|
'change .showPasswordCheckbox': 'onShowPasswordClick',
|
2018-08-15 12:50:48 +03:00
|
|
|
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
|
|
|
// copy link url
|
|
|
|
'click .linkText': 'onLinkTextClick',
|
|
|
|
// social
|
2017-03-09 15:56:27 +03:00
|
|
|
'click .pop-up': 'onPopUpClick',
|
2018-08-15 12:50:48 +03:00
|
|
|
// permission change
|
2018-07-19 11:04:37 +03:00
|
|
|
'change .publicUploadRadio': 'onPublicUploadChange',
|
2018-08-15 12:50:48 +03:00
|
|
|
// expire date
|
2018-07-19 11:04:37 +03:00
|
|
|
'click .expireDate' : 'onExpireDateChange',
|
|
|
|
'change .datepicker': 'onChangeExpirationDate',
|
|
|
|
'click .datepicker' : 'showDatePicker',
|
2018-08-15 12:50:48 +03:00
|
|
|
// note
|
2018-07-19 11:04:37 +03:00
|
|
|
'click .share-add': 'showNoteForm',
|
|
|
|
'click .share-note-delete': 'deleteNote',
|
|
|
|
'click .share-note-submit': 'updateNote'
|
2015-09-14 19:24:58 +03:00
|
|
|
},
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
initialize: function(options) {
|
|
|
|
var view = this;
|
|
|
|
|
|
|
|
this.model.on('change:permissions', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.model.on('change:itemType', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.model.on('change:allowPublicUploadStatus', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
2016-06-07 13:28:02 +03:00
|
|
|
this.model.on('change:hideFileListStatus', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
2015-09-12 15:21:14 +03:00
|
|
|
this.model.on('change:linkShare', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
if(!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel;
|
|
|
|
} else {
|
2015-08-25 00:20:01 +03:00
|
|
|
throw 'missing OC.Share.ShareConfigModel';
|
2015-08-21 16:40:50 +03:00
|
|
|
}
|
2015-09-12 15:21:14 +03:00
|
|
|
|
2016-07-08 15:30:32 +03:00
|
|
|
var clipboard = new Clipboard('.clipboardButton');
|
|
|
|
clipboard.on('success', function(e) {
|
2018-07-19 11:04:37 +03:00
|
|
|
var $menu = $(e.trigger);
|
|
|
|
var $linkTextMenu = $menu.parent().next('li.linkTextMenu')
|
|
|
|
|
|
|
|
$menu.tooltip('hide')
|
2016-11-16 17:36:44 +03:00
|
|
|
.attr('data-original-title', t('core', 'Copied!'))
|
|
|
|
.tooltip('fixTitle')
|
|
|
|
.tooltip({placement: 'bottom', trigger: 'manual'})
|
|
|
|
.tooltip('show');
|
2016-07-08 15:30:32 +03:00
|
|
|
_.delay(function() {
|
2018-07-19 11:04:37 +03:00
|
|
|
$menu.tooltip('hide');
|
|
|
|
$menu.tooltip('destroy');
|
2016-07-08 15:30:32 +03:00
|
|
|
}, 3000);
|
|
|
|
});
|
|
|
|
clipboard.on('error', function (e) {
|
2018-07-19 11:04:37 +03:00
|
|
|
var $menu = $(e.trigger);
|
|
|
|
var $linkTextMenu = $menu.parent().next('li.linkTextMenu')
|
|
|
|
var $input = $linkTextMenu.find('.linkText');
|
|
|
|
|
2016-07-08 15:30:32 +03:00
|
|
|
var actionMsg = '';
|
|
|
|
if (/iPhone|iPad/i.test(navigator.userAgent)) {
|
|
|
|
actionMsg = t('core', 'Not supported!');
|
|
|
|
} else if (/Mac/i.test(navigator.userAgent)) {
|
|
|
|
actionMsg = t('core', 'Press ⌘-C to copy.');
|
|
|
|
} else {
|
|
|
|
actionMsg = t('core', 'Press Ctrl-C to copy.');
|
|
|
|
}
|
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
$linkTextMenu.removeClass('hidden');
|
|
|
|
$input.select();
|
2016-11-16 17:36:44 +03:00
|
|
|
$input.tooltip('hide')
|
|
|
|
.attr('data-original-title', actionMsg)
|
|
|
|
.tooltip('fixTitle')
|
|
|
|
.tooltip({placement: 'bottom', trigger: 'manual'})
|
|
|
|
.tooltip('show');
|
2016-07-08 15:30:32 +03:00
|
|
|
_.delay(function () {
|
2017-03-03 15:36:20 +03:00
|
|
|
$input.tooltip('hide');
|
2018-07-19 11:04:37 +03:00
|
|
|
$input.attr('data-original-title', t('core', 'Copy'))
|
|
|
|
.tooltip('fixTitle');
|
2016-07-08 15:30:32 +03:00
|
|
|
}, 3000);
|
|
|
|
});
|
2015-09-12 15:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onLinkCheckBoxChange: function() {
|
2015-10-16 11:54:45 +03:00
|
|
|
var $checkBox = this.$el.find('.linkCheckbox');
|
2015-09-12 15:21:14 +03:00
|
|
|
var $loading = $checkBox.siblings('.icon-loading-small');
|
|
|
|
if(!$loading.hasClass('hidden')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($checkBox.is(':checked')) {
|
2018-08-15 12:50:48 +03:00
|
|
|
if(this.configModel.get('enforcePasswordForPublicLink') === false) {
|
2015-09-12 15:21:14 +03:00
|
|
|
$loading.removeClass('hidden');
|
2015-09-14 13:48:01 +03:00
|
|
|
// this will create it
|
|
|
|
this.model.saveLinkShare();
|
2018-08-15 12:50:48 +03:00
|
|
|
$('.share-menu .icon-more').click();
|
|
|
|
$('.share-menu .icon-more + .popovermenu .clipboardButton').click();
|
2015-09-12 15:21:14 +03:00
|
|
|
} else {
|
2018-08-15 12:50:48 +03:00
|
|
|
// force the rendering of the menu
|
|
|
|
this.showPending = true;
|
|
|
|
this.render()
|
|
|
|
$('.share-menu .icon-more').click();
|
|
|
|
$('.share-menu .icon-more + .popovermenu input:eq(1)').focus()
|
2015-09-12 15:21:14 +03:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-04 11:28:58 +03:00
|
|
|
if (this.model.get('linkShare').isLinkShare) {
|
2016-02-10 13:08:15 +03:00
|
|
|
$loading.removeClass('hidden');
|
2015-10-04 11:28:58 +03:00
|
|
|
this.model.removeLinkShare();
|
|
|
|
} else {
|
2018-08-15 12:50:48 +03:00
|
|
|
this.showPending = false;
|
|
|
|
this.render()
|
2015-10-04 11:28:58 +03:00
|
|
|
}
|
2015-09-12 15:21:14 +03:00
|
|
|
}
|
2015-08-21 16:40:50 +03:00
|
|
|
},
|
|
|
|
|
2015-09-12 16:53:05 +03:00
|
|
|
onLinkTextClick: function() {
|
2015-10-26 14:49:52 +03:00
|
|
|
var $el = this.$el.find('.linkText');
|
|
|
|
$el.focus();
|
|
|
|
$el.select();
|
2015-09-12 16:53:05 +03:00
|
|
|
},
|
|
|
|
|
2015-09-12 18:02:03 +03:00
|
|
|
onShowPasswordClick: function() {
|
2015-10-16 11:54:45 +03:00
|
|
|
this.$el.find('.linkPass').slideToggle(OC.menuSpeed);
|
2018-07-19 11:04:37 +03:00
|
|
|
this.$el.find('.linkPassMenu').toggleClass('hidden');
|
2015-10-16 11:54:45 +03:00
|
|
|
if(!this.$el.find('.showPasswordCheckbox').is(':checked')) {
|
2016-01-22 19:30:18 +03:00
|
|
|
this.model.saveLinkShare({
|
|
|
|
password: ''
|
|
|
|
});
|
2015-09-12 18:02:03 +03:00
|
|
|
} else {
|
2017-02-15 15:50:53 +03:00
|
|
|
if (!OC.Util.isIE()) {
|
|
|
|
this.$el.find('.linkPassText').focus();
|
|
|
|
}
|
2015-10-16 11:54:45 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onPasswordKeyUp: function(event) {
|
2016-08-19 22:03:25 +03:00
|
|
|
if(event.keyCode === 13) {
|
2015-10-16 11:54:45 +03:00
|
|
|
this.onPasswordEntered();
|
2015-09-12 18:02:03 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onPasswordEntered: function() {
|
2018-07-19 11:04:37 +03:00
|
|
|
var $loading = this.$el.find('.linkPassMenu .icon-loading-small');
|
2015-09-29 16:30:01 +03:00
|
|
|
if (!$loading.hasClass('hidden')) {
|
|
|
|
// still in process
|
|
|
|
return;
|
|
|
|
}
|
2015-10-16 11:54:45 +03:00
|
|
|
var $input = this.$el.find('.linkPassText');
|
2015-09-29 16:30:01 +03:00
|
|
|
$input.removeClass('error');
|
|
|
|
var password = $input.val();
|
2016-10-17 15:23:55 +03:00
|
|
|
|
|
|
|
if (this.$el.find('.linkPassText').attr('placeholder') === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) {
|
|
|
|
|
|
|
|
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
|
|
|
|
if(password === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) {
|
|
|
|
password = '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
|
|
|
|
if(password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) {
|
|
|
|
return;
|
|
|
|
}
|
2015-09-12 18:02:03 +03:00
|
|
|
}
|
|
|
|
|
2015-09-29 16:30:01 +03:00
|
|
|
$loading
|
2015-09-12 18:02:03 +03:00
|
|
|
.removeClass('hidden')
|
|
|
|
.addClass('inlineblock');
|
|
|
|
|
2016-01-22 19:30:18 +03:00
|
|
|
this.model.saveLinkShare({
|
|
|
|
password: password
|
|
|
|
}, {
|
2017-04-24 23:18:52 +03:00
|
|
|
complete: function(model) {
|
2017-04-23 19:54:33 +03:00
|
|
|
$loading.removeClass('inlineblock').addClass('hidden');
|
|
|
|
},
|
2015-09-29 16:30:01 +03:00
|
|
|
error: function(model, msg) {
|
2016-03-04 20:11:42 +03:00
|
|
|
// destroy old tooltips
|
|
|
|
$input.tooltip('destroy');
|
2015-09-29 16:30:01 +03:00
|
|
|
$input.addClass('error');
|
|
|
|
$input.attr('title', msg);
|
|
|
|
$input.tooltip({placement: 'bottom', trigger: 'manual'});
|
|
|
|
$input.tooltip('show');
|
|
|
|
}
|
|
|
|
});
|
2015-09-12 18:02:03 +03:00
|
|
|
},
|
|
|
|
|
2017-01-24 15:24:46 +03:00
|
|
|
onAllowPublicEditingChange: function() {
|
|
|
|
var $checkbox = this.$('.publicEditingCheckbox');
|
|
|
|
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
|
|
|
|
|
|
|
var permissions = OC.PERMISSION_READ;
|
|
|
|
if($checkbox.is(':checked')) {
|
|
|
|
permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_READ;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.model.saveLinkShare({
|
|
|
|
permissions: permissions
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-06-07 13:28:02 +03:00
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
onPublicUploadChange: function(e) {
|
2017-03-09 15:56:27 +03:00
|
|
|
var permissions = e.currentTarget.value;
|
2016-06-09 19:17:04 +03:00
|
|
|
this.model.saveLinkShare({
|
|
|
|
permissions: permissions
|
|
|
|
});
|
|
|
|
},
|
2018-10-01 12:02:12 +03:00
|
|
|
|
2018-07-20 10:39:52 +03:00
|
|
|
showNoteForm: function(event) {
|
2018-07-19 11:04:37 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var self = this;
|
|
|
|
var $element = $(event.target);
|
|
|
|
var $li = $element.closest('li[data-share-id]');
|
|
|
|
var $menu = $element.closest('li');
|
|
|
|
var $form = $menu.next('li.share-note-form');
|
|
|
|
|
|
|
|
// show elements
|
|
|
|
$menu.find('.share-note-delete').toggle();
|
|
|
|
$form.toggleClass('hidden');
|
2018-07-19 21:05:37 +03:00
|
|
|
$form.find('textarea').focus();
|
2018-07-19 11:04:37 +03:00
|
|
|
},
|
|
|
|
|
2018-07-20 10:39:52 +03:00
|
|
|
deleteNote: function(event) {
|
2018-07-19 11:04:37 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var self = this;
|
|
|
|
var $element = $(event.target);
|
|
|
|
var $li = $element.closest('li[data-share-id]');
|
|
|
|
var shareId = $li.data('share-id');
|
|
|
|
var $menu = $element.closest('li');
|
|
|
|
var $form = $menu.next('li.share-note-form');
|
2018-10-01 12:02:12 +03:00
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
$form.find('.share-note').val('');
|
2018-10-01 12:02:12 +03:00
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
$form.addClass('hidden');
|
|
|
|
$menu.find('.share-note-delete').hide();
|
|
|
|
|
|
|
|
self.sendNote('', shareId, $menu);
|
|
|
|
},
|
|
|
|
|
2018-07-20 10:39:52 +03:00
|
|
|
updateNote: function(event) {
|
2018-07-19 11:04:37 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var self = this;
|
|
|
|
var $element = $(event.target);
|
|
|
|
var $li = $element.closest('li[data-share-id]');
|
|
|
|
var shareId = $li.data('share-id');
|
|
|
|
var $form = $element.closest('li.share-note-form');
|
|
|
|
var $menu = $form.prev('li');
|
|
|
|
var message = $form.find('.share-note').val().trim();
|
|
|
|
|
|
|
|
if (message.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.sendNote(message, shareId, $menu);
|
|
|
|
},
|
|
|
|
|
2018-07-20 10:39:52 +03:00
|
|
|
sendNote: function(note, shareId, $menu) {
|
2018-07-19 11:04:37 +03:00
|
|
|
var $form = $menu.next('li.share-note-form');
|
|
|
|
var $submit = $form.find('input.share-note-submit');
|
|
|
|
var $error = $form.find('input.share-note-error');
|
|
|
|
|
|
|
|
$submit.prop('disabled', true);
|
|
|
|
$menu.find('.icon-loading-small').removeClass('hidden');
|
|
|
|
$menu.find('.icon-edit').hide();
|
|
|
|
|
|
|
|
var complete = function() {
|
|
|
|
$submit.prop('disabled', false);
|
|
|
|
$menu.find('.icon-loading-small').addClass('hidden');
|
|
|
|
$menu.find('.icon-edit').show();
|
|
|
|
};
|
|
|
|
var error = function() {
|
|
|
|
$error.show();
|
|
|
|
setTimeout(function() {
|
|
|
|
$error.hide();
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
|
|
|
|
// send data
|
|
|
|
$.ajax({
|
|
|
|
method: 'PUT',
|
|
|
|
url: OC.linkToOCS('apps/files_sharing/api/v1/shares',2) + shareId + '?' + OC.buildQueryString({format: 'json'}),
|
|
|
|
data: { note: note },
|
|
|
|
complete : complete,
|
|
|
|
error: error
|
|
|
|
});
|
|
|
|
},
|
2015-09-14 02:01:02 +03:00
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
render: function() {
|
2015-08-21 21:29:12 +03:00
|
|
|
var linkShareTemplate = this.template();
|
2015-12-07 18:53:56 +03:00
|
|
|
var resharingAllowed = this.model.sharePermissionPossible();
|
2015-08-21 21:29:12 +03:00
|
|
|
|
2015-12-07 18:53:56 +03:00
|
|
|
if(!resharingAllowed
|
2015-08-21 16:40:50 +03:00
|
|
|
|| !this.showLink
|
|
|
|
|| !this.configModel.isShareWithLinkAllowed())
|
|
|
|
{
|
2015-12-07 18:53:56 +03:00
|
|
|
var templateData = {shareAllowed: false};
|
|
|
|
if (!resharingAllowed) {
|
|
|
|
// add message
|
|
|
|
templateData.noSharingPlaceholder = t('core', 'Resharing is not allowed');
|
|
|
|
}
|
|
|
|
this.$el.html(linkShareTemplate(templateData));
|
2015-08-21 16:40:50 +03:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
var publicUpload =
|
|
|
|
this.model.isFolder()
|
2015-09-01 13:43:04 +03:00
|
|
|
&& this.model.createPermissionPossible()
|
2015-08-21 16:40:50 +03:00
|
|
|
&& this.configModel.isPublicUploadEnabled();
|
|
|
|
|
2017-03-09 15:56:27 +03:00
|
|
|
var publicUploadRWChecked = '';
|
|
|
|
var publicUploadRChecked = '';
|
|
|
|
var publicUploadWChecked = '';
|
|
|
|
|
|
|
|
switch (this.model.linkSharePermissions()) {
|
|
|
|
case OC.PERMISSION_READ:
|
|
|
|
publicUploadRChecked = 'checked';
|
|
|
|
break;
|
|
|
|
case OC.PERMISSION_CREATE:
|
|
|
|
publicUploadWChecked = 'checked';
|
|
|
|
break;
|
|
|
|
case OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE:
|
|
|
|
publicUploadRWChecked = 'checked';
|
|
|
|
break;
|
2015-08-21 16:40:50 +03:00
|
|
|
}
|
|
|
|
|
2017-01-24 15:24:46 +03:00
|
|
|
var publicEditingChecked = '';
|
|
|
|
if(this.model.isPublicEditingAllowed()) {
|
|
|
|
publicEditingChecked = 'checked="checked"';
|
|
|
|
}
|
|
|
|
|
2015-09-03 16:53:17 +03:00
|
|
|
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
|
|
|
var isPasswordSet = !!this.model.get('linkShare').password;
|
2018-08-15 12:50:48 +03:00
|
|
|
var isPasswordEnforced = this.configModel.get('enforcePasswordForPublicLink')
|
|
|
|
var isPasswordEnabledByDefault = this.configModel.get('enableLinkPasswordByDefault') === true
|
2015-09-03 16:53:17 +03:00
|
|
|
var showPasswordCheckBox = isLinkShare
|
|
|
|
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
|
|
|
|| !this.model.get('linkShare').password);
|
2016-10-17 15:23:55 +03:00
|
|
|
var passwordPlaceholderInitial = this.configModel.get('enforcePasswordForPublicLink')
|
|
|
|
? PASSWORD_PLACEHOLDER_MESSAGE : PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL;
|
2015-09-03 16:53:17 +03:00
|
|
|
|
2017-01-24 15:24:46 +03:00
|
|
|
var publicEditable =
|
|
|
|
!this.model.isFolder()
|
|
|
|
&& isLinkShare
|
|
|
|
&& this.model.updatePermissionPossible();
|
|
|
|
|
2017-03-03 15:27:06 +03:00
|
|
|
var link = this.model.get('linkShare').link;
|
|
|
|
var social = [];
|
|
|
|
OC.Share.Social.Collection.each(function(model) {
|
|
|
|
var url = model.get('url');
|
|
|
|
url = url.replace('{{reference}}', link);
|
|
|
|
|
|
|
|
social.push({
|
|
|
|
url: url,
|
|
|
|
label: t('core', 'Share to {name}', {name: model.get('name')}),
|
|
|
|
name: model.get('name'),
|
2017-04-20 17:32:46 +03:00
|
|
|
iconClass: model.get('iconClass'),
|
|
|
|
newWindow: model.get('newWindow')
|
2017-03-03 15:27:06 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-19 21:05:37 +03:00
|
|
|
var defaultExpireDays = this.configModel.get('defaultExpireDate');
|
2018-07-19 11:04:37 +03:00
|
|
|
var isExpirationEnforced = this.configModel.get('isDefaultExpireDateEnforced');
|
|
|
|
var hasExpireDate = !!this.model.get('linkShare').expiration || isExpirationEnforced;
|
|
|
|
|
|
|
|
var expireDate;
|
|
|
|
if (hasExpireDate) {
|
|
|
|
expireDate = moment(this.model.get('linkShare').expiration, 'YYYY-MM-DD').format('DD-MM-YYYY');
|
|
|
|
}
|
|
|
|
|
2018-07-19 21:05:37 +03:00
|
|
|
// what if there is another date picker on that page?
|
|
|
|
var minDate = new Date();
|
|
|
|
var maxDate = null;
|
|
|
|
// min date should always be the next day
|
|
|
|
minDate.setDate(minDate.getDate()+1);
|
|
|
|
|
|
|
|
if(hasExpireDate) {
|
|
|
|
if(isExpirationEnforced) {
|
|
|
|
// TODO: hack: backend returns string instead of integer
|
|
|
|
var shareTime = this.model.get('linkShare').stime;
|
|
|
|
if (_.isNumber(shareTime)) {
|
|
|
|
shareTime = new Date(shareTime * 1000);
|
|
|
|
}
|
|
|
|
if (!shareTime) {
|
|
|
|
shareTime = new Date(); // now
|
|
|
|
}
|
|
|
|
shareTime = OC.Util.stripTime(shareTime).getTime();
|
|
|
|
maxDate = new Date(shareTime + defaultExpireDays * 24 * 3600 * 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$.datepicker.setDefaults({
|
|
|
|
minDate: minDate,
|
|
|
|
maxDate: maxDate
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});
|
|
|
|
|
2017-03-03 15:27:06 +03:00
|
|
|
var popover = this.popoverMenuTemplate({
|
2018-07-19 11:04:37 +03:00
|
|
|
cid: this.model.get('linkShare').id,
|
2018-10-01 12:02:12 +03:00
|
|
|
copyLabel: t('core', 'Copy link'),
|
2018-07-19 11:04:37 +03:00
|
|
|
social: social,
|
2017-03-03 15:27:06 +03:00
|
|
|
|
2015-09-03 16:53:17 +03:00
|
|
|
shareLinkURL: this.model.get('linkShare').link,
|
2015-08-21 16:40:50 +03:00
|
|
|
urlLabel: t('core', 'Link'),
|
|
|
|
enablePasswordLabel: t('core', 'Password protect'),
|
|
|
|
passwordLabel: t('core', 'Password'),
|
2015-10-16 12:55:23 +03:00
|
|
|
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
2016-10-17 15:23:55 +03:00
|
|
|
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
2018-08-16 08:31:17 +03:00
|
|
|
isPasswordSet: isPasswordSet || isPasswordEnabledByDefault || isPasswordEnforced,
|
2015-09-03 16:53:17 +03:00
|
|
|
showPasswordCheckBox: showPasswordCheckBox,
|
|
|
|
publicUpload: publicUpload && isLinkShare,
|
2017-01-24 15:24:46 +03:00
|
|
|
publicEditing: publicEditable,
|
|
|
|
publicEditingChecked: publicEditingChecked,
|
|
|
|
publicEditingLabel: t('core', 'Allow editing'),
|
2015-08-21 16:40:50 +03:00
|
|
|
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
2017-03-03 15:27:06 +03:00
|
|
|
mailButtonText: t('core', 'Send'),
|
2017-03-09 15:56:27 +03:00
|
|
|
publicUploadRWLabel: t('core', 'Allow upload and editing'),
|
|
|
|
publicUploadRLabel: t('core', 'Read only'),
|
2017-05-18 17:53:10 +03:00
|
|
|
publicUploadWLabel: t('core', 'File drop (upload only)'),
|
2017-03-09 15:56:27 +03:00
|
|
|
publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
|
|
|
|
publicUploadRValue: OC.PERMISSION_READ,
|
|
|
|
publicUploadWValue: OC.PERMISSION_CREATE,
|
|
|
|
publicUploadRWChecked: publicUploadRWChecked,
|
|
|
|
publicUploadRChecked: publicUploadRChecked,
|
2018-07-19 11:04:37 +03:00
|
|
|
publicUploadWChecked: publicUploadWChecked,
|
|
|
|
expireDateLabel: t('core', 'Set expiration date'),
|
|
|
|
expirationLabel: t('core', 'Expiration'),
|
|
|
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
|
|
|
hasExpireDate: hasExpireDate,
|
|
|
|
isExpirationEnforced: isExpirationEnforced,
|
2018-08-16 08:31:17 +03:00
|
|
|
isPasswordEnforced: isPasswordEnforced,
|
2018-07-19 11:04:37 +03:00
|
|
|
expireDate: expireDate,
|
|
|
|
defaultExpireDate: moment().add(1, 'day').format('DD-MM-YYYY'), // Can't expire today
|
|
|
|
shareNote: this.model.get('linkShare').note,
|
2018-07-31 15:20:09 +03:00
|
|
|
addNoteLabel: t('core', 'Note to recipient'),
|
2018-07-19 11:04:37 +03:00
|
|
|
});
|
2015-08-21 16:40:50 +03:00
|
|
|
|
2018-08-15 12:50:48 +03:00
|
|
|
var pendingPopover = this.pendingPopoverMenuTemplate({
|
|
|
|
cid: this.model.get('linkShare').id,
|
|
|
|
enablePasswordLabel: t('core', 'Password protect'),
|
|
|
|
passwordLabel: t('core', 'Password'),
|
|
|
|
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
|
|
|
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
|
|
|
showPasswordCheckBox: showPasswordCheckBox,
|
|
|
|
isPasswordEnforced: isPasswordEnforced,
|
|
|
|
});
|
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
this.$el.html(linkShareTemplate({
|
|
|
|
cid: this.model.get('linkShare').id,
|
|
|
|
shareAllowed: true,
|
|
|
|
isLinkShare: isLinkShare,
|
|
|
|
linkShareLabel: t('core', 'Share link'),
|
|
|
|
linkShareEnableLabel: t('core', 'Enable'),
|
|
|
|
popoverMenu: popover,
|
2018-08-15 12:50:48 +03:00
|
|
|
pendingPopoverMenu: pendingPopover,
|
|
|
|
showMenu: isLinkShare || this.showPending,
|
|
|
|
showPending: this.showPending && !isLinkShare
|
2018-07-19 11:04:37 +03:00
|
|
|
}));
|
2017-03-03 15:36:20 +03:00
|
|
|
|
2015-09-14 19:24:58 +03:00
|
|
|
this.delegateEvents();
|
|
|
|
|
2018-07-19 21:05:37 +03:00
|
|
|
// new note autosize
|
|
|
|
autosize(this.$el.find('.share-note-form .share-note'));
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-03-03 15:27:06 +03:00
|
|
|
onToggleMenu: function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var $element = $(event.target);
|
2018-07-19 11:04:37 +03:00
|
|
|
var $li = $element.closest('li[data-share-id]');
|
|
|
|
var $menu = $li.find('.sharingOptionsGroup .popovermenu');
|
2017-03-03 15:27:06 +03:00
|
|
|
|
|
|
|
OC.showMenu(null, $menu);
|
|
|
|
this._menuOpen = $li.data('share-id');
|
|
|
|
},
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
template: function () {
|
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
|
|
|
return this._template;
|
2017-03-03 15:27:06 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* renders the popover template and returns the resulting HTML
|
|
|
|
*
|
|
|
|
* @param {Object} data
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
popoverMenuTemplate: function(data) {
|
|
|
|
if(!this._popoverMenuTemplate) {
|
|
|
|
this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU);
|
|
|
|
}
|
|
|
|
return this._popoverMenuTemplate(data);
|
|
|
|
},
|
|
|
|
|
2018-08-15 12:50:48 +03:00
|
|
|
/**
|
|
|
|
* renders the pending popover template and returns the resulting HTML
|
|
|
|
*
|
|
|
|
* @param {Object} data
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
pendingPopoverMenuTemplate: function(data) {
|
|
|
|
if(!this._pendingPopoverMenuTemplate) {
|
|
|
|
this._pendingPopoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU_PENDING);
|
|
|
|
}
|
|
|
|
return this._pendingPopoverMenuTemplate(data);
|
|
|
|
},
|
|
|
|
|
2017-03-03 15:27:06 +03:00
|
|
|
onPopUpClick: function(event) {
|
2017-03-15 07:50:32 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
var url = $(event.currentTarget).data('url');
|
2017-04-20 17:32:46 +03:00
|
|
|
var newWindow = $(event.currentTarget).data('window');
|
2017-03-15 07:50:32 +03:00
|
|
|
$(event.currentTarget).tooltip('hide');
|
2017-03-03 15:27:06 +03:00
|
|
|
if (url) {
|
2017-04-20 17:32:46 +03:00
|
|
|
if (newWindow === true) {
|
|
|
|
var width = 600;
|
|
|
|
var height = 400;
|
|
|
|
var left = (screen.width / 2) - (width / 2);
|
|
|
|
var top = (screen.height / 2) - (height / 2);
|
2017-03-03 15:27:06 +03:00
|
|
|
|
2017-04-20 17:32:46 +03:00
|
|
|
window.open(url, 'name', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
|
|
|
|
} else {
|
|
|
|
window.location.href = url;
|
|
|
|
}
|
2017-03-03 15:27:06 +03:00
|
|
|
}
|
2018-07-19 11:04:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onExpireDateChange: function(event) {
|
|
|
|
var $element = $(event.target);
|
2018-07-19 21:05:37 +03:00
|
|
|
var li = $element.closest('li[data-share-id]');
|
|
|
|
var shareId = li.data('share-id');
|
|
|
|
var expirationDatePicker = '#expirationDateContainer-' + shareId;
|
|
|
|
var datePicker = $(expirationDatePicker);
|
2018-07-19 11:04:37 +03:00
|
|
|
var state = $element.prop('checked');
|
|
|
|
datePicker.toggleClass('hidden', !state);
|
2018-10-01 12:02:12 +03:00
|
|
|
|
2018-07-19 11:04:37 +03:00
|
|
|
if (!state) {
|
|
|
|
// disabled, let's hide the input and
|
|
|
|
// set the expireDate to nothing
|
|
|
|
$element.closest('li').next('li').addClass('hidden');
|
|
|
|
this.setExpirationDate('');
|
|
|
|
} else {
|
|
|
|
// enabled, show the input and the datepicker
|
|
|
|
$element.closest('li').next('li').removeClass('hidden');
|
|
|
|
this.showDatePicker(event);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showDatePicker: function(event) {
|
2018-07-19 21:05:37 +03:00
|
|
|
var $element = $(event.target);
|
|
|
|
var li = $element.closest('li[data-share-id]');
|
|
|
|
var shareId = li.data('share-id');
|
|
|
|
var expirationDatePicker = '#expirationDatePicker-' + shareId;
|
2018-07-19 11:04:37 +03:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
$(expirationDatePicker).datepicker({
|
|
|
|
dateFormat : 'dd-mm-yy',
|
|
|
|
onSelect: function (expireDate) {
|
|
|
|
self.setExpirationDate(expireDate);
|
|
|
|
}
|
|
|
|
});
|
2018-07-19 21:05:37 +03:00
|
|
|
$(expirationDatePicker).datepicker('show');
|
2018-07-19 11:04:37 +03:00
|
|
|
$(expirationDatePicker).focus();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setExpirationDate: function(expireDate) {
|
|
|
|
this.model.saveLinkShare({expireDate: expireDate});
|
|
|
|
},
|
2015-08-21 16:40:50 +03:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogLinkShareView = ShareDialogLinkShareView;
|
|
|
|
|
|
|
|
})();
|