1 | import {SharedUiComponent} from "./shareduicomponent";
|
2 | import template from "./cjs-action-sheet.html";
|
3 |
|
4 | export default class cjsActionSheet extends SharedUiComponent {
|
5 | constructor() {
|
6 | super();
|
7 | this.componentId = "cjsActionSheet";
|
8 | this.template = template;
|
9 | }
|
10 | isNative() {
|
11 | return window.NativeNav;
|
12 | }
|
13 | controller($scope) {
|
14 | var self = $scope.componentDefinition;
|
15 | $scope.hideModal = function() {
|
16 | self.popuptrigger = null;
|
17 | var routeScope = self.app.scopesForRoutes[self.route];
|
18 |
|
19 | self.app.setSharedUiComponentState(routeScope, "cjs-action-sheet", false, true, null);
|
20 | };
|
21 | $scope.handleSharedPopupButtonClick = function(b) {
|
22 | self.popuptrigger = null;
|
23 | var routeScope = self.app.scopesForRoutes[self.route];
|
24 | self.app.setSharedUiComponentState(routeScope, "cjs-action-sheet", false, true, null);
|
25 | if (routeScope && b.action) {
|
26 | routeScope.$eval(b.action);
|
27 | }
|
28 | };
|
29 | }
|
30 | setState(self, route, active, available, data) {
|
31 | self.data = data;
|
32 | self.route = route;
|
33 |
|
34 | if (window.NativeNav) {
|
35 | if (active && data.element && data.element.length > 0) {
|
36 | var rect = data.element[0].getBoundingClientRect();
|
37 | window.NativeNav.showPopupMenu(route, rect.left, rect.top, rect.width, rect.height, data.items);
|
38 | }
|
39 | } else {
|
40 | if (!active) {
|
41 | self.popuptrigger = null;
|
42 | } else {
|
43 | self.popuptrigger = {
|
44 | element: data.element
|
45 | };
|
46 | }
|
47 | }
|
48 | }
|
49 | }
|