css - How to add condition in Extjs4 tpl for detecting current browser -
i working in extjs4. displaying tpl time, projectname , projectnumber.i have tpl as-
tpl : '<tpl for=".">'+ '<div class = "timer-icon"><img class="tasktimericoncls" src="./ui-inf/images/s.gif" onclick="ext.getcmp(\'' + me.id + '\').showtimerwindow()">' + '<span> <span id="timerid"> {hrsworked}</span><br><a onclick="ext.getcmp(\'' + me.id + '\').showtimerwindow()">stop timer</a></span></div>' + '<div class = "task-text-cls"><span id="tasktext">{projectname}  ({formattedprojectnumber})</span><br>{title}</div>' + '</tpl>', and class "task-text-cls" have css as-
.task-text-cls { color: white; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 260px; padding: 0 0 0 10px; font-size: 12px; position:relative; top:14%; } its working correctly in ie,firefox giving issue in chrome[more space getting included between fields]. chrome requires width 125px work properly. in extjs tpl, how detect current browser , how apply conditional css.
extjs adds css class indicating browser (engine) html body element, such as:
- x-webkit
- x-chrome
- x-gecko
- x-ie
- x-ie8
- ...and on...
you can see e.g. in chrome's developer tools, when inspect html:

in css file can use class create browser-based selector, e.g.:
.x-chrome .task-text-cls { width: 125px; } if want change template's markup depending on browser, can use corresponding properties on ext object, such ext.ischrome:
tpl: ( '<tpl for=".">' + (ext.ischrome ? '<div class="chrome">' : '<div>') + '<img src="test.jpg" />' + '</div>' '</tpl>' )
Comments
Post a Comment