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)
Description:
Adds a class name to each Node in the given ishObject.
Parameters:
| Name | Type | Description |
|---|---|---|
| name |
|
The class name you wish to add to the element/s. |
Example:
ish('selector').addClass('className');
attr(name, value)
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 |
|
A valid CSS attribute selector. |
| value |
|
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)
Description:
Gets the CSS value of the first element in the supplied ishObject. Or sets the CSS value on all items in an ishObject.
Parameters:
| Name | Type | Description |
|---|---|---|
| prop |
|
The name of the CSS property in camelCase. eg. 'margin-left' would be passed as 'marginLeft'. |
| value |
|
Exclude the horizontal scrollbars height from the result. |
Example:
ish('selector').css();
dimension(type, margins, clientHeight)
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 |
|
'width' or 'height'. |
| margins |
|
Include margins in the return result. |
| clientHeight |
|
Exclude the horizontal scrollbars height from the result. |
Example:
ish('selector').width();
forEach(fn, scope)
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.
Parameters:
| Name | Type | Description |
|---|---|---|
| fn |
|
The callback function which will be called with each iteration |
| scope |
|
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)
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 |
|
The class name to test against the collection. |
Example:
ish('selector').hasClass('className');
height(margins, clientHeight)
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 |
|
Include margins in the return result. |
| clientHeight |
|
Exclude the horizontal scrollbars height from the result. |
Example:
ish('selector').height();
indexOf(needle)
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 |
|
The |
Example:
ish('selector').indexOf(Node);
nth(int)
Description:
Returns the item at the specified index in the ishObject.
Parameters:
| Name | Type | Description |
|---|---|---|
| int |
|
The index of the item in the |
Example:
ish('selector').nth(0); //gets the first node
off(event, fn)
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.
Parameters:
| Name | Type | Description |
|---|---|---|
| event |
|
The type of event you're adding to the Node/s |
| fn |
|
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()
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)
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.
Parameters:
| Name | Type | Description |
|---|---|---|
| event |
|
The type of event you're adding to the Node/s |
| fn |
|
A callback to be fired when the event is triggered. |
| delegate |
|
A valid CSS selector to delegate the event to. |
Example:
var fn = function(event) {
//mousedown event
};
ish('selector').on('mousedown', fn);
removeClass(name)
Description:
Removes a class name from each Node in the given ishObject.
Parameters:
| Name | Type | Description |
|---|---|---|
| name |
|
The class name you wish to remove from the element/s. |
Example:
ish('selector').removeClass('className');
trigger(type, data)
Description:
Triggers an event.
Parameters:
| Name | Type | Description |
|---|---|---|
| type |
|
The type of event to trigger. |
| data |
|
Any |
Example:
var fn = function(event) {
//mousedown event
};
ish('selector').on('mousedown', fn); //on
ish('selector').trigger('mousedown'); //fires mousedown
width(margins, clientHeight)
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 |
|
Include margins in the return result. |
| clientHeight |
|
Exclude the horizontal scrollbars height from the result. |
Example:
ish('selector').width();