diff --git a/core/js/share.js b/core/js/share.js index 01467b495f..0a3bba49b6 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -405,272 +405,6 @@ OC.Share = _.extend(OC.Share, { OC.Share.droppedDown = true; }); itemModel.fetch(); - return; - - - var data = OC.Share.loadItem(itemType, itemSource); - var dropDownEl; - var html = ''; - dropDownEl = $(html); - dropDownEl.appendTo(appendTo); - } - dropDownEl.attr('data-item-source-name', filename); - $('#dropdown').slideDown(OC.menuSpeed, function() { - OC.Share.droppedDown = true; - }); - if ($('html').hasClass('lte9')){ - $('#dropdown input[placeholder]').placeholder(); - } - $('#shareWith').focus(); }, hideDropDown:function(callback) { OC.Share.currentShares = null; @@ -687,66 +421,6 @@ OC.Share = _.extend(OC.Share, { }, dirname:function(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); - }, - /** - * Parses a string to an valid integer (unix timestamp) - * @param time - * @returns {*} - * @internal Only used to work around a bug in the backend - */ - _parseTime: function(time) { - if (_.isString(time)) { - // skip empty strings and hex values - if (time === '' || (time.length > 1 && time[0] === '0' && time[1] === 'x')) { - return null; - } - time = parseInt(time, 10); - if(isNaN(time)) { - time = null; - } - } - return time; - }, - /** - * Displays the expiration date field - * - * @param {Date} date current expiration date - * @param {int} [shareTime] share timestamp in seconds, defaults to now - */ - showExpirationDate:function(date, shareTime) { - var now = new Date(); - // min date should always be the next day - var minDate = new Date(); - minDate.setDate(minDate.getDate()+1); - var datePickerOptions = { - minDate: minDate, - maxDate: null - }; - // TODO: hack: backend returns string instead of integer - shareTime = OC.Share._parseTime(shareTime); - if (_.isNumber(shareTime)) { - shareTime = new Date(shareTime * 1000); - } - if (!shareTime) { - shareTime = now; - } - $('#expirationCheckbox').attr('checked', true); - $('#expirationDate').val(date); - $('#expirationDate').slideDown(OC.menuSpeed); - $('#expirationDate').css('display','block'); - $('#expirationDate').datepicker({ - dateFormat : 'dd-mm-yy' - }); - if (oc_appconfig.core.defaultExpireDateEnforced) { - $('#expirationCheckbox').attr('disabled', true); - shareTime = OC.Util.stripTime(shareTime).getTime(); - // max date is share date + X days - datePickerOptions.maxDate = new Date(shareTime + oc_appconfig.core.defaultExpireDate * 24 * 3600 * 1000); - } - if(oc_appconfig.core.defaultExpireDateEnabled) { - $('#defaultExpireMessage').slideDown(OC.menuSpeed); - } - $.datepicker.setDefaults(datePickerOptions); } }); @@ -776,104 +450,6 @@ $(document).ready(function() { } }); - $(document).on('click', '#dropdown #expirationCheckbox', function() { - if (this.checked) { - OC.Share.showExpirationDate(''); - } else { - 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: '' }, function(result) { - if (!result || result.status !== 'success') { - OC.dialogs.alert(t('core', 'Error unsetting expiration date'), t('core', 'Error')); - } - $('#expirationDate').slideUp(OC.menuSpeed); - if (oc_appconfig.core.defaultExpireDateEnforced === false) { - $('#defaultExpireMessage').slideDown(OC.menuSpeed); - } - }); - } - }); - - $(document).on('change', '#dropdown #expirationDate', function() { - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - - $(this).tipsy('hide'); - $(this).removeClass('error'); - - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: $(this).val() }, function(result) { - if (!result || result.status !== 'success') { - var expirationDateField = $('#dropdown #expirationDate'); - if (!result.data.message) { - expirationDateField.attr('original-title', t('core', 'Error setting expiration date')); - } else { - expirationDateField.attr('original-title', result.data.message); - } - expirationDateField.tipsy({gravity: 'n'}); - expirationDateField.tipsy('show'); - expirationDateField.addClass('error'); - } else { - if (oc_appconfig.core.defaultExpireDateEnforced === 'no') { - $('#defaultExpireMessage').slideUp(OC.menuSpeed); - } - } - }); - }); - - - $(document).on('submit', '#dropdown #emailPrivateLink', function(event) { - event.preventDefault(); - var link = $('#linkText').val(); - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); - var email = $('#email').val(); - var expirationDate = ''; - if ( $('#expirationCheckbox').is(':checked') === true ) { - expirationDate = $( "#expirationDate" ).val(); - } - if (email != '') { - $('#email').prop('disabled', true); - $('#email').val(t('core', 'Sending ...')); - $('#emailButton').prop('disabled', true); - - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file, expiration: expirationDate}, - function(result) { - $('#email').prop('disabled', false); - $('#emailButton').prop('disabled', false); - if (result && result.status == 'success') { - $('#email').css('font-weight', 'bold').val(t('core','Email sent')); - setTimeout(function() { - $('#email').css('font-weight', 'normal').val(''); - }, 2000); - } else { - OC.dialogs.alert(result.data.message, t('core', 'Error while sharing')); - } - }); - } - }); - - $(document).on('click', '#dropdown input[name=mailNotification]', function() { - var $li = $(this).closest('li'); - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - var action = ''; - if (this.checked) { - action = 'informRecipients'; - } else { - action = 'informRecipientsDisabled'; - } - - var shareType = $li.data('share-type'); - var shareWith = $li.attr('data-share-with'); - - $.post(OC.filePath('core', 'ajax', 'share.php'), {action: action, recipient: shareWith, shareType: shareType, itemSource: itemSource, itemType: itemType}, function(result) { - if (result.status !== 'success') { - OC.dialogs.alert(t('core', result.data.message), t('core', 'Warning')); - } - }); - -}); });