Add directive for file input change
This commit is contained in:
parent
accbf276ad
commit
0d7d8e0cce
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
})();
|
Loading…
Reference in New Issue