PageSourceSearch

https://bayalagbuteegch.mn/js/theme.js

js bayalagbuteegch.mn collected 2026-10-04 13:28:15 UTC 18,438 bytes, 844 lines download raw bytes

1/*
2Name: 			Core Initializer
3Written by: 	Crivos - (http://www.crivos.com)
4Version: 		2.0
5*/
6
7(function() {
8
9	"use strict";
10
11	var Core = {
12
13		initialized: false,
14
15		initialize: function() {
16
17			if (this.initialized) return;
18			this.initialized = true;
19
20			this.build();
21			this.events();
22
23		},
24
25		build: function() {
26
27			// Adds browser version on html class.
28			
29
30			// Adds window smooth scroll on chrome.
31			var $html = $('html');
32			if($html.hasClass("chrome") || $html.hasClass('ie11') || $html.hasClass('ie10')) {
33				$.smoothScroll();
34			}
35
36			// Nav Menu
37			this.navMenu();
38
39			// Header Search
40			this.headerSearch();
41
42			// Page Top
43			this.pageTop();
44
45			// Animations
46			this.animations();
47
48			// Word Rotate
49			this.wordRotate();
50
51			// Newsletter
52			this.newsletter();
53
54			// Featured Boxes
55			this.featuredBoxes();
56
57			// Thumb Info
58			this.thumbInfo();
59
60			// Owl Carousel
61			this.owlCarousel();
62
63			// Tooltips
64			$("a[rel=tooltip]").tooltip();
65
66			// Sort
67			this.sort();
68
69			// Toggle
70			this.toggle();
71
72			// Twitter
73			this.latestTweets();
74
75			// Lightbox
76			this.lightbox();
77
78			// Parallax
79			this.parallax();
80
81		},
82
83		events: function() {
84
85			// Window Resize
86			/*$(window).afterResize(function() {
87
88				// Featured Boxes
89				Core.featuredBoxes();
90
91				// Sticky Menu
92				Core.checkStickyMenu(true);
93
94				// Revolution Slider Fix
95				Core.fixRevolutionSlider();
96
97				// Isotope
98				$(".isotope").isotope('reLayout');
99
100				// Masonry
101				Core.masonry();
102
103			});*/
104
105			// Anchors Position
106			$("a[data-hash]").on("click", function(e) {
107
108				e.preventDefault();
109				var header = $("body header:first"),
110					headerHeight = header.height(),
111					target = $(this).attr("href"),
112					$this = $(this);
113
114				if($(window).width() > 991) {
115					$("html,body").animate({scrollTop: $(target).offset().top - (headerHeight + 50)}, 600, "easeOutQuad");
116				} else {
117					$("html,body").animate({scrollTop: $(target).offset().top - 30}, 600, "easeOutQuad");
118				}
119
120				return false;
121
122			});
123
124		},
125
126		navMenu: function() {
127
128			// Responsive Menu Events
129			var addActiveClass = false;
130
131			$("#mainMenu li.dropdown > a, #mainMenu li.dropdown-submenu > a").on("click", function(e) {
132
133				if($(window).width() > 979) return;
134
135				e.preventDefault();
136
137				addActiveClass = $(this).parent().hasClass("resp-active");
138
139				$("#mainMenu").find(".resp-active").removeClass("resp-active");
140
141				if(!addActiveClass) {
142					$(this).parents("li").addClass("resp-active");
143				}
144
145				return;
146
147			});
148
149			// Submenu Check Visible Space
150			$("#mainMenu li.dropdown-submenu").hover(function() {
151
152				if($(window).width() < 767) return;
153
154				var subMenu = $(this).find("ul.dropdown-menu");
155
156				if(!subMenu.get(0)) return;
157
158				var screenWidth = $(window).width(),
159					subMenuOffset = subMenu.offset(),
160					subMenuWidth = subMenu.width(),
161					subMenuParentWidth = subMenu.parents("ul.dropdown-menu").width(),
162					subMenuPosRight = subMenu.offset().left + subMenu.width();
163
164				if(subMenuPosRight > screenWidth) {
165					subMenu.css("margin-left", "-" + (subMenuParentWidth + subMenuWidth + 10) + "px");
166				} else {
167					subMenu.css("margin-left", 0);
168				}
169
170			});
171
172			// Mega Menu
173			$(document).on("click", ".mega-menu .dropdown-menu", function(e) {
174				e.stopPropagation()
175			});
176
177		},
178
179
180		headerSearch: function() {
181
182			var searchEl = $("#headerSearch .search-input"),
183				searchSubmit = searchEl.find("button");
184
185			$(document).on("click", function(e) {
186				if($(e.target).closest("#headerSearch").length === 0) {
187					searchEl.removeClass("active");
188					setTimeout(function() {
189						searchEl.hide();
190					}, 250);
191				}
192			});
193
194			$("#headerSearchOpen").on("click", function(e) {
195				e.preventDefault();
196
197				searchEl.show();
198
199				setTimeout(function() {
200					searchEl.addClass("active");
201				}, 50);
202
203				setTimeout(function() {
204					searchEl.find("input").focus();
205				}, 250);
206			});
207
208			$("#headerSearchForm").validate({
209				rules: {
210					q: {
211						required: true
212					}
213				},
214	            errorPlacement: function(error, element) {
215
216	            },
217				highlight: function (element) {
218					$(element)
219						.closest(".control-group")
220						.removeClass("success")
221						.addClass("error");
222				},
223				success: function (element) {
224					$(element)
225						.closest(".control-group")
226						.removeClass("error")
227						.addClass("success");
228				}
229			});
230
231			searchSubmit.on("click", function(e) {
232				$("#headerSearchForm").submit();
233			});
234
235		},
236
237		pageTop: function(options) {
238
239			if(!$(".page-top").get(0)) {
240				$("body").addClass("no-page-top");
241				return;
242			}
243
244			$("div.page-top-slider:not(.manual)").each(function() {
245
246				var slider = $(this);
247
248				var defaults = {
249					delay: 6000,
250					startheight: 250,
251					startwidth: 960,
252
253					navigationType: "none",
254					navigationArrows: "none",
255
256					stopAtSlide: -1,
257					stopAfterLoops: -1,
258
259					shadow: 0,
260					fullWidth: "on",
261					onHoverStop: "off",
262					videoJsPath: "vendor/rs-plugin/videojs/"
263				}
264
265				var config = $.extend({}, defaults, options, slider.data("plugin-options"));
266
267				// Initialize Slider
268				var sliderApi = slider.revolution(config).addClass("slider-init");
269
270			});
271
272			setTimeout(function() {
273				$(".page-top-info").addClass("init");
274			}, 500);
275
276		},
277
278		animations: function() {
279
280			// Animation Appear
281			$("[data-appear-animation]").each(function() {
282
283				var $this = $(this);
284
285				$this.addClass("appear-animation");
286
287				if(!$("html").hasClass("no-csstransitions") && $(window).width() > 767) {
288
289					$this.appear(function() {
290
291						var delay = ($this.attr("data-appear-animation-delay") ? $this.attr("data-appear-animation-delay") : 1);
292
293						if(delay > 1) $this.css("animation-delay", delay + "ms");
294						$this.addClass($this.attr("data-appear-animation"));
295
296						setTimeout(function() {
297							$this.addClass("appear-animation-visible");
298						}, delay);
299
300					}, {accX: 0, accY: -150});
301
302				} else {
303
304					$this.addClass("appear-animation-visible");
305
306				}
307
308			});
309
310			// Animation Progress Bars
311			$("[data-appear-progress-animation]").each(function() {
312
313				var $this = $(this);
314
315				$this.appear(function() {
316
317					var delay = ($this.attr("data-appear-animation-delay") ? $this.attr("data-appear-animation-delay") : 1);
318
319					if(delay > 1) $this.css("animation-delay", delay + "ms");
320					$this.addClass($this.attr("data-appear-animation"));
321
322					setTimeout(function() {
323
324						$this.animate({
325							width: $this.attr("data-appear-progress-animation")
326						}, 1500, "easeOutQuad", function() {
327							$this.find(".progress-bar-tooltip").animate({
328								opacity: 1
329							}, 500, "easeOutQuad");
330						});
331
332					}, delay);
333
334				}, {accX: 0, accY: -50});
335
336			});
337
338			// Count To
339			$(".counters [data-to]").each(function() {
340
341				var $this = $(this);
342
343				$this.appear(function() {
344
345					$this.countTo({});
346
347				}, {accX: 0, accY: -150});
348
349			});
350
351			/* Circular Bars - Knob */
352			if(typeof($.fn.knob) != "undefined") {
353				$(".knob").knob({});
354			}
355
356		},
357
358		wordRotate: function() {
359			$(".word-rotate").each(function() {
360
361				var $this = $(this),
362					itemsWrapper = $(this).find(".word-rotate-items"),
363					items = itemsWrapper.find("> span"),
364					firstItem = items.eq(0),
365					firstItemClone = firstItem.clone(),
366					maxWidth = 0,
367					itemHeight = 0,
368					currentItem = 1,
369					currentTop = 0;
370
371				items.each(function() {
372					if($(this).width() > maxWidth) {
373						maxWidth = $(this).width();
374					}
375				});
376
377				itemHeight = firstItem.height();
378
379				itemsWrapper.append(firstItemClone);
380
381				$this
382					.width(maxWidth)
383					.height(itemHeight)
384					.addClass("active");
385
386				setInterval(function() {
387
388					currentTop = (currentItem * itemHeight);
389
390					itemsWrapper.animate({
391						top: -(currentTop) + "px"
392					}, 300, "easeOutQuad", function() {
393
394						currentItem++;
395
396						if(currentItem > items.length) {
397
398							itemsWrapper.css("top", 0);
399							currentItem = 1;
400
401						}
402
403					});
404
405				}, 2000);
406
407			});
408
409		},
410
411		newsletter: function() {
412
413			$("#newsletterForm").validate({
414				submitHandler: function(form) {
415
416					$.ajax({
417						type: "POST",
418						url: $("#newsletterForm").attr("action"),
419						data: {
420							"email": $("#newsletterForm #email").val()
421						},
422						dataType: "json",
423						success: function (data) {
424							if (data.response == "success") {
425
426								$("#newsletterSuccess").removeClass("hidden");
427								$("#newsletterError").addClass("hidden");
428
429								$("#newsletterForm #email")
430									.val("")
431									.blur()
432									.closest(".control-group")
433									.removeClass("success")
434									.removeClass("error");
435
436							} else {
437
438								$("#newsletterError").html(data.message);
439								$("#newsletterError").removeClass("hidden");
440								$("#newsletterSuccess").addClass("hidden");
441
442								$("#newsletterForm #email")
443									.blur()
444									.closest(".control-group")
445									.removeClass("success")
446									.addClass("error");
447
448							}
449						}
450					});
451
452				},
453				rules: {
454					email: {
455						required: true,
456						email: true
457					}
458				},
459	            errorPlacement: function(error, element) {
460
461	            },
462				highlight: function (element) {
463					$(element)
464						.closest(".control-group")
465						.removeClass("success")
466						.addClass("error");
467				},
468				success: function (element) {
469					$(element)
470						.closest(".control-group")
471						.removeClass("error")
472						.addClass("success");
473				}
474			});
475
476		},
477
478		featuredBoxes: function() {
479
480			$("div.featured-box").css("height", "auto");
481
482			$("div.featured-boxes").each(function() {
483
484				var wrapper = $(this);
485				var minBoxHeight = 0;
486
487				$("div.featured-box", wrapper).each(function() {
488					if($(this).height() > minBoxHeight)
489						minBoxHeight = $(this).height();
490				});
491
492				$("div.featured-box", wrapper).height(minBoxHeight);
493
494			});
495
496		},
497
498		thumbInfo: function() {
499
500			$(".thumb-info").css("min-height", "auto");
501
502			$(".thumb-info-list").each(function() {
503
504				var wrapper = $(this);
505				var minBoxHeight = 0;
506
507				$(".thumb-info", wrapper).each(function() {
508					if($(this).height() > minBoxHeight)
509						minBoxHeight = $(this).height();
510				});
511
512				$(".thumb-info", wrapper).height(minBoxHeight);
513
514			});
515
516		},
517
518		owlCarousel: function(options) {
519
520			var total = $("div.owl-carousel:not(.manual)").length,
521				count = 0;
522
523			$("div.owl-carousel:not(.manual)").each(function() {
524
525				var slider = $(this);
526
527				var defaults = {
528					 // Most important owl features
529					items : 5,
530					itemsCustom : false,
531					itemsDesktop : [1199,4],
532					itemsDesktopSmall : [980,3],
533					itemsTablet: [768,2],
534					itemsTabletSmall: false,
535					itemsMobile : [479,1],
536					singleItem : true,
537					itemsScaleUp : false,
538
539					//Basic Speeds
540					slideSpeed : 200,
541					paginationSpeed : 800,
542					rewindSpeed : 1000,
543
544					//Autoplay
545					autoPlay : false,
546					stopOnHover : false,
547
548					// Navigation
549					navigation : false,
550					navigationText : ["<i class=\"icon icon-chevron-left\"></i>","<i class=\"icon icon-chevron-right\"></i>"],
551					rewindNav : true,
552					scrollPerPage : false,
553
554					//Pagination
555					pagination : true,
556					paginationNumbers: false,
557
558					// Responsive
559					responsive: true,
560					responsiveRefreshRate : 200,
561					responsiveBaseWidth: window,
562
563					// CSS Styles
564					baseClass : "owl-carousel",
565					theme : "owl-theme",
566
567					//Lazy load
568					lazyLoad : false,
569					lazyFollow : true,
570					lazyEffect : "fade",
571
572					//Auto height
573					autoHeight : false,
574
575					//JSON
576					jsonPath : false,
577					jsonSuccess : false,
578
579					//Mouse Events
580					dragBeforeAnimFinish : true,
581					mouseDrag : true,
582					touchDrag : true,
583
584					//Transitions
585					transitionStyle : false,
586
587					// Other
588					addClassActive : false,
589
590					//Callbacks
591					beforeUpdate : false,
592					afterUpdate : false,
593					beforeInit: false,
594					afterInit: false,
595					beforeMove: false,
596					afterMove: false,
597					afterAction: false,
598					startDragging : false,
599					afterLazyLoad : false
600				}
601
602				var config = $.extend({}, defaults, options, slider.data("plugin-options"));
603
604				// Initialize Slider
605				slider.owlCarousel(config).addClass("owl-carousel-init");
606
607			});
608
609		},
610
611		sort: function() {
612
613			$("ul.sort-source").each(function() {
614
615				var source = $(this);
616				var destination = $("ul.sort-destination[data-sort-id=" + $(this).attr("data-sort-id") + "]");
617
618				if(destination.get(0)) {
619
620					$(window).load(function() {
621
622						destination.isotope({
623							itemSelector: "li",
624							layoutMode: 'sloppyMasonry'
625						});
626
627						source.find("a").click(function(e) {
628
629							e.preventDefault();
630
631							var $this = $(this),
632								sortId = $this.parents(".sort-source").attr("data-sort-id"),
633								filter = $this.parent().attr("data-option-value");
634
635							source.find("li.active").removeClass("active");
636							$this.parent().addClass("active");
637
638							destination.isotope({
639								filter: filter
640							});
641
642							self.location = "#" + filter.replace(".","");
643
644							$(".sort-source-title[data-sort-id=" + sortId + "] strong").html($this.html());
645
646							return false;
647
648						});
649
650						$(window).bind("hashchange", function(e) {
651
652							var hashFilter = "." + location.hash.replace("#",""),
653								hash = (hashFilter == "." || hashFilter == ".*" ? "*" : hashFilter);
654
655							source.find("li.active").removeClass("active");
656							source.find("li[data-option-value='" + hash + "']").addClass("active");
657
658							destination.isotope({
659								filter: hash
660							});
661
662						});
663
664						var hashFilter = "." + (location.hash.replace("#","") || "*");
665
666						var initFilterEl = source.find("li[data-option-value='" + hashFilter + "'] a");
667
668						if(initFilterEl.get(0)) {
669							source.find("li[data-option-value='" + hashFilter + "'] a").click();
670						} else {
671							source.find("li:first-child a").click();
672						}
673
674					});
675
676				}
677
678			});
679
680		},
681
682		toggle: function() {
683
684			var $this = this,
685				previewParClosedHeight = 25;
686
687			$("section.toggle.active > p").addClass("preview-active");
688			$("section.toggle.active > div.toggle-content").slideDown(350, function() {});
689
690			$("section.toggle > label").click(function(e) {
691
692				var parentSection = $(this).parent(),
693					parentWrapper = $(this).parents("div.toogle"),
694					previewPar = false,
695					isAccordion = parentWrapper.hasClass("toogle-accordion");
696
697				if(isAccordion && typeof(e.originalEvent) != "undefined") {
698					parentWrapper.find("section.toggle.active > label").trigger("click");
699				}
700
701				parentSection.toggleClass("active");
702
703				// Preview Paragraph
704				if(parentSection.find("> p").get(0)) {
705
706					previewPar = parentSection.find("> p");
707					var previewParCurrentHeight = previewPar.css("height");
708					previewPar.css("height", "auto");
709					var previewParAnimateHeight = previewPar.css("height");
710					previewPar.css("height", previewParCurrentHeight);
711
712				}
713
714				// Content
715				var toggleContent = parentSection.find("> div.toggle-content");
716
717				if(parentSection.hasClass("active")) {
718
719					$(previewPar).animate({
720						height: previewParAnimateHeight
721					}, 350, function() {
722						$(this).addClass("preview-active");
723					});
724
725					toggleContent.slideDown(350, function() {});
726
727				} else {
728
729					$(previewPar).animate({
730						height: previewParClosedHeight
731					}, 350, function() {
732						$(this).removeClass("preview-active");
733					});
734
735					toggleContent.slideUp(350, function() {});
736
737				}
738
739			});
740
741		},
742
743		lightbox: function(options) {
744
745			if(typeof($.magnificPopup) == "undefined") {
746				return false;
747			}
748
749			// Internationalization of Lightbox
750			$.extend(true, $.magnificPopup.defaults, {
751				tClose: 'Close (Esc)', // Alt text on close button
752				tLoading: 'Loading...', // Text that is displayed during loading. Can contain %curr% and %total% keys
753				gallery: {
754					tPrev: 'Previous (Left arrow key)', // Alt text on left arrow
755					tNext: 'Next (Right arrow key)', // Alt text on right arrow
756					tCounter: '%curr% of %total%' // Markup for "1 of 7" counter
757				},
758				image: {
759					tError: '<a href="%url%">The image</a> could not be loaded.' // Error message when image could not be loaded
760				},
761				ajax: {
762					tError: '<a href="%url%">The content</a> could not be loaded.' // Error message when ajax request failed
763				}
764			});
765
766			$(".lightbox").each(function() {
767
768				var el = $(this);
769
770				var config, defaults = {}
771				if(el.data("plugin-options"))
772					config = $.extend({}, defaults, options, el.data("plugin-options"));
773
774				$(this).magnificPopup(config);
775
776			});
777
778		},
779
780		parallax: function() {
781
782			if(typeof($.stellar) == "undefined") {
783				$(".parallax").addClass("parallax-init");
784				return false;
785			}
786
787			$(window).load(function () {
788
789				if($(".parallax").get(0)) {
790					if(!Modernizr.touch) {
791						$(window).stellar({
792							responsive:true,
793							scrollProperty: 'scroll',
794							parallaxElements: false,
795							horizontalScrolling: false,
796							horizontalOffset: 0,
797							verticalOffset: 0
798						});
799					} else {
800						$(".parallax").addClass("disabled");
801					}
802				}
803
804				$(".parallax").addClass("parallax-init");
805
806			});
807
808		},
809
810		latestTweets: function() {
811
812			var wrapper = $("#tweet"),
813				accountId = wrapper.data("account-id");
814
815			if(wrapper.get(0) && accountId != "") {
816				getTwitters("tweet", {
817					id: accountId,
818					count: 2
819				});
820
821				wrapper.before($("<a />").addClass("twitter-account").html("@" + accountId).attr("href", "http://www.twitter.com/" + accountId).attr("target", "_blank"));
822
823			}
824
825		},
826
827		
828		fixRevolutionSlider: function() {
829
830			$(".revslider-initialised").each(function() {
831				try{
832					$(this).revredraw();
833				} catch(e) {}
834			});
835
836		}
837
838	};
839
840	Core.initialize();
841
842	
843
844})();

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.