يعد Bootstrap-DatePicker مكونًا ممتازًا للغاية لاختيار الوقت ، ويتمثل الافتراضي في عرض التواريخ باللغة الإنجليزية. تقدم لك هذه المقالة ملف JS مع Bootstrap DatePicker مع الصينية.
// استخدم JSIF ($ (". DatePicker"). الطول> 0) {$ (". datePicker"). شكل})؛}فيما يلي ملف CSS الخاص بـ DatePicker ورمز JS
/*!* DatePicker for Bootstrap ** حقوق الطبع والنشر 2012 Stefan Petre* مرخصة بموجب ترخيص Apache v2.0* http://www.apache.org/licenses/license-2.0ers 4px ؛ -moz-border-radius: 4px ؛ الحدود-radius: 4px ؛/*. dow {border-top: 1px solid #ddd! harm ؛}*/}. DatePicker: قبل المحتوى: ' #ccc ؛ border-bottom-color: rgba (0 ، 0 ، 0 ، 0.2) ؛ الموضع: المطلق ؛ أعلى: -7px ؛ اليسار: 6px ؛}. -6px ؛ اليسار: 7px ؛}. DatePicker> div {display: none ؛} 4px ؛ border-radius: 4px ؛}. TD.Active ، .datepicker إلى ( #0044cc)) ؛ خلفية-صورة: -webkit-linar-radient (Top ، #0088cc ، #0044cc) ؛ procession-image: -o-linar-regient (top ، #0088cc ، #0044cc) ؛ emage-regient: 0088cc ، #0044. REPER-X ؛ FILTER: PROGID: DXIMAGETRANSFORM.Microsoft.gradient (startColorstr = ' #ff0088cc' ، endcolorstr = ' #ff0044cc' ، gradienttype = 0) ؛ border-color: #0044cc #0044c #002a80 ؛ RGBA (0 ، 0 ، 0 ، 0.1) RGBA (0 ، 0 ، 0 ، 0.25) ؛*الخلفية اللون: #0044CC ؛/*أزرار IE7 بشكل افتراضي بحيث تبرز بشكل أكبر بالنظر إلى أنها لن تحتوي على حدود*/filter: progid: dximagetransform.microsoft rgba (0 ، 0 ، 0 ، 0.25) ؛}. td.active.active ، .datepicker td.active: hover.active ، .datepicker #003bb3 ؛}. 54px ؛ تعويم: اليسار ؛ الهامش: 2px ؛ المؤشر: مؤشر ؛ -webkit-border-radius: 4px ؛ -moz-border-radius: 4px ؛ border-radius: 4px ؛}. #006DCC ؛ الخلفية-صورة: -Moz-Liner-Radient (TOP ، #0088CC ، #0044CC) ؛ Background-Image: -WebKit-Radient (Linear ، 0 0 ، 0 100 ٪ ، from ( #0088c) ، to ( #0044cc) #0044cc) ؛ الخلفية-صورة: -O-Linar-Radient (Top ، #0088cc ، #0044cc) ؛ صورة الخلفية: خطي (إلى أسفل ، #0088cc ، #0044cc) ؛ خلفية: تكرار-x ؛ فلتر: progid: dimizageTransform.microsoft.gradient (startColorStr = ' #ff0088cc' ، endcolorstr = ' #ff0044cc' ، gradienttype = 0) ؛ border-color: #0044cc #0044cc #002a80 ؛ border-color: 0 ، 0 ، 0 ، 0.1) RGBA (0 ، 0 ، 0 ، 0.25) ؛*خلفية اللون: #0044CC ؛/*أزرار IE7 بشكل افتراضي بحيث تبرز بشكل أكبر نظرًا لأنها لن يكون لها حدود*/مرشح: progid: dximagetransform.microsoft.gradian 0.25) ؛}. #0044cc ؛*الخلفية اللون: #003bb3 ؛}. th.next ، .datepicker th.prev {font-size: 21px ؛}. كتلة ؛ المؤشر: مؤشر ؛ العرض: 16px ؛ الارتفاع: 16px ؛}/* ================================================================================================================================================ ================================================================================================================================================ ================================================================================================================================================ ================================================================================================================================================ حقوق الطبع والنشر 2012 Stefan Petre ** مرخصة بموجب ترخيص Apache ، الإصدار 2.0 ("الترخيص") ؛* لا يجوز لك استخدام هذا الملف إلا في الامتثال للترخيص. ضمانات أو شروط من أي نوع ، إما صريحة أو ضمنية.* راجع ترخيص أذونات حوكمة اللغة المحددة والقيود* بموجب الترخيص.* ============================================================================================================================================================================= =================================================================================================================================================================== ============================================================================================================================================================================= =================================================================================================================================================================== الخيارات) {this.element = $ (element) ؛ this.format = dpglobal.parseformat (Options.format || this.element.data ('dones-format') || 'yyyy-mm-dd') ؛ this.picker = $ (dpglobal.template) .appendto ('body'). on {click: $. هذا) // ، // mousedown: $ .proxy (this.mousedown ، this)}) ؛ this.isinput = this.element.is ('input') ؛ this.component = this.element.is ('. date')؟ this.element.find ('. add-on'): false ؛ if (this.isinput) {this.element.on ({focus: $ .proxy (this.show ، this) ، // blur: $ .proxy (this. (this.component) {this.component.on ('click' ، $ .proxy (this.show ، this)) ؛} آخر {this.element.on ('click' ، $ .proxy (this.show ، this) ؛} Options.minViewMode || this.element.data ('date-minviewmode') || 0 ؛ if (typeof this.minviewMode ==== 'string') {switch (this.minviewmode) {case 'months': this.minviewmode = 1 ؛ case 'years: that.minview = 2 ؛ 0 ؛ break ؛}} this.viewmode = Options.viewMode || this.element.data ('Date-ViewMode') || 0 ؛ if (typeof this.viewmode === 'string') {switch (this.viewmode) {case 'months' 0 ؛ break ؛}} this.startViewMode = this.viewMode ؛ this.weekstart = options.weekstart || this.element.data ('date-weekstart') || 0 ؛ this.weekend = this.weekstart === 0؟ 6: this.weekstart - 1 ؛ this.onrender = Options.onrender ؛ this.filldow () ؛ this.fillmonths () ؛ this.update () ؛ this.showmode () ؛ هذا. function (ev) {if ($ (ev.target) .closest ('. this.place) ؛ this.viewmode = this.startViewMode ؛ this.showmode () ؛ if (! this.isinput) {$ (document) .off ('mousedown' ، this.hide) ؛} // this.set () ؛ dpglobal.formatdate (this.date ، this.format) ؛ if (! this.isInput) {if (this.component) {this.element.find ('input'). prop ('value' ، formatted) ؛} this.element.data ('date' ، formated) ؛ Function (newDate) {if (typeof newDate === 'string') {this.date = dpglobal.parsedate (newDate ، this.format) ؛} آخر {this.date = new date (newDate) ؛ 0) ؛ this.fill () ؛} ، المكان: function () {var offset = this.component؟ this.component.offset (): this.element.offset () ؛ this.picker.css ({TOP: Offset.top + this.height ، left: offset.left}) ؛} ، update: function (newDate) {this.date = dpglobal.parsedateate (typeof newDate '؟ this.element.prop ('value'): this.element.data ('date') ، this.format) ؛ this.viewDate = new date (this.date.getlyear () ، this.date.getMonth () ، 1 ، 0 ، 0 ، 0) ؛ '<tr>' ؛ بينما (dowcnt <this.weekstart+7) {html+= '<h>'+dpglobal.dates.daysmin [(dowcnt ++) ٪ 7]+'</h>' ؛} html+= '</tr>' ؛ this.picker.find ('. thead '). إلحاح (html) ؛} ، flowmonths: function () {var html =' '؛ var i = 0 while (i <12) {html+=' <span> '+dpglobal.dates.monthsshort [i ++]+' </span> '؛ td '). إلحاق (html) ؛} ، fill: function () {var d = new date (this.viewDate) ، year = d.getlyear () ، month = d.getMonth () ، currentDate = this.date.valueof () ؛ this.picker.find ('. prevmonth.getMonth ()) ؛ prevmonth.setdate (day) ؛ prevmonth.setDate (day - (prevmonth.getday () - this.weekstart + 7) ٪ 7) ؛ var nextmonth = new date (prevmonth) ؛ nextmonth.setdate (nextmonth.getDate () + 42) ؛ clsname ، prevy ، prevm ؛ بينما (prevmonth.valueof () <nextMonth) {if (prevmonth.getday () === this.weekstart) {html.push ('<tr>') ؛} clsname = this.onrender (prevmonth) ؛ && prevy === year) || prevy <year) {clsname += 'old' ؛} آخر إذا ( نشط '؛} html.push (' <td> '+prevmonth.getDate ()+' </td> ') ؛ if (prevmonth.getday () === this.weekend) {html.push (' </tr> ') ؛ tbody '). فارغة () {months.eq (this.date.getmonth ()). addClass ('نشط') ؛} html = '' ؛ year = parseint (year/10 ، 10) * 10 ؛ var yearcont = this.picker.find ('. 9)). end (). find ('td') ؛ year -= 1 ؛ for (var i = -1 ؛ i <11 ؛ i ++) {html+= '<span>'+year+'</span>' ؛ year+= 1 ؛} yearcont.html (html) ؛ $ (e.target) .closest ('span ، td ، th') ؛ if (target.length === 1) {switch (target [0] .nodename.toLowerCase ()) {case 'th': switch (target [0] .classname) {case 'switch': this.showmode (1) ؛ break ' "التالي": this.viewDate ['set'+dpglobal.modes [this.viewMode] .navfnc] .Call (this.viewDate ، this.viewDate ['get'+dpglobal.modes [this.viewMode] .Navfnc] .Call (this.viewdate)+ dpglobal.modes [this.viewMode] .NavStep * (Target [0] .className === 'Prev'؟ -1: 1)) ؛ this.fill () ؛ this.set () ؛ break ؛ target.parent (). "تغيير" ، التاريخ: this.date ، viewmode: dpglobal.modes [this.viewMode] .clsname}) ؛} this.showmode (-1) ؛ this.fill () ؛ this.set () 10) || 1 ؛ var month = this.viewDate.getMonth () ؛ if (target.is ('. old')) {month -= 1 ؛} آخر إذا (target.is (' this.date = تاريخ جديد (السنة ، الشهر ، اليوم ، 0،0،0،0) ؛ this.viewDate = تاريخ جديد (السنة ، الشهر ، Math.Min (28 ، Day) ، 0،0،0،0) ؛ this.fill () ؛ this.set () ؛ this.element.trigger ({type: 'change "، التاريخ: this.date ، viewmode: dpglobal.modes [this.viewmode] .clsname}) ؛ {this.viewmode = math.max (this.minviewmode ، math.min (2 ، this.viewmode + dir)) ؛} this.picker.find ('> div'). hide (). filter ('. = function (الخيار ، val) {return this.each (function () {var $ this = $ (this) ، data = $ this.data ('datepicker') ، stions = typeof orte === 'object' && orpion $ .fn.datepicker.defaults ، الخيارات)))))) {أوضاع: [{clsname: 'days' ، navfnc: 'month' ، navstep: 1} ، {clsname: 'months' ، navfnc: 'communear' ، navstep: 1} ، {clsname: 'years ، "الجمعة" ، "السبت" ، "الأحد"] ، DayShort: ["Sunday" ، "One" ، "اثنين" ، "ثلاثة" ، "أربعة" ، "خمسة" ، "ستة" ، "سبعة"] ، ["يوم" ، "واحد" ، "شهر يناير" ، "،" ، "،" ، "،" ، "،" ، "،" ، ". "يونيو" ، "يوليو" ، "يوليو" ، "يوليو" ، "يوليو" ، "يوليو" ، "يوليو" ، "يوليو" ، "يونيو" ، "يونيو" ، "يونيو" ، "ديسمبر"] ، isleapyear: function (year) {return [31 ، (dpglobal.isleapyear (year)؟ 29: 28) ، 31 ، 30 ، 31 ، 31 ، 31 ، 31 ، 30 ، 31] === 0) {رمي خطأ جديد ("تنسيق تاريخ غير صالح.") ؛} إرجاع {فاصل: فاصل ، أجزاء: أجزاء} ؛} ، parsedate: function (date ، format) {var parts. Date () ، val ؛ date.sethours (0) ؛ date.setMinutes (0) ؛ date.setseconds (0) ؛ date.setMillisEconds (0) ؛ if (parts.length === format.parts.length) format.parts.length ؛ val ؛ date.setlyear (2000 + val) ؛ break ؛ case 'yyyy': year = val ؛ date.setlyear (val) ؛ break ؛}} date = new date (year ، month ، 0 ، 0 ، 0) ؛ date.getlyear (). {date.push (val [format.parts [i]]) ؛} تاريخ الإرجاع. colspan = "7"> </td> </r> </tbody> '} ؛ dpglobal.template = '<viv>'+'<viv>'+'<bool>'+dpglobal.headtemplate+'<tbody> </tbody>'+'</table>'+'</viv>'+'<div>'+'<div>'+'<border>'+dpglobal .headtemplate+dpglobal.conttemplate+'</table>'+'</viv>'+'<viv>'+'<border>'+dpglobal.headtemplate+'</table>'+'</fiv>'+'؛} ( window.jquery) ؛ما سبق هو ملف JS في عنصر التحكم في DatePicker في Bootstrap الذي قدمه لك المحرر. آمل أن يكون ذلك مفيدًا لك. إذا كان لديك أي أسئلة ، فيرجى ترك رسالة لي وسوف يرد المحرر إليك في الوقت المناسب. شكرا جزيلا لدعمكم لموقع wulin.com!