From 7099f7b5d7ff47bff947bb8f7db35b18f171b4e3 Mon Sep 17 00:00:00 2001 From: llj Date: Tue, 31 Jul 2012 19:44:13 +0800 Subject: [PATCH] improved contact_add --- contacts/templates/contacts/contact_list.html | 47 ++++++++++--------- media/css/seahub.css | 19 +++----- templates/snippets/myhome_extra_script.html | 11 +++-- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/contacts/templates/contacts/contact_list.html b/contacts/templates/contacts/contact_list.html index b3650a9fa4..d706acdfa2 100644 --- a/contacts/templates/contacts/contact_list.html +++ b/contacts/templates/contacts/contact_list.html @@ -1,25 +1,10 @@ {% extends "myhome_base.html" %} {% block nav_contacts_class %}class="cur"{% endblock %} -{% block left_panel %} -

操作

- -
-

添加联系人

- {{ form.user_email.as_hidden }} - {{ form.contact_email }}
- {{ form.contact_name }}
- {{ form.note }}
-

请输入邮箱地址。

- -
-{% endblock %} {% block right_panel %} -

联系人列表

+ @@ -39,6 +24,16 @@ {% endfor %}
邮箱
+
+

添加联系人

+ {{ form.user_email.as_hidden }} +
+ {{ form.contact_email }}
+
{{ form.contact_name }}
+
{{ form.note }}
+

请输入邮箱地址。

+ +
{% endblock %} {% block extra_script %} @@ -58,10 +53,18 @@ $("table tr:gt(0)").hover( } ); -$('#contact-add').click(function() { +$('#contact-add') +.click(function() { $('#contact-add-form').modal({appendTo: '#main'}); - return false; -}); +}) +.hover( + function() { + $(this).css({'background-color': '#fff', 'cursor': 'pointer'}); + }, + function() { + $(this).css('background-color', '#f5f5f5'); + } +); $('#contact-add-form').submit(function() { if(!$.trim($('input[name="contact_email"]').val())) { $('#contact-add-error').removeClass('hide') @@ -69,10 +72,8 @@ $('#contact-add-form').submit(function() { return false; } - var self = $(this), - url = self.attr("action"); $.ajax({ - url: url, + url: $('#contact-add-form').attr('action'), type: 'POST', dataType: 'json', cache: 'false', @@ -83,7 +84,7 @@ $('#contact-add-form').submit(function() { 'contact_email': $('#contact-add-form input[name="contact_email"]').val(), 'contact_name': $('#contact-add-form input[name="contact_name"]').val(), 'note': $('#contact-add-form input[name="note"]').val() - }, + }, success: function(data) { if (data['success']) { location.reload(true); diff --git a/media/css/seahub.css b/media/css/seahub.css index 8e012d645e..2adcfad8df 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -404,7 +404,8 @@ p { color: #000; font-weight: normal; } -#repo-create { +#repo-create, +#contact-add{ padding-left:21px; height:27px; background:#f5f5f5 url('../img/add.png') scroll no-repeat 3px 48%; @@ -414,7 +415,10 @@ p { } #repo-name, #repo-desc, -.repo-create-encryption .passwd { +.repo-create-encryption .passwd, +#id_contact_email, +#id_contact_name, +#id_note { width:260px; margin-bottom:5px; } @@ -562,17 +566,6 @@ p { .contact-list-link:hover { text-decoration:none; } -#contact-add-form h4 { - border-bottom:1px solid #ddd; - margin-bottom:12px; -} -#contact-add-form label { - width:6em; -} -#contact-add-form .error, -#contact-add-form .submit { - margin-left:6em; -} /* group, org */ .group-list { margin-top:20px; diff --git a/templates/snippets/myhome_extra_script.html b/templates/snippets/myhome_extra_script.html index 03f6324d74..ea02f736d1 100644 --- a/templates/snippets/myhome_extra_script.html +++ b/templates/snippets/myhome_extra_script.html @@ -43,7 +43,11 @@ $(function() { }); //repo-create-form -$('#repo-create').hover( +$('#repo-create') +.click(function() { + $('#repo-create-form').modal({appendTo: '#main', autoResize: true}); +}) +.hover( function() { $(this).css({'background-color': '#fff', 'cursor': 'pointer'}); }, @@ -51,9 +55,6 @@ $('#repo-create').hover( $(this).css('background-color', '#f5f5f5'); } ); -$('#repo-create').click(function() { - $('#repo-create-form').modal({appendTo: '#main', autoResize: true}); -}); $('#encrypt-switch').click(function () { if ($(this).attr('checked')) { $('#repo-create-form input[type="password"]').attr('disabled', false).removeClass('input-disabled'); @@ -125,4 +126,4 @@ $('#repo-create-submit').click(function() { }); return false; -}); \ No newline at end of file +});