1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-22 07:16:38 +02:00
keeweb/app/scripts/views/open-view.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-10-17 23:49:24 +02:00
'use strict';
var Backbone = require('backbone'),
2015-11-05 21:58:33 +01:00
Keys = require('../const/keys'),
Alerts = require('../comp/alerts'),
SecureInput = require('../comp/secure-input'),
2015-10-24 21:06:44 +02:00
FileModel = require('../models/file-model'),
2015-11-05 21:58:33 +01:00
Launcher = require('../comp/launcher'),
DropboxLink = require('../comp/dropbox-link');
2015-10-17 23:49:24 +02:00
var OpenView = Backbone.View.extend({
template: require('templates/open.html'),
events: {
2015-11-05 21:58:33 +01:00
'change .open__file-ctrl': 'fileSelected',
'click .open__icon-open': 'openFile',
'click .open__icon-new': 'createNew',
'click .open__icon-dropbox': 'openFromDropbox',
'click .open__icon-demo': 'createDemo',
'click .open__pass-input[readonly]': 'openFile',
'input .open__pass-input': 'inputInput',
'keydown .open__pass-input': 'inputKeydown',
'keypress .open__pass-input': 'inputKeypress',
'click .open__settings-key-file': 'openKeyFile',
'change .open__settings-check-offline': 'changeOffline',
2015-10-17 23:49:24 +02:00
'dragover': 'dragover',
'dragleave': 'dragleave',
'drop': 'drop'
},
2015-11-05 21:58:33 +01:00
fileData: null,
keyFileData: null,
passwordInput: null,
dropboxLoading: null,
2015-10-17 23:49:24 +02:00
initialize: function () {
this.file = new FileModel();
2015-11-05 21:58:33 +01:00
this.fileData = null;
this.keyFileData = null;
this.passwordInput = new SecureInput();
2015-10-17 23:49:24 +02:00
this.listenTo(this.file, 'change:open', this.fileOpened);
},
render: function () {
if (this.dragTimeout) {
clearTimeout(this.dragTimeout);
}
2015-11-05 21:58:33 +01:00
this.renderTemplate({
supportsDropbox: !Launcher,
dropboxLoading: this.dropboxLoading
});
this.inputEl = this.$el.find('.open__pass-input');
this.passwordInput.setElement(this.inputEl);
2015-10-17 23:49:24 +02:00
return this;
}
});
module.exports = OpenView;