Rework the way builds are created.

Builds are now themselves UMD modules, so they could be `require`'d like any
other AMD module or they can still be used as old ES5 modules with globals.

Additionally the build is now closured, so that the almond API doesn't pollute
the global context with `define` or `require`. This does however mean that
`require` can no longer be used outside of the build (unless requirej.s is
included directly.
This commit is contained in:
JC Brand 2017-02-27 07:42:17 +00:00
parent 38c9a9e10c
commit ac867c9524
5 changed files with 38 additions and 62 deletions

View File

@ -14,8 +14,7 @@
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script src="node_modules/requirejs/require.js"></script>
<script src="config.js"></script>
<script src="src/converse.js"></script>
<script src="src/config.js"></script>
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-custom">
@ -66,11 +65,7 @@
],
auto_reconnect: true,
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
keepalive: true,
message_carbons: true,
message_archiving: 'always',
play_sounds: true,
roster_groups: true,
show_controlbox_by_default: true,
strict_plugin_dependencies: false,
chatstate_notification_blacklist: ['mulles@movim.eu'],

View File

@ -208,46 +208,41 @@
</body>
<script>
require(['converse'], function (converse) {
(function () {
/* XXX: This function initializes jquery.easing for the https://conversejs.org
* website. This code is only useful in the context of the converse.js
* website and converse.js itself is NOT dependent on it.
*/
var $ = converse.env.jQuery;
$.extend( $.easing, {
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
});
$(window).scroll(function() {
if ($(".navbar").offset().top > 50) {
$(".navbar-fixed-top").addClass("top-nav-collapse");
} else {
$(".navbar-fixed-top").removeClass("top-nav-collapse");
}
});
//jQuery for page scrolling feature - requires jQuery Easing plugin
$('.page-scroll a').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 700, 'easeInOutExpo');
event.preventDefault();
});
})();
converse.initialize({
// Please use this connection manager only for testing purposes
bosh_service_url: 'https://conversejs.org/http-bind/',
message_carbons: true,
play_sounds: true,
roster_groups: true,
show_controlbox_by_default: true,
(function () {
/* XXX: This function initializes jquery.easing for the https://conversejs.org
* website. This code is only useful in the context of the converse.js
* website and converse.js itself is NOT dependent on it.
*/
var $ = converse.env.jQuery;
$.extend( $.easing, {
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
});
$(window).scroll(function() {
if ($(".navbar").offset().top > 50) {
$(".navbar-fixed-top").addClass("top-nav-collapse");
} else {
$(".navbar-fixed-top").removeClass("top-nav-collapse");
}
});
//jQuery for page scrolling feature - requires jQuery Easing plugin
$('.page-scroll a').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 700, 'easeInOutExpo');
event.preventDefault();
});
})();
converse.initialize({
// Please use this connection manager only for testing purposes
bosh_service_url: 'https://conversejs.org/http-bind/',
show_controlbox_by_default: true,
});
</script>
</html>

View File

@ -24,13 +24,6 @@ if (typeof define !== 'undefined') {
"converse-headline", // Support for headline messages
/* END: Removable components */
], function (converse) {
var evt;
if (window.CustomEvent) {
evt = new CustomEvent('converse-loaded', {detail: {'converse': converse}});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent('converse-loaded', true, true, {'converse': converse});
}
window.dispatchEvent(evt);
return converse;
});
}

View File

@ -26,13 +26,6 @@ if (typeof define !== 'undefined') {
"converse-headline", // Support for headline messages
/* END: Removable components */
], function (converse) {
var evt;
if (window.CustomEvent) {
evt = new CustomEvent('converse-loaded', {detail: {'converse': converse}});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent('converse-loaded', true, true, {'converse': converse});
}
window.dispatchEvent(evt);
return converse;
});
}

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" media="screen" href="css/jasmine.css">
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script src="config.js"></script>
<script src="src/config.js"></script>
<script data-main="tests/main" src="node_modules/requirejs/require.js"></script>
<style>
.tests-brand-heading {