Hi James,
If you absolutely must have different view classes for phone, tablet,
and desktop (i.e. these widgets must differ by more than just CSS
meaning the JavaScript must be also be different) then I would want a
utility function to do the work for me.
I'd keep the utility in a file like named either
myApp/src/js/util.js
or
myApp/src/js/util/browser.js
With an API like
myApp.isMobile();
myApp.isTablet();
myApp.isDesktop();
You could even do something like the following after defining the
various product view classes if the isMobile and isTablet functions
can run when the JavaScript first executes
myApp.DeviceProductView =
myApp.isMobile() ?
myApp.MobileProductView :
myApp.isTablet() ?
myApp.TabletProductView :
myApp.DeviceProductView;
None of the above excites me too much as this is browser sniffing.
True responsive design is simply based on the size of the device. The
narrow view that is built with phones in mind will be used on the
desktop if the browser window is made narrow.
Peter