Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script(type='text/javascript').
- var Index = 1;
- showtab(Index);
- function tab(n) {
- showtab(Index = n);
- }
- function showtab(n) {
- var i;
- var tabs = document.getElementsByClassName("tab");
- var men = document.getElementsByClassName("men");
- if (n > tabs.length) {Index = 1}
- if (n < 1) {Index = tabs.length}
- for (i = 0; i < tabs.length; i++) {
- tabs[i].className = tabs[i].className.replace(" actv", "");
- men[i].className = men[i].className.replace(" bg", "");
- }
- tabs[Index-1].className += " actv";
- men[Index-1].className += " bg";
- }
- script.
- var x, i, j, selElmnt, a, b, c;
- x = document.getElementsByClassName("custom-select");
- selElmnt = x[0].getElementsByTagName("select")[0];
- a = document.createElement("DIV");
- a.setAttribute("class", "select-selected");
- a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
- x[0].appendChild(a);
- b = document.createElement("DIV");
- b.setAttribute("class", "select-items select-hide");
- for (j = 1; j < selElmnt.length; j++) {
- c = document.createElement("DIV");
- c.innerHTML = selElmnt.options[j].innerHTML;
- c.addEventListener("click", function(e) {
- var y, i, k, s, h;
- s = this.parentNode.parentNode.getElementsByTagName("select")[0];
- cities = document.getElementById("city");
- h = this.parentNode.previousSibling;
- for (i = 0; i < s.length; i++) {
- if (s.options[i].innerHTML == this.innerHTML) {
- s.selectedIndex = i;
- h.innerHTML = this.innerHTML;
- y = this.parentNode.getElementsByClassName("same-as-selected");
- for (k = 0; k < y.length; k++) {
- y[k].removeAttribute("class");
- }
- this.setAttribute("class", "same-as-selected");
- break;
- }
- }
- h.click();
- });
- b.appendChild(c);
- }
- x[0].appendChild(b);
- a.addEventListener("click", function(e) {
- e.stopPropagation();
- closeAllSelect(this);
- this.nextSibling.classList.toggle("select-hide");
- this.classList.toggle("select-arrow-active");
- });
- function closeAllSelect(elmnt) {
- var x, y, i, arrNo = [];
- x = document.getElementsByClassName("select-items");
- y = document.getElementsByClassName("select-selected");
- for (i = 0; i < y.length; i++) {
- if (elmnt == y[i]) {
- arrNo.push(i)
- } else {
- y[i].classList.remove("select-arrow-active");
- }
- }
- for (i = 0; i < x.length; i++) {
- if (arrNo.indexOf(i)) {
- x[i].classList.add("select-hide");
- }
- }
- }
- document.addEventListener("click", closeAllSelect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement