mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
[msg] move 'send msg' from topbar to all_msg_list page
This commit is contained in:
@@ -808,10 +808,6 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
margin-right:2px;
|
margin-right:2px;
|
||||||
vertical-align:middle;
|
vertical-align:middle;
|
||||||
}
|
}
|
||||||
#add-msg.add-msg-hl {
|
|
||||||
background:#fff;
|
|
||||||
line-height:22px;
|
|
||||||
}
|
|
||||||
.top-bar-con .msg-count {
|
.top-bar-con .msg-count {
|
||||||
color:red;
|
color:red;
|
||||||
}
|
}
|
||||||
@@ -876,7 +872,7 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
box-shadow:0 0 5px #ccc;
|
box-shadow:0 0 5px #ccc;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
right:0;
|
right:0;
|
||||||
top:24px;
|
top:-24px;
|
||||||
z-index:100;/* for pages with jquery tabs*/
|
z-index:100;/* for pages with jquery tabs*/
|
||||||
}
|
}
|
||||||
#msg-file-share {
|
#msg-file-share {
|
||||||
@@ -2484,3 +2480,7 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
color:#666;
|
color:#666;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
}
|
}
|
||||||
|
#add-msg .icon-pencil {
|
||||||
|
font-size:1em;
|
||||||
|
margin:0 3px 0 0;
|
||||||
|
}
|
||||||
|
@@ -9,11 +9,12 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title_panel %}
|
{% block title_panel %}
|
||||||
<div class="tabnav">
|
<div class="tabnav w100">
|
||||||
<ul class="tabnav-tabs">
|
<ul class="tabnav-tabs fleft">
|
||||||
<li class="tabnav-tab"><a href="{% url 'user_notification_list' %}">{% trans "Notices" %}</a></li>
|
<li class="tabnav-tab"><a href="{% url 'user_notification_list' %}">{% trans "Notices" %}</a></li>
|
||||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Messages" %}</li>
|
<li class="tabnav-tab tabnav-tab-cur">{% trans "Messages" %}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<button id="add-msg" class="fright"><span class="icon-pencil"></span>{% trans "New Message" %}</button>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -31,13 +32,30 @@
|
|||||||
<tr data-href="{% url 'user_msg_list' key|id_or_email %}" class="{% if not_read > 0 %}bold{% endif %}">
|
<tr data-href="{% url 'user_msg_list' key|id_or_email %}" class="{% if not_read > 0 %}bold{% endif %}">
|
||||||
<td class="alc">{% avatar key 20 %}</td>
|
<td class="alc">{% avatar key 20 %}</td>
|
||||||
<td>{{ key }}{% if not_read > 0%}({{not_read}}){% endif %}</td>
|
<td>{{ key }}{% if not_read > 0%}({{not_read}}){% endif %}</td>
|
||||||
<td>{{ value.last_msg|truncatechars:60 }}</td>
|
<td>{{ value.last_msg|seahub_urlize|truncatewords_html:12 }}</td>
|
||||||
<td>{{ value.last_time|translate_seahub_time }}</td>
|
<td>{{ value.last_time|translate_seahub_time }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="send-msg-popup" class="hide">
|
||||||
|
<img src="{{MEDIA_URL}}img/loading-icon.gif" class="loading-tip" />
|
||||||
|
<form id="send-msg-form" action="{% url 'message_send' %}" method="post" name="send-msg-form" class="hide">{% csrf_token %}
|
||||||
|
<textarea id="mass-msg" name="mass_msg" placeholder="{% trans "message..." %}"></textarea><br/>
|
||||||
|
<select id="mass-email" name="mass_email" multiple="multiple"></select><br/>
|
||||||
|
<div id="msg-file-share">
|
||||||
|
<button type="button" id="msg-file-share-btn"><span class="icon-plus-sign-alt"></span> {% trans "Add files" %}</button>
|
||||||
|
<div id="msg-file-tree" class="hide"></div>
|
||||||
|
<span class="icon-remove hide"></span>
|
||||||
|
</div>
|
||||||
|
<p class="error hide"></p>
|
||||||
|
<input type="submit" value="{% trans "Submit"%}" />
|
||||||
|
<input type="button" value="{% trans "Cancel"%}" class="cancel" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
@@ -47,5 +65,109 @@ $(function(){
|
|||||||
location.href = $(this).data('href');
|
location.href = $(this).data('href');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#main-panel').removeClass('ovhd').css({'position':'relative'});
|
||||||
|
$('#add-msg').click(function() {
|
||||||
|
var add_msg_btn = $('#add-msg'),
|
||||||
|
popup = $('#send-msg-popup');
|
||||||
|
|
||||||
|
if (!popup.hasClass('hide')) {
|
||||||
|
popup.addClass('hide');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
popup.removeClass('hide');
|
||||||
|
$.ajax({
|
||||||
|
url:'{% url 'get_contacts' %}',
|
||||||
|
cache: false,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
var contacts = data['contacts'],
|
||||||
|
opts = '',
|
||||||
|
email;
|
||||||
|
if (contacts.length > 0) {
|
||||||
|
popup.find('.loading-tip').remove();
|
||||||
|
$('#send-msg-form').removeClass('hide');
|
||||||
|
|
||||||
|
for(var i = 0, len = contacts.length; i < len; i++) {
|
||||||
|
email = contacts[i].email;
|
||||||
|
opts += '<option value="' + email + '" data-index="' + i + '">' + email + '</option>';
|
||||||
|
}
|
||||||
|
var format = function(item) {
|
||||||
|
return contacts[$(item.element).data('index')].avatar + '<span class="vam">' + item.text + '</span>';
|
||||||
|
}
|
||||||
|
$('#mass-email').html(opts).select2({
|
||||||
|
placeholder: "{% trans "send to: click to select contacts" %}",
|
||||||
|
formatResult: format,
|
||||||
|
formatSelection: format,
|
||||||
|
escapeMarkup: function(m) { return m; }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
popup.html('<p>' + "{% trans "please add contacts at first" %}" + '</p>');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
popup.html('<p class="error">' + "{% trans "Failed to get your contacts for sending a message." %}" + '</p>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(document).click(function(e) {
|
||||||
|
if (e.eventPhase == 2) { // for ff
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var target = e.target || event.srcElement,
|
||||||
|
popup = $('#send-msg-popup'),
|
||||||
|
popup_switch = $('#add-msg');
|
||||||
|
if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target)) {
|
||||||
|
popup.addClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#msg-file-share-btn').click(function() {
|
||||||
|
var msg_file_share = $('#msg-file-share'),
|
||||||
|
btn = $(this);
|
||||||
|
$.ajax({
|
||||||
|
'url': '{% url 'get_my_unenc_repos' %}',
|
||||||
|
'cache': false,
|
||||||
|
'dataType': 'json',
|
||||||
|
'success': function(data) {
|
||||||
|
btn.addClass('hide');
|
||||||
|
var file_tree = new FileTree();
|
||||||
|
var repos = file_tree.format_repo_data(data);
|
||||||
|
if (repos.length > 0) {
|
||||||
|
file_tree.renderFileTree($('#msg-file-tree').css({'max-height':$(window).height() - $('#title-panel').offset().top - $('#title-panel').height() - $('#send-msg-popup').outerHeight(), 'overflow':'auto'}).data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true});
|
||||||
|
$('#msg-file-tree').fadeIn(600);
|
||||||
|
msg_file_share.find('.icon-remove').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
msg_file_share.html('<p class="error">' + "{% trans "You don't have any library at present" %}" + '</p>');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'error': function(jqXHR, textStatus, errorThrown) {
|
||||||
|
if (!jqXHR.responseText) {
|
||||||
|
msg_file_share.html('<p class="error">' + "{% trans "Failed. Please check the network." %}" + '</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#msg-file-share .icon-remove').click(function() {
|
||||||
|
$(this).addClass('hide');
|
||||||
|
$('#msg-file-tree').fadeOut(200);
|
||||||
|
$('#msg-file-share-btn').removeClass('hide');
|
||||||
|
});
|
||||||
|
$('#send-msg-form .cancel').click(function() {
|
||||||
|
$('#send-msg-popup').addClass('hide');
|
||||||
|
$('#add-msg').removeClass('add-msg-hl');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#send-msg-form').submit(function() {
|
||||||
|
var form_id = $(this).attr('id');
|
||||||
|
if (!$('#mass-msg').val()) {
|
||||||
|
apply_form_error(form_id, "{% trans "message is required" %}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!$('#mass-email').val()) { // val is null or ['xx',...]
|
||||||
|
apply_form_error(form_id, "{% trans "contact is required" %}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -62,7 +62,7 @@
|
|||||||
<a class="author" href="{% url 'user_msg_list' msg.from_email|id_or_email %}">{{ msg.from_email|email2nickname }}</a>
|
<a class="author" href="{% url 'user_msg_list' msg.from_email|id_or_email %}">{{ msg.from_email|email2nickname }}</a>
|
||||||
<span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
|
<span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="msg-con">{{ msg.message|safe|seahub_urlize|find_at|linebreaksbr }}</p>
|
<p class="msg-con">{{ msg.message|seahub_urlize|find_at|linebreaksbr }}</p>
|
||||||
{% if msg.attachments %}
|
{% if msg.attachments %}
|
||||||
<ul class="msg-attachment">
|
<ul class="msg-attachment">
|
||||||
{% for att in msg.attachments %}
|
{% for att in msg.attachments %}
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
<div class="account">
|
<div class="account">
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<a href="{% url 'edit_profile' %}" class="top-link avatar-link" title="{% trans 'Profile Setting' %}">{% avatar request.user 16 %}</a> <span class="my-info">{{ request.user }}</span>
|
<a href="{% url 'edit_profile' %}" class="top-link avatar-link" title="{% trans 'Profile Setting' %}">{% avatar request.user 16 %}</a> <span class="my-info">{{ request.user }}</span>
|
||||||
<button class="icon-envelope btn" id="add-msg" title="{% trans "send a message" %}"></button>
|
<button class="icon-envelope btn" data-url="{% url 'message_list' %}" title="{% trans "messages" %}" id="msg-link"></button>
|
||||||
<button class="btn" data-url="{% url 'user_notification_list' %}" id="msg-count" title="{% trans "unread notices" %}">0</button>
|
<button class="btn" data-url="{% url 'user_notification_list' %}" id="msg-count" title="{% trans "unread notices" %}">0</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ SITE_ROOT }}accounts/login/" class="top-link">{% trans "Log In" %}</a>
|
<a href="{{ SITE_ROOT }}accounts/login/" class="top-link">{% trans "Log In" %}</a>
|
||||||
@@ -61,23 +61,6 @@
|
|||||||
<a href="{{ SITE_ROOT }}accounts/logout/" class="icon-signout top-link" title="{% trans "Log out" %}" id="logout"></a>
|
<a href="{{ SITE_ROOT }}accounts/logout/" class="icon-signout top-link" title="{% trans "Log out" %}" id="logout"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="send-msg-popup" class="hide">
|
|
||||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" class="loading-tip" />
|
|
||||||
<form id="send-msg-form" action="{% url 'message_send' %}" method="post" name="send-msg-form" class="hide">{% csrf_token %}
|
|
||||||
<textarea id="mass-msg" name="mass_msg" placeholder="{% trans "message..." %}"></textarea><br/>
|
|
||||||
<select id="mass-email" name="mass_email" multiple="multiple"></select><br/>
|
|
||||||
<div id="msg-file-share">
|
|
||||||
<button type="button" id="msg-file-share-btn"><span class="icon-plus-sign-alt"></span> {% trans "Add files" %}</button>
|
|
||||||
<div id="msg-file-tree" class="hide"></div>
|
|
||||||
<span class="icon-remove hide"></span>
|
|
||||||
</div>
|
|
||||||
<p class="error hide"></p>
|
|
||||||
<input type="submit" value="{% trans "Submit"%}" />
|
|
||||||
<input type="button" value="{% trans "Cancel"%}" class="cancel" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -291,114 +274,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$('#msg-count, #msg-link').click(function() {
|
||||||
$('#add-msg').click(function() {
|
|
||||||
var add_msg_btn = $('#add-msg'),
|
|
||||||
popup = $('#send-msg-popup');
|
|
||||||
|
|
||||||
if (!popup.hasClass('hide')) {
|
|
||||||
popup.addClass('hide');
|
|
||||||
add_msg_btn.removeClass('add-msg-hl');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
popup.removeClass('hide');
|
|
||||||
add_msg_btn.addClass('add-msg-hl');
|
|
||||||
$.ajax({
|
|
||||||
url:'{% url 'get_contacts' %}',
|
|
||||||
cache: false,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function(data) {
|
|
||||||
var contacts = data['contacts'],
|
|
||||||
opts = '',
|
|
||||||
email;
|
|
||||||
if (contacts.length > 0) {
|
|
||||||
popup.find('.loading-tip').remove();
|
|
||||||
$('#send-msg-form').removeClass('hide');
|
|
||||||
|
|
||||||
for(var i = 0, len = contacts.length; i < len; i++) {
|
|
||||||
email = contacts[i].email;
|
|
||||||
opts += '<option value="' + email + '" data-index="' + i + '">' + email + '</option>';
|
|
||||||
}
|
|
||||||
var format = function(item) {
|
|
||||||
return contacts[$(item.element).data('index')].avatar + '<span class="vam">' + item.text + '</span>';
|
|
||||||
}
|
|
||||||
$('#mass-email').html(opts).select2({
|
|
||||||
placeholder: "{% trans "send to: click to select contacts" %}",
|
|
||||||
formatResult: format,
|
|
||||||
formatSelection: format,
|
|
||||||
escapeMarkup: function(m) { return m; }
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
popup.html('<p>' + "{% trans "please add contacts at first" %}" + '</p>');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
popup.html('<p class="error">' + "{% trans "Failed to get your contacts for sending a message." %}" + '</p>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$(document).click(function(e) {
|
|
||||||
if (e.eventPhase == 2) { // for ff
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var target = e.target || event.srcElement,
|
|
||||||
popup = $('#send-msg-popup'),
|
|
||||||
popup_switch = $('#add-msg');
|
|
||||||
if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target)) {
|
|
||||||
popup.addClass('hide');
|
|
||||||
$('#add-msg').removeClass('add-msg-hl');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#msg-file-share-btn').click(function() {
|
|
||||||
var msg_file_share = $('#msg-file-share'),
|
|
||||||
btn = $(this);
|
|
||||||
$.ajax({
|
|
||||||
'url': '{% url 'get_my_unenc_repos' %}',
|
|
||||||
'cache': false,
|
|
||||||
'dataType': 'json',
|
|
||||||
'success': function(data) {
|
|
||||||
btn.addClass('hide');
|
|
||||||
var file_tree = new FileTree();
|
|
||||||
var repos = file_tree.format_repo_data(data);
|
|
||||||
if (repos.length > 0) {
|
|
||||||
file_tree.renderFileTree($('#msg-file-tree').css({'max-height':$(window).height() - $('#top-bar').height() - $('#send-msg-popup').outerHeight(), 'overflow':'auto'}).data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true});
|
|
||||||
$('#msg-file-tree').fadeIn(600);
|
|
||||||
msg_file_share.find('.icon-remove').removeClass('hide');
|
|
||||||
} else {
|
|
||||||
msg_file_share.html('<p class="error">' + "{% trans "You don't have any library at present" %}" + '</p>');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'error': function(jqXHR, textStatus, errorThrown) {
|
|
||||||
if (!jqXHR.responseText) {
|
|
||||||
msg_file_share.html('<p class="error">' + "{% trans "Failed. Please check the network." %}" + '</p>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('#msg-file-share .icon-remove').click(function() {
|
|
||||||
$(this).addClass('hide');
|
|
||||||
$('#msg-file-tree').fadeOut(200);
|
|
||||||
$('#msg-file-share-btn').removeClass('hide');
|
|
||||||
});
|
|
||||||
$('#send-msg-form .cancel').click(function() {
|
|
||||||
$('#send-msg-popup').addClass('hide');
|
|
||||||
$('#add-msg').removeClass('add-msg-hl');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#send-msg-form').submit(function() {
|
|
||||||
var form_id = $(this).attr('id');
|
|
||||||
if (!$('#mass-msg').val()) {
|
|
||||||
apply_form_error(form_id, "{% trans "message is required" %}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!$('#mass-email').val()) { // val is null or ['xx',...]
|
|
||||||
apply_form_error(form_id, "{% trans "contact is required" %}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#msg-count').click(function() {
|
|
||||||
location.href = $(this).data('url');
|
location.href = $(this).data('url');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user