2015-04-19 04:45:40 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common'
|
|
|
|
], function($, _, Backbone, Common) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var GroupNavView = Backbone.View.extend({
|
|
|
|
el: '.nav .nav-item-group',
|
|
|
|
|
|
|
|
popupTemplate: _.template($('#top-group-nav-tmpl').html()),
|
|
|
|
|
|
|
|
initialize: function() {
|
2015-04-23 08:16:43 +00:00
|
|
|
var popup = $(this.popupTemplate({groups: app.pageOptions.top_nav_groups}));
|
2015-04-19 04:45:40 +00:00
|
|
|
this.$el.append(popup);
|
|
|
|
popup.css({'right': ($('#top-nav-grp').outerWidth() - popup.outerWidth())/6 * 5});
|
|
|
|
this.popup = popup;
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'mouseenter': 'showPopup',
|
|
|
|
'mouseleave': 'hidePopup',
|
|
|
|
'mouseenter #top-nav-grp-list .item': 'highlightGroupItem',
|
|
|
|
'mouseleave #top-nav-grp-list .item': 'rmHighlightGroupItem',
|
|
|
|
'click #top-nav-grp-list .item': 'visitGroup'
|
|
|
|
},
|
|
|
|
|
2015-04-23 08:16:43 +00:00
|
|
|
showPopup: function(e) {
|
2015-04-19 04:45:40 +00:00
|
|
|
this.popup.removeClass('hide');
|
|
|
|
},
|
|
|
|
|
|
|
|
hidePopup: function(e) {
|
|
|
|
this.popup.addClass('hide');
|
|
|
|
},
|
|
|
|
|
|
|
|
highlightGroupItem: function(e) {
|
2015-08-29 04:10:02 +00:00
|
|
|
$(e.currentTarget).addClass('hl').children('a').removeClass('vh');
|
2015-04-19 04:45:40 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
rmHighlightGroupItem: function(e) {
|
2015-08-29 04:10:02 +00:00
|
|
|
$(e.currentTarget).removeClass('hl').children('a').addClass('vh');
|
2015-04-19 04:45:40 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
visitGroup: function(e) {
|
2015-04-23 08:16:43 +00:00
|
|
|
this.hidePopup(e);
|
2015-04-19 04:45:40 +00:00
|
|
|
location.href = $(e.currentTarget).attr('data-url');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return GroupNavView;
|
|
|
|
});
|