function query_params(qry) {
var pairs = (qry || location.search).replace(/^\?/, "").split("&"), params = {};
_.each(pairs, function (p) {
var kv = p.split("=");
params[kv[0]] = decodeURIComponent(kv[1]);
});
return params;
}
function euclidean_distance(pt1, pt2) {
return Math.sqrt(Math.pow(pt2[0] - pt1[0], 2) + Math.pow(pt2[1] - pt1[1], 2));
}
function remove_node(node) {
return node.parentNode.removeChild(node);
}
window.Venue = Backbone.Model.extend({});
window.Event = Backbone.Model.extend({initialize:function () {
this.set({absolute_url:"http://seatgeek.com" + this.get("url")}, {silent:true});
}});
window.AppView = Backbone.View.extend({events:{"click .listing .select":"handleBuyClick", "click .alt-listing .select":"handleBuyClick", "click .zoom-here":"handleZoomHere", "click .show-details":"handleShowDetails", "click .details-close":"handleShowDetails"}, initialize:function () {
var that = this, params = {}, query = query_params();
this.event = new Event(this.options.event);
this.venue = new Venue(this.options.venue);
params["id"] = this.event.get("id");
_.each(query, function (value, key) {
params[key] = value;
}, this);
params["trf"] = 1;
this.listings = new ListingCollection();
function default_listings_source(callback) {
jQuery.get('/event/tickets/', params, function (response) {
if (!response.deal_quality) {
jQuery("body").addClass("no-deal-quality");
jQuery("#sort-bar .price").addClass("asc");
}
that.listings.reset(response.listings);
that.listings.setupDeprecatedState(response);
callback();
});
}
(this.options.listings_source || default_listings_source)(function () {
SG.map.fire("sg:listings-ready");
});
jQuery(function () {
SG.map.init(that.options);
that.filters = new FiltersView({el:jQuery(".map-content .filters")[0]});
that.sidebar = new SidebarView({el:jQuery(".map-content .sidebar")[0]});
});
jQuery("sg:login", function () {
SG.map.track("login");
});
}, handleBuyClick:function (e) {
var select = jQuery(e.currentTarget), alt = select.closest(".alt-listing"), ticket = alt.size() == 1 ? alt : select.closest(".listing");
var params = {url:ticket.find("a.select").attr("href"), price:ticket.attr("price"), section:ticket.attr("section"), row:ticket.attr("row"), quantity:ticket.attr("quantity"), original:ticket.attr("baseprice"), fees:ticket.attr("fees"), shipping:ticket.attr("shipping"), pickup_only:ticket.attr("pickup_only"), market_name:ticket.attr("market"), market_full:ticket.attr("market_full"), splits:ticket.attr("splits").split(",")};
SG.map.track("buy-now-click", jQuery(select).is(".sidebar *") ? "sidebar" : "popup");
if (this.buy_click_callback) {
if (!this.buy_click_callback.call(this, e, params)) {
return;
}
}
function post_click() {
var show_timeout, mousemove_handler;
mousemove_handler = function () {
if (show_timeout)clearTimeout(show_timeout);
jQuery(document).unbind("mousemove", mousemove_handler);
};
jQuery(document).mousemove(mousemove_handler);
show_timeout = setTimeout(function () {
jQuery(document).unbind("mousemove", mousemove_handler);
SG.post_purchase();
}, 10000);
}
if (params["market_name"] === "ebay") {
e.preventDefault();
SG.warn_ebay(params, {callback:post_click});
} else {
post_click();
}
}, setBuyClickCallback:function (cb) {
this.buy_click_callback = cb;
}, handleZoomHere:function (e) {
var el = jQuery(e.currentTarget), l = el.closest(".listing-container").children(".listing"), key = l.attr("mapkey"), k = helpers.parseMapKey(key);
SG.map.zoomToSection(k.s);
SG.map.fire("sg:row-click", {key:key, el:el});
SG.map.track("zoom-here-click", el.is(".sidebar *") ? "sidebar" : "popup");
return false;
}, handleShowDetails:function (e) {
var el = jQuery(e.currentTarget), showDetails = true;
if (el.hasClass("details-close")) {
var details = el.closest(".details");
}
else {
var details = el.parent().parent().parent().siblings(".details");
}
if (!details.is(":visible")) {
details.slideDown(function () {
SG.map.repositionToRevealPopup();
SG.map.showListingDetails(details);
});
el.closest(".listing-container").find(".show-details a").text("hide details");
showDetails = true;
} else {
details.slideUp();
el.closest(".listing-container").find(".show-details a").text("show details");
showDetails = false;
}
SG.map.track("show-details-" + (showDetails ? "open" : "close"), el.is(".sidebar *") ? "sidebar" : "popup");
return false;
}, render:function (e) {
app.sidebar.render();
try {
SG.map.render();
} catch (e) {
}
}});
var SG = SG || {};
SG.chart = SG.chart || {};
SG.chart = (function (C) {
var loaded = false;
return{load:function () {
if (loaded)return false;
jQuery.getJSON("/event/price_graph_data", {id:app.event.get("id")}, function (data) {
loaded = true;
if (data.length <= 0) {
jQuery(".analytics-graph .inner").html(['<div style="padding:120px 0 0 4px; text-align:center; font-size:14px; text-shadow:0px 1px 1px black; color:white">', 'Graph currently unavailable', '</div>'].join("\n"));
return;
}
var has_price_ratio = _.all(data, function (t, date) {
return!!t["avg_price_ratio"];
});
if (has_price_ratio) {
jQuery(".analytics-graph h4").text("Historical prices as a % of face value")
}
var d = _.map(data, function (t, date) {
var ps = date.split("-"), dt = new Date(parseInt(ps[0], 10), parseInt(ps[1], 10) - 1, parseInt(ps[2], 10));
return[dt.getTime(), parseFloat(t[has_price_ratio ? "avg_price_ratio" : "avg_price"], 10), parseInt(t["quantity"], 10)];
});
var rolling_days = 5, smoothed = [], roll_sum, roll_qnt;
for (var i = 0; i < d.length; ++i) {
if (i < rolling_days)continue;
roll_sum = 0, roll_qnt = 0;
for (var j = i - rolling_days + 1; j <= i; ++j) {
roll_sum += d[j][1] * d[j][2];
roll_qnt += d[j][2];
}
smoothed.push([d[i][0], Math.round((roll_sum / roll_qnt) * 100) / 100]);
}
var series1 = {data:smoothed, color:"#368EBB", shadowSize:4};
var opts = {xaxis:{mode:"time", ticks:7, minTickSize:[5, "day"]}, yaxis:{min:0, tickFormatter:function (val, axis) {
return has_price_ratio ? Math.round(val * 100.0) + "%" : "$" + Math.round(val);
}}, grid:{borderWidth:0, minBorderMargin:0, color:"#374F6C"}, series:{lines:{fill:true, fillColor:{colors:[
{opacity:0.55},
{opacity:0.2}
]}, shadowSize:5}}};
jQuery.plot(jQuery(".analytics-graph .inner"), [series1], opts);
});
}};
})(SG.chart);
var SG = SG || {};
SG.draggable = function (elem, receiver) {
var that = this;
this.dragging = false;
this.lastdX = null;
this.lastdY = null;
this.startX = null;
this.startY = null;
this.mouseStartX = null;
this.mouseStartY = null;
this.elem = elem;
this.receiver = receiver || elem;
function dragMouse(e) {
var dX, dY;
if (!that.dragging)return;
dX = e.clientX - that.mouseStartX, dY = e.clientY - that.mouseStartY;
if (dX !== that.lastdX) {
that.elem.style.left = (that.startX + dX) + "px";
that.lastdX = dX;
}
if (dY !== that.lastdY) {
that.elem.style.top = (that.startY + dY) + "px";
that.lastdY = dY;
}
}
function dragStop(e) {
that.dragging = false;
jQuery(that.receiver).removeClass("dragging");
}
jQuery(document).mousemove(dragMouse);
jQuery(document).mouseup(dragStop);
if (jQuery.browser.msie)jQuery(document).click(dragStop);
jQuery(this.receiver).mousedown(function (e) {
that.dragging = true;
that.lastdX = null;
that.lastdY = null;
that.startX = that.elem.offsetLeft;
that.startY = that.elem.offsetTop;
that.mouseStartX = e.clientX;
that.mouseStartY = e.clientY;
jQuery(that.receiver).addClass("dragging");
return false;
});
};
jQuery(function () {
var price_slider = jQuery("#price_slider");
function slider_tranformation(f, invf, slmin, slmax, valmin, valmax) {
this.f = f;
this.invf = invf;
this.slmin = slmin;
this.slmax = slmax;
this.valmin = valmin;
this.valmax = valmax;
this.vmin = this.invf(valmin);
this.vmax = this.invf(valmax);
this.scale = (this.vmax - this.vmin) / (this.slmax - this.slmin)
}
slider_tranformation.prototype.sliderToVal = function (sv) {
if (sv == this.slmin)return this.valmin;
if (sv == this.slmax)return this.valmax;
return this.f(this.vmin + this.scale * (sv - this.slmin));
};
slider_tranformation.prototype.valToSlider = function (v) {
return this.slmin + (this.invf(v) - this.vmin) / this.scale;
};
function setup_price_slider(max) {
var max = max < 0 ? 1000 : max;
var transform = new slider_tranformation(function (x) {
return Math.pow(x, 2)
}, function (x) {
return Math.pow(x, 1 / 2)
}, 0, 171, 0, max);
jQuery("#max_price").val(max);
price_slider.slider({min:0, max:171, step:1, values:[0, 171], range:true, slide:function update_inputs() {
var min_handle = price_slider.slider("values", 0), max_handle = price_slider.slider("values", 1);
jQuery("#min_price").val(Math.floor(transform.sliderToVal(min_handle)));
jQuery("#max_price").val(Math.ceil(transform.sliderToVal(max_handle)));
}, stop:function (event, ui) {
var min_handle = price_slider.slider("values", 0), max_handle = price_slider.slider("values", 1);
jQuery("#min_price").val(Math.floor(transform.sliderToVal(min_handle)));
jQuery("#max_price").val(Math.ceil(transform.sliderToVal(max_handle)));
app.filters.filterListings();
SG.map.track("filter-change", "price");
}});
if (Browser.IE) {
jQuery('.filters .slider .handle').css({'top':'0', 'margin-top':'1px'});
jQuery('.filters .slider .track').css({'position':'absolute', 'margin-top':'6px'});
}
jQuery("#min_price").add("#max_price").unbind("change");
jQuery("#min_price").add("#max_price").change(function () {
price_slider.slider("values", [transform.valToSlider(jQuery("#min_price").val()), transform.valToSlider(jQuery("#max_price").val())]);
});
}
;
SG.map.observe("sg:listings-ready", function () {
var prices = _.map(app.listings.getAllListings(), function (l) {
return l.pf;
}), avg, median = prices[Math.floor(prices.length / 2)], sum = 0, i = 0, max = Math.max.apply(Math, prices);
setup_price_slider(max);
for (; i < prices.length; ++i)sum += prices[i];
avg = Math.round(sum / prices.length);
jQuery("#avg_price").html(avg > 0 ? "$" + avg : "--");
});
SG.map.observe("sg:listings-ready", function () {
var prs, avg, sum = 0, i = 0;
if (window.event_info.has_face_value) {
prs = _.filter(_.map(app.listings.getAllListings(), function (l) {
return l.pr;
}), function (pr) {
return pr !== undefined;
});
for (; i < prs.length; ++i)sum += parseFloat(prs[i], 10);
avg = Math.round(sum / prs.length);
jQuery("#avg_price_ratio").html(avg > 0 ? avg + "%" : "--");
}
});
var zoom_slider = jQuery(".zoom .track"), zoom_handle = jQuery(".zoom .handle");
zoom_slider.slider({min:0, max:3, step:1, value:0, orientation:"vertical", change:function (event, ui) {
var val = (ui.value - 3) * -1;
SG.map.setView(ui.value);
SG.map.track("zoom", "slider");
}});
jQuery(".zoom .track-ext").click(function () {
zoom_slider.slider("value", 3)
});
SG.map.observe("sg:map-view-change", function (e, data) {
zoom_slider.slider("value", data.index);
});
jQuery(".no-fees-message .close").click(function (e) {
jQuery(".no-fees-message").hide();
return false;
});
var atimeout = null;
var time = 12000;
function runAnimation() {
jQuery('.scrolling-sellers').animate({left:'-1087px'}, time).animate({left:'286px'}, time);
jQuery('.magnified-sellers').animate({left:'-1852px'}, time).animate({left:'127px'}, time);
atimeout = setTimeout("runAnimation()", time * 2);
}
jQuery(function () {
runAnimation();
});
function stopAnimation() {
clearTimeout(atimeout);
jQuery('.animated').stop(true, false);
jQuery('#listing_sidebar').show(100);
jQuery('#window').css('right', '332px');
SG.map.centerMap();
jQuery('#sgloading').fadeOut(250, function () {
jQuery('#loading-animation').remove();
});
}
SG.map.observe("sg:map-ready", function () {
stopAnimation();
setTimeout('runPreloadImages();', 3000);
});
});
jQuery(function () {
var recursions = 0;
function adjustTitleWidth() {
if (jQuery(".event-info h1 span").size() <= 0)return;
var m = jQuery(".event-info h1 span"), width = m.width() + parseInt(m.closest(".event-info").css("padding-left"), 10), maxwidth = jQuery("#listing_sidebar").position().left, h1;
if (width > maxwidth && recursions <= 13) {
h1 = m.closest("h1");
h1.css({fontSize:(parseInt(h1.css("fontSize"), 10) - 1) + "px"});
recursions += 1;
adjustTitleWidth();
} else {
recursions = 0;
}
}
;
adjustTitleWidth();
jQuery(window).resize(adjustTitleWidth);
});
function applyFilters(filters, ls) {
function all(fs, listing) {
for (var i = 0, ilen = fs.length; i < ilen; ++i)
if (!fs[i](listing))return false;
return true;
}
var ret = [];
for (var i = 0, ilen = ls.length; i < ilen; ++i)
if (all(filters, ls[i]))ret.push(ls[i]);
return ret;
}
;
function priceFilter(min, max) {
return function (listing) {
var p = listing.pf;
if (!min && !max)return true;
if (!min)return p <= max;
if (!max)return p >= min;
return p <= max && p >= min;
};
}
function quantityFilter(num) {
var inum = parseInt(num, 10);
return function (l) {
return l.sp && _.indexOf(l.sp, inum) !== -1;
};
}
function marketFilter(market) {
var lmarket = market.toLowerCase();
return function (l) {
return l.m.toLowerCase() == lmarket;
};
}
function eticketsFilter() {
return function (l) {
return!!l.et;
};
}
function belowFaceValueFilter() {
return function (l) {
return l.pf < l.fv;
};
}
function parkingFilter() {
return function (l) {
if (l.pk) {
return false;
}
return!(l.sr.match(/park/i) || l.rr.match(/park/i));
};
}
function unmappableFilter() {
return function (l) {
return!(l.mk == '' || l.mk == undefined);
};
}
function compareByPriceRatioThenPriceAsc(a, b) {
if (a.pr && b.pr)
return a.pr - b.pr;
if (!a.pr && !b.pr)
return a.pf - b.pf;
if (a.pr)
return-1;
if (b.pr)
return 1;
throw"bug in compareByPriceRatioThenPriceAsc";
}
function compareByPriceRatioThenPriceDesc(a, b) {
if (a.pr && b.pr)
return b.pr - a.pr;
if (!a.pr && !b.pr)
return b.pf - a.pf;
if (a.pr)
return-1;
if (b.pr)
return 1;
throw"bug in compareByPriceRatioThenPriceDesc";
}
function compareByDealQualityDescThenPriceAsc(a, b) {
if (a.dq === b.dq)
return a.pf - b.pf;
if (a.dq === null)
return 1;
if (b.dq === null)
return-1;
return b.dq - a.dq;
}
function compareByDealQualityAscThenPriceDesc(a, b) {
if (a.dq === b.dq)
return b.pf - a.pf;
if (a.dq === null)
return-1;
if (b.dq === null)
return 1;
return a.dq - b.dq;
}
function compareByDQAsc(a, b) {
if (a.dq === null && b.dq === null) {
return 0;
}
if (b.dq === null)
return-1;
if (a.dq === null)
return 1;
return a.dq - b.dq;
}
function compareByDQDesc(a, b) {
if (a.dq === null && b.dq === null) {
return 0;
}
if (a.dq === null)
return-1;
if (b.dq === null)
return 1;
return b.dq - a.dq;
}
var comparePriceAsc = function (a, b) {
return a.pf - b.pf;
}, comparePriceDesc = function (a, b) {
return b.pf - a.pf;
}, compareSectionAsc = function (a, b) {
var sectionCompare = a.s.localeCompare(b.s);
if (sectionCompare == 0) {
return compareByDQAsc(a, b);
}
return sectionCompare;
}, compareSectionDesc = function (a, b) {
var sectionCompare = b.s.localeCompare(a.s);
if (sectionCompare == 0) {
return compareByDQDesc(a, b);
}
return sectionCompare;
}, compareAvailableAsc = function (a, b) {
return a.q - b.q;
}, compareAvailableDesc = function (a, b) {
return b.q - a.q;
};
var groupListings = function (ls, quantitySelected) {
var grouped = {}, ungrouppable = [], markets = ["ticketsnow", "ticketnetwork", "razorgator", "vividseats", "ticketcity", "empiretickets", "stubhub"];
ls.sort(function (a, b) {
if (a.pf == b.pf) {
return _.indexOf(markets, a.m) - _.indexOf(markets, b.m);
}
return a.pf - b.pf;
});
_.each(ls, function (l) {
var key, q, section_row_key;
if (!l.s) {
l.alt = [];
ungrouppable.push(l);
return;
}
section_row_key = l.mk !== undefined ? l.mk : (l.s + "_" + l.r);
q = quantitySelected > 0 ? quantitySelected : l.q;
key = section_row_key + '--' + q + '--' + l.e;
if (!(key in grouped)) {
grouped[key] = l;
grouped[key].alt = [];
grouped[key].gidx = 1;
} else {
delete l.alt;
l.gidx = (grouped[key].alt.length + 2);
grouped[key].alt.push(l);
}
});
var vgrouped = _.values(grouped);
var catted = vgrouped.concat(ungrouppable);
return catted;
};
window.FiltersView = Backbone.View.extend({events:{"change":"filterListings"}, getMinPrice:function () {
return parseInt(jQuery('#min_price').val(), 10) || 0;
}, getMaxPrice:function () {
if (jQuery('#max_price').val() == "2000+")return null;
return parseInt(jQuery('#max_price').val(), 10);
}, getQuantity:function () {
return parseInt(jQuery('#quantity').val(), 10);
}, getEtickets:function () {
return jQuery('#etickets_only').is(':checked');
}, getMarket:function () {
return jQuery('#market').val();
}, getBelowFaceValue:function () {
return event_info.has_face_value && jQuery('#below-face-value').is(':checked');
}, getFilters:function () {
var filters = [];
filters.push(parkingFilter());
if (SG.map.hideUnmappable()) {
filters.push(unmappableFilter());
}
var min = this.getMinPrice(), max = this.getMaxPrice();
filters.push(priceFilter(min, max));
var q = this.getQuantity();
if (q > 0)filters.push(quantityFilter(q));
var et = this.getEtickets();
if (et)filters.push(eticketsFilter());
var market = this.getMarket();
if (market)filters.push(marketFilter(market));
if (this.getBelowFaceValue())filters.push(belowFaceValueFilter());
return filters;
}, getSort:function () {
function getSortValue() {
var sort = jQuery("#sort-bar .asc").add("#sort-bar .desc").eq(0), sortby = sort.attr("sortby");
return sortby + ":" + (sort.is(".asc") ? "asc" : "desc");
}
var sortValue = getSortValue();
var sortf = {"deal-quality:asc":compareByDealQualityAscThenPriceDesc, "deal-quality:desc":compareByDealQualityDescThenPriceAsc, "price-ratio:asc":compareByPriceRatioThenPriceAsc, "price-ratio:desc":compareByPriceRatioThenPriceDesc, "price:asc":comparePriceAsc, "price:desc":comparePriceDesc, "section:asc":compareSectionAsc, "section:desc":compareSectionDesc, "available:asc":compareAvailableAsc, "available:desc":compareAvailableDesc}[sortValue];
return sortf || compareByDealQualityDescThenPriceAsc;
}, setRank:function (ls, key, group, checkdq) {
for (var i = 0; i < ls.length; ++i) {
if (!(checkdq && ls[i].dq === undefined)) {
ls[i].ranks[key] = i + 1;
}
if (group) {
_.each(ls[i].alt, function (n) {
if (!(checkdq && ls[i].dq === undefined)) {
n.ranks[key] = i + 1;
}
});
}
}
}, computeRanks:function () {
var unfiltered = app.listings.getAllListings();
_.each(unfiltered, function (n) {
n.ranks = {};
});
unfiltered = _.sortBy(unfiltered, function (n) {
return n.pf;
});
this.setRank(unfiltered, 'upf', false);
unfiltered = _.sortBy(unfiltered, function (n) {
return-1 * n.dq;
});
this.setRank(unfiltered, 'udq', false, true);
var filtered = app.listings.getListings();
this.setRank(filtered, 'fuv', true);
filtered = _.sortBy(filtered, function (n) {
return n.pf;
});
this.setRank(filtered, 'fpf', true);
filtered = _.sortBy(filtered, function (n) {
return-1 * n.dq;
});
this.setRank(filtered, 'fdq', true, true);
}, filterListings:function (e) {
if (e && e.target) {
switch (jQuery(e.target).attr("id")) {
case"quantity":
SG.map.track("filter-change", "quantity");
break;
case"etickets_only":
SG.map.track("filter-change", "etickets");
break;
}
}
var ls = applyFilters(this.getFilters(), app.listings.getAllListings());
SG.map.log("sorting");
if (!SG.map.isGa()) {
ls = groupListings(ls, this.getQuantity());
}
ls.sort(this.getSort());
app.listings.setListings(ls);
this.computeRanks();
app.render();
jQuery('.scroll').animate({scrollTop:0}, 0);
}});
(function () {
var mapkeyre = /^s:([a-z0-9-]+)(?: r:([a-z0-9-]+))?$/i;
window.helpers = {listing_url:function (l) {
return"/event/click/?" + SG.fn.serializeParams({tid:l.id, eid:app.event.get("id"), section:l.s, row:l.r, quantity:app.filters.getQuantity() || l.q, price:l.pf, baseprice:l.p, market:l.m, sg:SG.map.isInteractive() ? 1 : 0, dq:l.dq ? l.dq : -1, rfuv:l.ranks.fuv ? l.ranks.fuv : -1, rfpf:l.ranks.fpf ? l.ranks.fpf : -1, rfdq:l.ranks.fdq ? l.ranks.fdq : -1, rupf:l.ranks.upf ? l.ranks.upf : -1, rudq:l.ranks.udq ? l.ranks.udq : -1, gidx:l.gidx ? l.gidx : -1});
}, attrs_for_listing:function (l) {
var params = {section:l.s, row:l.r || "", mapkey:l.mk || "", price:l.pf, baseprice:l.p, fees:l.f, shipping:l.sh, pickup_only:l.pu, eticket:l.et, market:l.m, market_full:l.mf, quantity:l.q, splits:l.sp.join(",")}, str = [];
for (var p in params) {
str.push(p + '="' + params[p] + '"');
}
return str.join(" ");
}, parseMapKey:function (key) {
var matches = key.match(mapkeyre);
if (matches) {
if (matches[2])
return{s:matches[1], r:matches[2]}; else
return{s:matches[1]};
}
throw"Improperly formatted mapkey: " + key;
}, pretty_section_name:function (s) {
if (!s)return"";
return _.map(s.split(/[\s-]+/),
function (w) {
return w.capitalize()
}).join(" ");
}};
})();
var SG = SG || {};
SG.map = SG.map || {};
(function (M) {
M.highlightSingleSec = function (section, color) {
var view = M.getView();
var shade = (color ? color : '#ff0000');
var path_style = {"stroke":shade, "stroke-width":2, "opacity":0.75, "fill":shade, "fill-opacity":0.33};
var path = M.getMapData(section).path;
var shape = view.drawShape(path);
shape.attr(path_style);
};
M.highlightSingleRow = function (section, row, color) {
var view = M.getView();
var shade = (color ? color : '#ff0000');
var path_style = {"stroke":shade, "stroke-width":2, "opacity":0.75, "fill":shade, "fill-opacity":0.33};
var path = M.getMapData(section).rows[row].path;
var shape = view.drawShape(path);
shape.attr(path_style);
};
M.hlightSecs = function () {
if (hlight_data) {
for (var key in hlight_data) {
if (hlight_data.hasOwnProperty(key)) {
var options = hlight_data[key];
M.highlightSingleSec(key, options.hue);
}
}
}
};
M.hlightRows = function () {
var n_buckets = 30;
if (hlight_data) {
var min = 9999999, max = 0;
for (var j = 0; j < hlight_data.length; j++) {
if (parseFloat(hlight_data[j].price) < min)min = parseFloat(hlight_data[j].price);
if (parseFloat(hlight_data[j].price) > max)max = parseFloat(hlight_data[j].price);
}
for (var i = 0; i < hlight_data.length; i++) {
var obj = hlight_data[i];
var full = obj.combo;
var sec = full.substr(0, full.indexOf(":"));
var row = full.substr(full.indexOf(":") + 1, full.length);
var price = parseFloat(obj.price);
var bucket = bucketit(min, max, n_buckets, price);
var green = Math.round(255 / n_buckets * bucket);
var blue = Math.round(255 - 225 / n_buckets * bucket);
var hue = rgbToHex(0, green, blue);
if (row == 'none') {
M.highlightSingleSec(sec, hue);
} else {
M.highlightSingleRow(sec, row, hue);
}
}
}
};
})(SG.map);
function rgbToHex(r, g, b) {
return"#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function bucketit(min, max, num, value) {
for (var i = 0; i < num; i++) {
if (value <= (min + (max - min) / num * (i + 1)))return i;
}
return num - 1;
}
find_clusters = (function () {
function xs_from_pts(pts) {
return _.map(pts, function (p) {
return p[0]
})
}
function ys_from_pts(pts) {
return _.map(pts, function (p) {
return p[1]
})
}
function euclidean_distance(pt1, pt2) {
return Math.sqrt(Math.pow(pt2[0] - pt1[0], 2) + Math.pow(pt2[1] - pt1[1], 2));
}
function nearest_cluster(pt, clusters) {
var distances = _.map(clusters, function (c) {
return euclidean_distance(c, pt)
}), min_distance = Math.min.apply(Math, distances);
return _.indexOf(distances, min_distance);
}
return function find_clusters(pts) {
var num_clusters = 4, clusters = [], cluster_assignment = [];
xs = xs_from_pts(pts), ys = ys_from_pts(pts), xmin = Math.min.apply(Math, xs), ymin = Math.min.apply(Math, ys), xmax = Math.max.apply(Math, xs), ymax = Math.max.apply(Math, ys);
clusters = [
[xmin, ymin],
[xmax, ymin],
[xmax, ymax],
[xmin, ymax]
];
function pts_in_cluster(cluster) {
var pt_is = [];
_.each(cluster_assignment, function (ca, i) {
if (ca === cluster)pt_is.push(pts[i]);
});
return pt_is;
}
while (1) {
var prev_cluster_assignment = cluster_assignment.slice(0);
cluster_assignment = _.map(pts, function (p, i) {
var nearest = nearest_cluster(p, clusters);
return nearest;
});
_.each(clusters, function (c, i) {
var cpts = pts_in_cluster(i);
if (cpts.length == 0) {
return;
}
var xs = xs_from_pts(cpts), ys = ys_from_pts(cpts);
clusters[i] = [_.reduce(xs, function (memo, num) {
return memo + num;
}, 0) / xs.length, _.reduce(ys, function (memo, num) {
return memo + num;
}, 0) / ys.length];
});
if (prev_cluster_assignment.toString() === cluster_assignment.toString())
return clusters;
}
}
})();
Listing = Backbone.Model.extend({});
ListingCollection = Backbone.Collection.extend({model:Listing, url:function () {
return'/event/tickets/?id=' + app.event.get("id")
}, initialize:function (opts) {
this.all_listings = [];
this.current_listings = [];
}, setupDeprecatedState:function (response) {
function bucketListings(ls) {
var prop = "dq", sorted = _.sortBy(ls, function (l) {
return-1 * l.get(prop);
}), props = _.map(sorted, function (l) {
return l.get(prop);
}), propslen = props.length, pts = [0.004, 0.03, 0.10, 0.23, 0.45, 0.70];
_.map(sorted, function (l) {
var bucket = 0;
_.map(pts, function (pt) {
if (l.get(prop) < props[Math.floor(propslen * pt)])
++bucket;
});
l.set({bucket:bucket}, {silent:true});
});
if (sorted.length)sorted[0].set({bucket:0});
}
if (response.deal_quality) {
bucketListings(this.models);
} else {
_.each(this.models, function (l) {
l.set({bucket:4})
});
}
_.each(this.models, function (l) {
l.set({sf:helpers.pretty_section_name(l.get("s")), rf:helpers.pretty_section_name(l.get("r")), d:l.get("d") ? SG.fn.strip_html(l.get("d")) : "", alt:[]});
});
this.all_listings = _.pluck(this.sortBy(
function (l) {
return l.get("dq");
}).reverse(), "attributes");
this.current_listings = this.all_listings.slice(0);
}, getListings:function () {
return this.current_listings.slice(0);
}, getAllListings:function () {
return this.all_listings.slice(0);
}, setListings:function (ls) {
this.current_listings = ls.slice(0);
}, getRows:function () {
function cmp(a, b) {
return a.localeCompare(b);
}
var ls = _.filter(this.getListings(), function (l) {
return l.mk != undefined;
}), key_buckets_map = {}, section_row_buckets = [];
_.map(ls, function (l) {
var k = l.mk;
key_buckets_map[k] = key_buckets_map[k] || [];
key_buckets_map[k].push(l.bucket);
});
for (k in key_buckets_map) {
section_row_buckets.push([k, Math.min.apply(Math, key_buckets_map[k])]);
}
return section_row_buckets;
}, getSections:function () {
function cmp(a, b) {
return a.localeCompare(b);
}
var ls = _.filter(this.getListings(), function (l) {
return l.mk != undefined;
}), key_buckets_map = {}, section_buckets = [];
_.map(ls, function (l) {
var sr = helpers.parseMapKey(l.mk);
key_buckets_map[sr.s] = key_buckets_map[sr.s] || [];
key_buckets_map[sr.s].push(l.bucket);
});
for (s in key_buckets_map) {
section_buckets.push([s, Math.min.apply(Math, key_buckets_map[s])]);
}
return section_buckets;
}, getListingsForRow:function (s, r) {
var key = "s:" + s + " r:" + r;
return _.filter(this.getListings(), function (l) {
return l.mk === key;
});
}, getListingsForSection:function (s) {
return _.filter(this.getListings(), function (l) {
if (l.mk) {
var k = helpers.parseMapKey(l.mk);
return k && k.s === s;
} else {
return false;
}
});
}});
(function (R) {
R.scalePath = function (scale, pathArray) {
var ret = [];
R.is(pathArray, "string") && (pathArray = R.parsePathString(pathArray));
for (var i = 0, ilen = pathArray.length; i < ilen; ++i) {
ret[i] = pathArray[i].slice(0);
for (var j = 1, jlen = pathArray[i].length; j < jlen; ++j) {
ret[i][j] = scale * pathArray[i][j];
}
}
return ret;
};
})(Raphael);
var SG = SG || {};
SG.map = SG.map || {};
(function (M) {
var paper = null, map_data = null, listings_ready = false, path_style = {stroke:"#3e75b5", "stroke-width":3.5, "opacity":0.8, "fill":"#3e75b5", "fill-opacity":0.31}, options = {auto_zoom:false, auto_close_sidebar:false, is_ga:false, map_base_url:null, static_map_url:"/images/map/new/pending.png", rows_at_all_zooms:false, view_from_seat_manifest:null, hide_unmappable:false}, NO_MAP;
M.debug = false;
M.log = function () {
if (!M.debug)return;
try {
console.log.apply(console, arguments);
}
catch (e) {
}
};
M.track = function (action, label, value) {
try {
M.log([action, label, value]);
_gaq.push(['_trackEvent', 'maps', action, label, value]);
}
catch (e) {
}
};
M.fire = function (e, data) {
M.log(e, data);
jQuery(document).trigger(e, data);
};
M.observe = function (e, cb) {
jQuery(document).bind(e, cb);
};
M.isInteractive = function () {
return!NO_MAP;
};
M.layers = {};
M.init = function (opts) {
options = jQuery.extend(options, opts);
NO_MAP = options.map_base_url === null;
if (NO_MAP) {
M.log("map not available");
jQuery("body").addClass("no-map no-deal-quality");
} else {
SG.map.retrieveMapData();
}
if (options.is_ga) {
M.log("venue is ga");
jQuery("body").addClass("is-ga");
} else if (options.static_map_url && options.static_map_url != "/images/pending.png") {
M.log("map is static");
jQuery("body").addClass("static-map");
}
sometimeWhen(function () {
return listings_ready && (map_data !== null || NO_MAP);
}, function () {
M.fire("sg:map-ready");
});
window.paper = paper = Raphael("canvas-spot", 100, 100);
M.layers.window = jQuery("#window")[0];
M.layers.drag_container = jQuery("#drag-container")[0];
M.layers.holder = jQuery("#holder")[0];
M.layers.map_tiles = jQuery("#map-tiles")[0];
M.layers.canvas_spot = jQuery("#canvas-spot")[0];
M.layers.marker_holder = jQuery("#marker-holder")[0];
M.layers.over_map = jQuery("#window .over-map")[0];
M.views = [new M.View({scale:0.7, detail:options.rows_at_all_zooms ? "rows" : "sections"}), new M.View({scale:1.4, detail:"rows"}), new M.View({scale:2.8, detail:"rows"}), new M.View({scale:5.6, detail:"rows"})];
M.view_from_seat_manifest = !window.DISABLE_VIEW_FROM_SEAT ? options.view_from_seat_manifest : null;
M.fire("sg:map-init");
};
M.retrieveMapData = function () {
jQuery.get(options.map_base_url.replace(/^http:\/\/cdn\.seatgeek\.com/, '') + 'map_data.json', function (json) {
map_data = json;
SG.map.fire("sg:map_data-ready");
}, "json");
};
M.getMapData = function (s, r) {
if (s === undefined)
return map_data;
if (r === undefined)
return map_data[s];
return map_data[s].rows[r];
};
var current_view = null, current_view_index = null;
M.View = function (opts) {
this.scale = opts.scale;
this.detail = opts.detail;
};
M.View.prototype.drawShape = function (path) {
var shape = paper.path(Raphael.scalePath(this.scale, path));
this.forceRender();
return shape;
};
M.View.prototype.drawCircle = function (x, y, r) {
var pt = this.scalePoint([x, y]), circle = paper.circle(pt[0], pt[1], r);
this.forceRender();
return circle;
};
M.View.prototype.scalePoint = function (pt) {
return[pt[0] * this.scale, pt[1] * this.scale];
};
M.View.prototype.forceRender = function () {
if (Browser.WebKit) {
var rect = paper.rect(-99, -99, this.scale * 1000 + 99, this.scale * 1000 + 99).attr({stroke:"none"});
window.setTimeout(function () {
if (rect && rect.parentNode)rect.remove();
});
}
};
M.views = [];
var cancel_render_func = null;
function renderListings(clear_first) {
var sections = map_data, view = current_view, clear_first = clear_first === undefined ? true : clear_first;
if (cancel_render_func) {
cancel_render_func();
cancel_render_func = null;
}
if (clear_first)M.clearMap();
function marker(detail, key, bucket, x, y) {
var bucket = Math.max(0, Math.min(6, bucket)), size = [23, 20, 18, 16, 14, 13, 11][bucket], offset = Math.ceil(size / 2), x = Math.round(x) - offset, y = Math.round(y) - offset;
return SG.fn.fastHtmlToDom(['<div class="marker marker' + bucket + '" detail="' + detail + '" key="' + key + '" ', 'style="position:absolute; top:' + y + 'px; left:' + x + 'px; width:' + size + 'px; height:' + size + 'px;">', '</div>'].join("\n"));
}
if (view.detail == "sections") {
cancel_render_func = yieldingMap(function (sb) {
var s = sb[0], b = sb[1], k = "s:" + s, section = sections[s], c = section.center;
M.layers.marker_holder.appendChild(marker("section", k, b, c[0] * view.scale, c[1] * view.scale));
}, app.listings.getSections(), function () {
cancel_render_func = null;
});
} else {
cancel_render_func = yieldingMap(function (srb) {
var k = srb[0], b = srb[1], sr = helpers.parseMapKey(k), row = sections[sr.s].rows[sr.r], c = row ? row.center : sections[sr.s].center;
M.layers.marker_holder.appendChild(marker("row", k, b, c[0] * view.scale, c[1] * view.scale));
}, app.listings.getRows(), function () {
cancel_render_func = null;
});
}
}
M.render = function (clear_first) {
renderListings(clear_first);
};
jQuery(function () {
var marker_holder = jQuery("#marker-holder");
function markerObserve(browserevt, sgevt) {
marker_holder.bind(browserevt, function (e) {
var el = jQuery(e.target);
if (!el.hasClass("marker"))return true;
M.fire("sg:" + el.attr("detail") + "-" + sgevt, {key:el.attr("key"), el:el});
return false;
});
}
markerObserve("click", "click");
markerObserve("mouseover", "over");
markerObserve("mouseout", "out");
});
var highlighted_section_or_row = null;
M.highlightSectionOrRow = function (key) {
if (!key)return;
var detail = current_view.detail;
M.clearHighlightedSectionOrRow();
M.fire(detail == "sections" ? "sg:section-over" : "sg:row-over", {key:key});
highlighted_section_or_row = key;
};
M.clearHighlightedSectionOrRow = function () {
var detail = current_view.detail;
if (highlighted_section_or_row)
M.fire(detail == "sections" ? "sg:section-out" : "sg:row-out", {key:highlighted_section_or_row});
highlighted_section_or_row = null;
};
var highlighted_shape = null;
function clearHighlightedShape() {
if (highlighted_shape) {
try {
highlighted_shape.remove();
} catch (e) {
}
highlighted_shape = null;
}
}
M.observe("sg:section-over", function (e, data) {
clearHighlightedShape();
try {
var k = helpers.parseMapKey(data.key), section = M.getMapData(k.s), shape = highlighted_shape = current_view.drawShape(section.path), ls = app.listings.getListingsForSection(k.s);
shape.attr(path_style);
M.showTooltip(templates.section_tooltip(ls), shape.getBBox());
} catch (e) {
}
});
M.observe("sg:section-out", function (e) {
clearTimeout(jQuery(tooltip).data("hiding"));
jQuery(tooltip).data("hiding", setTimeout(function () {
clearHighlightedShape();
M.hideTooltip();
}, 150));
});
M.observe("sg:row-over", function (e, data) {
clearHighlightedShape();
try {
var k = helpers.parseMapKey(data.key), row_or_section = M.getMapData(k.s, k.r), shape = highlighted_shape = current_view.drawShape(row_or_section.path), ls = (k.r) ? app.listings.getListingsForRow(k.s, k.r) : app.listings.getListingsForSection(k.s);
shape.attr(path_style);
jQuery(data.el).css({zIndex:13});
M.showTooltip(templates[(k.r ? "row" : "section") + "_tooltip"](ls), shape.getBBox());
} catch (e) {
}
});
M.observe("sg:row-out", function (e, data) {
jQuery(data.el).css({zIndex:""});
clearTimeout(jQuery(tooltip).data("hiding"));
jQuery(tooltip).data("hiding", setTimeout(function () {
clearHighlightedShape();
M.hideTooltip();
}, 50));
});
function popupTargetForPoint(pt) {
var pt = current_view.scalePoint(pt), pos = jQuery("#holder").position();
return{x:Math.round(pt[0] + pos.left), y:Math.round(pt[1] + pos.top)};
}
M.observe("sg:section-click sg:row-click", function (e, data) {
var k = helpers.parseMapKey(data.key), section_or_row = M.getMapData(k.s, k.r), pos = popupTargetForPoint(section_or_row.center), ls = k.r ? app.listings.getListingsForRow(k.s, k.r) : app.listings.getListingsForSection(k.s);
SG.map.showPopup(templates.section_row_popup(ls[0].sf, k.r ? ls[0].r : null, ls), pos.x, pos.y);
M.showViewFromSeat(k.ss);
});
M.showViewFromSeat = function (s) {
var img_html = templates.view_from_seat(s, 350);
if (img_html != '') {
jQuery(".view-from-seat-large").html(['<a href="#" class="close" onclick="SG.map.hideViewFromSeat(); return false;"> </a>', '<div class="description">View from section ' + s + '</div>', img_html].join("\n")).show();
}
};
M.hideViewFromSeat = function () {
jQuery(".view-from-seat-large").html("").hide();
};
M.showListingDetails = function (jQel) {
var el = jQel.closest('.ticket-container'), isPopup = !el.hasClass('scroll'), moveUp = isPopup ? -(el.height() - (jQel.position().top + jQel.outerHeight())) : -(jQuery(window).height() - (jQel.offset().top + jQel.outerHeight()));
if (moveUp > (jQel.parent().position().top - 10)) {
moveUp = jQel.parent().position().top - 10;
}
moveUp = (isPopup) ? moveUp + 10 : moveUp;
if (moveUp > 0) {
el.animate({scrollTop:'+=' + (moveUp) + 'px'}, 'slow');
}
};
M.getPosition = function () {
var pos = jQuery(M.layers.holder).position();
return{x:pos.left, y:pos.top};
};
M.setPosition = function (x, y) {
jQuery(M.layers.holder).css({top:y + "px", left:x + "px"});
};
M.getView = function () {
return current_view;
};
M.setView = function (index) {
var old_view = current_view;
current_view_index = Math.max(Math.min(index, M.views.length - 1), 0);
current_view = M.views[current_view_index];
if (old_view === current_view)return;
M.clearMap();
M.fire("sg:map-view-change", {view:current_view, old_view:old_view, index:index});
};
M.zoomIn = function () {
var z = Math.min(3, current_view_index + 1);
M.setView(z);
};
M.zoomOut = function () {
var z = Math.max(0, current_view_index - 1);
M.setView(z);
};
M.zoomToPoint = function (x, y, zoom_level) {
var zoom_level = zoom_level !== undefined ? zoom_level : 2;
M.centerMap([x, y]);
M.setView(zoom_level);
};
M.zoomToSection = function (s, zoom_level) {
var pt = map_data[s].center, scale = current_view.scale;
M.zoomToPoint(pt[0] * scale, pt[1] * scale, zoom_level);
};
var image_loader = null, loaded_images = {};
M.clearMap = function () {
var tiledim = 350, scale = current_view.scale, height = Math.round(1000 * scale), width = Math.round(1000 * scale), tileholder = jQuery(M.layers.map_tiles), tilecount = (height * width) / Math.pow(tiledim, 2), i = 0, tiles = [];
M.hideTooltip();
M.hidePopup();
paper.clear();
jQuery(M.layers.marker_holder).html("");
paper.setSize(width, height);
tileholder.css({height:height + "px", width:width + "px", position:"relative"});
jQuery(M.layers.holder).css({height:height + "px", width:width + "px"});
if (NO_MAP) {
tileholder.html(['<img src="' + options.static_map_url + '" />'].join("\n"));
return;
}
for (i = 0; i < tilecount; ++i) {
tiles.push(i);
}
tileholder.html(_.map(tiles,
function (tile) {
var src = [options.map_base_url, scale + "", "x/", "tile_", tile, ".png"].join("");
return'<img ' + (loaded_images[src] ? 'src' : 'deferredsrc') + '="' + src + '" style="width:' + tiledim + 'px; height:' + tiledim + 'px" />';
}).join("\n"));
clearTimeout(image_loader);
function load_visible_images() {
var imgs = _.filter(tileholder.find("img").get(), function (img) {
return img.src == "";
}), mp = M.getPosition(), ww = jQuery(M.layers.window).width(), wh = jQuery(M.layers.window).height();
if (imgs.length <= 0)return;
_.map(imgs, function (img) {
var img = jQuery(img), ipos = img.position(), x = mp.x + ipos.left, y = mp.y + ipos.top, src = img.attr("deferredsrc");
if ((x + tiledim) < 0 || (x > ww) || (y + tiledim) < 0 || (y > wh))
return;
img.attr("src", src);
loaded_images[src] = true;
});
image_loader = setTimeout(load_visible_images, 350);
}
load_visible_images();
M.log("map cleared");
};
M.centerMap = function (pt) {
var wdw = jQuery(M.layers.window).width(), wdh = jQuery(M.layers.window).height(), wc = [wdw / 2, wdh / 2], mdw = jQuery(M.layers.holder).width(), mdh = jQuery(M.layers.holder).height(), pt = pt || [mdw / 2, mdh / 2], mp = M.getPosition(), mc = [mp.x + pt[0], mp.y + pt[1]], dx = wc[0] - mc[0], dy = wc[1] - mc[1], moveto = [Math.round(mp.x + dx), Math.round(mp.y + dy)];
M.log("moveto", moveto);
M.setPosition.apply(M, moveto);
};
M.isGa = function () {
return options.is_ga;
};
M.hideUnmappable = function () {
return options.hide_unmappable;
};
var popup = null;
M.repositionToRevealPopup = function () {
if (!popup)return;
var jpop = jQuery(popup), po = jpop.position(), popw = jpop.width(), poph = jpop.height(), win = jQuery(M.layers.window), wdw = win.width(), wdh = win.height(), mappos = M.getPosition(), x = po.left, y = po.top, dx = 0, dy = 0;
if (y + poph > wdh)dy = wdh - (y + poph);
if (x + popw > wdw)dx = wdw - (x + popw);
if ((y + dy) < 0)dy = 0 - y;
if ((x + dx) < 0)dx = 0 - x;
jpop.css({left:x + dx});
jpop.animate({top:y + dy}, {queue:false, duration:500, step:function (p, details) {
if (details.prop == "top")M.setPosition(mappos.x + dx, mappos.y + (p - y));
}});
};
M.showPopup = function (html, targetx, targety, width) {
var div, popdim = null, dx = 0, dy = 0, mappos = M.getPosition(), offsetx = 16, offsety = -75, wdw = jQuery(M.layers.window).width(), targetx = targetx || 0, targety = targety || 0, width = width || 354, flip_arrow = (wdw - targetx) < (width + offsetx), y = targety + offsety;
x = flip_arrow ? targetx - (width + offsetx) : targetx + offsetx;
M.hideTooltip();
M.hidePopup();
div = popup = SG.fn.fastHtmlToDom(['<div class="popup" style="position:absolute; width:' + width + 'px; z-index:3; top:' + y + 'px; left:' + x + 'px">', '<div class="inner' + (flip_arrow ? ' flip' : '') + '">', '<div class="arrow"></div>', '<div class="body">', html, '</div>', '<div class="bottom"></div>', '</div>', '</div>'].join("\n"));
M.layers.over_map.appendChild(div);
new SG.draggable(div, M.layers.drag_container);
async(function () {
M.repositionToRevealPopup();
});
};
M.hidePopup = function () {
if (popup) {
remove_node(popup);
popup = null;
}
M.hideViewFromSeat();
};
var tooltip = null;
M.showTooltip = function (html, bb) {
var div, tooltipTemplate = '<div class="tooltip"></div>', mappos = M.getPosition(), dragw = jQuery(M.layers.window).width(), dragh = jQuery(M.layers.window).height(), divw, divh, x = bb.x + Math.max(bb.width, 12), y = bb.y;
clearTimeout(jQuery(tooltip).data("hiding"));
M.hideTooltip();
if (html.search('view-from-seat') != -1) {
tooltipTemplate = '<div class="tooltip seatview"></div>';
}
div = jQuery(tooltipTemplate).mouseenter(
function () {
clearTimeout(jQuery(this).data("hiding"));
}).mouseleave(function () {
jQuery(this).data("hiding", setTimeout(function () {
clearHighlightedShape();
M.hideTooltip();
}, 50));
});
tooltip = div[0];
div.css({position:"absolute", zIndex:14});
div.html(['<div class="inner">', html, '</div>'].join("\n"));
if (html.search('view-from-seat') != -1) {
div.html('<div class="inner-left"> </div>' + div.html() + '<div class="inner-right"> </div>');
}
jQuery(M.layers.over_map).append(div);
divw = div.width() + 2;
divh = div.height();
if ((x + mappos.x) + divw >= dragw)
x = bb.x - divw - 10;
if ((y + mappos.y) <= 0)
y = bb.y + bb.height - 5;
if ((y + mappos.y + divh) >= dragh) {
y = y - divh;
if (y + mappos.y + divh + bb.height < dragh)
y = y + bb.height;
}
div.css({top:(y + mappos.y) + "px", left:(x + mappos.x) + "px", width:divw + "px"});
};
M.hideTooltip = function () {
if (tooltip) {
remove_node(tooltip);
tooltip = null;
}
};
M.toggleSidebar = function () {
var sidebar = jQuery(".sidebar").eq(0), win = jQuery(M.layers.window), left = parseInt(win.css("left"), 10), to = 0, direction = true, duration = 250, mappos = M.getPosition();
M.hideTooltip();
M.hidePopup();
if (left < 1) {
to = 324;
direction = false;
duration = 300;
}
sidebar.animate({left:to - 324}, {queue:false, duration:duration});
win.animate({left:to}, {queue:false, duration:duration, step:function (p, details) {
if (details.prop == "left") {
p = Math.round(p);
M.setPosition(mappos.x + (direction ? (324 - p) : (p * -1)), mappos.y);
}
}, complete:function () {
var tab = jQuery(".toggle-sidebar");
tab.toggleClass("toggle-sidebar-flipped");
M.centerMap();
}});
M.track("sidebar-" + (direction ? "close" : "open"));
};
M.observe("sg:map-init", function () {
var width = options.auto_close_sidebar ? jQuery(document).width() : jQuery(M.layers.window).width();
if (M.isInteractive() && options.auto_zoom && 1400 < width) {
M.setView(1);
} else {
M.setView(0);
}
M.centerMap();
sometimeWhen(function () {
return jQuery(M.layers.window).height() > 0;
}, function () {
M.centerMap();
});
new SG.draggable(M.layers.holder, M.layers.drag_container);
});
M.observe("sg:listings-ready", function () {
listings_ready = true;
});
M.observe("sg:listings-ready", function () {
jQuery('#ticket_list_loading').hide();
});
M.observe("sg:map-ready", function () {
app.filters.filterListings();
});
M.observe("sg:map-view-change", function (e, data) {
if (!data.old_view)return;
var view = data.view, old_view = data.old_view, scale = view.scale / old_view.scale, new_pos = null, tempcw = jQuery(M.layers.window).width(), tempch = jQuery(M.layers.window).height(), C = [tempcw / 2, tempch / 2], tempo = M.getPosition(), O = [tempo.x, tempo.y];
new_pos = {x:C[0] - scale * (C[0] - O[0]), y:C[1] - scale * (C[1] - O[1])};
M.log("C", C);
M.log("O", O);
M.log("new_pos", new_pos);
M.setPosition(new_pos.x, new_pos.y);
});
M.observe("sg:map-view-change", function () {
M.render(false);
});
M.observe("sg:map-view-change", function () {
var zoom = jQuery(".map-content .zoom");
zoom.removeClass("level0 level1 level2 level3");
zoom.addClass("level" + current_view_index);
});
M.observe("sg:map-view-change", function () {
M.hideTooltip();
M.hidePopup();
});
M.observe("sg:map-init", function () {
if (!M.isInteractive())return;
jQuery("#drag-container").dblclick(function (e) {
if (NO_MAP)return;
var wo = jQuery("#holder").offset();
M.zoomToPoint(e.clientX - wo.left, e.clientY - wo.top, current_view_index + 1);
SG.map.track("zoom", "dblclick");
});
function getWheel(event) {
var delta = 0;
if (!event)event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta / 120;
if (window.opera)delta = -delta;
} else if (event.detail) {
delta = -event.detail;
}
return Math.round(delta);
}
var disable_wheel = false;
function handleScroll(e) {
if (disable_wheel)return;
disable_wheel = true;
setTimeout(function () {
disable_wheel = false;
}, 200);
getWheel(e) > 0 ? M.zoomIn() : M.zoomOut();
M.track("zoom", "scroll");
}
jQuery("#drag-container").bind("mousewheel", handleScroll).bind("DOMMouseScroll", handleScroll);
});
M.observe("sg:map-init", function () {
if (jQuery.browser.msie)
jQuery("#map-tiles")[0].ondragstart = function () {
return false;
};
});
SG.map.observe("sg:listings-ready", function () {
if (options.auto_close_sidebar) {
setTimeout(function () {
SG.map.toggleSidebar();
}, 500);
}
});
})(SG.map);
var mouseover = false, mousedown = false, quantityInitial = false, quantityTimeout = null, preloadImages = new Array(), obj = null, mode = 1;
jQuery(function () {
jQuery(".secondbar .label, .account-dropdown .label").mousedown(function (e) {
e.preventDefault();
showDropdown("." + jQuery(this).attr('id'));
mousedown = true;
jQuery(window).trigger("resize");
});
jQuery('.menu a').mouseup(function (event) {
obj = jQuery(this);
if (mousedown) {
if (obj.attr("href") != "#" && obj.attr("id") != "logout-link") {
window.location = obj.attr("href");
}
obj.click();
}
});
jQuery('body').mouseup(function () {
mousedown = false;
jQuery('.menu a').removeClass('hover-state');
});
jQuery('#drag-container').mousedown(function () {
jQuery('#search-bar-input').blur();
});
jQuery('.search h1.label').click(function () {
jQuery('.search h1.label').addClass('hastext');
jQuery('.search input').show();
});
jQuery(".menu a").hover(function () {
if (mousedown) {
jQuery(this).addClass('hover-state');
}
}, function () {
if (mousedown) {
jQuery(this).removeClass('hover-state');
}
});
jQuery('.dd, #quantity option').hover(function () {
mouseover = true;
}, function () {
mouseover = false;
});
jQuery("body").mouseup(function () {
if (!mouseover) {
quantityTimeout = window.setTimeout("resetDropdowns()", 1);
}
});
jQuery('.menu a').click(function () {
obj.addClass("active-state");
var multiplesOf = 90;
setTimeout("obj.addClass('blink');", 50);
setTimeout("obj.removeClass('blink');", multiplesOf * 2);
setTimeout("obj.removeClass('active-state'); resetDropdowns('fade');", multiplesOf * 3);
});
jQuery('.filters .price input').click(function () {
this.select();
});
jQuery('#quantity-initial').change(function () {
quantityInitial = true;
jQuery('#quantity').val(this.value).trigger("change");
jQuery('.quantity-filter').html("Thanks. You can update this in the 'Filter' dropdown.");
jQuery('.quantity-filter').delay(2500).animate({top:"-6px", opacity:0}, 500, function () {
jQuery('.quantity-filter').hide();
});
jQuery('.scroll-wrapper').delay(2500).animate({top:"36px"}, 500);
});
jQuery('#quantity').change(function () {
window.clearTimeout(quantityTimeout);
if (!quantityInitial && jQuery('.quantity-filter').is(':visible')) {
jQuery('.quantity-filter').animate({top:"-6px", opacity:0}, 500, function () {
jQuery('.quantity-filter').hide();
});
jQuery('.scroll-wrapper').animate({top:"36px"}, 500);
}
});
jQuery('#search-bar-input').focus(function () {
jQuery('.search-container').addClass("search-focus");
});
jQuery('#search-bar-input').blur(function () {
jQuery('.search-container').removeClass("search-focus");
});
jQuery('.search-structure').click(function () {
jQuery('#search-bar-input').focus();
});
jQuery('#sglightbox_modal').live('openModal', function () {
});
jQuery('#sglightbox_modal').live('closeModal', function () {
});
jQuery("a").each(function () {
jQuery(this).attr("hideFocus", "true").css("outline", "none");
});
jQuery('#search-bar-input').autoGrowInput();
jQuery('#search-bar-input').keydown(function () {
jQuery('.search h1 span').text(jQuery(this).val());
});
jQuery(window).resize(function () {
jQuery('#search-bar-input').trigger("window-resize");
adjustWindowSize();
});
jQuery(window).trigger("resize");
jQuery('.zoom a').mousedown(function () {
jQuery(this).addClass('active');
});
jQuery('.zoom a').mouseup(function () {
jQuery(this).removeClass('active');
});
jQuery('.zoom a').mouseout(function () {
if (jQuery(this).hasClass('active')) {
jQuery(this).trigger('mouseup');
}
});
jQuery('.ds .tabset a').click(function () {
resetDealScore();
jQuery(this).addClass('selected');
jQuery('.ds-' + jQuery(this).attr("rel")).show();
return false;
});
jQuery('#sponsorship_link').click(function () {
if (jQuery.browser.msie) {
window.location = this.href;
}
});
jQuery('.deal-quality-data.clickable, .sort-help-button').live("click", function () {
sglightbox.open(jQuery('#deal-score-explanation-popup')[0]);
return false;
});
});
function resetDealScore() {
jQuery('.ds .tabset a').removeClass('selected');
jQuery('.ds .tab').hide();
return true;
}
function adjustWindowSize() {
if (jQuery(window).width() < 1066) {
if (mode == 1) {
jQuery(".nav-links-full").hide();
jQuery(".nav-links-condensed").show();
jQuery(".first2").trigger("ninja-select");
jQuery(".over-map .key").addClass("fit");
mode = 0;
}
}
else {
if (mode == 0) {
jQuery(".nav-links-full").show();
jQuery(".nav-links-condensed").hide();
jQuery(".first").trigger("ninja-select");
jQuery(".over-map .key").removeClass("fit");
mode = 1;
}
}
}
function setTooltips() {
jQuery('.deal-quality-data').hoverIntent(function () {
jQuery(this).children('.help-button').show();
}, function () {
jQuery(this).children('.help-button').hide();
});
}
function preload() {
var path = preload.arguments[0];
for (i = 1; i < preload.arguments.length; i++) {
preloadImages[i] = new Image()
preloadImages[i].src = path + preload.arguments[i]
}
}
function runPreloadImages() {
preload("/images/map/new/", "dealscores.png", "tickets.png", "sprite.png", "modal-header.png", "nav-dropdown-end.png", "nav-dropdown-middle.png", "details-body.png", "details-ends.png", "dealscores_sample.png", "slider-handle.png");
preload("/images/", "map/ticket-group-popup-bg-top.png", "map/ticket-group-popup-bg-arrow.png", "map/ticket-group-popup-bg-bottom.png");
}
function showDropdown(object) {
if (jQuery(object + ' .label').hasClass('selected')) {
resetDropdowns();
return false;
}
resetDropdowns();
jQuery(object + ' .label').addClass('selected');
jQuery(object + ' .dropdown').show();
return false;
}
function resetDropdowns(fade) {
var time = 0;
if (fade == "fade") {
time = 100;
}
jQuery('.dd .dropdown').fadeOut(time, function () {
jQuery('.dd .label').removeClass('selected');
});
}
var recursions = 0;
function adjustTitleWidth() {
if (jQuery(".event-info h1 span").size() <= 0)return;
var m = jQuery(".event-info h1 span"), width = m.width() + parseInt(m.closest(".event-info").css("padding-left"), 10), maxwidth = jQuery("#listing_sidebar").position().left, h1;
if (width > maxwidth && recursions <= 13) {
h1 = m.closest("h1");
h1.css({fontSize:(parseInt(h1.css("fontSize"), 10) - 1) + "px"});
recursions += 1;
adjustTitleWidth();
} else {
recursions = 0;
}
}
(function (jQuery) {
jQuery.fn.autoGrowInput = function (o) {
o = jQuery.extend({minWidth:0, comfortZone:20}, o);
this.filter('input:text').each(function () {
var minWidth = o.minWidth || jQuery(this).width(), val = '', input = jQuery(this), testSubject = jQuery('<tester/>').css({position:'absolute', top:-9999, left:-9999, width:'auto', fontSize:input.css('fontSize'), fontFamily:input.css('fontFamily'), fontWeight:input.css('fontWeight'), letterSpacing:input.css('letterSpacing'), whiteSpace:'nowrap'}), check = function () {
var maxWidth = jQuery(window).width() - 425;
val = input.val();
testSubject.text(val);
var testerWidth = testSubject.width(), newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth, currentWidth = input.width(), isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth) || (newWidth > minWidth && newWidth < maxWidth);
var isMax = false;
if (newWidth > maxWidth) {
newWidth = maxWidth;
isMax = true;
isValidWidthChange = true;
}
if (isValidWidthChange) {
input.width(newWidth);
jQuery('.search h1').width(newWidth);
jQuery(".search").width(newWidth + 10);
if (newWidth < 500) {
jQuery('.event-meta').css('maxWidth', newWidth - 10);
}
}
if (isMax) {
var h1 = jQuery(".search h1"), span = jQuery(".search h1 span"), small = false, size;
h1.css("width", "auto");
while (h1.width() > maxWidth && parseInt(span.css("fontSize"), 10) > 11) {
small = true;
size = (parseInt(span.css("fontSize"), 10) - 1) + "px";
span.css({fontSize:size});
input.css({fontSize:size});
}
if (!small) {
while (h1.width() < maxWidth && parseInt(span.css("fontSize"), 10) < 19) {
size = (parseInt(span.css("fontSize"), 10) + 1) + "px";
span.css({fontSize:size});
input.css({fontSize:size});
}
}
}
};
testSubject.insertAfter(input);
jQuery(this).bind('keyup keydown blur update window-resize onload', check);
});
return this;
};
})(jQuery);
(function () {
SG.show_about = function (callback) {
var popup = jQuery("#about-event-popup");
sglightbox.open(popup[0]);
if (callback)callback();
};
jQuery('.more-info a').click(function (e) {
e.preventDefault();
SG.show_about();
});
})(jQuery);
var PagedList = function (ls, elem, opts) {
this.ls = ls;
this.elem = elem;
this.size = opts.size || 40;
this.render = opts.render || function (l) {
return l + "";
};
this.postRender = opts.postRender;
this.preamble = opts.preamble;
this.page = 0;
};
PagedList.prototype.drawPage = function (page, isNextPage) {
var page = page === undefined ? this.page : page, from = page * this.size, to = (page + 1) * this.size, listingsNodes = [], listings = this.ls.slice(from, to), that = this;
SG.map.log(page, from, to);
this.page = page;
if (listings.length) {
if (!isNextPage) {
this.elem.innerHTML = "";
jQuery('.scroll').scrollTop();
}
if (this.preamble && page == 0) {
this.elem.appendChild(SG.fn.fastHtmlToDom(this.preamble));
}
if (page > 0)this.elem.appendChild(SG.fn.fastHtmlToDom('<div class="pageHeaderLabel">Page ' + (page + 1) + ' of ' + this.pageCount() + '</div>'));
_.each(listings, function (l) {
var html = that.render(l), node = SG.fn.fastHtmlToDom(html);
that.elem.appendChild(node);
if (_.isFunction(that.postRender))
that.postRender(node);
});
this.elem.appendChild(SG.fn.fastHtmlToDom([page < this.pageCount() - 1 ? '<a href="#" onclick="app.sidebar.nextPage(); this.style.display=\'none\'; return false;" class="nextPage"><span>Load More Tickets</span></a>' : '<div class="pageSpacer"></div>'].join("\n")));
} else {
this.elem.innerHTML = app.listings.getAllListings().length ? "<div class='no-tickets-message text-shadow'><span class='header'>No matching tickets</span><span class='weSearched'>We're sorry, there are currently no tickets available that match your filter settings.</span></div>" : "<div class='no-tickets-message text-shadow'><span class='header'>No tickets available</span><span class='weSearched'>We searched all the web's ticket sites, but no one has any tickets available for this event.</span></div>";
}
setTooltips();
};
PagedList.prototype.pageCount = function () {
return Math.ceil(this.ls.length / this.size);
};
PagedList.prototype.constrainPage = function (page) {
return Math.min(Math.max(0, page), this.pageCount());
}
PagedList.prototype.nextPage = function () {
this.drawPage(this.constrainPage(this.page + 1), true);
};
PagedList.prototype.previousPage = function () {
this.drawPage(this.constrainPage(this.page - 1));
};
PagedList.prototype.setList = function (ls) {
this.ls = ls;
};
jQuery(function () {
SG.warn_ebay = function (ticket, options) {
options = jQuery.extend({callback:null}, options);
var confirm = jQuery("#pre-ebay-warning"), go_link = confirm.find(".go-link"), selected_quantity = jQuery("#quantity").val() || ticket.quantity;
confirm.find(".venue").html(app.venue.get("name"));
confirm.find(".location").html(app.venue.get("location"));
confirm.find(".datetime").html(jQuery(".event-details time").text());
confirm.find(".price").html(ticket.price);
confirm.find(".quantity").html(app.filters.getQuantity() || Math.max.apply(Math, ticket.splits));
confirm.find(".section").html(ticket.section);
confirm.find(".row-container").html(ticket.row ? 'Row: <strong><span class="row">' + ticket.row + '</span></strong>' : '');
confirm.find(".original").html(ticket.original);
confirm.find(".shipping").html(ticket.shipping);
confirm.find(".fees").html(ticket.fees);
confirm.find(".new-window").show();
go_link.removeClass("clicked").attr("href", ticket.url).unbind("click").click(function () {
setTimeout(function () {
confirm.find(".new-window").hide();
go_link.addClass("clicked").attr("href", "#").unbind("click").click(function (e) {
e.preventDefault();
sglightbox.close();
if (options.callback)options.callback.call();
})
}, 1000);
});
if (ticket.pickup_only == 1) {
confirm.find("#shipping_pickup").html('Pickup only');
} else {
confirm.find("#shipping_pickup").html('Delivery fee');
}
sglightbox.open(confirm[0]);
};
});
SidebarView = Backbone.View.extend({events:{"click #sort-bar a":"handleSortClick", "click .sponsored-result .toggle":"handleToggleSponsoredListings", "click .only-sponsored-listings .remove-filter":"handleToggleSponsoredListings", "click .sponsored-result .link-out":"handleSponsoredClickOut", "mouseenter .listing":"highlightListing", "mouseleave .listing":"clearListingHighlight"}, initialize:function () {
this.highlightedListing = null;
}, render:function () {
var preamble = "", filter_applied = !!app.filters.getMarket(), show_sponsorship = window.sponsorship_info;
app.has_ebay = app.has_ebay !== undefined ? app.has_ebay : _.any(app.listings.getAllListings(), function (l) {
return l.m == "ebay";
});
app.has_ticketsnow = app.has_ticketsnow !== undefined ? app.has_ticketsnow : _.any(app.listings.getAllListings(), function (l) {
return l.m == "ticketsnow";
});
app.has_primesport = app.has_primesport !== undefined ? app.has_primesport : _.any(app.listings.getAllListings(), function (l) {
return l.m == "primesport";
});
if (show_sponsorship) {
if (window.sponsorship_info.market_slug == 'ebay') {
show_sponsorship = app.has_ebay
} else if (window.sponsorship_info.market_slug == 'ticketsnow') {
show_sponsorship = app.has_ticketsnow
} else if (window.sponsorship_info.market_slug == 'primesport') {
show_sponsorship = app.has_primesport
}
}
if (show_sponsorship) {
preamble = templates.sponsored_result(window.sponsorship_info.market_full);
jQuery(".sidebar .listings")[filter_applied ? "addClass" : "removeClass"]("only-sponsored-listings");
jQuery(".hide-sponsored-listings .market-full").text(window.sponsorship_info.market_full);
if (!this.sponsorship_impression_tracked) {
_gaq.push(['_trackEvent', 'ads', 'impression', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
}
this.sponsorship_impression_tracked = true;
}
this.pager = new PagedList(app.listings.getListings(), jQuery(".sidebar .listings .inner")[0], {render:templates.listing, preamble:preamble});
this.pager.drawPage(0);
return this;
}, nextPage:function () {
this.pager.nextPage();
}, previousPage:function () {
this.pager.previousPage();
}, highlightListing:function (e, el) {
var el = e.currentTarget, k;
if (el == this.highlightedListing)return;
this.clearListingHighlight();
this.highlightedListing = el;
jQuery(el).addClass("hover");
SG.map.highlightSectionOrRow(jQuery(el).attr("mapkey"));
}, clearListingHighlight:function () {
if (this.highlightedListing) {
SG.map.clearHighlightedSectionOrRow();
jQuery(this.highlightedListing).removeClass("hover");
this.highlightedListing = null;
}
}, handleSortClick:function (e) {
var sorts = jQuery("#sort-bar a"), sort = jQuery(e.currentTarget), order = sort.hasClass("deal-quality") ? (sort.hasClass("desc") ? "asc" : "desc") : (sort.hasClass("asc") ? "desc" : "asc");
sorts.removeClass("asc desc");
sort.addClass(order);
app.filters.filterListings();
SG.map.track("sort", sort.attr("sortby"));
return false;
}, handleToggleSponsoredListings:function (e) {
var m = jQuery('#market');
if (m.val()) {
m.val("");
} else {
m.val(window.sponsorship_info.market_slug);
}
m.change();
_gaq.push(['_trackEvent', 'ads', 'interaction', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
return false;
}, handleSponsoredClickOut:function (e) {
_gaq.push(['_trackEvent', 'ads', 'click', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
return true;
}});
window.templates = {alternative:function (l, first) {
var first = first === true;
return['<div class="alt-listing' + (first ? ' first' : '') + '" ' + helpers.attrs_for_listing(l) + '>', (s_logo ? templates.market_logo(l.m) : templates.market_broker_logo(l.m, l.bi, l.bn)), '<div class="price amt">$' + l.pf + '</div>', '<a href="' + helpers.listing_url(l) + '" class="select" target="_blank" title="Buy"></a>', '</div>'].join("\n");
}, deal_quality:function (l) {
if (l.dq !== null) {
var text = "Best Great Great Good Good OK OK".split(" ")[l.bucket];
return['<div class="deal-quality deal-quality' + l.bucket + '">', '<div class="deal-quality-data clickable">', '<div class="number"><span class="value">' + Math.round(l.dq) + '</span></div>', '<div class="name">' + text + ' Deal</div>', '<a class="help-button" title="About Deal Score" href="#"></a>', '</div>', '</div>'].join("\n");
} else {
return['<div class="deal-quality deal-quality-unavailable">', '<div class="deal-quality-data">', '<div class="number">• • •</div>', '<div class="name">Unknown</div>', '</div>', '</div>'].join("\n");
}
}, market_logo:function (m) {
return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '.png" alt=""/></div></td></tr></table></div>';
}, market_broker_logo:function (m, bi, bn) {
if (bi != undefined) {
return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '_' + bi + '.png" alt=""/></div></td></tr></table></div>';
} else if (bn != undefined) {
var name = bn;
if (bn.length > 25)bn = "<span title='" + bn.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0') + "' class='substr'>" + bn.substr(0, 25) + "<span>…</span></span>";
return'<div class="market market-name-text market-' + m + '"><table><tr><td><div>' + bn + '</div></td></tr></table></div>';
} else {
return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '.png" alt=""/></div></td></tr></table></div>';
}
}, listing:function (l) {
var listing_class = 'listing';
if (l.sf.length > 8)listing_class += ' long_section';
if (l.et)listing_class += ' eticket';
return['<div class="listing-container">', '<div class="' + listing_class + '" ' + helpers.attrs_for_listing(l) + '>', '<div class="upper">', templates.deal_quality(l), '<div class="section">', '<div class="value' + (l.sf.length > 8 ? ' long-section-name' : '') + '">' + (l.sf == '' ? '--' : l.sf) + '</div>', '<div class="name">Section</div>', '</div>', '<div class="row">', '<div class="value">' + (l.rf == '' ? '--' : l.rf) + '</div>', '<div class="name">Row</div>', '</div>', (s_logo ? templates.market_logo(l.m) : templates.market_broker_logo(l.m, l.bi, l.bn)), '<div class="price amt' + (l.pf > 9999 ? ' long-price' : '') + '">$' + l.pf + '</div>', '<a href="' + helpers.listing_url(l) + '" class="select" target="_blank" title="Buy"></a>', '</div>', '<div class="lower">', '<div class="lower-details">', '<div class="show-details"><a href="#">show details</a></div>', '<div class="badge quantity">', '<strong>' + l.q + '</strong> ticket' + (l.q == 1 ? '' : 's'), '</div>', '<div class="badge eticketText eticketIcon">e-ticket</div>', '</div>', '</div>', '</div>', '<div class="details" style="display:none">', '<div class="details-top"><a class="details-close" title="Hide Details">Hide</a>More Details</div>', '<div class="details-middle">', '<div class="section-row">', 'Section <strong>' + l.sf.toUpperCase() + '</strong>', l.rf ? ' Row <strong>' + l.rf.toUpperCase() + '</strong>' : '', '</div>', '<div class="alternatives best-price">', ((l.alt.length == 0) ? '<div class="header">Only one listing available with these specs:</div>' : ''), templates.alternative(l, true), '</div>', '<div class="alternatives">', ((l.alt.length != 0) ? '<div class="header">' + l.alt.length + ' listing' + (l.alt.length > 1 ? 's' : '') + ' with the same specs but a worse price:</div>' : ''), _.map(l.alt, templates.alternative).join("\n"), '</div>', '<div class="fee-structure">', '<strong>$' + l.p + '</strong> base', ' + <strong>$' + (l.pf - l.p) + '</strong> fees & shipping', ' = <strong>$' + l.pf + '</strong> total', '</div>', l.fv ? '<span class="face-value">Face value: <strong>$' + Math.round(l.fv) + '</strong></span>' : '', l.d ? '<p class="notes"><b>Seller notes: </b>' + l.d + '</p>' : '', '<div class="more">', l.mk ? '<a href="#" class="zoom-here"><span class="pin-icon"></span> Show on the map</a>' : '', '</div>', '</div>', '<div class="details-bottom"></div>', '</div>', '</div>'].join("\n");
}, section_row_popup:function (sf, rf, ls) {
var listing_class = 'header', len = (sf ? sf.length : 0) + (rf ? rf.length : 0);
if (len > 12)listing_class += ' long-section-name';
return['<div class="header-wrap">', '<div class="' + listing_class + '">', '<a href="#" onclick="SG.map.hidePopup(); return false;" class="close"></a>', '<span class="title">', '<span class="section">Section ' + sf.toUpperCase() + '</span>' + (rf ? ', ' : ''), rf ? '<span class="row">Row ' + rf.toUpperCase() + '</span> ' : '', '</span>', '<span class="quantity">' + ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' available</span>', '</div>', '</div>', '<div class="listings ticket-container" style="max-height:400px; overflow:auto;">', _.map(ls, templates.listing).join("\n"), '</div>'].join("\n");
}, view_from_seat:function (s, width) {
var w = width || 250, h = Math.ceil(752 * (w / 1400)), src = "http://fanvenues4.appspot.com";
if (SG.map.view_from_seat_manifest && s in SG.map.view_from_seat_manifest) {
src += SG.map.view_from_seat_manifest[s];
src += "?size=" + w + "x" + h;
return['<div class="view-from-seat">', '<img src="' + src + '" width="' + w + 'px" height="' + h + 'px" alt="View from section ' + s + ' in ' + app.venue.get("name") + '" />', '</div>'].join("\n");
}
return'';
}, section_tooltip:function (ls) {
var lowest_price = Math.min.apply(Math, _.pluck(ls, "pf")), sf = ls[0].sf, s = ls[0].s;
return[this.view_from_seat(s), '<strong>Section ' + sf.toUpperCase() + '</strong>, ', '<span>', ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' from $' + lowest_price, '</span>'].join("\n");
}, row_tooltip:function (ls) {
var lowest_price = Math.min.apply(Math, _.pluck(ls, "pf")), sf = ls[0].sf, rf = ls[0].rf, s = ls[0].s, len = (sf ? sf.length : 0) + (rf ? rf.length : 0);
return[this.view_from_seat(s), '<strong>Section ' + sf.toUpperCase() + '</strong> ', '<strong>Row ' + rf.toUpperCase() + '</strong>, ', '<span>', ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' from $' + lowest_price, '</span>'].join("\n");
}, offer:function (o) {
var q = o.get("quantity");
return['<span class="zone">' + o.get("name") + '</span>', '<span class="quantity">' + q + ' tix' + '</span>', '<span class="discount">', Math.round(100 * o.getDiscount()) + "%", '<br />', '<span class="currentBest">off $' + o.get("best_price") + ' / ticket</span>', '</span>', '<span class="price">', '$' + o.get("price"), '<br />', '<a href="#" class="select"></a>', '</span>'].join("\n");
}, sponsored_result:function (market) {
var is_long_tagline = 45 < window.sponsorship_info.market_tagline.length + window.sponsorship_info.market_full.length, has_link = window.sponsorship_info.market_event_url !== undefined, has_tracking_image = window.sponsorship_info.market_tracker_image !== undefined;
return['<div class="listing-container">', '<div class="listing sponsored-result ' + window.sponsorship_info.market_slug + '-sponsored">', '<div class="upper">', '<div class="deal-quality deal-quality-sponsor">', '<div class="deal-quality-data">', '<div class="number">Sponsor</div>', '</div>', '</div>', '<div class="logo"></div>', '<a href="#" class="toggle"></a>', '</div>', '<div class="lower">', '<div class="lower-details">', '<div class="badge description">', is_long_tagline ? '' : window.sponsorship_info.market_tagline + ' – ', has_link ? '<a href="' + window.sponsorship_info.market_event_url + '" class="link-out" rel="nofollow" target="_blank">' : '', is_long_tagline ? window.sponsorship_info.market_tagline : 'Go to ' + window.sponsorship_info.market_full, has_link ? '</a>' : '', '</div>', '</div>', has_tracking_image ? '<img style="text-decoration:none;border:0;padding:0;margin:0;" src="' + window.sponsorship_info.market_tracker_image + '" />' : '', '</div>', '</div>', '</div>'].join("\n");
}, sponsored_link:function (sponsor) {
return['<div class="sponsored-link ' + sponsor.slug + '-link" style="' + sponsor.inline_style + '">', '<div class="link-message">', '<div class="message">' + sponsor.message + '</div>', '<div class="tagline">' + sponsor.tagline + '</div>', '</div>', '<a href="' + sponsor.url + '" class="link-image" target="_blank"></a>', '</div>'].join("\n");
}, no_fees:function () {
return['<div class="no-fees-message" style="display:none;">', '<a href="#" class="close"></a>', '</div>'].join("\n");
}};