define(["Marionette","Modernizr","jquery","hammerjs"],function(a,b,c){return a.ItemView.extend({className:"carouselView",initialize:function(a){this.lessonsModel=a.lessonsModel,this.settingsModel=a.settingsModel,this.hasClassAnimate=!1,_.bindAll(this,"setPaneDimensions","handleHammer","template")},template:function(){var a={lessons:this.lessonsModel.deepToJSON(),languages:window.myConfigApp.display.languages.show?window.dictionary.getAllLearnLanguages():null,hitMe:this.settingsModel.getHitMe(),displayStart:window.myConfigApp.display.displayStart.show},b=this.settingsModel.getColourBackgroundSelected();return b&&b.colour&&(a.bgColour=b.colour),window.Tmpl.carouselCarousel(a)},getCurrentPanelElement:function(){var a=this.lessonsModel.getLesson();if(a){var b=this.$el.find("[data-id="+a.id+"]");if(b.length)return b}return null},events:{"click .action":"triggerHandler"},onRender:function(){this.ui.carousel.hammer({velocity:.35}).bind("swipeleft swiperight",this.handleHammer)},triggerHandler:function(a){componentUtils.stopEvent(a),this.trigger("request:"+a.currentTarget.dataset.action,a.currentTarget.dataset.id)},onShow:function(){this.initCarus()},ui:{carousel:"#carousel",container:"#carousel > ul",panels:"#carousel >ul>li",actions:".action"},initCarus:function(){this.pane_width=0,this.pane_count=this.ui.panels.length,this.current_pane=0,c(window).bind("load resize orientationchange",this.setPaneDimensions),this.setPaneDimensions();var a=!1;this.showPanelIndexRequest(this.lessonsModel.getLessonIndex(),a)},showPanelIndexRequest:function(a,b){this.showPane(a,!0,b)},setPaneDimensions:function(){this.ui.container.removeClass("animate"),this.pane_width=this.ui.carousel.width(),this.ui.panels.width(this.pane_width),this.ui.container.width(this.pane_width*this.pane_count)},showPane:function(a,b,c){c?(!this.hasClassAnimate&&this.ui.container.addClass("animate"),this.hasClassAnimate=!0):(this.hasClassAnimate&&this.ui.container.removeClass("animate"),this.hasClassAnimate=!1),this.current_pane=Math.max(0,Math.min(a,this.pane_count-1));var d=-(100/this.pane_count*this.current_pane);this.setContainerOffset(d)},setContainerOffset:function(a){if(b.csstransforms3d)this.ui.container.css("transform","translate3d("+a+"%,0,0) scale3d(1,1,1)");else if(b.csstransforms)this.ui.container.css("transform","translate("+a+"%,0)");else{var c=this.pane_width*this.pane_count/100*a;this.ui.container.css("left",c+"px")}},next:function(){this.lessonsModel.nextLesson()},prev:function(){this.lessonsModel.prevLesson()},handleHammer:function(a){switch(componentUtils.stopEvent(a),a.type){case"swipeleft":this.next();break;case"swiperight":this.prev()}},onDestroy:function(){c(window).unbind("load resize orientationchange",this.setPaneDimensions)}})});