00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 @import "CPEvent.j"
00024 @import "CPPlatform.j"
00025
00026
00027 CPUnknownBrowserEngine = 0;
00028 CPGeckoBrowserEngine = 1;
00029 CPInternetExplorerBrowserEngine = 2;
00030 CPKHTMLBrowserEngine = 3;
00031 CPOperaBrowserEngine = 4;
00032 CPWebKitBrowserEngine = 5;
00033
00034
00035 CPMacOperatingSystem = 0;
00036 CPWindowsOperatingSystem = 1;
00037 CPOtherOperatingSystem = 2;
00038
00039
00040 CPCSSRGBAFeature = 1 << 5;
00041
00042 CPHTMLCanvasFeature = 1 << 6;
00043 CPHTMLContentEditableFeature = 1 << 7;
00044 CPHTMLDragAndDropFeature = 1 << 8;
00045
00046 CPJavascriptInnerTextFeature = 1 << 9;
00047 CPJavascriptTextContentFeature = 1 << 10;
00048 CPJavascriptClipboardEventsFeature = 1 << 11;
00049 CPJavascriptClipboardAccessFeature = 1 << 12;
00050 CPJavaScriptCanvasDrawFeature = 1 << 13;
00051 CPJavaScriptCanvasTransformFeature = 1 << 14;
00052
00053 CPVMLFeature = 1 << 15;
00054
00055 CPJavascriptRemedialKeySupport = 1 << 16;
00056 CPJavaScriptShadowFeature = 1 << 20;
00057
00058 CPJavaScriptNegativeMouseWheelValues = 1 << 22;
00059 CPJavaScriptMouseWheelValues_8_15 = 1 << 23
00060
00061 CPOpacityRequiresFilterFeature = 1 << 24;
00062
00063
00064 CPInputTypeCanBeChangedFeature = 1 << 25;
00065 CPHTML5DragAndDropSourceYOffBy1 = 1 << 26;
00066
00067
00068
00069
00070 var USER_AGENT = "",
00071 PLATFORM_ENGINE = CPUnknownBrowserEngine,
00072 PLATFORM_FEATURES = 0;
00073
00074
00075
00076 PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
00077
00078 if (typeof window != "undfined" && typeof window.navigator != "undefined")
00079 USER_AGENT = window.navigator.userAgent;
00080
00081
00082 if (window.opera)
00083 {
00084 PLATFORM_ENGINE = CPOperaBrowserEngine;
00085
00086 PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
00087 }
00088
00089
00090 else if (window.attachEvent)
00091 {
00092 PLATFORM_ENGINE = CPInternetExplorerBrowserEngine;
00093
00094
00095 PLATFORM_FEATURES |= CPVMLFeature;
00096 PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
00097 PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
00098
00099 PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature;
00100
00101 PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature;
00102 }
00103
00104
00105 else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
00106 {
00107 PLATFORM_ENGINE = CPWebKitBrowserEngine;
00108
00109
00110 PLATFORM_FEATURES |= CPCSSRGBAFeature;
00111 PLATFORM_FEATURES |= CPHTMLContentEditableFeature;
00112
00113 if (USER_AGENT.indexOf("Chrome") === -1)
00114 PLATFORM_FEATURES |= CPHTMLDragAndDropFeature;
00115
00116 PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature;
00117 PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature;
00118 PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
00119
00120 var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length,
00121 versionEnd = USER_AGENT.indexOf(" ", versionStart),
00122 versionString = USER_AGENT.substring(versionStart, versionEnd),
00123 versionDivision = versionString.indexOf('.'),
00124 majorVersion = parseInt(versionString.substring(0, versionDivision)),
00125 minorVersion = parseInt(versionString.substr(versionDivision + 1));
00126
00127 if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound)
00128 PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
00129
00130
00131
00132 if (![CPPlatform isBrowser])
00133 PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
00134
00135 if (majorVersion < 532 || (majorVersion === 532 && minorVersion < 6))
00136 PLATFORM_FEATURES |= CPHTML5DragAndDropSourceYOffBy1;
00137 }
00138
00139
00140 else if (USER_AGENT.indexOf("KHTML") != -1)
00141 {
00142 PLATFORM_ENGINE = CPKHTMLBrowserEngine;
00143 }
00144
00145
00146 else if (USER_AGENT.indexOf("Gecko") !== -1)
00147 {
00148 PLATFORM_ENGINE = CPGeckoBrowserEngine;
00149
00150 PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
00151
00152 var index = USER_AGENT.indexOf("Firefox"),
00153 version = (index === -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1));
00154
00155 if (version >= 3.0)
00156 PLATFORM_FEATURES |= CPCSSRGBAFeature;
00157
00158 if (version < 3.0)
00159 PLATFORM_FEATURES |= CPJavaScriptMouseWheelValues_8_15;
00160 }
00161
00162
00163 if (typeof document != "undefined")
00164 {
00165 var canvasElement = document.createElement("canvas");
00166
00167 if (canvasElement && canvasElement.getContext)
00168 {
00169 PLATFORM_FEATURES |= CPHTMLCanvasFeature;
00170
00171
00172 var context = document.createElement("canvas").getContext("2d");
00173
00174 if (context && context.setTransform && context.transform)
00175 PLATFORM_FEATURES |= CPJavaScriptCanvasTransformFeature;
00176 }
00177
00178 var DOMElement = document.createElement("div");
00179
00180
00181 if (DOMElement.innerText != undefined)
00182 PLATFORM_FEATURES |= CPJavascriptInnerTextFeature;
00183 else if (DOMElement.textContent != undefined)
00184 PLATFORM_FEATURES |= CPJavascriptTextContentFeature;
00185 }
00186
00187 function CPFeatureIsCompatible(aFeature)
00188 {
00189 return PLATFORM_FEATURES & aFeature;
00190 }
00191
00192 function CPBrowserIsEngine(anEngine)
00193 {
00194 return PLATFORM_ENGINE === anEngine;
00195 }
00196
00197 function CPBrowserIsOperatingSystem(anOperatingSystem)
00198 {
00199 return OPERATING_SYSTEM === anOperatingSystem;
00200 }
00201
00202 OPERATING_SYSTEM = CPOtherOperatingSystem;
00203
00204 if (USER_AGENT.indexOf("Mac") !== -1)
00205 {
00206 OPERATING_SYSTEM = CPMacOperatingSystem;
00207
00208 CPPlatformActionKeyMask = CPCommandKeyMask;
00209
00210 CPUndoKeyEquivalent = @"z";
00211 CPRedoKeyEquivalent = @"Z";
00212
00213 CPUndoKeyEquivalentModifierMask = CPCommandKeyMask;
00214 CPRedoKeyEquivalentModifierMask = CPCommandKeyMask;
00215 }
00216 else
00217 {
00218 if (USER_AGENT.indexOf("Windows") !== -1)
00219 OPERATING_SYSTEM = CPWindowsOperatingSystem;
00220
00221 CPPlatformActionKeyMask = CPControlKeyMask;
00222
00223 CPUndoKeyEquivalent = @"z";
00224 CPRedoKeyEquivalent = @"y";
00225
00226 CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
00227 CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
00228 }