Add directive for file input change

This commit is contained in:
Magnus Hauge Bakke 2015-10-09 13:50:55 +02:00 committed by Lorenz Hübschle-Schneider
parent accbf276ad
commit 0d7d8e0cce
2 changed files with 24 additions and 0 deletions

View File

@ -33,6 +33,7 @@
<script type="text/javascript" src="js/filters.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript" src="js/connection.js"></script>
<script type="text/javascript" src="js/file-change.js"></script>
<script type="text/javascript" src="js/inputbar.js"></script>
<script type="text/javascript" src="js/plugin-directive.js"></script>
<script type="text/javascript" src="js/websockets.js"></script>

23
js/file-change.js Normal file
View File

@ -0,0 +1,23 @@
(function() {
'use strict';
var weechat = angular.module('weechat');
weechat.directive('fileChange', ['$parse', function($parse) {
return {
restrict: 'A',
link: function ($scope, element, attrs) {
var attrHandler = $parse(attrs.fileChange);
var handler = function (e) {
$scope.$apply(function () {
attrHandler($scope, { $event: e, files: e.target.files });
});
};
element[0].addEventListener('change', handler, false);
}
};
}]);
})();