Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
1955c611
Commit
1955c611
authored
Oct 12, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into private-jquery
parents
d6110a1e
60367f82
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
438 additions
and
327 deletions
+438
-327
converse.js
converse.js
+51
-27
docs/CHANGES.rst
docs/CHANGES.rst
+1
-0
docs/source/index.rst
docs/source/index.rst
+338
-283
index.html
index.html
+8
-10
spec/converse.js
spec/converse.js
+37
-4
src/templates/add_contact_form.html
src/templates/add_contact_form.html
+1
-1
src/templates/login_panel.html
src/templates/login_panel.html
+1
-1
src/templates/search_contact.html
src/templates/search_contact.html
+1
-1
No files found.
converse.js
View file @
1955c611
...
...
@@ -11,7 +11,7 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
define
(
"
converse
"
,
[
"
converse-dependencies
"
,
"
converse-templates
"
],
function
(
dependencies
,
templates
)
{
function
(
dependencies
,
templates
)
{
var
otr
=
dependencies
.
otr
,
moment
=
dependencies
.
moment
;
if
(
typeof
otr
!==
"
undefined
"
)
{
...
...
@@ -42,9 +42,9 @@
};
// TODO: these non-backbone methods should all be moved to utils.
$
.
fn
.
addHyperlinks
=
function
()
{
$
.
fn
.
addHyperlinks
=
function
()
{
if
(
this
.
length
>
0
)
{
this
.
each
(
function
(
i
,
obj
)
{
this
.
each
(
function
(
i
,
obj
)
{
var
x
=
$
(
obj
).
html
();
var
list
=
x
.
match
(
/
\b(
https
?
:
\/\/
|www
\.
|https
?
:
\/\/
www
\.)[^\s
<
]{2,200}\b
/g
);
if
(
list
)
{
...
...
@@ -99,10 +99,10 @@
}
};
$
.
fn
.
addEmoticons
=
function
()
{
$
.
fn
.
addEmoticons
=
function
()
{
if
(
converse
.
visible_toolbar_buttons
.
emoticons
)
{
if
(
this
.
length
>
0
)
{
this
.
each
(
function
(
i
,
obj
)
{
this
.
each
(
function
(
i
,
obj
)
{
var
text
=
$
(
obj
).
html
();
text
=
text
.
replace
(
/>:
\)
/g
,
'
<span class="emoticon icon-evil"></span>
'
);
text
=
text
.
replace
(
/:
\)
/g
,
'
<span class="emoticon icon-smiley"></span>
'
);
...
...
@@ -136,16 +136,16 @@
var
converse
=
{
templates
:
templates
,
emit
:
function
(
evt
,
data
)
{
emit
:
function
(
evt
,
data
)
{
$
(
this
).
trigger
(
evt
,
data
);
},
once
:
function
(
evt
,
handler
)
{
once
:
function
(
evt
,
handler
)
{
$
(
this
).
one
(
evt
,
handler
);
},
on
:
function
(
evt
,
handler
)
{
on
:
function
(
evt
,
handler
)
{
$
(
this
).
bind
(
evt
,
handler
);
},
off
:
function
(
evt
,
handler
)
{
off
:
function
(
evt
,
handler
)
{
$
(
this
).
unbind
(
evt
,
handler
);
},
refreshWebkit
:
function
()
{
...
...
@@ -588,7 +588,7 @@
};
this
.
registerGlobalEventHandlers
=
function
()
{
$
(
document
).
click
(
function
()
{
$
(
document
).
click
(
function
()
{
if
(
$
(
'
.toggle-otr ul
'
).
is
(
'
:visible
'
))
{
$
(
'
.toggle-otr ul
'
,
this
).
slideUp
();
}
...
...
@@ -653,7 +653,7 @@
})
.
c
(
'
enable
'
,
{
xmlns
:
'
urn:xmpp:carbons:2
'
});
this
.
connection
.
send
(
carbons_iq
);
this
.
connection
.
addHandler
(
function
(
iq
)
{
this
.
connection
.
addHandler
(
function
(
iq
)
{
//TODO: check if carbons was enabled:
},
null
,
"
iq
"
,
null
,
"
enablecarbons
"
);
};
...
...
@@ -1550,7 +1550,7 @@
}
var
ctx
=
canvas
.
getContext
(
'
2d
'
);
var
img
=
new
Image
();
// Create new Image object
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
var
ratio
=
img
.
width
/
img
.
height
;
ctx
.
drawImage
(
img
,
0
,
0
,
35
*
ratio
,
35
);
};
...
...
@@ -2911,7 +2911,7 @@
},
this
);
},
_ensureElement
:
function
()
{
_ensureElement
:
function
()
{
/* Override method from backbone.js
* If the #conversejs element doesn't exist, create it.
*/
...
...
@@ -3019,19 +3019,18 @@
* If it doesn't exist, create it.
*/
var
chatbox
=
this
.
model
.
get
(
attrs
.
jid
);
if
(
chatbox
)
{
if
(
chatbox
.
get
(
'
minimized
'
))
{
chatbox
.
maximize
();
}
else
{
chatbox
.
trigger
(
'
show
'
);
}
}
else
{
if
(
!
chatbox
)
{
chatbox
=
this
.
model
.
create
(
attrs
,
{
'
error
'
:
function
(
model
,
response
)
{
converse
.
log
(
response
.
responseText
);
}
});
}
if
(
chatbox
.
get
(
'
minimized
'
))
{
chatbox
.
maximize
();
}
else
{
chatbox
.
trigger
(
'
show
'
);
}
return
chatbox
;
}
});
...
...
@@ -3258,6 +3257,8 @@
openChat
:
function
(
ev
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
// XXX: Can this.model.attributes be used here, instead of
// manually specifying all attributes?
return
converse
.
chatboxviews
.
showChat
({
'
id
'
:
this
.
model
.
get
(
'
jid
'
),
'
jid
'
:
this
.
model
.
get
(
'
jid
'
),
...
...
@@ -4236,7 +4237,7 @@
'
desc_change_status
'
:
__
(
'
Click to change your chat status
'
)
}));
// iterate through all the <option> elements and add option values
options
.
each
(
function
(){
options
.
each
(
function
(){
options_list
.
push
(
converse
.
templates
.
status_option
({
'
value
'
:
$
(
this
).
val
(),
'
text
'
:
this
.
text
...
...
@@ -4626,16 +4627,30 @@
this
.
registerGlobalEventHandlers
();
converse
.
emit
(
'
initialized
'
);
};
var
wrappedChatBox
=
function
(
chatbox
)
{
return
{
'
endOTR
'
:
$
.
proxy
(
chatbox
.
endOTR
,
chatbox
),
'
get
'
:
$
.
proxy
(
chatbox
.
get
,
chatbox
),
'
initiateOTR
'
:
$
.
proxy
(
chatbox
.
initiateOTR
,
chatbox
),
'
maximize
'
:
$
.
proxy
(
chatbox
.
maximize
,
chatbox
),
'
minimize
'
:
$
.
proxy
(
chatbox
.
minimize
,
chatbox
),
'
set
'
:
$
.
proxy
(
chatbox
.
set
,
chatbox
)
};
};
return
{
'
initialize
'
:
function
(
settings
,
callback
)
{
converse
.
initialize
(
settings
,
callback
);
},
'
getBuddy
'
:
function
(
jid
)
{
var
contact
=
converse
.
roster
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
if
(
contact
)
{
return
contact
.
attributes
;
}
},
'
getChatBox
'
:
function
(
jid
)
{
var
chatbox
=
converse
.
chatboxes
.
get
(
jid
);
if
(
chatbox
)
{
return
wrappedChatBox
(
chatbox
);
}
},
'
getRID
'
:
function
()
{
if
(
converse
.
expose_rid_and_sid
&&
typeof
converse
.
connection
!==
"
undefined
"
)
{
return
converse
.
connection
.
rid
||
converse
.
connection
.
_proto
.
rid
;
...
...
@@ -4648,13 +4663,22 @@
}
return
null
;
},
'
once
'
:
function
(
evt
,
handler
)
{
'
initialize
'
:
function
(
settings
,
callback
)
{
converse
.
initialize
(
settings
,
callback
);
},
'
openChatBox
'
:
function
(
jid
)
{
var
contact
=
converse
.
roster
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
if
(
contact
)
{
return
wrappedChatBox
(
converse
.
chatboxviews
.
showChat
(
contact
.
attributes
));
}
},
'
once
'
:
function
(
evt
,
handler
)
{
converse
.
once
(
evt
,
handler
);
},
'
on
'
:
function
(
evt
,
handler
)
{
'
on
'
:
function
(
evt
,
handler
)
{
converse
.
on
(
evt
,
handler
);
},
'
off
'
:
function
(
evt
,
handler
)
{
'
off
'
:
function
(
evt
,
handler
)
{
converse
.
off
(
evt
,
handler
);
},
'
jQuery
'
:
$
...
...
docs/CHANGES.rst
View file @
1955c611
...
...
@@ -8,6 +8,7 @@ Changelog
* Bugfix. Cannot read property "top" of undefined. [jcbrand]
* Add new event, noResumeableSession, for when keepalive=true and there aren't
any prebind session tokens. [jcbrand]
* Add 2 new API methods, getChatBox and openChatBox. [jcbrand]
0.8.3 (2014-09-22)
------------------
...
...
docs/source/index.rst
View file @
1955c611
This diff is collapsed.
Click to expand it.
index.html
View file @
1955c611
...
...
@@ -207,16 +207,14 @@
<div
class=
"row"
>
<div
class=
"col-lg-8 col-lg-offset-2"
>
<h2>
Contact
</h2>
<p>
<ul
class=
"contact"
>
<li>
Follow me on
<a
href=
"http://twitter.com/jcopkode"
target=
"_blank"
>
Twitter
</a>
.
</li>
<li>
Chat with me via XMPP:
<a
href=
"xmpp:jc@opkode.com"
class=
"xmpp JSnocheck"
title=
"XMPP/Jabber"
>
jc@opkode.com
</a>
.
</li>
<li>
For technical support, please write to the mailing list:
<a
href=
"mailto:conversejs@librelist.com"
>
conversejs@librelist.com
</a>
.
</li>
<li>
Also check out the
<a
href=
"http://librelist.com/browser/conversejs"
target=
"_blank"
>
mailing list archives
</a>
.
</li>
<li>
Please file
<a
target=
"_blank"
href=
"https://github.com/jcbrand/converse.js/issues"
>
bugs on Github
</a>
.
</li>
<li>
I'm available for features and
<a
href=
"http://opkode.com/contact"
target=
"_blank"
>
consulting
</a>
.
</li>
<ul>
</p>
<ul
class=
"contact"
>
<li>
Follow me on
<a
href=
"http://twitter.com/jcopkode"
target=
"_blank"
>
Twitter
</a>
.
</li>
<li>
Chat with me via XMPP:
<a
href=
"xmpp:jc@opkode.com"
class=
"xmpp JSnocheck"
title=
"XMPP/Jabber"
>
jc@opkode.com
</a>
.
</li>
<li>
For technical support, please write to the mailing list:
<a
href=
"mailto:conversejs@librelist.com"
>
conversejs@librelist.com
</a>
.
</li>
<li>
Also check out the
<a
href=
"http://librelist.com/browser/conversejs"
target=
"_blank"
>
mailing list archives
</a>
.
</li>
<li>
Please file
<a
target=
"_blank"
href=
"https://github.com/jcbrand/converse.js/issues"
>
bugs on Github
</a>
.
</li>
<li>
I'm available for features and
<a
href=
"http://opkode.com/contact"
target=
"_blank"
>
consulting
</a>
.
</li>
</ul>
</div>
</div>
</div>
...
...
spec/converse.js
View file @
1955c611
...
...
@@ -10,8 +10,10 @@
return
describe
(
"
Converse
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
beforeEach
(
$
.
proxy
(
function
()
{
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
test_utils
.
closeAllChatBoxes
();
test_utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
test_utils
.
createContacts
(
'
current
'
);
},
converse
));
it
(
"
has an API method for retrieving the next RID
"
,
$
.
proxy
(
function
()
{
...
...
@@ -46,12 +48,43 @@
it
(
"
has an API method for retrieving a buddy's attributes
"
,
$
.
proxy
(
function
()
{
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
expect
(
converse_api
.
getBuddy
(
jid
)).
toBeFalsy
();
test_utils
.
createContacts
(
'
current
'
);
expect
(
converse_api
.
getBuddy
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
var
attrs
=
converse_api
.
getBuddy
(
jid
);
expect
(
typeof
attrs
).
toBe
(
'
object
'
);
expect
(
attrs
.
fullname
).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
attrs
.
jid
).
toBe
(
jid
);
},
converse
));
it
(
"
has an API method, openChatBox, for opening a chat box for a buddy
"
,
$
.
proxy
(
function
()
{
expect
(
converse_api
.
openChatBox
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
// test on user that doesn't exist.
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
box
=
converse_api
.
openChatBox
(
jid
);
expect
(
box
instanceof
Object
).
toBeTruthy
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
var
chatboxview
=
this
.
chatboxviews
.
get
(
jid
);
expect
(
chatboxview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
},
converse
));
it
(
"
will focus an already open chat box, if the openChatBox API method is called for it.
"
,
$
.
proxy
(
function
()
{
// Calling openChatBox on an already open chat will focus it.
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
chatboxview
=
this
.
chatboxviews
.
get
(
jid
);
spyOn
(
chatboxview
,
'
focus
'
);
test_utils
.
openChatBoxFor
(
jid
);
box
=
converse_api
.
openChatBox
(
jid
);
expect
(
chatboxview
.
focus
).
toHaveBeenCalled
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
},
converse
));
it
(
"
has an API method, getChatBox, for retrieving chat box
"
,
$
.
proxy
(
function
()
{
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
expect
(
converse_api
.
getChatBox
(
jid
)).
toBeFalsy
();
test_utils
.
openChatBoxFor
(
jid
);
var
box
=
converse_api
.
getChatBox
(
jid
);
expect
(
box
instanceof
Object
).
toBeTruthy
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
},
converse
));
},
converse
,
mock
,
test_utils
));
}));
src/templates/add_contact_form.html
View file @
1955c611
...
...
@@ -6,4 +6,4 @@
placeholder=
"{{label_contact_username}}"
/>
<button
type=
"submit"
>
{{label_add}}
</button>
</form>
<li>
<
/
li>
src/templates/login_panel.html
View file @
1955c611
...
...
@@ -5,4 +5,4 @@
<input
type=
"password"
name=
"password"
placeholder=
"Password"
>
<input
class=
"login-submit"
type=
"submit"
value=
"{{label_login}}"
>
<span
class=
"conn-feedback"
></span>
</form
"
>
</form>
src/templates/search_contact.html
View file @
1955c611
...
...
@@ -6,4 +6,4 @@
placeholder=
"{{label_contact_name}}"
/>
<button
type=
"submit"
>
{{label_search}}
</button>
</form>
<li>
<
/
li>
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