-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
executable file
·120 lines (100 loc) · 3.79 KB
/
app.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(function () {
'use strict';
angular.module('dataProtection', [
'ngStorage',
'ngQuickDate'
]).controller('DataProtectionFormController', function ($scope, $localStorage, $sessionStorage) {
$scope.$storage = $sessionStorage;
$localStorage.$default({
plaintiff: $localStorage.plaintiff || {},
representative: $localStorage.representative || {},
operator: $localStorage.operator || {},
request: $localStorage.request || {},
// date: $localStorage.date ,
signature: $localStorage.signature || ''
});
$scope.selectFormtype = function(name) {
$scope.formType = name;
setTimeout(function(){
//do this after view has loaded :)
var $sidebar = $("#preview"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 15;
$window.scroll(function() {
if ($window.scrollTop() > offset.top && ($window.width() > 1012)) {
$sidebar.stop().animate({
top: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
top: 0
});
}
});
}, 0);
};
$scope.selectFormOperator = function(name) {
$scope.formOperator = name;
setTimeout(function(){
//do this after view has loaded :)
var $sidebar = $("#preview"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 15;
$window.scroll(function() {
if ($window.scrollTop() > offset.top && ($window.width() > 1012)) {
$sidebar.stop().animate({
top: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
top: 0
});
}
});
}, 0);
}
$scope.goForward = function(evt) {
evt.preventDefault();
var href = $(evt.target).attr('href');
$('[href="' + href + '"][role=tab]').click();
};
$scope.downloadPdf = function(evt) {
setTimeout(function() { $('button[type=submit]').click() }, 0);
};
$scope.onSubmit = function() {
var doc = new jsPDF();
if(typeof $scope.formOperator !== 'undefined') {
var html = $('.documentOperator').html();
} else {
var html = $('.documentForm').html();
}
var charmap = [
['ș', 's'],
['ț', 't'],
['ă', 'a'],
['â', 'a'],
['î', 'i'],
['Ș', 'S'],
['Ț', 'T'],
['Ă', 'A'],
['Â', 'A'],
['Î', 'I']
];
charmap.forEach(function (pair) {
html = html.replace(new RegExp(pair[0], 'g'), pair[1]);
});
doc.fromHTML(html, 15, 15, {
'width': 170,
'elementHandlers': {
'#editor': function (element, renderer) {
return true;
}
}
});
if(window._paq) { _paq.push(['trackEvent', 'Download', 'PDF']) }
doc.save('document.pdf');
};
});
})();