Skip to content
Snippets Groups Projects
Commit ac63afbd authored by Thomas Tanghus's avatar Thomas Tanghus
Browse files

Insert new contacts alphabetically correct in the list.

Added some tipsys to the editor.
parent 978a08ab
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;} #contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}
#contacts_details_photo { margin:.5em 0em .5em 25%; } #contacts_details_photo { margin:.5em 0em .5em 25%; }
#contacts_deletecard {position:absolute;top:15px;right:0;} #contacts_deletecard {position:absolute;top:15px;right:15px;}
#contacts_details_list { list-style:none; } #contacts_details_list { list-style:none; }
#contacts_details_list li { overflow:visible; } #contacts_details_list li { overflow:visible; }
#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; } #contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; }
......
...@@ -237,6 +237,9 @@ $(document).ready(function(){ ...@@ -237,6 +237,9 @@ $(document).ready(function(){
return false; return false;
}); });
/**
* Open blank form to add new contact.
*/
$('#contacts_newcontact').click(function(){ $('#contacts_newcontact').click(function(){
$.getJSON('ajax/showaddcard.php',{},function(jsondata){ $.getJSON('ajax/showaddcard.php',{},function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
...@@ -251,13 +254,27 @@ $(document).ready(function(){ ...@@ -251,13 +254,27 @@ $(document).ready(function(){
return false; return false;
}); });
/**
* Add and insert a new contact into the list.
*/
$('#contacts_addcardform input[type="submit"]').live('click',function(){ $('#contacts_addcardform input[type="submit"]').live('click',function(){
$.post('ajax/addcard.php',$('#contacts_addcardform').serialize(),function(jsondata){ $.post('ajax/addcard.php',$('#contacts_addcardform').serialize(),function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
$('#rightcontent').data('id',jsondata.data.id); $('#rightcontent').data('id',jsondata.data.id);
$('#rightcontent').html(jsondata.data.page); $('#rightcontent').html(jsondata.data.page);
$('#leftcontent .active').removeClass('active'); $('#leftcontent .active').removeClass('active');
$('#leftcontent ul').append('<li data-id="'+jsondata.data.id+'" class="active"><a href="index.php?id='+jsondata.data.id+'">'+jsondata.data.name+'</a></li>'); var item = '<li data-id="'+jsondata.data.id+'" class="active"><a href="index.php?id='+jsondata.data.id+'" style="background: url(thumbnail.php?id='+jsondata.data.id+') no-repeat scroll 0% 0% transparent;">'+jsondata.data.name+'</a></li>';
var added = false;
$('#leftcontent ul li').each(function(){
if ($(this).text().toLowerCase() > jsondata.data.name.toLowerCase()) {
$(this).before(item).fadeIn('fast');
added = true;
return false;
}
});
if(!added) {
$('#leftcontent ul').append(item);
}
} }
else{ else{
alert(jsondata.data.message); alert(jsondata.data.message);
...@@ -265,7 +282,6 @@ $(document).ready(function(){ ...@@ -265,7 +282,6 @@ $(document).ready(function(){
}, 'json'); }, 'json');
return false; return false;
}); });
$('.contacts_property [data-use="edit"]').live('click',function(){ $('.contacts_property [data-use="edit"]').live('click',function(){
var id = $('#rightcontent').data('id'); var id = $('#rightcontent').data('id');
var checksum = $(this).parents('.contacts_property').first().data('checksum'); var checksum = $(this).parents('.contacts_property').first().data('checksum');
...@@ -338,4 +354,7 @@ $(document).ready(function(){ ...@@ -338,4 +354,7 @@ $(document).ready(function(){
// element has gone out of viewport // element has gone out of viewport
} }
}); });
$('.action').tipsy();
$('.button').tipsy();
}); });
...@@ -86,3 +86,8 @@ ...@@ -86,3 +86,8 @@
</li> </li>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
<script language="Javascript">
/* Re-tipsify ;-)*/
$('.action').tipsy();
$('.button').tipsy();
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment