{"version":3,"file":"index.min.js","sources":["index.js"],"sourcesContent":["(function () {\r\n 'use strict';\r\n\r\n function HttpReq(url, contentType, input) {\r\n this.method = input ? 'POST' : 'GET';\r\n this.data = input ? input : {};\r\n this.contentType = contentType;\r\n this.url = url;\r\n }\r\n HttpReq.prototype.then = function (resolve, reject) {\r\n var req = new XMLHttpRequest();\r\n req.onreadystatechange = function () {\r\n if (req.readyState == XMLHttpRequest.DONE) {\r\n if (req.status == 200) { resolve(req.response); }\r\n else { reject(req.statusText); }\r\n }\r\n };\r\n req.open(this.method, this.url, true);\r\n req.setRequestHeader('Content-Type', this.contentType);\r\n req.send(this.data);\r\n };\r\n\r\n NodeList.prototype.addEventListener = function (type, f,uc) { this.forEach(function (x) { x.addEventListener(type, f, uc); }); };\r\n\r\n function SearchProducts(selector) {\r\n var searchResult = document.querySelector(selector + ' .searchResult');\r\n document.querySelectorAll('.search-tgl').addEventListener('click', function () {\r\n var el = document.querySelector(selector);\r\n el.classList.toggle('invisible');\r\n el.classList.toggle('bg-white');\r\n document.querySelector(selector + ' input').focus();\r\n });\r\n document.querySelectorAll('.search-btn').addEventListener('click', function () {\r\n document.querySelector(selector + ' form').submit();\r\n });\r\n document.querySelector(selector + ' input[type=\"search\"]').addEventListener('input', function () {\r\n document.querySelector('input.search-tgl[type=\"search\"]').value = this.value;\r\n var val = this.value.trim();\r\n if (val != \"\") {\r\n new HttpReq('/Members/searchlist.aspx?q=' + val, 'text/html; charset=utf-8').then(\r\n function (response) {\r\n searchResult.innerHTML = response;\r\n }, function (status) {\r\n console.log({ status: 'خطا', erroeText: status });\r\n });\r\n } else {\r\n searchResult.innerHTML = \"\";\r\n }\r\n });\r\n }\r\n\r\n function OnView(el, callback, fullSeen) {\r\n this.element = el;\r\n this.callback = callback;\r\n this.fullSeen = fullSeen;\r\n this.viewed();\r\n window.addEventListener('scroll', this.viewed.bind(this));\r\n }\r\n OnView.prototype.isview = function () {\r\n var position = this.element.getBoundingClientRect();\r\n if (this.fullSeen) {\r\n if (position.top >= 0 && position.bottom <= window.innerHeight) {\r\n return true;\r\n }\r\n } else if (position.top < window.innerHeight && position.bottom >= 0) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n OnView.prototype.viewed = function () {\r\n if (this.isview()) {\r\n this.callback(this.element);\r\n window.removeEventListener(\"scroll\", this.viewed , true);\r\n }\r\n };\r\n\r\n function Lazy(name, start, call) {\r\n this.call = call;\r\n document.querySelectorAll('.' + name + '-lazy').forEach(function (el) {\r\n if (start) {\r\n this.run(el);\r\n } else {\r\n new OnView(el, this.run.bind(this), false);\r\n }\r\n }.bind(this));\r\n }\r\n Lazy.prototype.run = function (el) {\r\n if (el.dataset.bg) {\r\n el.style.backgroundImage = \"url('\" + el.dataset.bg + \"')\";\r\n delete el.dataset.bg;\r\n }\r\n if (el.dataset.src && el.dataset.src != el.src) {\r\n var newImg = new Image();\r\n newImg.src = el.dataset.src;\r\n if (this.call) { this.call(newImg,el);}\r\n newImg.addEventListener('load', function () {\r\n el.src = this.src;\r\n delete el.dataset.src;\r\n }, true);\r\n newImg.addEventListener('error', function () {\r\n el.dataset.src = el.src;\r\n }, true); \r\n }\r\n if (el.dataset.bg) {\r\n el.style.backgroundImage = \"url('\" + el.dataset.bg + \"')\";\r\n }\r\n };\r\n\r\n //const modalTriggers = document.querySelectorAll('.popup-trigger')\r\n //const modalCloseTrigger = document.querySelector('.popup-modal__close')\r\n //const bodyBlackout = document.querySelector('.body-blackout')\r\n\r\n //modalTriggers.forEach(trigger => {\r\n // trigger.addEventListener('click', () => {\r\n // const { popupTrigger } = trigger.dataset\r\n // const popupModal = document.querySelector(`[data-popup-modal=\"${popupTrigger}\"]`)\r\n // popupModal.classList.add('is--visible')\r\n // bodyBlackout.classList.add('is-blacked-out')\r\n\r\n // popupModal.querySelector('.popup-modal__close').addEventListener('click', () => {\r\n // popupModal.classList.remove('is--visible')\r\n // bodyBlackout.classList.remove('is-blacked-out')\r\n // })\r\n // })\r\n //})\r\n\r\n function Modal() {\r\n var triggers = document.querySelectorAll('[data-modal]');\r\n //console.log(triggers);\r\n triggers.forEach(function(trigger){\r\n var modal = document.querySelector('#' + trigger.dataset.modal);\r\n console.log(modal);\r\n trigger.addEventListener('click', function () {\r\n console.log(modal.className);\r\n modal.classList.remove('invisible');\r\n });\r\n });\r\n }\r\n\r\n //function Menu(selector) {\r\n // this.nav = document.querySelector(selector);\r\n // this.toggle_fnc = function () {\r\n // if (!this.nav.hasAttribute('created')) {\r\n // //creatingMenu(selector);\r\n // this.nav.addAttributes('created');\r\n // }\r\n // nav.classList.toggle('open');\r\n // };\r\n\r\n\r\n\r\n //// this.config = config;\r\n //// this.config.selector.style.overflow = 'hidden';\r\n //// this.wrapper = config.selector.querySelector('div');\r\n\r\n //// this.wrapper.setAttributes({ style: { position: 'relative', left: '0px', transition: 'left ' + this.config.duration + 'ms ease-out 0s' } });\r\n //// this.wrapper.dataset.select = 0;\r\n //// if (config.control) {\r\n //// config.selector.querySelector('.next').addEventListener('click', this.next.bind(this));\r\n //// config.selector.querySelector('.prev').addEventListener('click', this.prev.bind(this));\r\n //// }\r\n //// window.addEventListener('resize', this.init.bind(this), false);\r\n //// this.items = Array.prototype.slice.call(this.wrapper.children);\r\n //// this.init();\r\n //}\r\n\r\n var responsiveMultiMenu = function (selector) {\r\n var nav = document.querySelector(selector);\r\n var createMenu = false;\r\n var toggle = function () {\r\n if (createMenu === false) {\r\n creatingMenu(selector);\r\n createMenu = true;\r\n }\r\n nav.classList.toggle('open');\r\n };\r\n\r\n document.querySelector(selector + '>div').addEventListener(\"click\", toggle);\r\n document.querySelector(selector + 'Toggle').addEventListener(\"click\", toggle);\r\n\r\n\r\n\r\n var creatingMenu = function (selector) {\r\n document.querySelectorAll(selector + '>ul ul').forEach(function (ul) {\r\n ul.classList.add('rmm-submenu');\r\n ul.insertAdjacentHTML('afterbegin', '