Saturday, March 17, 2018
Tuesday, February 13, 2018
Salesforce Lightning: What browser am I using? What version is my browser?
You can use $Browser global value provider to return information about the hardware and operating system of the browser accessing the application as described in the link below:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_browser_value_provider.htm
But it cannot be used to detect the browser type or version number.
You can use the below code to detect the browser on which you are running your Lightning application. Here, I am checking whether I am on Internet Explorer or not:
checkBrowser: function (component) {
var browserType = navigator.sayswho= (function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
}
M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
return M.join(' ');
})();
if (browserType.startsWith("IE")) {
component.set("v.isIE", true);
}
}
If the value of isIE attribute is true, then you are running on Internet Explorer. Similarly you can check for Chrome, Firefox, Opera and other browsers.
Thursday, January 4, 2018
Lightning: Star rating component
This is a simple, highly customizable star rating component.
Attributes:
value
: this is the actual value which represents the value of ratingreadonly
: when set to true, the rating cannot be edited.To use this component:
<c:StarRating value="2" readonly="false"/>
Refer the github link for the code:
https://github.com/iamsonal/Star-Rating
Tuesday, December 19, 2017
LockerService
The LockerService architectural layer enhances security by isolating individual Lightning components in their own containers and enforcing coding best practices.
- LockerService implicitly enables JavaScript ES5 strict mode.
- A component can only traverse the DOM and access elements created by a component in the same namespace. You can’t use
component.find("button1").getElement()
to access the DOM element created by <lightning:button>. - LockerService applies restrictions to global references. LockerService provides secure versions of non-intrinsic objects, such as window. For example, the secure version of window is SecureWindow.
References:
LockerService API Viewer app: http://documentation.auraframework.org/lockerApiTest/index.app?aura.mode=DEV
Sunday, December 3, 2017
Subscribe to:
Posts (Atom)