diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
index dfc0b020818..f3500cee0a3 100644
--- a/core/js/sharedialoglinkshareview.js
+++ b/core/js/sharedialoglinkshareview.js
@@ -42,13 +42,19 @@
'' +
'' +
' {{/if}}' +
+ ' {{#if mailPublicNotificationEnabled}}' +
+ '
' +
+ ' {{/if}}' +
'' +
' ' +
' ' +
' ' +
'
' +
'{{else}}' +
- // FIXME: this doesn't belong in this view
+ // FIXME: this doesn't belong in this view
'{{#if noSharingPlaceholder}}{{/if}}' +
'{{/if}}'
;
@@ -77,6 +83,7 @@
showLink: true,
events: {
+ 'submit .emailPrivateLinkForm': '_onEmailPrivateLink',
'focusout input.linkPassText': 'onPasswordEntered',
'keyup input.linkPassText': 'onPasswordKeyUp',
'click .linkCheckbox': 'onLinkCheckBoxChange',
@@ -117,6 +124,7 @@
_.bindAll(
this,
+ '_onEmailPrivateLink',
'onLinkCheckBoxChange',
'onPasswordEntered',
'onPasswordKeyUp',
@@ -237,9 +245,38 @@
});
},
+ _onEmailPrivateLink: function(event) {
+ event.preventDefault();
+
+ var $emailField = this.$el.find('.emailField');
+ var $emailButton = this.$el.find('.emailButton');
+ var email = $emailField.val();
+ if (email !== '') {
+ $emailField.prop('disabled', true);
+ $emailButton.prop('disabled', true);
+ $emailField.val(t('core', 'Sending ...'));
+ this.model.sendEmailPrivateLink(email).done(function() {
+ $emailField.css('font-weight', 'bold').val(t('core','Email sent'));
+ setTimeout(function() {
+ $emailField.val('');
+ $emailField.css('font-weight', 'normal');
+ $emailField.prop('disabled', false);
+ $emailButton.prop('disabled', false);
+ }, 2000);
+ }).fail(function() {
+ $emailField.val(email);
+ $emailField.css('font-weight', 'normal');
+ $emailField.prop('disabled', false);
+ $emailButton.prop('disabled', false);
+ });
+ }
+ return false;
+ },
+
render: function() {
var linkShareTemplate = this.template();
var resharingAllowed = this.model.sharePermissionPossible();
+ var email = this.$el.find('.emailField').val();
if(!resharingAllowed
|| !this.showLink
@@ -297,9 +334,43 @@
hideFileListLabel: t('core', 'Hide file listing'),
mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(),
mailPrivatePlaceholder: t('core', 'Email link to person'),
- mailButtonText: t('core', 'Send')
+ mailButtonText: t('core', 'Send'),
+ email: email
}));
+ var $emailField = this.$el.find('.emailField');
+ if (isLinkShare && $emailField.length !== 0) {
+ $emailField.autocomplete({
+ minLength: 1,
+ source: function (search, response) {
+ $.get(
+ OC.generateUrl('core/ajax/share.php'), {
+ fetch: 'getShareWithEmail',
+ search: search.term
+ }, function(result) {
+ if (result.status == 'success' && result.data.length > 0) {
+ response(result.data);
+ }
+ });
+ },
+ select: function( event, item ) {
+ $emailField.val(item.item.email);
+ return false;
+ }
+ })
+ .data("ui-autocomplete")._renderItem = function( ul, item ) {
+ return $('')
+ .append('' + escapeHTML(item.displayname) + "
" + escapeHTML(item.email) + '' )
+ .appendTo( ul );
+ };
+ }
+
+ // TODO drop with IE8 drop
+ if($('html').hasClass('ie8')) {
+ this.$el.find('#linkPassText').removeAttr('placeholder');
+ this.$el.find('#linkPassText').val('');
+ }
+
this.delegateEvents();
return this;
@@ -320,4 +391,4 @@
OC.Share.ShareDialogLinkShareView = ShareDialogLinkShareView;
-})();
\ No newline at end of file
+})();