Class Index | File Index

Classes


Class slikcalc.BaseCalc

BaseCalc
Defined in: BaseCalc.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Base Calculator class handles common configuration options, provides utility methods, an interface for extending, and runs calculator's initialize method on page load if it exists.
Field Summary
Field Attributes Field Name and Description
 
Boolean value to signal if the calculator should fire initially when the page loads
 
Reference to slikcalc custom event to fire when the calculation has been completed for this calculator
 
Internal value tracking the number of calculations triggered used to prevent callbacks from firing out of synch
 
Internal boolean to track if the calculator has been initialized yet
 
Configuration value for the pause in keyup events to wait for before calculating.
 
Internal value of the time when the last keyup event fired used to make sure andfire the calculate event only after there is a delay in typing for performance reasons
 
Boolean value indicating if event listeners should be placed on relevant elements to tracking key events and clicking
 
Element ID for the total value of the calculator
 
Mathematical operator to apply against each row to produce end result ( +, -, *, x, / )
Method Summary
Method Attributes Method Name and Description
 
Base initialize method to handle calling subclass initialize(), and sets initialized property.
 
Abstract method to be implemented in sub-classes.
 
calculateTotal(total, amount)
Calculates the total amount, dependant upon the totalOperator value.
 
dependsOn(dependCalc)
Sets up event chaining for BaseCalc objects.
 
Wrapper method to trigger processCalculation when there is a pause in users key events
 
Wrapper method for concrete class' `calculate` method
 
triggers(triggeredCalc)
Sets up event chaining for BaseCalc objects.
Class Detail
slikcalc.BaseCalc(config)
Base Calculator class handles common configuration options, provides utility methods, an interface for extending, and runs calculator's initialize method on page load if it exists.
Parameters:
{Object} config
Configuration object with the following options:
  • total.id : (Optional) Element ID to place end result of column calculation
  • total.operator : (Optional) ( +, -, *, x, / ) Mathematical operator to apply against each row to produce end result. Defaults to '+'
  • calcOnLoad : (Optional) Defaults to false. If true, on page load the calculate method is fired
  • registerListeners : (Optional) Defaults to false. If true, event listeners are attached to inputs that fire the calculate method
Field Detail
calcOnLoad
Boolean value to signal if the calculator should fire initially when the page loads

calculationComplete
Reference to slikcalc custom event to fire when the calculation has been completed for this calculator

calculations
Internal value tracking the number of calculations triggered used to prevent callbacks from firing out of synch

initialized
Internal boolean to track if the calculator has been initialized yet

keyupDelay
Configuration value for the pause in keyup events to wait for before calculating. Setting this to zero will cause calculations to perform on each keyup event, which could become costly with many calculatorschained together

lastKeyUp
Internal value of the time when the last keyup event fired used to make sure andfire the calculate event only after there is a delay in typing for performance reasons

registerListeners
Boolean value indicating if event listeners should be placed on relevant elements to tracking key events and clicking

totalId
Element ID for the total value of the calculator

totalOperator
Mathematical operator to apply against each row to produce end result ( +, -, *, x, / )
Method Detail
baseInitialize()
Base initialize method to handle calling subclass initialize(), and sets initialized property.Also calls processCalculation() if calcOnLoad is true

calculate()
Abstract method to be implemented in sub-classes.

calculateTotal(total, amount)
Calculates the total amount, dependant upon the totalOperator value. Seperated into conditional statements for better performance than using 'eval()', and to handle operator unique functionality
Parameters:
{Float} total
Initial value of total.
{Float} amount
New amount to calculate in conjunction with total.

dependsOn(dependCalc)
Sets up event chaining for BaseCalc objects. The object passed in is returned to allow for a fluent interfacethis.calculate will be called after dependCalc.calculate
Parameters:
{BaseCalc} dependCalc
BaseCalc object to attach event to

keyupEvent()
Wrapper method to trigger processCalculation when there is a pause in users key events

processCalculation()
Wrapper method for concrete class' `calculate` method

triggers(triggeredCalc)
Sets up event chaining for BaseCalc objects. The object passed in is returned to allow for a fluent interfacethis.calculate will be called before triggeredCalc.calculate
Parameters:
{BaseCalc} triggeredCalc
BaseCalc object to attach event to

Documentation generated by JsDoc Toolkit 2.0.2 on Thu Sep 11 2008 15:52:44 GMT-0600 (MDT)