Witam,
Chciałbym zapytać jak bardzo zły jest mój kody. Pisze dość "zaawansowaną" (jak nam mnie) aplikacje (zajmuje się frontendem). Jestem zadowolony z jej działania, ale mam pewną wątpliwość czy z takim kodem jest sens starać się o jaką kolwiek prace.
$('#dashapp_content').hide();
$("#dashapp_content").load("tpl/home.php", function() {
$('#dashapp_content').fadeIn('slow', function() {
});
});
/* change page function for main panel */
$(".nav > li").click(function() {
var link = $(this).find('a').attr('href');
if (link == undefined) {
return false;
}
$('#dashapp_content').hide();
$("#dashapp_content").load("tpl/" + link + ".php", function() {
$('#dashapp_content').fadeIn('slow', function() {
});
});
link = 0;
return false;
});
$(".dropdown-menu li").click(function() {
var parent = $(this).closest('.dropdown-submenu').find('a').attr('href');
var modal = $(this).find('a').attr('href');
$('#dashapp_content').hide();
$("#dashapp_content").load("tpl/" + parent + ".php", function() {
$('#dashapp_content').fadeIn('slow', function() {
$(modal).modal({
'show': true,
'backdrop': false
});
});
});
return false;
});
var jobs = [
{
"id": "1",
"started": "8:00",
"finished": "9:00",
"category": 'przetarg'},
{
"id": "2",
"started": "9:00",
"finished": "10:00",
"category": 'rozmowa z klientem'},
{
"id": "3",
"started": "10:00",
"finished": "11:00",
"category": 'papiery'},
{
"id": "4",
"started": "11:00",
"finished": "12:00",
"category": 'telefony'},
]
$.each(jobs, function(index, value) {
var tr = $('<tr>').appendTo('.today-duties');
$('<td>').append(value['id']).appendTo(tr);
$('<td>').append(value['started']).insertAfter('.today-duties td:last');
$('<td>').append(value['finished']).insertAfter('.today-duties td:last');
$('<td>').append(value['categoty']).insertAfter('.today-duties td:last');
$('<td>').append(value['misc']).insertAfter('.today-duties td:last');
});
/* Navigation sub menus */
/* Navigation icons boxes show */
$('#navigation i').click(function() {
var opened = $(this).data('opened');
var box_class = $(this).data('class');
var offset = $(this).offset();
console.log(opened);
$('.' + box_class).css({
'right': $(window).width() - (offset.left + $(this).outerWidth(true)) ,
'top': 40
});
if (opened == "no") {
$('#navigation').find(".opened").animate({height: '0px'}, 200, "swing", function() {
$(this).closest('.box').css('border', 'none');
$(this).closest('i').data("opened", "no");
$(this).find('.panel').hide('fast');
$(this).css('display', 'none').removeClass("opened");
});
$('.' + box_class).css({'display': 'block', 'height': 0}).animate({height: '150px'}, 200, "swing", function() {
$(this).closest('.box').css('border', 'none');
$(this).find('.panel').css('display', 'block');
$(this).addClass('opened');
});
$(this).data("opened", "yes");
}
if (opened == "yes") {
$('.' + box_class).animate({height: '0px'}, 200, "swing", function() {
$(this).closest('.box').css('border', 'none');
$(this).css('display', 'none').removeClass('opened');
$(this).find('.panel').hide('fast');
});
$(this).data("opened", "no");
}
});
$('.mainsearch').click(function() {
var offset = $(this).offset();
if ($('.mainsearch_box').hasClass('slided')) {
$('.slided').hide('slide', {direction: 'right'}, 200).removeClass('slided');
} else {
$('.mainsearch_box').css({
position: 'absolute',
right: 80,
top: offset.top - 20,
display: 'block'
}).effect("slide", {direction: "right"}, 200, function() {
$(this).addClass('slided');
});
}
});
$('body').click(function() {
$('.opened').animate({height: '0px'}, 200, "swing", function() {
$(this).css('display', 'none').removeClass("opened");
$(this).closest('.box').css('border', 'none');
$(this).find('.panel').hide('fast');
$(this).closest('i').data("opened", "no");
});
$('.slided').hide('slide', {direction: 'right'}, 500).removeClass('slided');
});
$('.box, input[name=searchfield]').click(function(e) {
e.stopPropagation();
});
/* Hideing quick panel */
function quick_panel_arrow_rotate(degree) {
$('.quick_panel').animate({borderSpacing: degree}, {
step: function(now, fx) {
$(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
$(this).css('-moz-transform', 'rotate(' + now + 'deg)');
$(this).css('transform', 'rotate(' + now + 'deg)');
},
duration: 'slow'
}, 'linear');
}
$('.quick_panel').click(function() {
var state = $(this).data('state');
if (state == "shown") {
quick_panel_arrow_rotate(1620);
$('body').animate({marginTop: "-80px"});
$(this).data('state', 'hidden');
} else if (state == "hidden") {
quick_panel_arrow_rotate(0);
$('body').animate({marginTop: "0px"});
$(this).data('state', 'shown');
return false;
}
});
/* Sticky header */
var w_width = $(window).width();
var h_bar = $('.nav_header').height();
if (w_width > 992) {
$('#navigation').css('padding-top', h_bar);
$('.nav_header').followTo(1000);
$(window).scroll(function() {
if ($(window).scrollTop() < h_bar) {
$('#navigation').css('padding-top', h_bar);
} else if ($(window).scrollTop() > h_bar) {
$('#navigation').css('padding-top', h_bar);
}
});
}