update included libraries

This commit is contained in:
Michael Deal 2012-04-13 21:56:56 -07:00
parent 2e79fcd8bf
commit 214d1917b0
2 changed files with 95 additions and 21 deletions

View file

@ -1,7 +1,7 @@
/*
Event.js : v1.1 : mudcu.be
-----------------------
Event.js : v1.2 : 2012.02.22
-----------------------------
/// calling "Event" with "new" provides additional support;
Event(syntax.area, "click", function(event, self) {
self.stop().prevent().remove();
@ -29,6 +29,16 @@
binding.remove(); // just remove this listener
}
});
/// on-element-is-ready (loads before onload)
Event("document.body", "ready", function(event, state, wheelData, self) {
self.stop.prevent.remove();
});
/// easier mousewheel events
Event.mousewheel(window, function(event, state, wheelData, self) {
self.stop.prevent.remove();
});
*/
@ -75,6 +85,16 @@ var Event = (function(root) { "use strict";
if (type.indexOf && type.indexOf(",") !== -1) {
type = type.split(",");
}
// check for element to load on interval (before onload)
if (typeof(target) === "string" && type === "ready") {
var interval = window.setInterval(function() {
if (eval(target)) {
window.clearInterval(interval);
listener();
}
}, 10);
return that;
}
// check type for multipel events
if (typeof(type) !== "string") { // has multiple events
that.events = {};
@ -85,6 +105,7 @@ var Event = (function(root) { "use strict";
}
}
} else { // has multiple listeners glued together (array)
if (typeof(listener) !== "function") return "missing listener";
for (var n = 0, length = type.length; n < length; n ++) {
that.events[type[n]] = Event(target, type[n], listener, scope);
}
@ -103,10 +124,10 @@ var Event = (function(root) { "use strict";
};
return that;
} else { // is single call
if (!(target && type && listener)) return "missing data.";
if (!(target && type && listener)) return "missing listener.";
type = standardize(type);
}
// tracked wrapper
// the wrapped unique id
var wrapperID = type + getEventID(target) + "." + getEventID(listener);
if (!wrappers[wrapperID]) { // create new wrapper
wrappers[wrapperID] = function(event) {
@ -146,9 +167,19 @@ var Event = (function(root) { "use strict";
return that;
};
//////////////// LEGACY SUPPORT //////////////////
root.add = function(target, type, listener, scope) {
type = standardize(type);
target[add](type, wrap(type, target, listener, scope || target), false);
if (typeof(type) !== "string") {
var config = type;
for (var type in config) {
if (isEvent[type] && typeof(config[type]) === "function") {
root.add(target, type, config[type]);
}
}
return config;
}
target[add](standardize(type), wrap(type, target, listener, scope || target), false);
return listener;
};
@ -165,6 +196,7 @@ var Event = (function(root) { "use strict";
} else { // <= IE8
event.cancelBubble = true;
}
return root;
};
root.prevent =
@ -174,6 +206,7 @@ var Event = (function(root) { "use strict";
} else { // <= IE8
event.returnValue = false;
}
return root;
};
/////////////
@ -197,7 +230,24 @@ var Event = (function(root) { "use strict";
}
return wrappers[wrapperID];
};
//////////////// MouseWheel ////////////////
root.mousewheel = function(target, listener, timeout) {
var interval = 0;
var self = Event(target, "mousewheel", function(event) {
event = event || window.event;
var wheelData = event.detail ? event.detail * -1 : event.wheelDelta / 40;
listener(event, "wheel", wheelData);
window.clearInterval(interval);
interval = window.setInterval(function() {
window.clearInterval(interval);
listener(event, "wheelup", wheelData, self);
}, timeout || 150);
});
return self;
};
//
return root;
//
})(Event);
})({});

View file

@ -1,4 +1,6 @@
/*
var loader = new widgets.Loader({ message: "loading: New loading message..." });
-----
var loader = new widgets.Loader({
id: "loader",
bars: 12,
@ -8,7 +10,7 @@
});
loader.stop();
loader.message("New loading message...");
loader.message("loading: New loading message...");
*/
@ -25,6 +27,23 @@ var defaultConfig = {
lineHeight: 70
};
var getWindowSize = function() {
if (window.innerWidth && window.innerHeight) {
var width = window.innerWidth;
var height = window.innerHeight;
} else if (document.body && document.body.offsetWidth) {
var width = window.innerWidth = document.body.offsetWidth;
var height = window.innerHeight = document.body.offsetHeight;
} else if (document.compatMode === 'CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
var width = window.innerWidth = document.documentElement.offsetWidth;
var height = window.innerHeight = document.documentElement.offsetHeight;
}
return {
width: width,
height: height
};
};
root.Loader = function (config) {
var that = this;
if (!document.body) return;
@ -51,21 +70,15 @@ root.Loader = function (config) {
canvas.style.cssText = "opacity: 1; position: absolute; z-index: 1000;";
div.appendChild(canvas);
document.body.appendChild(div);
} else {
that.span = canvas.parentNode.getElementsByTagName("span")[0];
}
if (window.innerWidth && window.innerHeight) {
var width = window.innerWidth;
var height = window.innerHeight;
} else if (document.body && document.body.offsetWidth) {
var width = document.body.offsetWidth;
var height = document.body.offsetHeight;
} else if (document.compatMode === "CSS1Compat" && document.documentElement && document.documentElement.offsetWidth ) {
var width = document.documentElement.offsetWidth;
var height = document.documentElement.offsetHeight;
}
//
var max = config.lineHeight + 20;
var size = max * 2 + config.radius;
width -= size;
height -= size;
var windowSize = getWindowSize();
var width = windowSize.width - size;
var height = windowSize.height - size;
canvas.width = size;
canvas.height = size;
canvas.style.left = (width / 2) + "px";
@ -88,6 +101,17 @@ root.Loader = function (config) {
ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
//
function animate() {
var windowSize = getWindowSize();
var width = windowSize.width - size;
var height = windowSize.height - size;
//
canvas.style.left = (width / 2) + "px";
canvas.style.top = (height / 2) + "px";
if (config.message) {
that.span.style.left = ((width + size) / 2 - that.span.offsetWidth/2) + "px";
that.span.style.top = (height / 2 + size - 10) + "px";
}
//
ctx.save();
ctx.clearRect(0, 0, size, size);
ctx.translate(size / 2, size / 2);
@ -125,7 +149,7 @@ root.Loader = function (config) {
//
if (config.messageAnimate) {
var iteration = offset / 0.07 >> 0;
if (iteration % 10 == 0) {
if (iteration % 10 === 0) {
var length = config.messageAnimate.length;
var n = iteration / 10 % length;
that.span.innerHTML = config.message + config.messageAnimate[n];