this.Openlayers_Dataset_Map=function(){function r(){}return r.map=null,r.map_points=null,r.render=function(e,t){$(".dataset-search a#ajax-search").colorbox({fixed:!0,width:"90%",height:"90%"});var a=$(e)[0];r.map=new Openlayers_Map(a,t)},r.selectItem=function(e){var t=$(e).attr("data-id"),a=$(e).find(".selected-item").clone(!1);$(a).find("a").removeClass("cboxElement"),$(a).find('[name="resource_id"]').each(function(){var e=$(this).val();$(this).data("map_points",r.map_points[t][e]),$(this).on("click",function(){r.setMarkers(),r.map.resize()}),$(this).closest("li").find(".marker-image-form .select-marker-image").on("click",function(){var e=$(this).closest(".marker-image-form"),t=$(e).find(".images");return $(".marker-image-form .images").hide(),t.show(),$("body").not(this).one("click",function(){t.hide()}),!1}),$(this).closest("li").find(".marker-image-form .images .image").on("click",function(){var e=$(this).closest(".marker-image-form"),t=$(e).find(".images"),a=$(e).find(".marker-thumb img"),s=$(this).find("img").andSelf("img").attr("src");return e.data("src",s),a.attr("src",s),t.hide(),r.setMarkers(),!1}),$(this).closest("li").find(".marker-image-form .marker-thumb").html($('<img src="'+r.map.markerIcon+'">'))}),$(a).find(".deselect").on("click",function(){return $(this).closest(".selected-item").remove(),r.setMarkers(),r.map.resize(),!1}),a.show(),$(".dataset-search .selected-dataset").append(a);for(var s=$(".dataset-search .selected-dataset .selected-item").length-10,i=0;i<s;i++)$(".dataset-search .selected-dataset .selected-item:first").remove();return a},r.setMarkers=function(){r.map.removeMarkers(),r.map.removeloadedLayers(),$(".dataset-search .selected-item .set-markers:checked").each(function(){var e=$(this).data("map_points"),t=$(this).closest("li").find(".marker-image-form");t&&t.data("src")&&$.each(e.points,function(){this.image=t.data("src")}),e.points?r.map.renderMarkers(e.points):"KML"==e.format?r.map.loadLayer(e.url,ol.format.KML):"GEOJSON"==e.format&&r.map.loadLayer(e.url,ol.format.GeoJSON)})},r.toggleSelectButton=function(){0<$(".search-ui .items input:checked").size()?$(".select-items").parent("div").show():$(".select-items").parent("div").hide()},r.modal=function(e){r.map_points=e,$(".search-ui-form form.search").on("submit",function(){return $(this).ajaxSubmit({url:$(this).attr("action"),success:function(e){return $("#cboxLoadedContent").html(e)},error:function(){return alert("== Error ==")}}),!1}),$(".search-ui a.select-item").on("click",function(){var e=$(this).closest("tr"),t=r.selectItem(e);return $.colorbox.close(),$(t).find(".set-markers").trigger("click"),!1}),$(".search-ui-select .select-items").on("click",function(){return $(".search-ui .items .set-dataset:checked").each(function(){var e=$(this).closest("tr");r.selectItem(e)}),$.colorbox.close(),!1}),$(".search-ui .list-head input:checkbox").on("change",function(){var e=$(this).prop("checked");$(".search-ui .list-item").each(function(){$(this).toggleClass("checked",e),$(this).find(".set-dataset").prop("checked",e)})}),$(".search-ui").on("change",function(){r.toggleSelectButton()}),$(".dataset-search .selected-dataset .selected-item").each(function(){var e=$(this).attr("data-id"),t=$(".items [data-id='"+e+"']");t.find("input[type=checkbox]").remove();var a=t.find(".select-item").html();t.find(".select-item").replaceWith("<span class='select-item' style='color: #888'>"+a+"</span>")})},r}();