' </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" />' +
+ ' <input type="submit" class="icon-confirm share-pass-submit" value="" />' +
' <span class="icon icon-loading-small hidden"></span>' +
' </span></li>' +
'{{/if}}' +
// open menu
'click .share-menu .icon-more': 'onToggleMenu',
// password
- 'focusout input.linkPassText': 'onPasswordEntered',
- 'keyup input.linkPassText': 'onPasswordKeyUp',
+ 'click input.share-pass-submit': 'onPasswordEntered',
+ 'keyup input.linkPassText': 'onPasswordKeyUp', // check for the enter key
'change .showPasswordCheckbox': 'onShowPasswordClick',
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
// copy link url
},
error: function(model, msg) {
// destroy old tooltips
- $input.tooltip('destroy');
+ var $container = $input.parent();
+ $container.tooltip('destroy');
$input.addClass('error');
- $input.attr('title', msg);
- $input.tooltip({placement: 'bottom', trigger: 'manual'});
- $input.tooltip('show');
+ $container.attr('title', msg);
+ $container.tooltip({placement: 'bottom', trigger: 'manual'});
+ $container.tooltip('show');
}
});
},
describe('Share with link', function() {
// TODO: test ajax calls
// TODO: test password field visibility (whenever enforced or not)
- it('update password on focus out', function() {
+ it('update password on enter', function() {
$('#allowShareWithLink').val('yes');
dialog.model.set('linkShare', {
});
dialog.render();
- // Enable password, enter password and focusout
+ // Toggle linkshare
+ dialog.$el.find('.linkCheckbox').click();
+
+ // Enable password and enter password
dialog.$el.find('[name=showPassword]').click();
dialog.$el.find('.linkPassText').focus();
dialog.$el.find('.linkPassText').val('foo');
- dialog.$el.find('.linkPassText').focusout();
+ dialog.$el.find('.linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
expect(saveLinkShareStub.calledOnce).toEqual(true);
expect(saveLinkShareStub.firstCall.args[0]).toEqual({
password: 'foo'
});
});
- it('update password on enter', function() {
+ it('update password on submit', function() {
$('#allowShareWithLink').val('yes');
dialog.model.set('linkShare', {
dialog.$el.find('[name=showPassword]').click();
dialog.$el.find('.linkPassText').focus();
dialog.$el.find('.linkPassText').val('foo');
- dialog.$el.find('.linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+ dialog.$el.find('.linkPassText + .icon-confirm').click();
expect(saveLinkShareStub.calledOnce).toEqual(true);
expect(saveLinkShareStub.firstCall.args[0]).toEqual({