<a href="#"
title="{% trans "Send email - rejected file(s)" %}"
class="btn btn-icon select-another-button"
data-url="{% url "messaging:send" request_id=object.pk %}">
<i class="material-icons">assignment_late</i>
<div class='alert alert-success' id='message'>
The message was sent to the client. Please wait 5 minutes before sending the message again.
</div>
</a>
app_name = 'messaging'
urlpatterns = [
...
url(r'^send/(?P<request_id>[0-9]+)/$',
send, name='send'),
]
@staff_member_required
@csrf_exempt
def send(request, request_id=None):
req= Request.objects.get(pk=request_id)
request_folders = req.folder.all_files.all()
context = []
for doc in request_folders:
if doc.meta.state == u'rejected':
context.append(doc)
if context:
ctx = {'request': req}
EmailFromTemplate('document-refusal', extra_context=ctx)\
.send_to(req.customer.user)
return HttpResponse('')
和
<div class="title-actions">
{% if not object.is_readonly %}
{# TODO: apply perms #}
<a href="#"
id="id_select_request_document"
title="{% trans "Select file(s)" %}"
class="btn btn-icon select-button"
data-turbolinks="false"
data-save-label="{% trans "Ok" %}"
data-close-label="{% trans "Cancel" %}"
data-copy-to="{{ folder.pk }}"
data-reload="true"
data-url="{% url "documents:ajax-select" folder_id=object.customer.folder.pk %}">
<i class="material-icons">folder</i>
</a>
{# TODO: apply perms #}
{# if permissions.has_add_children_permission and not folder.is_root #}
<a href="#"
id="id_upload_request_document"
title="{% trans "Upload file(s)" %}"
class="btn btn-icon upload-button"
data-turbolinks="false"
data-url="{% url "documents:ajax-upload" folder_id=folder.pk %}"
data-complete-post="{% url "requests:validate-requirements" pk=object.pk %}"
data-max-uploader-connections="1">
<i class="material-icons">cloud_upload</i>
</a>
<div class="wrapper">
<div id="overlay"></div>
<a href="#"
title="{% trans "Send email - rejected file(s)" %}"
class="btn btn-icon select-another-button"
data-url="{% url "messaging:send" request_id=object.pk %}">
<i class="material-icons">assignment_late</i>
<div class='alert alert-success' id='send-message' style="display: none;">
<p>
The message was sent to the client. Please wait 5 minutes <br> before sending the message again.
</p>
</div>
</a>
</div>
{% endif %}
{% if request.user.is_superuser %}
<a href="{{ folder.get_admin_directory_listing_url_path }}" class="btn-icon"><i class="material-icons">settings</i></a>
{% endif %}
</div>
此代码的目的是创建一个按钮,该按钮将在特定条件下发送电子邮件。我的弱点可能在于HTML和jS部分。一旦用户单击该按钮,我希望延迟五分钟才能再次发送消息。因此,我必须在使用后停用该按钮五分钟并显示消息:&#39; 消息已发送到客户端。请等待5分钟再重新发送邮件。&#39;当光标 ON 按钮时。我怎么能修改JS部分,以便它可以做我想要的?
.html
在修改之前,我得到right display,但现在我有wrong display。
我不知道它是否合适,但我将以下块放在<script type="text/css">
.wrapper{
position: relative;
display: inline-block;
}
#overlay{
display: none;
position: absolute;
top: 0;
left: 0;
opacity: .1;
background-color: blue;
height: 100%;
width: 100%;
}
文件的顶部。
.title-actions {
float: right;
height: 50px;
margin-top: 13px; }
.title-actions a {
transition: background 0.3s ease; }
.title-actions a.btn {
padding: 2px 14px;
line-height: 26px;
max-height: 28px;
position: relative;
top: -1px;
margin-left: 8px; }
.title-actions a:hover {
background: #4382b5; }
.title-actions span {
color: #444;
background: #e6e6e6;
padding: 6px 10px;
border-radius: 3px;
float: none;
position: relative;
margin-left: 6px; }
.title-actions .btn {
padding: 2px 14px;
line-height: 26px;
max-height: 28px;
position: relative;
top: -1px;
margin-left: 8px; }
.title-actions .btn-icon {
background: transparent;
position: relative;
color: #3e5366;
text-align: center;
display: inline-block;
padding: 0 !important;
transition: color 0.3s ease;
box-shadow: none !important;
margin-top: -16px;
margin-left: 6px; }
.title-actions .btn-icon i {
font-size: 35px;
line-height: 20px;
position: relative;
top: 12px; }
.title-actions .btn-icon:hover {
color: #4382b5;
background: transparent; }
.title-actions .badge .material-icons {
font-size: 1.2em;
line-height: 0;
position: relative;
top: 4px; }
public java.util.Map<String, java.util.Map<Integer, java.util.List<Integer>>> getPartitionAssignmentForTopics(final List<String> topics) {
final scala.collection.Seq<String> seqTopics = scala.collection.JavaConversions.asScalaBuffer(topics).toList();
scala.collection.mutable.Map<String, scala.collection.Map<Object, scala.collection.Seq<Object>>> tmpMap1 =
zkUtils.getPartitionAssignmentForTopics(seqTopics);
final java.util.Map<String, java.util.Map<Integer, java.util.List<Integer>>> result = new HashMap<>();
java.util.Map<String, Map<Object, Seq<Object>>> tmpMap2 = JavaConversions.mapAsJavaMap(tmpMap1);
tmpMap2.forEach((k1, v1) -> {
String topic = (String)k1;
java.util.Map<Object, Seq<Object>> objectSeqMap = JavaConversions.mapAsJavaMap(v1);
java.util.Map<Integer, List<Integer>> tmpResultMap = new HashMap<>();
objectSeqMap.forEach((k2, v2) -> {
Integer tmpInt = (Integer)k2;
List<Integer> tmpList = (List<Integer>)(Object)JavaConversions.seqAsJavaList(v2);
tmpResultMap.put(tmpInt, tmpList);
});
result.put(topic, tmpResultMap);
});
return result;
}
答案 0 :(得分:0)
您需要对代码进行大量更改。假设您只有1个元素id="message"
。
从您的JQuery代码开始。
$(function(){
$('.select-another-button').each(function(){
$(this).bind('click', function(e) {
$(this).attr('disabled','true'); //disables the button
$('#overlay').show(); //after disabling show the overlay for hover
setTimeout(function(){
$(this).attr('disabled','false'); //enables after 5mins
$('#overlay').hide(); //hide the overlay
}, 300000);
e.preventDefault();
fileBrowser(this);
return false;
});
});
});
$("#overlay").hover(function(){
$('#message').show();
},function(){
$('#message').hide();
});
由于已禁用按钮无法在其上显示hover
个事件,因此您需要在按钮上添加透明覆盖图。在其悬停时显示#message
。
<强> HTML 强>
<div class="wrapper">
<div id="overlay"></div>
<a href="#"
title="{% trans "Send email - rejected file(s)" %}"
class="btn btn-icon select-another-button"
data-url="{% url "messaging:send" request_id=object.pk %}">
<i class="material-icons">assignment_late</i>
<div class='alert alert-success' id='message' style="display: none;">
The message was sent to the client. Please wait 5 minutes before sending the message again.
</div>
</a>
</div>
当然,CSS更改以确保overlay
正确放置在稍后禁用的按钮上。
.wrapper{
position: relative;
display: inline-block;
}
#overlay{
display: none;
position: absolute;
top: 0;
left: 0;
opacity: .1;
height: 100%;
width: 100%;
}
$(function(){
$('.select-another-button').each(function(){
$(this).bind('click', function(e) {
$(this).attr('disabled','true');
$('#overlay').show();
setTimeout(function(){
$(this).attr('disabled','false');
$('#overlay').hide();
}, 300000);
e.preventDefault();
fileBrowser(this);
return false;
});
});
});
$("#overlay").hover(function(){
$('#message').show();
},function(){
$('#message').hide();
});
&#13;
.wrapper{
position: relative;
display: inline-block;
}
#overlay{
display: none;
position: absolute;
top: 0;
left: 0;
opacity: .1;
height: 100%;
width: 100%;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div id="overlay"></div>
<a href="#"
title="{% trans "Send email - rejected file(s)" %}"
class="btn btn-icon select-another-button"
data-url="{% url "messaging:send" request_id=object.pk %}">
<i class="material-icons">assignment_late</i>
<div class='alert alert-success' id='message' style="display: none;">
The message was sent to the client. Please wait 5 minutes before sending the message again.
</div>
</a>
</div>
&#13;