Utils Class
Item Index
Methods
Properties
Methods
_applyInterval
-
id
-
callback
-
interval
-
scope
use Firebrick.utils:setInterval()
Parameters:
-
id
String(optional)
-
callback
Function -
interval
Interger -
scope
Object
Returns:
id
_containerNS
()
String | Null
private
used by getPathFromName
Returns:
argsToArray
-
args
convert arguments array to nomral array
Parameters:
-
args
Arguments Array
Returns:
clearInterval
-
id
clear the interval running by id
Parameters:
-
id
String
clearSplash
()
private
removes splash tag $("#fb-splash")
compareArrays
-
array1
-
array2
multidimensional array comparison inspired by: http://stackoverflow.com/a/14853974/425226
Parameters:
-
array1
Object -
array2
Object
Returns:
true is they are identical
copyover
-
obj1
-
obj2
unlike overwrite it does not overwrite any properties that are already in obj1
Parameters:
-
obj1
Object -
obj2
Object
Returns:
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
Integermiliseconds
-
args
Anypass to delay function
-
scope
Object(optional) scope of the callback function. Defaults to: window
Example:
delay(function(){}, 1000, scope);
firstToUpper
-
str
Parameters:
-
str
String
Returns:
first character in string uppercase
getDeepProperty
-
property
-
obj
returns a deep property from an object fails silently and returns null
Parameters:
-
property
String -
obj
Object
Returns:
property value
Example:
//get property "where.street" obj = { where: { street: "Some Street" } }
getPathFromName
-
name
-
ext
Converts a name like "MyApp.controller.MyController" to a path MyApp/controller/MyController.js
Parameters:
-
name
String -
ext
String[default=''] extension
Returns:
initSplash
-
html
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
Check whether interval already exists
Parameters:
-
id
String
Returns:
interval function
loadCSS
-
url
load css file and append to HEAD
Parameters:
-
url
String
merge
-
propName
-
object
-
a
recursively iterate over prototypes and merge all the properties of an object together from its inherited parents for a specified property (name)
Parameters:
-
propName
Stringname of property to merge
-
object
Objectobject/class to iterate through
-
a
Object(optional) used when calling itself recursively
Returns:
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
Parameters:
-
any
Array | Argument Arraysnumber - ignores null
Returns:
overwrite
-
obj1
-
obj2
overwrite properties in {obj1} with properties from {obj2} (mixin)
Parameters:
-
obj1
Object -
obj2
Object
Returns:
obj1 mixed in with obj2
require
-
name
-
callback
Get a script/file from path
Parameters:
-
name
String, Array of StringsMyApp.controller.MyController
-
callback
Function(optional) called when last require has completed or failed
Returns:
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
Integermiliseconds
-
scope
Objectscope to apply to the callback
stripArguments
-
args
Parameters:
-
args
Object
Returns:
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 a unique id: http://stackoverflow.com/a/19223188
Returns:
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