-
Notifications
You must be signed in to change notification settings - Fork 0
/
persian-datepicker.js
5995 lines (5525 loc) · 279 KB
/
persian-datepicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** persian-datepicker - v1.2.0
** Reza Babakhani <babakhani.reza@gmail.com>
** http://babakhani.github.io/PersianWebToolkit/docs/datepicker
** Under MIT license
*/
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === "object" && typeof module === "object")
module.exports = factory();
else if (typeof define === "function" && define.amd) define([], factory);
else if (typeof exports === "object")
exports["persianDatepicker"] = factory();
else root["persianDatepicker"] = factory();
})(this, function () {
return /******/ (function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if (installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/ var module = (installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {},
/******/
});
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(
module.exports,
module,
module.exports,
__webpack_require__
);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function (value) {
return value;
};
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function (exports, name, getter) {
/******/ if (!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter,
/******/
});
/******/
}
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function (module) {
/******/ var getter =
module && module.__esModule
? /******/ function getDefault() {
return module["default"];
}
: /******/ function getModuleExports() {
return module;
};
/******/ __webpack_require__.d(getter, "a", getter);
/******/ return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function (object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
};
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__((__webpack_require__.s = 5));
/******/
})(
/************************************************************************/
/******/[
/* 0 */
/***/ function (module, exports, __webpack_require__) {
"use strict";
var Helper = {
// leading edge, instead of the trailing.
debounce: function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments;
var later = function later() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
},
/**
* @desc normal log
* @param input
* @example log('whoooooha')
*/
log: function log(input) {
/*eslint-disable no-console */
console.log(input);
/*eslint-enable no-console */
},
/* eslint-disable no-useless-escape */
isMobile: (function () {
var check = false;
(function (a) {
if (
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
a
) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
a.substr(0, 4)
)
)
check = true;
})(
navigator.userAgent ||
navigator.vendor ||
window.opera
);
return check;
})(),
/* eslint-enable no-useless-escape */
/**
* @desc show debug messages if window.persianDatepickerDebug set as true
* @param elem
* @param input
* @example window.persianDatepickerDebug = true;
* debug('element','message');
*/
debug: function debug(elem, input) {
/*eslint-disable no-console */
if (window.persianDatepickerDebug) {
if (elem.constructor.name) {
console.log(
"Debug: " +
elem.constructor.name +
" : " +
input
);
} else {
console.log("Debug: " + input);
}
}
/*eslint-enable no-console */
},
delay: function delay(callback, ms) {
clearTimeout(window.datepickerTimer);
window.datepickerTimer = setTimeout(callback, ms);
},
};
module.exports = Helper;
/***/
},
/* 1 */
/***/ function (module, exports, __webpack_require__) {
"use strict";
/**
* @type {string}
*/
var Template =
'\n<div id="plotId" class="datepicker-plot-area {{cssClass}}">\n {{#navigator.enabled}}\n <div data-navigator class="datepicker-navigator">\n <div class="pwt-btn pwt-btn-next"><i class="bi bi-chevron-left"></i></div>\n <div class="pwt-btn pwt-btn-switch">{{navigator.switch.text}}</div>\n <div class="pwt-btn pwt-btn-prev"><i class="bi bi-chevron-right"></i></div>\n </div>\n {{/navigator.enabled}}\n <div class="datepicker-grid-view" >\n {{#days.enabled}}\n {{#days.viewMode}}\n <div class="datepicker-day-view" > \n <div class="month-grid-box">\n <div class="date-header">\n <div class="title"></div>\n <div class="header-row">\n {{#weekdays.list}}\n <div class="header-row-cell">{{.}}</div>\n {{/weekdays.list}}\n </div>\n </div> \n <table cellspacing="0" class="table-days">\n <tbody>\n {{#days.list}}\n \n <tr>\n {{#.}}\n {{#enabled}}\n <td data-date="{{dataDate}}" data-unix="{{dataUnix}}" >\n <span class="{{#otherMonth}}other-month{{/otherMonth}}">{{title}}</span>\n {{#altCalendarShowHint}}\n <i class="alter-calendar-day">{{alterCalTitle}}</i>\n {{/altCalendarShowHint}}\n </td>\n {{/enabled}}\n {{^enabled}}\n <td data-date="{{dataDate}}" data-unix="{{dataUnix}}" class="disabled">\n <span class="{{#otherMonth}}other-month{{/otherMonth}}">{{title}}</span>\n {{#altCalendarShowHint}}\n <i class="alter-calendar-day">{{alterCalTitle}}</i>\n {{/altCalendarShowHint}}\n </td>\n {{/enabled}}\n \n {{/.}}\n </tr>\n {{/days.list}}\n </tbody>\n </table>\n </div>\n </div>\n {{/days.viewMode}}\n {{/days.enabled}}\n \n {{#month.enabled}}\n {{#month.viewMode}}\n <div class="datepicker-month-view">\n {{#month.list}}\n {{#enabled}} \n <div data-year="{{year}}" data-month="{{dataMonth}}" class="month-item {{#selected}}selected{{/selected}}">{{title}}</small></div>\n {{/enabled}}\n {{^enabled}} \n <div data-year="{{year}}"data-month="{{dataMonth}}" class="month-item month-item-disable {{#selected}}selected{{/selected}}">{{title}}</small></div>\n {{/enabled}}\n {{/month.list}}\n </div>\n {{/month.viewMode}}\n {{/month.enabled}}\n \n {{#year.enabled }}\n {{#year.viewMode }}\n <div class="datepicker-year-view" >\n {{#year.list}}\n {{#enabled}}\n <div data-year="{{dataYear}}" class="year-item {{#selected}}selected{{/selected}}">{{title}}</div>\n {{/enabled}}\n {{^enabled}}\n <div data-year="{{dataYear}}" class="year-item year-item-disable {{#selected}}selected{{/selected}}">{{title}}</div>\n {{/enabled}} \n {{/year.list}}\n </div>\n {{/year.viewMode }}\n {{/year.enabled }}\n \n </div>\n {{#time}}\n {{#enabled}}\n <div class="datepicker-time-view">\n {{#hour.enabled}}\n <div class="hour time-segment" data-time-key="hour">\n <div class="up-btn" data-time-key="hour">\u25B2</div>\n <input disabled value="{{hour.title}}" type="text" placeholder="hour" class="hour-input">\n <div class="down-btn" data-time-key="hour">\u25BC</div> \n </div> \n <div class="divider">\n <span>:</span>\n </div>\n {{/hour.enabled}}\n {{#minute.enabled}}\n <div class="minute time-segment" data-time-key="minute" >\n <div class="up-btn" data-time-key="minute">\u25B2</div>\n <input disabled value="{{minute.title}}" type="text" placeholder="minute" class="minute-input">\n <div class="down-btn" data-time-key="minute">\u25BC</div>\n </div> \n <div class="divider second-divider">\n <span>:</span>\n </div>\n {{/minute.enabled}}\n {{#second.enabled}}\n <div class="second time-segment" data-time-key="second" >\n <div class="up-btn" data-time-key="second" >\u25B2</div>\n <input disabled value="{{second.title}}" type="text" placeholder="second" class="second-input">\n <div class="down-btn" data-time-key="second" >\u25BC</div>\n </div>\n <div class="divider meridian-divider"></div>\n <div class="divider meridian-divider"></div>\n {{/second.enabled}}\n {{#meridian.enabled}}\n <div class="meridian time-segment" data-time-key="meridian" >\n <div class="up-btn" data-time-key="meridian">\u25B2</div>\n <input disabled value="{{meridian.title}}" type="text" class="meridian-input">\n <div class="down-btn" data-time-key="meridian">\u25BC</div>\n </div>\n {{/meridian.enabled}}\n </div>\n {{/enabled}}\n {{/time}}\n \n {{#toolbox}}\n {{#enabled}}\n <div class="toolbox">\n {{#toolbox.submitButton.enabled}}\n <div class="pwt-btn-submit">{{submitButtonText}}</div>\n {{/toolbox.submitButton.enabled}} \n {{#toolbox.todayButton.enabled}}\n <div class="pwt-btn-today">{{todayButtonText}}</div>\n {{/toolbox.todayButton.enabled}} \n {{#toolbox.calendarSwitch.enabled}}\n <div class="pwt-btn-calendar">{{calendarSwitchText}}</div>\n {{/toolbox.calendarSwitch.enabled}}\n </div>\n {{/enabled}}\n {{^enabled}}\n {{#onlyTimePicker}}\n <div class="toolbox">\n <div class="pwt-btn-submit">{{submitButtonText}}</div>\n </div>\n {{/onlyTimePicker}}\n {{/enabled}}\n {{/toolbox}}\n</div>\n';
module.exports = Template;
/***/
},
/* 2 */
/***/ function (module, exports, __webpack_require__) {
"use strict";
var _createClass = (function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable =
descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(
target,
descriptor.key,
descriptor
);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps)
defineProperties(Constructor.prototype, protoProps);
if (staticProps)
defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError(
"Cannot call a class as a function"
);
}
}
var State = __webpack_require__(11);
var Toolbox = __webpack_require__(12);
var View = __webpack_require__(13);
var Input = __webpack_require__(6);
var API = __webpack_require__(3);
var Navigator = __webpack_require__(7);
var Options = __webpack_require__(8);
var PersianDateWrapper = __webpack_require__(10);
/**
* Main datepicker object, manage every things
*/
var Model = (function () {
/**
* @param inputElement
* @param options
* @private
*/
function Model(inputElement, options) {
_classCallCheck(this, Model);
return this.components(inputElement, options);
}
_createClass(Model, [
{
key: "components",
value: function components(inputElement, options) {
/**
* @desc [initialUnix=null]
* @type {unix}
*/
this.initialUnix = null;
/**
* @desc inputElement=inputElement
* @type {Object}
*/
this.inputElement = inputElement;
/**
* @desc handle works about config
* @type {Options}
*/
this.options = new Options(options, this);
/**
*
* @type {PersianDateWrapper}
*/
this.PersianDate = new PersianDateWrapper(this);
/**
* @desc set and get selected and view and other state
* @type {State}
*/
this.state = new State(this);
this.api = new API(this);
/**
* @desc handle works about input and alt field input element
* @type {Input}
*/
this.input = new Input(this, inputElement);
/**
* @desc render datepicker view base on State
* @type {View}
*/
this.view = new View(this);
/**
* @desc handle works about toolbox
* @type {Toolbox}
*/
this.toolbox = new Toolbox(this);
/**
*
* @param unix
*/
this.updateInput = function (unix) {
this.input.update(unix);
};
this.state.setViewDateTime(
"unix",
this.input.getOnInitState()
);
this.state.setSelectedDateTime(
"unix",
this.input.getOnInitState()
);
this.view.render();
/**
* @desc handle navigation and dateoicker element events
* @type {Navigator}
*/
this.navigator = new Navigator(this);
return this.api;
},
},
]);
return Model;
})();
module.exports = Model;
/***/
},
/* 3 */
/***/ function (module, exports, __webpack_require__) {
"use strict";
var _createClass = (function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable =
descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(
target,
descriptor.key,
descriptor
);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps)
defineProperties(Constructor.prototype, protoProps);
if (staticProps)
defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError(
"Cannot call a class as a function"
);
}
}
/**
* This is the API documentation for persian-datepicker
*/
var API = (function () {
function API(model) {
_classCallCheck(this, API);
this.model = model;
}
/**
* @description get current option object
* @example var pd = $('.selector').persianDatepicker();
* console.log(pd.options);
*/
_createClass(API, [
{
key: "show",
/**
* @description make datepicker visible
* @example var pd = $('.selector').persianDatepicker();
* pd.show();
*/
value: function show() {
this.model.view.show();
this.model.options.onShow(this.model);
return this.model;
},
/**
* @description return datepicker current state
* @since 1.0.0
* @example var pd = $('.selector').persianDatepicker();
* var state = pd.getState();
*
* console.log(state.selected);
* console.log(state.view);
* */
},
{
key: "getState",
value: function getState() {
return this.model.state;
},
/**
* @description make datepicker invisible
* @example var pd = $('.selector').persianDatepicker();
* pd.show();
*/
},
{
key: "hide",
value: function hide() {
this.model.view.hide();
this.model.options.onHide(this.model);
return this.model;
},
/**
* @description toggle datepicker visibility state
* @example var pd = $('.selector').persianDatepicker();
* pd.toggle();
*/
},
{
key: "toggle",
value: function toggle() {
this.model.view.toggle();
this.model.options.onToggle(this.model);
return this.model;
},
/**
* @description destroy every thing clean dom and
* @example var pd = $('.selector').persianDatepicker();
* pd.destroy();
*/
},
{
key: "destroy",
value: function destroy() {
if (this.model) {
this.model.view.destroy();
this.model.options.onDestroy(this.model);
delete this.model;
}
},
/**
* @description set selected date of datepicker accept unix timestamp
* @param unix
* @example var pd = $('.selector').persianDatepicker();
* pd.setDate(1382276091100)
*/
},
{
key: "setDate",
value: function setDate(unix) {
this.model.state.setSelectedDateTime(
"unix",
unix
);
this.model.state.setViewDateTime("unix", unix);
this.model.state.setSelectedDateTime(
"unix",
unix
);
this.model.view.render(this.view);
this.model.options.onSet(unix);
return this.model;
},
},
{
key: "options",
get: function get() {
return this.model.options;
},
/**
* @description set options live
* @example var pd = $('.selector').persianDatepicker();
* pd.options;
* //return current options
* pd.options = {};
* // set options and render datepicker with new options
*/
set: function set(inputOptions) {
var opt = $.extend(
true,
this.model.options,
inputOptions
);
this.model.view.destroy();
this.model.components(
this.model.inputElement,
opt
);
},
},
]);
return API;
})();
module.exports = API;
/***/
},
/* 4 */
/***/ function (module, exports, __webpack_require__) {
"use strict";
var Helper = __webpack_require__(0);
/**
* @description persian-datepicker configuration document
*/
var Config = {
/**
* @description set default calendar mode of datepicker, available options: 'persian', 'gregorian'
* @default 'persian'
* @type string
* @since 1.0.0
*/
calendarType: "persian",
/**
* @description calendar type and localization configuration
* @type object
* @since 1.0.0
* @example
* {
* 'persian': {
* 'locale': 'fa',
* 'showHint': false,
* 'leapYearMode': 'algorithmic' // "astronomical"
* },
*
* 'gregorian': {
* 'locale': 'en',
* 'showHint': false
* }
* }
*
*
*
*/
calendar: {
/**
* @description Persian calendar configuration
* @type object
* @since 1.0.0
*/
persian: {
/**
* @description set locale of Persian calendar available options: 'fa', 'en'
* @default 'fa'
* @type string
* @since 1.0.0
*/
locale: "fa",
/**
* @description if set true, small date hint of this calendar will be shown on another calendar
* @type boolean
* @default false
* @since 1.0.0
*/
showHint: false,
/**
* @description Persian calendar leap year calculation mode, available options: 'algorithmic', 'astronomical'
* @type string
* @link http://babakhani.github.io/PersianWebToolkit/doc/persian-date/leapyear
* @default 'algorithmic'
* @since 1.0.0
*/
leapYearMode: "algorithmic", // "astronomical"
},
/**
* @description Gregorian calendar configuration
* @type object
* @since 1.0.0
*/
gregorian: {
/**
* @description set locale of Gregorian calendar available options: 'fa', 'en'
* @default 'en'
* @type string
* @since 1.0.0
*/
locale: "en",
/**
* @description if set true, small date hint of this calendar will be shown on another calendar
* @type boolean
* @default false
* @since 1.0.0
*/
showHint: false,
},
},
/**
* @description if set true make enable responsive view on mobile devices
* @type boolean
* @since 1.0.0
* @default true
*/
responsive: true,
/**
* @description if true datepicker render inline
* @type boolean
* @default false
*/
inline: false,
/**
* @description If set true datepicker init with input value date, use data-date property when you want set inline datepicker initial value
* @type boolean
* @default true
*/
initialValue: true,
/**
* @description Initial value calendar type, accept: 'persian', 'gregorian'
* @type boolean
* @default true
*/
initialValueType: "gregorian",
/**
* @description from v1.0.0 this options is deprecated, use calendar.persian.locale instead
* @deprecated
* @type boolean
* @default true
*/
persianDigit: false,
/**
* @description default view mode, Acceptable value : day,month,year
* @type {string}
* @default 'day'
*/
viewMode: "day",
/**
* @description the date format, combination of d, dd, m, mm, yy, yyy.
* @link http://babakhani.github.io/PersianWebToolkit/doc/persian-date/#format
* @type {boolean}
* @default 'LLLL'
*/
format: "dddd، DD MMMM YYYY ساعت hh:mm:ss a",
/**
* @description format value of input
* @param unixDate
* @default function
* @example function (unixDate) {
* var self = this;
* var pdate = new persianDate(unixDate);
* pdate.formatPersian = this.persianDigit;
* return pdate.format(self.format);
* }
*/
formatter: function formatter(unixDate) {
var self = this,
pdate = this.model.PersianDate.date(unixDate);
return pdate.format(self.format);
},
/**
* @description An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. acceptable value: : '#elementId','.element-class'
* @type {boolean}
* @default false
* @example
* altField: '#inputAltFirld'
*
* altField: '.input-alt-field'
*/
altField: false,
/**
* @description the date format, combination of d, dd, m, mm, yy, yyy.
* @link http://babakhani.github.io/PersianWebToolkit/doc/persian-date/#format
* @type {string}
* @default 'unix'
*/
altFormat: "unix",
/**
* @description format value of 'altField' input
* @param unixDate
* @default function
* @example function (unixDate) {
* var self = this;
* var thisAltFormat = self.altFormat.toLowerCase();
* if (thisAltFormat === 'gregorian' || thisAltFormat === 'g') {
* return new Date(unixDate);
* }
* if (thisAltFormat === 'unix' || thisAltFormat === 'u') {
* return unixDate;
* }
* else {
* var pd = new persianDate(unixDate);
* pd.formatPersian = this.persianDigit;
* return pd.format(self.altFormat);
* }
* }
*/
altFieldFormatter: function altFieldFormatter(unixDate) {
var self = this,
thisAltFormat = self.altFormat.toLowerCase(),
pd = void 0;
if (
thisAltFormat === "gregorian" ||
thisAltFormat === "g"
) {
return new Date(unixDate);
}
if (thisAltFormat === "unix" || thisAltFormat === "u") {
return unixDate;
} else {
pd = this.model.PersianDate.date(unixDate);
return pd.format(self.altFormat);
}
},
/**
* @description Set min date on datepicker, prevent user select date before given unix time
* @property minDate
* @type Date
* @default null
*/
minDate: null,
/**
* @description Set max date on datepicker, prevent user select date after given unix time
* @property maxDate
* @type Date
* @default null
*/
maxDate: null,
/**
* @description navigator config object
* @type {object}
* @default true
*/
navigator: {
/**
* @description make navigator enable or disable
* @type boolean
* @default true
*/
enabled: true,
/**
* @description navigate by scroll configuration
* @type object
* @description scroll navigation options
*/
scroll: {
/**
* @description if you want make disable scroll navigation set this option false
* @type boolean
* @default true
*/
enabled: true,
},
/**
* @description navigator text config object
*/
text: {
/**
* @description text of next button
* @default '<'
*/
btnNextText: "<i class='bi bi-trash'></i>",
/**
* @description text of prev button
* @default: '>'
*/
btnPrevText: ">",
},
/**
* @description Called when navigator goes to next state
* @event
* @example function (navigator) {
* //log('navigator next ');
* }
*/
onNext: function onNext(datepickerObject) {
Helper.debug(datepickerObject, "Event: onNext");
},
/**
* @description Called when navigator goes to previews state
* @event
* @example function (navigator) {
* //log('navigator prev ');
* }
*/
onPrev: function onPrev(datepickerObject) {
Helper.debug(datepickerObject, "Event: onPrev");
},
/**
* @description Called when navigator switch
* @event
* @example function (datepickerObject) {
// console.log('navigator switch ');
* }
*/
onSwitch: function onSwitch(datepickerObject) {
Helper.debug(
datepickerObject,
"dayPicker Event: onSwitch"
);
},
},
/**
* @description toolbox config object
* @type {object}
* @default true
*/
toolbox: {
/**
* @description boolean option that make toolbar enable or disable
* @type boolean
* @default true
*/
enabled: true,
/**
* @description toolbox button text configuration
* @type object
* @deprecated from 1.0.0
*/
text: {
/**
* @description text of today button, deprecated from 1.0.0
* @type string
* @default 'امروز'
* @deprecated from 1.0.0
*/
btnToday: "امروز",
},
/**
* @description submit button configuration (only shown on mobile)
* @since 1.0.0
*/
submitButton: {
/**
* @description make submit button enable or disable
* @type boolean
* @default false
* @since 1.0.0
*/
enabled: Helper.isMobile,
/**
* @description submit button text
* @since 1.0.0
* @type object
*/
text: {
/**
* @description show when current calendar is Persian
* @since 1.0.0
* @type object
* @default تایید
*/
fa: "تایید",
/**
* @description show when current calendar is Gregorian
* @since 1.0.0
* @type object
* @default submit
*/
en: "submit",
},
/**
* @description Called when submit button clicked
* @since 1.0.0
* @type function
* @event
*/
onSubmit: function onSubmit(datepickerObject) {
Helper.debug(
datepickerObject,
"dayPicker Event: onSubmit"
);
},
},
/**
* @description toolbox today button configuration
* @since 1.0.0
*/
todayButton: {
/**
* @description make toolbox today button enable or disable
* @type boolean
* @since 1.0.0
*/
enabled: true,
/**
* @description today button text
* @since 1.0.0
* @type object
*/
text: {
/**
* @description show when current calendar is Persian
* @since 1.0.0
* @type object
* @default امروز
*/
fa: "امروز",
/**
* @description show when current calendar is Gregorian
* @since 1.0.0
* @type object
* @default today
*/
en: "today",
},
/**
* @description Called when today button clicked
* @since 1.0.0
* @type function
* @event
*/
onToday: function onToday(datepickerObject) {
Helper.debug(
datepickerObject,
"dayPicker Event: onToday"
);
},
},
/**
* @description toolbox calendar switch configuration
* @type object
* @since 1.0.0
*/