API Docs for: 0.13.12
Show:

Utils Class

Defined in: src\firebrick.js:962
Module: Firebrick

Methods

_applyInterval

(
  • id
  • callback
  • interval
  • scope
)
String private

use Firebrick.utils:setInterval()

Parameters:

  • id String

    (optional)

  • callback Function
  • interval Interger
  • scope Object

Returns:

String:

id

_containerNS

() String | Null private

used by getPathFromName

Returns:

String | Null:

argsToArray

(
  • args
)
Array

convert arguments array to nomral array

Parameters:

  • args Arguments Array

Returns:

Array:

clearInterval

(
  • id
)

clear the interval running by id

Parameters:

  • id String

clearSplash

() private

removes splash tag $("#fb-splash")

compareArrays

(
  • array1
  • array2
)
Boolean

multidimensional array comparison inspired by: http://stackoverflow.com/a/14853974/425226

Parameters:

  • array1 Object
  • array2 Object

Returns:

Boolean:

true is they are identical

copyover

(
  • obj1
  • obj2
)
Object

unlike overwrite it does not overwrite any properties that are already in obj1

Parameters:

  • obj1 Object
  • obj2 Object

Returns:

Object:

obj2 mixed in missing property into obj1

dataFor

()

shortcut for knockout.dataFor

Returns:

knockout.dataFor

delay

(
  • callback
  • timeout
  • args
  • scope
)

Javascript setTimout function

Parameters:

  • callback Function
  • timeout Integer

    miliseconds

  • args Any

    pass to delay function

  • scope Object

    (optional) scope of the callback function. Defaults to: window

Example:

 delay(function(){}, 1000, scope);

firstToUpper

(
  • str
)
String

Parameters:

  • str String

Returns:

String:

first character in string uppercase

getDeepProperty

(
  • property
  • obj
)
Any | Null

returns a deep property from an object fails silently and returns null

Parameters:

  • property String
  • obj Object

Returns:

Any | Null:

property value

Example:

//get property "where.street" obj = { where: { street: "Some Street" } }

getPathFromName

(
  • name
  • ext
)
String private

Converts a name like "MyApp.controller.MyController" to a path MyApp/controller/MyController.js

Parameters:

  • name String
  • ext String

    [default=''] extension

Returns:

String:

initSplash

(
  • html
)
private

html is appended to the $("html") tag before the document is ready used by Firebrick:ready

Parameters:

  • html String

Example:

               Firebrick.ready({
                   splash:"<div></div>"
               });

isIntervalRunning

(
  • id
)
Object

Check whether interval already exists

Parameters:

  • id String

Returns:

Object:

interval function

loadCSS

(
  • url
)

load css file and append to HEAD

Parameters:

  • url String

merge

(
  • propName
  • object
  • a
)
Object private

recursively iterate over prototypes and merge all the properties of an object together from its inherited parents for a specified property (name)

Parameters:

  • propName String

    name of property to merge

  • object Object

    object/class to iterate through

  • a Object

    (optional) used when calling itself recursively

Returns:

Object:

object : same object with property (name) merged

Example:

    merge("a", {a:{a:"s"},__proto__:{a:{a:1, b:2, c:3}}})
    //returns {a:{a:"s", b:2, c:3},__proto__:{a:{a:1, b:2, c:3}}}

mergeArrays

(
  • any
)
Array

Parameters:

  • any Array | Argument Arrays

    number - ignores null

Returns:

Array:

overwrite

(
  • obj1
  • obj2
)
Object

overwrite properties in {obj1} with properties from {obj2} (mixin)

Parameters:

  • obj1 Object
  • obj2 Object

Returns:

Object:

obj1 mixed in with obj2

require

(
  • name
  • callback
)
Array of Strings

Get a script/file from path

Parameters:

  • name String, Array of Strings

    MyApp.controller.MyController

  • callback Function

    (optional) called when last require has completed or failed

Returns:

Array of Strings:

the files that were eventually loaded

Example:

require("MyApp.controller.MyController", function(){}, true, "html", "js");

setInterval

(
  • id
  • callback
  • timeout
  • scope
)

set an interval and prevent any duplicates

Parameters:

  • id String

    (optional)

  • callback Function
    • callback gets this.id, this.stop()
  • timeout Integer

    miliseconds

  • scope Object

    scope to apply to the callback

stripArguments

(
  • args
)
Object

Parameters:

  • args Object

Returns:

Object:

Example:

     var a = function(){
         //arguments are [["a"]]
         return stripArguments(arguments) //return ["a"]
     }
     var b = function(){
         return a(arguments); //note not called with apply
     }
    b("a")

used to strip the arguments "array" inside an wrapper "array" - http://jsfiddle.net/smasala/ppdtLmag/

uniqId

() String

Returns:

String:

unique id

Properties

_globalC

Unknown private

intervalRegistry

Object map private

keep track of all the interval functions running

requiredFiles

Object map private

keep track of all require requests

splashCleared

Object map private

used by init&Clear Splash