update included libraries
This commit is contained in:
parent
2e79fcd8bf
commit
214d1917b0
64
js/Event.js
64
js/Event.js
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Event.js : v1.1 : mudcu.be
|
Event.js : v1.2 : 2012.02.22
|
||||||
-----------------------
|
-----------------------------
|
||||||
/// calling "Event" with "new" provides additional support;
|
/// calling "Event" with "new" provides additional support;
|
||||||
Event(syntax.area, "click", function(event, self) {
|
Event(syntax.area, "click", function(event, self) {
|
||||||
self.stop().prevent().remove();
|
self.stop().prevent().remove();
|
||||||
|
@ -30,6 +30,16 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// 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();
|
||||||
|
});
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Event = (function(root) { "use strict";
|
var Event = (function(root) { "use strict";
|
||||||
|
@ -75,6 +85,16 @@ var Event = (function(root) { "use strict";
|
||||||
if (type.indexOf && type.indexOf(",") !== -1) {
|
if (type.indexOf && type.indexOf(",") !== -1) {
|
||||||
type = type.split(",");
|
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
|
// check type for multipel events
|
||||||
if (typeof(type) !== "string") { // has multiple events
|
if (typeof(type) !== "string") { // has multiple events
|
||||||
that.events = {};
|
that.events = {};
|
||||||
|
@ -85,6 +105,7 @@ var Event = (function(root) { "use strict";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // has multiple listeners glued together (array)
|
} else { // has multiple listeners glued together (array)
|
||||||
|
if (typeof(listener) !== "function") return "missing listener";
|
||||||
for (var n = 0, length = type.length; n < length; n ++) {
|
for (var n = 0, length = type.length; n < length; n ++) {
|
||||||
that.events[type[n]] = Event(target, type[n], listener, scope);
|
that.events[type[n]] = Event(target, type[n], listener, scope);
|
||||||
}
|
}
|
||||||
|
@ -103,10 +124,10 @@ var Event = (function(root) { "use strict";
|
||||||
};
|
};
|
||||||
return that;
|
return that;
|
||||||
} else { // is single call
|
} else { // is single call
|
||||||
if (!(target && type && listener)) return "missing data.";
|
if (!(target && type && listener)) return "missing listener.";
|
||||||
type = standardize(type);
|
type = standardize(type);
|
||||||
}
|
}
|
||||||
// tracked wrapper
|
// the wrapped unique id
|
||||||
var wrapperID = type + getEventID(target) + "." + getEventID(listener);
|
var wrapperID = type + getEventID(target) + "." + getEventID(listener);
|
||||||
if (!wrappers[wrapperID]) { // create new wrapper
|
if (!wrappers[wrapperID]) { // create new wrapper
|
||||||
wrappers[wrapperID] = function(event) {
|
wrappers[wrapperID] = function(event) {
|
||||||
|
@ -146,9 +167,19 @@ var Event = (function(root) { "use strict";
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////// LEGACY SUPPORT //////////////////
|
||||||
|
|
||||||
root.add = function(target, type, listener, scope) {
|
root.add = function(target, type, listener, scope) {
|
||||||
type = standardize(type);
|
if (typeof(type) !== "string") {
|
||||||
target[add](type, wrap(type, target, listener, scope || target), false);
|
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;
|
return listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,6 +196,7 @@ var Event = (function(root) { "use strict";
|
||||||
} else { // <= IE8
|
} else { // <= IE8
|
||||||
event.cancelBubble = true;
|
event.cancelBubble = true;
|
||||||
}
|
}
|
||||||
|
return root;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.prevent =
|
root.prevent =
|
||||||
|
@ -174,6 +206,7 @@ var Event = (function(root) { "use strict";
|
||||||
} else { // <= IE8
|
} else { // <= IE8
|
||||||
event.returnValue = false;
|
event.returnValue = false;
|
||||||
}
|
}
|
||||||
|
return root;
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -197,7 +230,24 @@ var Event = (function(root) { "use strict";
|
||||||
}
|
}
|
||||||
return wrappers[wrapperID];
|
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;
|
return root;
|
||||||
//
|
//
|
||||||
})(Event);
|
})({});
|
|
@ -1,4 +1,6 @@
|
||||||
/*
|
/*
|
||||||
|
var loader = new widgets.Loader({ message: "loading: New loading message..." });
|
||||||
|
-----
|
||||||
var loader = new widgets.Loader({
|
var loader = new widgets.Loader({
|
||||||
id: "loader",
|
id: "loader",
|
||||||
bars: 12,
|
bars: 12,
|
||||||
|
@ -8,7 +10,7 @@
|
||||||
});
|
});
|
||||||
loader.stop();
|
loader.stop();
|
||||||
|
|
||||||
loader.message("New loading message...");
|
loader.message("loading: New loading message...");
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,6 +27,23 @@ var defaultConfig = {
|
||||||
lineHeight: 70
|
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) {
|
root.Loader = function (config) {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (!document.body) return;
|
if (!document.body) return;
|
||||||
|
@ -51,21 +70,15 @@ root.Loader = function (config) {
|
||||||
canvas.style.cssText = "opacity: 1; position: absolute; z-index: 1000;";
|
canvas.style.cssText = "opacity: 1; position: absolute; z-index: 1000;";
|
||||||
div.appendChild(canvas);
|
div.appendChild(canvas);
|
||||||
document.body.appendChild(div);
|
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 max = config.lineHeight + 20;
|
||||||
var size = max * 2 + config.radius;
|
var size = max * 2 + config.radius;
|
||||||
width -= size;
|
var windowSize = getWindowSize();
|
||||||
height -= size;
|
var width = windowSize.width - size;
|
||||||
|
var height = windowSize.height - size;
|
||||||
canvas.width = size;
|
canvas.width = size;
|
||||||
canvas.height = size;
|
canvas.height = size;
|
||||||
canvas.style.left = (width / 2) + "px";
|
canvas.style.left = (width / 2) + "px";
|
||||||
|
@ -88,6 +101,17 @@ root.Loader = function (config) {
|
||||||
ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
|
||||||
//
|
//
|
||||||
function animate() {
|
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.save();
|
||||||
ctx.clearRect(0, 0, size, size);
|
ctx.clearRect(0, 0, size, size);
|
||||||
ctx.translate(size / 2, size / 2);
|
ctx.translate(size / 2, size / 2);
|
||||||
|
@ -125,7 +149,7 @@ root.Loader = function (config) {
|
||||||
//
|
//
|
||||||
if (config.messageAnimate) {
|
if (config.messageAnimate) {
|
||||||
var iteration = offset / 0.07 >> 0;
|
var iteration = offset / 0.07 >> 0;
|
||||||
if (iteration % 10 == 0) {
|
if (iteration % 10 === 0) {
|
||||||
var length = config.messageAnimate.length;
|
var length = config.messageAnimate.length;
|
||||||
var n = iteration / 10 % length;
|
var n = iteration / 10 % length;
|
||||||
that.span.innerHTML = config.message + config.messageAnimate[n];
|
that.span.innerHTML = config.message + config.messageAnimate[n];
|
||||||
|
|
Loading…
Reference in a new issue