Author: sergeyhalipov
Date: 2007-10-26 11:57:11 -0400 (Fri, 26 Oct 2007)
New Revision: 3571
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/browser_info.js
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
trunk/ui/inputnumber-slider/src/main/resources/org/richfaces/renderkit/html/script/SliderScript.js
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
trunk/ui/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
Log:
Optimaze browser detection.
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/browser_info.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/browser_info.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/browser_info.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -2,26 +2,35 @@
window.RichFaces = {};
}
+RichFaces.MSIE = 0;
+RichFaces.FF = 1;
+RichFaces.OPERA = 2;
+RichFaces.NETSCAPE = 3;
+RichFaces.SAFARI = 4;
+RichFaces.KONQ = 5;
+
RichFaces.navigatorType = function () {
- if (navigator.userAgent.toLowerCase().indexOf("msie") >= 0 ||
- navigator.userAgent.toLowerCase().indexOf("explorer") >= 0)
- return "MSIE";
- if (navigator.userAgent.toLowerCase().indexOf("firefox") >= 0 ||
- navigator.userAgent.toLowerCase().indexOf("iceweasel") >= 0)
- return "FF";
- if (navigator.userAgent.toLowerCase().indexOf("opera") >= 0)
- return "OPERA";
- if (navigator.userAgent.toLowerCase().indexOf("netscape") >= 0)
- return "NETSCAPE";
- if (navigator.userAgent.toLowerCase().indexOf("safari") >= 0)
- return "SAFARI";
- if (navigator.userAgent.toLowerCase().indexOf("konqueror") >= 0)
- return "KONQUEROR";
+ var userAgent = navigator.userAgent.toLowerCase();
+ if (userAgent.indexOf("msie") >= 0 ||
+ userAgent.indexOf("explorer") >= 0)
+ return RichFaces.MSIE;
+ if (userAgent.indexOf("firefox") >= 0 ||
+ userAgent.indexOf("iceweasel") >= 0)
+ return RichFaces.FF;
+ if (userAgent.indexOf("opera") >= 0)
+ return RichFaces.OPERA;
+ if (userAgent.indexOf("netscape") >= 0)
+ return RichFaces.NETSCAPE;
+ if (userAgent.indexOf("safari") >= 0)
+ return RichFaces.SAFARI;
+ if (userAgent.indexOf("konqueror") >= 0)
+ return RichFaces.KONQ;
return "OTHER";
}
RichFaces.getOperaVersion = function () {
- var index = navigator.userAgent.toLowerCase().indexOf("opera");
+ var userAgent = navigator.userAgent.toLowerCase();
+ var index = userAgent.indexOf("opera");
if (index == -1) return;
- return parseFloat(navigator.userAgent.toLowerCase().substring(index+6));
+ return parseFloat(userAgent.substring(index+6));
}
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -37,7 +37,7 @@
}
if (this.mouseMoveProvidesButton && !Event.isLeftClick(event) &&
- RichFaces.navigatorType() != "MSIE") {
+ RichFaces.navigatorType() != RichFaces.MSIE) {
this.endDrag(event);
}
}
Modified:
trunk/ui/inputnumber-slider/src/main/resources/org/richfaces/renderkit/html/script/SliderScript.js
===================================================================
---
trunk/ui/inputnumber-slider/src/main/resources/org/richfaces/renderkit/html/script/SliderScript.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/inputnumber-slider/src/main/resources/org/richfaces/renderkit/html/script/SliderScript.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -293,13 +293,13 @@
Richfaces.createEvent("mouseup", this.mainTable, null, null).fire();
Event.stop(event);
}
- if (RichFaces.navigatorType() != "MSIE")
+ if (RichFaces.navigatorType() != RichFaces.MSIE)
Richfaces.createEvent("change", this.input, null, null).fire();
},
fireClickIfNeeded: function(event){
if ((this.prevMouseDownEvent.target != event.target
- && RichFaces.navigatorType() == "FF")
+ && RichFaces.navigatorType() == RichFaces.FF)
|| (RichFaces.getOperaVersion()
&& RichFaces.getOperaVersion() < 9.0
&& event.target.tagName.toLowerCase() != "div")) {
Modified:
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js
===================================================================
---
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -11,8 +11,8 @@
this.ch = options.chameleon;
this.items = new Array();
this.table = $
(containers.buttons.substr(containers.buttons.indexOf("buttons")+7));
- if (RichFaces.navigatorType() == "FF" ||
- RichFaces.navigatorType() == "NETSCAPE") {
+ if (RichFaces.navigatorType() == RichFaces.FF ||
+ RichFaces.navigatorType() == RichFaces.NETSCAPE) {
if (!this.fie)
this.table.style.display = "-moz-inline-box";
}
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -127,7 +127,7 @@
function getSizeElement() {
var element;
- if (RichFaces.navigatorType() != "OPERA" &&
document.compatMode=='CSS1Compat') {
+ if (RichFaces.navigatorType() != RichFaces.OPERA &&
document.compatMode=='CSS1Compat') {
element = document.documentElement;
} else {
element = document.body;
@@ -598,7 +598,7 @@
_left = parseInt(options.left, 10);
} else {
var cw = getSizeElement().clientWidth;
- if (RichFaces.navigatorType() == "OPERA")
+ if (RichFaces.navigatorType() == RichFaces.OPERA)
{
_left = (cw - eContentDiv.parentNode.getWidth()) / 2;
}
@@ -620,7 +620,7 @@
_top = parseInt(options.top, 10);
} else {
var cw = getSizeElement().clientHeight;
- if (RichFaces.navigatorType() == "OPERA")
+ if (RichFaces.navigatorType() == RichFaces.OPERA)
{
_top = (cw - eContentDiv.parentNode.getHeight()) / 2;
}
@@ -741,7 +741,7 @@
var eContentDiv = $(this.contentDiv);
// Avoid currentStyle bug in opera
- if (RichFaces.navigatorType() != "OPERA")
+ if (RichFaces.navigatorType() != RichFaces.OPERA)
{
newSize = Richfaces.getComputedStyleSize(eContentDiv, "width");
}
@@ -790,7 +790,7 @@
}
// Avoid currentStyle bug in opera
- if (RichFaces.navigatorType() != "OPERA")
+ if (RichFaces.navigatorType() != RichFaces.OPERA)
{
newSize = Richfaces.getComputedStyleSize(eContentDiv, "height");
}
@@ -950,7 +950,7 @@
Richfaces.showModalPanel = function (id, opts) {
var invoke =
- ("MSIE" == RichFaces.navigatorType()) ?
+ (RichFaces.MSIE == RichFaces.navigatorType()) ?
function(f) {
if (document.readyState != "complete") {
var args = arguments;
Modified:
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
===================================================================
---
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -47,7 +47,7 @@
switch_off.style.display="";
}
- if (RichFaces.navigatorType() == "MSIE"){
+ if (RichFaces.navigatorType() == RichFaces.MSIE){
/* if ($(this.panelId_head).clientWidth<$(this.panelId).clientWidth){
$(this.panelId_head).style.width=$(this.panelId).clientWidth-2+"px";
}*/
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -4,7 +4,7 @@
};
Suggestion.Base.prototype = {
baseInitialize: function(element, update, options) {
- this.isOpera = (RichFaces.navigatorType() == "OPERA"?true:false);
+ this.isOpera = (RichFaces.navigatorType() == RichFaces.OPERA?true:false);
this.element = $(element);
this.update = $(update);
this.hasFocus = false;
@@ -19,7 +19,7 @@
options.selection = update + "_selection";
- var needIframe = (RichFaces.navigatorType() == "MSIE");
+ var needIframe = (RichFaces.navigatorType() == RichFaces.MSIE);
if (needIframe) {
options.iframeId = update + "_iframe";
@@ -158,7 +158,7 @@
},
show: function() {
- if ("SAFARI" == RichFaces.navigatorType()) {
+ if (RichFaces.SAFARI == RichFaces.navigatorType()) {
this.wasScroll = false;
this.wasBlur = false;
if (!this.overflow)
@@ -171,7 +171,7 @@
},
hide: function() {
- if ("SAFARI" == RichFaces.navigatorType()) {
+ if (RichFaces.SAFARI == RichFaces.navigatorType()) {
if (this.wasScroll) {
this.wasScroll = false;
return;
@@ -381,7 +381,7 @@
if (!this.active) return;
var offsets = RichFaces.Position.calcOffsets(this.update);
- if (RichFaces.navigatorType() != "MSIE") {
+ if (RichFaces.navigatorType() != RichFaces.MSIE) {
offsets["x"] = 0;
offsets["y"] = 0;
}
@@ -405,7 +405,7 @@
},
onScroll: function(event) {
- if ("SAFARI" == RichFaces.navigatorType() && this.wasBlur ) {
+ if (RichFaces.SAFARI == RichFaces.navigatorType() && this.wasBlur ) {
if(this.element) {
this.element.focus();
this.wasScroll = true;
@@ -419,7 +419,7 @@
var realOffset = 0;
while (item && (item != scroll)) {
// Avoid bug in Safari. Details:
http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in...
- if ("SAFARI" == RichFaces.navigatorType() && "TR" ==
item.tagName.toUpperCase()) {
+ if (RichFaces.SAFARI == RichFaces.navigatorType() && "TR" ==
item.tagName.toUpperCase()) {
realOffset += document.getElementsByClassName("dr-sb-cell-padding",
item)[0].offsetTop;
}
else
@@ -429,7 +429,7 @@
}
var entryOffsetHeight;
- if ("SAFARI" == RichFaces.navigatorType()) {
+ if (RichFaces.SAFARI == RichFaces.navigatorType()) {
var tdElement = document.getElementsByClassName("dr-sb-cell-padding",
item)[0];
entryOffsetHeight = tdElement.offsetTop + tdElement.offsetHeight;
} else
Modified:
trunk/ui/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js
===================================================================
---
trunk/ui/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-10-26
15:01:40 UTC (rev 3570)
+++
trunk/ui/tabPanel/src/main/resources/org/richfaces/renderkit/html/scripts/tabPanel.js 2007-10-26
15:57:11 UTC (rev 3571)
@@ -1,6 +1,6 @@
if (!window.RichFaces) window.RichFaces = {};
-var RichFaces_FF_Loaded = (RichFaces.navigatorType() == "FF");
+var RichFaces_FF_Loaded = (RichFaces.navigatorType() == RichFaces.FF);
RichFaces.panelTabs={};