!function(window, document, $) { "use strict"; var Typed = function(el, options) { var self = this; this.el = el; this.options = {}; Object.keys(defaults).forEach(function(key) { self.options[key] = defaults[key]; }); Object.keys(options).forEach(function(key) { self.options[key] = options[key]; }); this.isInput = this.el.tagName.toLowerCase() === 'input'; this.attr = this.options.attr; this.showCursor = this.isInput ? false : this.options.showCursor; this.elContent = this.attr ? this.el.getAttribute(this.attr) : this.el.textContent; this.contentType = this.options.contentType; this.typeSpeed = this.options.typeSpeed; this.startDelay = this.options.startDelay; this.backSpeed = this.options.backSpeed; this.backDelay = this.options.backDelay; this.fadeOut = this.options.fadeOut; this.fadeOutClass = this.options.fadeOutClass; this.fadeOutDelay = this.options.fadeOutDelay; if($ && this.options.stringsElement instanceof $) { this.stringsElement = this.options.stringsElement[0]; } else { this.stringsElement = this.options.stringsElement; } this.strings = this.options.strings; this.strPos = 0; this.arrayPos = 0; this.stopNum = 0; this.loop = this.options.loop; this.loopCount = this.options.loopCount; this.curLoop = 0; this.stop = false; this.cursorChar = this.options.cursorChar; this.shuffle = this.options.shuffle; this.sequence = []; this.build(); }; Typed.prototype = { constructor: Typed, init: function() { var self = this; self.timeout = setTimeout(function() { for (var i = 0; i < self.strings.length; ++i) self.sequence[i] = i; if (self.shuffle) self.sequence = self.shuffleArray(self.sequence); self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos); }, self.startDelay); }, build: function() { var self = this; if (this.showCursor === true) { this.cursor = document.createElement('span'); this.cursor.className = 'typed-cursor'; this.cursor.innerHTML = this.cursorChar; this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling); } if (this.stringsElement) { this.strings = []; this.stringsElement.style.display = 'none'; var strings = Array.prototype.slice.apply(this.stringsElement.children); strings.forEach(function(stringElement) { self.strings.push(stringElement.innerHTML); }); } this.init(); }, typewrite: function(curString, curStrPos) { if (this.stop === true) return; if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) { this.el.classList.remove(this.fadeOutClass); this.cursor.classList.remove(this.fadeOutClass); } var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed; var self = this; self.timeout = setTimeout(function() { var charPause = 0; var substr = curString.substr(curStrPos); if (substr.charAt(0) === '^') { var skip = 1; if (/^\^\d+/.test(substr)) { substr = /\d+/.exec(substr)[0]; skip += substr.length; charPause = parseInt(substr); } curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip); } if (self.contentType === 'html') { var curChar = curString.substr(curStrPos).charAt(0); if (curChar === '<' || curChar === '&') { var tag = ''; var endTag = curChar === '<' ? '>' : ';'; while (curString.substr(curStrPos + 1).charAt(0) !== endTag) { tag += curString.substr(curStrPos).charAt(0); curStrPos++; if (curStrPos + 1 > curString.length) break; } curStrPos++; tag += endTag; } } self.timeout = setTimeout(function() { if (curStrPos === curString.length) { self.options.onStringTyped(self.arrayPos); if (self.arrayPos === self.strings.length - 1) { self.options.callback(); self.curLoop++; if (self.loop === false || self.curLoop === self.loopCount) return; } self.timeout = setTimeout(function() { self.backspace(curString, curStrPos); }, self.backDelay); } else { if (curStrPos === 0) self.options.preStringTyped(self.arrayPos); var nextString = curString.substr(0, curStrPos + 1); if (self.attr) { self.el.setAttribute(self.attr, nextString); } else { if (self.isInput) { self.el.value = nextString; } else if (self.contentType === 'html') { self.el.innerHTML = nextString; } else { self.el.textContent = nextString; } } curStrPos++; self.typewrite(curString, curStrPos); } }, charPause); }, humanize); }, backspace: function(curString, curStrPos) { if (this.stop === true) return; if (this.fadeOut) { this.initFadeOut(); return; } var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed; var self = this; self.timeout = setTimeout(function() { if (self.contentType === 'html') { if (curString.substr(curStrPos).charAt(0) === '>') { var tag = ''; while (curString.substr(curStrPos - 1).charAt(0) !== '<') { tag -= curString.substr(curStrPos).charAt(0); curStrPos--; if (curStrPos < 0) break; } curStrPos--; tag += '<'; } } var nextString = curString.substr(0, curStrPos); self.replaceText(nextString); if (curStrPos > self.stopNum) { curStrPos--; self.backspace(curString, curStrPos); } else if (curStrPos <= self.stopNum) { self.arrayPos++; if (self.arrayPos === self.strings.length) { self.arrayPos = 0; if (self.shuffle) self.sequence = self.shuffleArray(self.sequence); self.init(); } else { self.typewrite(self.strings[self.sequence[self.arrayPos]], curStrPos); } } }, humanize); }, initFadeOut: function() { self = this; this.el.className += ' ' + this.fadeOutClass; this.cursor.className += ' ' + this.fadeOutClass; return setTimeout(function() { self.arrayPos++; self.replaceText(''); self.typewrite(self.strings[self.sequence[self.arrayPos]], 0); }, self.fadeOutDelay); }, replaceText: function(str) { if (this.attr) { this.el.setAttribute(this.attr, str); } else { if (this.isInput) { this.el.value = str; } else if (this.contentType === 'html') { this.el.innerHTML = str; } else { this.el.textContent = str; } } }, shuffleArray: function(array) { var tmp, current, top = array.length; if (top) while (--top) { current = Math.floor(Math.random() * (top + 1)); tmp = array[current]; array[current] = array[top]; array[top] = tmp; } return array; }, reset: function() { var self = this; clearInterval(self.timeout); var id = this.el.getAttribute('id'); this.el.textContent = ''; if (typeof this.cursor !== 'undefined' && typeof this.cursor.parentNode !== 'undefined') { this.cursor.parentNode.removeChild(this.cursor); } this.strPos = 0; this.arrayPos = 0; this.curLoop = 0; this.options.resetCallback(); } }; Typed.new = function(selector, option) { var elements = Array.prototype.slice.apply(document.querySelectorAll(selector)); elements.forEach(function(element) { var instance = element._typed, options = typeof option == 'object' && option; if (instance) { instance.reset(); } element._typed = instance = new Typed(element, options); if (typeof option == 'string') instance[option](); }); }; if ($) { $.fn.typed = function(option) { return this.each(function() { var $this = $(this), data = $this.data('typed'), options = typeof option == 'object' && option; if (data) { data.reset(); } $this.data('typed', (data = new Typed(this, options))); if (typeof option == 'string') data[option](); }); }; } window.Typed = Typed; var defaults = { strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"], stringsElement: null, typeSpeed: 0, startDelay: 0, backSpeed: 0, shuffle: false, backDelay: 500, fadeOut: false, fadeOutClass: 'typed-fade-out', fadeOutDelay: 500, loop: true, loopCount: false, showCursor: true, cursorChar: "|", attr: null, contentType: 'html', callback: function() {}, preStringTyped: function() {}, onStringTyped: function() {}, resetCallback: function() {} }; }(window, document, window.jQuery); document.addEventListener('DOMContentLoaded', function() { Typed.new("#typed", { stringsElement: document.getElementById('typed-strings'), typeSpeed: 60, backDelay: 1000, loop: true, contentType: 'html', loopCount: null, callback: function() { foo(); }, resetCallback: function() { newTyped(); } }); var resetElement = document.querySelector('.reset'); if (resetElement) { resetElement.addEventListener('click', function() { document.getElementById('typed')._typed.reset(); }); } // Digital Business Card Logic const overlay = document.getElementById('businessCardOverlay'); const container = document.getElementById('businessCardContainer'); const closeBtn = document.getElementById('closeCardBtn'); function checkOrientation() { if (window.innerHeight > window.innerWidth) { container.classList.add('portrait'); } else { container.classList.remove('portrait'); } } function showBusinessCard() { overlay.style.display = 'flex'; checkOrientation(); document.body.style.overflow = 'hidden'; // Prevent background scrolling } function hideBusinessCard() { overlay.style.display = 'none'; document.body.style.overflow = 'auto'; // Re-enable scrolling } // Check URL hash on load if (window.location.hash === '#vc') { showBusinessCard(); } // Listen for hash changes window.addEventListener('hashchange', function() { if (window.location.hash === '#vc') { showBusinessCard(); } else { hideBusinessCard(); } }); // Close button event closeBtn.addEventListener('click', function() { window.location.hash = ''; // Remove hash from URL hideBusinessCard(); }); // Update orientation on resize window.addEventListener('resize', checkOrientation); }); function newTyped() {} function foo() { console.log("Callback"); } (function($) { $.flexslider = function(c, b) { var d = c; d.init = function() { d.vars = $.extend({}, $.flexslider.defaults, b); d.data("flexslider", true); d.container = $(".slides", d); d.slides = $(".slides > li", d); d.count = d.slides.length; d.animating = false; d.currentSlide = d.vars.slideToStart; d.animatingTo = d.currentSlide; d.atEnd = (d.currentSlide == 0) ? true : false; d.eventType = ("ontouchstart" in document.documentElement) ? "touchstart" : "click"; d.cloneCount = 0; d.cloneOffset = 0; if (d.vars.controlsContainer != "") { d.controlsContainer = $(d.vars.controlsContainer).eq($(".slides").index(d.container)); d.containerExists = d.controlsContainer.length > 0; } if (d.vars.manualControls != "") { d.manualControls = $(d.vars.manualControls, ((d.containerExists) ? d.controlsContainer : d)); d.manualExists = d.manualControls.length > 0; } if (d.vars.randomize) { d.slides.sort(function() { return (Math.round(Math.random()) - 0.5); }); d.container.empty().append(d.slides); } if (d.vars.animation.toLowerCase() == "slide") { d.css({ overflow: "hidden" }); if (d.vars.animationLoop) { d.cloneCount = 2; d.cloneOffset = 1; d.container.append(d.slides.filter(":first").clone().addClass("clone")).prepend(d.slides.filter(":last").clone().addClass("clone")); } d.container.width(((d.count + d.cloneCount) * d.width()) + 2000); d.newSlides = $(".slides > li", d); setTimeout(function() { d.newSlides.width(d.width()).css({ "float": "left" }).show(); }, 100); d.container.css({ marginLeft: (-1 * (d.currentSlide + d.cloneOffset)) * d.width() + "px" }); } else { d.slides.css({ "z-index": "0", width: "100%", "float": "left", marginRight: "-100%" }).eq(d.currentSlide).fadeIn(400); } if (d.vars.controlNav) { if (d.manualExists) { d.controlNav = d.manualControls; } else { var g = $('
    '); var k = 1; for (var l = 0; l < d.count; l++) { g.append("
  1. " + k + "
  2. "); k++; } if (d.containerExists) { $(d.controlsContainer).append(g); d.controlNav = $(".flex-control-nav li a", d.controlsContainer); } else { d.append(g); d.controlNav = $(".flex-control-nav li a", d); } } d.controlNav.eq(d.currentSlide).addClass("active"); d.controlNav.bind(d.eventType, function(i) { i.preventDefault(); if (!$(this).hasClass("active")) { d.flexAnimate(d.controlNav.index($(this)), d.vars.pauseOnAction); } }); } if (d.vars.directionNav) { var f = $('"); if (d.containerExists) { $(d.controlsContainer).append(f); d.directionNav = $(".flex-direction-nav li a", d.controlsContainer); } else { d.append(f); d.directionNav = $(".flex-direction-nav li a", d); } if (!d.vars.animationLoop) { if (d.currentSlide == 0) { d.directionNav.filter(".prev").addClass("disabled"); } else if (d.currentSlide == d.count - 1) { d.directionNav.filter(".next").addClass("disabled"); } } d.directionNav.bind(d.eventType, function(i) { i.preventDefault(); var j = ($(this).hasClass("next")) ? d.getTarget("next") : d.getTarget("prev"); if (d.canAdvance(j)) { d.flexAnimate(j, d.vars.pauseOnAction); } }); } if (d.vars.keyboardNav && $("ul.slides").length == 1) { $(document).keyup(function(i) { if (d.animating) return; if (i.keyCode != 39 && i.keyCode != 37) return; var j = (i.keyCode == 39) ? d.getTarget("next") : d.getTarget("prev"); if (d.canAdvance(j)) { d.flexAnimate(j, d.vars.pauseOnAction); } }); } if (d.vars.slideshow) { if (d.vars.pauseOnHover && d.vars.slideshow) { d.hover(function() { d.pause(); }, function() { d.resume(); }); } d.animatedSlides = setInterval(d.animateSlides, d.vars.slideshowSpeed); } if (d.vars.pausePlay) { var e = $('
    '); if (d.containerExists) { d.controlsContainer.append(e); d.pausePlay = $(".flex-pauseplay span", d.controlsContainer); } else { d.append(e); d.pausePlay = $(".flex-pauseplay span", d); } var h = (d.vars.slideshow) ? "pause" : "play"; d.pausePlay.addClass(h).text((h == "pause") ? d.vars.pauseText : d.vars.playText); d.pausePlay.click(function(i) { i.preventDefault(); ($(this).hasClass("pause")) ? d.pause() : d.resume(); }); } if (d.vars.touchSwipe && "ontouchstart" in document.documentElement) { d.each(function() { var i, j = 20; var isMoving = false; function o() { this.removeEventListener("touchmove", m); i = null; isMoving = false; } function m(s) { if (isMoving) { var p = s.touches[0].pageX, q = i - p; if (Math.abs(q) >= j) { o(); var r = (q > 0) ? d.getTarget("next") : d.getTarget("prev"); if (d.canAdvance(r)) { d.flexAnimate(r, d.vars.pauseOnAction); } } } } function n(p) { if (p.touches.length == 1) { i = p.touches[0].pageX; isMoving = true; this.addEventListener("touchmove", m, false); } } if ("ontouchstart" in document.documentElement) { this.addEventListener("touchstart", n, false); } }); } if (d.vars.animation.toLowerCase() == "slide") { d.sliderTimer; $(window).resize(function() { d.newSlides.width(d.width()); d.container.width(((d.count + d.cloneCount) * d.width()) + 2000); clearTimeout(d.sliderTimer); d.sliderTimer = setTimeout(function() { d.flexAnimate(d.currentSlide); }, 300); }); } d.vars.start(d); }; d.flexAnimate = function(f, e) { if (!d.animating) { d.animating = true; d.animatingTo = f; d.vars.before(d); if (e) d.pause(); if (d.vars.controlNav) { d.controlNav.removeClass("active").eq(f).addClass("active"); } d.atEnd = (f == 0 || f == d.count - 1) ? true : false; if (!d.vars.animationLoop && d.vars.directionNav) { if (f == 0) { d.directionNav.removeClass("disabled").filter(".prev").addClass("disabled"); } else if (f == d.count - 1) { d.directionNav.removeClass("disabled").filter(".next").addClass("disabled"); } else { d.directionNav.removeClass("disabled"); } } if (!d.vars.animationLoop && f == d.count - 1) { d.pause(); d.vars.end(d); } if (d.vars.animation.toLowerCase() == "slide") { if (d.currentSlide == 0 && f == d.count - 1 && d.vars.animationLoop && d.direction != "next") { d.slideString = "0px"; } else if (d.currentSlide == d.count - 1 && f == 0 && d.vars.animationLoop && d.direction != "prev") { d.slideString = (-1 * (d.count + 1)) * d.slides.filter(":first").width() + "px"; } else { d.slideString = (-1 * (f + d.cloneOffset)) * d.slides.filter(":first").width() + "px"; } d.container.animate({ marginLeft: d.slideString }, d.vars.animationDuration, function() { if (d.currentSlide == 0 && f == d.count - 1 && d.vars.animationLoop) { d.container.css({ marginLeft: (-1 * d.count) * d.slides.filter(":first").width() + "px" }); } else if (d.currentSlide == d.count - 1 && f == 0 && d.vars.animationLoop) { d.container.css({ marginLeft: -1 * d.slides.filter(":first").width() + "px" }); } d.animating = false; d.currentSlide = f; d.vars.after(d); }); } else { d.slides.eq(d.currentSlide).fadeOut(d.vars.animationDuration); d.slides.eq(f).fadeIn(d.vars.animationDuration, function() { d.animating = false; d.currentSlide = f; d.vars.after(d); }); } } }; d.animateSlides = function() { if (!d.animating) { var e = (d.currentSlide == d.count - 1) ? 0 : d.currentSlide + 1; d.flexAnimate(e); } }; d.pause = function() { clearInterval(d.animatedSlides); if (d.vars.pausePlay) { d.pausePlay.removeClass("pause").addClass("play").text(d.vars.playText); } }; d.resume = function() { d.animatedSlides = setInterval(d.animateSlides, d.vars.slideshowSpeed); if (d.vars.pausePlay) { d.pausePlay.removeClass("play").addClass("pause").text(d.vars.pauseText); } }; d.canAdvance = function(e) { if (!d.vars.animationLoop && d.atEnd) { if (d.currentSlide == 0 && e == d.count - 1 && d.direction != "next") { return false; } else if (d.currentSlide == d.count - 1 && e == 0 && d.direction == "next") { return false; } else { return true; } } else { return true; } }; d.getTarget = function(e) { d.direction = e; if (e == "next") { return (d.currentSlide == d.count - 1) ? 0 : d.currentSlide + 1; } else { return (d.currentSlide == 0) ? d.count - 1 : d.currentSlide - 1; } }; d.init(); }; $.flexslider.defaults = { animation: "fade", slideshow: true, slideshowSpeed: 5000, animationDuration: 1400, directionNav: true, controlNav: true, keyboardNav: true, touchSwipe: true, prevText: "", nextText: "", pausePlay: false, pauseText: "توقف", playText: "پخش", randomize: false, slideToStart: 0, animationLoop: true, pauseOnAction: false, pauseOnHover: false, controlsContainer: "", manualControls: "", start: function() {}, before: function() {}, after: function() {}, end: function() {} }; $.fn.flexslider = function(b) { return this.each(function() { if ($(this).find(".slides li").length == 1) { $(this).find(".slides li").fadeIn(400); } else if ($(this).data("flexslider") != true) { new $.flexslider($(this), b); } }); }; })(jQuery); var $ = jQuery.noConflict(); $(window).load(function() { $('.flexslider').flexslider({ animation: "fade" }); $('.show_menu').click(function() { $('.menu').fadeIn(); $('.show_menu').fadeOut(); $('.hide_menu').fadeIn(); }); $('.hide_menu').click(function() { $('.menu').fadeOut(); $('.show_menu').fadeIn(); $('.hide_menu').fadeOut(); }); });