1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.7 KiB

/*jslint laxbreak:true */
/*jslint laxcomma:true */
/*jslint loopfunc:true */
/*jslint strict:true */
/*jslint browser:true */
/*jslint devel:true */
define([
"underscore"
, "jquery"
, "backbone"
, "bootstrap"
, "text!../../templates/footer/layout.html"
]
, function (
_
, $
, Backbone
, Bootstrap
, tmplFooterLayout
) {
"use strict";
var Footer = Backbone.View.extend({
events: {
"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);
that.$el.html(tmplFooterLayout);
return that;
}
, __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");
}
if (!that.__timeoutDebounceRepeatButton) {
that.__timeoutDebounceRepeatButton = setTimeout(function () {
that.trigger("toggle:repeat", that._stateRepeat || null);
delete that.__timeoutDebounceRepeatButton;
}, 500);
}
}
, __eventToggleButtonSideBar: function (event) {
var that = this
;
that.trigger("toggle:sidebar");
var $target = $(event.target);
if (event.target.tagName === "BUTTON") {
$target = $target.find("i");
}
$target.toggleClass("icon-chevron-right");
$target.toggleClass("icon-chevron-left");
}
, __eventButtonAboutClick: function(event) {
var that = this
;
Backbone.Router.prototype.navigate("about", true);
}
});
return Footer;
});