diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2012-12-18 04:04:37 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2012-12-18 04:04:37 -0800 |
commit | a5a25eb2a81dc2bc6fe4be8fe6766d7a82989516 (patch) | |
tree | 87670c95cab2164e6ab4f72d95c3da3729ccc954 /core | |
parent | db30d8621e29cc4e32a11c8ee3bdfd92bd5cb6c9 (diff) | |
parent | a0b3b65fa3086274b041ea8b1b6a42e7fce62584 (diff) | |
download | nextcloud-server-a5a25eb2a81dc2bc6fe4be8fe6766d7a82989516.tar.gz nextcloud-server-a5a25eb2a81dc2bc6fe4be8fe6766d7a82989516.zip |
Merge pull request #709 from schiesbn/set_passwd_on_enter_and_focusout
set password for shared links when the user press enter
Diffstat (limited to 'core')
-rw-r--r-- | core/js/share.js | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/core/js/share.js b/core/js/share.js index 59e11150af7..0d4f5d1b0ee 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -140,9 +140,9 @@ OC.Share={ if (link) { html += '<div id="link">'; html += '<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">'+t('core', 'Share with link')+'</label>'; - html += '<a href="#" id="showPassword" style="display:none;"><img class="svg" alt="'+t('core', 'Password protect')+'" src="'+OC.imagePath('core', 'actions/lock')+'"/></a>'; html += '<br />'; html += '<input id="linkText" type="text" readonly="readonly" />'; + html += '<input type="checkbox" name="showPassword" id="showPassword" value="1" style="display:none;" /><label for="showPassword" style="display:none;">'+t('core', 'Password protect')+'</label>'; html += '<div id="linkPass">'; html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />'; html += '</div>'; @@ -326,9 +326,12 @@ OC.Share={ } $('#linkText').val(link); $('#linkText').show('blind'); + $('#linkText').css('display','block'); $('#showPassword').show(); + $('#showPassword+label').show(); if (password != null) { $('#linkPass').show('blind'); + $('#showPassword').attr('checked', true); $('#linkPassText').attr('placeholder', t('core', 'Password protected')); } $('#expiration').show(); @@ -338,6 +341,7 @@ OC.Share={ hideLink:function() { $('#linkText').hide('blind'); $('#showPassword').hide(); + $('#showPassword+label').hide(); $('#linkPass').hide(); $('#emailPrivateLink #email').hide(); $('#emailPrivateLink #emailButton').hide(); @@ -487,16 +491,25 @@ $(document).ready(function() { $('#showPassword').live('click', function() { $('#linkPass').toggle('blind'); + if (!$('#showPassword').is(':checked') ) { + var itemType = $('#dropdown').data('item-type'); + var itemSource = $('#dropdown').data('item-source'); + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ); + } else { + $('#linkPassText').focus(); + } }); - $('#linkPassText').live('focusout', function(event) { - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() { - $('#linkPassText').val(''); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); - }); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + $('#linkPassText').live('focusout keyup', function(event) { + if ( $('#linkPassText').val() != '' && (event.type == 'focusout' || event.keyCode == 13) ) { + var itemType = $('#dropdown').data('item-type'); + var itemSource = $('#dropdown').data('item-source'); + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), OC.PERMISSION_READ, function() { + console.log("password set to: '" + $('#linkPassText').val() +"' by event: " + event.type); + $('#linkPassText').val(''); + $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + }); + } }); $('#expirationCheckbox').live('click', function() { |