pixeladmin.js is a core script that performs some initial setup and defines
basic PixelAdmin
object.
require(['px/pixeladmin', 'px/plugins/px-file'], function() {
...
});
PixelAdmin.methodName();
require(['px/pixeladmin'], function(px) {
px.methodName();
// or
window.PixelAdmin.methodName();
PixelAdmin.methodName();
});
You can access to an attribute of PixelAdmin object using the syntax:
PixelAdmin.attributeName
Attribute name | Description |
---|---|
isRtl | true if the <html> element has dir="rtl" attribute, otherwise false . |
isMobile | true if navigator.userAgent attribute contains mobile-specific string, otherwise false . |
isLocalStorageSupported | true if browser supports Local Storage, otherwise false . |
options |
Application-wide options:
|
You can call a public method of PixelAdmin object using the syntax:
PixelAdmin.methodName(argumentOne, argumentTwo)
Method name | Description |
---|---|
getScreenSize |
Returns current screen size. Returning values:
|
storage.set(key, value) |
Store key/value pair in the Local Storage. To store multiple key/value pairs, pass a hash object as a first parameter to the method. Note: If Local Storage is not supported by the browser, then values will be stored in the Cookies.
|
storage.get(key) |
Get value from the Local Storage by key.
To get multiple values, pass an array of keys as a first parameter to the method.
If key is not exists, then Note: If Local Storage is not supported by the browser, then values will be loaded from the Cookies.
|
cookies.set(key, value) |
Store key/value pair in the Cookies. To store multiple key/value pairs, pass a hash object as a first parameter to the method.
|
cookies.get(key) |
Get value from the Cookies by key.
To get multiple values, pass an array of keys as a first parameter to the method.
If key is not exists, then
|
pixeladmin.js script fires some events on window
object. You can subscribe on those events using the syntax:
$(window).on('px.event', function(e) {
// ...
});
Event | Description |
---|---|
load | This event is fired when the basic setup is completed. |
resize | Delayed resize event, fired when window resize is complete. |
resize.xs | This event is fired when screen size is changed to extra small. |
resize.sm | This event is fired when screen size is changed to small. |
resize.md | This event is fired when screen size is changed to medium. |
resize.lg | This event is fired when screen size is changed to large. |
resize.xl | This event is fired when screen size is changed to extra large. |
util.js script defines pxUtil
object that contains
utility methods.
pxUtil.methodName();
require(['px/util'], function(pxUtil) {
pxUtil.methodName();
});
You can call a public method of pxUtil object using the syntax:
pxUtil.methodName(argumentOne, argumentTwo)
Method name | Description |
---|---|
generateUniqueId | Returns unique ID. |
escapeRegExp(str) | Returns RegEx-safe string. |
hexToRgba(color, opacity) |
Convert HEX color to RGBA color with given opacity .
Returns string rgba(...) .
|
triggerResizeEvent | Trigger window resize event. Do not require jQuery. |
hasClass(elem, className) |
Returns true if the DOM elem are assigned the given className ,
otherwise returns false . Do not require jQuery.
|
addClass(elem, classes) |
Adds the specified classes to the DOM elem .
classes - One or more space-separated classes / array of classes
to be added to the class attribute of DOM elem .
Do not require jQuery.
|
removeClass(elem, classes) |
Removes the specified classes from the DOM elem .
classes - One or more space-separated classes / array of classes
to be removed from the class attribute of DOM elem .
Do not require jQuery.
|
toggleClass(elem, classes) |
Adds or removes the specified classes from the DOM elem ,
depending on the class's presence.
classes - One or more space-separated classes / array of classes
to be added/removed from the class attribute of DOM elem .
Do not require jQuery.
|