mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 00:00:00 +00:00
clean up code for 'link share'; fixed bug for 'login_require_ajax'
This commit is contained in:
@@ -4,7 +4,7 @@ except ImportError:
|
||||
from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback.
|
||||
|
||||
from seahub.auth import REDIRECT_FIELD_NAME
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
||||
from django.utils.decorators import available_attrs
|
||||
from django.utils.http import urlquote
|
||||
import simplejson as json
|
||||
|
@@ -38,14 +38,6 @@
|
||||
<label>{% trans "Password again"%}</label><br />
|
||||
<input type="password" name="passwd_again" disabled="disabled" class="input input-disabled" />
|
||||
</div>
|
||||
<label class="checkbox-label">
|
||||
<span class="checkbox"><input type="checkbox" name="set-expiration" id="link-expire-switch" class="checkbox-orig" /></span>
|
||||
<span class="checkbox-option">{% trans "Add auto expiration"%}</span>
|
||||
</label>
|
||||
<div id="link-expire" class="hide">
|
||||
<label>{% trans "Days" %}</label><br />
|
||||
<input type="text" name="expire-days" disabled="disabled" class="input input-disabled" />
|
||||
</div>
|
||||
<p class="error hide"></p>
|
||||
</div>
|
||||
<button id="gen-link-btn" class="hide">{% trans "Generate"%}</button>
|
||||
|
@@ -231,8 +231,7 @@ $('#gen-link-btn').click(function() {
|
||||
form = $('#link-options'),
|
||||
form_id = form.attr('id'),
|
||||
use_passwd = $('#link-passwd-switch').attr('checked'),
|
||||
set_expiration = $('#link-expire-switch').attr('checked'),
|
||||
passwd, passwd_again, expire_days, post_data;
|
||||
passwd, passwd_again, post_data;
|
||||
|
||||
if (use_passwd) {
|
||||
passwd = $('input[name="passwd"]', form).val();
|
||||
@@ -259,20 +258,6 @@ $('#gen-link-btn').click(function() {
|
||||
post_data = {'use_passwd': 0};
|
||||
}
|
||||
|
||||
if (set_expiration) {
|
||||
expire_days = $('input[name="expire-days"]', form).val();
|
||||
if (!$.trim(expire_days)) {
|
||||
apply_form_error(form_id, "{% trans "Please enter days" %}");
|
||||
return false;
|
||||
}
|
||||
if (Math.floor(expire_days) == expire_days && $.isNumeric(expire_days)) {
|
||||
post_data["expire_days"] = expire_days;
|
||||
} else {
|
||||
apply_form_error(form_id, "{% trans "Please enter valid days" %}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: gen_link_btn.data('url'),
|
||||
type: 'POST',
|
||||
@@ -285,9 +270,9 @@ $('#gen-link-btn').click(function() {
|
||||
gen_link_btn.addClass('hide');
|
||||
|
||||
$('#link-options, #link-options .error').addClass('hide');
|
||||
$('#link-passwd, #link-expire').hide(); // slideDown use 'show()'
|
||||
$('#link-passwd-switch, #link-expire-switch').attr('checked', false).parent().removeClass('checkbox-checked');
|
||||
$('[type="password"], [name="expire-days"]', form).val('').attr('disabled', false).removeClass('input-disabled');
|
||||
$('#link-passwd').hide(); // slideDown use 'show()'
|
||||
$('#link-passwd-switch').attr('checked', false).parent().removeClass('checkbox-checked');
|
||||
$('[type="password"]', form).val('').attr('disabled', false).removeClass('input-disabled');
|
||||
|
||||
$('#shared-link-text, #link-send-form input[name="file_shared_link"]').val(link);
|
||||
$('#main').append('<p id="linkwidth" class="hide">' + link + '</p>');
|
||||
@@ -301,7 +286,7 @@ $('#gen-link-btn').click(function() {
|
||||
feedback(jQuery.parseJSON(xhr.responseText).error, 'error');
|
||||
} else {
|
||||
feedback("{% trans "Failed. Please check the network." %}", 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@@ -513,17 +498,3 @@ $('#link-passwd-switch').click(function () {
|
||||
pwd_input.attr('disabled', true).addClass('input-disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('#link-expire-switch').click(function () {
|
||||
var form = $('#link-options'),
|
||||
days_input = $('input[name="expire-days"]', form);
|
||||
var link_expire = $('#link-expire');
|
||||
|
||||
if ($(this).attr('checked')) {
|
||||
link_expire.slideDown(100);
|
||||
days_input.attr('disabled', false).removeClass('input-disabled');
|
||||
} else {
|
||||
link_expire.slideUp(100);
|
||||
days_input.attr('disabled', true).addClass('input-disabled');
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user