3 The Browser Core. Contains Browser initialization, Window and Document, and the Browser Hash.
9 var Browser = new Hash({
10 Engine: {name: 'unknown', version: ''},
11 Platform: {name: (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()},
12 Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)},
16 if (window.opera) Browser.Engine = {name: 'presto', version: (document.getElementsByClassName) ? 950 : 925};
17 else if (window.ActiveXObject) Browser.Engine = {name: 'trident', version: (window.XMLHttpRequest) ? 5 : 4};
18 else if (!navigator.taintEnabled) Browser.Engine = {name: 'webkit', version: (Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419};
19 else if (document.getBoxObjectFor != null) Browser.Engine = {name: 'gecko', version: (document.getElementsByClassName) ? 19 : 18};
20 Browser.Engine[Browser.Engine.name] = Browser.Engine[Browser.Engine.name + Browser.Engine.version] = true;
22 if (window.orientation != undefined) Browser.Platform.name = 'ipod';
24 Browser.Platform[Browser.Platform.name] = true;
26 Browser.Request = function(){
27 return $try(function(){
28 return new XMLHttpRequest();
30 return new ActiveXObject('MSXML2.XMLHTTP');
34 Browser.Features.xhr = !!(Browser.Request());
36 Browser.Plugins.Flash = (function(){
37 var version = ($try(function(){
38 return navigator.plugins['Shockwave Flash'].description;
40 return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
41 }) || '0 r0').match(/\d+/g);
42 return {version: parseInt(version[0] || 0 + '.' + version[1] || 0), build: parseInt(version[2] || 0)};
46 if (!text) return text;
47 if (window.execScript){
48 window.execScript(text);
50 var script = document.createElement('script');
51 script.setAttribute('type', 'text/javascript');
53 document.head.appendChild(script);
54 document.head.removeChild(script);
61 var $uid = (Browser.Engine.trident) ? function(item){
62 return (item.uid || (item.uid = [Native.UID++]))[0];
64 return item.uid || (item.uid = Native.UID++);
67 var Window = new Native({
71 legacy: (Browser.Engine.trident) ? null: window.Window,
73 initialize: function(win){
77 if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2
78 win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {};
80 var doc = win.document;
82 return $extend(win, Window.Prototype);
85 afterImplement: function(property, value){
86 window[property] = Window.Prototype[property] = value;
91 Window.Prototype = {$family: {name: 'window'}};
95 var Document = new Native({
99 legacy: (Browser.Engine.trident) ? null: window.Document,
101 initialize: function(doc){
103 doc.head = doc.getElementsByTagName('head')[0];
104 doc.html = doc.getElementsByTagName('html')[0];
105 if (Browser.Engine.trident4) $try(function(){
106 doc.execCommand("BackgroundImageCache", false, true);
108 return $extend(doc, Document.Prototype);
111 afterImplement: function(property, value){
112 document[property] = Document.Prototype[property] = value;
117 Document.Prototype = {$family: {name: 'document'}};
119 new Document(document);