(function(){"use strict";var a=this;a.define(["backbone","communicator","globals","hbs!tmpl/BulletLayer","underscore"],function(a,b,c,d){var e=a.Marionette.ItemView.extend({tagName:"li",events:{drop:"drop",change:"onChange","click .fa-adjust":"onOpenSlider","slide .ui-slider":"onOpacityAdjust"},initialize:function(a){this.$slider=$("<div>").slider({range:"max",max:100,min:0}),this.$slider.width(100)},onShow:function(a){$(".sortable").sortable({revert:!0,delay:90,containment:".layercontrol .panel-body",axis:"y",forceHelperSize:!0,forcePlaceHolderSize:!0,placeholder:"sortable-placeholder",handle:".fa-sort",start:function(a,b){$(".ui-slider").detach(),$(".fa-adjust").toggleClass("active"),$(".fa-adjust").popover("hide")},stop:function(a,b){b.item.trigger("drop",b.item.index())}}),$(".fa-adjust").popover({trigger:"manual"})},onChange:function(a){var d=!1;this.model.get("view").isBaseLayer&&(d=!0);var e={id:this.model.get("view").id,isBaseLayer:d,visible:a.target.checked},f=c.products.find(function(a){return a.get("view").id==e.id});if(f)if(e.visible&&"WMS"==f.get("view").protocol){var g="?LAYERS="+f.get("view").id+"&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=33.75,56.25,39.375,61.875&WIDTH=256&HEIGHT=256&TIME=2014-02-19T00:00:00Z/2014-02-19T00:00:00Z";$.get(f.get("view").urls[0]+g,function(){b.mediator.trigger("map:layer:change",e)},"text")}else b.mediator.trigger("map:layer:change",e);else b.mediator.trigger("map:layer:change",e)},drop:function(a,c){b.mediator.trigger("productCollection:updateSort",{model:this.model,position:c})},onOpenSlider:function(a){this.$(".fa-adjust").toggleClass("active").hasClass("active")?(this.$(".fa-adjust").popover("show"),this.$(".popover-content").empty().append(this.$slider),this.$(".ui-slider").slider("option","value",100*this.model.get("opacity"))):(this.$slider.detach(),this.$(".fa-adjust").popover("hide"))},onOpacityAdjust:function(a,c){this.model.set("opacity",c.value/100),b.mediator.trigger("productCollection:updateOpacity",{model:this.model,value:c.value/100})}});return{LayerItemView:e}})}).call(this);