Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
1801b876
Commit
1801b876
authored
Aug 18, 2014
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revised contactlist gadget
parent
ecceec8e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
83 deletions
+88
-83
Gruntfile.js
Gruntfile.js
+0
-2
src/jabberclient/jabberclient.js
src/jabberclient/jabberclient.js
+3
-20
src/jabberclient_chatbox/jabberclient_chatbox.js
src/jabberclient_chatbox/jabberclient_chatbox.js
+11
-1
src/jabberclient_contactlist/index.html
src/jabberclient_contactlist/index.html
+16
-11
src/jabberclient_contactlist/jabberclient_contactlist.css
src/jabberclient_contactlist/jabberclient_contactlist.css
+0
-17
src/jabberclient_contactlist/jabberclient_contactlist.js
src/jabberclient_contactlist/jabberclient_contactlist.js
+58
-32
No files found.
Gruntfile.js
View file @
1801b876
...
...
@@ -110,8 +110,6 @@ module.exports = function (grunt) {
"
<%= global_config.src %>/jabberclient/jabberclient.css
"
,
"
<%= global_config.dest %>/jabberclient_connection/jabberclient_connection.css
"
:
"
<%= global_config.src %>/jabberclient_connection/jabberclient_connection.css
"
,
"
<%= global_config.dest %>/jabberclient_contactlist/jabberclient_contactlist.css
"
:
"
<%= global_config.src %>/jabberclient_contactlist/jabberclient_contactlist.css
"
,
"
<%= global_config.dest %>/jabberclient_chatbox/jabberclient_chatbox.css
"
:
"
<%= global_config.src %>/jabberclient_chatbox/jabberclient_chatbox.css
"
}
...
...
src/jabberclient/jabberclient.js
View file @
1801b876
...
...
@@ -108,32 +108,15 @@
.
push
(
this
.
pleaseRedirectMyHash
.
bind
(
this
));
})
.
declareMethod
(
'
getConnectionJID
'
,
function
()
{
.
allowPublicAcquisition
(
'
getConnectionJID
'
,
function
()
{
return
this
.
getDeclaredGadget
(
'
connection
'
)
.
push
(
function
(
connection_gadget
)
{
return
connection_gadget
.
getConnectionJID
();
});
})
.
allowPublicAcquisition
(
'
getConnectionJID
'
,
function
()
{
return
this
.
getConnectionJid
();
})
.
allowPublicAcquisition
(
'
getJID
'
,
function
()
{
return
this
.
login_gadget
.
getJID
();
})
.
allowPublicAcquisition
(
'
openChat
'
,
function
(
jid
)
{
var
gadget
=
this
;
return
gadget
.
getConnectionJID
()
.
push
(
function
(
connection_jid
)
{
return
gadget
.
aq_pleasePublishMyState
({
page
:
'
chatbox
'
,
current_contact_jid
:
jid
[
0
],
jid
:
connection_jid
});
})
.
push
(
this
.
pleaseRedirectMyHash
.
bind
(
this
));
.
allowPublicAcquisition
(
'
getHash
'
,
function
(
options
)
{
return
this
.
aq_pleasePublishMyState
(
options
[
0
]);
})
.
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
)
...
...
src/jabberclient_chatbox/jabberclient_chatbox.js
View file @
1801b876
...
...
@@ -75,12 +75,22 @@
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
;
var
gadget
=
this
,
messages
;
this
.
props
.
jid
=
options
.
jid
;
this
.
props
.
current_contact_jid
=
options
.
current_contact_jid
;
$
(
'
[data-role="page"]
'
).
height
(
"
100%
"
);
$
(
'
.gadget-container
'
).
height
(
"
93%
"
);
$
(
gadget
.
__element
).
find
(
"
.talk-box
"
).
html
(
""
);
if
(
this
.
props
.
talks
[
this
.
props
.
current_contact_jid
])
{
messages
=
this
.
props
.
talks
[
this
.
props
.
current_contact_jid
].
messages
;
messages
.
forEach
(
function
(
message
)
{
displayMessage
(
message
);
});
}
$
(
this
.
__element
).
find
(
"
.send-button
"
).
click
(
function
(
e
)
{
e
.
preventDefault
();
sendInput
(
gadget
);
...
...
src/jabberclient_contactlist/index.html
View file @
1801b876
...
...
@@ -5,7 +5,6 @@
<title>
Jabber client
</title>
<link
rel=
"stylesheet"
href=
"../<%= curl.jquerymobilecss.relative_dest %>"
>
<link
rel=
"stylesheet"
href=
"jabberclient_contactlist.css"
>
<script
src=
"../<%= curl.jquery.relative_dest %>"
></script>
<script
src=
"../<%= curl.jquerymobilejs.relative_dest %>"
></script>
...
...
@@ -18,23 +17,29 @@
<script
class=
"offline-contact-template"
type=
"text/x-handlebars-template"
>
<
li
>
<
img
src
=
"
../jabberclient_contactlist/images/offline.png
"
>
<
h2
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
<
/h2
>
<
img
src
=
"
../jabberclient_contactlist/images/offline.png
"
alt
=
"
offline
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
<
/li
>
</script>
<script
class=
"online-contact-template"
type=
"text/x-handlebars-template"
>
<
li
>
<
img
src
=
"
../jabberclient_contactlist/images/online.png
"
>
<
h2
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
<
/h2
>
<
/li
>
<
li
><
a
href
=
"
{{hash}}
"
>
<
img
src
=
"
../jabberclient_contactlist/images/online.png
"
alt
=
"
online
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
<
/a></
li
>
</script>
<script
class=
"status-contact-template"
type=
"text/x-handlebars-template"
>
<
li
>
<
img
src
=
"
../jabberclient_contactlist/images/status.png
"
>
<
h2
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
&
nbsp
&
nbsp
({{
status
}})
<
/h2
>
<
/li
>
<
li
><
a
href
=
"
{{hash}}
"
>
<
img
src
=
"
../jabberclient_contactlist/images/status.png
"
alt
=
"
{{status}}
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
&
nbsp
&
nbsp
({{
status
}})
<
/a></
li
>
</script>
</head>
...
...
src/jabberclient_contactlist/jabberclient_contactlist.css
deleted
100644 → 0
View file @
ecceec8e
#contact-list
img
{
float
:
left
;
margin-right
:
5px
;
}
#contact-list
li
{
min-height
:
0.625em
;
padding-left
:
3.25em
;
}
#contact-list
li
>
*
{
cursor
:
pointer
;
}
#contact-list
h2
{
margin
:
-0.6em
0
;
margin-top
:
-0.3em
;
}
\ No newline at end of file
src/jabberclient_contactlist/jabberclient_contactlist.js
View file @
1801b876
/*global window, rJS, Strophe, $, DOMParser,
/*global window, rJS, Strophe, $, DOMParser,
RSVP,
XMLSerializer, Handlebars, $iq, $pres*/
/*jslint nomen: true*/
...
...
@@ -25,7 +25,6 @@
function
updateContactElement
(
gadget
,
contact
)
{
var
template
,
options
=
{};
if
(
contact
.
el
)
{
contact
.
el
.
remove
();
}
if
(
contact
.
offline
)
{
template
=
offline_contact_template
;
...
...
@@ -37,10 +36,18 @@
}
options
.
jid
=
contact
.
jid
;
options
.
name
=
contact
.
name
;
contact
.
el
=
$
(
template
(
options
));
contact
.
el
.
click
(
function
()
{
gadget
.
openChat
(
contact
.
jid
);
});
return
gadget
.
getConnectionJID
()
.
push
(
function
(
connection_jid
)
{
return
gadget
.
getHash
({
page
:
"
chatbox
"
,
current_contact_jid
:
contact
.
jid
,
jid
:
connection_jid
});
})
.
push
(
function
(
hash
)
{
options
.
hash
=
hash
;
contact
.
el
=
$
(
template
(
options
));
});
}
function
updateContact
(
gadget
,
contact
,
presence
)
{
...
...
@@ -54,37 +61,49 @@
contact
.
status
=
show
.
text
();
}
}
updateContactElement
(
gadget
,
contact
);
return
updateContactElement
(
gadget
,
contact
);
}
function
Contact
(
gadget
,
jid
,
options
)
{
this
.
jid
=
jid
;
this
.
offline
=
true
;
this
.
status
=
null
;
function
createContact
(
gadget
,
jid
,
options
)
{
gadget
.
contactList
.
list
[
jid
]
=
{};
gadget
.
contactList
.
list
[
jid
].
jid
=
jid
;
gadget
.
contactList
.
list
[
jid
].
offline
=
true
;
gadget
.
contactList
.
list
[
jid
].
status
=
null
;
if
(
typeof
options
===
'
object
'
)
{
$
.
extend
(
this
,
options
);
$
.
extend
(
gadget
.
contactList
.
list
[
jid
]
,
options
);
}
updateContactElement
(
gadget
,
this
);
return
updateContactElement
(
gadget
,
gadget
.
contactList
.
list
[
jid
]
);
}
function
ContactList
(
gadget
,
rosterIq
)
{
var
that
=
this
,
contactItems
=
rosterIq
.
childNodes
[
0
].
childNodes
,
jid
,
options
;
queue
=
new
RSVP
.
Queue
();
this
.
list
=
{};
this
.
el
=
$
(
'
#contact-list ul
'
);
//that.el.listview();
this
.
el
.
hide
();
[].
forEach
.
call
(
contactItems
,
function
(
item
)
{
jid
=
$
(
item
).
attr
(
'
jid
'
);
options
=
{};
[].
forEach
.
call
(
item
.
attributes
,
function
(
attr
)
{
options
[
attr
.
name
]
=
attr
.
value
;
});
that
.
list
[
jid
]
=
new
Contact
(
gadget
,
jid
,
options
);
that
.
el
.
append
(
that
.
list
[
jid
].
el
);
queue
.
push
(
function
()
{
var
options
=
{},
jid
=
$
(
item
).
attr
(
'
jid
'
);
[].
forEach
.
call
(
item
.
attributes
,
function
(
attr
)
{
options
[
attr
.
name
]
=
attr
.
value
;
});
return
createContact
(
gadget
,
jid
,
options
);
})
.
push
(
function
()
{
var
jid
=
$
(
item
).
attr
(
'
jid
'
);
that
.
el
.
append
(
that
.
list
[
jid
].
el
);
});
});
this
.
el
.
listview
();
gadget
.
send
(
$pres
().
toString
());
queue
.
push
(
function
()
{
that
.
el
.
listview
();
that
.
el
.
show
();
gadget
.
send
(
$pres
().
toString
());
});
}
function
updateContactList
(
gadget
,
presence
)
{
...
...
@@ -92,19 +111,26 @@
contact
=
gadget
.
contactList
.
list
[
jid
];
if
(
contact
)
{
updateContact
(
gadget
,
contact
,
presence
);
if
(
contact
.
offline
)
{
gadget
.
contactList
.
el
.
append
(
contact
.
el
);
}
else
{
gadget
.
contactList
.
el
.
prepend
(
contact
.
el
);
}
gadget
.
contactList
.
el
.
listview
(
'
refresh
'
);
return
updateContact
(
gadget
,
contact
,
presence
)
.
push
(
function
()
{
if
(
contact
.
offline
)
{
gadget
.
contactList
.
el
.
append
(
contact
.
el
);
}
else
{
gadget
.
contactList
.
el
.
prepend
(
contact
.
el
);
}
gadget
.
contactList
.
el
.
listview
(
'
refresh
'
);
});
}
}
gadget
.
declareAcquiredMethod
(
'
getHash
'
,
'
getHash
'
)
.
declareAcquiredMethod
(
"
getConnectionJID
"
,
"
getConnectionJID
"
)
.
declareAcquiredMethod
(
'
send
'
,
'
send
'
)
.
declareAcquiredMethod
(
'
openChat
'
,
'
openChat
'
)
.
declareMethod
(
'
receiveRoster
'
,
function
(
roster
)
{
...
...
@@ -112,7 +138,7 @@
})
.
declareMethod
(
'
receivePresence
'
,
function
(
presence
)
{
updateContactList
(
this
,
parseXML
(
presence
));
return
updateContactList
(
this
,
parseXML
(
presence
));
});
}(
$
,
Strophe
,
rJS
(
window
)));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment