Methods
-
<static> attr(name, value) → {String|caph.window}
-
Gets the value of an attribute for the window or sets a attribute for the window.
Parameters:
Name Type Argument Description name
String The name of the attribute to get or set.
value
String <optional>
A value to set for the attribute. If not passed, gets the value of given name parameter attribute for the window.
- Since:
-
- 2.0.0
Returns:
If value parameter is passed, the current object. If not, the value of an attribute for the window.
- Type
- String | caph.window
Example
caph.window.attr('data', 'another ' + caph.window.attr('data'));
-
<static> bind(type, listener, capture) → {caph.window}
-
Attaches a handler to an event for the window.
Parameters:
Name Type Argument Description type
String A string containing a DOM event types, such as 'click' or 'submit,' or custom event names.
listener
function A function to execute each time the event is triggered.
capture
Boolean <optional>
Indicates that the user wishes to initiate capture.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.window
Example
caph.window.bind('click', function(event) { console.log('click!'); });
-
<static> height() → {Number}
-
Gets the current height for the window.
- Since:
-
- 2.0.0
Returns:
- Type
- Number
Example
var height = caph.window.height();
-
<static> outerHeight() → {Number}
-
Gets the current outer height for the window.
- Since:
-
- 2.0.0
Returns:
- Type
- Number
Example
var outerHeight = caph.window.outerHeight();
-
<static> outerWidth() → {Number}
-
Gets the current outer width for the window.
- Since:
-
- 2.0.0
Returns:
- Type
- Number
Example
var outerWidth = caph.window.outerWidth();
-
<static> removeAttr(name) → {caph.window}
-
Removes an attribute from the window.
Parameters:
Name Type Description name
String The name of the attribute(s) to remove.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.window
Example
caph.window.removeAttr('data');
-
<static> scrollLeft(value) → {Number|caph.window}
-
Gets the current horizontal position of the scroll bar for the window or sets the horizontal position of the scroll bar for the window.
Parameters:
Name Type Argument Description value
Number <optional>
An integer indicating the new position to set the scroll bar to.
- Since:
-
- 2.0.0
Returns:
If value parameter is passed, the current object. If not, an integer indicating the current horizontal position of the scroll bar for the window.
- Type
- Number | caph.window
Example
caph.window.scrollLeft(caph.window.scrollLeft() + 100);
-
<static> scrollTop(value) → {Number|caph.window}
-
Gets the current vertical position of the scroll bar for the window or sets the vertical position of the scroll bar for the window.
Parameters:
Name Type Argument Description value
Number <optional>
An integer indicating the new position to set the scroll bar to.
- Since:
-
- 2.0.0
Returns:
If value parameter is passed, the current object. If not, an integer indicating the current vertical position of the scroll bar for the window.
- Type
- Number | caph.window
Example
caph.window.scrollTop(caph.window.scrollTop() + 100);
-
<static> trigger(type, prop) → {caph.window}
-
Executes all handlers attached to the window for the given event type.
Parameters:
Name Type Argument Description type
String A string containing a DOM event types, such as 'click' or 'submit,' or custom event names.
prop
Object <optional>
Additional parameters to pass along to the event handler.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.window
Example
caph.window.bind('click', function(event) { console.log('click!'); }); caph.window.trigger('click'); caph.window.trigger('click', { clientX: 10, clientY: 10 });
-
<static> unbind(type) → {caph.window}
-
Removes attached handlers to an event for the window.
Parameters:
Name Type Argument Description type
String <optional>
A string containing a DOM event types, such as 'click' or 'submit,' or custom event names. If not passed, all event types are removed.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.window
Example
caph.window.bind('click', function(event) { console.log('click!'); }); caph.window.bind('keydown', function(event) { console.log('keydown!'); }); caph.window.bind('keyup', function(event) { console.log('keyup'); }); caph.window.unbind('click'); caph.window.unbind(); // remove all
-
<static> width() → {Number}
-
Gets the current width for the window.
- Since:
-
- 2.0.0
Returns:
- Type
- Number
Example
var width = caph.window.width();