Version

1.1.1

License

Notes

Browser

Sets a few Browser/DOM flags.

Note

These are more for internal use than external.  The entire goal of Flow Core is that you don’t need to worry about browser detection.

Properties

Flow.Browser.IEInternet Explorer.
Flow.Browser.IE8Internet Explorer 8
Flow.Browser.IE6Internet Explorer 6
Flow.Browser.IE7Internet Explorer 7
Flow.Browser.GKGecko-based
Flow.Browser.WKWebkit
Flow.Browser.S3Safari 3
Flow.Browser.OPOpera

Properties

every

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:every

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var isBigEnough = function(element, index, array) {
  return (element >= 10);
};
var passed = [12, 5, 8, 130, 44].every(isBigEnough); // passed is false
passed = [12, 54, 18, 130, 44].every(isBigEnough); // passed is true

some

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:some

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var isBigEnough = function(element, index, array) {
  return (element >= 10);
};
var passed = [2, 5, 8, 1, 4].some(isBigEnough); // passed is false
passed = [12, 5, 8, 1, 4].some(isBigEnough); // passed is true

filter

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:filter

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var isBigEnough = function(element, index, array) {
  return (element >= 10);
};
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough); // returns [12, 130, 44]

map

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:map

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var numbers = [1, 4, 9];
var roots = numbers.map(Math.sqrt); // roots is now [1, 2, 3]
// numbers is still [1, 4, 9]

indexOf

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var array = [2, 5, 9];
var index = array.indexOf(2); // index is 0
index = array.indexOf(7); // index is -1

lastIndexOf

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var array = [2, 5, 9, 2];
var index = array.lastIndexOf(2); // index is 3
index = array.lastIndexOf(7); // index is -1
index = array.lastIndexOf(2, 3); // index is 3
index = array.lastIndexOf(2, 2); // index is 0
index = array.lastIndexOf(2, -2); // index is 0
index = array.lastIndexOf(2, -1); // index is 3

forEach

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:filter

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

var lis = document.getElementsByTagName("li");
lis.forEach(function(element, index, array) {
    console.log(element.nodeName.toLowerCase == "li") // alerts true
    console.log(i) // Alerts current index
    console.log(array) // alerts the elements container array
});

reduce

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:reduce

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

Flatten an array of arrays:

var flattened = [[0,1], [2,3], [4,5]].reduce(function(a,b) {
  return a.concat(b);
}, []);
// flattened is [0, 1, 2, 3, 4, 5]

reduceRight

http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:reduceRight

Parameters

elementthe element to test against
index(optional) A.K.A.  "i", the current index in loop
array(optional) element’s parent

Example

Flatten an array of arrays:

var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {
  return a.concat(b);
}, []);
// flattened is [4, 5, 2, 3, 0, 1]

Apply

Used to extend Flow to elements.

Note

Flow auto-extends every element. getInnerHTML / setInnerHTML take care of adding Flow to elements using innerHTML However if you insist on using native innerHTML, you need to re-bind Flow to injected elements using Flow.Apply

Plugin

Allows you to extend the Flow namespace

Example

// define closure
new Flow.Plugin({
    name : "Foo", // You've defined "Flow.Foo"
    version : "1.0.2 (fixes conflict with 'Soda.Grape')", // Versioning info
    description : "Foo integrates Flow with 'Soda.Orange'.", // Brief description

    constructor : { // The meat n' potatoes. Your Function/Object goes here
        init : function(e) {
            e = e.toUpperCase();
            this.orange(e);
        },
        orange : function(e) {
            this.flavor = e;
            this.fizz();
        },
        fizz : function() {
            alert("soda");
        }
    }.init("orange") // call constructor.init
}); // closure