forked from lgrammel/breeze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreeze-ui.min.js
1 lines (1 loc) · 13.2 KB
/
breeze-ui.min.js
1
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=function(a,b){return function(){return a.apply(b,arguments)}},y={}.hasOwnProperty,z=function(a,b){function d(){this.constructor=a}for(var c in b){if(y.call(b,c))a[c]=b[c]}d.prototype=b.prototype;a.prototype=new d;a.__super__=b.prototype;return a};w=function(a,b,c){if(c==null){c=null}mixpanel.track(a,b);if(c){return c()}};o=function(a,b,c){n(b,c.source,c.url);return w(b,c,function(){return window.open(a.href,"_blank")})};window.recordOutboundLink=o;n=function(a,b,c){return _gat._getTrackerByName()._trackEvent(a,b,c)};window.recordEvent=n;q=function(a,b,c){return _gaq.push(["_setCustomVar",a,b,c,2])};window.setVariable=q;if(Modernizr.svg&&Modernizr.inlinesvg){if($(window).height()<500||$(window).width()<500){$(".desktop").hide()}if(Modernizr.touch){$(".github").hide()}$(".header").show();i=function(a){if($("#standard-options").is(":visible")){$("#standard-options").hide("slow");$(a).button("option","icons",{primary:"ui-icon-triangle-1-s"});return w("hid options")}else{$("#standard-options").show("slow");$(a).button("option","icons",{primary:"ui-icon-triangle-1-n"});return w("show options")}};$(".header-expand").button({icons:{primary:"ui-icon ui-icon-triangle-1-n"},text:false}).click(function(){return i(this)});v=function(){if($("#additional-notices").is(":visible")){$("#additional-notices").hide("slow");$("a#additional-expand").text("additional notices");return w("hid notices")}else{$("#additional-notices").show("slow");$("a#additional-expand").text("less notices");return w("show notices")}};$("a#additional-expand").click(function(){return v()});m=org.polymaps;l=m.map().container(d3.select("#map").append("svg:svg").attr("width","100%").attr("height","100%").node()).zoom(13).center({lat:48.455164,lon:-123.351059}).add(m.drag()).add(m.wheel().smooth(false)).add(m.dblclick()).add(m.arrow()).add(m.touch());l.add(m.image().url(m.url("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png")));d=function(){function a(a){var b=this;this.map=a;this.transform=x(this.transform,this);this.selector=d3.select("#map svg").insert("svg:g");this.map.on("move",function(){return b.update()});this.map.on("resize",function(){return b.update()})}a.name="Layer";a.prototype.zoomLevel=function(){return this.map.zoom()};a.prevZoom=13;a.distance=0;a.prototype.pixelDistance=function(){var a,b;a=this.map.pointLocation({x:0,y:0});b=this.map.pointLocation({x:1,y:1});this.distance={lat:Math.abs(a.lat-b.lat),lon:Math.abs(a.lon-b.lon)};return this.distance};a.prototype.transform=function(a){var b;b=this.map.locationPoint(a);return"translate("+b.x+","+b.y+")"};a.prototype.cluster=function(a,b){var c,d,e,f,g,h,i,j,k;f=a.slice(0);j=this.pixelDistance();g=b*j.lat;h=b*j.lon;e=[];while(f.length>0){k=f.shift();d=[];d.push(k);i=0;while(i<f.length){if(Math.abs(f[i].lat-k.lat)<g&&Math.abs(f[i].lon-k.lon)<h){c=f.splice(i,1);d.push(c[0]);i--}i++}e.push(d)}return e};a.prototype.filter=function(a,b){var c,d,e,f;f=this.map.pointLocation({x:0-b,y:0-b});c=this.map.pointLocation({x:$(window).width()+b,y:$(window).height()+b});e=function(){var b,e,g;g=[];for(b=0,e=a.length;b<e;b++){d=a[b];if(c.lat<=d[0].lat&&d[0].lat<=f.lat&&f.lon<=d[0].lon&&d[0].lon<=c.lon){g.push(d)}}return g}();return e};return a}();c=function(a){function f(){return f.__super__.constructor.apply(this,arguments)}var b,c,d,e;z(f,a);f.name="DistanceLayer";e=[];b=[];d=[];f.prototype.update=function(){var a,b=this;if(this.zoomLevel()!==this.prevZoom||this.stops&&this.prevNumStops!==this.stops.length){this.prevNumStops=this.stops.length;this.prevZoom=this.zoomLevel();this.clusters=this.cluster(this.stops,10)}this.localClusters=this.filter(this.clusters,this.distanceInPixels());if(!this.prevLocalClusters||this.prevLocalClusters!==this.localClusters){this.prevLocalClusters=this.localClusters;a=this.selector.selectAll("g").data(this.localClusters);a.enter().append("g").append("circle").attr("class","reach").attr("r",this.distanceInPixels());a.exit().remove();this.updateCircleRadius()}return this.selector.selectAll("g").attr("transform",function(a){return b.transform(a[0])})};c=$.cookie("distance")?$.cookie("distance"):500;f.prototype.distanceInMeters=function(){if(arguments.length===0){return c}else{c=arguments[0];$.cookie("distance",c,{expires:30});q(1,"Distance",c.toString());this.updateCircleRadius();return this}};f.prototype.distanceInPixels=function(){var a;a=this.map.locationPoint({lat:0,lon:.008983}).x-this.map.locationPoint({lat:0,lon:0}).x;return this.distanceInMeters()/1e3*a};f.prototype.updateCircleRadius=function(){return this.selector.selectAll("circle.reach").attr("r",this.distanceInPixels())};f.prototype.addStops=function(a){a.sort(function(a,b){return a.lat-b.lat});this.stops=a;return this.update()};return f}(d);a=function(a){function c(){return c.__super__.constructor.apply(this,arguments)}var b;z(c,a);c.name="BusRouteLayer";b=d3.svg.line().x(function(a){return a.x}).y(function(a){return a.y}).interpolate("linear");c.prototype.update=function(){var a=this;return this.selector.selectAll("path").attr("d",function(b){return a.line(b)})};c.prototype.addRoutes=function(a,c){var d,e=this;d={};c.forEach(function(a){return d[a.id]=a});this.line=function(a){var c=this;return b(a.stops.map(function(a){return c.map.locationPoint(d[a.point_id])}))};return this.selector.selectAll("g").data(a).enter().append("path").attr("class","route").attr("d",function(a){return e.line(a)})};return c}(d);b=function(a){function f(){return f.__super__.constructor.apply(this,arguments)}var b,c,d,e;z(f,a);f.name="BusStopLayer";b=[];e=[];d=0;c=[];f.prototype.update=function(){var a,b=this;if(this.zoomLevel()!==this.prevZoom||this.stops&&this.prevNumStops!==this.stops.length){if(this.prevZoom&&this.zoomLevel()!==this.prevZoom){w("Zoom level changed",{"Zoom level":this.zoomLevel()})}this.prevNumStops=this.stops.length;this.prevZoom=this.zoomLevel();this.clusters=this.cluster(this.stops,10)}this.localClusters=this.filter(this.clusters,10);if(!this.prevLocalClusters||this.localClusters!==this.prevLocalClusters){a=this.selector.selectAll("g").data(this.localClusters);a.select("circle").attr("r",function(a){if(a.length>1){return 5}else{return 3.5}}).attr("text",this.representCluster);a.enter().append("g").append("circle").attr("class","stop no-tip").attr("r",function(a){if(a.length>1){return 5}else{return 3.5}}).attr("text",this.representCluster);a.exit().remove()}return this.selector.selectAll("g").attr("transform",function(a){return b.transform(a[0])})};f.prototype.representCluster=function(a){var b,c,d,e,f,g,h,i,j;d=[];for(f=0,h=a.length;f<h;f++){e=a[f];j=e.routes;for(g=0,i=j.length;g<i;g++){c=j[g];d.push(c)}}d=d.sort();d=function(){var a,e,f;f=[];for(b=a=0,e=d.length;a<e;b=++a){c=d[b];if(b=0||c!==d[b-1]){f.push(c)}}return f}();d=d.sort(function(a,b){return parseInt(a.match(/^\d+/)[0])-parseInt(b.match(/^\d+/)[0])});return"<ul>"+function(){var a,b,e;e=[];for(a=0,b=d.length;a<b;a++){c=d[a];e.push("<li>"+c+"</li>")}return e}().join("")+"</ul>"};f.prototype.addStops=function(a){a.sort(function(a,b){return a.lat-b.lat});this.stops=a;if(!Modernizr.touch){$(".stop").live("mouseover",function(a){return $(this).qtip({overwrite:false,content:{attr:"text"},show:{event:a.type,ready:true},hide:"mouseout"},a)})}return this.update()};return f}(d);e=function(a){function e(){this.rentalClass=x(this.rentalClass,this);return e.__super__.constructor.apply(this,arguments)}var b,c,d;z(e,a);e.name="RentalsLayer";e.prototype.viewedIndices=$.cookie("viewed-listings")?JSON.parse($.cookie("viewed-listings")):new Object;e.prototype.rentalClass=function(a,b){if(this.viewedIndices.hasOwnProperty(a.id)){if(a.updated_at>this.viewedIndices[a.id]){delete this.viewedIndices[a.id];return"rental"}else{return"rental rental-viewed"}}else{return"rental"}};c=$.cookie("priceLow")&&$.cookie("priceHigh")?[$.cookie("priceLow"),$.cookie("priceHigh")]:[0,3e3];e.prototype.priceRange=function(){if(arguments.length===0){return c}else{c=arguments[0];$.cookie("priceLow",c[0],{expires:30});$.cookie("priceHigh",c[1],{expires:30});q(2,"Price Low",c[0].toString());q(3,"Price High",c[1].toString());this.updateVisibility();return this}};d=$.cookie("roomsLow")&&$.cookie("roomsHigh")?[$.cookie("roomsLow"),$.cookie("roomsHigh")]:[0,5];e.prototype.roomsRange=function(){if(arguments.length===0){return d}else{d=arguments[0];$.cookie("roomsLow",d[0],{expires:30});$.cookie("roomsHigh",d[1],{expires:30});q(4,"Min Rooms",d[0].toString());q(5,"Max Rooms",d[1].toString());this.updateVisibility();return this}};b=$.cookie("showShared")?$.cookie("showShared")==="true":false;e.prototype.allowShared=function(){if(arguments.length===0){return b}else{b=arguments[0];$.cookie("showShared",b,{expires:30});this.updateVisibility();return this}};e.prototype.isNotSharedOrAllowed=function(a){var c;c=/shared|room/i.test(a.type);if(c){return b}else{return true}};e.prototype.updateVisibility=function(){var a=this;return this.selector.selectAll("rect").attr("visibility",function(b){var e,f;f=function(){var a,f,g,h,i,j;g=b.availabilities;j=[];for(a=0,f=g.length;a<f;a++){e=g[a];if(e&&c[0]<=(h=e.price)&&h<=c[1]&&d[0]<=(i=e.bedrooms)&&i<=d[1]){j.push(e)}}return j}();if(f.length>0){if(a.isNotSharedOrAllowed(b)){return"visible"}else{return"hidden"}}else{return"hidden"}})};e.prototype.update=function(){this.selector.selectAll("g").attr("transform",this.transform);return $(".rental").qtip("reposition")};e.prototype.convertDateToUTC=function(a){return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds())};e.prototype.setListingDisplay=function(a){var b,c,d;b=function(){var b,c,e,f;e=a.availabilities;f=[];for(b=0,c=e.length;b<c;b++){d=e[b];f.push("<li>"+(d.bedrooms?d.bedrooms:"unknown")+" bedroom: "+(d.price>0?"$"+d.price:"Unknown")+"</li>")}return f}();c="";if(a.image_url){c=c+'<a href="'+a.url+'" target="_blank" onClick="recordOutboundLink(this, \'Outbound Links\', {"source":"'+a.source+'", "url":"'+a.url+'"})"><img class="rental-img" src="'+a.image_url+'"></a>'}c=c+a.source+", "+a.type+" <br/><ul>"+b.join("")+'</ul><br /><a href="'+a.url+"\" target=\"_blank\" onClick=\"recordOutboundLink(this, 'Outbound Links', {'source':'"+a.source+"', 'url':'"+a.url+"'});return false;\">View Original Listing</a>";return c};e.prototype.addRentals=function(a){var e,f=this;e=this.selector.selectAll("g").data(a).enter().append("g").attr("transform",this.transform);e.append("rect").attr("class",this.rentalClass).attr("x",-8/2).attr("y",-8/2).attr("height",8).attr("width",8).attr("text",function(a){return f.setListingDisplay(a)});this.updateVisibility();e.on("click",function(a,e){f.viewedIndices[a.id]=new Date*1;$.cookie("viewed-listings",JSON.stringify(f.viewedIndices),{expires:30});f.selector.selectAll("g").select("rect").attr("class",f.rentalClass);n("Rental View",a.source,a.url);return w("Rental View",{"Rental Source":a.source,url:a.url,"min price":c[0],"max price":c[1],"min rooms":d[0],"max rooms":d[1],"shared allowed":b,"zoom level":f.zoomLevel()})});return $(".rental").qtip({content:{attr:"text",title:{text:"Rental Details",button:true}},show:"mousedown",hide:false,position:{my:"bottom center",at:"top center"},style:"ui-tooltip-tipped"})};return e}(d);h=new c(l);f=new a(l);g=new b(l);p=new e(l);r=function(){var a;a=function(a){$("#slider-distance > .value").html(a+"m");return h.distanceInMeters(a)};$("#slider-distance-element").slider({range:"min",value:h.distanceInMeters(),step:10,min:0,max:2500,slide:function(b,c){return a(c.value)},stop:function(a,b){return w("distance changed",{distance:h.distanceInMeters()})}});return a($("#slider-distance-element").slider("value"))};s=function(){var a;a=function(a){$("#slider-price > .value").html("$"+a[0]+" - "+a[1]);return p.priceRange(a)};$("#slider-price-element").slider({range:true,values:p.priceRange(),step:50,min:0,max:3e3,slide:function(b,c){return a(c.values)},stop:function(a,b){return w("price changed",{"low price":p.priceRange()[0],"high price":p.priceRange()[1]})}});return a($("#slider-price-element").slider("values"))};t=function(){var a;a=function(a){$("#slider-rooms > .value").html(a[0]+" - "+a[1]+" rooms");return p.roomsRange(a)};$("#slider-rooms-element").slider({range:true,values:p.roomsRange(),min:0,max:5,slide:function(b,c){return a(c.values)},stop:function(a,b){return w("# rooms changed",{"min rooms":p.roomsRange()[0],"max rooms":p.roomsRange()[1]})}});return a($("#slider-rooms-element").slider("values"))};u=function(){$("#show-shared").attr("checked",p.allowShared());return $("#show-shared").click(function(){p.allowShared(this.checked);if(this.checked){return w("shared selected")}else{return w("private selected")}})};j=function(){return d3.json("data/uvic_transit.json",function(a){h.addStops(a.stops);f.addRoutes(a.routes,a.stops);return g.addStops(a.stops)})};k=function(){return d3.json("data/rentals.json",function(a){return p.addRentals(a)})};(function(){r();s();t();u();j();k();return w("RentalMap loaded")})();$(window).unload(function(){return w("RentalMap closed")});addthis.addEventListener("addthis.menu.share",function(a){return w("AddThis",a.data)});$("a[rel*='external']").click(function(){var a;a=$(this);n("External Link",a.text(),a.attr("href"));return w("External Link",{"Link Text":a.text(),url:a.attr("href")})});$("#loading").hide()}else{$("#unsupportedBrowser").show();$(".regular").hide();n("Unsupported Browser","No SVG",navigator.userAgent);w("Unsupported Browser",{Browser:navigator.userAgent})}}).call(this)