function DragCorner(container, handle) { var container = $(container); var handle = $(handle); /* Add property to container to store position variables */ container.moveposition = {x:0, y:0}; function moveListener(event) { event.stop (); /* Calculate how far the mouse moved */ var moved = { x:(event.pointerX() - container.moveposition.x), y:(event.pointerY() - container.moveposition.y) }; moved.y = moved.y * -1; /* Reset container's x/y utility property */ container.moveposition = { x:event.pointerX(), y:event.pointerY() }; //console.log (moved.x, moved.y); /* Border adds to dimensions */ var borderStyle = container.getStyle('border-width'); var borderSize = borderStyle.split(' ')[0].replace(/[^0-9]/g,''); /* Padding adds to dimensions */ var paddingStyle = container.getStyle('padding'); var paddingSize = paddingStyle.split(' ')[0].replace(/[^0-9]/g,''); /* Add things up that change dimensions */ var sizeAdjust = (borderSize*2) + (paddingSize*2); sizeAdjust = 2; /* Update container's size */ var size = container.getDimensions(); var height = size.height + moved.y - sizeAdjust; var width = size.width + moved.x - sizeAdjust; if (width < 100) { width = 100; } if (height < 100) { height = 100; } container.setStyle ({ 'height': (height) + 'px', 'width': (width)+'px' }); Game.minimap.oScrollMap.resize (width, height); } /* Listen for 'mouse down' on handle to start the move listener */ handle.observe('mousedown', function(event) { /* Set starting x/y */ container.moveposition = { x:event.pointerX(), y:event.pointerY() }; /* Start listening for mouse move on body */ Event.observe(document.body,'mousemove',moveListener); event.stop (); }); /* Listen for 'mouse up' to cancel 'move' listener */ Event.observe(document.body,'mouseup', function(event) { Event.stopObserving(document.body,'mousemove',moveListener); }); } Game.minimap = { 'iTileSizeX' : 400, 'iTileSizeY' : 200, 'iMapOffsetX' : 4, 'iMapOffsetY' : 2, 'oScrollMap' : null, 'iZoom' : 1, 'btnZoomIn' : null, 'btnZoomOut' : null, /* Warning! Mind that the minimap can be initialized multiple times. */ 'loadMap' : function (x, y) { var cdiv = $('minimap'); var div = $(document.createElement ('div')); div.id = 'minimap_real'; div.style.width = cdiv.style.width; div.style.height = cdiv.style.height; div.style.position = 'absolute'; div.style.zIndex = '0'; div.style.overflow = 'hidden'; cdiv.appendChild (div); if (div) { var l = Game.minimap.getOrthogonalCors (x, y); var minimap = new TiledImageViewer ( div, Game.minimap.getTile, function () {}, 0, 0, div.offsetWidth, div.offsetHeight, Game.minimap.iTileSizeX * this.iZoom, Game.minimap.iTileSizeY * this.iZoom, l[0], l[1] ); minimap.enableControls (); minimap.setDblclickLocation (Game.minimap.scrollBigMap); Game.minimap.oScrollMap = minimap; if (typeof(Game.map) != 'undefined' && Game.map.bIsLoaded) { // Create viewport var windowSize = Game.core.getWindowSize (); var sx = Math.floor(windowSize[0] / Game.map.nMinimapRatioX); var sy = Math.floor(windowSize[1] / Game.map.nMinimapRatioY); var loc = Game.minimap.getOrthogonalCors (x, y); var px = loc[0] * -1; var py = loc[1] * -1; // Move it a bit px -= (sx / 2); py -= (sy / 2); minimap.addInnerHTML ('