Created
July 1, 2015 20:39
-
-
Save atuttle/faaa6d38d62fbff2c7cb to your computer and use it in GitHub Desktop.
My JSCS config and a sample of how it formats
This file contains hidden or 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
Show hidden characters
{ | |
"preset": "node-style-guide" | |
,"validateIndentation": "\t" | |
,"disallowAnonymousFunctions": true | |
,"disallowSpacesInsideParentheses": { "only": [ "{", "}" ] } | |
,"requireSpacesInsideParentheses": { "all": true, "except": [ "{", "}" ] | |
,"requireSpacesInsideBrackets": { "allExcept": [ "[", "]", "{", "}" ] }} | |
,"requireSpacesInsideObjectBrackets": "allButNested" | |
,"validateParameterSeparator": ", " | |
,"disallowCommaBeforeLineBreak": true | |
,"disallowMixedSpacesAndTabs": "smart" | |
} |
This file contains hidden or 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
'use strict'; | |
var _ = require( 'lodash' ); | |
var numeral = require( 'numeral' ); | |
var $ = window.jQuery; | |
module.exports = { | |
calculateSubtotal: function() { | |
var totalPrice = 0; | |
$( '#partyMemberSelections select option:checked' ).each( function() { | |
var itemPrice = $( this ).data( 'price' ); | |
if ( typeof ( itemPrice ) === 'undefined' ) { | |
//0 | |
}else { | |
itemPrice = parseFloat( itemPrice ); | |
totalPrice += itemPrice; | |
} | |
}); | |
$( '#subtotal' ).show().html( 'Total: $ ' + numeral( totalPrice ).format( '9.99' ) ); | |
} | |
, enableSectionsOptions: function( select ) { | |
var $this = $( select ); | |
if ( $this.val() === 'true' ) { | |
$this.closest( '.row' ).find( 'select' ).removeAttr( 'disabled' ); | |
}else { | |
var $selects = $this.closest( '.row' ).find( 'select' ).not( '.primary' ); | |
$selects.find( 'option' ).removeAttr( 'selected' ); | |
$selects.attr( 'disabled', 'disabled' ); | |
} | |
} | |
, validateActivitySelections: function() { | |
var isSuccess = true; | |
var requiredSelects = $( '#partyMemberSelections' ).find( '.requireSelection' ); | |
_.map( requiredSelects, function( el ) { | |
var $selected = $( el ); | |
var $dependsOn = $selected.closest( '.row' ).find( '.primary' ); | |
var selectedVal = $selected.val(); | |
if ( selectedVal === '' && $dependsOn.val() === 'true' ) { | |
isSuccess = false; | |
$selected.closest( 'div' ).addClass( 'error' ).focus(); | |
}else if ( $selected.is( '.primary' ) ) { | |
if ( selectedVal === '' ) { | |
isSuccess = false; | |
$selected.closest( 'div' ).addClass( 'error' ).focus(); | |
}else { | |
$selected.closest( 'div' ).removeClass( 'error' ); | |
} | |
}else { | |
$selected.closest( 'div' ).removeClass( 'error' ); | |
} | |
}); | |
if ( !isSuccess ) { | |
window.alert( 'Please make a selection in all fields marked in red' ); | |
} | |
return isSuccess; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment