@ -9,42 +9,108 @@ define([
, "jquery"
, "backbone"
, "bootstrap"
, "text!../../templates/footer/modal-about.html"
]
, function ( _ , $ , Backbone , Bootstrap , tmplModalAbout ) {
, function ( _ , $ , Backbone , Bootstrap ) {
"use strict" ;
var Footer = Backbone . View . extend ( {
events : {
"click button[data-target='modalAboutDaapr']" : "_buttonAboutClick"
"click button[data-target='about']" : "__eventButtonAboutClick"
, "click button[data-target='sidebar']" : "__eventToggleButtonSideBar"
, "click button[data-target='random']" : "__eventToggleButtonRandom"
, "click button[data-target='repeat']" : "__eventToggleButtonRepeat"
}
, _stateRepeat : false
, _stateRandom : false
, initialize : function ( options ) {
_ . bindAll ( this
, "__eventToggleButtonRandom"
, "__eventToggleButtonRepeat"
, "__eventToggleButtonSideBar"
, "__eventButtonAboutClick"
) ;
var that = this
;
Footer . _ _super _ _ . initialize . apply ( that , arguments ) ;
}
, _ _eventToggleButtonRandom : function ( event ) {
var that = this
, $target = $ ( event . target )
;
that . _stateRandom = ! that . _stateRandom ;
if ( event . target . tagName === "I" ) {
$target = $target . parent ( ) ;
}
if ( that . _stateRandom ) {
$target . addClass ( "active" ) ;
} else {
$target . removeClass ( "active" ) ;
}
if ( ! that . _ _timeoutDebounceRandomButton ) {
that . _ _timeoutDebounceRandomButton = setTimeout ( function ( ) {
that . trigger ( "toggle:random" , that . _stateRandom ) ;
delete that . _ _timeoutDebounceRandomButton ;
} , 500 ) ;
}
}
, _ _eventToggleButtonRepeat : function ( event ) {
var that = this
, $target = $ ( event . target )
;
that . _stateRepeat = ! that . _stateRepeat ;
if ( event . target . tagName === "I" ) {
$target = $target . parent ( ) ;
}
if ( that . _stateRepeat ) {
$target . addClass ( "active" ) ;
} else {
$target . removeClass ( "active" ) ;
}
that . $el . delegate ( "button[data-toggle='side-bar']" , "click" , function ( event ) {
that . trigger ( "toggle:sidebar" ) ;
if ( ! that . _ _timeoutDebounceRepeatButton ) {
that . _ _timeoutDebounceRepeatButton = setTimeout ( function ( ) {
that . trigger ( "toggle:repeat" , that . _stateRepeat ) ;
var $target = $ ( event . target ) ;
if ( event . target . tagName === "BUTTON" ) {
$target = $target . find ( "i" ) ;
}
delete that . _ _timeoutDebounceRepeatButton ;
} , 500 ) ;
}
}
, _ _eventToggleButtonSideBar : function ( event ) {
var that = this
;
that . trigger ( "toggle:sidebar" ) ;
$target . toggleClass ( "icon-chevron-right" ) ;
$target . toggleClass ( "icon-chevron-left" ) ;
} ) ;
var $target = $ ( event . target ) ;
if ( event . target . tagName === "BUTTON" ) {
$target = $target . find ( "i" ) ;
}
$target . toggleClass ( "icon-chevron-right" ) ;
$target . toggleClass ( "icon-chevron-left" ) ;
}
, _buttonAboutClick : function ( event ) {
var $modal = $ ( tmplModalAbout )
, _ _eventB uttonAboutClick: function ( event ) {
var that = this
;
$modal . modal ( ) ;
Backbone. Router . prototype . navigate ( "about" , true ) ;
}
} ) ;