Commit c7abf543 authored by JC Brand's avatar JC Brand

Merge branch 'private-jquery' of github.com:jcbrand/converse.js into private-jquery

parents bfc747b4 5b17becf
......@@ -17,9 +17,7 @@
"backbone.overview": "*",
"strophe": "~1.1.3",
"strophe.roster": "https://raw.github.com/strophe/strophejs-plugins/b1f364eb6e854ffe844c57add38e885cfeb9b498/roster/strophe.roster.js",
"strophe.vcard": "https://raw.github.com/strophe/strophejs-plugins/f5c9e16b463610d501591452cded0359f53aae48/vcard/strophe.vcard.js",
"strophe.disco": "https://raw.github.com/jcbrand/strophejs-plugins/75c8693992bc357c699b6d615eeb396e799f5c02/disco/strophe.disco.js",
"strophe.muc": "https://raw.githubusercontent.com/strophe/strophejs-plugins/8056cbca4dcd69700c44e1e3341a9ce387a6af0c/muc/strophe.muc.js",
"strophe.muc": "https://raw.githubusercontent.com/strophe/strophejs-plugins/master/muc/strophe.muc.js",
"otr": "0.2.12",
"crypto-js-evanvosberg": "~3.1.2",
"almond": "~0.2.9",
......@@ -32,6 +30,7 @@
"bootstrapJS": "https://raw.githubusercontent.com/jcbrand/bootstrap/7d96a5f60d26c67b5348b270a775518b96a702c8/dist/js/bootstrap.js",
"fontawesome": "~4.1.0",
"typeahead.js": "https://raw.githubusercontent.com/jcbrand/typeahead.js/eedfb10505dd3a20123d1fafc07c1352d83f0ab3/dist/typeahead.jquery.js"
"strophejs-plugins": "~0.0.4"
},
"exportsOverride": {}
}
This diff is collapsed.
......@@ -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)
------------------
......
This diff is collapsed.
......@@ -15,10 +15,10 @@ config = {
"jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website
"moment": "components/momentjs/moment",
"strophe": "components/strophe/strophe",
"strophe.disco": "components/strophe.disco/index",
"strophe.disco": "components/strophejs-plugins/disco/strophe.disco",
"strophe.muc": "components/strophe.muc/index",
"strophe.roster": "components/strophe.roster/index",
"strophe.vcard": "components/strophe.vcard/index",
"strophe.vcard": "components/strophejs-plugins/vcard/strophe.vcard",
"text": 'components/requirejs-text/text',
"tpl": 'components/requirejs-tpl-jcbrand/tpl',
"typeahead": "components/typeahead.js/index",
......
......@@ -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));
}));
define("converse-dependencies", [
"jquery",
"utils",
"otr",
"moment",
"locales",
......@@ -7,16 +8,16 @@ define("converse-dependencies", [
"backbone.overview",
"jquery.browser",
"typeahead",
"utils",
"strophe",
"strophe.muc",
"strophe.roster",
"strophe.vcard",
"strophe.disco"
], function($, otr, moment) {
], function($, utils, otr, moment) {
return {
'jQuery': $,
'moment': moment,
'otr': otr,
'moment': moment
'utils': utils
};
});
define("converse-dependencies", [
"jquery",
"utils",
"moment",
"locales",
"backbone.browserStorage",
"backbone.overview",
"jquery.browser",
"typeahead",
"utils",
"strophe",
"strophe.muc",
"strophe.roster",
"strophe.vcard",
"strophe.disco"
], function($, moment) {
], function($, utils, moment) {
return {
'jQuery': $,
'otr': undefined,
'moment': moment
'moment': moment,
'utils': utils
};
});
define("converse-dependencies", [
"jquery",
"utils",
"moment",
"locales",
"bootstrapJS", // XXX: Can be removed, only for https://conversejs.org
......@@ -8,16 +9,16 @@ define("converse-dependencies", [
"jquery.browser",
"jquery.easing", // XXX: Can be removed, only for https://conversejs.org
"typeahead",
"utils",
"strophe",
"strophe.muc",
"strophe.roster",
"strophe.vcard",
"strophe.disco"
], function($, moment) {
], function($, utils, moment) {
return {
'jQuery': $,
'otr': undefined,
'moment': moment
'moment': moment,
'utils': utils
};
});
define("converse-dependencies", [
"jquery",
"utils",
"otr",
"moment",
"locales",
......@@ -9,16 +10,16 @@ define("converse-dependencies", [
"jquery.browser",
"jquery.easing", // XXX: Only for https://conversejs.org
"typeahead",
"utils",
"strophe",
"strophe.muc",
"strophe.roster",
"strophe.vcard",
"strophe.disco"
], function($, otr, moment) {
], function($, utils, otr, moment) {
return {
'jQuery': $,
'otr': otr,
'moment': moment
'moment': moment,
'utils': utils
};
});
......@@ -8,4 +8,51 @@ define(["jquery"], function ($) {
}
return false;
};
$.fn.addHyperlinks = function () {
if (this.length > 0) {
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) {
for (i=0; i<list.length; i++) {
var prot = list[i].indexOf('http://') === 0 || list[i].indexOf('https://') === 0 ? '' : 'http://';
var escaped_url = encodeURI(decodeURI(list[i])).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
x = x.replace(list[i], "<a target='_blank' href='" + prot + escaped_url + "'>"+ list[i] + "</a>" );
}
}
$(obj).html(x);
});
}
return this;
};
var utils = {
// Translation machinery
// ---------------------
__: $.proxy(function (str) {
// Translation factory
if (this.i18n === undefined) {
this.i18n = locales.en;
}
var t = this.i18n.translate(str);
if (arguments.length>1) {
return t.fetch.apply(t, [].slice.call(arguments,1));
} else {
return t.fetch();
}
}, this),
___: function (str) {
/* XXX: This is part of a hack to get gettext to scan strings to be
* translated. Strings we cannot send to the function above because
* they require variable interpolation and we don't yet have the
* variables at scan time.
*
* See actionInfoMessages
*/
return str;
}
};
return utils;
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment