1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

Merge pull request #1080 from haiwen/HLItemView

HL item view
This commit is contained in:
Daniel Pan
2016-03-31 13:37:46 +08:00
12 changed files with 212 additions and 176 deletions

View File

@@ -3,33 +3,26 @@ define([
'underscore',
'backbone',
'common',
'moment'
], function($, _, Backbone, Common, Moment) {
'moment',
'app/views/widgets/hl-item-view',
'app/views/widgets/dropdown'
], function($, _, Backbone, Common, Moment, HLItemView, DropdownView) {
'use strict';
var DeviceView = Backbone.View.extend({
var DeviceView = HLItemView.extend({
tagName: 'tr',
template: _.template($('#device-item-tmpl').html()),
events: {
'mouseenter': 'highlight',
'mouseleave': 'rmHighlight',
'click .unlink-device': 'unlinkDevice',
'click .js-toggle-repos': 'toggleSyncedRepos'
'click .unlink-device': 'unlinkDevice'
},
initialize: function() {
$(document).click(function(e) {
var target = e.target || event.srcElement;
if (!$('.js-toggle-repos, .device-libs-popover').is(target)) {
$('.device-libs-popover').addClass('hide');
$('.dir-icon').removeClass('icon-caret-up').addClass('icon-caret-down');
}
});
HLItemView.prototype.initialize.call(this);
},
render: function () {
render: function() {
var data = this.model.toJSON();
if (typeof(data['synced_repos']) == 'undefined') {
@@ -48,36 +41,13 @@ define([
this.$el.html(this.template(data));
new DropdownView({
el: this.$('.js-dropdown')
});
return this;
},
highlight: function() {
this.$el.addClass('hl');
this.$el.find('.op-icon').removeClass('vh');
},
rmHighlight: function() {
this.$el.removeClass('hl');
this.$el.find('.op-icon').addClass('vh');
},
toggleSyncedRepos: function(e) {
var $current_icon= $(e.currentTarget).children('.dir-icon'),
$current_popover = $(e.currentTarget).next('.device-libs-popover');
$('.device-libs-popover').not($current_popover).addClass('hide');
$('.dir-icon').not($current_icon).removeClass('icon-caret-up').addClass('icon-caret-down');
$current_popover.toggleClass('hide');
if ($current_icon.hasClass('icon-caret-up')) {
$current_icon.removeClass('icon-caret-up').addClass('icon-caret-down');
} else {
$current_icon.removeClass('icon-caret-down').addClass('icon-caret-up');
}
return false
},
unlinkDevice: function() {
var _this = this,
device_name = this.model.get('device_name');