From 584c4cc5d2e3e4b985b1c3f9621c78715d196172 Mon Sep 17 00:00:00 2001 From: bach Date: Wed, 27 Jan 2021 21:21:20 +0100 Subject: [PATCH] updating language switcher links on route change; fixed prev/next blabla article links --- .../custom/materiotheme/assets/dist/main.js | 4 ++-- .../custom/materiotheme/assets/scripts/main.js | 17 ++++++++++++++++- .../vuejs/components/Pages/Article.vue | 6 ++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/web/themes/custom/materiotheme/assets/dist/main.js b/web/themes/custom/materiotheme/assets/dist/main.js index 5e5b3de..27de0f8 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.js +++ b/web/themes/custom/materiotheme/assets/dist/main.js @@ -1327,7 +1327,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n})); /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; -eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _graphqlAxios = __webpack_require__(/*! vuejs/api/graphql-axios */ \"./web/themes/custom/materiotheme/vuejs/api/graphql-axios.js\");\n\nvar _printer = __webpack_require__(/*! graphql/language/printer */ \"./node_modules/graphql/language/printer.js\");\n\nvar _graphqlTag = _interopRequireDefault(__webpack_require__(/*! graphql-tag */ \"./node_modules/graphql-tag/src/index.js\"));\n\nvar _articleFragment = _interopRequireDefault(__webpack_require__(/*! vuejs/api/gql/article.fragment.gql */ \"./web/themes/custom/materiotheme/vuejs/api/gql/article.fragment.gql\"));\n\nvar _Card = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Card */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _wrapRegExp(re, groups) { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _RegExp = _wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = _RegExp.call(this, re, flags); _groups.set(_this, groups || _groups.get(re)); return _this; } _inherits(BabelRegExp, _RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === \"string\") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\\$<([^>]+)>/g, function (_, name) { return \"$\" + groups[name]; })); } else if (typeof substitution === \"function\") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = []; args.push.apply(args, arguments); if (_typeof(args[args.length - 1]) !== \"object\") { args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _templateObject() {\n var data = _taggedTemplateLiteral([\"{\\n route(path: \\\"\", \"\\\", lang: \\\"\", \"\\\") {\\n ...ArticleFields\\n }\\n }\\n \", \"\\n \"]);\n\n _templateObject = function _templateObject() {\n return data;\n };\n\n return data;\n}\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"Article\",\n router: _route.default,\n store: _store.default,\n props: ['item'],\n data: function data() {\n return {\n index: -1,\n prevnext: {},\n nid: null,\n path: null,\n article: {},\n image_accroche: null,\n lightbox_items: null,\n loading: true,\n lightbox_index: null\n };\n },\n metaInfo: function metaInfo() {\n return {\n title: this.article.title\n };\n },\n computed: _objectSpread({}, (0, _vuex.mapState)({\n items: function items(state) {\n return state.Blabla.items;\n }\n })),\n created: function created() {\n this.getArticle();\n },\n methods: _objectSpread(_objectSpread({}, (0, _vuex.mapActions)({\n getItems: 'Blabla/getItems',\n getItemIndex: 'Blabla/getItemIndex',\n getPrevNextItems: 'Blabla/getPrevNextItems'\n })), {}, {\n getArticle: function getArticle() {\n console.log(this.$route); // get the article uuid\n // if(this.$route.query.nid){\n // // we come from internal link with vuejs\n // // directly record uuid\n // this.nid = this.$route.query.nid\n //\n // }else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){\n // // we landed in an internal page\n // // get the uuid from drupalDeclouped, provided by materio_decoupled.module\n // this.nid = drupalDecoupled.entity_id\n // }\n\n if (this.$route.path) {\n // we come from internal link with vuejs\n this.path = this.$route.path;\n } else {\n // we landed in an internal page\n this.path = window.location.pathname;\n }\n\n if (this.path) {\n this.loadArticle();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n getIndex: function getIndex() {\n var _this = this;\n\n console.log(\"Article getIndex article.id:\", this.article.id);\n this.getItemIndex(this.article.id).then(function (index) {\n _this.index = index;\n console.log('article index', index, _this);\n\n _this.getPrevNextItems(index).then(function (pn) {\n _this.prevnext = pn;\n });\n });\n },\n loadArticle: function loadArticle() {\n var _this2 = this;\n\n console.log('loadArticle');\n this.loading = true;\n var ast = (0, _graphqlTag.default)(_templateObject(), this.path, drupalDecoupled.lang_code, _articleFragment.default);\n\n _graphqlAxios.MGQ.post('', {\n query: (0, _printer.print)(ast)\n }).then(function (_ref) {\n var route = _ref.data.data.route;\n console.log('loadArticle', route);\n\n _this2.parseDataGQL(route);\n }).catch(function (error) {\n console.warn('Issue with loadArticle', error);\n Promise.reject(error);\n });\n },\n parseDataGQL: function parseDataGQL(article) {\n var _this3 = this;\n\n console.log('parseDataGQL article', article);\n this.article = article; // get the prev next items\n\n if (!this.items.length) {\n // if items list not yet loaded preload them\n this.getItems().then(function () {\n // then get the index\n _this3.getIndex();\n });\n } else {\n // or directly get the index\n this.getIndex();\n }\n\n this.image_accroche = article.images[0];\n this.lightbox_items = []; // fill the lightbox\n\n for (var i = 0; i < article.images.length; i++) {\n article.images[i].thumb = article.images[i].style_articlecardmedium.url;\n this.lightbox_items.push(article.images[i]);\n } // parse embeded videos pushing it in lightbox\n\n\n for (var i = 0; i < article.videos.length; i++) {\n var videoUrl = article.videos[i].url;\n\n var provider_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/(www\\.)?(youtube|vimeo)\\.com\\/.+/, {\n provider: 2\n });\n\n var match = provider_regex.exec(videoUrl); // console.log('provider', match.groups.provider);\n\n var video_id = null;\n var video_thumb = null;\n\n switch (match.groups.provider) {\n case 'vimeo':\n var vimeo_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/vimeo\\.com\\/([0-9]+)/, {\n id: 1\n });\n\n video_id = vimeo_regex.exec(videoUrl).groups.id || null; // TODO: get the vimeo thumb https://coderwall.com/p/fdrdmg/get-a-thumbnail-from-a-vimeo-video\n\n video_thumb = \"http://blogpeda.ac-poitiers.fr/ent-lyc/files/2015/06/Vimeo_icon_block.png\";\n break;\n\n case 'youtube':\n var youtube_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/(www\\.)?youtube\\.com\\/watch\\?v=(.+)/, {\n id: 2\n });\n\n video_id = youtube_regex.exec(videoUrl).groups.id || null;\n video_thumb = \"http://img.youtube.com/vi/\" + video_id + \"/0.jpg\";\n break;\n } // console.log('video_id', video_id);\n\n\n this.lightbox_items.push({\n url: videoUrl,\n title: \"\",\n description: \"\",\n thumb: video_thumb\n });\n } // console.log('this.content.lightbox_items', this.lightbox_items);\n // update main page title\n\n\n this.$store.commit('Common/setPagetitle', article.title);\n this.loading = false;\n },\n onPrevNext: function onPrevNext(a) {\n // console.log('clicked on next', this.prevnext.next);\n var alias = a.replace(/^.?\\/blabla\\//g, '');\n this.$router.push({\n name: \"article\",\n params: {\n alias: alias\n }\n });\n },\n setLightboxIndex: function setLightboxIndex(index) {\n this.lightbox_index = index;\n }\n }),\n components: {\n Card: _Card.default\n },\n watch: {\n '$route': function $route(to, from) {\n console.log('route change');\n this.getArticle();\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options"); +eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _graphqlAxios = __webpack_require__(/*! vuejs/api/graphql-axios */ \"./web/themes/custom/materiotheme/vuejs/api/graphql-axios.js\");\n\nvar _printer = __webpack_require__(/*! graphql/language/printer */ \"./node_modules/graphql/language/printer.js\");\n\nvar _graphqlTag = _interopRequireDefault(__webpack_require__(/*! graphql-tag */ \"./node_modules/graphql-tag/src/index.js\"));\n\nvar _articleFragment = _interopRequireDefault(__webpack_require__(/*! vuejs/api/gql/article.fragment.gql */ \"./web/themes/custom/materiotheme/vuejs/api/gql/article.fragment.gql\"));\n\nvar _Card = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Card */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _wrapRegExp(re, groups) { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _RegExp = _wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = _RegExp.call(this, re, flags); _groups.set(_this, groups || _groups.get(re)); return _this; } _inherits(BabelRegExp, _RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === \"string\") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\\$<([^>]+)>/g, function (_, name) { return \"$\" + groups[name]; })); } else if (typeof substitution === \"function\") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = []; args.push.apply(args, arguments); if (_typeof(args[args.length - 1]) !== \"object\") { args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _templateObject() {\n var data = _taggedTemplateLiteral([\"{\\n route(path: \\\"\", \"\\\", lang: \\\"\", \"\\\") {\\n ...ArticleFields\\n }\\n }\\n \", \"\\n \"]);\n\n _templateObject = function _templateObject() {\n return data;\n };\n\n return data;\n}\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"Article\",\n router: _route.default,\n store: _store.default,\n props: ['item'],\n data: function data() {\n return {\n index: -1,\n prevnext: {},\n nid: null,\n path: null,\n article: {},\n image_accroche: null,\n lightbox_items: null,\n loading: true,\n lightbox_index: null\n };\n },\n metaInfo: function metaInfo() {\n return {\n title: this.article.title\n };\n },\n computed: _objectSpread({}, (0, _vuex.mapState)({\n items: function items(state) {\n return state.Blabla.items;\n }\n })),\n created: function created() {\n this.getArticle();\n },\n methods: _objectSpread(_objectSpread({}, (0, _vuex.mapActions)({\n getItems: 'Blabla/getItems',\n getItemIndex: 'Blabla/getItemIndex',\n getPrevNextItems: 'Blabla/getPrevNextItems'\n })), {}, {\n getArticle: function getArticle() {\n console.log(this.$route); // get the article uuid\n // if(this.$route.query.nid){\n // // we come from internal link with vuejs\n // // directly record uuid\n // this.nid = this.$route.query.nid\n //\n // }else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){\n // // we landed in an internal page\n // // get the uuid from drupalDeclouped, provided by materio_decoupled.module\n // this.nid = drupalDecoupled.entity_id\n // }\n\n if (this.$route.path) {\n // we come from internal link with vuejs\n this.path = this.$route.path;\n } else {\n // we landed in an internal page\n this.path = window.location.pathname;\n }\n\n if (this.path) {\n this.loadArticle();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n getIndex: function getIndex() {\n var _this = this;\n\n console.log(\"Article getIndex article.id:\", this.article.id);\n this.getItemIndex(this.article.id).then(function (index) {\n _this.index = index;\n console.log('article index', index, _this);\n\n _this.getPrevNextItems(index).then(function (pn) {\n _this.prevnext = pn;\n });\n });\n },\n loadArticle: function loadArticle() {\n var _this2 = this;\n\n console.log('loadArticle');\n this.loading = true;\n var ast = (0, _graphqlTag.default)(_templateObject(), this.path, drupalDecoupled.lang_code, _articleFragment.default);\n\n _graphqlAxios.MGQ.post('', {\n query: (0, _printer.print)(ast)\n }).then(function (_ref) {\n var route = _ref.data.data.route;\n console.log('loadArticle', route);\n\n _this2.parseDataGQL(route);\n }).catch(function (error) {\n console.warn('Issue with loadArticle', error);\n Promise.reject(error);\n });\n },\n parseDataGQL: function parseDataGQL(article) {\n var _this3 = this;\n\n console.log('parseDataGQL article', article);\n this.article = article; // get the prev next items\n\n if (!this.items.length) {\n // if items list not yet loaded preload them\n this.getItems().then(function () {\n // then get the index\n _this3.getIndex();\n });\n } else {\n // or directly get the index\n this.getIndex();\n }\n\n this.image_accroche = article.images[0];\n this.lightbox_items = []; // fill the lightbox\n\n for (var i = 0; i < article.images.length; i++) {\n article.images[i].thumb = article.images[i].style_articlecardmedium.url;\n this.lightbox_items.push(article.images[i]);\n } // parse embeded videos pushing it in lightbox\n\n\n for (var i = 0; i < article.videos.length; i++) {\n var videoUrl = article.videos[i].url;\n\n var provider_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/(www\\.)?(youtube|vimeo)\\.com\\/.+/, {\n provider: 2\n });\n\n var match = provider_regex.exec(videoUrl); // console.log('provider', match.groups.provider);\n\n var video_id = null;\n var video_thumb = null;\n\n switch (match.groups.provider) {\n case 'vimeo':\n var vimeo_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/vimeo\\.com\\/([0-9]+)/, {\n id: 1\n });\n\n video_id = vimeo_regex.exec(videoUrl).groups.id || null; // TODO: get the vimeo thumb https://coderwall.com/p/fdrdmg/get-a-thumbnail-from-a-vimeo-video\n\n video_thumb = \"http://blogpeda.ac-poitiers.fr/ent-lyc/files/2015/06/Vimeo_icon_block.png\";\n break;\n\n case 'youtube':\n var youtube_regex = /*#__PURE__*/_wrapRegExp(/https:\\/\\/(www\\.)?youtube\\.com\\/watch\\?v=(.+)/, {\n id: 2\n });\n\n video_id = youtube_regex.exec(videoUrl).groups.id || null;\n video_thumb = \"http://img.youtube.com/vi/\" + video_id + \"/0.jpg\";\n break;\n } // console.log('video_id', video_id);\n\n\n this.lightbox_items.push({\n url: videoUrl,\n title: \"\",\n description: \"\",\n thumb: video_thumb\n });\n } // console.log('this.content.lightbox_items', this.lightbox_items);\n // update main page title\n\n\n this.$store.commit('Common/setPagetitle', article.title);\n this.loading = false;\n },\n onPrevNext: function onPrevNext(a) {\n console.log('clicked on prev/next; a', a);\n var alias = a.replace(/^\\/\\D{2,3}\\/blabla\\//g, '');\n console.log('alias', alias);\n this.$router.push({\n name: \"article\",\n params: {\n alias: alias\n }\n });\n },\n setLightboxIndex: function setLightboxIndex(index) {\n this.lightbox_index = index;\n }\n }),\n components: {\n Card: _Card.default\n },\n watch: {\n '$route': function $route(to, from) {\n console.log('route change');\n this.getArticle();\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options"); /***/ }), @@ -17984,7 +17984,7 @@ eval("module.exports = JSON.parse(\"{\\\"default\\\":{\\\"Closing in !seconds se \***************************************************************/ /*! unknown exports (runtime-defined) */ /*! runtime requirements: __webpack_require__ */ -eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.js\"));\n\nvar _vueInfiniteLoading = _interopRequireDefault(__webpack_require__(/*! vue-infinite-loading */ \"./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js\"));\n\nvar _vueCoolLightbox = _interopRequireDefault(__webpack_require__(/*! vue-cool-lightbox */ \"./node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.esm.js\"));\n\nvar _vueJsModal = _interopRequireDefault(__webpack_require__(/*! vue-js-modal */ \"./node_modules/vue-js-modal/dist/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _i18n = __webpack_require__(/*! vuejs/i18n */ \"./web/themes/custom/materiotheme/vuejs/i18n/index.js\");\n\nvar _vueMeta = _interopRequireDefault(__webpack_require__(/*! vue-meta */ \"./node_modules/vue-meta/dist/vue-meta.esm.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/UserBlock.vue\"));\n\nvar _MainContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/MainContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/MainContent.vue\"));\n\nvar _SearchBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/SearchBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/SearchBlock.vue\"));\n\nvar _LeftContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/LeftContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/LeftContent.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\n__webpack_require__(/*! vue-cool-lightbox/dist/vue-cool-lightbox.min.css */ \"./node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.min.css\");\n\n__webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n\n__webpack_require__(/*! theme/assets/styles/print.scss */ \"./web/themes/custom/materiotheme/assets/styles/print.scss\");\n\nvar _vueSimpleAccordion = _interopRequireDefault(__webpack_require__(/*! vue-simple-accordion */ \"./node_modules/vue-simple-accordion/dist/vue-simple-accordion.common.js\"));\n\n__webpack_require__(/*! vue-simple-accordion/dist/vue-simple-accordion.css */ \"./node_modules/vue-simple-accordion/dist/vue-simple-accordion.css\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n_vue.default.use(_vueInfiniteLoading.default, {\n props: {\n spinner: 'spiral' // slots.noMore: ''\n\n } // system: {\n // throttleLimit: 50,\n // /* other settings need to configure */\n // }\n\n}); // import vueVimeoPlayer from 'vue-vimeo-player'\n// Vue.use(vueVimeoPlayer)\n// import VueYouTubeEmbed from 'vue-youtube-embed'\n// Vue.use(VueYouTubeEmbed)\n\n\n_vue.default.use(_vueCoolLightbox.default);\n\n_vue.default.use(_vueJsModal.default);\n\n_vue.default.use(_vueMeta.default);\n\n_vue.default.use(_vueSimpleAccordion.default, {// ... Options go here\n});\n\n(function (Drupal, drupalSettings, drupalDecoupled) {\n var MaterioTheme = function MaterioTheme() {\n var _v_sitebranding_block, _v_user_block, _v_header_menu, _v_pagetitle_block, _v_search_block, _v_main_content, _v_left_content;\n\n var _is_front = drupalSettings.path.isFront;\n console.log('drupalSettings', drupalSettings); // let _I18n\n // ___ _ _\n // |_ _|_ _ (_) |_\n // | || ' \\| | _|\n // |___|_||_|_|\\__|\n\n function init() {\n console.log('MaterioTheme init()');\n initVues();\n }\n\n function checkNoVuePages() {\n // return drupalDecoupled.sys_path != '/cart'\n // && drupalDecoupled.sys_path.indexOf('checkout') != 1;\n if (drupalDecoupled.route_name.indexOf('commerce') == -1 && drupalDecoupled.route_name.indexOf('flagging_collection') == -1 && drupalDecoupled.route_name.indexOf('user') == -1) {\n return false;\n } else {\n return true;\n }\n }\n\n function initVues() {\n // only launch views if we are not in commerce pages\n if (!checkNoVuePages()) {\n initVi18n();\n initVStore();\n initVRouter();\n initVSiteBrandingBlock();\n initVPagetitleBlock();\n initVHeaderMenu();\n initVMainContent();\n initVSearchBlock();\n initVLeftContent();\n }\n\n initVUserBlock();\n }\n\n function initVi18n() {\n // i18n.locale = drupalDecoupled.lang_code\n // console.log('i18n.messages', i18n.messages)\n (0, _i18n.loadLanguageAsync)(drupalDecoupled.lang_code).then(function () {\n console.log('main.js language loaded');\n });\n }\n\n function initVStore() {\n _store.default.dispatch('Showrooms/getItems');\n }\n\n function initVRouter() {\n // we need this to update the title and body classes while using history nav\n _route.default.beforeEach(function (to, from, next) {\n var _document$querySelect, _document$querySelect2;\n\n // console.log('router beforeEach to ', to);\n // commit new title to store\n var title = null;\n\n switch (to.name) {\n case 'home':\n title = null;\n break;\n\n case 'article':\n title = false;\n break;\n\n default:\n title = to.name;\n }\n\n if (title !== false) {\n _store.default.commit('Common/setPagetitle', title);\n } // remove all path related body classes\n\n\n var body_classes = document.querySelector('body').classList;\n var classes_to_rm = [];\n\n for (var i = 0; i < body_classes.length; i++) {\n if (body_classes[i].startsWith('path-')) {\n classes_to_rm.push(body_classes[i]);\n }\n }\n\n (_document$querySelect = document.querySelector('body').classList).remove.apply(_document$querySelect, classes_to_rm); // add new path classes to body\n\n\n var classes = [];\n\n if (to.path == '/') {\n classes.push('path-home');\n } else {\n var path_parts = to.path.replace(/^\\//, '') // remove language relative prefix from path classes (fr, en, etc)\n .replace(/^\\D{2,3}\\//, '').split('/');\n\n for (var i = 0; i < path_parts.length; i++) {\n if (i == 0) {\n var c = 'path-' + path_parts[i];\n } else if (path_parts[i] !== '') {\n var c = classes[i - 1] + '-' + path_parts[i];\n }\n\n classes.push(c);\n }\n }\n\n (_document$querySelect2 = document.querySelector('body').classList).add.apply(_document$querySelect2, classes); // trigger router\n\n\n next();\n });\n }\n\n function initVSiteBrandingBlock() {\n _v_sitebranding_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: '#block-sitebranding',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on logo event\", event);\n var href = event.target.getAttribute('href'); // console.log(\"Clicked on logo href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', null)\n }\n }\n });\n }\n\n function initVPagetitleBlock() {\n var $blk = document.querySelector('#block-pagetitle');\n var $h2 = $blk.querySelector('h2'); // get the loaded pagetitle\n\n var title = $h2.innerText; // if not front recorde the loaded pagetitle in store\n\n if (!_is_front) {\n _store.default.commit('Common/setPagetitle', title);\n } // replace in template the pagetitle by vue binding\n\n\n $h2.innerText = '{{ pagetitle }}'; // create the vue\n\n _v_pagetitle_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: $blk,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n pagetitle: function pagetitle(state) {\n return state.Common.pagetitle;\n }\n }))\n });\n }\n\n function initVUserBlock() {\n var mount_point = drupalSettings.user.uid !== 0 ? 'block-userblock' : 'block-userlogin';\n var props = {\n title: '',\n loginblock: ''\n };\n var $block;\n\n switch (mount_point) {\n case 'block-userlogin':\n $block = document.getElementById(mount_point);\n console.log('initVUserBlock login form html', $block);\n props.loginblock = $block.outerHTML.trim();\n break;\n\n case 'block-userblock':\n default:\n break;\n }\n\n _v_user_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n // computed: {\n // ...mapState({\n // isloggedin: state => state.User.isloggedin\n // })\n // },\n created: function created() {\n // if already loggedin, call store.user to get the user infos\n if (drupalSettings.user.uid !== 0) {\n this.$store.commit('User/setUid', drupalSettings.user.uid);\n this.$store.dispatch('User/getUser');\n }\n },\n render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount('#' + mount_point); // console.log('initVUserBlock', _v_user_block);\n }\n\n function initVHeaderMenu() {\n // console.log('initVHeaderMenu');\n // adding vuejs attributes has it wont work on twig template (see menu--header.html.twig)\n // not working : String contains an invalid character\n // document.querySelectorAll(`#block-header a`).forEach(link => {\n // console.log(link);\n // link.setAttribute('@click.prevent', 'onclick')\n // });\n _v_header_menu = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: '#block-header',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on header menu link\", event);\n var href = event.target.getAttribute('href'); // let title = event.target.innerText;\n // console.log(\"Clicked on header menu link : href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', title)\n }\n }\n });\n }\n\n function initVMainContent() {\n var id = 'main-content';\n var $main_content = document.querySelector('#' + id); // console.log('main-content', $main_content);\n\n var main_html = $main_content.innerHTML;\n _v_main_content = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n metaInfo: {\n // if no subcomponents specify a metaInfo.title, this title will be used\n title: \"materiO'\",\n // all titles will be injected into this template\n titleTemplate: \"%s | materiO'\"\n },\n render: function render(h) {\n return h(_MainContent.default, {\n props: {\n id: id,\n html: main_html,\n isfront: drupalSettings.path.isFront\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVSearchBlock() {\n // console.log('initVSearchBlock');\n var id = 'block-materiosapisearchblock';\n var $search_block = document.getElementById(id);\n var formhtml = null;\n\n if ($search_block) {\n // get the search form html to pass it as template to the vue\n // we gain display speed vs async downloaded data\n formhtml = $search_block.innerHTML;\n } else {\n // else create the empty block to fill it later with async data\n $search_block = document.createElement('div');\n $search_block.setAttribute('id', id); // TODO: get region by REST\n\n var $region = document.getElementById('header-bottom');\n $region.appendChild($search_block);\n } // in any case create the vue\n\n\n _v_search_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n render: function render(h) {\n return h(_SearchBlock.default, {\n props: {\n blockid: id,\n formhtml: formhtml\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVLeftContent() {\n var id = 'content-left';\n var $leftContent = document.getElementById(id); // in any case create the vue\n\n _v_left_content = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n render: function render(h) {\n return h(_LeftContent.default, {\n props: {\n id: id\n }\n });\n }\n }).$mount('#' + id);\n }\n\n init();\n }; // end MaterioTheme()\n\n\n var materiotheme = new MaterioTheme();\n})(Drupal, drupalSettings, drupalDecoupled);\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/assets/scripts/main.js?"); +eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.js\"));\n\nvar _vueInfiniteLoading = _interopRequireDefault(__webpack_require__(/*! vue-infinite-loading */ \"./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js\"));\n\nvar _vueCoolLightbox = _interopRequireDefault(__webpack_require__(/*! vue-cool-lightbox */ \"./node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.esm.js\"));\n\nvar _vueJsModal = _interopRequireDefault(__webpack_require__(/*! vue-js-modal */ \"./node_modules/vue-js-modal/dist/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _i18n = __webpack_require__(/*! vuejs/i18n */ \"./web/themes/custom/materiotheme/vuejs/i18n/index.js\");\n\nvar _vueMeta = _interopRequireDefault(__webpack_require__(/*! vue-meta */ \"./node_modules/vue-meta/dist/vue-meta.esm.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/UserBlock.vue\"));\n\nvar _MainContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/MainContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/MainContent.vue\"));\n\nvar _SearchBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/SearchBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/SearchBlock.vue\"));\n\nvar _LeftContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/LeftContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/LeftContent.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\n__webpack_require__(/*! vue-cool-lightbox/dist/vue-cool-lightbox.min.css */ \"./node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.min.css\");\n\n__webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n\n__webpack_require__(/*! theme/assets/styles/print.scss */ \"./web/themes/custom/materiotheme/assets/styles/print.scss\");\n\nvar _vueSimpleAccordion = _interopRequireDefault(__webpack_require__(/*! vue-simple-accordion */ \"./node_modules/vue-simple-accordion/dist/vue-simple-accordion.common.js\"));\n\n__webpack_require__(/*! vue-simple-accordion/dist/vue-simple-accordion.css */ \"./node_modules/vue-simple-accordion/dist/vue-simple-accordion.css\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n_vue.default.use(_vueInfiniteLoading.default, {\n props: {\n spinner: 'spiral' // slots.noMore: ''\n\n } // system: {\n // throttleLimit: 50,\n // /* other settings need to configure */\n // }\n\n}); // import vueVimeoPlayer from 'vue-vimeo-player'\n// Vue.use(vueVimeoPlayer)\n// import VueYouTubeEmbed from 'vue-youtube-embed'\n// Vue.use(VueYouTubeEmbed)\n\n\n_vue.default.use(_vueCoolLightbox.default);\n\n_vue.default.use(_vueJsModal.default);\n\n_vue.default.use(_vueMeta.default);\n\n_vue.default.use(_vueSimpleAccordion.default, {// ... Options go here\n});\n\n(function (Drupal, drupalSettings, drupalDecoupled) {\n var MaterioTheme = function MaterioTheme() {\n var _v_sitebranding_block, _v_user_block, _v_header_menu, _v_pagetitle_block, _v_search_block, _v_main_content, _v_left_content;\n\n var _is_front = drupalSettings.path.isFront;\n console.log('drupalSettings', drupalSettings); // let _I18n\n // ___ _ _\n // |_ _|_ _ (_) |_\n // | || ' \\| | _|\n // |___|_||_|_|\\__|\n\n function init() {\n console.log('MaterioTheme init()');\n initVues();\n }\n\n function checkNoVuePages() {\n // return drupalDecoupled.sys_path != '/cart'\n // && drupalDecoupled.sys_path.indexOf('checkout') != 1;\n if (drupalDecoupled.route_name.indexOf('commerce') == -1 && drupalDecoupled.route_name.indexOf('flagging_collection') == -1 && drupalDecoupled.route_name.indexOf('user') == -1) {\n return false;\n } else {\n return true;\n }\n }\n\n function initVues() {\n // only launch views if we are not in commerce pages\n if (!checkNoVuePages()) {\n initVi18n();\n initVStore();\n initVRouter();\n initVSiteBrandingBlock();\n initVPagetitleBlock();\n initVHeaderMenu();\n initVMainContent();\n initVSearchBlock();\n initVLeftContent();\n }\n\n initVUserBlock();\n }\n\n function initVi18n() {\n // i18n.locale = drupalDecoupled.lang_code\n // console.log('i18n.messages', i18n.messages)\n (0, _i18n.loadLanguageAsync)(drupalDecoupled.lang_code).then(function () {\n console.log('main.js language loaded');\n });\n }\n\n function initVStore() {\n _store.default.dispatch('Showrooms/getItems');\n }\n\n function initVRouter() {\n // we need this to update the title and body classes while using history nav\n _route.default.beforeEach(function (to, from, next) {\n var _document$querySelect, _document$querySelect2;\n\n // console.log('router beforeEach to ', to);\n // commit new title to store\n var title = null;\n\n switch (to.name) {\n case 'home':\n title = null;\n break;\n\n case 'article':\n title = false;\n break;\n\n default:\n title = to.name;\n }\n\n if (title !== false) {\n _store.default.commit('Common/setPagetitle', title);\n } // remove all path related body classes\n\n\n var body_classes = document.querySelector('body').classList;\n var classes_to_rm = [];\n\n for (var i = 0; i < body_classes.length; i++) {\n if (body_classes[i].startsWith('path-')) {\n classes_to_rm.push(body_classes[i]);\n }\n }\n\n (_document$querySelect = document.querySelector('body').classList).remove.apply(_document$querySelect, classes_to_rm); // add new path classes to body\n\n\n var classes = [];\n\n if (to.path == '/') {\n classes.push('path-home');\n } else {\n var path_parts = to.path.replace(/^\\//, '') // remove language relative prefix from path classes (fr, en, etc)\n .replace(/^\\D{2,3}\\//, '').split('/');\n\n for (var i = 0; i < path_parts.length; i++) {\n if (i == 0) {\n var c = 'path-' + path_parts[i];\n } else if (path_parts[i] !== '') {\n var c = classes[i - 1] + '-' + path_parts[i];\n }\n\n classes.push(c);\n }\n }\n\n (_document$querySelect2 = document.querySelector('body').classList).add.apply(_document$querySelect2, classes); // update block language selection\n\n\n var links = document.querySelectorAll('#block-languageswitcher a.language-link');\n var path = to.path.replace(/^\\/\\D{2,3}\\//, '') // remove language relative prefix from path classes (fr, en, etc)\n .replace(/^\\/\\D{2,3}$/, '');\n\n if (path !== '') {\n path = '/' + path;\n }\n\n links.forEach(function (link, i) {\n console.log(\"language link\", path, link);\n link.setAttribute('href', \"/\".concat(link.getAttribute('hreflang')).concat(path));\n }); // trigger router\n\n next();\n });\n }\n\n function initVSiteBrandingBlock() {\n _v_sitebranding_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: '#block-sitebranding',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on logo event\", event);\n var href = event.target.getAttribute('href'); // console.log(\"Clicked on logo href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', null)\n }\n }\n });\n }\n\n function initVPagetitleBlock() {\n var $blk = document.querySelector('#block-pagetitle');\n var $h2 = $blk.querySelector('h2'); // get the loaded pagetitle\n\n var title = $h2.innerText; // if not front recorde the loaded pagetitle in store\n\n if (!_is_front) {\n _store.default.commit('Common/setPagetitle', title);\n } // replace in template the pagetitle by vue binding\n\n\n $h2.innerText = '{{ pagetitle }}'; // create the vue\n\n _v_pagetitle_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: $blk,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n pagetitle: function pagetitle(state) {\n return state.Common.pagetitle;\n }\n }))\n });\n }\n\n function initVUserBlock() {\n var mount_point = drupalSettings.user.uid !== 0 ? 'block-userblock' : 'block-userlogin';\n var props = {\n title: '',\n loginblock: ''\n };\n var $block;\n\n switch (mount_point) {\n case 'block-userlogin':\n $block = document.getElementById(mount_point);\n console.log('initVUserBlock login form html', $block);\n props.loginblock = $block.outerHTML.trim();\n break;\n\n case 'block-userblock':\n default:\n break;\n }\n\n _v_user_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n // computed: {\n // ...mapState({\n // isloggedin: state => state.User.isloggedin\n // })\n // },\n created: function created() {\n // if already loggedin, call store.user to get the user infos\n if (drupalSettings.user.uid !== 0) {\n this.$store.commit('User/setUid', drupalSettings.user.uid);\n this.$store.dispatch('User/getUser');\n }\n },\n render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount('#' + mount_point); // console.log('initVUserBlock', _v_user_block);\n }\n\n function initVHeaderMenu() {\n // console.log('initVHeaderMenu');\n // adding vuejs attributes has it wont work on twig template (see menu--header.html.twig)\n // not working : String contains an invalid character\n // document.querySelectorAll(`#block-header a`).forEach(link => {\n // console.log(link);\n // link.setAttribute('@click.prevent', 'onclick')\n // });\n _v_header_menu = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n router: _route.default,\n el: '#block-header',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on header menu link\", event);\n var href = event.target.getAttribute('href'); // let title = event.target.innerText;\n // console.log(\"Clicked on header menu link : href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', title)\n }\n }\n });\n }\n\n function initVMainContent() {\n var id = 'main-content';\n var $main_content = document.querySelector('#' + id); // console.log('main-content', $main_content);\n\n var main_html = $main_content.innerHTML;\n _v_main_content = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n metaInfo: {\n // if no subcomponents specify a metaInfo.title, this title will be used\n title: \"materiO'\",\n // all titles will be injected into this template\n titleTemplate: \"%s | materiO'\"\n },\n render: function render(h) {\n return h(_MainContent.default, {\n props: {\n id: id,\n html: main_html,\n isfront: drupalSettings.path.isFront\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVSearchBlock() {\n // console.log('initVSearchBlock');\n var id = 'block-materiosapisearchblock';\n var $search_block = document.getElementById(id);\n var formhtml = null;\n\n if ($search_block) {\n // get the search form html to pass it as template to the vue\n // we gain display speed vs async downloaded data\n formhtml = $search_block.innerHTML;\n } else {\n // else create the empty block to fill it later with async data\n $search_block = document.createElement('div');\n $search_block.setAttribute('id', id); // TODO: get region by REST\n\n var $region = document.getElementById('header-bottom');\n $region.appendChild($search_block);\n } // in any case create the vue\n\n\n _v_search_block = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n render: function render(h) {\n return h(_SearchBlock.default, {\n props: {\n blockid: id,\n formhtml: formhtml\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVLeftContent() {\n var id = 'content-left';\n var $leftContent = document.getElementById(id); // in any case create the vue\n\n _v_left_content = new _vue.default({\n store: _store.default,\n i18n: _i18n.i18n,\n render: function render(h) {\n return h(_LeftContent.default, {\n props: {\n id: id\n }\n });\n }\n }).$mount('#' + id);\n }\n\n init();\n }; // end MaterioTheme()\n\n\n var materiotheme = new MaterioTheme();\n})(Drupal, drupalSettings, drupalDecoupled);\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/assets/scripts/main.js?"); })(); /******/ })() diff --git a/web/themes/custom/materiotheme/assets/scripts/main.js b/web/themes/custom/materiotheme/assets/scripts/main.js index f141a2a..82716f2 100644 --- a/web/themes/custom/materiotheme/assets/scripts/main.js +++ b/web/themes/custom/materiotheme/assets/scripts/main.js @@ -103,7 +103,6 @@ Vue.use(VueSimpleAccordion, { function initVi18n () { // i18n.locale = drupalDecoupled.lang_code // console.log('i18n.messages', i18n.messages) - loadLanguageAsync(drupalDecoupled.lang_code) .then(() => { console.log('main.js language loaded') @@ -164,6 +163,22 @@ Vue.use(VueSimpleAccordion, { } document.querySelector('body').classList.add(...classes) + // update block language selection + let links = document.querySelectorAll('#block-languageswitcher a.language-link') + let path = to.path.replace(/^\/\D{2,3}\//, '') + // remove language relative prefix from path classes (fr, en, etc) + .replace(/^\/\D{2,3}$/, '') + + if(path !== ''){ + path = '/'+path + } + + links.forEach((link, i) => { + console.log("language link",path , link) + link.setAttribute('href', `/${link.getAttribute('hreflang')}${path}`) + }); + + // trigger router next() }) diff --git a/web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue b/web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue index 3f8cf37..f1670c2 100644 --- a/web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue +++ b/web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue @@ -295,8 +295,10 @@ export default { this.loading = false; }, onPrevNext(a){ - // console.log('clicked on next', this.prevnext.next); - let alias = a.replace(/^.?\/blabla\//g, '') + console.log('clicked on prev/next; a', a); + let alias = a.replace(/^\/\D{2,3}\/blabla\//g, '') + console.log('alias', alias); + this.$router.push({ name:`article`, params: { alias:alias }