Skip to content

Commit

Permalink
js: Conform with jQuery JavaScript Style Guide
Browse files Browse the repository at this point in the history
* Update JSHint configuration and enforce new rules
  (mostly quote marks and removing unused variables).

* Whitespace (no space after last object/function argument,
  no space after "function" operator in anonymous functions).

* Remove dates from @author.

Ref #289
  • Loading branch information
Krinkle committed Jan 15, 2014
1 parent 98c6e86 commit 5cdfed0
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 328 deletions.
40 changes: 23 additions & 17 deletions .jshintrc
@@ -1,21 +1,27 @@
{
"predef": [
"SWARM"
],
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"onevar": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true,

"bitwise": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"undef": true,
"trailing": true,
"bitwise": true,
"browser": true,
"es3": true,
"latedef": true,
"newcap": true,
"noempty": true,

"smarttabs": true,

"browser": true,
"jquery": true
"predef": [
"SWARM",
"jQuery"
]
}
31 changes: 15 additions & 16 deletions js/addjob.js
@@ -1,42 +1,41 @@
/**
* JavaScript file for the "addjob" page.
*
* @author Timo Tijhof, 2012
* @author Timo Tijhof
* @since 1.0.0
* @package TestSwarm
*/
jQuery(function ( $ ) {
var $runsContainer, $addRunBtn, $runFieldsetClean, cnt;
jQuery(function( $ ) {
var $addRunBtn,
$runsContainer = $( "#runs-container" ),
$runFieldsetClean = $runsContainer.children( "fieldset" ).eq( 0 ).clone().detach(),
cnt = $runsContainer.children( "fieldset" ).length;

$runsContainer = $('#runs-container');
$runFieldsetClean = $runsContainer.children('fieldset').eq(0).clone().detach();
cnt = $runsContainer.children('fieldset').length;

$addRunBtn = $('<button>')
.text('+ Run')
.addClass('btn')
$addRunBtn = $( "<button>" )
.text( "+ Run" )
.addClass( "btn" )
.click(function ( e ) {
e.preventDefault();

cnt += 1;

function fixNum( i, val ) {
return val.replace( '1', cnt );
return val.replace( "1", cnt );
}

$addRunBtn.before(
$runFieldsetClean.clone()
.find('input').val('')
.find( "input" ).val( "" )
.end()
.find('[for*="1"]').attr('for', fixNum)
.find( "[for*='1']" ).attr( "for", fixNum )
.end()
.find('[id*="1"]').attr('id', fixNum)
.find( "[id*='1']" ).attr( "id", fixNum )
.end()
.find('legend').text(fixNum)
.find( "legend" ).text( fixNum )
.end()
);
})
.appendTo('<div class="form-actions"></div>')
.appendTo( "<div class='form-actions'></div>" )
.parent();

$runsContainer.append( $addRunBtn );
Expand Down

0 comments on commit 5cdfed0

Please sign in to comment.