Skip to content

Commit

Permalink
Added IE9 support which fixed OscarGodson#5,
Browse files Browse the repository at this point in the history
Note: added a _isIE() function but it should not be used if possible. Where I used it to fix the height issue in preview mode is because I couldn't find where the 2px was coming from. All values of height, padding, offsetHeight, etc were exactly the same as Chrome and Firefox.
  • Loading branch information
OscarGodson committed Mar 3, 2012
1 parent 56fc1d7 commit 6aa615f
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions epiceditor.js
Expand Up @@ -79,7 +79,9 @@
var b = parseInt(_getStyle(el,'border-left-width'))+parseInt(_getStyle(el,'border-right-width'))
, p = parseInt(_getStyle(el,'padding-left'))+parseInt(_getStyle(el,'padding-right'))
, w = el.offsetWidth
, t = b+p+w;
//For IE in case no border is set and it defaults to "medium"
if(isNaN(b)){ var b = 0; }
var t = b+p+w;
return t;
}

Expand All @@ -92,7 +94,9 @@
var b = parseInt(_getStyle(el,'border-top-width'))+parseInt(_getStyle(el,'border-bottom-width'))
, p = parseInt(_getStyle(el,'padding-top'))+parseInt(_getStyle(el,'padding-bottom'))
, w = el.offsetHeight
, t = b+p+w;
//For IE in case no border is set and it defaults to "medium"
if(isNaN(b)){ var b = 0; }
var t = b+p+w;
return t;
}

Expand Down Expand Up @@ -121,6 +125,22 @@
headID.appendChild(cssNode);
}

/**
* Will return the version number if the browser is IE. If not will return -1
* TRY NEVER TO USE THIS AND USE FEATURE DETECTION IF POSSIBLE
* @returns {Number} -1 if false or the version number if true
*/
function _isIE(){
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer'){
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}

/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param {boolean} [deepMerge=false] If true, will deep merge meaning it will merge sub-objects like {obj:obj2{foo:'bar'}}
Expand Down Expand Up @@ -320,6 +340,11 @@
this.previewer.style.width = this.element.offsetWidth - _outerWidth(this.previewer) - widthDiff +'px';
this.previewer.style.height = this.element.offsetHeight - _outerHeight(this.previewer) - heightDiff +'px';

//FIXME figure out why it needs +2 px
if(_isIE() > -1){
this.previewer.style.height = parseInt(_getStyle(this.previewer,'height'))+2;
}

//If there is a file to be opened with that filename and it has content...
this.open(self.settings.file.name);

Expand Down

0 comments on commit 6aa615f

Please sign in to comment.