Commit f2d1ae51 authored by alexandre's avatar alexandre

Use Behaviors for Toggable and moved to its own file

parent 3704d817
;
window.W = window.W || {};
(function (undefined) {
'use strict';
W.ToggableBehavior = Marionette.Behavior.extend({
ui: {
'toggle': '.panel__toggle',
},
triggers: {
'click @ui.toggle': 'toggle',
},
onShow: function () {
this.$el.removeClass('is-collapsed');
},
onHide: function () {
// console.log("hiding");
this.$el.addClass('is-collapsed');
},
onToggle: function () {
this.$el.toggleClass('is-collapsed');
},
});
W.ModalBehavior = Marionette.Behavior.extend({
ui: {
'close': '.btn-close',
'submit': '.btn-submit',
'register': '.js-register',
},
triggers: {
'click @ui.close': 'hide:modal',
'click @ui.submit': 'submit',
'click @ui.register': 'show:register',
},
});
})();
......@@ -298,22 +298,6 @@ window.W = window.W || {};
var state = initState();
W.ToggableView = Marionette.View.extend({
onShow: function () {
this.$el.removeClass('is-collapsed');
},
onHide: function () {
// console.log("hiding");
this.$el.addClass('is-collapsed');
},
onToggle: function () {
this.$el.toggleClass('is-collapsed');
},
});
/**
* Instantiate with at least a label.
*/
......@@ -2284,21 +2268,15 @@ window.W = window.W || {};
});
W.SearchPanelView = W.ToggableView.extend({
W.SearchPanelView = Marionette.View.extend({
behaviors: [W.ToggableBehavior],
template: '#search-panel-template',
attributes: {
class: 'score-filters panel panel--right'
},
ui: {
'toggle': '.panel__toggle',
},
triggers: {
'click @ui.toggle': 'toggle',
},
regions: {
search: '#search',
languageFilter: '#language-filter',
......@@ -2480,25 +2458,6 @@ window.W = window.W || {};
});
W.ModalBehavior = Marionette.Behavior.extend({
// attributes : {
// class: 'page__modal modal',
// },
ui: {
'close': '.btn-close',
'submit': '.btn-submit',
'register': '.js-register',
},
triggers: {
'click @ui.close': 'hide:modal',
'click @ui.submit': 'submit',
'click @ui.register': 'show:register',
},
});
W.LoginView = Marionette.View.extend({
template: '#login-template',
......@@ -2696,35 +2655,29 @@ window.W = window.W || {};
});
W.helpView = W.ToggableView.extend({
W.helpView = Marionette.View.extend({
behaviors: [W.ToggableBehavior],
template: '#help-template',
attributes: {
class: 'page__help help is-collapsed panel panel--right'
},
ui: {
'toggle': '.panel__toggle',
},
triggers: {
'click @ui.show': 'show',
'click @ui.hide': 'hide',
'click @ui.toggle': 'toggle',
},
});
W.HeaderView = W.ToggableView.extend({
W.HeaderView = Marionette.View.extend({
tagName: 'header',
template: '#header-template',
attributes: {
class: 'page__header main-header panel panel--left'
},
behaviors: [W.ToggableBehavior],
ui: {
'toggle': '.js-toggle',
'login': '.js-login',
'logout': '.js-logout',
'register': '.js-register',
......@@ -2732,9 +2685,6 @@ window.W = window.W || {};
},
triggers: {
'click @ui.show': 'show',
'click @ui.hide': 'hide',
'click @ui.toggle': 'toggle',
'click @ui.login': 'show:login',
'click @ui.logout': 'show:logout',
'click @ui.register': 'show:register',
......
......@@ -185,6 +185,7 @@
<script src="{% static 'playground/js/extendedTemplate.js' %}"></script>
<script src="{% static 'playground/js/models.js' %}"></script>
<script src="{% static 'playground/js/collections.js' %}"></script>
<script src="{% static 'playground/js/behaviors.js' %}"></script>
<script src="{% static 'playground/js/views.js' %}"></script>
<script src="{% static 'playground/js/controllers.js' %}"></script>
<script src="{% static 'playground/js/routers.js' %}"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment