| Server IP : 172.64.80.1 / Your IP : 172.70.50.105 Web Server : Apache System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64 User : federalpolyede.edu.ng_idh35skikv ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/federalpolyede.edu.ng/phd_code/securitymodel/static/js/ |
Upload File : |
/**
* Created by Lenovo on 1/10/2022.
*/
// ========================================================================================================
// Don't tamper my touchable carousel(Image slider) function
$(function () {
var carousels = $('.carousel');
carousels.each(function (i) {
var element = $(this);
element.carousel();
element.find('.left').click(function () {element.carousel('prev')});
element.find('.right').click(function () {element.carousel('next')});
element.touchStartX = element.touchEndX = 0;
element.distance = 100;
element.handleTS = function (event) {
if (event.touches && event.touches.length > 0) element.touchStartX = event.touches[0].clientX;
};
element.handleTM = function (event) {
element.touchEndX = 0
if (event.touches && event.touches.length > 0) element.touchEndX = event.touches[0].clientX;
};
element.handleTE = function (event) {
var space = element.touchEndX - element.touchStartX;
console.log(element.touchStartX, element.touchEndX, space)
if (space > element.distance) element.carousel('prev')
else if (space < -element.distance) element.carousel('next')
};
element.ce = document.getElementsByClassName('carousel')[i];
element.ce.addEventListener('touchstart', element.handleTS);
element.ce.addEventListener('touchmove', element.handleTM);
element.ce.addEventListener('touchend', element.handleTE);
})
});
// ========================================================================================================
//------------------------------------------------
$(document).ready(function () {
//$('.content-wrapper').attr("tabindex","-1").focus();
//new//
document.addEventListener('touchstart', handleTouchStart, false);
document.addEventListener('touchmove', handleTouchMove, false);
var xDown = null;
var yDown = null;
function handleTouchStart(evt) {
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
}
function handleTouchMove(evt) {
if ( ! xDown || ! yDown ) {
return;
}
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
var xDiff = xDown - xUp;
var yDiff = yDown - yUp;
if(Math.abs( xDiff )+Math.abs( yDiff )>150){ //to deal with to short swipes
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
if ( xDiff < 0 ) {/* left swipe */
scroll();
}else{
if(c==1)scroll();
}
}
/* reset values */
xDown = null;
yDown = null;
}
}
//+++
$("#toggle").on("click", function () {
$("body").toggleClass("open");
});var c=0;
$("#toggle1").on("click", function () {
scroll();
});
var nav = document.getElementById("aside-full");
$(window).on("click", function (e) {
if(e.target==nav){
scroll();
}
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
function scroll(){
$("body").toggleClass("open");
c+=1;
if(c==1){
$("aside").css({"display":"block"});
$("aside").animate({left:'0'},150);
$(".aside-full").css({"display":"block"});
$(".aside-full").animate({left:'0'},100);
}
if(c==2){
$("aside").css({"display":"block"});
$("aside").animate({left:'-150vh'},400);
$(".aside-full").css({"display":"block"});
$(".aside-full").animate({left:'-300vh'},100);
c=0;
}
}
});
//------------------------------------------------
$(window).ready(function(){
$(".loading").fadeOut("slow")
});
// ========================================================================================================
// Don't tamper my toast(short-time message) function
var toast = function () {
var tm = this;
this.con = $('.notifications').length === 0 ? $('<ul class="notifications"></ul>').insertAfter($('body')) : $('.notifications');
this.default = {
timer: 5000,
pos: 'top-right',
success: {icon: 'fa-check-circle', text: 'Success: This is a success toast.'},
error: {icon: 'fa-times-circle', text: 'Error: This is an error toast.'},
warning: {icon: 'fa-exclamation-triangle', text: 'Warning: This is a warning toast.'},
info: {icon: 'fa-info-circle', text: 'Info: This is an information toast.'}
};
this.applyPos = function (toast) {
var pos = toast.pos;
if (pos == 'top-left')
$(toast).parent().css('top', '60px').css('bottom', '').css('right', '').css('transform', '').css('left', '0');
else if (pos == 'top-center')
$(toast).parent().css('top', '60px').css('left', '50%').css('bottom', '').css('right', '').css('transform', 'translateX(-50%)');
else if (pos == 'bottom-right')
$(toast).parent().css('bottom', '20px').css('right', '0').css('top', '').css('left', '').css('transform', '');
else if (pos == 'bottom-left')
$(toast).parent().css('bottom', '20px').css('left', '0').css('top', '').css('right', '').css('transform', '');
else if (pos == 'bottom-center')
$(toast).parent().css('bottom', '20px').css('left', '50%').css('top', '').css('right', '').css('transform', 'translateX(-50%)');
else if (pos == 'left-center')
$(toast).parent().css('top', '50%').css('left', '0').css('bottom', '').css('right', '').css('transform', 'translateY(-50%)');
else if (pos == 'right-center')
$(toast).parent().css('top', '50%').css('right', '0').css('bottom', '').css('left', '').css('transform', 'translateY(-50%)');
else if (pos == 'middle')
$(toast).parent().css('top', '50%').css('left', '50%').css('bottom', '').css('right', '').css('transform', 'translateX(-50%) translateY(-50%)');
else
$(toast).parent().css('top', '60px').css('right', '0').css('bottom', '').css('left', '').css('transform', 'none');
};
this.removeToast = function (toast) {
toast.addClass("hide-toast");
if (toast.timeoutId) clearTimeout(toast.timeoutId);
setTimeout(function () {
toast.remove()
}, 1000);
};
this.createToast = function (options) {
var key = ['success', 'error', 'warning', 'info'];
this.option = (typeof options == 'object' && options) ? options : tm.default;
var id = key[Math.floor(Math.random() * 4)];
var text = this.option.text || tm.default[id].text,
icon = this.option.icon || id;
var toast = document.createElement("li");
toast.className = 'toast ' + icon;
toast.innerHTML =
'<div class="column"> ' +
'<i class="fa ' + this.default[icon].icon + '"></i> ' +
'<span>' + text + '</span> ' +
'<i class="fa fa-times close" onclick="new toast().removeToast($(this).parent().parent())"></i>' +
'<div class="indicator"></div></div> ';
tm.con.append(toast);
var timer = this.option.timer || tm.default.timer;
$(toast).find('.indicator').animate({width: 0}, timer, 'linear', 'forwards');
toast.pos = this.option.pos == undefined ? tm.default.pos : this.option.pos;
tm.con.children().length <= 1 ? tm.applyPos(toast) : '';
if (tm.con.children().length <= 1) {
if (['top-left', 'bottom-left', 'left-center'].includes(toast.pos))
$(toast).addClass('toast-l');
else if (['top-right', 'bottom-right', 'right-center'].includes(toast.pos))
$(toast).addClass('toast-r');
else
$(toast).addClass('toast-m');
} else $(toast).addClass($(toast).prev().attr('class').split(' ')[2]);
toast.timeoutId = setTimeout(function () {
tm.removeToast($(toast))
}, timer);
$(toast).hover(function (ev) {
clearTimeout(toast.timeoutId);
$(toast).find('.indicator').animate().stop().width(100 + '%');
}, function () {
$(toast).find('.indicator').animate({width: 0}, timer, 'linear', 'forwards');
toast.timeoutId = setTimeout(function () {
tm.removeToast($(toast))
}, timer);
});
}
};
function toast_it(option){
var toasts = new toast();
toasts.createToast(option);
}
// ========================================================================================================
$(document).ready(function () {
$('[data-toggle="tootip"]').tooltip();
var eles = $('section'), win = $(window);
win.on('scroll', check_in_view);
win.trigger('scroll');
function check_in_view(){
var win_h = win.height(),
win_t_pos = win.scrollTop(),
win_b_pos = (win_t_pos+win_h);
$.each(eles, function () {
var ele = $(this),
ele_h = ele.outerHeight(),
ele_t_pos = ele.offset().top,
ele_b_pos = (ele_t_pos + ele_h);
if((ele_b_pos >= win_t_pos) && (ele_t_pos <= win_b_pos)){
ele.addClass('fadeIn animated slow');
}else{
ele.removeClass('fadeIn animated slow');
}
})
}
});