The ishObject prototype

When you invoke the ish('selector') method ish.fn.ishObject members are inherited through Prototype Delegation to the returned collection. The result is just like a jQuery Object, there is utility methods, a length, context and selector property.

Example
// Cache an ishObject collection
var collection = ish('selector');

// Call an ishObject method
ish('selector').attr('attributeName');

// There is a length property
ish('selector').length; 

// and also a selector property which refers to the first parameter passed into ish();
ish('selector').selector;

// You can call native methods on collection items just like you would in jQuery
ish('selector')[0].style.display = 'block';

Methods

addClass(name)

line 50
Description:

Adds a class name to each Node in the given ishObject.

Returns
ishObject

Returns the ishObject which called it. Method is chainable.

Parameters:
Name Type Description
name string

The class name you wish to add to the element/s.

Example:
ish('selector').addClass('className');

attr(name, value)

line 182
Description:

Gets an attributes value for the first element in the ishObject. If the second argument is supplied the method sets an attribute and its value on all Node's in the given ishObject. Prototyped method and properties are shadowed in the new object.

Returns
ishObject | String

If setting an attribute the method returns the ishObject which called it and is chainable. If getting an attribute value the method will return the value found or undefined if it's not found.

Parameters:
Name Type Description
name String

A valid CSS attribute selector.

value String

The attirbute value to be set.

Example:
ish('selector').attr('attribute-name'); //get an attribute value
ish('selector').attr('attribute-name','attribute-value'); //set an attribute value

css(prop, value)

line 340
Description:

Gets the CSS value of the first element in the supplied ishObject. Or sets the CSS value on all items in an ishObject.

Returns
ishObject

Returns the ishObject which called it. Method is chainable.

Parameters:
Name Type Description
prop String

The name of the CSS property in camelCase. eg. 'margin-left' would be passed as 'marginLeft'.

value String

Exclude the horizontal scrollbars height from the result.

Example:
ish('selector').css();

dimension(type, margins, clientHeight)

line 300
Description:

Gets the width or height the first element in the supplied ishObject.

Returns
Integer

The height of the element.

Parameters:
Name Type Description
type String

'width' or 'height'.

margins Boolean

Include margins in the return result.

clientHeight Boolean

Exclude the horizontal scrollbars height from the result.

Example:
ish('selector').width();

forEach(fn, scope)

line 135
Description:

Iterates an ishObject returning each Node in an individual ishObject, along with its index in the original collection. This method will iterate every item in the collection and cannot be broken.

Returns
ishObject

Returns the ishObject which called it. Method is chainable.

Parameters:
Name Type Description
fn function

The callback function which will be called with each iteration

scope Object

The scope in which the callback function will be called.

Example:
ish('selector', function( $item, index ) {
    //iterates the collections Dom Nodes, cannot be broken out of.    
});

hasClass(test)

line 7
Description:

Tests if a particular class name is found on a Node within the given ishObject. This method will check the whole collection, if you want to check a specific selector you will be required to filter the collection before making the check.

Returns
boolean

If the class name was found on the collection.

Parameters:
Name Type Description
test String

The class name to test against the collection.

Example:
ish('selector').hasClass('className');

height(margins, clientHeight)

line 1
Description:

Gets the height of the first element in the supplied ishObject. This method is an abstraction of ishObject.dimension.

Returns
Integer

The height of the element.

Parameters:
Name Type Description
margins Boolean

Include margins in the return result.

clientHeight Boolean

Exclude the horizontal scrollbars height from the result.

Example:
ish('selector').height();

indexOf(needle)

line 159
Description:

Gets the index of a specific Node in an ishObject

Returns
Number

Index of the Node in the ishObject. Returns -1 if not found.

Parameters:
Name Type Description
needle Node

The Node to find in the ishObject.

Example:
ish('selector').indexOf(Node);

nth(int)

line 120
Description:

Returns the item at the specified index in the ishObject.

Parameters:
Name Type Description
int Number

The index of the item in the ishObject.

Example:
ish('selector').nth(0); //gets the first node

off(event, fn)

line 57
Description:

Dettach handlers to the Node/s in the given ishObject. This method is just a wrapper for 'removeEventListener' so any valid Javascript event can be used. Its inclusion in the library is intended to save you writing loops to cover multiple event targets when hooking events.

Returns
ishObject

Method is chainable, returns the ish Object which called the method.

Parameters:
Name Type Description
event string

The type of event you're adding to the Node/s

fn function

The Node to find in the ish Object.

Example:
var fn = function(event) {
    //mousedown event
};
ish('selector').on('mousedown', mousedownHandler); //on
ish('selector').off('mousedown', fn); //off

offset()

line 277
Description:

Returns the left and top offset in pixels for the first element in the ishObject.

Returns
Object

An Object with values for left and top offsets in pixel values.

Example:
ish('selector').offset();

on(event, fn, delegate)

line 2
Description:

Attach handlers to the Node/s in the given ishObject. This method is just a wrapper for 'addeventListener' so any valid Javascript event can be used. It's inclusion in the library is intended to save you writing loops to cover multiple event targets when hooking events.

Returns
ishObject

Method is chainable, returns the ish Object which called the method.

Parameters:
Name Type Description
event String

The type of event you're adding to the Node/s

fn function

A callback to be fired when the event is triggered.

delegate String

A valid CSS selector to delegate the event to.

Example:
var fn = function(event) {
    //mousedown event
};
ish('selector').on('mousedown', fn);

removeClass(name)

line 28
Description:

Removes a class name from each Node in the given ishObject.

Returns
ishObject

Returns the ishObject which called it. Method is chainable.

Parameters:
Name Type Description
name String

The class name you wish to remove from the element/s.

Example:
ish('selector').removeClass('className');

trigger(type, data)

line 94
Description:

Triggers an event.

Returns
ishObject

Method is chainable, returns the ish Object which called the method.

Parameters:
Name Type Description
type string

The type of event to trigger.

data object

Any

Example:
var fn = function(event) {
    //mousedown event
};
ish('selector').on('mousedown', fn); //on
ish('selector').trigger('mousedown'); //fires mousedown

width(margins, clientHeight)

line 14
Description:

Gets the width of the first element in the supplied ishObject. This method is an abstraction of ish.fn.ishObject.dimension.

Returns
Integer

The height of the element.

Parameters:
Name Type Description
margins Boolean

Include margins in the return result.

clientHeight Boolean

Exclude the horizontal scrollbars height from the result.

Example:
ish('selector').width();