App.Models.BBDModel=Backbone.Model.extend({defaults:{persist:!1,solo:!0}}),App.Views.BottomDrawerViewNew=Backbone.View.extend({template:_.template(bottom_drawer_new_template),initialize:function(e){this.render(),this.setElement(e.el)},render:function(){showDebug==3&&console.log(this),$("#bbd_container").append(this.template({id:this.model.get("_id")})),this.setDrawerSpecificAttr();var e=$("#"+this.model.get("_id")),t=this.model.get("class");t&&e.addClass(t),this.$el.init.prototype.close=this.closeDrawer,this.$el.init.prototype.open=this.openDrawer,this.$el.init.prototype.toggle=this.toggleDrawer,this.$el.init.prototype.killYourself=this.destroyDrawer,this.$el.init.prototype.renderContent=this.renderContent;var n=this.model.get("child");n&&this.renderContent(n),this.model.get("persist")||setTimeout(_.bind(function(){this.openDrawer()},this),50)},closeDrawer:function(e){var t=this;showDebug==3&&console.log("closeDrawer"),t.$el||(t=t.backboneView());if(t){t.$el.removeClass("open");var n=$(t.el.parentElement);t.setShowHideBackdropClass(n)}},openDrawer:function(e){showDebug==3&&console.log("openDrawer");var t=this;t.$el||(t=t.backboneView()),t.model.get("solo")&&$.each($(".bbd"),function(e,n){$(n).backboneView().closeDrawer(),t.model.get("_id")==="bbd_presets"&&funcObj.presets.scrollToTop(!0)}),t.$el.removeClass("vis_off"),t.$el.addClass("open");var n=$(t.el.parentElement);$("#main").addClass(t.model.get("_id")),t.setShowHideBackdropClass(n),t.delegateEvents(),funcObj.UIMain.addAccessibilityOnViewChange(t.model.get("_id"))},toggleDrawer:function(e){var t=this;showDebug==3&&console.log("toggleDrawer"),t.$el||(t=t.backboneView()),t.$el.toggleClass("open");var n=$(t.el.parentElement);t.setShowHideBackdropClass(n),t.$el.hasClass("open")&&$("#main").addClass(t.model.get("_id"))},destroyDrawer:function(e){var t=this;showDebug==3&&console.log("destroyDrawer"),t.$el||(t=t.backboneView());if(t){$("#main").removeClass(t.model.get("_id")),t.model.get("_id")=="bbd_tour"&&$(".zztop").removeClass("zztop");var n=$(t.$el[0].parentElement);t.setShowHideBackdropClass($(t.el.parentElement)),t.undelegateEvents(),t.unbind(),t.remove(),Backbone.View.prototype.remove.call(t)}},renderContent:function(e){var t=this;showDebug==3&&console.log("renderContent"),t.$el||(t=t.backboneView()),e.setElement("#"+t.model.get("_id")+" .child_content"),e.model.set("parentDrawer",t.model.get("_id")),e.render()},setShowHideBackdropClass:function(e){var t=this,n=!1;for(var r=0;r<e[0].children.length;r++){var i=$(e[0].children[r]);i.hasClass("open")&&(n=!0)}var s=typeof t.model.get("backdrop")!="boolean"||t.model.get("_id")!=="bbd_presets"&&t.model.get("_id")!=="bbd_favorites"?n:t.model.get("backdrop");s?e.addClass("show_backdrop"):e.removeClass("show_backdrop"),app.Models.MainLayoutModel.trigger("BOTTOM_DRAWER",{bottomDrawer:n})},setDrawerSpecificAttr:function(){var e=$("#"+this.model.get("_id"));showDebug==3&&console.log(e),this.model.get("persist")||e.on(transEndEvent,function(t){var n=t.originalEvent.srcElement.id,r=$(t.originalEvent.srcElement);e.hasClass("open")||e.killYourself()}),this.model.get("dismiss")?e.find(".toggleBottomDrawer").removeClass("hide"):e.find(".toggleBottomDrawer").addClass("hide")},delegateEvents:function(){var e=this;$(e.$el).on(vdown,function(e){(e.target.id==="toggleBottomDrawer"||e.target.className==="bbd open")&&funcObj.UIMain.setCurBut(e.target.id)}).on(vup,function(t){t.target.id===funcObj.UIMain.getCurBut()&&!outside&&!moved&&t.target.id==="toggleBottomDrawer"&&e.closeDrawer(),t.target.className==="bbd open"&&e.model.get("dismiss")&&e.closeDrawer()})},undelegateEvents:function(){$("#bbd_container").off(),$("div.toggleBottomDrawer").off()}});