var scrollspeed = 5000;
canTick = true;
function prep(){
$(document).on('page:fetch', function() { NProgress.start(); })
$(document).on('page:change', function() { NProgress.done(); })
$(document).on('page:restore', function() { NProgress.remove(); })
$('.article-header-menu').removeClass('scrolled');
$('.ticker-container ul div').each(function(i) {
if ($(window).width() >= 500) {
$(this).find('li').width($(window).width() - parseInt($(this).css('left')));
}
if (i == 0) {
$(this).addClass('ticker-active');
} else {
$(this).addClass('not-active');
}
if ($(this).find('li').height() > 30) {
$(this).find('li').css({
'height': '20px',
'width': '200%',
'text-align': 'right',
'padding-right': '5px'
});
$(this).find('li').css('width', $(this).find('li span').width());
}
});
startTicker();
animateTickerElementHorz();
var polyfillAmdUrl =
"https://cdn.jsdelivr.net/npm/intersection-observer-amd@2.0.1/intersection-observer.amd.min.js";
var dependencies = [
"IntersectionObserver" in window ? null : polyfillAmdUrl,
"./assets/js/lazy.js"
];
var callback_error = function (element) {
element.src = "/assets/logosc.jpg";
};
require(dependencies, function (_, LazyLoad) {
window.ll = new LazyLoad({
callback_error: callback_error
});
});
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
$(".next").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
right = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({
'transform': 'scale('+scale+')',
'position': 'absolute'
});
next_fs.css({'right': right, 'opacity': opacity});
},
duration: 600,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
$(".previous").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
previous_fs = $(this).parent().prev();
//de-activate current step on progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
//show the previous fieldset
previous_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale previous_fs from 80% to 100%
scale = 0.8 + (1 - now) * 0.2;
//2. take current_fs to the right(50%) - from 0%
right = ((1-now) * 50)+"%";
//3. increase opacity of previous_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'right': right});
previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
},
duration: 600,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
$(window).scroll(function(event){
var target = $(".article-header-menu");
target.addClass('scrolled');
});
var distance = $('.article-header-menu').offset().top,
$window = $(window);
$window.scroll(function() {
if ( $window.scrollTop() === distance ) {
var target = $(".article-header-menu");
target.removeClass('scrolled');
}
});
$(".submit").click(function(){
return false;
})
}
$(window).resize(function() {
$('.ticker-container ul div').each(function(i) {
if ($(this).find('li').height() > 30) {
$(this).css({
'height': '20px',
'width': '200%',
'text-align': 'right',
'padding-right': '5px'
});
$(this).find('li').css('width', $(this).find('li span').width());
}
});
});
function startTicker() {
setInterval(function() {
if (canTick) {
$('.ticker-container ul div.ticker-active')
.removeClass('ticker-active')
.addClass('remove');
if ($('.ticker-container ul div.remove').next().length) {
$('.ticker-container ul div.remove')
.next()
.addClass('next');
} else {
$('.ticker-container ul div')
.first()
.addClass('next');
}
$('.ticker-container ul div.next')
.removeClass('not-active next')
.addClass('ticker-active');
setTimeout(function() {
$('.ticker-container ul div.remove')
.css('transition', '0s ease-in-out')
.removeClass('remove')
.addClass('not-active finished');
if ($(window).width() < 500) {
if ($('.ticker-container ul div.finished li').width() < $(window).width()) {
$('.ticker-container ul div.finished').removeClass('finished');
}
} else {
if ($('.ticker-container ul div.finished li').width() < ($(window).width() - (parseInt($('.ticker-container ul div.ticker-active').css('left')) + 15))) {
$('.ticker-container ul div.finished').removeClass('finished');
}
}
setTimeout(function() {
$('.ticker-container ul div')
.css('transition', '0.25s ease-in-out');
}, 75);
animateTickerElementHorz();
}, 250);
}
}, scrollspeed);
}
function animateTickerElementHorz() {
if ($(window).width() < 500) {
if ($('.ticker-container ul div.ticker-active li').width() > $(window).width()) {
setTimeout(function() {
$('.ticker-container ul div.ticker-active li').animate({
'margin-left': '-' + (($('.ticker-container ul div.ticker-active li').width() - $(window).width()) + 15)
}, scrollspeed - (scrollspeed / 5), 'swing', function() {
setTimeout(function() {
$('.ticker-container ul div.finished').removeClass('finished').find('li').css('margin-left', 0);
}, ((scrollspeed / 5) / 2));
});
}, ((scrollspeed / 5) / 2));
}
} else {
if ($('.ticker-container ul div.ticker-active li').width() > ($(window).width() - parseInt($('.ticker-container ul div.ticker-active').css('left')))) {
setTimeout(function() {
$('.ticker-container ul div.ticker-active li').animate({
'margin-left': Math.abs($('.ticker-container ul div.ticker-active li').width() - ($(window).width() - parseInt($('.ticker-container ul div.ticker-active').css('left'))) + 15) * -1
}, scrollspeed - (scrollspeed / 5), 'swing', function() {
setTimeout(function() {
$('.ticker-container ul div.finished').removeClass('finished').find('li').css('margin-left', 0);
}, ((scrollspeed / 5) / 2));
});
}, ((scrollspeed / 5) / 2));
}
}
}
$('.ticker-container').on('mouseover', function() {
canTick = false;
});
$('.ticker-container').on('mouseout', function() {
canTick = true;
});
/*! NProgress (c) 2013, Rico Sta. Cruz
* http://ricostacruz.com/nprogress */
;(function(factory) {
if (typeof module === 'function') {
module.exports = factory(this.jQuery || require('jquery'));
} else {
this.NProgress = factory(this.jQuery);
}
})(function($) {
var NProgress = {};
NProgress.version = '0.1.2';
var Settings = NProgress.settings = {
minimum: 0.08,
easing: 'ease',
positionUsing: '',
speed: 200,
trickle: true,
trickleRate: 0.02,
trickleSpeed: 800,
showSpinner: true,
template: '
'
};
/**
* Updates configuration.
*
* NProgress.configure({
* minimum: 0.1
* });
*/
NProgress.configure = function(options) {
$.extend(Settings, options);
return this;
};
/**
* Last number.
*/
NProgress.status = null;
/**
* Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
*
* NProgress.set(0.4);
* NProgress.set(1.0);
*/
NProgress.set = function(n) {
var started = NProgress.isStarted();
n = clamp(n, Settings.minimum, 1);
NProgress.status = (n === 1 ? null : n);
var $progress = NProgress.render(!started),
$bar = $progress.find('[role="bar"]'),
speed = Settings.speed,
ease = Settings.easing;
$progress[0].offsetWidth; /* Repaint */
$progress.queue(function(next) {
// Set positionUsing if it hasn't already been set
if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
// Add transition
$bar.css(barPositionCSS(n, speed, ease));
if (n === 1) {
// Fade out
$progress.css({ transition: 'none', opacity: 1 });
$progress[0].offsetWidth; /* Repaint */
setTimeout(function() {
$progress.css({ transition: 'all '+speed+'ms linear', opacity: 0 });
setTimeout(function() {
NProgress.remove();
next();
}, speed);
}, speed);
} else {
setTimeout(next, speed);
}
});
return this;
};
NProgress.isStarted = function() {
return typeof NProgress.status === 'number';
};
/**
* Shows the progress bar.
* This is the same as setting the status to 0%, except that it doesn't go backwards.
*
* NProgress.start();
*
*/
NProgress.start = function() {
if (!NProgress.status) NProgress.set(0);
var work = function() {
setTimeout(function() {
if (!NProgress.status) return;
NProgress.trickle();
work();
}, Settings.trickleSpeed);
};
if (Settings.trickle) work();
return this;
};
/**
* Hides the progress bar.
* This is the *sort of* the same as setting the status to 100%, with the
* difference being `done()` makes some placebo effect of some realistic motion.
*
* NProgress.done();
*
* If `true` is passed, it will show the progress bar even if its hidden.
*
* NProgress.done(true);
*/
NProgress.done = function(force) {
if (!force && !NProgress.status) return this;
return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
};
/**
* Increments by a random amount.
*/
NProgress.inc = function(amount) {
var n = NProgress.status;
if (!n) {
return NProgress.start();
} else {
if (typeof amount !== 'number') {
amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
}
n = clamp(n + amount, 0, 0.994);
return NProgress.set(n);
}
};
NProgress.trickle = function() {
return NProgress.inc(Math.random() * Settings.trickleRate);
};
/**
* (Internal) renders the progress bar markup based on the `template`
* setting.
*/
NProgress.render = function(fromStart) {
if (NProgress.isRendered()) return $("#nprogress");
$('html').addClass('nprogress-busy');
var $el = $("")
.html(Settings.template);
var perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0);
$el.find('[role="bar"]').css({
transition: 'all 0 linear',
transform: 'translate3d('+perc+'%,0,0)'
});
if (!Settings.showSpinner)
$el.find('[role="spinner"]').remove();
$el.appendTo(document.body);
return $el;
};
/**
* Removes the element. Opposite of render().
*/
NProgress.remove = function() {
$('html').removeClass('nprogress-busy');
$('#nprogress').remove();
};
/**
* Checks if the progress bar is rendered.
*/
NProgress.isRendered = function() {
return ($("#nprogress").length > 0);
};
/**
* Determine which positioning CSS rule to use.
*/
NProgress.getPositioningCSS = function() {
// Sniff on document.body.style
var bodyStyle = document.body.style;
// Sniff prefixes
var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
('MozTransform' in bodyStyle) ? 'Moz' :
('msTransform' in bodyStyle) ? 'ms' :
('OTransform' in bodyStyle) ? 'O' : '';
if (vendorPrefix + 'Perspective' in bodyStyle) {
// Modern browsers with 3D support, e.g. Webkit, IE10
return 'translate3d';
} else if (vendorPrefix + 'Transform' in bodyStyle) {
// Browsers without 3D support, e.g. IE9
return 'translate';
} else {
// Browsers without translate() support, e.g. IE7-8
return 'margin';
}
};
/**
* Helpers
*/
function clamp(n, min, max) {
if (n < min) return min;
if (n > max) return max;
return n;
}
/**
* (Internal) converts a percentage (`0..1`) to a bar translateX
* percentage (`-100%..0%`).
*/
function toBarPerc(n) {
return (-1 + n) * 100;
}
/**
* (Internal) returns the correct CSS for changing the bar's
* position given an n percentage, and speed and ease from Settings
*/
function barPositionCSS(n, speed, ease) {
var barCSS;
if (Settings.positionUsing === 'translate3d') {
barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
} else if (Settings.positionUsing === 'translate') {
barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
} else {
barCSS = { 'margin-left': toBarPerc(n)+'%' };
}
barCSS.transition = 'all '+speed+'ms '+ease;
return barCSS;
}
return NProgress;
});
/*
$('.speaker').click(function(e) {
toggleMute('video-ad-top-main');
});
$('.boxclose').click(function(e) {
$('.video-ad-top-main').remove();
});
document.getElementById('video-ad-top-main').addEventListener('ended',myHandler,false);
function myHandler(e) {
$(this).closest('.video-ad-top-main').remove();
}
$(document).on('click','.unmute', function() {
toggleMute("video-ad-top-main");
});
function toggleMute(v) {
var video=document.getElementById(v);
video.muted = !video.muted;
$(".speaker").toggleClass('on');
}
*/
/*
(function($) {
'use strict';
// call our plugin
var Nav = new hcOffcanvasNav('#main-nav', {
disableAt: false,
customToggle: '.toggle',
levelSpacing: 40,
navTitle: 'القائمة',
levelTitles: true,
levelTitleAsBack: true,
pushContent: '.wrap',
labelClose: false,
position: 'right'
});
// add new items to original nav
$('#main-nav').find('li.add').children('a').on('click', function() {
var $this = $(this);
var $li = $this.parent();
var items = eval('(' + $this.attr('data-add') + ')');
$li.before('
'+items[0]+'');
items.shift();
if (!items.length) {
$li.remove();
}
else {
$this.attr('data-add', JSON.stringify(items));
}
Nav.update(true); // update DOM
});
// demo settings update
const update = function(settings) {
if (Nav.isOpen()) {
Nav.on('close.once', function() {
Nav.update(settings);
Nav.open();
});
Nav.close();
}
else {
Nav.update(settings);
}
};
$('.actions').find('a').on('click', function(e) {
e.preventDefault();
var $this = $(this).addClass('active');
var $siblings = $this.parent().siblings().children('a').removeClass('active');
var settings = eval('(' + $this.data('demo') + ')');
update(settings);
});
$('.actions').find('input').on('change', function() {
var $this = $(this);
var settings = eval('(' + $this.data('demo') + ')');
if ($this.is(':checked')) {
update(settings);
}
else {
var removeData = {};
$.each(settings, function(index, value) {
removeData[index] = false;
});
update(removeData);
}
});
})(jQuery);*//*
$.fn.isInViewport = function() {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return viewportBottom - elementBottom > 0 || viewportTop - elementTop === 50
};
$(window).on('resize scroll', function() {
$('.section').each(function() {
// var activeColor = $(this).attr('id');
if ($(this).isInViewport()) {
// $('#fixed-' + activeColor).addClass(activeColor + '-active');
$(this).addClass('fixedheader');
} else {
$(this).removeClass('fixedheader');
}
});
});
*/
//jQuery time
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('#navbar').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('#navbar').removeClass('nav-down').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('#navbar').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
}
$(function(){
'use strict';
var $page = $('#main'),
options = {
debug: true,
prefetch: true,
cacheLength: 12,
onStart: {
duration: 0, // Duration of our animation
render: function ($container) {
// Add your CSS animation reversing class
$container.addClass('is-exiting');
// Restart your animation
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
// Remove your CSS animation reversing class
$container.removeClass('is-exiting');
// Inject the new content
$container.html($newContent);
}
},
onAfter: function( $container, $newContent ) {
}
},
smoothState = $page.smoothState(options).data('smoothState');
$('#navbar').removeClass('nav-up').addClass('nav-down');
});
$(document).ready(function(){
prep();
});
$('#main').smoothState({
onAfter: function() {
prep();
}
});
$(document)
.on('.m-button:click', function() {
NProgress.start();
})
.on('.m-button:render', function() {
NProgress.done(); // to work with the above method on first visit
NProgress.remove(); // to work on back btn click, restore event
});