Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow different builds to be tested more easily with a dropdown menu.
- Loading branch information
Showing
6 changed files
with
139 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
;(function(window) { | ||
'use strict'; | ||
|
||
/** `QUnit.addEvent` shortcut */ | ||
var addEvent = QUnit.addEvent; | ||
|
||
/** The Lo-Dash build to load */ | ||
var build = (/build=([^&]+)/.exec(location.search) || [])[1]; | ||
|
||
/** A flag to determine if RequireJS should be loaded */ | ||
var norequire = /[?&]norequire=true(?:&|$)/.test(location.search); | ||
|
||
/*--------------------------------------------------------------------------*/ | ||
|
||
// assign `QUnit.config` properties | ||
QUnit.config.lodashFilename = build == 'prod' | ||
? 'lodash.min' | ||
: (build == 'custom' ? 'lodash.custom.min' : 'lodash'); | ||
|
||
// assign `QUnit.urlParams` properties | ||
QUnit.extend(QUnit.urlParams, { | ||
'build': build, | ||
'norequire': norequire | ||
}); | ||
|
||
// initialize the build dropdown | ||
addEvent(window, 'load', function() { | ||
function eventHandler(event) { | ||
var search = location.search.replace(/^\?|&?(?:build|norequire)=[^&]*&?/g, ''); | ||
if (event.stopPropagation) { | ||
event.stopPropagation(); | ||
} else { | ||
event.cancelBubble = true; | ||
} | ||
location.href = | ||
location.href.split('?')[0] + '?' + | ||
(search ? search + '&' : '') + 'build=' + | ||
dropdown[dropdown.selectedIndex].value + | ||
(checkbox.checked ? '&norequire=true' : ''); | ||
} | ||
|
||
function init() { | ||
var header = document.getElementById('qunit-header'); | ||
if (header) { | ||
header.appendChild(label1); | ||
header.appendChild(label2); | ||
|
||
if (build == 'prod') { | ||
dropdown.selectedIndex = 1; | ||
} else if (build == 'custom') { | ||
dropdown.selectedIndex = 2; | ||
} | ||
checkbox.checked = norequire; | ||
addEvent(checkbox, 'click', eventHandler); | ||
addEvent(dropdown, 'change', eventHandler); | ||
} | ||
else { | ||
setTimeout(init, 15); | ||
} | ||
} | ||
|
||
var label1 = document.createElement('label'); | ||
label1.innerHTML = | ||
'<input name="norequire" type="checkbox">norequire</label>'; | ||
|
||
var label2 = document.createElement('label'); | ||
label2.innerHTML = | ||
'<select name="build">' + | ||
'<option value="dev">developement</option>' + | ||
'<option value="prod">production</option>' + | ||
'<option value="custom">custom</option>' + | ||
'</select>build'; | ||
|
||
var checkbox = label1.firstChild, | ||
dropdown = label2.firstChild; | ||
|
||
init(); | ||
}); | ||
|
||
}(this)); |
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