EIOS/tpl/js/calendar_zabuto/zabuto_calendar.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

2023-12-28 15:39:22 +03:00
if(typeof jQuery=="undefined"){throw new Error("jQuery is not loaded")}$.fn.zabuto_calendar=function(b){var c=$.extend({},$.fn.zabuto_calendar_defaults(),b);var a=$.fn.zabuto_calendar_language(c.language);c=$.extend({},c,a);this.each(function(){var i=$(this);i.attr("id","zabuto_calendar_"+Math.floor(Math.random()*99999).toString(36));i.data("initYear",c.year);i.data("initMonth",c.month);i.data("monthLabels",c.month_labels);i.data("weekStartsOn",c.weekstartson);i.data("navIcons",c.nav_icon);i.data("dowLabels",c.dow_labels);i.data("showToday",c.today);i.data("showDays",c.show_days);i.data("showPrevious",c.show_previous);i.data("showNext",c.show_next);i.data("cellBorder",c.cell_border);i.data("jsonData",c.data);i.data("ajaxSettings",c.ajax);i.data("legendList",c.legend);i.data("actionFunction",c.action);i.data("actionNavFunction",c.action_nav);k();function k(){var x=parseInt(i.data("initYear"));var A=parseInt(i.data("initMonth"))-1;var C=new Date(x,A,1,0,0,0,0);i.data("initDate",C);var D=(i.data("cellBorder")===true)?" table-bordered":"";var B=$('<table class="table'+D+'"></table>');B=u(i,B,C.getFullYear(),C.getMonth());var w=f(i);var y=$('<div class="zabuto_calendar"></div>');y.append(B);y.append(w);i.append(y);var z=i.data("jsonData");if(false!==z){p(i,C.getFullYear(),C.getMonth())}}function u(y,A,x,z){var w=new Date(x,z,1,0,0,0,0);y.data("currDate",w);A.empty();A=q(y,A,x,z);A=d(y,A);A=o(y,A,x,z);p(y,x,z);return A}function f(y){var w=$('<div class="legend" id="'+y.attr("id")+'_legend"></div>');var x=y.data("legendList");if(typeof(x)=="object"&&x.length>0){$(x).each(function(C,E){if(typeof(E)=="object"){if("type" in E){var D="";if("label" in E){D=E.label}switch(E.type){case"text":if(D!==""){var B="";if("badge" in E){if(typeof(E.classname)==="undefined"){var F="badge-event"}else{var F=E.classname}B='<span class="badge '+F+'">'+E.badge+"</span> "}w.append('<span class="legend-'+E.type+'">'+B+D+"</span>")}break;case"block":if(D!==""){D="<span>"+D+"</span>"}if(typeof(E.classname)==="undefined"){var A="event"}else{var A="event-styled "+E.classname}w.append('<span class="legend-'+E.type+'"><ul class="legend"><li class="'+A+'"></li></ul>'+D+"</span>");break;case"list":if("list" in E&&typeof(E.list)=="object"&&E.list.length>0){var z=$('<ul class="legend"></ul>');$(E.list).each(function(H,G){z.append('<li class="'+G+'"></li>')});w.append(z)}break;case"spacer":w.append('<span class="legend-'+E.type+'"> </span>');break}}}})}return w}function q(E,D,G,M){var L=E.data("navIcons");var A=$('<span><span class="glyphicon glyphicon-chevron-left"></span></span>');var Q=$('<span><span class="glyphicon glyphicon-chevron-right"></span></span>');if(typeof(L)==="object"){if("prev" in L){A.html(L.prev)}if("next" in L){Q.html(L.next)}}var K=E.data("showPrevious");if(typeof(K)==="number"||K===false){K=n(E.data("showPrevious"),true)}var w=$('<div class="calendar-month-navigation"></div>');w.attr("id",E.attr("id")+"_nav-prev");w.data("navigation","prev");if(K!==false){var N=(M-1);var F=G;if(N==-1){F=(F-1);N=11}w.data("to",{year:F,month:(N+1)});w.append(A);if(typeof(E.data("actionNavFunction"))==="function"){w.click(E.data("actionNavFunction"))}w.click(function(R){u(E,D,F,N)})}var C=E.data("showNext");if(typeof(C)==="number"||C===false){C=n(E.data("showNext"),false)}var z=$('<div class="calendar-month-navigation"></div>');z.attr("id",E.attr("id")+"_nav-next");z.data("navigation","next");if(C!==false){var x=(M+1);var P=G;if(x==12){P=(P+1);x=0}z.data("to",{year:P,month:(x+1)});z.append(Q);if(typeof(E.data("actionNavFunction"))==="function"){z.click(E.data("actionNavFunction"))}z.click(function(R){u(E,D,P,x)})}var B=E.data("monthLabels");var J=$("<td></td>").append(w);var O=$("<td></td>").append(z);var H=$("<span>"+B[M]+" "+G+"</span>");H.dblclick(function(){var R=E.data("initDate");u(E,D,R.getFullYear(),R.getMonth())});var I=$('<td colspan="5"></td>');I.append(H);var y=$('<tr class="calendar-month-header"></tr>');y.append(J,I,O);D.append(y);return D}function d(z,B){if(z.data("showDays")===true){var w=z.data("weekStartsOn");var x=z.data("dowLabels");if(w=