1(function() { 2 var oba; 3 4 oba = window.oba ? window.oba : {}; 5 6 oba.Header = (function() { 7 Header.prototype.searchURL = "https://www.carnival.com/search.aspx?q="; 8 9 Header.prototype.animationTime = 300; 10 11 Header.prototype.closeTime = 500; 12 13 Header.prototype.transitions = Modernizr.csstransitions; 14 15 Header.prototype.placeholder = (function() { 16 var i; 17 i = document.createElement('input'); 18 return 'placeholder' in i; 19 })(); 20 21 Header.prototype.touch = Modernizr.touch; 22 23 function Header(el) { 24 this.el = el; 25 if (this.el.length) { 26 this.insertHeaderHTML(); 27 } 28 } 29 30 Header.prototype.insertHeaderHTML = function() { 31 var _this = this; 32 return $.ajax({ 33 type: "GET", 34 dataType: "html", 35 url: "./_globalHeader.html", 36 success: function(html) { 37 var $html, pathname; 38 $html = $(html); 39 pathname = window.location.pathname.toLowerCase(); 40 if (pathname === "/index.html" || pathname === "/" || pathname === "/explore/index.html" || pathname === "/explore/") { 41 $html.find(".active").removeClass("active"); 42 } 43 _this.el.after($html); 44 _this.el.remove(); 45 _this.el = $html; 46 return _this.navInit(); 47 } 48 }); 49 }; 50 51 Header.prototype.navInit = function() { 52 this.headerAlert(); 53 this.initSubscribe(); 54 this.navTooltips(); 55 this.initFlyouts(); 56 this.iconHover(); 57 this.initNoClick(); 58 this.supportPlaceholder(); 59 this.initSearch(); 60 return this.ignoreEmptyClicks(); 61 }; 62 63 Header.prototype.headerAlert = function() { 64 return this.el.on("click", ".header-alert-close", function(e) { 65 $(e.currentTarget).parents(".header-alert").slideUp("fast"); 66 return e.preventDefault(); 67 }); 68 }; 69 70 Header.prototype.initSubscribe = function() { 71 var $subscribe, $triggers; 72 $subscribe = this.el.find(".header-subscribe"); 73 $triggers = this.el.find("#subscribeLink").add($subscribe.find(".close")); 74 return $triggers.bind("click", function(e) { 75 $subscribe.slideToggle("fast"); 76 return e.preventDefault(); 77 }); 78 }; 79 80 Header.prototype.navTooltips = function() { 81 var $triggers, $white, tooltipTimeout, 82 _this = this; 83 $triggers = this.el.find(".nav-tooltip-trigger"); 84 $white = this.el.find(".header-branding"); 85 tooltipTimeout = null; 86 return $triggers.each(function(i, trig) { 87 var $localeLink, $localeTooltip, id, myTimeout; 88 $localeLink = $(trig); 89 id = $localeLink.data("id"); 90 $localeTooltip = _this.el.find(".nav-tooltip[data-id='" + id + "']"); 91 myTimeout = null; 92 $localeLink.add($localeTooltip).data("mouseenter", function() { 93 if (myTimeout) { 94 window.clearTimeout(myTimeout); 95 } 96 if (tooltipTimeout) { 97 window.clearTimeout(tooltipTimeout); 98 } 99 $localeLink.parent().addClass("hover"); 100 $white.addClass("increaseZ"); 101 return $triggers.not($localeLink).each(function(x, elem) { 102 return $(elem).parent().removeClass("hover"); 103 }); 104 }).bind("mouseenter", $localeLink.data("mouseenter")).data("mouseleave", function(immediate) { 105 if (immediate === true) { 106 $localeLink.parent().removeClass("hover"); 107 return $white.removeClass("increaseZ"); 108 } else { 109 myTimeout = window.setTimeout(function() { 110 return $localeLink.parent().removeClass("hover"); 111 }, _this.closeTime); 112 return tooltipTimeout = window.setTimeout(function() { 113 return $white.removeClass("increaseZ"); 114 }, _this.closeTime); 115 } 116 }).bind("mouseleave", $localeLink.data("mouseleave")); 117 if (_this.touch) { 118 return $localeLink.unbind("mouseenter mouseleave").bind("click", function(e) { 119 var $par; 120 $par = $localeLink.parent(); 121 if ($par.hasClass("hover")) { 122 $localeLink.data("mouseleave")(true); 123 } else { 124 $localeLink.data("mouseenter")(); 125 } 126 return e.preventDefault(); 127 }); 128 } 129 }); 130 }; 131 132 Header.prototype.initFlyouts = function() {
133 var $clickable, $flyoutLinks, $flyouts, closeTimeout, 134 _this = this; 135 $clickable = this.el.find("a[data-ccl-flyout-click='true']").addClass("canHover"); 136 $flyoutLinks = this.el.find("a[data-ccl-flyout]").not("[data-flyout-disabled='true']").not($clickable).addClass("canHover"); 137 $flyouts = this.el.find(".flyout"); 138 closeTimeout = null; 139 $flyouts.each(function(i, fly) { 140 var childCount, o; 141 o = $(fly).find(">ul"); 142 childCount = o.find(">li").length; 143 return o.addClass("children-" + childCount); 144 }); 145 if (this.transitions) { 146 $flyoutLinks.each(function(i, lnk) { 147 var $btm, $span, $top; 148 $span = $(lnk).find("span").addClass("org"); 149 $top = $('<span class="top">' + $span.html() + '</span>'); 150 $btm = $('<span class="btm">' + $span.html() + '</span>'); 151 return $(lnk).append($top, $btm); 152 }); 153 } 154 $flyoutLinks.add($clickable).data("mouseenter", function(lnk) { 155 var $flyout, $link, flyoutID; 156 $link = $(lnk); 157 flyoutID = $link.data("cclFlyout"); 158 $flyout = $link.data("flyout"); 159 if ($link.hasClass("canHover")) { 160 $flyoutLinks.add($clickable).not($link).removeClass("hover"); 161 $link.addClass("hover initialized"); 162 } 163 if (!$flyout) { 164 $flyout = _this.el.find(".flyout[data-ccl-flyout='" + flyoutID + "']"); 165 $link.data("flyout", $flyout); 166 } 167 _this.exposeFlyouts($flyout); 168 window.clearTimeout(closeTimeout); 169 return closeTimeout = null; 170 }).bind("mouseenter", function(e) { 171 return $(e.currentTarget).data("mouseenter")(e.currentTarget); 172 }); 173 $flyoutLinks.add($flyouts).add($clickable).data("mouseleave", function(immediate) { 174 if (immediate === true) { 175 return _this.closeAll(); 176 } else { 177 return closeTimeout = window.setTimeout(function() { 178 return _this.closeAll(); 179 }, _this.closeTime); 180 } 181 }).bind("mouseleave", function(e) { 182 return $(e.currentTarget).data("mouseleave")(); 183 }); 184 $clickable.unbind("mouseenter mouseleave").bind("click", function(e) { 185 var $link; 186 $link = $(e.currentTarget); 187 if ($link.hasClass("hover")) { 188 $link.data("mouseleave")(true); 189 } else { 190 $link.data("mouseenter")(e.currentTarget); 191 } 192 e.preventDefault(); 193 return e.stopPropagation(); 194 }); 195 $flyouts.data("mouseenter", function() { 196 window.clearTimeout(closeTimeout); 197 return closeTimeout = null; 198 }).bind("mouseenter", function(e) { 199 return $(e.currentTarget).data("mouseenter")(); 200 }); 201 if (this.touch) { 202 return $flyoutLinks.unbind("mouseenter mouseleave").bind("click", function(e) { 203 var $link; 204 $link = $(e.currentTarget); 205 if ($link.hasClass("hover")) { 206 $link.data("mouseleave")(true); 207 } else { 208 $link.data("mouseenter")(e.currentTarget); 209 } 210 return e.preventDefault(); 211 }); 212 } 213 }; 214 215 Header.prototype.exposeFlyouts = function($flyout) { 216 var $wrap; 217 $wrap = this.el.find(".header-flyouts"); 218 this.closeAll($flyout); 219 if (this.transitions) { 220 if (!$wrap.hasClass("exposed")) { 221 $flyout.addClass("active"); 222 $wrap.addClass("exposed"); 223 return this.showingTimeout = window.setTimeout(function() { 224 return $flyout.addClass("active showUL"); 225 }, this.animationTime); 226 } else { 227 $flyout.addClass("active"); 228 return window.setTimeout(function() { 229 return $flyout.addClass("showUL"); 230 }, 100); 231 } 232 } else { 233 if (!$wrap.hasClass("exposed")) { 234 $flyout.addClass("active showUL"); 235 return $wrap.addClass("exposed"); 236 } else { 237 return $flyout.addClass("active showUL"); 238 } 239 } 240 }; 241 242 Header.prototype.closeAll = function($exclude) {
243 var $flyouts, $inputs, $wrap; 244 $wrap = this.el.find(".header-flyouts"); 245 $flyouts = $wrap.find(".flyout"); 246 $inputs = $wrap.find("input:visible"); 247 if (this.showingTimeout) { 248 window.clearTimeout(this.showingTimeout); 249 this.showingTimeout = null; 250 } 251 $inputs.blur(); 252 if ($exclude) { 253 $flyouts = $flyouts.not($exclude); 254 return $flyouts.removeClass("showUL active"); 255 } else { 256 $wrap.removeClass("exposed"); 257 this.el.find(".canHover.hover").removeClass("hover"); 258 if (this.transitions) { 259 return window.setTimeout(function() { 260 return $flyouts.removeClass("showUL active"); 261 }, this.animationTime); 262 } else { 263 return $flyouts.removeClass("showUL active"); 264 } 265 } 266 }; 267 268 Header.prototype.iconHover = function() { 269 var $links; 270 $links = this.el.find(".flyout > ul > li > a"); 271 $links.bind("mouseenter", function(e) { 272 var $img, def, hover; 273 $img = $(e.currentTarget).find(".img img"); 274 def = $img.data("default"); 275 hover = $img.data("hover"); 276 if (def && hover) { 277 return $img.attr("src", hover); 278 } 279 }); 280 return $links.bind("mouseleave", function(e) { 281 var $img, def, hover; 282 $img = $(e.currentTarget).find(".img img"); 283 def = $img.data("default"); 284 hover = $img.data("hover"); 285 if (def && hover) { 286 return $img.attr("src", def); 287 } 288 }); 289 }; 290 291 Header.prototype.initNoClick = function() { 292 var $noClick; 293 $noClick = this.el.find("a[data-link-disabled='true']"); 294 return $noClick.bind("click", function() { 295 return false; 296 }); 297 }; 298 299 Header.prototype.supportPlaceholder = function() { 300 var $inputs; 301 if (this.placeholder) { 302 return false; 303 } 304 $inputs = this.el.find("[placeholder]"); 305 return $inputs.focus(function(e) { 306 var o, ph; 307 o = $(e.currentTarget); 308 ph = o.attr("placeholder"); 309 if (o.val() === ph) { 310 return o.val("").removeClass("placeholder"); 311 } 312 }).blur(function(e) { 313 var o, ph; 314 o = $(e.currentTarget); 315 ph = o.attr("placeholder"); 316 if (o.val() === "") { 317 return o.val(ph).addClass("placeholder"); 318 } 319 }).trigger("focus").trigger("blur"); 320 }; 321 322 Header.prototype.initSearch = function() { 323 var $search, $submit, 324 _this = this; 325 $search = this.el.find("#ccl_header_site-search"); 326 $submit = this.el.find("#ccl_header_site-search-submit"); 327 $submit.click(function(e) { 328 var val; 329 val = $.trim($search.val()); 330 if (val.length && val.toLowerCase() !== $search.attr("placeholder").toLowerCase()) { 331 window.location.href = _this.searchURL + encodeURIComponent(val); 332 } 333 return e.preventDefault(); 334 }); 335 return $search.keyup(function(e) { 336 if (e.keyCode === 13) { 337 $submit.click(); 338 e.preventDefault(); 339 return e.stopPropagation(); 340 } 341 }); 342 }; 343 344 Header.prototype.ignoreEmptyClicks = function() { 345 return $("body").on("click", "a[href=#]", function(e) { 346 return e.preventDefault(); 347 }); 348 }; 349 350 return Header; 351 352 })(); 353 354 window.oba = oba; 355 356 (function($) { 357 return $('.ph-header').each(function(i, el) { 358 return new oba.Header($(el)); 359 }); 360 })(jQuery); 361 362}).call(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.