Skip to content

Commit

Permalink
Merge branch 'codeReview' into 1.3wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomcosta committed Apr 3, 2010
2 parents 92f0eb3 + 3e5f40a commit 3c37cd3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
16 changes: 13 additions & 3 deletions Source/Element/Element.Style.js
Expand Up @@ -14,10 +14,16 @@ provides: Element.Style
...
*/

(function(){

var html = document.html;

Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};

var hasFilter = (html.style.filter != null);

Element.Properties.opacity = {

set: function(opacity, novisibility){
Expand All @@ -29,7 +35,7 @@ Element.Properties.opacity = {
}
}
if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;
if (Browser.ie) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
if (hasFilter) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
this.style.opacity = opacity;
this.store('opacity', opacity);
},
Expand All @@ -40,6 +46,8 @@ Element.Properties.opacity = {

};

var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';

Element.implement({

setOpacity: function(value){
Expand All @@ -53,7 +61,7 @@ Element.implement({
setStyle: function(property, value){
switch (property){
case 'opacity': return this.set('opacity', parseFloat(value));
case 'float': property = (Browser.ie) ? 'styleFloat' : 'cssFloat';
case 'float': property = floatName;
}
property = property.camelCase();
if (typeOf(value) != 'string'){
Expand All @@ -72,7 +80,7 @@ Element.implement({
getStyle: function(property){
switch (property){
case 'opacity': return this.get('opacity');
case 'float': property = (Browser.ie) ? 'styleFloat' : 'cssFloat';
case 'float': property = floatName;
}
property = property.camelCase();
var result = this.style[property];
Expand Down Expand Up @@ -146,3 +154,5 @@ Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, bor
Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
});

})();
10 changes: 8 additions & 2 deletions Source/Element/Element.js
Expand Up @@ -21,7 +21,7 @@ var Element = function(tag, props){

if (!props) props = {};

if (!tag.test(/^\w+$/)){
if (!tag.test(/^[\w-]+$/)){
var parsed = Slick.parse(tag).expressions[0][0];
tag = (parsed.tag == '*') ? 'div' : parsed.tag;
if (parsed.id && props.id == null) props.id = parsed.id;
Expand Down Expand Up @@ -679,6 +679,12 @@ Element.Properties.tag = {
};

Element.Properties.html = (function(){

var tableTest = Function.stab(function(){
var table = document.createElement('table');
table.innerHTML = '<tr><td></td></tr>';
});

var wrapper = document.createElement('div');

var translations = {
Expand All @@ -692,7 +698,7 @@ Element.Properties.html = (function(){
var html = {
set: function(){
var html = Array.flatten(arguments).join('');
var wrap = Browser.ie && translations[this.get('tag')];
var wrap = (!tableTest && translations[this.get('tag')]);
if (wrap){
var first = wrapper;
first.innerHTML = wrap[1] + html + wrap[2];
Expand Down
2 changes: 1 addition & 1 deletion Source/Types/Number.js
Expand Up @@ -21,7 +21,7 @@ Number.implement({
},

round: function(precision){
precision = Math.pow(10, precision || 0);
precision = Math.pow(10, precision || 0).toFixed(precision < 0 ? Math.abs(precision) : 0);
return Math.round(this * precision) / precision;
},

Expand Down

0 comments on commit 3c37cd3

Please sign in to comment.