var fiwaw_linked_image_url = "http://widget.wildatlanticway.com/images/wild-atlantic-way-200-1.jpg"; var fiwaw_ambassador_widget_url = "http://widget.wildatlanticway.com/stage2/sandhousehotel"; var fiwaw_css_href = "http://widget.wildatlanticway.com/site_includes/jqNiftyModal.css"; //---------------------------------------------------------- // Failte Ireland Wild Atlantic Way Widget Overlay Embed Call // OSD.ie : 2013 - 2014 // - Checks for jQuery library and if undefined load library // - Use jQuery noConflict // - Load jqNiftyModal overlay library & CSS // - Update default HTML img // - Bind click to show widget in overlay //---------------------------------------------------------- document.write("\"Wild"); (function() { // Localize jQuery variable var wawjQuery; var ie; var gen_image = false; /******** Load jQuery if not present *********/ //if (true) { if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.9.1') { //console.log("01. Check : jQuery"); var script_tag = document.createElement('script'); script_tag.setAttribute("type", "text/javascript"); //script_tag.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"); script_tag.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"); if (script_tag.readyState) { script_tag.onreadystatechange = function () { // For old versions of IE if (this.readyState == 'complete' || this.readyState == 'loaded') { scriptLoadHandler(); } }; } else { // Other browsers script_tag.onload = scriptLoadHandler; } // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); //console.log("02. jQuery added to DOM"); } else { // The jQuery version on the window is the one we want to use wawjQuery = window.jQuery; FIWAWmain(); } /******** Called once jQuery has loaded ******/ function scriptLoadHandler() { // Restore $ and window.jQuery to their previous values and store the // new jQuery in our local jQuery variable wawjQuery = window.jQuery.noConflict(true); //console.log("03. jQuery noConflict"); //console.log("04. IE:"+ie); // Call our main function FIWAWmain(); } /******** IE Checker ******/ //---------------------------------------------------------- //A short snippet for detecting versions of IE in JavaScript //without resorting to user-agent sniffing //---------------------------------------------------------- //If you're not in IE (or IE version is less than 5) then: //ie === undefined //If you're in IE (>=5) then you can determine which version: //ie === 7; // IE7 //Thus, to detect IE: //if (ie) {} //And to detect the version: //ie === 6 // IE6 //ie > 7 // IE8, IE9 ... //ie < 9 // Anything less than IE9 //---------------------------------------------------------- //UPDATE: Now using Live NodeList idea from @jdalton var ie = (function(){ var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '', all[0] ); return v > 4 ? v : undef; }()); /******** Main function ********/ function FIWAWmain() { // Include jqNiftyModal JS if ((ie == "8") || (ie == "7") || (ie == "6")) { (function(e){"use strict";var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y;var b={init:function(m){t=this,t.jqNiftyModal.settings=e.extend({},t.jqNiftyModal.defaults,m),n=e("body"),r="body",i=t.jqNiftyModal.settings.TargetType,s="jqNMODefaultClass",o="jqNMMDefaultClass",u="."+s,a="."+o,f=t.jqNiftyModal.settings.Callback,l="",c="",t.jqNiftyModal.settings.OverlayClass+=" "+s,t.jqNiftyModal.settings.ModalClass+=" "+o,h=t.jqNiftyModal.settings.AnimateToCenterDelay,p=t.jqNiftyModal.settings.OpenCloseAnimationsDelay;t.jqNiftyModal.settings.ChainLoading=t.jqNiftyModal.settings.NestedModals?false:true;v=w.isHtml(t)?true:false;if(v||i=="element"){d=v?t:e(t.jqNiftyModal.settings.Target+":eq(-1)");if(!w.isHtml(d)||!d.length){return false}d=t.jqNiftyModal.settings.CloneTarget?d.clone(true):d.children().clone(true);d=e(d)}else if(i=="url"||i=="page"){d=t.jqNiftyModal.settings.Target}else if(i=="text"){d=e("

"+t.jqNiftyModal.settings.Target+"

")}else if(i=="image"){var g=e(t.jqNiftyModal.settings.Target);if(!w.isHtml(g)||!g.length||g.attr("href")==undefined){return false}var b=g.attr("href"),E=g.attr("data-alt"),S=g.attr("data-title"),x,T;x=E==undefined?"Image Element":E;T=S==undefined?"":S;d=e(""+x+"")}w.createOverlay(t.jqNiftyModal.settings.OverlayClass);if(e(a).length&&t.jqNiftyModal.settings.ChainLoading){c=c==""?a:c;e(c).html("")}else{w.createModal(t.jqNiftyModal.settings.ModalClass)}if(i!="url"&&i!="page"){y=d.appendTo(c);if(i=="image"){y.hide();e("
").prependTo(c).addClass("loading");y.on("load",function(){e(c).find(".loading").fadeOut(600,function(){e(this).remove();e(c).children().show();var n=e(window).scrollTop()+e(window).outerHeight()/2-e(c).outerHeight()/2;t.jqNiftyModal.settings.ModalVerticallyCenter&&e(c).css({top:n});w.executeCallback()})})}}else if(i=="url"){e(c).addClass("jqNMMUrl").css({width:e(window).width(),height:e(window).height()-200});e("