Skip to content

Commit

Permalink
- updated the Browser properties checks to not use the compatibility…
Browse files Browse the repository at this point in the history
… ones.
  • Loading branch information
kamicane committed Mar 24, 2010
1 parent 4a9e6d7 commit 9e95d8c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core.js
Expand Up @@ -15,7 +15,7 @@ inspiration:
- Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)
- Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
provides: [Core, MooTools, Type, typeOf, instanceOf, Hash.Base]
provides: [Core, MooTools, Type, typeOf, instanceOf]
...
*/
Expand Down
10 changes: 5 additions & 5 deletions Source/Element/Element.Dimensions.js
Expand Up @@ -60,7 +60,7 @@ Element.implement({
getOffsetParent: function(){
var element = this;
if (isBody(element)) return null;
if (!Browser.Engine.trident) return element.offsetParent;
if (!Browser.ie) return element.offsetParent;
while ((element = element.parentNode) && !isBody(element)){
if (styleString(element, 'position') != 'static') return element;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ Element.implement({
position.x += element.offsetLeft;
position.y += element.offsetTop;

if (Browser.Engine.gecko){
if (Browser.firefox){
if (!borderBox(element)){
position.x += leftBorder(element);
position.y += topBorder(element);
Expand All @@ -99,14 +99,14 @@ Element.implement({
position.x += leftBorder(parent);
position.y += topBorder(parent);
}
} else if (element != this && Browser.Engine.webkit){
} else if (element != this && Browser.safari){
position.x += leftBorder(element);
position.y += topBorder(element);
}

element = element.offsetParent;
}
if (Browser.Engine.gecko && !borderBox(this)){
if (Browser.firefox && !borderBox(this)){
position.x -= leftBorder(this);
position.y -= topBorder(this);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ Element.implement({
[Document, Window].call('implement', {

getSize: function(){
if (Browser.Engine.presto || Browser.Engine.webkit){
if (Browser.opera || Browser.safari){
var win = this.getWindow();
return {x: win.innerWidth, y: win.innerHeight};
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Element/Element.Event.js
Expand Up @@ -148,7 +148,7 @@ Element.Events = new Hash({
},

mousewheel: {
base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel'
base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
}

});
Expand Down
10 changes: 5 additions & 5 deletions Source/Element/Element.Style.js
Expand Up @@ -29,7 +29,7 @@ Element.Properties.opacity = {
}
}
if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;
if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
if (Browser.ie) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
this.style.opacity = opacity;
this.store('opacity', opacity);
},
Expand All @@ -53,7 +53,7 @@ Element.implement({
setStyle: function(property, value){
switch (property){
case 'opacity': return this.set('opacity', parseFloat(value));
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
case 'float': property = (Browser.ie) ? 'styleFloat' : 'cssFloat';
}
property = property.camelCase();
if (typeOf(value) != 'string'){
Expand All @@ -72,7 +72,7 @@ Element.implement({
getStyle: function(property){
switch (property){
case 'opacity': return this.get('opacity');
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
case 'float': property = (Browser.ie) ? 'styleFloat' : 'cssFloat';
}
property = property.camelCase();
var result = this.style[property];
Expand All @@ -90,15 +90,15 @@ Element.implement({
var color = result.match(/rgba?\([\d\s,]+\)/);
if (color) result = result.replace(color[0], color[0].rgbToHex());
}
if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(result, 10)))){
if (Browser.opera || (Browser.ie && !$chk(parseInt(result, 10)))){
if (property.test(/^(height|width)$/)){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
}, this);
return this['offset' + property.capitalize()] - size + 'px';
}
if ((Browser.Engine.presto) && String(result).test('px')) return result;
if ((Browser.opera) && String(result).test('px')) return result;
if (property.test(/(border(.+)Width|margin|padding)/)) return '0px';
}
return result;
Expand Down
14 changes: 7 additions & 7 deletions Source/Element/Element.js
Expand Up @@ -236,7 +236,7 @@ if (window.$$ == null) Window.implement({$$: function(selector){
(function(){

var collected = {}, storage = {};
var props = {input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value'};
var props = {input: 'checked', option: 'selected', textarea: (Browser.safari && Browser.version == 2) ? 'innerHTML' : 'value'};

var get = function(uid){
return (storage[uid] || (storage[uid] = {}));
Expand All @@ -246,7 +246,7 @@ var clean = function(item, retain){
if (!item) return;
var uid = item.uid;
if (retain !== true) retain = false;
if (Browser.Engine.trident){
if (Browser.ie){
if (item.clearAttributes){
var clone = retain && item.cloneNode(false);
item.clearAttributes();
Expand All @@ -267,7 +267,7 @@ var clean = function(item, retain){

var purge = function(){
Hash.each(collected, clean);
if (Browser.Engine.trident) Array.from(document.getElementsByTagName('object')).each(clean);
if (Browser.ie) Array.from(document.getElementsByTagName('object')).each(clean);
if (window.CollectGarbage) CollectGarbage();
collected = storage = null;
};
Expand All @@ -277,7 +277,7 @@ var attributes = {
'class': 'className',
'for': 'htmlFor',
'defaultValue': 'defaultValue',
'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'
'text': (Browser.ie || (Browser.safari && Browser.version <= 2)) ? 'innerText' : 'textContent'
};
var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];
var camels = [
Expand Down Expand Up @@ -540,7 +540,7 @@ Element.implement({
var clone = this.cloneNode(contents);
var clean = function(node, element){
if (!keepid) node.removeAttribute('id');
if (Browser.Engine.trident){
if (Browser.ie){
node.clearAttributes();
node.mergeAttributes(element);
node.removeAttribute('uid');
Expand Down Expand Up @@ -692,7 +692,7 @@ Element.Properties.html = (function(){
var html = {
set: function(){
var html = Array.flatten(arguments).join('');
var wrap = Browser.Engine.trident && translations[this.get('tag')];
var wrap = Browser.ie && translations[this.get('tag')];
if (wrap){
var first = wrapper;
first.innerHTML = wrap[1] + html + wrap[2];
Expand All @@ -709,7 +709,7 @@ Element.Properties.html = (function(){
return html;
})();

if (Browser.Engine.webkit && Browser.Engine.version < 420) Element.Properties.text = {
if (Browser.safari && Browser.version <= 2) Element.Properties.text = {
get: function(){
if (this.innerText) return this.innerText;
var temp = this.ownerDocument.newElement('div', {html: this.innerHTML}).inject(this.ownerDocument.body);
Expand Down
2 changes: 1 addition & 1 deletion Source/Request/Request.HTML.js
Expand Up @@ -33,7 +33,7 @@ Request.HTML = new Class({

return Function.stab(function(){
var root = '<root>' + text + '</root>', doc;
if (Browser.Engine.trident){
if (Browser.ie){
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = false;
doc.loadXML(root);
Expand Down
2 changes: 1 addition & 1 deletion Source/Types/Event.js
Expand Up @@ -55,7 +55,7 @@ var Event = new Type('Event', function(event, win){
if (!(function(){
while (related && related.nodeType == 3) related = related.parentNode;
return true;
}).create({attempt: Browser.Engine.gecko})()) related = false;
}).create({attempt: Browser.firefox})()) related = false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Types/Hash.js
Expand Up @@ -7,7 +7,7 @@ description: Contains Hash Prototypes. Provides a means for overcoming the JavaS
license: MIT-style license.
requires: Hash.Base
requires: Type
provides: Hash
Expand Down Expand Up @@ -139,4 +139,4 @@ Hash.implement({

});

Hash.alias({indexOf: 'keyOf', contains: 'hasValue'});
Hash.alias({indexOf: 'keyOf', contains: 'hasValue'});
4 changes: 2 additions & 2 deletions Source/Utilities/DomReady.js
Expand Up @@ -33,15 +33,15 @@ Element.Events.domready = {

window.addEvent('load', domready);

if (Browser.Engine.trident){
if (Browser.ie){
var temp = document.createElement('div');
(function(){
(Function.stab(function(){
temp.doScroll(); // Technique by Diego Perini
return document.id(temp).inject(document.body).set('html', 'temp').dispose();
})) ? domready() : arguments.callee.delay(50);
})();
} else if (Browser.Engine.webkit && Browser.Engine.version < 525){
} else if (Browser.safari && Browser.version < 4){
(function(){
(['loaded', 'complete'].contains(document.readyState)) ? domready() : arguments.callee.delay(50);
})();
Expand Down
2 changes: 1 addition & 1 deletion Source/Utilities/Swiff.js
Expand Up @@ -66,7 +66,7 @@ var Swiff = new Class({
}

params.flashVars = Hash.toQueryString(vars);
if (Browser.Engine.trident){
if (Browser.ie){
properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
params.movie = path;
} else {
Expand Down

0 comments on commit 9e95d8c

Please sign in to comment.