Project refactored to use NPM package manager, jquery and created new features

This commit is contained in:
vinicius.reif
2019-09-05 13:26:09 -03:00
parent 4a37634e40
commit 2ba52ac5e7
60 changed files with 7739 additions and 43 deletions

61
src/js/tuicss.js Normal file
View File

@@ -0,0 +1,61 @@
/**
* Init
*/
$(document).ready(function() {
tabsController();
dateController();
sidenavController();
});
/**
* TuiTabs controller
*/
function tabsController() {
$(".tui-tab").click(function(event) {
$(".tui-tab-content").hide();
let tabContentid = $(this).attr('data-tab-content');
$(`#${tabContentid}`).show();
$(".tui-tab").removeClass("active");
$(this).addClass("active");
});
$('.tui-tab.active').click();
}
function dateController() {
let interval = setInterval(function () {
let today = new Date();
let clock = $(".tui-date");
if(!clock.length) {
clearInterval(interval);
return;
}
let format = clock.attr("data-format");
let month = (today.getMonth() + "").length == 2 ? today.getMonth() + 1 : "0" + (today.getMonth() + 1);
let day = (today.getDay() + "").length == 2 ? today.getDay() + 1 : "0" + (today.getDay() + 1);
let year = today.getFullYear();
let hour = (today.getHours() + "").length == 2 ? today.getHours() : "0" + today.getHours();
let minute = (today.getMinutes() + "").length == 2 ? today.getMinutes() : "0" + today.getMinutes();
let second = (today.getSeconds() + "").length == 2 ? today.getSeconds() : "0" + today.getSeconds();
format = format.replace("M", month);
format = format.replace("d", day);
format = format.replace("y", year);
format = format.replace("h", hour);
format = format.replace("m", minute);
format = format.replace("s", second);
clock.html(format);
});
}
function sidenavController() {
$(".tui-sidenav-button").click(function() {
let sidenav = $(".tui-sidenav");
if(sidenav.hasClass("active")) {
$(".tui-sidenav").removeClass("active");
} else {
$(".tui-sidenav").addClass("active");
}
});
}