Simplified component-creation, dropping IE8 compatibility.

This commit is contained in:
FrozenCow 2011-03-31 12:54:32 +02:00
parent 6eface57ae
commit 6622db1b2c
5 changed files with 173 additions and 192 deletions

View File

@ -7,9 +7,7 @@ $.ajax({
});
componentconstructors['chat'] = function(dynmap, configuration) {
return {
dynmap: dynmap,
initialize: function() {
var me = this;
// Provides 'chat'-events by monitoring the world-updates.
$(dynmap).bind('worldupdate', function(event, update) {
swtch(update.type, {
@ -40,6 +38,4 @@ componentconstructors['chat'] = function(dynmap, configuration) {
});
});
}
}
};
};

View File

@ -1,10 +1,6 @@
componentconstructors['chatballoon'] = function(dynmap, configuration) {
return {
dynmap: dynmap,
options: configuration,
chatpopups: {},
initialize: function() {
var me = this;
me.chatpopups = {};
$(dynmap).bind('chat', function(event, message) {
if (message.source != 'player') {
return;
@ -48,6 +44,4 @@ componentconstructors['chatballoon'] = function(dynmap, configuration) {
delete me.chatpopups[message.name];
}, 8000);
});
}
};
};

View File

@ -1,7 +1,5 @@
componentconstructors['chatbox'] = function(dynmap, configuration) {
return {
dynmap: dynmap,
initialize: function() {
var me = this;
var chat = $('<div/>')
.addClass('chat')
.appendTo(dynmap.options.container);
@ -69,6 +67,4 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
//var scrollHeight = jQuery(me.messagelist).attr('scrollHeight');
messagelist.scrollTop(messagelist.scrollHeight());
});
}
};
};

View File

@ -280,10 +280,8 @@ DynMap.prototype = {
me.selectMap(me.defaultworld.defaultmap);
$.each(me.options.components, function(index, configuration) {
me.components.push(componentconstructors[configuration.type](me, configuration));
});
$.each(me.components, function(index, component) {
component.initialize();
var componentconstructor = componentconstructors[configuration.type];
me.components.push(new componentconstructor(me, configuration));
});
setTimeout(function() { me.update(); }, me.options.updaterate);

View File

@ -1,6 +1,5 @@
componentconstructors['playermarkers'] = function(dynmap, configuration) {
return {
initialize: function() {
var me = this;
$(dynmap).bind('playeradded', function(event, player) {
// Create the player-marker.
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
@ -35,6 +34,4 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
player.marker.toggle(dynmap.world === player.location.world);
player.marker.setPosition(markerPosition);
});
}
};
};