Datepicker continuous date selection (source code needs to be changed), datepicker source code

Source: Internet
Author: User
Tags date1

Datepicker continuous date selection (source code needs to be changed), datepicker source code

First effect:

Code:

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head> <meta http-equiv =" Content-Type "content =" text/html; charset = UTF-8 "/> <title> date selection </title> <link rel =" stylesheet "href =" reset-jquery-ui.min.css "/> <script type =" text/javascript "src = "jquery-1.8.3.min.js"> </script> <script type = "text/javascript" src = "jquery-ui.js"> </script> <script type = "text/javascript"> // Date select $. datepicker. regional ['zh-cn'] = {clearText: 'clear', clearStatus: 'clear selected date', closeText: 'close', closeStatus: 'Do not change current select ', prevText: '<', prevStatus: 'Show previous month', prevBigText: '<', prevBigStatus: 'Show previous year', nextText: 'Next month> ', nextStatus: 'Show next month', nextBigText: '>', nextBigStatus: 'Show next year', currentText: 'day', currentStatus: 'Show this month', monthNames: ['August 1 ', 'octoken ', 'August 1'], monthNamesShort: ['yi', '2', '3', '4', '5', '6', '7', '8 ', '9', '10', '11', '12'], monthStatus: 'select month', yearStatus: 'select year', weekHeader: 'Week', weekStatus: 'Weekly times in year', dayNames: ['sunday', 'monday', 'tuesday', 'wedday', 'thurday', 'saturday'], dayNamesShort: ['sunday', 'monday', 'tuesday', 'wedday', 'thurs', 'Friday'], dayNamesMin: ['day ', '1', '2', '3', '4', '5', '6'], dayStatus: 'dd is set to a week start', dateStatus: 'select m-month-D, dd', dateFormat: 'yy-mm-dd', firstDay: 1, initStatus: 'select date', isRTL: false}; $. datepicker. setDefaults ($. datepicker. regional ['zh-cn']); var a = 0; var tmpdate = "";/*** instantiate the date control and bind the callback function, input the tag id * ajaxMethod callback function * The additional parameter required by the ajaxMethod function */function datePickerById (tagId) {$ (tagId ). datepicker ({isDataChecked: true, autoClose: true, showOtherMonths: true, changeYear: true, // showStatus: true, // showOn: "both", numberOfMonths: 2, // display showMonthAfterYear: true, onSelect: function (dateText, inst) {// select the operation a ++; inst. autoClose = true; if (a = 1) {inst. settings. isDataChecked = false; tmpdate = dateText;} if (a = 2) {a = 0; inst. settings. isDataChecked = false; inst. autoClose = false; var date1 = new Date (tmpdate ). getTime (); var date2 = new Date (dateText ). getTime (); var arg = {time_s: date1, time_e: date2}; // time parameter for ajax functions if (date1 <date2) {$ (tagId ). val (tmpdate. replace (/-/ig, "-") + "to" + dateText. replace (/-/ig, "-");} else if (date1 = date2) {a = 1; inst. settings. isDataChecked = false; inst. autoClose = true;} else {$ (tagId ). val (dateText. replace (/-/ig, "-") + "to" + tmpdate. replace (/-/ig, "-") ;}}}}</script> 

 

Based on jquery UI 1.11.4, modify the following (in the source code ):

/* Hide the date picker from view. * @ param input element-the input field attached to the date picker */_ hideDatepicker: function (input) {var showAnim, duration, postProcess, onClose, inst = this. _ curInst; if (! Inst | (input & inst! = $. Data (input, "datepicker") {return;}/*** 2015.6.11 modify * author: link * to add the inst. autoClose control calendar panel */
// -----------------------------------------------------------------------------------------
If (this. _ datepickerShowing |! Inst. autoClose) {showAnim = this. _ get (inst, "showAnim"); duration = this. _ get (inst, "duration"); postProcess = function () {$. datepicker. _ tidyDialog (inst) ;}; // DEPRECATED: after BC for 1.8.x $. effects [showAnim] is not needed if (inst. autoClose = true) {// here it is not hidden} else {if ($. effects & ($. effects. effect [showAnim] | $. effects [showAnim]) {inst. dpDiv. hide (showAnim, $. datepicker. _ get (inst , "ShowOptions"), duration, postProcess);} else {inst. dpDiv [(showAnim = "slideDown "? "SlideUp": (showAnim = "fadeIn "? "FadeOut": "hide")] (showAnim? Duration: null), postProcess );}}
// -----------------------------------------------------------------------------------------
if (!showAnim) { postProcess(); } this._datepickerShowing = false; onClose = this._get(inst, "onClose"); if (onClose) { onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]); } this._lastInput = null; if (this._inDialog) { this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" }); if ($.blockUI) { $.unblockUI(); $("body").append(this.dpDiv); } } this._inDialog = false; } },

 

1.11.4 complete source code after modification

Link: http://pan.baidu.com/s/1bnjQycv password: hr19

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.