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-04-18 10:53:02 +03:00
|
|
|
var PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL = t('core', 'Choose a password for the public link or press "Enter ↵"');
|
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}}' +
|
|
|
|
'<span class="icon-loading-small hidden"></span>' +
|
2015-10-16 11:54:45 +03:00
|
|
|
'<input type="checkbox" name="linkCheckbox" id="linkCheckbox-{{cid}}" class="checkbox linkCheckbox" value="1" {{#if isLinkShare}}checked="checked"{{/if}} />' +
|
|
|
|
'<label for="linkCheckbox-{{cid}}">{{linkShareLabel}}</label>' +
|
2015-08-21 21:29:12 +03:00
|
|
|
'<br />' +
|
2016-07-08 15:30:32 +03:00
|
|
|
'<div class="oneline">' +
|
2015-10-16 11:54:45 +03:00
|
|
|
'<label for="linkText-{{cid}}" class="hidden-visually">{{urlLabel}}</label>' +
|
|
|
|
'<input id="linkText-{{cid}}" class="linkText {{#unless isLinkShare}}hidden{{/unless}}" type="text" readonly="readonly" value="{{shareLinkURL}}" />' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'{{#if singleAction}}' +
|
|
|
|
'<a class="{{#unless isLinkShare}}hidden-visually{{/unless}} clipboardButton icon icon-clippy" data-clipboard-target="#linkText-{{cid}}"></a>' +
|
|
|
|
'{{else}}' +
|
2017-03-31 18:29:41 +03:00
|
|
|
'<a class="{{#unless isLinkShare}}hidden-visually{{/unless}}" href="#"><span class="linkMore icon icon-more"></span></a>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'{{{popoverMenu}}}' +
|
|
|
|
'{{/if}}' +
|
2016-07-08 15:30:32 +03:00
|
|
|
'</div>' +
|
2015-08-21 16:40:50 +03:00
|
|
|
' {{#if publicUpload}}' +
|
2015-09-14 01:43:11 +03:00
|
|
|
'<div id="allowPublicUploadWrapper">' +
|
2015-08-21 21:29:12 +03:00
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
2015-10-16 11:54:45 +03:00
|
|
|
' <input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload-{{cid}}" class="checkbox publicUploadCheckbox" {{{publicUploadChecked}}} />' +
|
|
|
|
'<label for="sharingDialogAllowPublicUpload-{{cid}}">{{publicUploadLabel}}</label>' +
|
2015-08-21 21:29:12 +03:00
|
|
|
'</div>' +
|
2016-06-11 16:15:37 +03:00
|
|
|
' {{#if hideFileList}}' +
|
2016-06-07 13:28:02 +03:00
|
|
|
'<div id="hideFileListWrapper">' +
|
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
|
|
|
' <input type="checkbox" value="1" name="hideFileList" id="sharingDialogHideFileList-{{cid}}" class="checkbox hideFileListCheckbox" {{{hideFileListChecked}}} />' +
|
|
|
|
'<label for="sharingDialogHideFileList-{{cid}}">{{hideFileListLabel}}</label>' +
|
|
|
|
'</div>' +
|
2016-06-11 16:15:37 +03:00
|
|
|
' {{/if}}' +
|
2016-06-07 13:28:02 +03:00
|
|
|
' {{/if}}' +
|
2017-01-24 15:24:46 +03:00
|
|
|
' {{#if publicEditing}}' +
|
|
|
|
'<div id="allowPublicEditingWrapper">' +
|
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
|
|
|
' <input type="checkbox" value="1" name="allowPublicEditing" id="sharingDialogAllowPublicEditing-{{cid}}" class="checkbox publicEditingCheckbox" {{{publicEditingChecked}}} />' +
|
|
|
|
'<label for="sharingDialogAllowPublicEditing-{{cid}}">{{publicEditingLabel}}</label>' +
|
|
|
|
'</div>' +
|
|
|
|
' {{/if}}' +
|
2016-05-02 21:33:45 +03:00
|
|
|
' {{#if showPasswordCheckBox}}' +
|
|
|
|
'<input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox" {{#if isPasswordSet}}checked="checked"{{/if}} value="1" />' +
|
|
|
|
'<label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
2015-08-21 16:40:50 +03:00
|
|
|
' {{/if}}' +
|
2016-05-02 21:33:45 +03:00
|
|
|
'<div id="linkPass" class="linkPass {{#unless isPasswordSet}}hidden{{/unless}}">' +
|
|
|
|
' <label for="linkPassText-{{cid}}" class="hidden-visually">{{passwordLabel}}</label>' +
|
2016-10-17 15:23:55 +03:00
|
|
|
' {{#if showPasswordCheckBox}}' +
|
2016-05-02 21:33:45 +03:00
|
|
|
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" />' +
|
2016-10-17 15:23:55 +03:00
|
|
|
' {{else}}' +
|
|
|
|
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholderInitial}}" />' +
|
|
|
|
' {{/if}}' +
|
2016-05-02 21:33:45 +03:00
|
|
|
' <span class="icon-loading-small hidden"></span>' +
|
|
|
|
'</div>' +
|
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 =
|
2017-03-15 07:50:32 +03:00
|
|
|
'<div class="popovermenu bubble hidden menu socialSharingMenu">' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'<ul>' +
|
|
|
|
'<li>' +
|
2017-03-15 07:50:32 +03:00
|
|
|
'<a href="#" class="shareOption menuitem clipboardButton" data-clipboard-target="#linkText-{{cid}}">' +
|
|
|
|
'<span class="icon icon-clippy" ></span>' +
|
|
|
|
'<span>{{copyLabel}}</span>' +
|
|
|
|
'</a>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'</li>' +
|
|
|
|
'{{#each social}}' +
|
|
|
|
'<li>' +
|
2017-03-15 07:50:32 +03:00
|
|
|
'<a href="#" class="shareOption menuitem pop-up" data-url="{{url}}">' +
|
|
|
|
'<span class="icon {{iconClass}}"' +
|
|
|
|
'></span><span>{{label}}' +
|
|
|
|
'</span>' +
|
|
|
|
'</a>' +
|
2017-03-03 15:27:06 +03:00
|
|
|
'</li>' +
|
|
|
|
'{{/each}}' +
|
|
|
|
'</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,
|
|
|
|
|
2015-08-21 16:40:50 +03:00
|
|
|
/** @type {boolean} **/
|
|
|
|
showLink: true,
|
|
|
|
|
2015-09-14 19:24:58 +03:00
|
|
|
events: {
|
2015-10-16 11:54:45 +03:00
|
|
|
'focusout input.linkPassText': 'onPasswordEntered',
|
|
|
|
'keyup input.linkPassText': 'onPasswordKeyUp',
|
|
|
|
'click .linkCheckbox': 'onLinkCheckBoxChange',
|
|
|
|
'click .linkText': 'onLinkTextClick',
|
2016-06-09 19:17:04 +03:00
|
|
|
'change .publicUploadCheckbox': 'onAllowPublicUploadChange',
|
2017-01-24 15:24:46 +03:00
|
|
|
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
2016-06-09 19:17:04 +03:00
|
|
|
'change .hideFileListCheckbox': 'onHideFileListChange',
|
2017-03-03 15:27:06 +03:00
|
|
|
'click .showPasswordCheckbox': 'onShowPasswordClick',
|
|
|
|
'click .icon-more': 'onToggleMenu',
|
|
|
|
'click .pop-up': 'onPopUpClick'
|
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
|
|
|
|
2015-10-16 11:54:45 +03:00
|
|
|
_.bindAll(
|
|
|
|
this,
|
|
|
|
'onLinkCheckBoxChange',
|
|
|
|
'onPasswordEntered',
|
|
|
|
'onPasswordKeyUp',
|
|
|
|
'onLinkTextClick',
|
|
|
|
'onShowPasswordClick',
|
2016-06-07 13:28:02 +03:00
|
|
|
'onHideFileListChange',
|
2017-01-24 15:24:46 +03:00
|
|
|
'onAllowPublicUploadChange',
|
|
|
|
'onAllowPublicEditingChange'
|
2015-10-16 11:54:45 +03:00
|
|
|
);
|
2016-07-08 15:30:32 +03:00
|
|
|
|
|
|
|
var clipboard = new Clipboard('.clipboardButton');
|
|
|
|
clipboard.on('success', function(e) {
|
2017-03-15 07:50:32 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
2016-08-19 22:03:25 +03:00
|
|
|
var $input = $(e.trigger);
|
2016-11-16 17:36:44 +03:00
|
|
|
$input.tooltip('hide')
|
|
|
|
.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() {
|
2017-03-03 15:36:20 +03:00
|
|
|
$input.tooltip('hide');
|
|
|
|
if (OC.Share.Social.Collection.size() == 0) {
|
|
|
|
$input.attr('data-original-title', t('core', 'Copy'))
|
|
|
|
.tooltip('fixTitle');
|
|
|
|
} else {
|
|
|
|
$input.tooltip("destroy");
|
|
|
|
}
|
2016-07-08 15:30:32 +03:00
|
|
|
}, 3000);
|
|
|
|
});
|
|
|
|
clipboard.on('error', function (e) {
|
2016-08-19 22:03:25 +03:00
|
|
|
var $input = $(e.trigger);
|
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.');
|
|
|
|
}
|
|
|
|
|
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');
|
|
|
|
if (OC.Share.Social.Collection.size() == 0) {
|
|
|
|
$input.attr('data-original-title', t('core', 'Copy'))
|
|
|
|
.tooltip('fixTitle');
|
|
|
|
} else {
|
|
|
|
$input.tooltip("destroy");
|
|
|
|
}
|
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')) {
|
2016-10-17 10:11:30 +03:00
|
|
|
if(this.configModel.get('enforcePasswordForPublicLink') === false && this.configModel.get('enableLinkPasswordByDefault') === 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();
|
2015-09-12 15:21:14 +03:00
|
|
|
} else {
|
2015-10-16 11:54:45 +03:00
|
|
|
this.$el.find('.linkPass').slideToggle(OC.menuSpeed);
|
|
|
|
this.$el.find('.linkPassText').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 {
|
2015-10-16 11:54:45 +03:00
|
|
|
this.$el.find('.linkPass').slideToggle(OC.menuSpeed);
|
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);
|
|
|
|
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() {
|
2015-10-16 11:54:45 +03:00
|
|
|
var $loading = this.$el.find('.linkPass .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
|
|
|
|
}, {
|
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
|
|
|
$loading.removeClass('inlineblock').addClass('hidden');
|
|
|
|
$input.addClass('error');
|
|
|
|
$input.attr('title', msg);
|
|
|
|
$input.tooltip({placement: 'bottom', trigger: 'manual'});
|
|
|
|
$input.tooltip('show');
|
|
|
|
}
|
|
|
|
});
|
2015-09-12 18:02:03 +03:00
|
|
|
},
|
|
|
|
|
2015-09-14 02:01:02 +03:00
|
|
|
onAllowPublicUploadChange: function() {
|
2015-10-16 11:54:45 +03:00
|
|
|
var $checkbox = this.$('.publicUploadCheckbox');
|
|
|
|
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
2016-01-22 19:30:18 +03:00
|
|
|
|
|
|
|
var permissions = OC.PERMISSION_READ;
|
|
|
|
if($checkbox.is(':checked')) {
|
2016-06-23 16:43:21 +03:00
|
|
|
permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE;
|
2016-01-22 19:30:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
this.model.saveLinkShare({
|
|
|
|
permissions: permissions
|
|
|
|
});
|
2016-06-09 19:17:04 +03:00
|
|
|
},
|
2016-06-07 13:28:02 +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-09 19:17:04 +03:00
|
|
|
onHideFileListChange: function () {
|
|
|
|
var $checkbox = this.$('.hideFileListCheckbox');
|
|
|
|
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
2016-06-07 13:28:02 +03:00
|
|
|
|
2016-07-14 11:25:24 +03:00
|
|
|
var permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE;
|
2016-06-09 19:17:04 +03:00
|
|
|
if ($checkbox.is(':checked')) {
|
2016-07-14 11:25:53 +03:00
|
|
|
permissions = OC.PERMISSION_CREATE;
|
2016-06-09 19:17:04 +03:00
|
|
|
}
|
2016-06-07 13:28:02 +03:00
|
|
|
|
2016-06-09 19:17:04 +03:00
|
|
|
this.model.saveLinkShare({
|
|
|
|
permissions: permissions
|
|
|
|
});
|
|
|
|
},
|
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();
|
|
|
|
|
|
|
|
var publicUploadChecked = '';
|
|
|
|
if(this.model.isPublicUploadAllowed()) {
|
|
|
|
publicUploadChecked = 'checked="checked"';
|
|
|
|
}
|
|
|
|
|
2017-01-24 15:24:46 +03:00
|
|
|
var publicEditingChecked = '';
|
|
|
|
if(this.model.isPublicEditingAllowed()) {
|
|
|
|
publicEditingChecked = 'checked="checked"';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-07 13:28:02 +03:00
|
|
|
var hideFileList = publicUploadChecked;
|
|
|
|
|
|
|
|
var hideFileListChecked = '';
|
|
|
|
if(this.model.isHideFileListSet()) {
|
|
|
|
hideFileListChecked = 'checked="checked"';
|
|
|
|
}
|
|
|
|
|
2015-09-03 16:53:17 +03:00
|
|
|
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
|
|
|
var isPasswordSet = !!this.model.get('linkShare').password;
|
|
|
|
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'),
|
|
|
|
iconClass: model.get('iconClass')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var popover = this.popoverMenuTemplate({
|
|
|
|
cid: this.cid,
|
|
|
|
copyLabel: t('core', 'Copy'),
|
|
|
|
social: social
|
|
|
|
});
|
|
|
|
|
2015-08-25 00:20:01 +03:00
|
|
|
this.$el.html(linkShareTemplate({
|
2015-10-16 11:54:45 +03:00
|
|
|
cid: this.cid,
|
2015-08-21 21:29:12 +03:00
|
|
|
shareAllowed: true,
|
2016-06-07 13:28:02 +03:00
|
|
|
hideFileList: hideFileList,
|
2015-09-03 16:53:17 +03:00
|
|
|
isLinkShare: isLinkShare,
|
|
|
|
shareLinkURL: this.model.get('linkShare').link,
|
2015-08-21 16:40:50 +03:00
|
|
|
linkShareLabel: t('core', 'Share link'),
|
|
|
|
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,
|
2015-09-03 16:53:17 +03:00
|
|
|
isPasswordSet: isPasswordSet,
|
|
|
|
showPasswordCheckBox: showPasswordCheckBox,
|
|
|
|
publicUpload: publicUpload && isLinkShare,
|
2015-08-21 16:40:50 +03:00
|
|
|
publicUploadChecked: publicUploadChecked,
|
2016-06-07 13:28:02 +03:00
|
|
|
hideFileListChecked: hideFileListChecked,
|
2016-08-28 22:50:31 +03:00
|
|
|
publicUploadLabel: t('core', 'Allow upload and editing'),
|
2017-01-24 15:24:46 +03:00
|
|
|
publicEditing: publicEditable,
|
|
|
|
publicEditingChecked: publicEditingChecked,
|
|
|
|
publicEditingLabel: t('core', 'Allow editing'),
|
2017-03-26 18:53:18 +03:00
|
|
|
hideFileListLabel: 'Secure drop (' + t('core', 'upload only') + ')',
|
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'),
|
|
|
|
singleAction: OC.Share.Social.Collection.size() == 0,
|
|
|
|
popoverMenu: popover
|
2015-08-21 16:40:50 +03:00
|
|
|
}));
|
|
|
|
|
2017-03-03 15:36:20 +03:00
|
|
|
if (OC.Share.Social.Collection.size() == 0) {
|
|
|
|
this.$el.find('.clipboardButton').tooltip({
|
|
|
|
placement: 'bottom',
|
|
|
|
title: t('core', 'Copy'),
|
|
|
|
trigger: 'hover'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-09-14 19:24:58 +03:00
|
|
|
this.delegateEvents();
|
|
|
|
|
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);
|
|
|
|
var $li = $element.closest('.oneline');
|
|
|
|
var $menu = $li.find('.popovermenu');
|
|
|
|
|
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
|
|
|
onPopUpClick: function(event) {
|
2017-03-15 07:50:32 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
var url = $(event.currentTarget).data('url');
|
|
|
|
$(event.currentTarget).tooltip('hide');
|
2017-03-03 15:27:06 +03:00
|
|
|
if (url) {
|
|
|
|
var width = 600;
|
|
|
|
var height = 400;
|
|
|
|
var left = (screen.width/2)-(width/2);
|
|
|
|
var top = (screen.height/2)-(height/2);
|
|
|
|
|
|
|
|
window.open(url, 'name', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
|
|
|
|
}
|
2015-08-21 16:40:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogLinkShareView = ShareDialogLinkShareView;
|
|
|
|
|
|
|
|
})();
|