summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/css/sharetabview.css4
-rw-r--r--core/js/share.js70
-rw-r--r--core/js/sharedialoglinkshareview.js32
-rw-r--r--core/js/sharedialogview.js2
-rw-r--r--core/js/shareitemmodel.js24
5 files changed, 58 insertions, 74 deletions
diff --git a/apps/files_sharing/css/sharetabview.css b/apps/files_sharing/css/sharetabview.css
index 96a75717c53..0cc812e917c 100644
--- a/apps/files_sharing/css/sharetabview.css
+++ b/apps/files_sharing/css/sharetabview.css
@@ -69,3 +69,7 @@
#shareWithList li label{
margin-right: 8px;
}
+
+.shareTabView .icon-loading-small {
+ margin-left: -30px;
+}
diff --git a/core/js/share.js b/core/js/share.js
index 4b1e773c1ac..f97a91bd3ab 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -996,76 +996,6 @@ $(document).ready(function() {
});
});
- $(document).on('click', '#dropdown #showPassword', function() {
- $('#linkPass').slideToggle(OC.menuSpeed);
- if (!$('#showPassword').is(':checked') ) {
- var itemType = $('#dropdown').data('item-type');
- var itemSource = $('#dropdown').data('item-source');
- var itemSourceName = $('#dropdown').data('item-source-name');
- var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked');
- var permissions = 0;
- var $loading = $('#showPassword .icon-loading-small');
-
- // Calculate permissions
- if (allowPublicUpload) {
- permissions = OC.PERMISSION_UPDATE + OC.PERMISSION_CREATE + OC.PERMISSION_READ;
- } else {
- permissions = OC.PERMISSION_READ;
- }
-
- $loading.removeClass('hidden');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, itemSourceName).then(function() {
- $loading.addClass('hidden');
- $('#linkPassText').attr('placeholder', t('core', 'Choose a password for the public link'));
- });
- } else {
- $('#linkPassText').focus();
- }
- });
-
- $(document).on('focusout keyup', '#dropdown #linkPassText', function(event) {
- var linkPassText = $('#linkPassText');
- if ( linkPassText.val() != '' && (event.type == 'focusout' || event.keyCode == 13) ) {
- var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked');
- var dropDown = $('#dropdown');
- var itemType = dropDown.data('item-type');
- var itemSource = dropDown.data('item-source');
- var itemSourceName = $('#dropdown').data('item-source-name');
- var permissions = 0;
- var $loading = dropDown.find('#linkPass .icon-loading-small');
-
- // Calculate permissions
- if (allowPublicUpload) {
- permissions = OC.PERMISSION_UPDATE + OC.PERMISSION_CREATE + OC.PERMISSION_READ;
- } else {
- permissions = OC.PERMISSION_READ;
- }
-
- var expireDateString = OC.Share.getDefaultExpirationDate();
-
- $loading.removeClass('hidden');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, expireDateString, function(data) {
- $loading.addClass('hidden');
- linkPassText.val('');
- linkPassText.attr('placeholder', t('core', 'Password protected'));
-
- if (oc_appconfig.core.enforcePasswordForPublicLink) {
- OC.Share.showLink(data.token, "password set", itemSource);
- OC.Share.updateIcon(itemType, itemSource);
- }
- $('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
- }, function(result) {
- $loading.addClass('hidden');
- linkPassText.val('');
- linkPassText.attr('placeholder', result.data.message);
- });
-
- if (expireDateString !== '') {
- OC.Share.showExpirationDate(expireDateString);
- }
- }
- });
-
$(document).on('click', '#dropdown #expirationCheckbox', function() {
if (this.checked) {
OC.Share.showExpirationDate('');
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
index 3e3ef2d5029..d95b3d82020 100644
--- a/core/js/sharedialoglinkshareview.js
+++ b/core/js/sharedialoglinkshareview.js
@@ -94,7 +94,7 @@
throw 'missing OC.Share.ShareConfigModel';
}
- _.bindAll(this, 'onLinkCheckBoxChange');
+ _.bindAll(this, 'onLinkCheckBoxChange', 'onPasswordEntered', 'onShowPasswordClick');
},
onLinkCheckBoxChange: function() {
@@ -127,6 +127,28 @@
this.select();
},
+ onShowPasswordClick: function() {
+ this.$el.find('#linkPass').slideToggle(OC.menuSpeed);
+ if(!this.$el.find('#showPassword').is(':checked')) {
+ this.model.addLinkShare({password: ''});
+ } else {
+ this.$el.find('#linkPassText').focus();
+ }
+ },
+
+ onPasswordEntered: function() {
+ var password = this.$el.find('#linkPassText').val();
+ if(password === '') {
+ return;
+ }
+
+ this.$el.find('#linkPass .icon-loading-small')
+ .removeClass('hidden')
+ .addClass('inlineblock');
+
+ this.model.addLinkShare({password: password});
+ },
+
render: function() {
var linkShareTemplate = this.template();
@@ -178,6 +200,14 @@
this.$el.find('#linkCheckbox').change(this.onLinkCheckBoxChange);
this.$el.find('#linkText').click(this.onLinkTextClick);
+ this.$el.find('#showPassword').click(this.onShowPasswordClick);
+ this.$el.find('#linkPassText').focusout(this.onPasswordEntered);
+ var view = this;
+ this.$el.find('#linkPassText').keyup(function(event) {
+ if(event.keyCode == 13) {
+ view.onPasswordEntered();
+ }
+ });
return this;
},
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 7a7fe692c13..416fff53de4 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -157,7 +157,7 @@
this.$el.html(baseTemplate({
shareLabel: t('core', 'Share'),
sharePlaceholder: this._renderSharePlaceholderPart(),
- remoteShareInfo: this._renderRemoteShareInfoPart(),
+ remoteShareInfo: this._renderRemoteShareInfoPart()
}));
var view = this;
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 9e153dcb3e5..9e3f829e457 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -20,6 +20,7 @@
* @property {string} token
* @property {string|null} password
* @property {string} link
+ * @property {number} permissions
* @property {Date} expiration
* @property {number} stime share time
*/
@@ -89,12 +90,30 @@
linkShare: {}
},
- addLinkShare: function() {
+ addLinkShare: function(options) {
var model = this;
var expiration = this.configModel.getDefaultExpirationDateString();
var itemType = this.get('itemType');
var itemSource = this.get('itemSource');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, this.fileInfoModel.get('name'), expiration, function(data) {
+
+ var options = options || {};
+ var requiredOptions = [
+ { name: 'password', defaultValue: '' },
+ { name: 'permissions', defaultValue: OC.PERMISSION_READ }
+ ];
+ _.each(requiredOptions, function(option) {
+ // a provided options overrides a present value of the link
+ // share. If neither is given, the default value is used.
+ if(_.isUndefined(options[option.name])) {
+ options[option.name] = option.defaultValue;
+ var currentValue = model.get('linkShare')[option.name];
+ if(!_.isUndefined(currentValue)) {
+ options[option.name] = currentValue;
+ }
+ }
+ });
+
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, options.password, options.permissions, this.fileInfoModel.get('name'), expiration, function(data) {
model.fetch();
//FIXME: updateIcon belongs to view
OC.Share.updateIcon(itemType, itemSource);
@@ -512,6 +531,7 @@
token: share.token,
password: share.share_with,
link: link,
+ permissions: share.permissions,
// currently expiration is only effective for link shares.
expiration: share.expiration,
stime: share.stime