This block is for downloading the jQuery library and its extensions and enabling them on a page. Extensions are enabled via dependencies on the block elements.
modules.require(['jquery'], function($) {
console.log($);
});
| Element | Usage | Description |
|---|---|---|
| config | JS |
jQuery configuration. |
| event | JS |
Extensions for the jQuery event model. |
| Element | Name | Return type | Description |
|---|---|---|---|
| config | url | String |
String with the URL for connecting the jQuery library. |
| Element | Name | Description |
|---|---|---|
| event | pointerclick | Eliminates the delay of the click event on touch devices. |
| pointerover | Generated when the pointer on the input device is over an element. | |
| pointerenter | Generated when the pointer enters an element's active area. | |
| pointerdown | Generated when the input device enters the active button state. | |
| pointermove | Generated when the pointer's coordinates change. | |
| pointerup | Generated when exiting the active button state. | |
| pointerout | Generated when the pointer leaves the area over an element. | |
| pointerleave | Generated when the pointer leaves an element's active area. | |
| pointerpress | Generated on the pointerdown event. |
|
| pointerrelease | Generated on the pointerup and pointercancel events. |
|
| pointercancel | Generated when more pointer events are not expected to occur, or after generating the pointerdown event. |
The block is implemented in:
jsevent element in the jquery blockThis element implements support for additional types of jQuery events. The additional types are enabled using the corresponding values of the type modifier.
type modifierProvides a set of polyfills that implement the abstraction layer over jQuery events on input devices. This allows you to create a shared logic for different platforms (desktop, phone, etc.) and supplement it with methods specific to the device type.
Each polyfill adds a set of pointer events for creating hardware agnostic logic.
All the pointer events are jQuery user events. Subscribe to pointer events in the standard way:
modules.define('pointer-test', ['i-bem-dom'], function(provide, bemDom) {
provide(bemDom.declBlock(this.name, /** @lends pointer-test.prototype */ {
onSetMod : {
js : {
inited : function() {
// subscribing to pointerpress on the block itself during initialization
this._domEvents().on('pointerpress', this._onPress);
}
}
},
_onPress : function(e) {
console.log(e.type);
// subscribing to pointerrelease when calling the pointerpress handler
this._domEvents().on('pointerrelease', this._onRelease);
},
_onRelease : function(e) {
console.log(e.type);
// unsubscribing from pointerrelease when calling the pointerrelease handler
this._domEvents().un('pointerrelease', this._onRelease);
}
}));
});
Different polyfills are enabled depending on the modifier's value.
type modifier with the pointer valueThis is a modifier for enabling all types of pointer events. It doesn't introduce additional logic.
type modifier with the pointerclick valueEnables a polyfill that implements the pointerclick event.
pointerclick eventGenerated for a left click or a touch on the device screen. Using pointerclick eliminates the delay of the click event on touch devices.
type modifier with the pointernative valueEnables a polyfill that implements the basic functionality of the W3C Pointer Events model.
The following set of events is available with the modifier:
pointerover eventGenerated:
pointerdown event for devices that don't support hover.pointerenter eventGenerated:
pointerdown event for devices that don't support hover.This event is the same as pointerover, but it doesn't bubble.
pointerdown eventGenerated when the input device is in the active buttons state.
pointermove eventGenerated when the pointer's coordinates change.
pointerup eventGenerated when exiting the active button state:
pointerout eventGenerated when the pointer leaves the element's active area:
pointerup and pointercancel events for devices that don't support hover. For example, when the stylus or finger leaves the device's working area.pointerleave eventGenerated when the pointer leaves the element's active area:
pointerup and pointercancel events for devices that don't support hover.This event is the same as pointerout, but it doesn't bubble.
pointercancel eventGenerated when:
pointerdown event has been generated, if the pointer was used for zooming the page.For example, this event is generated when changing the device orientation while it is in the active buttons state. Or after reaching the maximum number of simultaneous clicks on the device.
After generating the pointercancel event, the pointerout and pointerleave events are generated in succession.
type modifier with the pointerpressrelease valueEnables a polyfill that implements the pointerpress and pointerrelease events. The polyfill uses Pointer Events.
pointerpress eventGenerated on the pointerdown event.
pointerrelease eventGenerated on the pointerup and pointercancel events.