|
1
|
|
|
/** |
|
2
|
|
|
* We'll load the axios HTTP library which allows us to easily issue requests |
|
3
|
|
|
* to our Laravel back-end. This library automatically handles sending the |
|
4
|
|
|
* CSRF token as a header based on the value of the "XSRF" token cookie. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Sett global authorization headers for js libraries |
|
11
|
|
|
*/ |
|
12
|
|
|
window.axios.defaults.headers.common['Authorization'] = "Bearer " + Laravel.apiToken; |
|
|
|
|
|
|
13
|
|
|
$.ajaxSetup({ |
|
14
|
|
|
beforeSend: function (xhr) { |
|
15
|
|
|
xhr.setRequestHeader("Authorization", "Bearer " + Laravel.apiToken); |
|
|
|
|
|
|
16
|
|
|
} |
|
17
|
|
|
}); |
|
18
|
|
|
kendo.jQuery.ajaxSetup({ |
|
|
|
|
|
|
19
|
|
|
beforeSend: function (xhr) { |
|
20
|
|
|
xhr.setRequestHeader("Authorization", "Bearer " + Laravel.apiToken); |
|
|
|
|
|
|
21
|
|
|
} |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Next we will register the CSRF Token as a common header with Axios so that |
|
26
|
|
|
* all outgoing HTTP requests automatically have it attached. This is just |
|
27
|
|
|
* a simple convenience so we don't have to attach every token manually. |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
let token = document.head.querySelector('meta[name="csrf-token"]'); |
|
31
|
|
|
|
|
32
|
|
|
if (token) { |
|
33
|
|
|
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; |
|
34
|
|
|
} else { |
|
35
|
|
|
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Echo exposes an expressive API for subscribing to channels and listening |
|
40
|
|
|
* for events that are broadcast by Laravel. Echo and event broadcasting |
|
41
|
|
|
* allows your team to easily build robust real-time web applications. |
|
42
|
|
|
*/ |
|
43
|
|
|
|
|
44
|
|
|
// window.Echo = new Echo({ |
|
45
|
|
|
// broadcaster: 'pusher', |
|
46
|
|
|
// key: 'your-pusher-key' |
|
47
|
|
|
// }); |
|
48
|
|
|
|
|
49
|
|
|
// Material Buttons |
|
50
|
|
|
$(() => { |
|
51
|
|
|
window['mmex'] = window['mmex'] || {}; |
|
52
|
|
|
window['mmex']['momentLocal'] = (date) => { |
|
53
|
|
|
if (!date || _.isEmpty(date)) { |
|
|
|
|
|
|
54
|
|
|
return moment(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
let m = moment(date); |
|
58
|
|
|
if (m.isValid()) { |
|
59
|
|
|
return m; |
|
60
|
|
|
} |
|
61
|
|
|
m = moment(date, "DD.MM.YYYY"); |
|
62
|
|
|
if (m.isValid()) { |
|
63
|
|
|
return m; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
throw new Error("No supported date format found for ", date); |
|
67
|
|
|
}; |
|
68
|
|
|
|
|
69
|
|
|
$.material.init(); |
|
70
|
|
|
|
|
71
|
|
|
autosize($('textarea')); |
|
72
|
|
|
|
|
73
|
|
|
$("[autofocus]").focus(); |
|
74
|
|
|
|
|
75
|
|
|
$(".common-dateinput").each((index, elm) => { |
|
76
|
|
|
let val = $(elm).val(); |
|
77
|
|
|
let date = mmex.momentLocal(val).toDate(); |
|
|
|
|
|
|
78
|
|
|
console.log("set date ", date, " out of ", val); |
|
|
|
|
|
|
79
|
|
|
new kendo.ui.DateInput($(elm), { |
|
|
|
|
|
|
80
|
|
|
value: val ? date : new Date() |
|
81
|
|
|
}); |
|
82
|
|
|
}); |
|
83
|
|
|
|
|
84
|
|
|
$(".common-datepicker").each((index, elm) => { |
|
85
|
|
|
let val = $(elm).val(); |
|
86
|
|
|
let date = mmex.momentLocal(val).toDate(); |
|
|
|
|
|
|
87
|
|
|
console.log("set date ", date, " out of ", val); |
|
|
|
|
|
|
88
|
|
|
new kendo.ui.DatePicker($(elm), { |
|
|
|
|
|
|
89
|
|
|
value: val ? date : new Date() |
|
90
|
|
|
}); |
|
91
|
|
|
}); |
|
92
|
|
|
|
|
93
|
|
|
$(".common-dropdown-list").each((index, elm) => { |
|
94
|
|
|
new kendo.ui.DropDownList($(elm), { |
|
|
|
|
|
|
95
|
|
|
filter: "startswith", |
|
96
|
|
|
}); |
|
97
|
|
|
}); |
|
98
|
|
|
|
|
99
|
|
|
$('textarea, input').keyup(function (e) { |
|
100
|
|
|
if (e.which == 17) isCtrl = false; |
|
|
|
|
|
|
101
|
|
|
}).keydown(function (e) { |
|
102
|
|
|
if (e.which == 17) isCtrl = true; |
|
|
|
|
|
|
103
|
|
|
if (e.which == 13 && isCtrl === true) { |
|
|
|
|
|
|
104
|
|
|
$(this).closest('form').submit(); |
|
105
|
|
|
return false; |
|
106
|
|
|
} |
|
107
|
|
|
}); |
|
108
|
|
|
}); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.