Require vue-shortkey and use on Vue

parent 8a624a56
......@@ -31282,6 +31282,7 @@ _vue2.default.use(_elementUi2.default, { locale: _en2.default });
_vue2.default.use(_vueDataTables2.default, { locale: _en2.default });
_vue2.default.use(_vueI18n2.default);
_vue2.default.use(_vueRouter2.default);
_vue2.default.use(__webpack_require__(141), { prevent: ['input', 'textarea'] });
_vue2.default.component('ckeditor', __webpack_require__(125));
_vue2.default.component('DeleteButton', __webpack_require__(132));
......@@ -72759,9 +72760,14 @@ var _TranslationHelper = __webpack_require__(10);
var _TranslationHelper2 = _interopRequireDefault(_TranslationHelper);
var _ShortcutHelper = __webpack_require__(142);
var _ShortcutHelper2 = _interopRequireDefault(_ShortcutHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _data = void 0; //
//
//
//
//
//
......@@ -72838,8 +72844,10 @@ var _data = void 0; //
//
//
var _data = void 0;
exports.default = {
mixins: [_TranslationHelper2.default],
mixins: [_TranslationHelper2.default, _ShortcutHelper2.default],
data: function data() {
return {
data: _data,
......@@ -73129,7 +73137,24 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
_vm.meta.current_page = $event
}
}
})], 1)], 1)])])])])])
})], 1)], 1)])])])]), _vm._v(" "), _c('button', {
directives: [{
name: "shortkey",
rawName: "v-shortkey",
value: (['c']),
expression: "['c']"
}],
staticStyle: {
"display": "none"
},
on: {
"shortkey": function($event) {
_vm.pushRoute({
name: 'admin.page.page.create'
})
}
}
})])
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
......@@ -73202,12 +73227,112 @@ var _TranslationHelper = __webpack_require__(10);
var _TranslationHelper2 = _interopRequireDefault(_TranslationHelper);
var _ShortcutHelper = __webpack_require__(142);
var _ShortcutHelper2 = _interopRequireDefault(_ShortcutHelper);
var _formBackendValidation = __webpack_require__(120);
var _formBackendValidation2 = _interopRequireDefault(_formBackendValidation);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
mixins: [_Slugify2.default, _TranslationHelper2.default, _ShortcutHelper2.default],
props: {
locales: { default: null },
pageTitle: { default: null, String: String }
},
data: function data() {
return {
page: _(this.locales).keys().map(function (locale) {
return [locale, {
title: '',
slug: '',
body: '',
meta_title: '',
meta_description: '',
og_title: '',
og_description: '',
og_type: ''
}];
}).fromPairs().merge({ template: 'default', is_home: 0 }).value(),
templates: {
'index': 'index',
'home': 'home',
'default': 'default'
},
form: new _formBackendValidation2.default(),
loading: false,
tags: {}
};
},
methods: {
onSubmit: function onSubmit() {
var _this = this;
this.form = new _formBackendValidation2.default(_.merge(this.page, { tags: this.tags }));
this.loading = true;
this.form.post(this.getRoute()).then(function (response) {
_this.loading = false;
_this.$message({
type: 'success',
message: response.message
});
_this.$router.push({ name: 'admin.page.page.index' });
}).catch(function (error) {
console.log(error);
_this.loading = false;
_this.$notify.error({
title: 'Error',
message: 'There are some errors in the form.'
});
});
},
onCancel: function onCancel() {
this.$router.push({ name: 'admin.page.page.index' });
},
fetchTemplates: function fetchTemplates() {
var _this2 = this;
_axios2.default.get(route('api.page.page-templates.index')).then(function (response) {
_this2.templates = response.data;
});
},
generateSlug: function generateSlug(event, locale) {
this.page[locale].slug = this.slugify(this.page[locale].title);
},
setTags: function setTags(tags) {
this.tags = tags;
},
fetchPage: function fetchPage() {
var _this3 = this;
this.loading = true;
_axios2.default.post(route('api.page.page.find', { page: this.$route.params.pageId })).then(function (response) {
_this3.loading = false;
_this3.page = response.data.data;
_this3.tags = response.data.data.tags;
}).catch(function (error) {});
},
getRoute: function getRoute() {
if (this.$route.params.pageId !== undefined) {
return route('api.page.page.update', { page: this.$route.params.pageId });
}
return route('api.page.page.store');
}
},
mounted: function mounted() {
this.fetchTemplates();
if (this.$route.params.pageId !== undefined) {
this.fetchPage();
}
}
}; //
//
//
//
......@@ -73357,103 +73482,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
//
//
exports.default = {
mixins: [_Slugify2.default, _TranslationHelper2.default],
props: {
locales: { default: null },
pageTitle: { default: null, String: String }
},
data: function data() {
return {
page: _(this.locales).keys().map(function (locale) {
return [locale, {
title: '',
slug: '',
body: '',
meta_title: '',
meta_description: '',
og_title: '',
og_description: '',
og_type: ''
}];
}).fromPairs().merge({ template: 'default', is_home: 0 }).value(),
templates: {
'index': 'index',
'home': 'home',
'default': 'default'
},
form: new _formBackendValidation2.default(),
loading: false,
tags: {}
};
},
methods: {
onSubmit: function onSubmit() {
var _this = this;
this.form = new _formBackendValidation2.default(_.merge(this.page, { tags: this.tags }));
this.loading = true;
this.form.post(this.getRoute()).then(function (response) {
_this.loading = false;
_this.$message({
type: 'success',
message: response.message
});
_this.$router.push({ name: 'admin.page.page.index' });
}).catch(function (error) {
console.log(error);
_this.loading = false;
_this.$notify.error({
title: 'Error',
message: 'There are some errors in the form.'
});
});
},
onCancel: function onCancel() {
this.$router.push({ name: 'admin.page.page.index' });
},
fetchTemplates: function fetchTemplates() {
var _this2 = this;
_axios2.default.get(route('api.page.page-templates.index')).then(function (response) {
_this2.templates = response.data;
});
},
generateSlug: function generateSlug(event, locale) {
this.page[locale].slug = this.slugify(this.page[locale].title);
},
setTags: function setTags(tags) {
this.tags = tags;
},
fetchPage: function fetchPage() {
var _this3 = this;
this.loading = true;
_axios2.default.post(route('api.page.page.find', { page: this.$route.params.pageId })).then(function (response) {
_this3.loading = false;
_this3.page = response.data.data;
_this3.tags = response.data.data.tags;
}).catch(function (error) {});
},
getRoute: function getRoute() {
if (this.$route.params.pageId !== undefined) {
return route('api.page.page.update', { page: this.$route.params.pageId });
}
return route('api.page.page.store');
}
},
mounted: function mounted() {
this.fetchTemplates();
if (this.$route.params.pageId !== undefined) {
this.fetchPage();
}
}
};
/***/ }),
/* 119 */
/***/ (function(module, exports, __webpack_require__) {
......@@ -74218,7 +74246,24 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
on: {
"input": _vm.setTags
}
})], 1)])])])])], 1)
})], 1)])])])]), _vm._v(" "), _c('button', {
directives: [{
name: "shortkey",
rawName: "v-shortkey",
value: (['b']),
expression: "['b']"
}],
staticStyle: {
"display": "none"
},
on: {
"shortkey": function($event) {
_vm.pushRoute({
name: 'admin.page.page.index'
})
}
}
})], 1)
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
......@@ -75063,5 +75108,32 @@ if (false) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 139 */,
/* 140 */,
/* 141 */
/***/ (function(module, exports, __webpack_require__) {
!function(e,t){if(true)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="../dist/",t(t.s=0)}([function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}var o,i={},a={},u=[],s=[],c=!1;i.install=function(e,t){s=[].concat(n(t&&t.prevent?t.prevent:[])),e.directive("shortkey",{bind:function(e,t,r){var n="string"==typeof t.value?JSON.parse(t.value.replace(/\'/gi,'"')):t.value,o=!0===t.modifiers.persistent,i=!0===t.modifiers.push,s=!0===t.modifiers.avoid,c=!0===t.modifiers.focus,f=!0===t.modifiers.once;if(i&&delete n.push,s)u.push(e);else{var p=n.join("");a[p]={pr:o,ps:i,oc:f,fn:!c,el:r.elm}}},unbind:function(e,t){var r=[];if(r="string"==typeof t.value?JSON.parse(t.value.replace(/\'/gi,'"')):t.value,!0===t.modifiers.push&&delete r.push,r){var n=r.join("");a[n].el===e&&delete a[n]}u=u.filter(function(t){return!t===e})}})},i.decodeKey=function(e){var t="";return("Shift"===e.key||e.shiftKey)&&(t+="shift"),("Control"===e.key||e.ctrlKey)&&(t+="ctrl"),("Meta"===e.key||e.metaKey)&&(t+="meta"),("Alt"===e.key||e.altKey)&&(t+="alt"),"ArrowUp"===e.key&&(t+="arrowup"),"ArrowLeft"===e.key&&(t+="arrowleft"),"ArrowRight"===e.key&&(t+="arrowright"),"ArrowDown"===e.key&&(t+="arrowdown"),"AltGraph"===e.key&&(t+="altgraph"),"Escape"===e.key&&(t+="esc"),"Enter"===e.key&&(t+="enter"),"Tab"===e.key&&(t+="tab"),(e.key&&1===e.key.length||/F\d{1,2}/g.test(e.key))&&(t+=e.key.toLowerCase()),t},i.keyDown=function(e){if(!a[e].oc&&!a[e].ps||a[e].ps&&!c){var t=document.createEvent("HTMLEvents");t.initEvent("shortkey",!0,!0),a[e].el.dispatchEvent(t)}},i.keyUp=function(e){var t=document.createEvent("HTMLEvents");t.initEvent("shortkey",!0,!0),a[e].el.dispatchEvent(t)},function(){document.addEventListener("keydown",function(e){var t=i.decodeKey(e);f(e)&&(e.preventDefault(),e.stopPropagation(),a[t].fn?(i.keyDown(t),c=!0):c||(a[t].el.focus(),c=!0))},!0),document.addEventListener("keyup",function(e){var t=i.decodeKey(e);f(e)&&(e.preventDefault(),e.stopPropagation(),(a[t].oc||a[t].ps)&&i.keyUp(t)),c=!1},!0)}();var f=function(e){var t=i.decodeKey(e),r=u.find(function(e){return e===document.activeElement}),n=p(),o=n.avoidedTypes,s=n.avoidedClasses,c=o.find(function(e){return e===document.activeElement.tagName.toLowerCase()}),f=s.find(function(e){return e==="."+document.activeElement.className.toLowerCase()});return!r&&a[t]&&!c&&!f},p=function(){var e=[],t=[];return s.forEach(function(r){var n=r.indexOf(".");0===n?t.push(r):n>0?(e.push(r.split(".")[0]),t.push("."+r.split(".")[1])):e.push(r)}),{avoidedTypes:e,avoidedClasses:t}};void 0!==e&&e.exports?e.exports=i:void 0!==(o=function(){return i}.call(t,r,t,e))&&(e.exports=o)}])});
//# sourceMappingURL=index.js.map
/***/ }),
/* 142 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
methods: {
pushRoute: function pushRoute(route) {
this.$router.push(route);
}
}
};
/***/ })
/******/ ]);
\ No newline at end of file
......@@ -11,6 +11,7 @@ Vue.use(ElementUI, { locale });
Vue.use(DataTables, { locale });
Vue.use(VueI18n);
Vue.use(VueRouter);
Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] });
Vue.component('ckeditor', require('../../../Modules/Core/Assets/js/components/CkEditor.vue'));
Vue.component('DeleteButton', require('../../../Modules/Core/Assets/js/components/DeleteComponent.vue'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment