add minified calendar with utils
parent
7784be4ff7
commit
a02fbbf2d2
|
@ -277,8 +277,7 @@ var Calendar = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Setup a text input box to be a calendar box.
|
/// Setup a text input box to be a calendar box.
|
||||||
set: function(input_or_id)
|
set: function(input_or_id) {
|
||||||
{
|
|
||||||
if (typeof input_or_id == 'string')
|
if (typeof input_or_id == 'string')
|
||||||
input_or_id = document.getElementById(input_or_id);
|
input_or_id = document.getElementById(input_or_id);
|
||||||
if (!input_or_id)
|
if (!input_or_id)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,47 @@
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
// UTILITY FUNCTIONS
|
||||||
|
window.addListener = (function() {
|
||||||
|
return window.addEventListener
|
||||||
|
? function(el, type, fn) { el.addEventListener(type, fn, false); }
|
||||||
|
: function(el, type, fn) { el.attachEvent('on'+type, fn); };
|
||||||
|
})();
|
||||||
|
|
||||||
|
var getOffsetRect = function(elem)
|
||||||
|
{
|
||||||
|
var box = elem.getBoundingClientRect();
|
||||||
|
|
||||||
|
var body = document.body;
|
||||||
|
var docElem = document.documentElement;
|
||||||
|
|
||||||
|
var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
|
||||||
|
var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
|
||||||
|
var clientTop = docElem.clientTop || body.clientTop || 0;
|
||||||
|
var clientLeft = docElem.clientLeft || body.clientLeft || 0;
|
||||||
|
var top = box.top + scrollTop - clientTop;
|
||||||
|
var left = box.left + scrollLeft - clientLeft;
|
||||||
|
|
||||||
|
return { top: Math.round(top), left: Math.round(left) };
|
||||||
|
};
|
||||||
|
|
||||||
|
var getOffsetSum = function(elem)
|
||||||
|
{
|
||||||
|
var top = 0, left = 0;
|
||||||
|
while(elem)
|
||||||
|
{
|
||||||
|
top = top + parseInt(elem.offsetTop);
|
||||||
|
left = left + parseInt(elem.offsetLeft);
|
||||||
|
elem = elem.offsetParent;
|
||||||
|
}
|
||||||
|
return { top: top, left: left };
|
||||||
|
};
|
||||||
|
|
||||||
|
window.getOffset = function(elem)
|
||||||
|
{
|
||||||
|
if (elem.getBoundingClientRect)
|
||||||
|
return getOffsetRect(elem);
|
||||||
|
else
|
||||||
|
return getOffsetSum(elem);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
Loading…
Reference in New Issue