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
|
/*!
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
import { IParseService } from 'angular';
import { ComponentPublicInstance } from 'vue';
import MatomoDialog from './MatomoDialog.vue';
import createAngularJsAdapter from '../createAngularJsAdapter';
export default createAngularJsAdapter<[IParseService]>({
component: MatomoDialog,
scope: {
show: {
vue: 'modelValue',
default: false,
},
element: {
default: (scope, element) => element[0],
},
},
events: {
yes: ($event, scope, element, attrs) => {
if (attrs.yes) {
scope.$eval(attrs.yes);
setTimeout(() => { scope.$apply(); }, 0);
}
},
no: ($event, scope, element, attrs) => {
if (attrs.no) {
scope.$eval(attrs.no);
setTimeout(() => { scope.$apply(); }, 0);
}
},
close: ($event, scope, element, attrs) => {
if (attrs.close) {
scope.$eval(attrs.close);
setTimeout(() => { scope.$apply(); }, 0);
}
},
'update:modelValue': (newValue, scope, element, attrs, $parse: IParseService) => {
setTimeout(() => {
scope.$apply($parse(attrs.piwikDialog).assign(scope, newValue));
}, 0);
},
},
$inject: ['$parse'],
directiveName: 'piwikDialog',
transclude: true,
mountPointFactory: (scope, element) => {
const vueRootPlaceholder = $('<div class="vue-placeholder"/>');
vueRootPlaceholder.appendTo(element);
return vueRootPlaceholder[0];
},
postCreate: (vm: ComponentPublicInstance, scope, element, attrs) => {
scope.$watch(attrs.piwikDialog, (newValue: boolean, oldValue: boolean) => {
if (oldValue !== newValue) {
vm.modelValue = newValue || false;
}
});
},
noScope: true,
});
|