Fixed: Add tag when text box loses focus

This commit is contained in:
Mark McDowall
2014-12-02 17:18:17 -08:00
parent be81bf322a
commit cd1d34a0f2
17 changed files with 373 additions and 49 deletions

View File

@@ -18,7 +18,14 @@ define([
_deleteView: DeleteView,
ui: {
tags : '.x-tags'
tags : '.x-tags',
usenetDelay : '.x-usenet-delay',
torrentDelay : '.x-torrent-delay',
protocol : '.x-protocol'
},
events: {
'change .x-protocol' : '_updateModel'
},
initialize: function (options) {
@@ -32,11 +39,83 @@ define([
property : 'tags'
});
}
this._toggleControls();
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
},
_updateModel: function () {
var protocol = this.ui.protocol.val();
if (protocol === 'preferUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet'
});
}
if (protocol === 'preferTorrent') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
if (protocol === 'onlyUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : false,
preferredProtocol : 'usenet'
});
}
if (protocol === 'onlyTorrent') {
this.model.set({
enableUsenet : false,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
this._toggleControls();
},
_toggleControls: function () {
var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol');
if (preferred === 'usenet') {
this.ui.protocol.val('preferUsenet');
}
else {
this.ui.protocol.val('preferTorrent');
}
if (enableUsenet) {
this.ui.usenetDelay.show();
}
else {
this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide();
}
if (enableTorrent) {
this.ui.torrentDelay.show();
}
else {
this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide();
}
}
});