var calendarFunctions={};!function($){var calendarData={bsMonths:["बैशाख","जेठ","असार","सावन","भदौ","असोज","कार्तिक","मंसिर","पौष","माघ","फागुन","चैत"],bsDays:["आईत","सोम","मंगल","बुध","बिही","शुक्र","शनि"],nepaliNumbers:["०","१","२","३","४","५","६","७","८","९"],bsMonthUpperDays:[[30,31],[31,32],[31,32],[31,32],[31,32],[30,31],[29,30],[29,30],[29,30],[29,30],[29,30],[30,31]],extractedBsMonthData:[[0,1,1,22,1,3,1,1,1,3,1,22,1,3,1,3,1,22,1,3,1,19,1,3,1,1,3,1,2,2,1,3,1],[1,2,2,2,2,2,2,1,3,1,3,1,2,2,2,3,2,2,2,1,3,1,3,1,2,2,2,2,2,2,2,2,2,2,2,1,3,1,2,2,2,2,2,2,2,2,2,2,2,1,3,1,2,2,2,2,2,1,1,1,2,2,2,2,2,1,3,1,1,2],[0,1,2,1,3,1,3,1,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,1,3,1,3,1,2,2,2,2,2,2,2,2,2,1,3,1,3,1,2,2,2,2,2,2,2,2,2,1,3,1,3,1,1,1,1,2,2,2,2,2,1,3,1,1,2],[1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,2,2,2,1,3,1,3,1,3,1,3,1,3,1,2,2,2,1,3,1,3,1,3,1,3,1,3,1,3,2,2,1,3,1,2,2,2,1,2],[59,1,26,1,28,1,2,1,12],[0,1,2,2,2,2,2,2,2,2,2,2,2,1,3,1,3,1,3,1,2,2,2,2,2,2,2,2,2,2,2,1,3,1,2,2,2,2,2,2,2,2,2,2,2,1,3,1,2,2,2,2,2,2,2,2,2,2,5,1,1,2,2,1,3,1,2,1,2],[0,12,1,3,1,3,1,5,1,11,1,3,1,3,1,18,1,3,1,3,1,18,1,3,1,3,1,27,1,2],[1,2,2,2,2,1,2,2,2,2,2,2,2,3,1,3,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,15,2,4],[0,1,2,2,2,2,1,3,1,3,1,3,1,2,2,2,3,2,2,2,1,3,1,3,1,3,1,2,2,2,2,2,2,2,1,3,1,3,1,3,1,2,2,2,2,2,2,2,2,2,1,3,1,3,1,2,2,2,15,2,4],[1,1,3,1,3,1,14,1,3,1,1,1,3,1,14,1,3,1,3,1,3,1,18,1,3,1,3,1,3,1,14,1,3,15,1,2,1,1],[0,1,1,3,1,3,1,10,1,3,1,3,1,1,1,3,1,3,1,10,1,3,1,3,1,3,1,3,1,14,1,3,1,3,1,3,1,3,1,10,1,20,1,1,1],[1,2,2,1,3,1,3,1,3,1,2,2,2,2,2,3,2,2,2,2,2,1,3,1,3,1,3,1,2,2,2,2,2,2,2,1,3,1,3,1,3,1,3,1,2,2,2,2,2,2,2,1,3,1,3,1,20,3]],minBsYear:1970,maxBsYear:2100,minAdDateEqBsDate:{ad:{year:1913,month:3,date:13},bs:{year:1970,month:1,date:1}}},validationFunctions={validateRequiredParameters:function(requiredParameters){$.each(requiredParameters,function(key,value){if("undefined"==typeof value||null===value)throw new ReferenceError("Missing required parameters: "+Object.keys(requiredParameters).join(", "))})},validateBsYear:function(bsYear){if("number"!=typeof bsYear||null===bsYear)throw new TypeError("Invalid parameter bsYear value");if(bsYearcalendarData.maxBsYear)throw new RangeError("Parameter bsYear value should be in range of "+calendarData.minBsYear+" to "+calendarData.maxBsYear)},validateAdYear:function(adYear){if("number"!=typeof adYear||null===adYear)throw new TypeError("Invalid parameter adYear value");if(adYearcalendarData.maxBsYear-57)throw new RangeError("Parameter adYear value should be in range of "+(calendarData.minBsYear-57)+" to "+(calendarData.maxBsYear-57))},validateBsMonth:function(bsMonth){if("number"!=typeof bsMonth||null===bsMonth)throw new TypeError("Invalid parameter bsMonth value");if(bsMonth<1||bsMonth>12)throw new RangeError("Parameter bsMonth value should be in range of 1 to 12")},validateAdMonth:function(adMonth){if("number"!=typeof adMonth||null===adMonth)throw new TypeError("Invalid parameter adMonth value");if(adMonth<1||adMonth>12)throw new RangeError("Parameter adMonth value should be in range of 1 to 12")},validateBsDate:function(bsDate){if("number"!=typeof bsDate||null===bsDate)throw new TypeError("Invalid parameter bsDate value");if(bsDate<1||bsDate>32)throw new RangeError("Parameter bsDate value should be in range of 1 to 32")},validateAdDate:function(adDate){if("number"!=typeof adDate||null===adDate)throw new TypeError("Invalid parameter adDate value");if(adDate<1||adDate>31)throw new RangeError("Parameter adDate value should be in range of 1 to 31")},validatePositiveNumber:function(numberParameters){$.each(numberParameters,function(key,value){if("number"!=typeof value||null===value||value<0)throw new ReferenceError("Invalid parameters: "+Object.keys(numberParameters).join(", "));if("yearDiff"===key&&value>calendarData.maxBsYear-calendarData.minBsYear+1)throw new RangeError("Parameter yearDiff value should be in range of 0 to "+(calendarData.maxBsYear-calendarData.minBsYear+1))})}};$.extend(calendarFunctions,{getNepaliNumber:function(number){if("undefined"==typeof number)throw new Error("Parameter number is required");if("number"!=typeof number||number<0)throw new Error("Number should be positive integer");var prefixNum=Math.floor(number/10),suffixNum=number%10;return 0!==prefixNum?calendarFunctions.getNepaliNumber(prefixNum)+calendarData.nepaliNumbers[suffixNum]:calendarData.nepaliNumbers[suffixNum]},getNumberByNepaliNumber:function(nepaliNumber){if("undefined"==typeof nepaliNumber)throw new Error("Parameter nepaliNumber is required");if("string"!=typeof nepaliNumber)throw new Error("Parameter nepaliNumber should be in string");for(var number=0,i=0;ibsMonthDays?bsMonthDays:bsDate;var eqAdDate=calendarFunctions.getAdDateByBsDate(bsYear,bsMonth,bsDate),weekDay=eqAdDate.getDay()+1,formattedDate=calendarFunctions.bsDateFormat(dateFormatPattern,bsYear,bsMonth,bsDate);return{bsYear:bsYear,bsMonth:bsMonth,bsDate:bsDate,weekDay:weekDay,formattedDate:formattedDate,adDate:eqAdDate,bsMonthFirstAdDate:bsMonthFirstAdDate,bsMonthDays:bsMonthDays}},getAdDateByBsDate:function(bsYear,bsMonth,bsDate){validationFunctions.validateRequiredParameters({bsYear:bsYear,bsMonth:bsMonth,bsDate:bsDate}),validationFunctions.validateBsYear(bsYear),validationFunctions.validateBsMonth(bsMonth),validationFunctions.validateBsDate(bsDate);var daysNumFromMinBsYear=calendarFunctions.getTotalDaysNumFromMinBsYear(bsYear,bsMonth,bsDate),adDate=new Date(calendarData.minAdDateEqBsDate.ad.year,calendarData.minAdDateEqBsDate.ad.month,calendarData.minAdDateEqBsDate.ad.date-1);return adDate.setDate(adDate.getDate()+daysNumFromMinBsYear),adDate},getTotalDaysNumFromMinBsYear:function(bsYear,bsMonth,bsDate){if(validationFunctions.validateRequiredParameters({bsYear:bsYear,bsMonth:bsMonth,bsDate:bsDate}),validationFunctions.validateBsYear(bsYear),validationFunctions.validateBsMonth(bsMonth),validationFunctions.validateBsDate(bsDate),bsYearcalendarData.maxBsYear)return null;for(var daysNumFromMinBsYear=0,diffYears=bsYear-calendarData.minBsYear,month=1;month<=12;month++)daysNumFromMinBsYear+=month2085&&bsYear<2088?bsDate-2:2085===bsYear&&bsMonth>5?bsDate-2:bsYear>2088?bsDate-4:2088===bsYear&&bsMonth>5?bsDate-4:bsDate},getMonthDaysNumFormMinBsYear:function(bsMonth,yearDiff){validationFunctions.validateRequiredParameters({bsMonth:bsMonth,yearDiff:yearDiff}),validationFunctions.validateBsMonth(bsMonth),validationFunctions.validatePositiveNumber({yearDiff:yearDiff});var yearCount=0,monthDaysFromMinBsYear=0;if(0===yearDiff)return 0;for(var bsMonthData=calendarData.extractedBsMonthData[bsMonth-1],i=0;iyearCount+bsMonthData[i])){monthDaysFromMinBsYear+=calendarData.bsMonthUpperDays[bsMonth-1][bsMonthUpperDaysIndex]*(yearDiff-yearCount),yearCount=yearDiff-yearCount;break}yearCount+=bsMonthData[i],monthDaysFromMinBsYear+=calendarData.bsMonthUpperDays[bsMonth-1][bsMonthUpperDaysIndex]*bsMonthData[i]}return monthDaysFromMinBsYear},getBsMonthDays:function(bsYear,bsMonth){validationFunctions.validateRequiredParameters({bsYear:bsYear,bsMonth:bsMonth}),validationFunctions.validateBsYear(bsYear),validationFunctions.validateBsMonth(bsMonth);for(var yearCount=0,totalYears=bsYear+1-calendarData.minBsYear,bsMonthData=calendarData.extractedBsMonthData[bsMonth-1],i=0;i=1&&adDate');$("body").append($nepaliDatePicker),""!==$element.val()?datePickerPlugin.renderFormattedSpecificDateCalendar($nepaliDatePicker,datePickerPlugin.options.dateFormat,$element.val()):datePickerPlugin.renderCurrentMonthCalendar($nepaliDatePicker),datePickerPlugin.addEventHandler($element,$nepaliDatePicker),datePickerPlugin.addCommonEventHandler($nepaliDatePicker)},addCommonEventHandler:function(){var $datePickerWrapper=$(".nepali-date-picker");$(document).click(function(event){var $targetElement=$(event.target);$targetElement.is($(".nepali-date-picker"))||($datePickerWrapper.hide(),$datePickerWrapper.find(".drop-down-content").hide())})},addEventHandler:function($element,$nepaliDatePicker){$element.click(function(){if($(".nepali-date-picker").is(":visible"))return void $(".nepali-date-picker").hide();var inputFieldPosition=$(this).offset();return $nepaliDatePicker.css({top:inputFieldPosition.top+$(this).outerHeight(!0),left:inputFieldPosition.left}),$element.val()&&datePickerPlugin.renderFormattedSpecificDateCalendar($nepaliDatePicker,datePickerPlugin.options.dateFormat,$element.val()),$nepaliDatePicker.show(),datePickerPlugin.eventFire($element,$nepaliDatePicker,"show"),!1}),$nepaliDatePicker.on("click",".next-btn",function(event){event.preventDefault();var preCalendarData={bsYear:$nepaliDatePicker.data().bsYear,bsMonth:$nepaliDatePicker.data().bsMonth,bsDate:$nepaliDatePicker.data().bsDate};return datePickerPlugin.renderNextMonthCalendar($nepaliDatePicker),datePickerPlugin.triggerChangeEvent($element,$nepaliDatePicker,preCalendarData),$nepaliDatePicker.show(),!1}),$nepaliDatePicker.on("click",".prev-btn",function(event){event.preventDefault();var preCalendarData={bsYear:$nepaliDatePicker.data().bsYear,bsMonth:$nepaliDatePicker.data().bsMonth,bsDate:$nepaliDatePicker.data().bsDate};datePickerPlugin.renderPreviousMonthCalendar($nepaliDatePicker);$nepaliDatePicker.data();return datePickerPlugin.triggerChangeEvent($element,$nepaliDatePicker,preCalendarData),$nepaliDatePicker.show(),!1}),$nepaliDatePicker.on("click",".today-btn",function(event){event.preventDefault();var preCalendarData={bsYear:$nepaliDatePicker.data().bsYear,bsMonth:$nepaliDatePicker.data().bsMonth,bsDate:$nepaliDatePicker.data().bsDate};datePickerPlugin.renderCurrentMonthCalendar($nepaliDatePicker);$nepaliDatePicker.data();return datePickerPlugin.triggerChangeEvent($element,$nepaliDatePicker,preCalendarData),$nepaliDatePicker.show(),!1}),$nepaliDatePicker.on("click",".current-year-txt, .current-month-txt",function(){if($(this).find(".drop-down-content").is(":visible"))$(this).find(".drop-down-content").hide();else{$nepaliDatePicker.find(".drop-down-content").hide(),$(this).find(".drop-down-content").show();var $optionWrapper=$(this).find(".option-wrapper");$optionWrapper.scrollTop(0);var scrollTopTo=$optionWrapper.find(".active").position().top;$optionWrapper.scrollTop(scrollTopTo)}return!1}),$nepaliDatePicker.on("click",".current-month-date",function(){if(!$(this).hasClass("disable")){var datePickerData=$nepaliDatePicker.data(),bsYear=datePickerData.bsYear,bsMonth=datePickerData.bsMonth,preDate=datePickerData.bsDate,bsDate=$(this).data("date"),dateText=calendarFunctions.bsDateFormat(datePickerPlugin.options.dateFormat,bsYear,bsMonth,bsDate);return $element.val(dateText),datePickerPlugin.setCalendarDate($nepaliDatePicker,bsYear,bsMonth,bsDate),datePickerPlugin.renderMonthCalendar($nepaliDatePicker),preDate!==bsDate&&datePickerPlugin.eventFire($element,$nepaliDatePicker,"dateChange"),datePickerPlugin.eventFire($element,$nepaliDatePicker,"dateSelect"),datePickerPlugin.options.closeOnDateSelect?$nepaliDatePicker.hide():$nepaliDatePicker.show(),!1}}),$nepaliDatePicker.on("click",".drop-down-content li",function(){var $dropDown=$(this).parents(".drop-down-content");$dropDown.data("value",$(this).data("value")),$dropDown.attr("data-value",$(this).data("value"));var preCalendarData={bsYear:$nepaliDatePicker.data().bsYear,bsMonth:$nepaliDatePicker.data().bsMonth,bsDate:$nepaliDatePicker.data().bsDate},bsMonth=$nepaliDatePicker.find(".month-drop-down").data("value"),bsYear=$nepaliDatePicker.find(".year-drop-down").data("value"),bsDate=preCalendarData.bsDate;datePickerPlugin.setCalendarDate($nepaliDatePicker,bsYear,bsMonth,bsDate),datePickerPlugin.renderMonthCalendar($nepaliDatePicker);$nepaliDatePicker.data();return datePickerPlugin.triggerChangeEvent($element,$nepaliDatePicker,preCalendarData),$nepaliDatePicker.show(),!1})},triggerChangeEvent:function($element,$nepaliDatePicker,preCalendarData){var calendarData=$nepaliDatePicker.data();preCalendarData.bsYear!==calendarData.bsYear&&datePickerPlugin.eventFire($element,$nepaliDatePicker,"yearChange"),preCalendarData.bsMonth!==calendarData.bsMonth&&datePickerPlugin.eventFire($element,$nepaliDatePicker,"monthChange"),preCalendarData.bsDate!==calendarData.bsDate&&datePickerPlugin.eventFire($element,$nepaliDatePicker,"dateChange")},eventFire:function($element,$nepaliDatePicker,eventType){switch(eventType){case"generate":$element.trigger({type:eventType,message:"Nepali date picker initialize",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"show":$element.trigger({type:eventType,message:"Show nepali date picker",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"close":$element.trigger({type:eventType,message:"close nepali date picker",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"dateSelect":$element.trigger({type:eventType,message:"Select date",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"dateChange":$element.trigger({type:eventType,message:"Change date",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"monthChange":$element.trigger({type:eventType,message:"Change month",datePickerData:$nepaliDatePicker.data(),time:new Date});break;case"yearChange":$element.trigger({type:eventType,message:"Change year",datePickerData:$nepaliDatePicker.data(),time:new Date})}},setCalendarDate:function($nepaliDatePicker,bsYear,bsMonth,BsDate){$nepaliDatePicker.data(calendarFunctions.getBsMonthInfoByBsDate(bsYear,bsMonth,BsDate,datePickerPlugin.options.dateFormat))},renderMonthCalendar:function($nepaliDatePicker){$nepaliDatePicker.find(".calendar-wrapper").remove(),$nepaliDatePicker.append(datePickerPlugin.getCalendar($nepaliDatePicker)).hide()},getCalendar:function($nepaliDatePicker){var calendarWrapper=$('
');calendarWrapper.append(datePickerPlugin.getCalendarController($nepaliDatePicker));var calendarTable=$("");return calendarTable.append(datePickerPlugin.getCalendarHeader()),calendarTable.append(datePickerPlugin.getCalendarBody($nepaliDatePicker)),calendarWrapper.append(calendarTable),calendarWrapper},getCalendarController:function($nepaliDatePicker){var calendarController=$("
");return calendarController.append(''),calendarController.append(''),calendarController.append(datePickerPlugin.getMonthDropOption($nepaliDatePicker)),calendarController.append(datePickerPlugin.getYearDropOption($nepaliDatePicker)),calendarController.append(''),calendarController},getMonthDropOption:function($nepaliDatePicker){var datePickerData=$nepaliDatePicker.data(),$monthSpan=$('
');$monthSpan.text(calendarData.bsMonths[datePickerData.bsMonth-1]),$monthSpan.append('');for(var data=[],i=0;i<12;i++)data.push({label:calendarData.bsMonths[i],value:i+1});var $monthDropOption=datePickerPlugin.getCustomSelectOption(data,datePickerData.bsMonth).addClass("month-drop-down");return $monthSpan.append($monthDropOption),$monthSpan},getYearDropOption:function($nepaliDatePicker){var datePickerData=$nepaliDatePicker.data(),$yearSpan=$('
');$yearSpan.text(calendarFunctions.getNepaliNumber(datePickerData.bsYear)),$yearSpan.append('');for(var data=[],i=datePickerPlugin.options.yearStart;i<=datePickerPlugin.options.yearEnd;i++)data.push({label:calendarFunctions.getNepaliNumber(i),value:i});var $yearDropOption=datePickerPlugin.getCustomSelectOption(data,datePickerData.bsYear).addClass("year-drop-down");return $yearSpan.append($yearDropOption),$yearSpan},getCustomSelectOption:function(datas,activeValue){var $dropDown=$('
"),tableRow=$(""),i=0;i<7;i++)tableRow.append("");return calendarHeader.append(tableRow),calendarHeader},getCalendarBody:function($nepaliDatePicker){var datePickerData=$nepaliDatePicker.data(),weekCoverInMonth=Math.ceil((datePickerData.bsMonthFirstAdDate.getDay()+datePickerData.bsMonthDays)/7),preMonth=datePickerData.bsMonth-1!==0?datePickerData.bsMonth-1:12,preYear=12===preMonth?datePickerData.bsYear-1:datePickerData.bsYear,preMonthDays=preYear>=calendarData.minBsYear?calendarFunctions.getBsMonthDays(preYear,preMonth):30,minBsDate=null,maxBsDate=null;null!==datePickerPlugin.options.minDate&&(minBsDate=calendarFunctions.parseFormattedBsDate(datePickerPlugin.options.dateFormat,datePickerPlugin.options.minDate)),null!==datePickerPlugin.options.maxDate&&(maxBsDate=calendarFunctions.parseFormattedBsDate(datePickerPlugin.options.dateFormat,datePickerPlugin.options.maxDate));for(var calendarBody=$(""),i=0;i"),k=1;k<=7;k++){var calendarDate=7*i+k-datePickerData.bsMonthFirstAdDate.getDay(),isCurrentMonthDate=!0;if(calendarDate<=0?(calendarDate=preMonthDays+calendarDate,isCurrentMonthDate=!1):calendarDate>datePickerData.bsMonthDays&&(calendarDate-=datePickerData.bsMonthDays,isCurrentMonthDate=!1),isCurrentMonthDate){var $td=$('");calendarDate==datePickerData.bsDate&&$td.addClass("active"),datePickerPlugin.disableIfOutOfRange($td,datePickerData,minBsDate,maxBsDate,calendarDate),tableRow.append($td)}else tableRow.append('")}calendarBody.append(tableRow)}return calendarBody},disableIfOutOfRange:function($td,datePickerData,minBsDate,maxBsDate,calendarDate){return null!==minBsDate&&(datePickerData.bsYearmaxBsDate.bsYear?$td.addClass("disable"):datePickerData.bsYear===maxBsDate.bsYear&&datePickerData.bsMonth>maxBsDate.bsMonth?$td.addClass("disable"):datePickerData.bsYear===maxBsDate.bsYear&&datePickerData.bsMonth===maxBsDate.bsMonth&&calendarDate>maxBsDate.bsDate&&$td.addClass("disable")),$td},renderCurrentMonthCalendar:function($nepaliDatePicker){var currentDate=new Date,currentBsDate=calendarFunctions.getBsDateByAdDate(currentDate.getFullYear(),currentDate.getMonth()+1,currentDate.getDate()),bsYear=currentBsDate.bsYear,bsMonth=currentBsDate.bsMonth,bsDate=currentBsDate.bsDate;datePickerPlugin.setCalendarDate($nepaliDatePicker,bsYear,bsMonth,bsDate),datePickerPlugin.renderMonthCalendar($nepaliDatePicker)},renderPreviousMonthCalendar:function($nepaliDatePicker){var datePickerData=$nepaliDatePicker.data(),prevMonth=datePickerData.bsMonth-1>0?datePickerData.bsMonth-1:12,prevYear=12!==prevMonth?datePickerData.bsYear:datePickerData.bsYear-1,prevDate=datePickerData.bsDate;return prevYeardatePickerPlugin.options.yearEnd?null:(datePickerPlugin.setCalendarDate($nepaliDatePicker,prevYear,prevMonth,prevDate),void datePickerPlugin.renderMonthCalendar($nepaliDatePicker))},renderNextMonthCalendar:function($nepaliDatePicker){var datePickerData=$nepaliDatePicker.data(),nextMonth=datePickerData.bsMonth+1<=12?datePickerData.bsMonth+1:1,nextYear=1!==nextMonth?datePickerData.bsYear:datePickerData.bsYear+1,nextDate=datePickerData.bsDate;return nextYeardatePickerPlugin.options.yearEnd?null:(datePickerPlugin.setCalendarDate($nepaliDatePicker,nextYear,nextMonth,nextDate),void datePickerPlugin.renderMonthCalendar($nepaliDatePicker))},renderFormattedSpecificDateCalendar:function($nepaliDatePicker,dateFormat,dateFormattedText){var datePickerDate=calendarFunctions.parseFormattedBsDate(dateFormat,dateFormattedText);datePickerPlugin.setCalendarDate($nepaliDatePicker,datePickerDate.bsYear,datePickerDate.bsMonth,datePickerDate.bsDate),datePickerPlugin.renderMonthCalendar($nepaliDatePicker)}};return this.each(function(){var $element=$(this);datePickerPlugin.init($element)}),datePickerPlugin.addCommonEventHandler(),this}}(jQuery,calendarFunctions);
"+calendarData.bsDays[i]+"
'+calendarFunctions.getNepaliNumber(calendarDate)+"'+calendarFunctions.getNepaliNumber(calendarDate)+"