- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcontacts.js
More file actions
Latest commit
71 lines (53 loc) · 1.74 KB
/
Copy pathcontacts.js
File metadata and controls
71 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* pages.contacts
*
* handles contact list page actions
*/
(function(global){
varcontacts_page={el : $('#page-main')};
contacts_page.initContactList=function(el){
varli,
contacts=global.store.getContacts();
el.html("");
for(vari=0;i<contacts.length;++i){
li=contacts_page.createContactListItem(contacts[i]);
el.append(li);
}
};
contacts_page.viewContact=function(){
varel=$(this),
contact=el.data('contact'),
viewer=$('#page-view');
viewer.find('span#view-name').text(contact.name);
viewer.find('span#view-phone').text(contact.phone);
viewer.find('span#view-email').text(contact.email);
$.mobile.changePage(viewer);
};
contacts_page.createContactListItem=function(contact){
varli,a;
li=$(document.createElement('li'));
a=$(document.createElement('a'));
a.attr('href','#');
a.text(contact.name);
a.data('contact',contact);
a.click(contacts_page.viewContact);
li.append(a);
returnli;
};
contacts_page.refresh=function(){
varlist_el=contacts_page.el.find('#all-contacts');
contacts_page.initContactList(list_el);
list_el.listview('refresh');
console.log('refresh');
};
$('#page-main').live('pagecreate',function(){
contacts_page.el=$(this);
varlist_el=contacts_page.el.find('#all-contacts');
contacts_page.initContactList(list_el);
list_el.listview();
});
if(typeofglobal.pages==='undefined'){
global.pages={};
}
global.pages.contacts=contacts_page;
}(this));