diff --git a/core/js/sharedialogexpirationview.js b/core/js/sharedialogexpirationview.js index 772b9ba97d..eef440c9af 100644 --- a/core/js/sharedialogexpirationview.js +++ b/core/js/sharedialogexpirationview.js @@ -8,6 +8,8 @@ * */ +/* global moment */ + (function() { if (!OC.Share) { OC.Share = {}; @@ -19,9 +21,9 @@ // in the LinkShareView to ease reusing it in future. Then, // modifications (getting rid of IDs) are still necessary. '{{#if isLinkShare}}' + - '' + - '' + + '' + '
' + ' ' + ' ' + @@ -134,11 +136,11 @@ var expiration; if (isExpirationSet) { - expiration = moment(this.model.get('linkShare').expiration, 'YYYY-MM-DD').format('DD-MM-YYYY') + expiration = moment(this.model.get('linkShare').expiration, 'YYYY-MM-DD').format('DD-MM-YYYY'); } - var expirationTemplate = this.template(); - this.$el.html(expirationTemplate({ + this.$el.html(this.template({ + cid: this.cid, setExpirationLabel: t('core', 'Set expiration date'), expirationLabel: t('core', 'Expiration'), expirationDatePlaceholder: t('core', 'Expiration date'), @@ -186,11 +188,11 @@ * @returns {Function} from Handlebars * @private */ - template: function () { + template: function (data) { if (!this._template) { this._template = Handlebars.compile(TEMPLATE); } - return this._template; + return this._template(data); } }); diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 1bbd10d572..dfd9bdc2f4 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -16,33 +16,36 @@ var TEMPLATE = '{{#if shareAllowed}}' + '' + - '' + + '' + + '' + '
' + - '' + - '' + + '' + + '' + ' {{#if showPasswordCheckBox}}' + - '' + + '' + + '' + ' {{/if}}' + - '
' + - ' ' + - ' ' + + '
' + + ' ' + + ' ' + ' ' + '
' + ' {{#if publicUpload}}' + '
' + ' ' + - ' ' + - '' + + ' ' + + '' + '
' + ' {{/if}}' + ' {{#if mailPublicNotificationEnabled}}' + '' + ' {{/if}}' + '{{else}}' + - '' + + // FIXME: this doesn't belong in this view + '' + '{{/if}}' ; @@ -70,7 +73,13 @@ showLink: true, events: { - 'submit .emailPrivateLinkForm': '_onEmailPrivateLink' + 'submit .emailPrivateLinkForm': '_onEmailPrivateLink', + 'focusout input.linkPassText': 'onPasswordEntered', + 'keyup input.linkPassText': 'onPasswordKeyUp', + 'click .linkCheckbox': 'onLinkCheckBoxChange', + 'click .linkText': 'onLinkTextClick', + 'change .publicUploadCheckbox': 'onAllowPublicUploadChange', + 'click .showPasswordCheckbox': 'onShowPasswordClick' }, initialize: function(options) { @@ -98,12 +107,20 @@ throw 'missing OC.Share.ShareConfigModel'; } - _.bindAll(this, 'onLinkCheckBoxChange', 'onPasswordEntered', - 'onShowPasswordClick', 'onAllowPublicUploadChange'); + _.bindAll( + this, + '_onEmailPrivateLink', + 'onLinkCheckBoxChange', + 'onPasswordEntered', + 'onPasswordKeyUp', + 'onLinkTextClick', + 'onShowPasswordClick', + 'onAllowPublicUploadChange' + ); }, onLinkCheckBoxChange: function() { - var $checkBox = this.$el.find('#linkCheckbox'); + var $checkBox = this.$el.find('.linkCheckbox'); var $loading = $checkBox.siblings('.icon-loading-small'); if(!$loading.hasClass('hidden')) { return false; @@ -115,19 +132,19 @@ // this will create it this.model.saveLinkShare(); } else { - this.$el.find('#linkPass').slideToggle(OC.menuSpeed); + this.$el.find('.linkPass').slideToggle(OC.menuSpeed); // TODO drop with IE8 drop if($('html').hasClass('ie8')) { - this.$el.find('#linkPassText').attr('placeholder', null); - this.$el.find('#linkPassText').val(''); + this.$el.find('.linkPassText').attr('placeholder', null); + this.$el.find('.linkPassText').val(''); } - this.$el.find('#linkPassText').focus(); + this.$el.find('.linkPassText').focus(); } } else { if (this.model.get('linkShare').isLinkShare) { this.model.removeLinkShare(); } else { - this.$el.find('#linkPass').slideToggle(OC.menuSpeed); + this.$el.find('.linkPass').slideToggle(OC.menuSpeed); } } }, @@ -138,23 +155,29 @@ }, onShowPasswordClick: function() { - this.$el.find('#linkPass').slideToggle(OC.menuSpeed); - if(!this.$el.find('#showPassword').is(':checked')) { + this.$el.find('.linkPass').slideToggle(OC.menuSpeed); + if(!this.$el.find('.showPasswordCheckbox').is(':checked')) { this.model.setPassword(''); this.model.saveLinkShare(); } else { - this.$el.find('#linkPassText').focus(); + this.$el.find('.linkPassText').focus(); + } + }, + + onPasswordKeyUp: function(event) { + if(event.keyCode == 13) { + this.onPasswordEntered(); } }, onPasswordEntered: function() { var self = this; - var $loading = this.$el.find('#linkPass .icon-loading-small'); + var $loading = this.$el.find('.linkPass .icon-loading-small'); if (!$loading.hasClass('hidden')) { // still in process return; } - var $input = this.$el.find('#linkPassText'); + var $input = this.$el.find('.linkPassText'); $input.removeClass('error'); var password = $input.val(); if(password === '') { @@ -178,18 +201,18 @@ }, onAllowPublicUploadChange: function() { - this.$el.find('#sharingDialogAllowPublicUpload') - .siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock'); - this.model.setPublicUpload(this.$el.find('#sharingDialogAllowPublicUpload').is(':checked')); + var $checkbox = this.$('.publicUploadCheckbox'); + $checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock'); + this.model.setPublicUpload($checkbox.is(':checked')); this.model.saveLinkShare(); }, _onEmailPrivateLink: function(event) { event.preventDefault(); - var $emailField = this.$el.find('#email'); - var $emailButton = this.$el.find('#emailButton'); - var email = this.$el.find('#email').val(); + 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); @@ -243,6 +266,7 @@ || !this.model.get('linkShare').password); this.$el.html(linkShareTemplate({ + cid: this.cid, shareAllowed: true, isLinkShare: isLinkShare, shareLinkURL: this.model.get('linkShare').link, @@ -261,20 +285,7 @@ mailButtonText: t('core', 'Send') })); - // TODO: move this to delegate events instead - this.$el.find('#linkCheckbox').click(this.onLinkCheckBoxChange); - this.$el.find('#sharingDialogAllowPublicUpload').change(this.onAllowPublicUploadChange); - 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(); - } - }); - - var $emailField = this.$el.find('#email'); + var $emailField = this.$el.find('.emailField'); if (isLinkShare && $emailField.length !== 0) { $emailField.autocomplete({ minLength: 1, diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index c29716b3e5..dfe5789e77 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -14,7 +14,7 @@ } var TEMPLATE = - '