!function(a,b,c,d){function e(){this.root=a("#map-editor-wrap"),this.edit_markers_mode=!1,this.edit_info_windows_mode=!1,this.init()}function f(a,b){this.id=d,this.lat=a,this.lng=b,this.title="Untitled Marker",this.marker=d,this.icon="default",this.icon_url=q,this.clickListener=d,this.rightClickListener=d,this.init()}function g(a){this.id=d,this.marker_id=a,this.info_window=d,this.open=0,this.title="Title",this.subtitle="Subtitle",this.phone="++2 1234 5678",this.address="John Smith Str. 1, Melbourne",this.email="john@smith.com",this.web="johnsmith.com",this.content="

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

",this.init()}var h={positionType:"manual",lat:-34.397,lng:150.644,zoom:8,width:640,height:480,responsive:1,searchQuery:"",language:"en",markers:[],infoWindows:[],showInfoWindowsOn:"click",animateMarkers:1,style_type:"preset",style_index:0,style_array:d,style_array_custom:"[]",auto_sign_in:0,fullscreen_enabled:0,disable_scroll:0,load_api:1},i={ar:"ARABIC",eu:"BASQUE",bg:"BULGARIAN",bn:"BENGALI",ca:"CATALAN",cs:"CZECH",da:"DANISH",de:"GERMAN",el:"GREEK",en:"ENGLISH","en-AU":"ENGLISH (AUSTRALIAN)","en-GB":"ENGLISH (GREAT BRITAIN)",es:"SPANISH",eu:"BASQUE",fa:"FARSI",fi:"FINNISH",fil:"FILIPINO",fr:"FRENCH",gl:"GALICIAN",gu:"GUJARATI",hi:"HINDI",hr:"CROATIAN",hu:"HUNGARIAN",id:"INDONESIAN",it:"ITALIAN",iw:"HEBREW",ja:"JAPANESE",kn:"KANNADA",ko:"KOREAN",lt:"LITHUANIAN",lv:"LATVIAN",ml:"MALAYALAM",mr:"MARATHI",nl:"DUTCH",no:"NORWEGIAN",pl:"POLISH",pt:"PORTUGUESE","pt-BR":"PORTUGUESE (BRAZIL)","pt-PT":"PORTUGUESE (PORTUGAL)",ro:"ROMANIAN",ru:"RUSSIAN",sk:"SLOVAK",sl:"SLOVENIAN",sr:"SERBIAN",sv:"SWEDISH",tl:"TAGALOG",ta:"TAMIL",te:"TELUGU",th:"THAI",tr:"TURKISH",uk:"UKRAINIAN",vi:"VIETNAMESE","zh-CN":"CHINESE (SIMPLIFIED)","zh-TW":"CHINESE (TRADITIONAL)"},j=d,k=d,l={},m={},n=d,o=d,p=d,q=d;a.uber_google_maps_init_editor=function(){if(l={},m={},j=d,k=a.extend(!0,{},h),a.uber_google_maps_get_stored_settings!=d){var b=a.uber_google_maps_get_stored_settings();b!=d&&(k=a.extend(!0,k,b));for(var c=0;c=e;e++)m+='
',m+=' ',m+="
";q=l+"icons/66.png",a("#preset-icons-container").html(m),a("#preset-icons-container").find(".marker-icon-wrap").first().addClass("selected");var l=a("#img-folder-url").data("url");a("#marker-custom-icon").attr("src",l+"admin/placeholder_image.png");for(var l=a("#img-folder-url").data("url"),m="",n=uber_google_maps_styles.length,e=0;n>e;e++)m+='
';a("#styles-container").html(m),b.load_settings(),b.update_form(),b.enable_events()},e.prototype.disable_events=function(){a(c).off("change","#map-form input, #map-form select, #map-form textarea"),a(c).off("change","#modal-edit-marker input"),a(c).off("change","#modal-edit-window input, #modal-edit-window textarea"),a(c).off("click","#button-sample-position"),a(c).off("click","#button-search"),a(c).off("click","#button-add-marker"),a(c).off("click","#button-add-info-window"),a(c).off("click","#button-finish-adding-markers"),a(c).off("click","#marker-custom-icon-container"),a(c).off("click","#button-finish-adding-info-windows"),a(c).off("click",".style-preset"),a(c).off("click",".button-list-item-delete"),a(c).off("click",".button-list-item-edit"),a(c).off("click","#button-confirm-delete"),a(c).off("click","#button-confirm-edit-marker"),a(c).off("click","#button-confirm-edit-window"),a(c).off("click",".marker-icon-wrap"),a(c).off("mouseover",".list-item"),a(c).off("mouseout",".list-item")},e.prototype.enable_events=function(){var b=this;a(c).on("change","#map-form input, #map-form select, #map-form textarea",function(){b.update_form(),b.update_settings(),b.redraw()}),a(c).on("change","#modal-edit-marker input",function(){b.update_marker_form()}),a(c).on("click",".marker-icon-wrap",function(){a(".marker-icon-wrap").removeClass("selected"),a(this).addClass("selected"),a("#input-marker-icon-url").val(a(this).find("img").attr("src"))}),a(c).on("change","#modal-edit-window input, #modal-edit-window textarea",function(){b.update_window_form()}),a(c).on("click","#button-sample-position",function(){b.sample_position(),b.load_settings(),b.update_settings(),b.redraw()}),a(c).on("click","#button-search",function(){b.place_search()}),a(c).on("click","#button-add-marker",function(){b.add_marker_mode()}),a(c).on("click","#button-finish-adding-markers",function(){b.add_marker_mode_quit()}),a(c).on("click","#marker-custom-icon-container",function(){a.uber_google_maps_open_image_upload("custom-marker-icon")}),a(c).on("click","#button-add-info-window",function(){b.add_info_window_mode()}),a(c).on("click","#button-finish-adding-info-windows",function(){b.add_info_window_mode_quit()}),a(c).on("click",".style-preset",function(){a(".style-preset").removeClass("selected"),a(this).addClass("selected"),b.update_settings(),b.redraw()}),a(c).on("click",".button-list-item-delete",function(b){if(a("#modal-confirm-delete").modal(),a(b.target).closest(".list-item-marker").length>0){var c=a(b.target).closest(".list-item-marker").data("marker-id");n="marker",o=c}if(a(b.target).closest(".list-item-window").length>0){var d=a(b.target).closest(".list-item-window").data("window-id");n="window",o=d}}),a(c).on("click","#button-confirm-delete",function(){"marker"==n&&b.delete_marker_from_list(o),"window"==n&&b.delete_window_from_list(o)}),a(c).on("click",".button-list-item-edit",function(c){a(c.target).closest(".list-item-marker").length>0&&(o=a(c.target).closest(".list-item-marker").data("marker-id"),b.redraw(),b.load_marker_settings(o),b.update_marker_form(),a("#modal-edit-marker").modal()),a(c.target).closest(".list-item-window").length>0&&(o=a(c.target).closest(".list-item-window").data("window-id"),b.redraw(),b.load_window_settings(o),b.update_window_form(),a("#modal-edit-window").modal())}),a(c).on("click","#button-confirm-edit-marker",function(){b.update_marker_settings(o),b.update_marker_form(),b.update_form(),b.redraw()}),a(c).on("click","#button-confirm-edit-window",function(){b.update_window_settings(o),b.update_marker_form(),b.update_form(),b.redraw()}),a(c).on("mouseover",".list-item",function(c){var d=a(this).data("marker-id");p!=d&&(p=d,b.bounce_marker(p))}),a(c).on("mouseout",".list-item",function(c){a(c.toElement).closest(".list-item").length>0&&a(c.toElement).closest(".list-item").data("marker-id")==p||(b.bounce_marker_stop(p),p=0)})},e.prototype.redraw=function(b){var c=this;c.edit_markers_mode&&c.add_marker_mode_quit(),c.edit_info_windows_mode&&c.add_info_window_mode_quit(),a("#map-container").UberGoogleMaps(k,function(a){c.map=a,b&&b()},!0)},e.prototype.load_settings=function(){a("#input-instance-title").val(k.title),a("#input-instance-shortcode").val(k.shortcode),"search"==k.positionType&&(a("#radio-map-position-manual").get(0).checked=!1,a("#radio-map-position-search").get(0).checked=!0,a("#radio-map-position-search").parent().button("toggle"),a("#settings-group-position-search-query").show(),a("#settings-group-position-manual").hide()),"manual"==k.positionType&&(a("#radio-map-position-manual").get(0).checked=!0,a("#radio-map-position-search").get(0).checked=!1,a("#radio-map-position-manual").parent().button("toggle"),a("#settings-group-position-search-query").hide(),a("#settings-group-position-manual").show()),a("#input-lat").val(k.lat),a("#input-lng").val(k.lng),a("#input-zoom").val(k.zoom),a("#input-search-query").val(k.searchQuery),a("#checkbox-animate-markers").get(0).checked=parseInt(k.animateMarkers,10),a("#select-info-windows-open").val(k.showInfoWindowsOn),"default"==k.style_type&&(a("#radio-style-default").get(0).checked=!0,a("#radio-style-preset").get(0).checked=!1,a("#radio-style-custom").get(0).checked=!1,a("#radio-style-default").parent().button("toggle")),"preset"==k.style_type&&(a("#radio-style-default").get(0).checked=!1,a("#radio-style-preset").get(0).checked=!0,a("#radio-style-custom").get(0).checked=!1,a("#radio-style-preset").parent().button("toggle")),"custom"==k.style_type&&(a("#radio-style-default").get(0).checked=!1,a("#radio-style-preset").get(0).checked=!1,a("#radio-style-custom").get(0).checked=!0,a("#radio-style-custom").parent().button("toggle")),a(".style-preset").removeClass("selected"),a('.style-preset[data-index="'+k.style_index+'"]').addClass("selected"),a("#textarea-style-array").val(k.style_array_custom),a("#input-width").val(parseInt(k.width,10)),a("#input-height").val(parseInt(k.height,10)),a("#checkbox-responsive").get(0).checked=1==parseInt(k.responsive,10)?!0:!1,a("#select-language").val(k.language),a("#checkbox-auto-sign-in").get(0).checked=1==parseInt(k.auto_sign_in,10)?!0:!1,a("#checkbox-fullscreen-enabled").get(0).checked=1==parseInt(k.fullscreen_enabled,10)?!0:!1,a("#checkbox-disable-scroll").get(0).checked=1==parseInt(k.disable_scroll,10)?!0:!1,a("#checkbox-load-api").get(0).checked=1==parseInt(k.load_api,10)?!0:!1},e.prototype.update_form=function(){a("#help-block-shortcode").html('Full shortcode:
[arrowgooglemaps name="'+a("#input-instance-shortcode").val()+'"]'),1==a("#radio-map-position-manual").get(0).checked&&(a("#settings-group-position-manual").show(),a("#settings-group-position-search-query").hide()),1==a("#radio-map-position-search").get(0).checked&&(a("#settings-group-position-manual").hide(),a("#settings-group-position-search-query").show());var b="";for(marker_id in l)b+='
'+l[marker_id].title+'
';a("#marker-list-container").html(b);var b="";for(window_id in m)b+='
Attached to: '+m[window_id].title+'
';a("#radio-style-default").get(0).checked&&(a("#container-style-default").show(),a("#container-style-preset").hide(),a("#container-style-custom").hide()),a("#radio-style-preset").get(0).checked&&(a("#container-style-default").hide(),a("#container-style-preset").show(),a("#container-style-custom").hide()),a("#radio-style-custom").get(0).checked&&(a("#container-style-default").hide(),a("#container-style-preset").hide(),a("#container-style-custom").show()),a("#window-list-container").html(b)},e.prototype.update_settings=function(){k.title=a("#input-instance-title").val(),k.shortcode=a("#input-instance-shortcode").val(),1==a("#radio-map-position-manual").get(0).checked&&(k.positionType="manual"),1==a("#radio-map-position-search").get(0).checked&&(k.positionType="search"),k.lat=a("#input-lat").val(),k.lng=a("#input-lng").val(),k.zoom=a("#input-zoom").val(),k.searchQuery=a("#input-search-query").val(),k.markers=new Array,k.infoWindows=new Array;for(marker_id in l)k.markers.push(l[marker_id].get_model());for(window_id in m)k.infoWindows.push(m[window_id].get_model());k.animateMarkers=a("#checkbox-animate-markers").get(0).checked?1:0,k.showInfoWindowsOn=a("#select-info-windows-open").val(),a("#radio-style-default").get(0).checked&&(k.style_type="default"),a("#radio-style-preset").get(0).checked&&(k.style_type="preset"),a("#radio-style-custom").get(0).checked&&(k.style_type="custom"),k.style_index=a(".style-preset.selected").data("index"),k.style_array=uber_google_maps_styles[k.style_index],k.style_array_custom=a("#textarea-style-array").val(),k.width=parseInt(a("#input-width").val(),10),k.height=parseInt(a("#input-height").val(),10),k.responsive=a("#checkbox-responsive").get(0).checked?1:0,k.language=a("#select-language").val(),k.auto_sign_in=a("#checkbox-auto-sign-in").get(0).checked?1:0,k.fullscreen_enabled=a("#checkbox-fullscreen-enabled").get(0).checked?1:0,k.disable_scroll=a("#checkbox-disable-scroll").get(0).checked?1:0,k.load_api=a("#checkbox-load-api").get(0).checked?1:0},e.prototype.load_marker_settings=function(b){var c=l[b];a("#input-marker-title").val(c.title),"default"==c.icon&&(a("#radio-marker-icon-default").get(0).checked=!0,a("#radio-marker-icon-preset").get(0).checked=!1,a("#radio-marker-icon-custom").get(0).checked=!1,a("#radio-marker-icon-default").parent().button("toggle")),"preset"==c.icon&&(a("#radio-marker-icon-default").get(0).checked=!1,a("#radio-marker-icon-preset").get(0).checked=!0,a("#radio-marker-icon-custom").get(0).checked=!1,a("#radio-marker-icon-preset").parent().button("toggle")),"custom"==c.icon&&(a("#radio-marker-icon-default").get(0).checked=!1,a("#radio-marker-icon-preset").get(0).checked=!1,a("#radio-marker-icon-custom").get(0).checked=!0,a("#radio-marker-icon-custom").parent().button("toggle")),a("#input-marker-icon-url").val(c.icon_url),a(".marker-icon-wrap").removeClass("selected"),a(".marker-icon-wrap").each(function(){a(this).find("img").attr("src")==c.icon_url&&a(this).addClass("selected")})},e.prototype.update_marker_form=function(){a("#radio-marker-icon-default").get(0).checked&&(a("#marker-icons-preset").hide(),a("#marker-icons-custom").hide()),a("#radio-marker-icon-preset").get(0).checked&&(a("#marker-icons-preset").show(),a("#marker-icons-custom").hide()),a("#radio-marker-icon-custom").get(0).checked&&(a("#marker-icons-preset").hide(),a("#marker-icons-custom").show()),a("#input-marker-icon-url").val()&&a("#input-marker-icon-url").val().length>0&&a("#marker-custom-icon").attr("src",a("#input-marker-icon-url").val())},e.prototype.update_marker_settings=function(b){var c=l[b];c.title=a("#input-marker-title").val(),a("#radio-marker-icon-default").get(0).checked&&(c.icon="default"),a("#radio-marker-icon-preset").get(0).checked&&(c.icon="preset"),a("#radio-marker-icon-custom").get(0).checked&&(c.icon="custom"),c.icon_url=a("#input-marker-icon-url").val(),this.update_settings()},e.prototype.load_window_settings=function(b){var c=m[b];a("#input-window-title").val(c.title),a("#input-window-subtitle").val(c.subtitle),a("#input-window-phone").val(c.phone),a("#input-window-address").val(c.address),a("#input-window-email").val(c.email),a("#input-window-web").val(c.web),a("#textarea-window-content").val(c.content),a("#checkbox-window-open-on-load").get(0).checked=parseInt(c.open,10)},e.prototype.update_window_form=function(){},e.prototype.update_window_settings=function(b){var c=m[b];c.title=a("#input-window-title").val(),c.subtitle=a("#input-window-subtitle").val(),c.phone=a("#input-window-phone").val(),c.address=a("#input-window-address").val(),c.email=a("#input-window-email").val(),c.web=a("#input-window-web").val(),c.content=a("#textarea-window-content").val(),c.open=a("#checkbox-window-open-on-load").get(0).checked?1:0,this.update_settings()},e.prototype.sample_position=function(){var a=this.map.getCenter();k.lat=a.lat(),k.lng=a.lng(),k.zoom=this.map.getZoom()},e.prototype.place_search=function(){var b=this,c={query:a("#input-search-query").val()};service=new google.maps.places.PlacesService(b.map),service.textSearch(c,function(c){c.length>0&&(a("#input-search-query").val(c[0].formatted_address),k.searchQuery=c[0].formatted_address,k.lat=c[0].geometry.location.lat(),k.lng=c[0].geometry.location.lng(),b.load_settings(),b.redraw())})},e.prototype.add_marker_mode=function(){if(this.edit_markers_mode)return void this.add_marker_mode_quit();this.edit_info_windows_mode&&this.add_info_window_mode_quit(),a(".button-active").removeClass("button-active"),a("#button-add-marker").addClass("button-active"),a("#map-container-wrap").addClass("add-marker-mode"),k.markers=new Array,k.infoWindows=new Array,this.redraw();for(marker_id in l)l[marker_id].attach(!0),google.maps.event.clearInstanceListeners(l[marker_id].marker),google.maps.event.addListener(l[marker_id].marker,"rightclick",j.remove_marker);for(window_id in m)m[window_id].hide();google.maps.event.addListener(this.map,"click",this.add_marker),this.edit_markers_mode=!0},e.prototype.add_marker_mode_quit=function(){a(".button-active").removeClass("button-active"),a("#map-container-wrap").removeClass("add-marker-mode");for(marker_id in l){var b=l[marker_id];b.lat=b.marker.getPosition().lat(),b.lng=b.marker.getPosition().lng(),b.id=b.lat+"_"+b.lng,delete l[marker_id],l[b.id]=b;for(window_id in m)m[window_id].marker_id==marker_id&&(m[window_id].marker_id=b.id)}this.update_form(),this.update_settings(),this.edit_markers_mode=!1,this.redraw()},e.prototype.add_marker=function(a){var b=a.latLng,c=new f(b.lat(),b.lng());c.attach(!0),google.maps.event.addListener(c.marker,"rightclick",j.remove_marker),j.update_form()},e.prototype.remove_marker=function(a){var b=a.latLng,c=b.lat()+"_"+b.lng();l[c]["delete"](),j.update_form()},e.prototype.delete_marker_from_list=function(a){var b=this;l[a]["delete"](),b.update_form(),b.update_settings(),b.redraw()},e.prototype.bounce_marker=function(b){this.edit_markers_mode||this.edit_info_windows_mode?l[b].marker.setAnimation(google.maps.Animation.BOUNCE):a.uber_google_maps_markers[b].setAnimation(google.maps.Animation.BOUNCE)},e.prototype.bounce_marker_stop=function(b){this.edit_markers_mode||this.edit_info_windows_mode?l[b].marker.setAnimation(null):a.uber_google_maps_markers[b].setAnimation(null)},e.prototype.add_info_window_mode=function(){if(this.edit_markers_mode&&this.add_marker_mode_quit(),this.edit_info_windows_mode)return void this.add_info_window_mode_quit();a(".button-active").removeClass("button-active"),a("#button-add-info-window").addClass("button-active"),a("#map-container-wrap").addClass("add-info-windows-mode"),k.markers=new Array,k.infoWindows=new Array,this.redraw();for(marker_id in l)l[marker_id].attach(!1),google.maps.event.clearInstanceListeners(l[marker_id].marker),google.maps.event.addListener(l[marker_id].marker,"click",j.add_info_window),google.maps.event.addListener(l[marker_id].marker,"rightclick",j.remove_info_window);for(window_id in m)m[window_id].show();this.edit_info_windows_mode=!0},e.prototype.add_info_window_mode_quit=function(){a(".button-active").removeClass("button-active"),a("#map-container-wrap").removeClass("add-info-windows-mode"),this.update_settings(),this.edit_info_windows_mode=!1,this.redraw()},e.prototype.add_info_window=function(a){var b=a.latLng,c=b.lat()+"_"+b.lng();for(window_id in m)if(m[window_id].marker_id==c)return void m[window_id].show();var d=new g(c);d.show(),j.update_form()},e.prototype.remove_info_window=function(a){var b=a.latLng,c=b.lat()+"_"+b.lng();for(window_id in m)m[window_id].marker_id==c&&m[window_id]["delete"]();j.update_form()},e.prototype.delete_window_from_list=function(a){var b=this;m[a]["delete"](),b.update_form(),b.update_settings(),b.redraw()},f.prototype.init=function(){this.id=this.lat+"_"+this.lng,l[this.id]=this;var a={position:{lat:parseFloat(this.lat),lng:parseFloat(this.lng)},title:this.title,draggable:!0};"default"!=this.icon&&(a.icon=this.icon_url),this.marker=new google.maps.Marker(a)},f.prototype.get_model=function(){return this.lat=this.marker.getPosition().lat(),this.lng=this.marker.getPosition().lng(),{id:this.id,lat:parseFloat(this.lat),lng:parseFloat(this.lng),icon:this.icon,icon_url:this.icon_url,title:this.title}},f.prototype.attach=function(a){var b={position:{lat:parseFloat(this.lat),lng:parseFloat(this.lng)},title:this.title,draggable:!0};"default"!=this.icon&&(b.icon=this.icon_url),this.marker=new google.maps.Marker(b),this.marker.setMap(j.map),this.marker.setDraggable(a)},f.prototype["delete"]=function(){for(window_id in m)m[window_id].marker_id==this.id&&(m[window_id].hide(),delete m[window_id]);this.marker.setMap(null),delete l[this.id]},g.prototype.init=function(){this.id=Math.floor(1e5*Math.random())+1,m[this.id]=this;var a='
';this.title.length>0&&(a+='
'+this.title+"
"),this.subtitle.length>0&&(a+='
'+this.subtitle+"
"),this.phone.length>0&&(a+='
'+this.phone+"
"),this.address.length>0&&(a+='
'+this.address+"
"),this.email.length>0&&(a+='
'+this.email+"
"),this.web.length>0&&(a+='
'+this.web+"
"),this.content.length>0&&(a+=this.content),a+="
",this.info_window=new google.maps.InfoWindow({content:a})},g.prototype.get_model=function(){return{id:this.id,marker_id:this.marker_id,title:this.title,subtitle:this.subtitle,phone:this.phone,address:this.address,email:this.email,web:this.web,content:this.content,open:this.open}},g.prototype.show=function(){this.info_window.open(j.map,l[this.marker_id].marker)},g.prototype.hide=function(){this.info_window.close()},g.prototype["delete"]=function(){this.hide(),delete m[this.id]}}(jQuery,window,document);