PageSourceSearch

https://ashghal-ye.com/public/assets/frontend/js/theme.js

js ashghal-ye.com collected 2026-09-24 14:38:33 UTC 12,113 bytes, 342 lines download raw bytes

1"use strict";
2
3function 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; }
4
5function _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; }
6
7function _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; }
8
9/* -------------------------------------------------------------------------- */
10
11/*                                    Utils                                   */
12
13/* -------------------------------------------------------------------------- */
14var docReady = function docReady(fn) {
15  // see if DOM is already available
16  if (document.readyState === 'loading') {
17    document.addEventListener('DOMContentLoaded', fn);
18  } else {
19    setTimeout(fn, 1);
20  }
21};
22
23var resize = function resize(fn) {
24  return window.addEventListener('resize', fn);
25};
26
27var isIterableArray = function isIterableArray(array) {
28  return Array.isArray(array) && !!array.length;
29};
30
31var camelize = function camelize(str) {
32  var text = str.replace(/[-_\s.]+(.)?/g, function (_, c) {
33    return c ? c.toUpperCase() : '';
34  });
35  return "".concat(text.substr(0, 1).toLowerCase()).concat(text.substr(1));
36};
37
38var getData = function getData(el, data) {
39  try {
40    return JSON.parse(el.dataset[camelize(data)]);
41  } catch (e) {
42    return el.dataset[camelize(data)];
43  }
44};
45/* ----------------------------- Colors function ---------------------------- */
46
47
48var hexToRgb = function hexToRgb(hexValue) {
49  var hex;
50  hexValue.indexOf('#') === 0 ? hex = hexValue.substring(1) : hex = hexValue; // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
51
52  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
53  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex.replace(shorthandRegex, function (m, r, g, b) {
54    return r + r + g + g + b + b;
55  }));
56  return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : null;
57};
58
59var rgbaColor = function rgbaColor() {
60  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#fff';
61  var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
62  return "rgba(".concat(hexToRgb(color), ", ").concat(alpha, ")");
63};
64/* --------------------------------- Colors --------------------------------- */
65
66
67var colors = {
68  primary: '#2c7be5',
69  secondary: '#748194',
70  success: '#00d27a',
71  info: '#27bcfd',
72  warning: '#f5803e',
73  danger: '#e63757',
74  light: '#f9fafd',
75  dark: '#000'
76};
77var grays = {
78  white: '#fff',
79  100: '#f9fafd',
80  200: '#edf2f9',
81  300: '#d8e2ef',
82  400: '#b6c1d2',
83  500: '#9da9bb',
84  600: '#748194',
85  700: '#5e6e82',
86  800: '#4d5969',
87  900: '#344050',
88  1000: '#232e3c',
89  1100: '#0b1727',
90  black: '#000'
91};
92
93var hasClass = function hasClass(el, className) {
94  !el && false;
95  return el.classList.value.includes(className);
96};
97
98var addClass = function addClass(el, className) {
99  el.classList.add(className);
100};
101
102var getOffset = function getOffset(el) {
103  var rect = el.getBoundingClientRect();
104  var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
105  var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
106  return {
107    top: rect.top + scrollTop,
108    left: rect.left + scrollLeft
109  };
110};
111
112var isScrolledIntoView = function isScrolledIntoView(el) {
113  var top = el.offsetTop;
114  var left = el.offsetLeft;
115  var width = el.offsetWidth;
116  var height = el.offsetHeight;
117
118  while (el.offsetParent) {
119    // eslint-disable-next-line no-param-reassign
120    el = el.offsetParent;
121    top += el.offsetTop;
122    left += el.offsetLeft;
123  }
124
125  return {
126    all: top >= window.pageYOffset && left >= window.pageXOffset && top + height <= window.pageYOffset + window.innerHeight && left + width <= window.pageXOffset + window.innerWidth,
127    partial: top < window.pageYOffset + window.innerHeight && left < window.pageXOffset + window.innerWidth && top + height > window.pageYOffset && left + width > window.pageXOffset
128  };
129};
130
131var breakpoints = {
132  xs: 0,
133  sm: 576,
134  md: 768,
135  lg: 992,
136  xl: 1200,
137  xxl: 1540
138};
139
140var getBreakpoint = function getBreakpoint(el) {
141  var classes = el && el.classList.value;
142  var breakpoint;
143
144  if (classes) {
145    breakpoint = breakpoints[classes.split(' ').filter(function (cls) {
146      return cls.includes('navbar-expand-');
147    }).pop().split('-').pop()];
148  }
149
150  return breakpoint;
151};
152/* --------------------------------- Cookie --------------------------------- */
153
154
155var setCookie = function setCookie(name, value, expire) {
156  var expires = new Date();
157  expires.setTime(expires.getTime() + expire);
158  document.cookie = "".concat(name, "=").concat(value, ";expires=").concat(expires.toUTCString());
159};
160
161var getCookie = function getCookie(name) {
162  var keyValue = document.cookie.match("(^|;) ?".concat(name, "=([^;]*)(;|$)"));
163  return keyValue ? keyValue[2] : keyValue;
164};
165
166var settings = {
167  tinymce: {
168    theme: 'oxide'
169  },
170  chart: {
171    borderColor: 'rgba(255, 255, 255, 0.8)'
172  }
173};
174/* -------------------------- Chart Initialization -------------------------- */
175
176var newChart = function newChart(chart, config) {
177  var ctx = chart.getContext('2d');
178  return new window.Chart(ctx, config);
179};
180/* ---------------------------------- Store --------------------------------- */
181
182
183var getItemFromStore = function getItemFromStore(key, defaultValue) {
184  var store = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
185
186  try {
187    return JSON.parse(store.getItem(key)) || defaultValue;
188  } catch (_unused) {
189    return store.getItem(key) || defaultValue;
190  }
191};
192
193var setItemToStore = function setItemToStore(key, payload) {
194  var store = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
195  return store.setItem(key, payload);
196};
197
198var getStoreSpace = function getStoreSpace() {
199  var store = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
200  return parseFloat((escape(encodeURIComponent(JSON.stringify(store))).length / (1024 * 1024)).toFixed(2));
201};
202
203var utils = {
204  docReady: docReady,
205  resize: resize,
206  isIterableArray: isIterableArray,
207  camelize: camelize,
208  getData: getData,
209  hasClass: hasClass,
210  addClass: addClass,
211  hexToRgb: hexToRgb,
212  rgbaColor: rgbaColor,
213  colors: colors,
214  grays: grays,
215  getOffset: getOffset,
216  isScrolledIntoView: isScrolledIntoView,
217  getBreakpoint: getBreakpoint,
218  setCookie: setCookie,
219  getCookie: getCookie,
220  newChart: newChart,
221  settings: settings,
222  getItemFromStore: getItemFromStore,
223  setItemToStore: setItemToStore,
224  getStoreSpace: getStoreSpace
225};
226/* -------------------------------------------------------------------------- */
227
228/*                                  Detector                                  */
229
230/* -------------------------------------------------------------------------- */
231
232var detectorInit = function detectorInit() {
233  var _window = window,
234      is = _window.is;
235  var html = document.querySelector('html');
236  is.opera() && addClass(html, 'opera');
237  is.mobile() && addClass(html, 'mobile');
238  is.firefox() && addClass(html, 'firefox');
239  is.safari() && addClass(html, 'safari');
240  is.ios() && addClass(html, 'ios');
241  is.iphone() && addClass(html, 'iphone');
242  is.ipad() && addClass(html, 'ipad');
243  is.ie() && addClass(html, 'ie');
244  is.edge() && addClass(html, 'edge');
245  is.chrome() && addClass(html, 'chrome');
246  is.mac() && addClass(html, 'osx');
247  is.windows() && addClass(html, 'windows');
248  navigator.userAgent.match('CriOS') && addClass(html, 'chrome');
249};
250/*-----------------------------------------------
251|   Top navigation opacity on scroll
252-----------------------------------------------*/
253
254
255var navbarInit = function navbarInit() {
256  var Selector = {
257    NAVBAR: '[data-navbar-on-scroll]',
258    NAVBAR_COLLAPSE: '.navbar-collapse',
259    NAVBAR_TOGGLER: '.navbar-toggler'
260  };
261  var ClassNames = {
262    COLLAPSED: 'collapsed'
263  };
264  var Events = {
265    SCROLL: 'scroll',
266    SHOW_BS_COLLAPSE: 'show.bs.collapse',
267    HIDE_BS_COLLAPSE: 'hide.bs.collapse',
268    HIDDEN_BS_COLLAPSE: 'hidden.bs.collapse'
269  };
270  var DataKey = {
271    NAVBAR_ON_SCROLL: 'navbar-light-on-scroll'
272  };
273  var navbar = document.querySelector(Selector.NAVBAR);
274
275  if (navbar) {
276    var windowHeight = window.innerHeight;
277    var html = document.documentElement;
278    var navbarCollapse = navbar.querySelector(Selector.NAVBAR_COLLAPSE);
279
280    var allColors = _objectSpread(_objectSpread({}, utils.colors), utils.grays);
281
282    var name = utils.getData(navbar, DataKey.NAVBAR_ON_SCROLL);
283    var colorName = Object.keys(allColors).includes(name) ? name : 'white';
284    var color = allColors[colorName];
285    var bgClassName = "bg-".concat(colorName);
286    var shadowName = 'shadow-transition';
287    var colorRgb = utils.hexToRgb(color);
288
289    var _window$getComputedSt = window.getComputedStyle(navbar),
290        backgroundImage = _window$getComputedSt.backgroundImage;
291
292    var transition = 'background-color 0.35s ease';
293    navbar.style.backgroundImage = 'none'; // Change navbar background color on scroll
294
295    window.addEventListener(Events.SCROLL, function () {
296      var scrollTop = html.scrollTop;
297      var alpha = scrollTop / windowHeight * 5;
298      alpha >= 1 && (alpha = 1);
299      navbar.style.backgroundColor = "rgba(".concat(colorRgb[0], ", ").concat(colorRgb[1], ", ").concat(colorRgb[2], ", ").concat(alpha, ")");
300      navbar.style.backgroundImage = alpha > 0 || utils.hasClass(navbarCollapse, 'show') ? backgroundImage : 'none';
301      alpha > 0 || utils.hasClass(navbarCollapse, 'show') ? navbar.classList.add(shadowName) : navbar.classList.remove(shadowName);
302    }); // Toggle bg class on window resize
303
304    utils.resize(function () {
305      var breakPoint = utils.getBreakpoint(navbar);
306
307      if (window.innerWidth > breakPoint) {
308        navbar.style.backgroundImage = html.scrollTop ? backgroundImage : 'none';
309        navbar.style.transition = 'none';
310      } else if (!utils.hasClass(navbar.querySelector(Selector.NAVBAR_TOGGLER), ClassNames.COLLAPSED)) {
311        navbar.classList.add(bgClassName);
312        navbar.classList.add(shadowName);
313        navbar.style.backgroundImage = backgroundImage;
314      }
315
316      if (window.innerWidth <= breakPoint) {
317        navbar.style.transition = utils.hasClass(navbarCollapse, 'show') ? transition : 'none';
318      }
319    });
320    navbarCollapse.addEventListener(Events.SHOW_BS_COLLAPSE, function () {
321      navbar.classList.add(bgClassName);
322      navbar.classList.add(shadowName);
323      navbar.style.backgroundImage = backgroundImage;
324      navbar.style.transition = transition;
325    });
326    navbarCollapse.addEventListener(Events.HIDE_BS_COLLAPSE, function () {
327      navbar.classList.remove(bgClassName);
328      navbar.classList.remove(shadowName);
329      !html.scrollTop && (navbar.style.backgroundImage = 'none');
330    });
331    navbarCollapse.addEventListener(Events.HIDDEN_BS_COLLAPSE, function () {
332      navbar.style.transition = 'none';
333    });
334  }
335}; // /* -------------------------------------------------------------------------- */
336// /*                            Theme Initialization                            */
337// /* -------------------------------------------------------------------------- */
338
339
340docReady(navbarInit);
341docReady(detectorInit);
342//# sourceMappingURL=theme.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.