PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.2
Independent Analytics – WordPress Analytics Plugin v2.14.2
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / javascript-source / controllers / overview / module.js
independent-analytics / javascript-source / controllers / overview Last commit date
add_module.js 1 year ago checkbox_group.js 1 year ago module.js 1 year ago module_editor.js 1 year ago module_list.js 1 year ago module_picker.js 1 year ago reorder_modules.js 1 year ago
module.js
132 lines
1 import {Controller} from "@hotwired/stimulus"
2 import {getModuleMarkup} from "../../modules/module-markup";
3
4 export default class extends Controller {
5 static targets = []
6 static values = {
7 moduleId: String,
8 hasDataset: Boolean
9 }
10
11 connect() {
12 if(!this.hasDatasetValue) {
13 getModuleMarkup(this.moduleIdValue)
14 document.addEventListener('iawp:module-markup:' + this.moduleIdValue, this.handleMarkup)
15 }
16 }
17
18 disconnect() {
19 document.removeEventListener('iawp:module-markup:' + this.moduleIdValue, this.handleMarkup)
20 }
21
22 delete(event) {
23 const button = event.currentTarget
24 const module = button.closest('.iawp-module')
25 const data = {
26 ...iawpActions.delete_module,
27 module_id: this.moduleIdValue
28 }
29
30 button.disabled = true
31 button.classList.add('sending')
32 module.classList.add('will-be-refreshed')
33
34 jQuery.post(ajaxurl, data, (response) => {
35 this.element.remove()
36 button.disabled = false
37 }).fail((error) => {
38 button.classList.remove('sending')
39 button.disabled = false
40 })
41 }
42
43 edit(event) {
44 const button = event.currentTarget
45 const data = {
46 ...iawpActions.get_markup_for_module,
47 id: this.moduleIdValue
48 }
49
50
51 this.signalEditingStarted()
52 button.classList.add('sending')
53 button.disabled = true
54
55 jQuery.post(ajaxurl, data, (response) => {
56 this.element.outerHTML = response.data.editor_html
57 button.classList.remove('sending')
58 button.disabled = false
59 }).fail((error) => {
60 this.signalEditingFinished()
61 button.classList.remove('sending')
62 button.disabled = false
63 })
64 }
65
66 toggleWidth(event) {
67 const button = event.currentTarget
68 const module = button.closest('.iawp-module')
69 const shouldBeFullWidth = !module.classList.contains('full-width')
70
71 const data = {
72 ...iawpActions.edit_module,
73 module_id: this.moduleIdValue,
74 fields: {
75 is_full_width: shouldBeFullWidth
76 }
77 }
78
79 module.classList.toggle('full-width', shouldBeFullWidth)
80
81 if ((module.querySelector('.recent-views') || module.querySelector('.recent-conversions')) && module.querySelector('.module-pagination')) {
82 module.querySelector(".current-page").textContent = "1"
83 module.querySelector(".current").classList.remove('current')
84 module.querySelector(".module-page").classList.add('current')
85 module.querySelector(".pagination-button.left").disabled = true
86 module.querySelector(".pagination-button.right").disabled = false
87 }
88 jQuery.post(ajaxurl, data, (response) => {
89 //
90 }).fail((error) => {
91 // module.classList.toggle('full-width', !shouldBeFullWidth)
92 })
93 }
94
95 handleMarkup = (event) => {
96 const html = event.detail.moduleHtml
97 const isDraggable = this.element.classList.contains('draggable-module')
98 document.removeEventListener('iawp:module-markup:' + this.moduleIdValue, this.handleMarkup)
99 this.element.outerHTML = html
100
101 // Update the new module with whatever draggable state the replaced module had
102 setTimeout(() => {
103 const module = document.querySelector(`[data-module-module-id-value="${event.detail.id}"]`)
104 if(module) {
105 module.classList.toggle('draggable-module', isDraggable)
106 }
107 }, 0)
108 }
109
110
111 signalEditingStarted() {
112 document.dispatchEvent(
113 new CustomEvent('iawp:moduleEditingStarted', {
114 detail: {
115 moduleId: this.moduleIdValue
116 }
117 })
118 )
119 }
120
121 signalEditingFinished() {
122 document.dispatchEvent(
123 new CustomEvent('iawp:moduleEditingFinished', {
124 detail: {
125 moduleId: this.moduleIdValue
126 }
127 })
128 )
129 }
130
131
132 }