-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from strophe/amd-merge
Add support for the Asynchronous Module Definition (AMD) and require.js
- Loading branch information
Showing
25 changed files
with
512 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
({ | ||
baseUrl: ".", | ||
name: "bower_components/almond/almond.js", | ||
out: "strophe.js", | ||
include: ['main'], | ||
mainConfigFile: 'main.js' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Strophe.js AMD Example</title> | ||
<script src="../main.js"></script> | ||
<script src="../bower_components/requirejs/require.js" data-main="main.js"></script> | ||
</head> | ||
<body> | ||
<div id='login' style='text-align: center'> | ||
<form name='cred'> | ||
<label for='jid'>JID:</label> | ||
<input type='text' id='jid'> | ||
<label for='pass'>Password:</label> | ||
<input type='password' id='pass'> | ||
<input type='button' id='connect' value='connect'> | ||
</form> | ||
</div> | ||
<hr> | ||
<div id='log'></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
config.baseUrl = '../'; | ||
require.config(config); | ||
if (typeof(require) === 'function') { | ||
require(["jquery", "strophe", ], function($, wrapper) { | ||
Strophe = wrapper.Strophe; | ||
|
||
var BOSH_SERVICE = 'http://bosh.metajack.im:5280/xmpp-httpbind'; | ||
var connection = null; | ||
|
||
function log(msg) { | ||
$('#log').append('<div></div>').append(document.createTextNode(msg)); | ||
} | ||
|
||
function rawInput(data) { | ||
log('RECV: ' + data); | ||
} | ||
|
||
function rawOutput(data) { | ||
log('SENT: ' + data); | ||
} | ||
|
||
function onConnect(status) { | ||
if (status == Strophe.Status.CONNECTING) { | ||
log('Strophe is connecting.'); | ||
} else if (status == Strophe.Status.CONNFAIL) { | ||
log('Strophe failed to connect.'); | ||
$('#connect').get(0).value = 'connect'; | ||
} else if (status == Strophe.Status.DISCONNECTING) { | ||
log('Strophe is disconnecting.'); | ||
} else if (status == Strophe.Status.DISCONNECTED) { | ||
log('Strophe is disconnected.'); | ||
$('#connect').get(0).value = 'connect'; | ||
} else if (status == Strophe.Status.CONNECTED) { | ||
log('Strophe is connected.'); | ||
connection.disconnect(); | ||
} | ||
} | ||
|
||
$(document).ready(function () { | ||
connection = new Strophe.Connection(BOSH_SERVICE); | ||
connection.rawInput = rawInput; | ||
connection.rawOutput = rawOutput; | ||
$('#connect').bind('click', function () { | ||
var button = $('#connect').get(0); | ||
if (button.value == 'connect') { | ||
button.value = 'disconnect'; | ||
connection.connect( | ||
$('#jid').get(0).value, | ||
$('#pass').get(0).value, | ||
onConnect | ||
); | ||
} else { | ||
button.value = 'connect'; | ||
connection.disconnect(); | ||
} | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var config; | ||
if (typeof(require) === 'undefined') { | ||
/* XXX: Hack to work around r.js's stupid parsing. | ||
* We want to save the configuration in a variable so that we can reuse it in | ||
* tests/main.js. | ||
*/ | ||
require = { | ||
config: function (c) { | ||
config = c; | ||
} | ||
}; | ||
} | ||
|
||
require.config({ | ||
baseUrl: '.', | ||
paths: { | ||
// Strophe.js src files | ||
"strophe-base64": "src/base64", | ||
"strophe-bosh": "src/bosh", | ||
"strophe-core": "src/core", | ||
"strophe": "src/wrapper", | ||
"strophe-md5": "src/md5", | ||
"strophe-sha1": "src/sha1", | ||
"strophe-websocket": "src/websocket", | ||
"strophe-polyfill": "src/polyfills", | ||
|
||
// Examples | ||
"basic": "examples/basic", | ||
|
||
// Tests | ||
"jquery": "bower_components/jquery/dist/jquery", | ||
"sinon": "bower_components/sinon/index", | ||
"sinon-qunit": "bower_components/sinon-qunit/lib/sinon-qunit", | ||
"tests": "tests/tests" | ||
} | ||
}); | ||
|
||
if (typeof(require) === 'function') { | ||
require(["strophe"], function(Strophe) { | ||
window.Strophe = Strophe; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.