glib-web 0.11.21 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/action.js CHANGED
@@ -49,6 +49,8 @@ import ActionsAnalyticsLogEvent from "./actions/analytics/logEvent";
49
49
 
50
50
  import ActionCommandsCopy from "./actions/commands/copy";
51
51
 
52
+ import ActionToursStart from "./actions/tours/start";
53
+
52
54
  const actions = {
53
55
  runMultiple: ActionsRunMultiple,
54
56
 
@@ -96,7 +98,8 @@ const actions = {
96
98
  "auth/creditCard": ActionsCreditCard,
97
99
 
98
100
  "analytics/logEvent": ActionsAnalyticsLogEvent,
99
- "commands/copy": ActionCommandsCopy
101
+ "commands/copy": ActionCommandsCopy,
102
+ "tours/start": ActionToursStart
100
103
  };
101
104
 
102
105
  export default class Action {
@@ -0,0 +1,17 @@
1
+ import Driver from "driver.js";
2
+ import "driver.js/dist/driver.min.css";
3
+
4
+ export default class {
5
+ execute(spec, component) {
6
+ let driver = new Driver(spec.options || {});
7
+ let steps = spec.steps;
8
+ steps
9
+ .filter(value => value.customBehavior)
10
+ .forEach(step => {
11
+ const element = document.querySelector(step.element);
12
+ component.driverCustomBehavior[step.customBehavior](element, driver);
13
+ });
14
+ driver.defineSteps(steps);
15
+ driver.start(spec.startFrom || 0);
16
+ }
17
+ }
package/app.vue CHANGED
@@ -42,14 +42,13 @@ import Utils from "./utils/helper";
42
42
  import ContentLayout from "./nav/content";
43
43
  import phoenixSocketMixin from "./components/mixins/ws/phoenixSocket.js";
44
44
  import actionCableMixin from "./components/mixins/ws/actionCable.js";
45
- import tourMixin from "./components/mixins/tour";
46
45
 
47
46
  export default {
48
47
  components: {
49
48
  "nav-appbar": NavAppBar,
50
49
  "layouts-content": ContentLayout
51
50
  },
52
- mixins: [phoenixSocketMixin, actionCableMixin, tourMixin],
51
+ mixins: [phoenixSocketMixin, actionCableMixin],
53
52
  props: {
54
53
  page: { type: Object, required: true }
55
54
  },
@@ -111,7 +110,6 @@ export default {
111
110
  setTimeout(() => {
112
111
  // Wait until page is rendered
113
112
  GLib.action.execute(this.page.onLoad, this);
114
- this.startTour();
115
113
  });
116
114
  }
117
115
  }
@@ -19,10 +19,9 @@
19
19
 
20
20
  <script>
21
21
  import tooltipMixin from "./mixins/tooltip";
22
- import tourMixin from "./mixins/tour";
23
22
 
24
23
  export default {
25
- mixins: [tooltipMixin, tourMixin],
24
+ mixins: [tooltipMixin],
26
25
  props: {
27
26
  spec: { type: Object, required: true }
28
27
  },
@@ -33,7 +32,6 @@ export default {
33
32
  },
34
33
  methods: {
35
34
  $ready() {
36
- this.registerTour();
37
35
  this.tooltip = this.spec.tooltip || { disabled: true };
38
36
  }
39
37
  }
@@ -26,7 +26,7 @@
26
26
 
27
27
  <!-- <panels-responsive v-else-if="spec.view == 'panels/scroll-v1'" :spec="spec" /> -->
28
28
 
29
- <component :is="name" v-else-if="name" :spec="spec" />
29
+ <component :is="name" v-else-if="name" :id="spec.id" :spec="spec" />
30
30
 
31
31
  <div v-else>Unsupported view: {{ spec.view }}</div>
32
32
  </template>
package/index.js CHANGED
@@ -125,6 +125,9 @@ window.GLib = Framework;
125
125
  import { settings } from "./utils/settings";
126
126
  export { settings };
127
127
 
128
+ import driverCustomBehavior from "./plugins/driverCustomBehavior";
129
+ Vue.use(driverCustomBehavior);
130
+
128
131
  // TODO: https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components
129
132
  // Vue.component('async-webpack-example', function (resolve) {
130
133
  // // This special require syntax will instruct Webpack to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "0.11.21",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,6 @@
21
21
  "marked": "^4.0.0",
22
22
  "phoenix": "^1.5.3",
23
23
  "push.js": "^1.0.12",
24
- "sass": "^1.38.0",
25
- "sass-loader": "10.1.1",
26
24
  "vue": "2.6.14",
27
25
  "vue-chartkick": "^0.6.1",
28
26
  "vue-gtag": "^1.1.2",
@@ -0,0 +1,13 @@
1
+ export default {
2
+ install: (Vue, options) => {
3
+ let driverCustomBehavior = {};
4
+ driverCustomBehavior.clickToNext = (element, driver) => {
5
+ element.addEventListener("click", () => driver.moveNext());
6
+ };
7
+ driverCustomBehavior.focusToNext = (element, driver) => {
8
+ element.addEventListener("focus", () => driver.moveNext());
9
+ };
10
+
11
+ Vue.prototype.driverCustomBehavior = driverCustomBehavior;
12
+ }
13
+ };
@@ -1,75 +0,0 @@
1
- import Driver from "driver.js";
2
- import "driver.js/dist/driver.min.css";
3
-
4
- class TourHelper {
5
- constructor() {
6
- this.keys = [];
7
- this.storage = window.localStorage;
8
-
9
- this.driver = new Driver({
10
- doneBtnText: "Done",
11
- closeBtnText: "Skip tour",
12
- nextBtnText: "Next tip",
13
- prevBtnText: "Prev",
14
- onHighlighted: element => {
15
- console.log("onHighlighted", element);
16
- // TODO
17
- // this.keys.forEach(value => this.storage.removeItem(value));
18
- // this.storage.setItem(element.node.dataset.key, 1);
19
- }
20
- });
21
-
22
- this.elements = [];
23
- }
24
- }
25
-
26
- const helper = new TourHelper();
27
-
28
- export default {
29
- methods: {
30
- registerTour() {
31
- if (this.spec.tour) {
32
- helper.elements.push(this);
33
- }
34
- },
35
- startTour() {
36
- if (helper.elements && helper.elements.length > 0) {
37
- helper.elements = Array.from(helper.elements).sort(
38
- (a, b) => a.index - b.index
39
- );
40
- let stepDefinitions = helper.elements.map(element => {
41
- const tourSpec = element.spec.tour;
42
-
43
- return {
44
- element: element.$el,
45
- popover: {
46
- title: tourSpec.title,
47
- description: tourSpec.message,
48
- position: tourSpec.position
49
- }
50
- };
51
- });
52
-
53
- // TODO
54
- // this.keys = helper.elements.map(value => value.dataset.key);
55
-
56
- helper.driver.defineSteps(stepDefinitions);
57
-
58
- helper.driver.start(this.latestTourStep());
59
- }
60
- },
61
- latestTourStep() {
62
- let step = 0;
63
-
64
- // TODO
65
- // Array.from(this.elements).forEach(element => {
66
- // if (this.storage.getItem(element.dataset.key)) {
67
- // step = parseInt(element.dataset.index);
68
- // }
69
- // });
70
- // return step;
71
-
72
- return step;
73
- }
74
- }
75
- };