This commit is contained in:
Fabian Jakobs 2011-12-01 11:02:22 +01:00
commit acf258ea8b
2 changed files with 18 additions and 44 deletions

View file

@ -177,7 +177,7 @@ exports.importCssString = function importCssString(cssText, id, doc) {
exports.importCssStylsheet = function(uri, doc) { exports.importCssStylsheet = function(uri, doc) {
if (doc.createStyleSheet) { if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet(uri); doc.createStyleSheet(uri);
} else { } else {
var link = exports.createElement('link'); var link = exports.createElement('link');
link.rel = 'stylesheet'; link.rel = 'stylesheet';
@ -189,13 +189,19 @@ exports.importCssStylsheet = function(uri, doc) {
}; };
exports.getInnerWidth = function(element) { exports.getInnerWidth = function(element) {
return (parseInt(exports.computedStyle(element, "paddingLeft")) return (
+ parseInt(exports.computedStyle(element, "paddingRight")) + element.clientWidth); parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
parseInt(exports.computedStyle(element, "paddingRight"), 10) +
element.clientWidth
);
}; };
exports.getInnerHeight = function(element) { exports.getInnerHeight = function(element) {
return (parseInt(exports.computedStyle(element, "paddingTop")) return (
+ parseInt(exports.computedStyle(element, "paddingBottom")) + element.clientHeight); parseInt(exports.computedStyle(element, "paddingTop"), 10) +
parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
element.clientHeight
);
}; };
if (window.pageYOffset !== undefined) { if (window.pageYOffset !== undefined) {
@ -221,13 +227,13 @@ if (window.getComputedStyle)
exports.computedStyle = function(element, style) { exports.computedStyle = function(element, style) {
if (style) if (style)
return (window.getComputedStyle(element, "") || {})[style] || ""; return (window.getComputedStyle(element, "") || {})[style] || "";
return window.getComputedStyle(element, "") || {} return window.getComputedStyle(element, "") || {};
}; };
else else
exports.computedStyle = function(element, style) { exports.computedStyle = function(element, style) {
if (style) if (style)
return element.currentStyle[style]; return element.currentStyle[style];
return element.currentStyle return element.currentStyle;
}; };
exports.scrollbarWidth = function(document) { exports.scrollbarWidth = function(document) {
@ -300,36 +306,4 @@ exports.getParentWindow = function(document) {
return document.defaultView || document.parentWindow; return document.defaultView || document.parentWindow;
}; };
exports.getSelectionStart = function(textarea) {
// TODO IE
var start;
try {
start = textarea.selectionStart || 0;
} catch (e) {
start = 0;
}
return start;
};
exports.setSelectionStart = function(textarea, start) {
// TODO IE
return textarea.selectionStart = start;
};
exports.getSelectionEnd = function(textarea) {
// TODO IE
var end;
try {
end = textarea.selectionEnd || 0;
} catch (e) {
end = 0;
}
return end;
};
exports.setSelectionEnd = function(textarea, end) {
// TODO IE
return textarea.selectionEnd = end;
};
}); });

View file

@ -49,7 +49,7 @@ var trimBeginRegexp = /^\s\s*/;
var trimEndRegexp = /\s\s*$/; var trimEndRegexp = /\s\s*$/;
exports.stringTrimLeft = function (string) { exports.stringTrimLeft = function (string) {
return string.replace(trimBeginRegexp, '') return string.replace(trimBeginRegexp, '');
}; };
exports.stringTrimRight = function (string) { exports.stringTrimRight = function (string) {
@ -66,11 +66,11 @@ exports.copyObject = function(obj) {
exports.copyArray = function(array){ exports.copyArray = function(array){
var copy = []; var copy = [];
for (i=0, l=array.length; i<l; i++) { for (var i=0, l=array.length; i<l; i++) {
if (array[i] && typeof array[i] == "object") if (array[i] && typeof array[i] == "object")
copy[i] = this.copyObject( array[i] ); copy[i] = this.copyObject( array[i] );
else else
copy[i] = array[i] copy[i] = array[i];
} }
return copy; return copy;
}; };
@ -89,7 +89,7 @@ exports.deepCopy = function (obj) {
} }
} }
return copy; return copy;
} };
exports.arrayToMap = function(arr) { exports.arrayToMap = function(arr) {
var map = {}; var map = {};
@ -127,7 +127,7 @@ exports.deferredCall = function(fcn) {
deferred.cancel(); deferred.cancel();
timer = setTimeout(callback, timeout || 0); timer = setTimeout(callback, timeout || 0);
return deferred; return deferred;
} };
deferred.schedule = deferred; deferred.schedule = deferred;