Merge pull request #193 from whiteout-io/dev/WO-721

refactor keyfilBtn for broader usage
This commit is contained in:
Tankred Hase 2014-11-29 13:03:59 +01:00
commit 5b4d7bcd4a
5 changed files with 12 additions and 20 deletions

View File

@ -119,13 +119,4 @@ ngModule.directive('keyfileInput', function() {
};
});
ngModule.directive('keyfileBtn', function() {
return function(scope, elm) {
elm.on('click touchstart', function(e) {
e.preventDefault();
document.querySelector('#keyfile-input').click();
});
};
});
module.exports = ContactsCtrl;

View File

@ -491,13 +491,4 @@ ngModule.directive('attachmentInput', function() {
};
});
ngModule.directive('attachmentBtn', function() {
return function(scope, elm) {
elm.on('click touchstart', function(e) {
e.preventDefault();
document.querySelector('#attachment-input').click();
});
};
});
module.exports = WriteCtrl;

View File

@ -163,4 +163,14 @@ ngModule.directive('woFocusMe', function($timeout, $parse) {
};
});
ngModule.directive('woClickFileInput', function() {
return function(scope, elm, attrs) {
var fileInput = document.querySelector(attrs.woClickFileInput);
elm.on('click touchstart', function(e) {
e.preventDefault();
fileInput.click();
});
};
});
module.exports = ngModule;

View File

@ -9,7 +9,7 @@
<input class="u-hide-visually" id="keyfile-input" type="file" multiple accept=".asc" keyfile-input>
<div class="form-input-with-button u-gap-bottom">
<input class="input-text" type="text" placeholder="Search..." ng-model="searchText">
<button class="btn" ng-class="{'btn--invalid': sendBtnSecure === false}" keyfile-btn>Import keys</button>
<button class="btn" ng-class="{'btn--invalid': sendBtnSecure === false}" wo-click-file-input="#keyfile-input">Import keys</button>
</div>
<p class="typo-paragraph u-text-center" ng-show="!keys.length">

View File

@ -48,7 +48,7 @@
<div class="write__subject">
<input class="input-text" ng-model="subject" spellcheck="true" tabindex="2" placeholder="Subject" ng-change="updatePreview()">
<input id="attachment-input" type="file" multiple attachment-input>
<button class="btn" ng-class="{'btn--invalid': sendBtnSecure === false}" attachment-btn>
<button class="btn" ng-class="{'btn--invalid': sendBtnSecure === false}" wo-click-file-input="#attachment-input">
<svg><use xlink:href="#icon-attachment" /><title>Add attachment</title></svg>
</button>
</div>