if (link) {
html += '<div id="link">';
html += '<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">Share with link</label>';
- // TODO Change to lock/unlock icon?
- html += '<a href="#" id="showPassword" style="display:none;"><img class="svg" alt="Password protect" src="'+OC.imagePath('core', 'actions/triangle-n')+'"/></a>';
+ html += '<a href="#" id="showPassword" style="display:none;"><img class="svg" alt="Password protect" src="'+OC.imagePath('core', 'actions/lock')+'"/></a>';
html += '<br />';
- html += '<input id="linkText" style="display:none; width:90%;" readonly="readonly" />';
- html += '<input id="linkPassText" type="password" placeholder="Password" style="display:none; width:90%;" />';
+ html += '<input id="linkText" type="text" readonly="readonly" />';
+ html += '<div id="linkPass">';
+ html += '<input id="linkPassText" type="password" placeholder="Password" />';
+ html += '</div>';
html += '</div>';
}
+ html += '<div id="expiration">';
+ html += '<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" /><label for="expirationCheckbox">Set expiration date</label>';
+ html += '<input id="expirationDate" type="text" placeholder="Expiration date" style="display:none; width:90%;" />';
html += '</div>';
$(html).appendTo(appendTo);
// Reset item shares
if (event.keyCode == 13) {
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
- // TODO Do this internally
- OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.Share.PERMISSION_READ);
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() {
+ $('#linkPassText').val('');
+ $('#linkPassText').attr('placeholder', 'Password protected');
+ });
}
});
- $('#expirationCheckbox').live('change', function() {
+
- console.log('checked');
++ $('#expirationCheckbox').live('click', function() {
+ if (this.checked) {
- console.log('unchecled');
+ $('#expirationDate').before('<br />');
+ $('#expirationDate').show();
+ $('#expirationDate').datepicker({
+ dateFormat : 'dd-mm-yy'
+ });
+ } else {
- $('#emailPrivateLink').live('submit', function() {
- OC.Share.emailPrivateLink();
- });
+ $('#expirationDate').hide();
+ }
+ });
+
+ $('#expirationDate').live('change', function() {
+ var itemType = $('#dropdown').data('item-type');
+ var itemSource = $('#dropdown').data('item-source');
+ $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: $(this).val() }, function(result) {
+ if (!result || result.status !== 'success') {
+ OC.dialogs.alert('Error', 'Error setting expiration date');
+ }
+ });
+ });
+
});