').css( { width: '150px', border: '1px solid #bbb', borderRadius: '8px', position: 'absolute', bottom: '22px', right: '-4px', whiteSpace: 'normal', textAlign: 'left', padding: '0.25em 0.75em 0.25em 0.75em', fontSize: '90%', backgroundColor: '#f9f9f9', boxShadow: '4px 4px 10px rgba(0,0,0,0.2)' } ).text('Click the blue globe to open an interactive map.').append( $('
').css({position: 'absolute', width: 0, height: 0, bottom: '-10px', right: '10px', borderBottom:0, borderLeft: '5px solid transparent', borderRight: '5px solid transparent', borderTop: '10px solid #bbb'}) ).append( $('
').css({position: 'absolute', width: 0, height: 0, bottom: '-7px', right: '10px', borderBottom:0, borderLeft: '5px solid transparent', borderRight: '5px solid transparent', borderTop: '10px solid #f9f9f9'}) ).hide();
if( span.length>0 ) {
wrap = $('
').css( { width: '20px', height: '17px', position: 'relative' } );
span.wrap(wrap).parent().append(bubble.fadeIn().click(function(){ bubble.fadeOut(); window.localStorage.setItem('wmatooltipdismissed','yes'); awt='c'; }));
setTimeout( function() { bubble.fadeOut() }, 10*1000 );
awt="1";
}
})();
} else { awt=(ttc=='yes')?'p':ttc; }
}
// detect and load KML
// also insert globe even if no title coords are given
(function () {
var i, l = $('div.kmldata')
,alat = 0, alon = 0, np = 0
,la1 = Infinity, la2 =- Infinity
,lo1 = Infinity, lo2 =- Infinity
,ex,ey, titlebutton = false;
for( i = 0; i < l.length; ++i ) {// TODO: replace with .each
coordinates = true;
$.ajax({
url: '/wiki/' + encodeURI(l.eq(i).attr('title')) + '?action=raw',
dataType: 'xml',
success: function (xml) {
function processCoords(t) {
var way = [], c, p = t.split(' '), i, lat, lon;
for( i=0; i
= 2 ) {
lat = parseFloat(c[1]);
lon = parseFloat(c[0]);
way.push( { lat: lat, lon: lon } );
// determine extent of way
if( latla2 ) { la2=lat; }
if( lon>lo2 ) { lo2=lon; }
}
}
return way;
}
// initialize transfer datastructure
kml = { ways: [], areas: [] };
window.kmldata = xml; // DEBUG!
// ways
$(xml).find('LineString > coordinates').each(function () {
var way = processCoords( $(this).text() );
if( way.length > 0 ) { kml.ways.push(way); }
});
// areas
$(xml).find('Polygon').each(function () {
var i, j, c,
area = { inner: [], outer: [] };
// outer boundary
$(this).find('outerBoundaryIs > LinearRing > coordinates').each(function () {
var way = processCoords( $(this).text() );
if( way.length > 0 ) {
area.outer.push(way);
}
});
// inner boundary (holes in the polygon)
$(this).find('innerBoundaryIs > LinearRing > coordinates').each(function () {
var way = processCoords( $(this).text() );
if( way.length > 0 ) { area.inner.push(way); }
});
// only add if we have an outer boundary
if( area.outer.length>0 ) { kml.areas.push(area); }
});
// inset min/max extent
kml.minlon = lo1;
kml.maxlon = lo2;
kml.minlat = la1;
kml.maxlat = la2;
window.kml = kml; // DEBUG!
// already got a request message
if( mes !== null && kml.ways.length > 0 && typeof JSON !== "undefined" ) {
mes.postMessage( JSON.stringify(kml), document.location.protocol + '//toolserver.org' );
}
// insert blue globe
if( coord_list.length == 0 || ( !$('#coordinates').find('.wmamapbutton').length) ) {
// determine center
alat = (la1+la2)/2;
alon = (lo1+lo2)/2;
//determine zoomfactor
ex = (lo2-lo1)/180.0 * 3.0*128;
ey = (la2-la1)/180.0 * 3.0*128; // max extent in degrees, zoom0 has 3*128/180 px/degree
for( zoomlevel = 0; zoomlevel < 12; ++zoomlevel ) {
if( ex>config.width/2 || ey>config.height/2 ) break;
ex *= 2; ey *= 2;
}
// add mapbutton
mapbutton = $('')
.hover(function (){ $(this).css('opacity', 0.75); }, function () { $(this).css('opacity', ''); })
.css('padding', isRTL() ? '0px 3px 0px 0px' : '0px 0px 0px 3px' ).css('cursor', 'pointer')
.attr('src', wc.buttonImage).addClass('wmamapbutton').addClass('noprint')
.bind( 'click', { param:
alat + '_' + alon + '_' +
wc.width + '_' + wc.height + '_' +
site + '_' + zoomlevel + '_' + language
}, showIFrame ); // zoomlevel!
if(!titlebutton ) {
if( $('#coordinates').length ) {
$('#coordinates').append(mapbutton);
} else {
$(''+(strings.map[language] || strings.map.en)+' ').append(mapbutton).appendTo('#bodyContent');
}
titlebutton = true;
}
}
}
});
} // end for
})();
// prepare quicklink menu box
if ( coordinates !== null && wc.quicklink ) {
quicklinkbox = document.createElement('div');
// more to come :-)
}
// prepare iframe to house the map
if ( coordinates !== null ) {
wi.div = $('').css( {
width: (wc.width+2)+'px', height: (wc.height+2)+'px',
margin: '0px', padding: '0px',
backgroundColor : 'white', border: '1px solid gray',
position: 'absolute', top: '1em', zIndex: 13, boxShadow: '3px 3px 25px rgba(0,0,0,0.3)'
} ).css( isRTL() ? 'left' : 'right', '2em' ).hide();
var rbrtl = [ '//upload.wikimedia.org/wikipedia/commons/b/b5/Button_resize.png',
'//upload.wikimedia.org/wikipedia/commons/3/30/Button_resize_rtl.png' ]
wi.resizebutton = $('').attr( {
title : strings.resize[language] || strings.resize.en,
src : rbrtl[isRTL()?1:0]
} ).hide().attr('ondragstart','return false');
// cover the iframe to prevent loosing the mouse to the iframe during resizing
wi.resizehelper = $('').css( { position: 'absolute', top:0, left:0, zIndex: 20 } ).hide();
wi.closebutton = $('').attr( {
title : strings.close[language] || strings.close.en,
src : '//upload.wikimedia.org/wikipedia/commons/d/d4/Button_hide.png'
} ).css( {
zIndex : 15, position : 'absolute', right : '11px', top : '9px', width : '18px', cursor : 'pointer'
} ).click( function(e) { wi.div.hide() } );
wi.iframe = $('').attr( {
scrolling: 'no',
frameBorder : 0
} ).css( {
zIndex: 14, position: 'absolute', right: '1px', top: '1px',
width: (wc.width)+'px', height: (wc.height)+'px',
margin: '0px', padding: '0px'
} );
wi.div.append(wi.iframe);
wi.div.append(wi.resizehelper);
wi.div.append(wi.closebutton);
(function () {
var startx, starty, idle = true, dir = isRTL()?-1:1;
function adjusthelper() {
wi.resizehelper.css( { width: (wc.width+2)+'px', height: (wc.height+2)+'px' } );
}
wi.div.append(
$('')
.css( {
zIndex : 15, position : 'absolute', bottom : '3px',
width : '18px', height: '18px', cursor : (isRTL()?'se-resize':'sw-resize'),
'user-select': 'none', '-moz-user-select': 'none', '-ms-user-select': 'none'
} ).css( (isRTL()?'right':'left'), '3px' )
.mouseenter( function(e) { wi.resizebutton.fadeIn() } )
.mouseleave( function(e) { if( idle ) { wi.resizebutton.fadeOut(); } } )
.mousedown( function(e) {
if( idle ) {
wi.resizehelper.show();
adjusthelper();
lastx = e.pageX;
lasty = e.pageY;
$('body').bind('mouseup.wmaresize', function(e) {
$('body').unbind('mousemove.wmaresize');
$('body').unbind('mouseup.wmaresize');
idle = true;
wi.resizehelper.hide();
} );
$('body').bind('mousemove.wmaresize', function(e) {
wc.width -= dir*(e.pageX-lastx);
wc.height += (e.pageY-lasty);
lastx = e.pageX; lasty = e.pageY;
wi.div.css( { width: (wc.width+2)+'px', height: (wc.height+2)+'px' } );
wi.iframe.css( { width: wc.width+'px', height: wc.height+'px' } );
adjusthelper();
} );
idle = false;
}
} )
.append(wi.resizebutton)
);
})();
$(window).bind('message', messageHub);
}
});
//