Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMD tests #13843

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ module.exports = function (grunt) {
' */\n',
// NOTE: This jqueryCheck code is duplicated in customizer.js; if making changes here, be sure to update the other copy too.
jqueryCheck: 'if (typeof define == \'undefined\' && typeof exports == \'undefined\' && typeof jQuery == \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n',
umdDefinition: [
'(function (o_o) {\n',
' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n',
' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n',
'})(function ($) {'
],

// Task configuration.
clean: {
Expand Down Expand Up @@ -87,8 +93,15 @@ module.exports = function (grunt) {

concat: {
options: {
banner: '<%= banner %>\n<%= jqueryCheck %>',
stripBanners: false
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= umdDefinition.join("") %>\n\n',
footer: '});\n',
stripBanners: false,
process: function (src) {
var umdHeader = '\n\n ' + grunt.config.get('umdDefinition').join(' ');
var umdFooter = ' })\n\n}();\n';

return src.replace(umdHeader, '').replace(umdFooter, '}();\n');
}
},
bootstrap: {
src: [
Expand Down
15 changes: 13 additions & 2 deletions docs/assets/js/_src/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,27 @@ window.onload = function () { // wait for load in a dumb way because B-0
function generateJS(preamble) {
var $checked = $('#plugin-section input:checked')
var jqueryCheck = 'if (typeof define == \'undefined\' && typeof exports == \'undefined\' && typeof jQuery == \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n'
var umdDefinition = [
'(function (o_o) {\n',
' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n',
' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n',
'})(function ($) {'
]

if (!$checked.length) return false

var js = $checked
.map(function () { return __js[this.value] })
.map(function () {
var umdHeader = '\n\n ' + umdDefinition.join(' ')
var umdFooter = ' })\n\n}();\n'

return __js[this.value].replace(umdHeader, '').replace(umdFooter, '}();\n')
})
.toArray()
.join('\n')

preamble = cw + preamble
js = jqueryCheck + js
js = jqueryCheck + umdDefinition.join('') + '\n\n' + js + '});\n'

return {
'bootstrap.js': preamble + js,
Expand Down
9,205 changes: 9,205 additions & 0 deletions js/tests/umd/browserify/concatenated/bundle.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions js/tests/umd/browserify/concatenated/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Browserify concatenated</title>
<link rel="stylesheet" type="text/css" href="../../../../../dist/css/bootstrap.min.css">
</head>
<body>

<div class="container">

<div class="page-header">
<h1>Tooltip <small>Bootstrap Visual Test</small></h1>
</div>

<p class="muted" style="margin-bottom: 0;">Tight pants next level keffiyeh <a href="#" data-toggle="tooltip" title="" data-original-title="Default tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" data-toggle="tooltip" title="" data-original-title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" data-toggle="tooltip" title="" data-original-title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" data-toggle="tooltip" title="" data-original-title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral.
</p>
<hr>
<p>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="" data-original-title="Tooltip on left">Tooltip on left</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</button>
</p>

</div>

<script src="bundle.js"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions js/tests/umd/browserify/concatenated/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var $ = require('jquery')
require('../../../../../dist/js/bootstrap.min.js')

$('[data-toggle="tooltip"]').tooltip()
Loading