MediaWiki:Gadget-fa-bid-calculator.js: Difference between revisions

Years -> Contract length, matching the re-sign calculator
Stack calculator rows on narrow screens
Line 97: Line 97:
form.className = 'tc-calc';
form.className = 'tc-calc';


/**
* One labelled row. Controls live in their own flex wrapper so that on a
* narrow screen the label can stack above them while they stay in a row.
* Returns the wrapper, so callers can append a readout beside the control.
*/
function row( labelText, el ) {
function row( labelText, el ) {
var r = document.createElement( 'div' );
var r = document.createElement( 'div' );
Line 102: Line 107:
var l = document.createElement( 'label' );
var l = document.createElement( 'label' );
l.textContent = labelText;
l.textContent = labelText;
var c = document.createElement( 'div' );
c.className = 'tc-calc-controls';
c.appendChild( el );
r.appendChild( l );
r.appendChild( l );
r.appendChild( el );
r.appendChild( c );
form.appendChild( r );
form.appendChild( r );
return r;
return c;
}
}


Line 126: Line 134:
name.type = 'text';
name.type = 'text';
name.placeholder = 'Caldwell Jones';
name.placeholder = 'Caldwell Jones';
name.style.width = '14em';
name.className = 'tc-calc-wide';


var team = document.createElement( 'input' );
var team = document.createElement( 'input' );
team.type = 'text';
team.type = 'text';
team.placeholder = 'Suns';
team.placeholder = 'Suns';
team.style.width = '14em';
team.className = 'tc-calc-wide';


function fillYears() {
function fillYears() {
Line 154: Line 162:
salaryPts.className = 'tc-calc-inline';
salaryPts.className = 'tc-calc-inline';
row( 'Salary', salary ).appendChild( salaryPts );
row( 'Salary', salary ).appendChild( salaryPts );
var ageRow = row( 'Player is 35+', age35 );
row( 'Player is 35+', age35 ).parentNode
ageRow.querySelector( 'label' ).style.fontWeight = 'normal';
.querySelector( 'label' ).style.fontWeight = 'normal';
row( 'Bid to beat (optional)', beat );
row( 'Bid to beat (optional)', beat );
row( 'Your team (optional)', team );
row( 'Your team (optional)', team );