87a9320acd8f15d7b75db236ca9eb5987889ecaf.svn-base
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
import CONFIG from './../config.json';
let {
extend
} = angular;
export default () => {
class FileDirective {
/**
* Creates instance of {FileDirective} object
* @param {Object} options
* @param {Object} options.uploader
* @param {HTMLElement} options.element
* @param {Object} options.events
* @param {String} options.prop
* @constructor
*/
constructor(options) {
extend(this, options);
this.uploader._directives[this.prop].push(this);
this._saveLinks();
this.bind();
}
/**
* Binds events handles
*/
bind() {
for(var key in this.events) {
var prop = this.events[key];
this.element.bind(key, this[prop]);
}
}
/**
* Unbinds events handles
*/
unbind() {
for(var key in this.events) {
this.element.unbind(key, this.events[key]);
}
}
/**
* Destroys directive
*/
destroy() {
var index = this.uploader._directives[this.prop].indexOf(this);
this.uploader._directives[this.prop].splice(index, 1);
this.unbind();
// this.element = null;
}
/**
* Saves links to functions
* @private
*/
_saveLinks() {
for(var key in this.events) {
var prop = this.events[key];
this[prop] = this[prop].bind(this);
}
}
}
/**
* Map of events
* @type {Object}
*/
FileDirective.prototype.events = {};
return FileDirective;
}
module.exports.$inject = [
];