@acanto/components-locale-switch
Advanced tools
Comparing version 0.0.3 to 0.0.4
46
index.js
import { $$, forEach, on, getDataAttr } from "@acanto/core-dom"; | ||
import { octoberRequest } from "@acanto/core-october"; | ||
import "./index.scss"; | ||
/** | ||
* October's locale switch component | ||
* TODO: Locale switch component | ||
* | ||
@@ -11,26 +10,21 @@ * @param {string} [rootSelector=".LocaleSwitch:"] | ||
export default function localeSwitch(rootSelector = ".LocaleSwitch:") { | ||
function handleSwitch($root) { | ||
const locale = getDataAttr($root, "locale"); | ||
const request = octoberRequest("onSwitchLocale", { locale }); | ||
$root.classList.add("loading"); | ||
request | ||
.then(({ data }) => { | ||
if (data["X_OCTOBER_REDIRECT"]) { | ||
location.href = data["X_OCTOBER_REDIRECT"]; | ||
} | ||
}) | ||
.catch(() => { | ||
$root.classList.remove("loading"); | ||
}); | ||
} | ||
forEach($$(rootSelector), ($root) => { | ||
on($root, "click", () => { | ||
if (!$root.classList.contains("is-active")) { | ||
handleSwitch($root); | ||
} | ||
}); | ||
}); | ||
// function handleSwitch($root) { | ||
// const locale = getDataAttr($root, "locale"); | ||
// $root.classList.add("loading"); | ||
// request | ||
// .then(({ data }) => { | ||
// location.href = data; | ||
// } | ||
// }) | ||
// .catch(() => { | ||
// $root.classList.remove("loading"); | ||
// }); | ||
// } | ||
// forEach($$(rootSelector), ($root) => { | ||
// on($root, "click", () => { | ||
// if (!$root.classList.contains("is-active")) { | ||
// handleSwitch($root); | ||
// } | ||
// }); | ||
// }); | ||
} |
{ | ||
"name": "@acanto/components-locale-switch", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Acanto <info@acanto.net> (https://acanto.agency/)", | ||
@@ -15,6 +15,5 @@ "license": "ISC", | ||
"dependencies": { | ||
"@acanto/core-dom": "^0.0.3", | ||
"@acanto/core-october": "^0.0.3" | ||
"@acanto/core-dom": "^0.0.3" | ||
}, | ||
"gitHead": "ece5ff7e3930f6925661a62e92b83d42857bdaf3" | ||
"gitHead": "0aa3c21c899ba912381a7116c945bfb4b89ac75f" | ||
} |
2406
1
5
28
- Removed@acanto/core-october@^0.0.3
- Removed@acanto/core-ajax@0.0.3(transitive)
- Removed@acanto/core-forms@0.0.3(transitive)
- Removed@acanto/core-october@0.0.3(transitive)
- Removed@acanto/core-polyfills@0.0.3(transitive)
- Removedatomicjs@4.4.1(transitive)
- Removedes6-promise@4.2.8(transitive)
- Removedloadjs@4.2.0(transitive)