MarinaGuide & Sejlerguide

  • Video
  • Billeder
  • Navigation
  • Havnekort
MarinaGuide.gr
(function($) { var has_VML, create_canvas_for, add_shape_to, clear_canvas, shape_from_area, canvas_style, fader, hex_to_decimal, css3color, is_image_loaded, options_from_area; has_VML = document.namespaces; has_canvas = !!document.createElement('canvas').getContext; if(!(has_canvas || has_VML)) { $.fn.maphilight = function() { return this; }; return; } if(has_canvas) { fader = function(element, opacity, interval) { if(opacity <= 1) { element.style.opacity = opacity; window.setTimeout(fader, 10, element, opacity + 0.1, 10); } }; hex_to_decimal = function(hex) { return Math.max(0, Math.min(parseInt(hex, 16), 255)); }; css3color = function(color, opacity) { return 'rgba('+hex_to_decimal(color.substr(0,2))+','+hex_to_decimal(color.substr(2,2))+','+hex_to_decimal(color.substr(4,2))+','+opacity+')'; }; create_canvas_for = function(img) { var c = $('').get(0); c.getContext("2d").clearRect(0, 0, c.width, c.height); return c; }; add_shape_to = function(canvas, shape, coords, options, name) { var i, context = canvas.getContext('2d'); context.beginPath(); if(shape == 'rect') { context.rect(coords[0], coords[1], coords[2] - coords[0], coords[3] - coords[1]); } else if(shape == 'poly') { context.moveTo(coords[0], coords[1]); for(i=2; i < coords.length; i+=2) { context.lineTo(coords[i], coords[i+1]); } } else if(shape == 'circ') { context.arc(coords[0], coords[1], coords[2], 0, Math.PI * 2, false); } context.closePath(); if(options.fill) { context.fillStyle = css3color(options.fillColor, options.fillOpacity); context.fill(); } if(options.stroke) { context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity); context.lineWidth = options.strokeWidth; context.stroke(); } if(options.fade) { fader(canvas, 0); } }; clear_canvas = function(canvas, area) { canvas.getContext('2d').clearRect(0, 0, canvas.width,canvas.height); }; } else { // ie executes this code create_canvas_for = function(img) { return $('').get(0); }; add_shape_to = function(canvas, shape, coords, options, name) { var fill, stroke, opacity, e; fill = ''; stroke = (options.stroke ? 'strokeweight="'+options.strokeWidth+'" stroked="t" strokecolor="#'+options.strokeColor+'"' : 'stroked="f"'); opacity = ''; if(shape == 'rect') { e = $(''); } else if(shape == 'poly') { e = $(''); } else if(shape == 'circ') { e = $(''); } e.get(0).innerHTML = fill+opacity; $(canvas).append(e); }; clear_canvas = function(canvas) { $(canvas).find('[name=highlighted]').remove(); }; } shape_from_area = function(area) { var i, coords = area.getAttribute('coords').split(','); for (i=0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); } return [area.getAttribute('shape').toLowerCase().substr(0,4), coords]; }; options_from_area = function(area, options) { var $area = $(area); return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight')); }; is_image_loaded = function(img) { if(!img.complete) { return false; } // IE if(typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; } // Others return true; }; canvas_style = { position: 'absolute', left: 0, top: 0, padding: 0, border: 0 }; var ie_hax_done = false; $.fn.maphilight = function(opts) { opts = $.extend({}, $.fn.maphilight.defaults, opts); if($.browser.msie && !ie_hax_done) { document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); var style = document.createStyleSheet(); var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox']; $.each(shapes, function() { style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true"); } ); ie_hax_done = true; } return this.each(function() { var img, wrap, options, map, canvas, canvas_always, mouseover, highlighted_shape, usemap; img = $(this); if(!is_image_loaded(this)) { // If the image isn't fully loaded, this won't work right. Try again later. return window.setTimeout(function() { img.maphilight(opts); }, 200); } options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight')); // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr. // So use raw getAttribute instead. usemap = img.get(0).getAttribute('usemap'); map = $('map[name="'+usemap.substr(1)+'"]'); if(!(img.is('img') && usemap && map.size() > 0)) { return; } if(img.hasClass('maphilighted')) { // We're redrawing an old map, probably to pick up changes to the options. // Just clear out all the old stuff. var wrapper = img.parent(); img.insertBefore(wrapper); wrapper.remove(); } wrap = $('
').css({ display:'block', background:'url('+this.src+')', position:'relative', padding:0, width:this.width, height:this.height }); if(options.wrapClass) { if(options.wrapClass === true) { wrap.addClass($(this).attr('class')); } else { wrap.addClass(options.wrapClass); } } img.before(wrap).css('opacity', 0).css(canvas_style).remove(); if($.browser.msie) { img.css('filter', 'Alpha(opacity=0)'); } wrap.append(img); canvas = create_canvas_for(this); $(canvas).css(canvas_style); canvas.height = this.height; canvas.width = this.width; mouseover = function(e) { var shape, area_options; area_options = options_from_area(this, options); if( !area_options.neverOn && !area_options.alwaysOn ) { shape = shape_from_area(this); add_shape_to(canvas, shape[0], shape[1], area_options, "highlighted"); if(area_options.groupBy && $(this).attr(area_options.groupBy)) { var first = this; map.find('area['+area_options.groupBy+'='+$(this).attr(area_options.groupBy)+']').each(function() { if(this != first) { var subarea_options = options_from_area(this, options); if(!subarea_options.neverOn && !subarea_options.alwaysOn) { var shape = shape_from_area(this); add_shape_to(canvas, shape[0], shape[1], subarea_options, "highlighted"); } } }); } } } if(options.alwaysOn) { $(map).find('area[coords]').each(mouseover); } else { // If the metadata plugin is present, there may be areas with alwaysOn set. // We'll add these to a *second* canvas, which will get around flickering during fading. $(map).find('area[coords]').each(function() { var shape, area_options; area_options = options_from_area(this, options); if(area_options.alwaysOn) { if(!canvas_always) { canvas_always = create_canvas_for(img.get()); $(canvas_always).css(canvas_style); canvas_always.width = img.width(); canvas_always.height = img.height(); img.before(canvas_always); } shape = shape_from_area(this); if ($.browser.msie) { add_shape_to(canvas, shape[0], shape[1], area_options, ""); } else { add_shape_to(canvas_always, shape[0], shape[1], area_options, ""); } } }); $(map).find('area[coords]').mouseover(mouseover).mouseout(function(e) { clear_canvas(canvas); }); } img.before(canvas); // if we put this after, the mouseover events wouldn't fire. img.addClass('maphilighted'); }); }; $.fn.maphilight.defaults = { fill: true, fillColor: '000000', fillOpacity: 0.2, stroke: true, strokeColor: 'ff0000', strokeOpacity: 1, strokeWidth: 1, fade: true, alwaysOn: false, neverOn: false, groupBy: false, wrapClass: true }; })(jQuery);
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param f onMouseOver function || An object with configuration options
* @param g onMouseOut function || Nothing (use configuration options object)
* @author Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);
MarinaGuide.dk
/*! * jQuery Cookie Plugin v1.3 * https://github.com/carhartl/jquery-cookie * * Copyright 2011, Klaus Hartl * Dual licensed under the MIT or GPL Version 2 licenses. * http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/GPL-2.0 */ (function ($, document, undefined) { var pluses = /\+/g; function raw(s) { return s; } function decoded(s) { return decodeURIComponent(s.replace(pluses, ' ')); } var config = $.cookie = function (key, value, options) { // write if (value !== undefined) { options = $.extend({}, config.defaults, options); if (value === null) { options.expires = -1; } if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } value = config.json ? JSON.stringify(value) : String(value); return (document.cookie = [ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // read var decode = config.raw ? raw : decoded; var cookies = document.cookie.split('; '); for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) { if (decode(parts.shift()) === key) { var cookie = decode(parts.join('=')); return config.json ? JSON.parse(cookie) : cookie; } } return null; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) !== null) { $.cookie(key, null, options); return true; } return false; }; })(jQuery, document);
Share