/
index.js
71 lines (60 loc) · 1.32 KB
/
index.js
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
// Dependencies
var remodal = require('./lib/remodal');
var $ = require('./lib/jquery.min');
/* public function */
/*
*
* initilizes the remodal module
* @name init
*
*/
exports.init = function (config, ready) {
this._config = config;
if (!this._config.modal) {
return ready(new Error('Flow-remodal.init: Missing modal container selector.'));
}
var selector = this._config.modal;
this.modal = $(selector).remodal({
hashTracking: false
});
$(document).on('closed', selector, function (e) {
//console.log(e);
});
ready();
};
/*
*
* initilizes the remodal module
* @name render
*
*/
exports.addContent = function (options, data, next) {
if (!this._config.modalContent) {
return next(new Error('Flow-remodal.addContent: Modal content selector not configured'));
}
var selector = this._config.modalContent;
var content = $(selector);
// clear the content
content.html(JSON.stringify(data, null, 2));
next(null, data);
};
/*
*
* initilizes the remodal module
* @name open
*
*/
exports.open = function (options, data, next) {
this.modal.open();
next(null, data);
};
/*
*
* initilizes the remodal module
* @name close
*
*/
exports.close = function (options, data, next) {
this.modal.close();
next(null, data);
};