Version Description
- PHP 7.2
Download this release
Release Info
Developer | Persianscript |
Plugin | Persian Woocommerce |
Version | 3.6.3 |
Comparing to | |
See all releases |
Code changes from version 3.5.5 to 3.6.3
- assets/css/persianDatepicker-default.css +198 -0
- assets/js/persianDatepicker.js +758 -0
- assets/js/persianDatepicker.min.js +13 -0
- include/class-tools.php +1 -1
- include/tools/class-price.php +3 -1
- include/tools/general.php +22 -18
- readme.txt +8 -4
- woocommerce-persian.php +3 -3
assets/css/persianDatepicker-default.css
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
@keyframes start {
|
3 |
+
from {
|
4 |
+
transform: scale(.5);
|
5 |
+
}
|
6 |
+
to {
|
7 |
+
transform: scale(1);
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
11 |
+
@-webkit-keyframes start {
|
12 |
+
from {
|
13 |
+
-webkit-transform: scale(.5);
|
14 |
+
}
|
15 |
+
to {
|
16 |
+
-webkit-transform: scale(1);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
.rtl{direction:rtl}
|
20 |
+
.pdp-default {
|
21 |
+
position: absolute;
|
22 |
+
direction: rtl;
|
23 |
+
color: #555;
|
24 |
+
box-shadow: 1px 1px 8px 1px rgba(0, 0, 0, 0.19);
|
25 |
+
z-index: 99999;
|
26 |
+
}
|
27 |
+
|
28 |
+
.pdp-default ::-webkit-scrollbar-track
|
29 |
+
{
|
30 |
+
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
|
31 |
+
background-color: #F5F5F5;
|
32 |
+
}
|
33 |
+
|
34 |
+
.pdp-default ::-webkit-scrollbar
|
35 |
+
{
|
36 |
+
width: 15px;
|
37 |
+
background-color: #F5F5F5;
|
38 |
+
}
|
39 |
+
|
40 |
+
.pdp-default ::-webkit-scrollbar-thumb
|
41 |
+
{
|
42 |
+
background-color: #444444;
|
43 |
+
}
|
44 |
+
.pdp-default ::selection{
|
45 |
+
color: #67cdcc;
|
46 |
+
}
|
47 |
+
|
48 |
+
.pdp-default .pdp-header{
|
49 |
+
background-color: #ffffff;
|
50 |
+
border-top: 2px solid #999;
|
51 |
+
border-left: 1px solid #999;
|
52 |
+
border-right: 1px solid #999;
|
53 |
+
border-bottom: none;
|
54 |
+
padding: 2px;
|
55 |
+
font-weight: bold;
|
56 |
+
}
|
57 |
+
|
58 |
+
.pdp-default .yearSelect{
|
59 |
+
overflow-y: auto;
|
60 |
+
direction: ltr;
|
61 |
+
}
|
62 |
+
|
63 |
+
.pdp-default .monthSelect li.disableMonth, .pdp-default .monthSelect li.disableMonth:hover{
|
64 |
+
color: #bbb;
|
65 |
+
background: #eee;
|
66 |
+
cursor: not-allowed;
|
67 |
+
}
|
68 |
+
|
69 |
+
.pdp-default .yearSelect, .pdp-default .monthSelect{
|
70 |
+
font:normal 12px Tahoma;
|
71 |
+
background: #f9f9f9;
|
72 |
+
border: 1px solid #ccc;
|
73 |
+
list-style: none;
|
74 |
+
position: absolute;
|
75 |
+
padding: 0;
|
76 |
+
width: 99.6%;
|
77 |
+
text-align: center;
|
78 |
+
z-index: 9999;
|
79 |
+
animation: start 0.2s;
|
80 |
+
-webkit-animation: start 0.2s;
|
81 |
+
}
|
82 |
+
.pdp-default .selected{
|
83 |
+
background: #15a6eb;
|
84 |
+
color: #ffffff;
|
85 |
+
}
|
86 |
+
|
87 |
+
.pdp-default .yearSelect li, .pdp-default .monthSelect li {
|
88 |
+
padding: 1px;
|
89 |
+
cursor: default;
|
90 |
+
display: inline-table;
|
91 |
+
text-align: center;
|
92 |
+
border: 1px dotted #ddd;
|
93 |
+
}
|
94 |
+
.pdp-default .yearSelect li:hover, .pdp-default .monthSelect li:hover {
|
95 |
+
background: #FF9933;
|
96 |
+
color: #ffffff;
|
97 |
+
border-color: #FF7700;
|
98 |
+
}
|
99 |
+
|
100 |
+
.pdp-default .nextArrow{
|
101 |
+
right:0;
|
102 |
+
}
|
103 |
+
.pdp-default .prevArrow{
|
104 |
+
left:0;
|
105 |
+
}
|
106 |
+
.pdp-default .monthYear{
|
107 |
+
width: 80%;
|
108 |
+
margin: 0 auto;
|
109 |
+
text-align: center;
|
110 |
+
cursor: pointer;
|
111 |
+
}
|
112 |
+
|
113 |
+
.pdp-default .nextArrow, .pdp-default .prevArrow{
|
114 |
+
cursor: pointer;
|
115 |
+
position: absolute;
|
116 |
+
top:1px;
|
117 |
+
padding: 2px;
|
118 |
+
}
|
119 |
+
|
120 |
+
.pdp-default .nextArrow:hover, .pdp-default .prevArrow:hover{
|
121 |
+
color: #0073ea;
|
122 |
+
}
|
123 |
+
|
124 |
+
.pdp-default .cell {
|
125 |
+
display: inline-block;
|
126 |
+
cursor: default;
|
127 |
+
text-align: center;
|
128 |
+
}
|
129 |
+
|
130 |
+
/* Days of the week */
|
131 |
+
.pdp-default .dows {
|
132 |
+
background: #5F5D5D;/*#006fe0;*/
|
133 |
+
color: #fff;
|
134 |
+
}
|
135 |
+
.pdp-default .dow {
|
136 |
+
font: bold 14px 'helvetica';
|
137 |
+
border: 1px solid #5F5D5D;
|
138 |
+
}
|
139 |
+
|
140 |
+
.pdp-default .days{
|
141 |
+
background-color: #ffffff;
|
142 |
+
border: 1px solid #999;
|
143 |
+
border-top: none;
|
144 |
+
font: normal 12px Tahoma;
|
145 |
+
}
|
146 |
+
|
147 |
+
.pdp-default .day{
|
148 |
+
border: 1px solid #f1f1f1;
|
149 |
+
}
|
150 |
+
|
151 |
+
.pdp-default .day:hover{
|
152 |
+
background: #f3f3f3;
|
153 |
+
border: 1px solid #bbb;
|
154 |
+
border-radius: 2px;
|
155 |
+
}
|
156 |
+
.pdp-default .selday, .pdp-default .selday:hover{
|
157 |
+
background: #eadaa6;
|
158 |
+
border-color: #eb5b04;
|
159 |
+
}
|
160 |
+
|
161 |
+
.pdp-default .friday{
|
162 |
+
color: #f38;
|
163 |
+
}
|
164 |
+
|
165 |
+
.pdp-default .today{
|
166 |
+
color: #fff;
|
167 |
+
background: #0073ea;
|
168 |
+
}
|
169 |
+
.pdp-default .today:hover{
|
170 |
+
color: #fff;
|
171 |
+
background: #0073ea;
|
172 |
+
}
|
173 |
+
|
174 |
+
.pdp-default .disday, .pdp-default .disday:hover{
|
175 |
+
color: #B7B5B5;
|
176 |
+
background: #F1F1F1;
|
177 |
+
cursor: not-allowed;
|
178 |
+
}
|
179 |
+
|
180 |
+
.pdp-default .nul{
|
181 |
+
border: 1px solid #f1f1f1;
|
182 |
+
background: #f1f1f1;
|
183 |
+
}
|
184 |
+
|
185 |
+
.pdp-default .pdp-footer{
|
186 |
+
background: #999;
|
187 |
+
font: normal 12px Tahoma;
|
188 |
+
text-align: center;
|
189 |
+
height: 17px;
|
190 |
+
}
|
191 |
+
.pdp-default .pdp-footer .goToday{
|
192 |
+
color: #f0f0f0;
|
193 |
+
text-decoration: none;
|
194 |
+
}
|
195 |
+
.pdp-default .pdp-footer .goToday:hover{
|
196 |
+
color: #ffffff;
|
197 |
+
text-decoration: overline;
|
198 |
+
}
|
assets/js/persianDatepicker.js
ADDED
@@ -0,0 +1,758 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* persianDatepicker v0.1.0
|
3 |
+
* http://github.com/behzadi/persianDatepicker/
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 Mohammad hasan Behzadi All rights reserved.
|
6 |
+
*
|
7 |
+
* Released under the MIT license.
|
8 |
+
*
|
9 |
+
* jalali Date Functions
|
10 |
+
*
|
11 |
+
* Date: Tue Jan 1 2013
|
12 |
+
*/
|
13 |
+
;
|
14 |
+
(function($) {
|
15 |
+
$.fn.persianDatepicker = function(options) {
|
16 |
+
var pluginName = 'persianDatepicker';
|
17 |
+
var instance = this.data(pluginName);
|
18 |
+
if (!instance) {
|
19 |
+
return this.each(function() {
|
20 |
+
return $(this).data(pluginName, new persianDatepicker(this, options));
|
21 |
+
});
|
22 |
+
}
|
23 |
+
return (options === true) ? instance : this;
|
24 |
+
};
|
25 |
+
// persianDatepicker object
|
26 |
+
var persianDatepicker = (function() {
|
27 |
+
function persianDatepicker(element, userOptions) {
|
28 |
+
var defaults = {
|
29 |
+
months: ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"],
|
30 |
+
dowTitle: ["شنبه", "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنج شنبه", "جمعه"],
|
31 |
+
shortDowTitle: ["ش", "ی", "د", "س", "چ", "پ", "ج"],
|
32 |
+
showGregorianDate: !1,
|
33 |
+
persianNumbers: !0,
|
34 |
+
formatDate: "YYYY/MM/DD",
|
35 |
+
selectedBefore: !1,
|
36 |
+
selectedDate: null,
|
37 |
+
startDate: null,
|
38 |
+
endDate: null,
|
39 |
+
prevArrow: '\u25c4',
|
40 |
+
nextArrow: '\u25ba',
|
41 |
+
theme: 'default',
|
42 |
+
alwaysShow: !1,
|
43 |
+
selectableYears: null,
|
44 |
+
selectableMonths: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
45 |
+
cellWidth: 25, // by px
|
46 |
+
cellHeight: 20, // by px
|
47 |
+
fontSize: 13, // by px
|
48 |
+
isRTL: !1,
|
49 |
+
closeOnBlur: !0,
|
50 |
+
calendarPosition: {
|
51 |
+
x: 0,
|
52 |
+
y: 0,
|
53 |
+
},
|
54 |
+
onShow: function() {},
|
55 |
+
onHide: function() {},
|
56 |
+
onSelect: function() {},
|
57 |
+
onRender: function() {}
|
58 |
+
};
|
59 |
+
var self = this;
|
60 |
+
self.el = $(element);
|
61 |
+
var el = self.el;
|
62 |
+
self.options = $.extend(false, {}, defaults, userOptions);
|
63 |
+
var options = self.options;
|
64 |
+
|
65 |
+
_fontSize = options.fontSize;
|
66 |
+
_cw = parseInt(options.cellWidth);
|
67 |
+
_ch = parseInt(options.cellHeight);
|
68 |
+
self.cellStyle = "style='width:" + _cw + "px;height:" + _ch + "px;line-height:" + _ch + "px; font-size:" + (_fontSize) + "px; ' ";
|
69 |
+
self.headerStyle = "style='height:" + _ch + "px;line-height:" + _ch + "px; font-size:" + (_fontSize + 4) + "px;' ";
|
70 |
+
self.selectUlStyle = "style='margin-top:" + _ch + "px;height:" + (_ch * 7 + 20) + "px; font-size:" + (_fontSize - 2) + "px;' ";
|
71 |
+
self.selectMonthLiStyle = "style='height:" + (_ch * 7 + 7) / (4) + "px;line-height:" + (_ch * 7 + 7) / (4) + "px; width:" + (6.7 * _cw) / (3) + "px;width:" + (6.7 * _cw) / (3) + "px\\9;' ";
|
72 |
+
self.selectYearLiStyle = "style='height:" + (_ch * 7 + 10) / (6) + "px;line-height:" + (_ch * 7 + 10) / (6) + "px; width:" + (6.7 * _cw - 14) / (3) + "px;width:" + (6.7 * _cw - 15) / (3) + "px\\9;' ";
|
73 |
+
self.footerStyle = "style='height:" + _ch + "px;line-height:" + _ch + "px; font-size:" + _fontSize + "px;' ";
|
74 |
+
|
75 |
+
self.jDateFunctions = new jDateFunctions();
|
76 |
+
|
77 |
+
if (self.options.startDate != null) {
|
78 |
+
if (self.options.startDate == "today")
|
79 |
+
self.options.startDate = self.now().toString("YYYY/MM/DD");
|
80 |
+
if (self.options.endDate == "today")
|
81 |
+
self.options.endDate = self.now().toString("YYYY/MM/DD");
|
82 |
+
self.options.selectedDate = self.options.startDate;
|
83 |
+
}
|
84 |
+
|
85 |
+
if (self.options.selectedDate == undefined) {
|
86 |
+
var patt1 = new RegExp('^([1-9][0-9][0-9][0-9])/([0]?[1-9]|[1][0-2])/([0]?[1-9]|[1-2][0-9]|[3][0-1])$');
|
87 |
+
if (el.is('input')) {
|
88 |
+
if (patt1.test(el.val()))
|
89 |
+
self.options.selectedDate = el.val();
|
90 |
+
} else {
|
91 |
+
if (patt1.test(el.html()))
|
92 |
+
self.options.selectedDate = el.html();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
self._persianDate = (self.options.selectedDate != undefined) ? new persianDate().parse(self.options.selectedDate) : self.now();
|
97 |
+
if (options.selectableYears != undefined && options.selectableYears._indexOf(self._persianDate.year) == -1)
|
98 |
+
self._persianDate.year = options.selectableYears[0];
|
99 |
+
if (self.options.selectableMonths._indexOf(self._persianDate.month) == -1)
|
100 |
+
self._persianDate.month = options.selectableMonths[0];
|
101 |
+
|
102 |
+
self.persianDate = self._persianDate;
|
103 |
+
self._id = 'pdp-' + Math.round(Math.random() * 1e7);
|
104 |
+
self.persianDate.formatDate = options.formatDate;
|
105 |
+
self.calendar = $('<div id="' + self._id + '" class="pdp-' + options.theme + '" />');
|
106 |
+
|
107 |
+
if (self.options.startDate != null) {
|
108 |
+
self.options.selectableYears = [];
|
109 |
+
for (var i = self.persianDate.parse(self.options.startDate).year; i <= self.persianDate.parse(self.options.endDate).year; i++)
|
110 |
+
self.options.selectableYears.push(i);
|
111 |
+
}
|
112 |
+
|
113 |
+
if (!(el.attr('pdp-id') || '').length) {
|
114 |
+
el.attr('pdp-id', self._id);
|
115 |
+
}
|
116 |
+
|
117 |
+
el
|
118 |
+
.addClass('pdp-el')
|
119 |
+
.on('click', function(e) {
|
120 |
+
self.show(e);
|
121 |
+
})
|
122 |
+
.on('focus', function(e) {
|
123 |
+
self.show(e);
|
124 |
+
});
|
125 |
+
|
126 |
+
// close on blur
|
127 |
+
if (options.closeOnBlur) {
|
128 |
+
el.on('blur', function(e) {
|
129 |
+
if (!self.calendar.is(":hover"))
|
130 |
+
self.hide(e);
|
131 |
+
});
|
132 |
+
}
|
133 |
+
|
134 |
+
if (options.selectedBefore) {
|
135 |
+
if (self.options.selectedDate != undefined) {
|
136 |
+
//>jd = self.jDateFunctions.getJulianDayFromPersian(self.persianDate.parse(self.options.selectedDate));
|
137 |
+
self.showDate(el, self.persianDate.parse(self.options.selectedDate).toString("YYYY/MM/DD/" + self.jDateFunctions.getWeekday(self.persianDate.parse(self.options.selectedDate)), self.now().gDate, options.showGregorianDate));
|
138 |
+
} else {
|
139 |
+
//>jd = self.jDateFunctions.getJulianDayFromPersian(self.now());
|
140 |
+
self.showDate(el, self.now().toString("YYYY/MM/DD/" + self.jDateFunctions.getWeekday(self.now())), self.now().gDate, options.showGregorianDate);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
if (options.isRTL)
|
145 |
+
el.addClass('rtl');
|
146 |
+
if (self.calendar.length && !options.alwaysShow) {
|
147 |
+
self.calendar.hide();
|
148 |
+
}
|
149 |
+
$(document).bind('mouseup', function(e) {
|
150 |
+
var target = e.target;
|
151 |
+
var calendar = self.calendar;
|
152 |
+
if (!el.is(target) && !calendar.is(target) && calendar.has(target).length === 0 && calendar.is(':visible')) {
|
153 |
+
self.hide();
|
154 |
+
}
|
155 |
+
var container = $(".pdp-" + options.theme + " .yearSelect");
|
156 |
+
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
157 |
+
container.hide();
|
158 |
+
}
|
159 |
+
container = $(".pdp-" + options.theme + " .monthSelect");
|
160 |
+
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
161 |
+
container.hide();
|
162 |
+
}
|
163 |
+
});
|
164 |
+
var onResize = function() {
|
165 |
+
var elPos = el.offset();
|
166 |
+
self.calendar.css({
|
167 |
+
top: (elPos.top + el.outerHeight() + options.calendarPosition.y) + 'px',
|
168 |
+
left: (elPos.left + options.calendarPosition.x) + 'px'
|
169 |
+
});
|
170 |
+
};
|
171 |
+
self.onresize = onResize;
|
172 |
+
$(window).resize(onResize);
|
173 |
+
$('body').append(self.calendar);
|
174 |
+
self.render();
|
175 |
+
onResize();
|
176 |
+
};
|
177 |
+
|
178 |
+
// persianDatepicker methods
|
179 |
+
persianDatepicker.prototype = {
|
180 |
+
show: function() {
|
181 |
+
this.calendar.show();
|
182 |
+
$.each($('.pdp-el').not(this.el), function(i, o) {
|
183 |
+
if (o.length) {
|
184 |
+
o.options.onHide(o.calendar);
|
185 |
+
}
|
186 |
+
});
|
187 |
+
this.options.onShow(this.calendar);
|
188 |
+
this.onresize();
|
189 |
+
},
|
190 |
+
hide: function() {
|
191 |
+
this.options.onHide(this.calendar);
|
192 |
+
|
193 |
+
if (this.options && !this.options.alwaysShow) {
|
194 |
+
this.calendar.hide();
|
195 |
+
}
|
196 |
+
|
197 |
+
},
|
198 |
+
render: function() {
|
199 |
+
this.calendar.children().remove();
|
200 |
+
this.header();
|
201 |
+
this.dows();
|
202 |
+
this.content();
|
203 |
+
this.footer();
|
204 |
+
this.options.onRender();
|
205 |
+
},
|
206 |
+
header: function() {
|
207 |
+
var self = this;
|
208 |
+
_monthYear = $('<div class="" />');
|
209 |
+
_monthYear.appendTo(this.calendar);
|
210 |
+
_head = $('<div class="pdp-header" ' + self.headerStyle + ' />');
|
211 |
+
_head.appendTo(this.calendar);
|
212 |
+
_next = $('<div class="nextArrow" />')
|
213 |
+
.html(this.options.nextArrow)
|
214 |
+
.attr('title', 'ماه بعد');
|
215 |
+
|
216 |
+
/*yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy*/
|
217 |
+
if (self.options.endDate == null || (self.persianDate.parse(self.options.endDate).year > self.persianDate.year || self.persianDate.parse(self.options.endDate).month > self.persianDate.month)) {
|
218 |
+
_next.bind("click", function() {
|
219 |
+
nextMonth = self.persianDate.month + 1;
|
220 |
+
for (; self.options.selectableMonths._indexOf(nextMonth) == -1 && nextMonth < 13; nextMonth++)
|
221 |
+
;
|
222 |
+
self.persianDate.addMonth(nextMonth - self.persianDate.month);
|
223 |
+
self.render();
|
224 |
+
});
|
225 |
+
_next.removeClass("disabled");
|
226 |
+
} else {
|
227 |
+
_next.addClass("disabled");
|
228 |
+
}
|
229 |
+
|
230 |
+
_next.appendTo(_head);
|
231 |
+
var _monthSelect = $('<ul class="monthSelect" ' + self.selectUlStyle + ' />').hide();
|
232 |
+
var _yearSelect = $('<ul class="yearSelect" ' + self.selectUlStyle + ' />').hide();
|
233 |
+
// Build month label
|
234 |
+
var _monthText = $('<span/>')
|
235 |
+
.html(self.options.months[self.persianDate.month - 1])
|
236 |
+
.mousedown(function() {
|
237 |
+
return false;
|
238 |
+
})
|
239 |
+
.click(function(e) {
|
240 |
+
e.stopPropagation();
|
241 |
+
_yearSelect.css({
|
242 |
+
display: 'none'
|
243 |
+
});
|
244 |
+
_monthSelect.css({
|
245 |
+
display: 'inline-block'
|
246 |
+
});
|
247 |
+
});
|
248 |
+
var _yearText = $('<span/>')
|
249 |
+
.html(self.options.persianNumbers ? self.jDateFunctions.toPersianNums(self.persianDate.year) : self.persianDate.year)
|
250 |
+
.mousedown(function() {
|
251 |
+
return false;
|
252 |
+
})
|
253 |
+
.click(function(e) {
|
254 |
+
e.stopPropagation();
|
255 |
+
_monthSelect.css({
|
256 |
+
display: 'none'
|
257 |
+
});
|
258 |
+
_yearSelect.css({
|
259 |
+
display: 'inline-block'
|
260 |
+
});
|
261 |
+
_yearSelect.scrollTop(70);
|
262 |
+
});
|
263 |
+
|
264 |
+
//----
|
265 |
+
_startDate = self.options.startDate != null ? self.persianDate.parse(self.options.startDate) : self.persianDate.parse("1/1/1");
|
266 |
+
_endDate = self.options.endDate != null ? self.persianDate.parse(self.options.endDate) : self.persianDate.parse("9999/1/1");
|
267 |
+
|
268 |
+
// selectable years
|
269 |
+
var getSelectableYears = function(f, l) {
|
270 |
+
var pre = !1;
|
271 |
+
if (f === undefined && l === undefined) {
|
272 |
+
b = self.persianDate.year - 7;
|
273 |
+
a = self.persianDate.year + 14;
|
274 |
+
} else if (l == 0) {
|
275 |
+
b = f - 6;
|
276 |
+
a = f;
|
277 |
+
pre = !0;
|
278 |
+
} else if (f == 0) {
|
279 |
+
b = l + 1;
|
280 |
+
a = b + 6;
|
281 |
+
}
|
282 |
+
var arr = [];
|
283 |
+
for (i = b; i < a && b > 0; i++)
|
284 |
+
arr.push(parseInt(i));
|
285 |
+
$.each(self.options.selectableYears || ((pre) ? arr.reverse() : arr), function(i, v) {
|
286 |
+
var o = $('<li ' + self.selectYearLiStyle + ' />').html(self.options.persianNumbers ? self.jDateFunctions.toPersianNums(v) : v);
|
287 |
+
if (v == self.persianDate.year) {
|
288 |
+
o.addClass('selected');
|
289 |
+
}
|
290 |
+
o.attr("value", v);
|
291 |
+
o.bind("click", function() {
|
292 |
+
self.persianDate.date = 1;
|
293 |
+
self.persianDate.year = parseInt(v);
|
294 |
+
if (_endDate.year == v || _endDate.year == 9999)
|
295 |
+
self.persianDate.month = _endDate.month;
|
296 |
+
if (_startDate.year == v || _startDate.year == 9999)
|
297 |
+
self.persianDate.month = _startDate.month;
|
298 |
+
self.render();
|
299 |
+
});
|
300 |
+
(pre) ? _yearSelect.prepend(o): _yearSelect.append(o);
|
301 |
+
});
|
302 |
+
};
|
303 |
+
getSelectableYears();
|
304 |
+
|
305 |
+
// selectable months
|
306 |
+
for (i = 1; i <= 12; i++) {
|
307 |
+
var m = self.options.months[i - 1];
|
308 |
+
var o = (self.options.selectableMonths._indexOf(i) == -1 || (_startDate.year == self.persianDate.year && _startDate.month > i) || (_endDate.year == self.persianDate.year && i > _endDate.month)) ? $('<li class="disableMonth" ' + self.selectMonthLiStyle + ' />').html(m) : $('<li ' + self.selectMonthLiStyle + ' />').html(m);
|
309 |
+
if (i == self.persianDate.month) {
|
310 |
+
o.addClass('selected');
|
311 |
+
}
|
312 |
+
o.data('month', {
|
313 |
+
month: m,
|
314 |
+
monthNum: i
|
315 |
+
});
|
316 |
+
if (!o.hasClass('disableMonth')) {
|
317 |
+
o.bind("click", function() {
|
318 |
+
self.persianDate.date = 1;
|
319 |
+
self.persianDate.month = $(this).data('month').monthNum;
|
320 |
+
self.render();
|
321 |
+
});
|
322 |
+
}
|
323 |
+
_monthSelect.append(o);
|
324 |
+
}
|
325 |
+
|
326 |
+
// selectable years
|
327 |
+
_yearSelect.bind("scroll", function() {
|
328 |
+
if (self.options.selectableYears == undefined) {
|
329 |
+
c = $(this).find("li").length;
|
330 |
+
firstYear = parseInt($(this).children("li:first").val());
|
331 |
+
lastYear = parseInt($(this).children("li:last").val());
|
332 |
+
lisHeight = c / 3 * ($(this).find("li:first").height() + 4);
|
333 |
+
_com = $(this).scrollTop().toString().length * 500;
|
334 |
+
if ($(this).scrollTop() < _com.toString().length * 100 && firstYear >= 1) {
|
335 |
+
getSelectableYears(firstYear, 0);
|
336 |
+
}
|
337 |
+
|
338 |
+
_com = $(this).scrollTop().toString().length * 100;
|
339 |
+
if ((lisHeight - $(this).scrollTop()) > -_com && (lisHeight - $(this).scrollTop()) < _com) {
|
340 |
+
getSelectableYears(0, lastYear);
|
341 |
+
$(this).scrollTop($(this).scrollTop() - 50);
|
342 |
+
}
|
343 |
+
if ($(this).scrollTop() < _com.toString().length && firstYear >= 30) {
|
344 |
+
$(this).scrollTop(_com.toString().length * 100);
|
345 |
+
}
|
346 |
+
}
|
347 |
+
});
|
348 |
+
_monthYear.append(_monthSelect).append(_yearSelect);
|
349 |
+
var titleYearMonth = $('<div class="monthYear" />')
|
350 |
+
.append(_monthText)
|
351 |
+
.append("<span> </span>")
|
352 |
+
.append(_yearText);
|
353 |
+
_head.append(titleYearMonth);
|
354 |
+
_prev = $('<div class="prevArrow" />')
|
355 |
+
.html(this.options.prevArrow)
|
356 |
+
.attr('title', 'ماه قبل');
|
357 |
+
|
358 |
+
if (self.options.startDate == null || (self.persianDate.parse(self.options.startDate).year < self.persianDate.year || self.persianDate.parse(self.options.startDate).month < self.persianDate.month)) {
|
359 |
+
_prev.bind("click", function() {
|
360 |
+
//prevMonth = self.persianDate.month - 1;
|
361 |
+
//for (; self.options.selectableMonths._indexOf(prevMonth) == -1 && prevMonth > 1; prevMonth--);
|
362 |
+
//self.persianDate.addMonth(-(self.persianDate.month - prevMonth));
|
363 |
+
self.persianDate.addMonth(-1);
|
364 |
+
self.render();
|
365 |
+
});
|
366 |
+
_prev.removeClass("disabled");
|
367 |
+
} else {
|
368 |
+
_prev.addClass("disabled");
|
369 |
+
}
|
370 |
+
|
371 |
+
_prev.appendTo(_head);
|
372 |
+
},
|
373 |
+
// days of week title
|
374 |
+
dows: function() {
|
375 |
+
_row = $('<div class="dows" />');
|
376 |
+
for (i = 0; i < 7; i++) {
|
377 |
+
_cell = $('<div class="dow cell " ' + this.cellStyle + ' />')
|
378 |
+
.html(this.options.shortDowTitle[i]);
|
379 |
+
_cell.appendTo(_row);
|
380 |
+
}
|
381 |
+
_row.appendTo(this.calendar);
|
382 |
+
},
|
383 |
+
content: function() {
|
384 |
+
var self = this;
|
385 |
+
_days = $('<div class="days" />');
|
386 |
+
_days.appendTo(this.calendar);
|
387 |
+
jd = self.persianDate;
|
388 |
+
jd.date = 1;
|
389 |
+
_start = self.jDateFunctions.getWeekday(self.persianDate);
|
390 |
+
_end = self.jDateFunctions.getLastDayOfMonth(self.persianDate);
|
391 |
+
for (var row = 0, cellIndex = 0; row < 5 + 1; row++) {
|
392 |
+
_row = $('<div />');
|
393 |
+
for (var col = 0; col < 7; col++, cellIndex++) {
|
394 |
+
if (cellIndex < _start || cellIndex - _start + 1 > _end) {
|
395 |
+
_cell = $('<div class="nul cell " ' + self.cellStyle + ' />')
|
396 |
+
.html(' ');
|
397 |
+
} else {
|
398 |
+
_dt = self.getDate(self.persianDate, cellIndex - _start + 1);
|
399 |
+
_today = '', _selday = '', _disday = '';
|
400 |
+
if (self.now().compare(_dt) == 0)
|
401 |
+
_today = 'today';
|
402 |
+
|
403 |
+
if (self.options.startDate != null && (self.persianDate.parse(self.options.startDate).compare(_dt) == -1 || self.persianDate.parse(self.options.endDate).compare(_dt) == 1))
|
404 |
+
_disday = 'disday';
|
405 |
+
|
406 |
+
if (self.options.selectedDate != undefined) {
|
407 |
+
if (self.persianDate.parse(self.options.selectedDate).date == cellIndex - _start + 1)
|
408 |
+
_selday = 'selday';
|
409 |
+
} else if (cellIndex - _start + 1 == self.now().date)
|
410 |
+
_selday = 'selday';
|
411 |
+
_fri = col == 6 ? 'friday' : '';
|
412 |
+
_cell = $('<div class="day cell ' + _fri + ' ' + _today + ' ' + _selday + ' ' + _disday + '" ' + self.cellStyle + ' />');
|
413 |
+
_cell.attr("data-jdate", _dt.toString("YYYY/MM/DD"));
|
414 |
+
_cell.attr("data-gdate", self.jDateFunctions.getGDate(_dt)._toString("YYYY/MM/DD"));
|
415 |
+
_cell.html(self.options.persianNumbers ? self.jDateFunctions.toPersianNums(cellIndex - _start + 1) : cellIndex - _start + 1);
|
416 |
+
|
417 |
+
if (self.options.startDate == undefined || (self.persianDate.parse(self.options.startDate).compare(_dt) != -1 && self.persianDate.parse(self.options.endDate).compare(_dt) != 1))
|
418 |
+
_cell.bind("click", function() {
|
419 |
+
self.calendar.find(".day").removeClass("selday");
|
420 |
+
$(this).addClass("selday");
|
421 |
+
if (self.options.showGregorianDate)
|
422 |
+
self.showDate(self.el, $(this).data('jdate'), $(this).data('gdate'), !0);
|
423 |
+
else
|
424 |
+
self.showDate(self.el, $(this).data('jdate'), $(this).data('gdate'), !1);
|
425 |
+
|
426 |
+
self.hide();
|
427 |
+
});
|
428 |
+
}
|
429 |
+
_cell.appendTo(_row);
|
430 |
+
}
|
431 |
+
_row.appendTo(_days);
|
432 |
+
}
|
433 |
+
|
434 |
+
},
|
435 |
+
footer: function() {
|
436 |
+
var self = this;
|
437 |
+
_footer = $('<div class="pdp-footer" ' + self.footerStyle + ' />');
|
438 |
+
_footer.appendTo(this.calendar);
|
439 |
+
|
440 |
+
if (self.options.selectableMonths._indexOf(self.persianDate.month) > -1) {
|
441 |
+
_goToday = $('<a class="goToday" />');
|
442 |
+
_goToday.attr("data-jdate", self.now().toString("YYYY/MM/DD/DW"));
|
443 |
+
_goToday.attr("data-gdate", self.jDateFunctions.getGDate(self.now()));
|
444 |
+
_goToday
|
445 |
+
.attr("href", "javascript:;")
|
446 |
+
.html('هم اکنون');
|
447 |
+
if (self.options.startDate == null)
|
448 |
+
_goToday.bind("click", function() {
|
449 |
+
self.persianDate = self.now();
|
450 |
+
|
451 |
+
self.showDate(self.el, $(this).data('jdate'), $(this).data('gdate'), self.options.showGregorianDate);
|
452 |
+
|
453 |
+
self.calendar.find(".day").removeClass("selday");
|
454 |
+
self.render();
|
455 |
+
self.calendar.find(".today").addClass("selday");
|
456 |
+
self.hide();
|
457 |
+
});
|
458 |
+
_goToday.appendTo(_footer);
|
459 |
+
|
460 |
+
}
|
461 |
+
|
462 |
+
},
|
463 |
+
showDate: function(el, jDate, gDate, showGdate) {
|
464 |
+
var self = this;
|
465 |
+
jDate = self.persianDate.parse(jDate).toString(self.options.formatDate);
|
466 |
+
gDate = new Date(gDate)._toString(self.options.formatDate);
|
467 |
+
if (el.is('input:text')) {
|
468 |
+
if (showGdate)
|
469 |
+
el.val(gDate);
|
470 |
+
else
|
471 |
+
el.val(jDate);
|
472 |
+
} else {
|
473 |
+
if (showGdate)
|
474 |
+
el.html(gDate);
|
475 |
+
else
|
476 |
+
el.html(jDate);
|
477 |
+
}
|
478 |
+
|
479 |
+
el.attr('data-jDate', jDate);
|
480 |
+
el.attr('data-gDate', gDate);
|
481 |
+
|
482 |
+
this.options.onSelect();
|
483 |
+
},
|
484 |
+
getDate: function(pd, d) {
|
485 |
+
pd.date = d;
|
486 |
+
pd.day = this.jDateFunctions.getWeekday(pd)
|
487 |
+
return pd;
|
488 |
+
},
|
489 |
+
now: function() {
|
490 |
+
return this.jDateFunctions.gregorian_to_jalali(new Date());
|
491 |
+
},
|
492 |
+
};
|
493 |
+
// Return the persianDatepicker plugin
|
494 |
+
return persianDatepicker;
|
495 |
+
})();
|
496 |
+
|
497 |
+
(function() {
|
498 |
+
//padleft
|
499 |
+
Number.prototype.padLeft = function(base, chr) {
|
500 |
+
var len = (String(base || 10).length - String(this).length) + 1;
|
501 |
+
return len > 0 ? new Array(len).join(chr || '0') + this : this;
|
502 |
+
}
|
503 |
+
|
504 |
+
// format Date with _toString()
|
505 |
+
Date.prototype._toString = function(formatDate) {
|
506 |
+
|
507 |
+
months = ["Januray", "February", "March", "April", "May", "June", "Julay", "August", "September", "October", "November", "December"];
|
508 |
+
dows = ["Sun", "Mon", "Tue", "Wed", "Tur", "Fri", "Sat"];
|
509 |
+
if (formatDate === undefined || formatDate == "default")
|
510 |
+
return this.toLocaleDateString();
|
511 |
+
|
512 |
+
return (
|
513 |
+
formatDate
|
514 |
+
.replace("YYYY", this.getFullYear())
|
515 |
+
.replace("MM", (this.getMonth() + 1))
|
516 |
+
.replace("DD", this.getDate())
|
517 |
+
.replace("0M", (this.getMonth() + 1) > 9 ? this.getMonth() + 1 : '0' + (this.getMonth() + 1))
|
518 |
+
.replace("0D", this.getDate() > 9 ? this.getDate() : '0' + this.getDate())
|
519 |
+
.replace("hh", this.getHours() == 0 ? new Date().getHours() : this.getHours())
|
520 |
+
.replace("mm", this.getMinutes() == 0 ? new Date().getMinutes() : this.getMinutes())
|
521 |
+
.replace("ss", this.getSeconds() == 0 ? new Date().getSeconds() : this.getSeconds())
|
522 |
+
.replace("ms", this.getMilliseconds() == 0 ? new Date().getMilliseconds() : this.getMilliseconds())
|
523 |
+
.replace("tm", (this.getHours() >= 12 && this.getMinutes() > 0) ? "PM" : "AM")
|
524 |
+
.replace("NM", months[this.getMonth()])
|
525 |
+
.replace("DW", this.getDay())
|
526 |
+
.replace("ND", dows[this.getDay()])
|
527 |
+
)
|
528 |
+
};
|
529 |
+
// _indexOf() for arrays
|
530 |
+
Array.prototype._indexOf = function(value) {
|
531 |
+
return $.inArray(value, this);
|
532 |
+
};
|
533 |
+
})();
|
534 |
+
})(jQuery); // end of persianDatepicker plugin
|
535 |
+
|
536 |
+
// persianDate object
|
537 |
+
var persianDate = (function() {
|
538 |
+
function persianDate() {
|
539 |
+
var self = this;
|
540 |
+
self.months = ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"];
|
541 |
+
self.dowTitle = ["شنبه", "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنج شنبه", "جمعه"];
|
542 |
+
self.year = 1300;
|
543 |
+
self.month = 1;
|
544 |
+
self.date = 1;
|
545 |
+
self.day = 1;
|
546 |
+
self.gDate = new Date();
|
547 |
+
};
|
548 |
+
persianDate.prototype = {
|
549 |
+
now: function() {
|
550 |
+
var jdf = new jDateFunctions();
|
551 |
+
return jdf.gregorian_to_jalali(new Date());
|
552 |
+
},
|
553 |
+
addDay: function(d) {
|
554 |
+
var jdf = new jDateFunctions();
|
555 |
+
var to = d > 0 ? d : -d;
|
556 |
+
for (var i = 0; i < to; i++) {
|
557 |
+
var r = new persianDate();
|
558 |
+
r.month = this.month;
|
559 |
+
r.year = this.year;
|
560 |
+
r = r.addMonth(-1);
|
561 |
+
var lastDayOfMonth = d > 0 ? jdf.getLastDayOfMonth(this) : jdf.getLastDayOfMonth(r);
|
562 |
+
d > 0 ? this.date += 1 : this.date -= 1;
|
563 |
+
if (d > 0) {
|
564 |
+
if (this.date > lastDayOfMonth) {
|
565 |
+
this.date = 1;
|
566 |
+
this.addMonth(1);
|
567 |
+
}
|
568 |
+
} else if (d < 0) {
|
569 |
+
if (this.month > 1 && this.date > lastDayOfMonth) {
|
570 |
+
this.date = 1;
|
571 |
+
this.addMonth(1);
|
572 |
+
} else if (this.date == 0) {
|
573 |
+
this.addMonth(-1);
|
574 |
+
this.date = lastDayOfMonth;
|
575 |
+
}
|
576 |
+
}
|
577 |
+
|
578 |
+
}
|
579 |
+
return this;
|
580 |
+
},
|
581 |
+
addMonth: function(d) {
|
582 |
+
var to = d > 0 ? d : -d;
|
583 |
+
for (var i = 0; i < to; i++) {
|
584 |
+
d > 0 ? this.month += 1 : this.month -= 1;
|
585 |
+
if (this.month == 13) {
|
586 |
+
this.month = 1;
|
587 |
+
this.addYear(1);
|
588 |
+
} else if (this.month == 0) {
|
589 |
+
this.month = 12;
|
590 |
+
this.addYear(-1);
|
591 |
+
}
|
592 |
+
}
|
593 |
+
return this;
|
594 |
+
},
|
595 |
+
addYear: function(d) {
|
596 |
+
this.year += d;
|
597 |
+
return this;
|
598 |
+
},
|
599 |
+
compare: function(d) {
|
600 |
+
if (d.year == this.year && d.month == this.month && d.date == this.date)
|
601 |
+
return 0;
|
602 |
+
if (d.year > this.year)
|
603 |
+
return 1;
|
604 |
+
if (d.year == this.year && d.month > this.month)
|
605 |
+
return 1;
|
606 |
+
if (d.year == this.year && d.month == this.month && d.date > this.date)
|
607 |
+
return 1;
|
608 |
+
return -1;
|
609 |
+
},
|
610 |
+
parse: function(s) {
|
611 |
+
arr = s.split("/");
|
612 |
+
y = arr[0];
|
613 |
+
m = arr[1];
|
614 |
+
d = arr[2];
|
615 |
+
var r = new persianDate();
|
616 |
+
jdf = new jDateFunctions();
|
617 |
+
r.year = parseInt(y), r.month = parseInt(m), r.date = parseInt(d), r.day = jdf.getWeekday(r), r.gDate = jdf.jalali_to_gregorian(r);
|
618 |
+
return r;
|
619 |
+
},
|
620 |
+
toString: function(formatDate) {
|
621 |
+
if (formatDate === undefined)
|
622 |
+
return this.year + "/" + this.month + "/" + this.date;
|
623 |
+
return (
|
624 |
+
formatDate
|
625 |
+
.replace("YYYY", this.year)
|
626 |
+
.replace("MM", this.month)
|
627 |
+
.replace("DD", this.date)
|
628 |
+
.replace("0M", this.month > 9 ? this.month : "0" + this.month.toString())
|
629 |
+
.replace("0D", this.date > 9 ? this.date : "0" + this.date.toString())
|
630 |
+
.replace("hh", this.gDate.getHours())
|
631 |
+
.replace("mm", this.gDate.getMinutes())
|
632 |
+
.replace("ss", this.gDate.getSeconds())
|
633 |
+
.replace("tm", (this.gDate.getHours() >= 12 && this.gDate.getMinutes() > 0) ? "ب.ظ" : "ق.ظ")
|
634 |
+
.replace("ms", this.gDate.getMilliseconds())
|
635 |
+
.replace("NM", this.months[this.month - 1])
|
636 |
+
.replace("DW", this.day)
|
637 |
+
.replace("ND", this.dowTitle[this.day])
|
638 |
+
)
|
639 |
+
},
|
640 |
+
};
|
641 |
+
return persianDate;
|
642 |
+
})();
|
643 |
+
|
644 |
+
// jalali Date Functions from NASA.gov
|
645 |
+
var jDateFunctions = (function() {
|
646 |
+
function jDateFunctions() {};
|
647 |
+
|
648 |
+
jDateFunctions.prototype = {
|
649 |
+
toPersianNums: function(s) {
|
650 |
+
strnum = s.toString();
|
651 |
+
nums = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
|
652 |
+
res = '';
|
653 |
+
for (i = 0; i < strnum.length; i++)
|
654 |
+
res += nums[parseInt(strnum[i])];
|
655 |
+
return res;
|
656 |
+
},
|
657 |
+
|
658 |
+
gregorian_to_jalali: function (dt) {
|
659 |
+
gy = dt.getFullYear();
|
660 |
+
gm = dt.getMonth()+1;
|
661 |
+
gd = dt.getDate();
|
662 |
+
g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
663 |
+
if (gy > 1600) {
|
664 |
+
jy = 979;
|
665 |
+
gy -= 1600;
|
666 |
+
} else {
|
667 |
+
jy = 0;
|
668 |
+
gy -= 621;
|
669 |
+
}
|
670 |
+
gy2 = (gm > 2) ? (gy + 1) : gy;
|
671 |
+
days = (365 * gy) + (parseInt((gy2 + 3) / 4)) - (parseInt((gy2 + 99) / 100)) + (parseInt((gy2 + 399) / 400)) - 80 + gd + g_d_m[gm - 1];
|
672 |
+
jy += 33 * (parseInt(days / 12053));
|
673 |
+
days %= 12053;
|
674 |
+
jy += 4 * (parseInt(days / 1461));
|
675 |
+
days %= 1461;
|
676 |
+
if (days > 365) {
|
677 |
+
jy += parseInt((days - 1) / 365);
|
678 |
+
days = (days - 1) % 365;
|
679 |
+
}
|
680 |
+
jm = (days < 186) ? 1 + parseInt(days / 31) : 7 + parseInt((days - 186) / 30);
|
681 |
+
jd = 1 + ((days < 186) ? (days % 31) : ((days - 186) % 30));
|
682 |
+
dt = new Date();
|
683 |
+
pd = new persianDate();
|
684 |
+
pd.year = jy;
|
685 |
+
pd.month = jm;
|
686 |
+
pd.date = jd;
|
687 |
+
pd.gDate = dt;
|
688 |
+
return pd;
|
689 |
+
},
|
690 |
+
|
691 |
+
jalali_to_gregorian: function (pd) {
|
692 |
+
jy = pd.year;
|
693 |
+
jm = pd.month;
|
694 |
+
jd = pd.date;
|
695 |
+
if (jy > 979) {
|
696 |
+
gy = 1600;
|
697 |
+
jy -= 979;
|
698 |
+
} else {
|
699 |
+
gy = 621;
|
700 |
+
}
|
701 |
+
days = (365 * jy) + ((parseInt(jy / 33)) * 8) + (parseInt(((jy % 33) + 3) / 4)) + 78 + jd + ((jm < 7) ? (jm - 1) * 31 : ((jm - 7) * 30) + 186);
|
702 |
+
gy += 400 * (parseInt(days / 146097));
|
703 |
+
days %= 146097;
|
704 |
+
if (days > 36524) {
|
705 |
+
gy += 100 * (parseInt(--days / 36524));
|
706 |
+
days %= 36524;
|
707 |
+
if (days >= 365) days++;
|
708 |
+
}
|
709 |
+
gy += 4 * (parseInt(days / 1461));
|
710 |
+
days %= 1461;
|
711 |
+
if (days > 365) {
|
712 |
+
gy += parseInt((days - 1) / 365);
|
713 |
+
days = (days - 1) % 365;
|
714 |
+
}
|
715 |
+
gd = days + 1;
|
716 |
+
sal_a = [0, 31, ((gy % 4 == 0 && gy % 100 != 0) || (gy % 400 == 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
717 |
+
for (gm = 0; gm < 13; gm++) {
|
718 |
+
v = sal_a[gm];
|
719 |
+
if (gd <= v) break;
|
720 |
+
gd -= v;
|
721 |
+
}
|
722 |
+
dt = new Date();
|
723 |
+
return new Date(gy, gm-1, gd, dt.getHours(), dt.getMinutes(), dt.getSeconds(), dt.getMilliseconds());
|
724 |
+
},
|
725 |
+
getGDate: function(pd) {
|
726 |
+
return this.jalali_to_gregorian(pd);
|
727 |
+
//>return this.getGCalendarDate(this.getJulianDayFromPersian(pd), "gmonth");
|
728 |
+
},
|
729 |
+
getWeekday: function(pd) {
|
730 |
+
var gds = [1, 2, 3, 4, 5, 6, 0];
|
731 |
+
return gds[this.jalali_to_gregorian(pd).getDay()];
|
732 |
+
},
|
733 |
+
getLastDayOfMonth: function(pd) {
|
734 |
+
y = pd.year, m = pd.month;
|
735 |
+
if (m >= 1 && m <= 6) {
|
736 |
+
return 31;
|
737 |
+
} else if (m >= 7 && m < 12) {
|
738 |
+
return 30;
|
739 |
+
}
|
740 |
+
/* Esfand */
|
741 |
+
else if (this.isLeapYear(y)) {
|
742 |
+
/* Leap year */
|
743 |
+
return 30;
|
744 |
+
}
|
745 |
+
return 29;
|
746 |
+
},
|
747 |
+
// to 1472
|
748 |
+
isLeapYear: function(year) {
|
749 |
+
var ary = year > 1342 ? [1, 5, 9, 13, 17, 22, 26, 30] : [1, 5, 9, 13, 17, 21, 26, 30];
|
750 |
+
b = year % 33;
|
751 |
+
if (ary._indexOf(b))
|
752 |
+
return true;
|
753 |
+
return false;
|
754 |
+
}
|
755 |
+
}; //========
|
756 |
+
|
757 |
+
return jDateFunctions;
|
758 |
+
})();
|
assets/js/persianDatepicker.min.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* persianDatepicker v0.1.0
|
3 |
+
* http://github.com/behzadi/persianDatepicker/
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 Mohammad hasan Behzadi All rights reserved.
|
6 |
+
*
|
7 |
+
* Released under the MIT license.
|
8 |
+
*
|
9 |
+
* jalali Date Functions
|
10 |
+
*
|
11 |
+
* Date: Tue Jan 1 2013
|
12 |
+
*/
|
13 |
+
(function(n){n.fn.persianDatepicker=function(i){var r="persianDatepicker",u=this.data(r);return u?i===!0?u:this:this.each(function(){return n(this).data(r,new t(this,i))})};var t=function(){function t(t,i){var h={months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],dowTitle:["شنبه","یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنج شنبه","جمعه"],shortDowTitle:["ش","ی","د","س","چ","پ","ج"],showGregorianDate:!1,persianNumbers:!0,formatDate:"YYYY/MM/DD",selectedBefore:!1,selectedDate:null,startDate:null,endDate:null,prevArrow:"◄",nextArrow:"►",theme:"default",alwaysShow:!1,selectableYears:null,selectableMonths:[1,2,3,4,5,6,7,8,9,10,11,12],cellWidth:25,cellHeight:20,fontSize:13,isRTL:!1,closeOnBlur:!0,calendarPosition:{x:0,y:0},onShow:function(){},onHide:function(){},onSelect:function(){},onRender:function(){}},r=this,f,u,s,e,o;if(r.el=n(t),f=r.el,r.options=n.extend(!1,{},h,i),u=r.options,_fontSize=u.fontSize,_cw=parseInt(u.cellWidth),_ch=parseInt(u.cellHeight),r.cellStyle="style='width:"+_cw+"px;height:"+_ch+"px;line-height:"+_ch+"px; font-size:"+_fontSize+"px; ' ",r.headerStyle="style='height:"+_ch+"px;line-height:"+_ch+"px; font-size:"+(_fontSize+4)+"px;' ",r.selectUlStyle="style='margin-top:"+_ch+"px;height:"+(_ch*7+20)+"px; font-size:"+(_fontSize-2)+"px;' ",r.selectMonthLiStyle="style='height:"+(_ch*7+7)/4+"px;line-height:"+(_ch*7+7)/4+"px; width:"+6.7*_cw/3+"px;width:"+6.7*_cw/3+"px\\9;' ",r.selectYearLiStyle="style='height:"+(_ch*7+10)/6+"px;line-height:"+(_ch*7+10)/6+"px; width:"+(6.7*_cw-14)/3+"px;width:"+(6.7*_cw-15)/3+"px\\9;' ",r.footerStyle="style='height:"+_ch+"px;line-height:"+_ch+"px; font-size:"+_fontSize+"px;' ",r.jDateFunctions=new jDateFunctions,r.options.startDate!=null&&(r.options.startDate=="today"&&(r.options.startDate=r.now().toString("YYYY/MM/DD")),r.options.endDate=="today"&&(r.options.endDate=r.now().toString("YYYY/MM/DD")),r.options.selectedDate=r.options.startDate),r.options.selectedDate==undefined&&(s=new RegExp("^([1-9][0-9][0-9][0-9])/([0]?[1-9]|[1][0-2])/([0]?[1-9]|[1-2][0-9]|[3][0-1])$"),f.is("input")?s.test(f.val())&&(r.options.selectedDate=f.val()):s.test(f.html())&&(r.options.selectedDate=f.html())),r._persianDate=r.options.selectedDate!=undefined?(new persianDate).parse(r.options.selectedDate):r.now(),u.selectableYears!=undefined&&u.selectableYears._indexOf(r._persianDate.year)==-1&&(r._persianDate.year=u.selectableYears[0]),r.options.selectableMonths._indexOf(r._persianDate.month)==-1&&(r._persianDate.month=u.selectableMonths[0]),r.persianDate=r._persianDate,r._id="pdp-"+Math.round(Math.random()*1e7),r.persianDate.formatDate=u.formatDate,r.calendar=n('<div id="'+r._id+'" class="pdp-'+u.theme+'" />'),r.options.startDate!=null)for(r.options.selectableYears=[],e=r.persianDate.parse(r.options.startDate).year;e<=r.persianDate.parse(r.options.endDate).year;e++)r.options.selectableYears.push(e);(f.attr("pdp-id")||"").length||f.attr("pdp-id",r._id);f.addClass("pdp-el").on("click",function(n){r.show(n)}).on("focus",function(n){r.show(n)});if(u.closeOnBlur)f.on("blur",function(n){r.calendar.is(":hover")||r.hide(n)});u.selectedBefore&&(r.options.selectedDate!=undefined?r.showDate(f,r.persianDate.parse(r.options.selectedDate).toString("YYYY/MM/DD/"+r.jDateFunctions.getWeekday(r.persianDate.parse(r.options.selectedDate)),r.now().gDate,u.showGregorianDate)):r.showDate(f,r.now().toString("YYYY/MM/DD/"+r.jDateFunctions.getWeekday(r.now())),r.now().gDate,u.showGregorianDate));u.isRTL&&f.addClass("rtl");r.calendar.length&&!u.alwaysShow&&r.calendar.hide();n(document).bind("mouseup",function(t){var e=t.target,o=r.calendar,i;f.is(e)||o.is(e)||o.has(e).length!==0||!o.is(":visible")||r.hide();i=n(".pdp-"+u.theme+" .yearSelect");i.is(t.target)||i.has(t.target).length!==0||i.hide();i=n(".pdp-"+u.theme+" .monthSelect");i.is(t.target)||i.has(t.target).length!==0||i.hide()});o=function(){var n=f.offset();r.calendar.css({top:n.top+f.outerHeight()+u.calendarPosition.y+"px",left:n.left+u.calendarPosition.x+"px"})};r.onresize=o;n(window).resize(o);n("body").append(r.calendar);r.render();o()}return t.prototype={show:function(){this.calendar.show();n.each(n(".pdp-el").not(this.el),function(n,t){if(t.length)t.options.onHide(t.calendar)});this.options.onShow(this.calendar);this.onresize()},hide:function(){this.options.onHide(this.calendar);this.options&&!this.options.alwaysShow&&this.calendar.hide()},render:function(){this.calendar.children().remove();this.header();this.dows();this.content();this.footer();this.options.onRender()},header:function(){var t=this,e,o,u,s;_monthYear=n('<div class="" />');_monthYear.appendTo(this.calendar);_head=n('<div class="pdp-header" '+t.headerStyle+" />");_head.appendTo(this.calendar);_next=n('<div class="nextArrow" />').html(this.options.nextArrow).attr("title","ماه بعد");t.options.endDate==null||t.persianDate.parse(t.options.endDate).year>t.persianDate.year||t.persianDate.parse(t.options.endDate).month>t.persianDate.month?(_next.bind("click",function(){for(nextMonth=t.persianDate.month+1;t.options.selectableMonths._indexOf(nextMonth)==-1&&nextMonth<13;nextMonth++);t.persianDate.addMonth(nextMonth-t.persianDate.month);t.render()}),_next.removeClass("disabled")):_next.addClass("disabled");_next.appendTo(_head);var f=n('<ul class="monthSelect" '+t.selectUlStyle+" />").hide(),r=n('<ul class="yearSelect" '+t.selectUlStyle+" />").hide(),h=n("<span/>").html(t.options.months[t.persianDate.month-1]).mousedown(function(){return!1}).click(function(n){n.stopPropagation();r.css({display:"none"});f.css({display:"inline-block"})}),l=n("<span/>").html(t.options.persianNumbers?t.jDateFunctions.toPersianNums(t.persianDate.year):t.persianDate.year).mousedown(function(){return!1}).click(function(n){n.stopPropagation();f.css({display:"none"});r.css({display:"inline-block"});r.scrollTop(70)});for(_startDate=t.options.startDate!=null?t.persianDate.parse(t.options.startDate):t.persianDate.parse("1/1/1"),_endDate=t.options.endDate!=null?t.persianDate.parse(t.options.endDate):t.persianDate.parse("9999/1/1"),e=function(u,f){var o=!1,e;for(u===undefined&&f===undefined?(b=t.persianDate.year-7,a=t.persianDate.year+14):f==0?(b=u-6,a=u,o=!0):u==0&&(b=f+1,a=b+6),e=[],i=b;i<a&&b>0;i++)e.push(parseInt(i));n.each(t.options.selectableYears||(o?e.reverse():e),function(i,u){var f=n("<li "+t.selectYearLiStyle+" />").html(t.options.persianNumbers?t.jDateFunctions.toPersianNums(u):u);u==t.persianDate.year&&f.addClass("selected");f.attr("value",u);f.bind("click",function(){t.persianDate.date=1;t.persianDate.year=parseInt(u);(_endDate.year==u||_endDate.year==9999)&&(t.persianDate.month=_endDate.month);(_startDate.year==u||_startDate.year==9999)&&(t.persianDate.month=_startDate.month);t.render()});o?r.prepend(f):r.append(f)})},e(),i=1;i<=12;i++)o=t.options.months[i-1],u=t.options.selectableMonths._indexOf(i)==-1||_startDate.year==t.persianDate.year&&_startDate.month>i||_endDate.year==t.persianDate.year&&i>_endDate.month?n('<li class="disableMonth" '+t.selectMonthLiStyle+" />").html(o):n("<li "+t.selectMonthLiStyle+" />").html(o),i==t.persianDate.month&&u.addClass("selected"),u.data("month",{month:o,monthNum:i}),u.hasClass("disableMonth")||u.bind("click",function(){t.persianDate.date=1;t.persianDate.month=n(this).data("month").monthNum;t.render()}),f.append(u);r.bind("scroll",function(){t.options.selectableYears==undefined&&(c=n(this).find("li").length,firstYear=parseInt(n(this).children("li:first").val()),lastYear=parseInt(n(this).children("li:last").val()),lisHeight=c/3*(n(this).find("li:first").height()+4),_com=n(this).scrollTop().toString().length*500,n(this).scrollTop()<_com.toString().length*100&&firstYear>=1&&e(firstYear,0),_com=n(this).scrollTop().toString().length*100,lisHeight-n(this).scrollTop()>-_com&&lisHeight-n(this).scrollTop()<_com&&(e(0,lastYear),n(this).scrollTop(n(this).scrollTop()-50)),n(this).scrollTop()<_com.toString().length&&firstYear>=30&&n(this).scrollTop(_com.toString().length*100))});_monthYear.append(f).append(r);s=n('<div class="monthYear" />').append(h).append("<span> <\/span>").append(l);_head.append(s);_prev=n('<div class="prevArrow" />').html(this.options.prevArrow).attr("title","ماه قبل");t.options.startDate==null||t.persianDate.parse(t.options.startDate).year<t.persianDate.year||t.persianDate.parse(t.options.startDate).month<t.persianDate.month?(_prev.bind("click",function(){t.persianDate.addMonth(-1);t.render()}),_prev.removeClass("disabled")):_prev.addClass("disabled");_prev.appendTo(_head)},dows:function(){for(_row=n('<div class="dows" />'),i=0;i<7;i++)_cell=n('<div class="dow cell " '+this.cellStyle+" />").html(this.options.shortDowTitle[i]),_cell.appendTo(_row);_row.appendTo(this.calendar)},content:function(){var t=this,u,i,r;for(_days=n('<div class="days" />'),_days.appendTo(this.calendar),jd=t.persianDate,jd.date=1,_start=t.jDateFunctions.getWeekday(t.persianDate),_end=t.jDateFunctions.getLastDayOfMonth(t.persianDate),u=0,i=0;u<6;u++){for(_row=n("<div />"),r=0;r<7;r++,i++)i<_start||i-_start+1>_end?_cell=n('<div class="nul cell " '+t.cellStyle+" />").html(" "):(_dt=t.getDate(t.persianDate,i-_start+1),_today="",_selday="",_disday="",t.now().compare(_dt)==0&&(_today="today"),t.options.startDate!=null&&(t.persianDate.parse(t.options.startDate).compare(_dt)==-1||t.persianDate.parse(t.options.endDate).compare(_dt)==1)&&(_disday="disday"),t.options.selectedDate!=undefined?t.persianDate.parse(t.options.selectedDate).date==i-_start+1&&(_selday="selday"):i-_start+1==t.now().date&&(_selday="selday"),_fri=r==6?"friday":"",_cell=n('<div class="day cell '+_fri+" "+_today+" "+_selday+" "+_disday+'" '+t.cellStyle+" />"),_cell.attr("data-jdate",_dt.toString("YYYY/MM/DD")),_cell.attr("data-gdate",t.jDateFunctions.getGDate(_dt)._toString("YYYY/MM/DD")),_cell.html(t.options.persianNumbers?t.jDateFunctions.toPersianNums(i-_start+1):i-_start+1),(t.options.startDate==undefined||t.persianDate.parse(t.options.startDate).compare(_dt)!=-1&&t.persianDate.parse(t.options.endDate).compare(_dt)!=1)&&_cell.bind("click",function(){t.calendar.find(".day").removeClass("selday");n(this).addClass("selday");t.options.showGregorianDate?t.showDate(t.el,n(this).data("jdate"),n(this).data("gdate"),!0):t.showDate(t.el,n(this).data("jdate"),n(this).data("gdate"),!1);t.hide()})),_cell.appendTo(_row);_row.appendTo(_days)}},footer:function(){var t=this;_footer=n('<div class="pdp-footer" '+t.footerStyle+" />");_footer.appendTo(this.calendar);t.options.selectableMonths._indexOf(t.persianDate.month)>-1&&(_goToday=n('<a class="goToday" />'),_goToday.attr("data-jdate",t.now().toString("YYYY/MM/DD/DW")),_goToday.attr("data-gdate",t.jDateFunctions.getGDate(t.now())),_goToday.attr("href","javascript:;").html("هم اکنون"),t.options.startDate==null&&_goToday.bind("click",function(){t.persianDate=t.now();t.showDate(t.el,n(this).data("jdate"),n(this).data("gdate"),t.options.showGregorianDate);t.calendar.find(".day").removeClass("selday");t.render();t.calendar.find(".today").addClass("selday");t.hide()}),_goToday.appendTo(_footer))},showDate:function(n,t,i,r){var u=this;t=u.persianDate.parse(t).toString(u.options.formatDate);i=new Date(i)._toString(u.options.formatDate);n.is("input:text")?r?n.val(i):n.val(t):r?n.html(i):n.html(t);n.attr("data-jDate",t);n.attr("data-gDate",i);this.options.onSelect()},getDate:function(n,t){return n.date=t,n.day=this.jDateFunctions.getWeekday(n),n},now:function(){return this.jDateFunctions.gregorian_to_jalali(new Date)}},t}();(function(){Number.prototype.padLeft=function(n,t){var i=String(n||10).length-String(this).length+1;return i>0?new Array(i).join(t||"0")+this:this};Date.prototype._toString=function(n){return(months=["Januray","February","March","April","May","June","Julay","August","September","October","November","December"],dows=["Sun","Mon","Tue","Wed","Tur","Fri","Sat"],n===undefined||n=="default")?this.toLocaleDateString():n.replace("YYYY",this.getFullYear()).replace("MM",this.getMonth()+1).replace("DD",this.getDate()).replace("0M",this.getMonth()+1>9?this.getMonth()+1:"0"+(this.getMonth()+1)).replace("0D",this.getDate()>9?this.getDate():"0"+this.getDate()).replace("hh",this.getHours()==0?(new Date).getHours():this.getHours()).replace("mm",this.getMinutes()==0?(new Date).getMinutes():this.getMinutes()).replace("ss",this.getSeconds()==0?(new Date).getSeconds():this.getSeconds()).replace("ms",this.getMilliseconds()==0?(new Date).getMilliseconds():this.getMilliseconds()).replace("tm",this.getHours()>=12&&this.getMinutes()>0?"PM":"AM").replace("NM",months[this.getMonth()]).replace("DW",this.getDay()).replace("ND",dows[this.getDay()])};Array.prototype._indexOf=function(t){return n.inArray(t,this)}})()})(jQuery);var persianDate=function(){function n(){var n=this;n.months=["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"];n.dowTitle=["شنبه","یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنج شنبه","جمعه"];n.year=1300;n.month=1;n.date=1;n.day=1;n.gDate=new Date}return n.prototype={now:function(){var n=new jDateFunctions;return n.gregorian_to_jalali(new Date)},addDay:function(t){for(var i,r,u=new jDateFunctions,e=t>0?t:-t,f=0;f<e;f++)i=new n,i.month=this.month,i.year=this.year,i=i.addMonth(-1),r=t>0?u.getLastDayOfMonth(this):u.getLastDayOfMonth(i),t>0?this.date+=1:this.date-=1,t>0?this.date>r&&(this.date=1,this.addMonth(1)):t<0&&(this.month>1&&this.date>r?(this.date=1,this.addMonth(1)):this.date==0&&(this.addMonth(-1),this.date=r));return this},addMonth:function(n){for(var i=n>0?n:-n,t=0;t<i;t++)n>0?this.month+=1:this.month-=1,this.month==13?(this.month=1,this.addYear(1)):this.month==0&&(this.month=12,this.addYear(-1));return this},addYear:function(n){return this.year+=n,this},compare:function(n){return n.year==this.year&&n.month==this.month&&n.date==this.date?0:n.year>this.year?1:n.year==this.year&&n.month>this.month?1:n.year==this.year&&n.month==this.month&&n.date>this.date?1:-1},parse:function(t){arr=t.split("/");y=arr[0];m=arr[1];d=arr[2];var i=new n;return jdf=new jDateFunctions,i.year=parseInt(y),i.month=parseInt(m),i.date=parseInt(d),i.day=jdf.getWeekday(i),i.gDate=jdf.jalali_to_gregorian(i),i},toString:function(n){return n===undefined?this.year+"/"+this.month+"/"+this.date:n.replace("YYYY",this.year).replace("MM",this.month).replace("DD",this.date).replace("0M",this.month>9?this.month:"0"+this.month.toString()).replace("0D",this.date>9?this.date:"0"+this.date.toString()).replace("hh",this.gDate.getHours()).replace("mm",this.gDate.getMinutes()).replace("ss",this.gDate.getSeconds()).replace("tm",this.gDate.getHours()>=12&&this.gDate.getMinutes()>0?"ب.ظ":"ق.ظ").replace("ms",this.gDate.getMilliseconds()).replace("NM",this.months[this.month-1]).replace("DW",this.day).replace("ND",this.dowTitle[this.day])}},n}(),jDateFunctions=function(){function n(){}return n.prototype={toPersianNums:function(n){for(strnum=n.toString(),nums=["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"],res="",i=0;i<strnum.length;i++)res+=nums[parseInt(strnum[i])];return res},gregorian_to_jalali:function(n){return gy=n.getFullYear(),gm=n.getMonth()+1,gd=n.getDate(),g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334],gy>1600?(jy=979,gy-=1600):(jy=0,gy-=621),gy2=gm>2?gy+1:gy,days=365*gy+parseInt((gy2+3)/4)-parseInt((gy2+99)/100)+parseInt((gy2+399)/400)-80+gd+g_d_m[gm-1],jy+=33*parseInt(days/12053),days%=12053,jy+=4*parseInt(days/1461),days%=1461,days>365&&(jy+=parseInt((days-1)/365),days=(days-1)%365),jm=days<186?1+parseInt(days/31):7+parseInt((days-186)/30),jd=1+(days<186?days%31:(days-186)%30),n=new Date,pd=new persianDate,pd.year=jy,pd.month=jm,pd.date=jd,pd.gDate=n,pd},jalali_to_gregorian:function(n){for(jy=n.year,jm=n.month,jd=n.date,jy>979?(gy=1600,jy-=979):gy=621,days=365*jy+parseInt(jy/33)*8+parseInt((jy%33+3)/4)+78+jd+(jm<7?(jm-1)*31:(jm-7)*30+186),gy+=400*parseInt(days/146097),days%=146097,days>36524&&(gy+=100*parseInt(--days/36524),days%=36524,days>=365&&days++),gy+=4*parseInt(days/1461),days%=1461,days>365&&(gy+=parseInt((days-1)/365),days=(days-1)%365),gd=days+1,sal_a=[0,31,gy%4==0&&gy%100!=0||gy%400==0?29:28,31,30,31,30,31,31,30,31,30,31],gm=0;gm<13;gm++){if(v=sal_a[gm],gd<=v)break;gd-=v}return dt=new Date,new Date(gy,gm-1,gd,dt.getHours(),dt.getMinutes(),dt.getSeconds(),dt.getMilliseconds())},getGDate:function(n){return this.jalali_to_gregorian(n)},getWeekday:function(n){return[1,2,3,4,5,6,0][this.jalali_to_gregorian(n).getDay()]},getLastDayOfMonth:function(n){return(y=n.year,m=n.month,m>=1&&m<=6)?31:m>=7&&m<12||this.isLeapYear(y)?30:29},isLeapYear:function(n){var t=n>1342?[1,5,9,13,17,22,26,30]:[1,5,9,13,17,21,26,30];return(b=n%33,t._indexOf(b))?!0:!1}},n}()
|
include/class-tools.php
CHANGED
@@ -80,7 +80,7 @@ if ( ! class_exists( 'Persian_Woocommerce_Tools' ) ) :
|
|
80 |
'id' => 'PW_Options[fix_orders_list]',
|
81 |
'type' => 'checkbox',
|
82 |
'default' => 'no',
|
83 |
-
'desc' => 'برای مرتب سازی لیست سفارشات بر اساس تاریخ پرداخت تیک بزنید',
|
84 |
),
|
85 |
array(
|
86 |
'title' => 'تاریخ شمسی',
|
80 |
'id' => 'PW_Options[fix_orders_list]',
|
81 |
'type' => 'checkbox',
|
82 |
'default' => 'no',
|
83 |
+
'desc' => 'برای مرتب سازی لیست سفارشات بر اساس تاریخ پرداخت تیک بزنید (قبل از فعالسازی این گزینه، حتما <a href="https://forum.persianscript.ir/threads/%D8%A7%D8%B3%D8%AA%D9%81%D8%A7%D8%AF%D9%87-%D8%A7%D8%B2-%D8%A7%D8%A8%D8%B2%D8%A7%D8%B1-%D9%85%D8%B1%D8%AA%D8%A8-%D8%B3%D8%A7%D8%B2%DB%8C-%D9%84%DB%8C%D8%B3%D8%AA-%D8%B3%D9%81%D8%A7%D8%B1%D8%B4%D8%A7%D8%AA.26864/" target="_blank">اینجا</a> را کامل مطالعه نمایید)',
|
84 |
),
|
85 |
array(
|
86 |
'title' => 'تاریخ شمسی',
|
include/tools/class-price.php
CHANGED
@@ -34,7 +34,9 @@ if ( ! class_exists( 'PW_Tools_Price' ) ) :
|
|
34 |
public function is_related() {
|
35 |
global $post;
|
36 |
|
37 |
-
|
|
|
|
|
38 |
}
|
39 |
|
40 |
public function on_empty_price( $price ) {
|
34 |
public function is_related() {
|
35 |
global $post;
|
36 |
|
37 |
+
$ID = isset( $post->ID ) ? $post->ID : '';
|
38 |
+
|
39 |
+
return is_singular() !== is_single( $ID );
|
40 |
}
|
41 |
|
42 |
public function on_empty_price( $price ) {
|
include/tools/general.php
CHANGED
@@ -12,11 +12,11 @@ function pw_checkout_state_dropdown_fix() {
|
|
12 |
|
13 |
?>
|
14 |
<script>
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
</script>
|
21 |
<?php
|
22 |
}
|
@@ -27,9 +27,13 @@ if ( is_admin() && PW()->get_options( 'fix_orders_list' ) != 'no' ) {
|
|
27 |
|
28 |
function pw_sort_orders_list_by_pay_date( $query ) {
|
29 |
|
|
|
|
|
|
|
|
|
30 |
$screen = get_current_screen();
|
31 |
|
32 |
-
if (
|
33 |
return $query;
|
34 |
}
|
35 |
|
@@ -40,22 +44,26 @@ function pw_sort_orders_list_by_pay_date( $query ) {
|
|
40 |
return $query;
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
if ( PW()->get_options( 'fix_postcode_persian_number' ) != 'no' ) {
|
44 |
add_filter( 'woocommerce_checkout_process', 'pw_checkout_process_postcode', 20, 1 );
|
45 |
}
|
46 |
|
47 |
function pw_checkout_process_postcode() {
|
48 |
|
49 |
-
function convert_number( $num ) {
|
50 |
-
return str_replace( array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ), range( 0, 9 ), $num );
|
51 |
-
}
|
52 |
-
|
53 |
if ( isset( $_POST['billing_postcode'] ) ) {
|
54 |
-
$_POST['billing_postcode'] =
|
55 |
}
|
56 |
|
57 |
if ( isset( $_POST['shipping_postcode'] ) ) {
|
58 |
-
$_POST['shipping_postcode'] =
|
59 |
}
|
60 |
|
61 |
}
|
@@ -79,16 +87,12 @@ if ( PW()->get_options( 'fix_phone_persian_number' ) != 'no' ) {
|
|
79 |
|
80 |
function pw_checkout_process_phone() {
|
81 |
|
82 |
-
function convert_number( $num ) {
|
83 |
-
return str_replace( array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ), range( 0, 9 ), $num );
|
84 |
-
}
|
85 |
-
|
86 |
if ( isset( $_POST['billing_phone'] ) ) {
|
87 |
-
$_POST['billing_phone'] =
|
88 |
}
|
89 |
|
90 |
if ( isset( $_POST['shipping_phone'] ) ) {
|
91 |
-
$_POST['shipping_phone'] =
|
92 |
}
|
93 |
|
94 |
}
|
12 |
|
13 |
?>
|
14 |
<script>
|
15 |
+
jQuery(function () {
|
16 |
+
// Snippets.ir
|
17 |
+
jQuery('#billing_country').trigger('change');
|
18 |
+
jQuery('#billing_state_field').removeClass('woocommerce-invalid');
|
19 |
+
});
|
20 |
</script>
|
21 |
<?php
|
22 |
}
|
27 |
|
28 |
function pw_sort_orders_list_by_pay_date( $query ) {
|
29 |
|
30 |
+
if ( ! function_exists( 'get_current_screen' ) ) {
|
31 |
+
return $query;
|
32 |
+
}
|
33 |
+
|
34 |
$screen = get_current_screen();
|
35 |
|
36 |
+
if ( is_null( $screen ) || $screen->id != 'edit-shop_order' ) {
|
37 |
return $query;
|
38 |
}
|
39 |
|
44 |
return $query;
|
45 |
}
|
46 |
|
47 |
+
if ( ! function_exists( 'pw_convert_number' ) ) {
|
48 |
+
|
49 |
+
function pw_convert_number( $num ) {
|
50 |
+
return str_replace( array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ), range( 0, 9 ), $num );
|
51 |
+
}
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
if ( PW()->get_options( 'fix_postcode_persian_number' ) != 'no' ) {
|
56 |
add_filter( 'woocommerce_checkout_process', 'pw_checkout_process_postcode', 20, 1 );
|
57 |
}
|
58 |
|
59 |
function pw_checkout_process_postcode() {
|
60 |
|
|
|
|
|
|
|
|
|
61 |
if ( isset( $_POST['billing_postcode'] ) ) {
|
62 |
+
$_POST['billing_postcode'] = pw_convert_number( $_POST['billing_postcode'] );
|
63 |
}
|
64 |
|
65 |
if ( isset( $_POST['shipping_postcode'] ) ) {
|
66 |
+
$_POST['shipping_postcode'] = pw_convert_number( $_POST['shipping_postcode'] );
|
67 |
}
|
68 |
|
69 |
}
|
87 |
|
88 |
function pw_checkout_process_phone() {
|
89 |
|
|
|
|
|
|
|
|
|
90 |
if ( isset( $_POST['billing_phone'] ) ) {
|
91 |
+
$_POST['billing_phone'] = pw_convert_number( $_POST['billing_phone'] );
|
92 |
}
|
93 |
|
94 |
if ( isset( $_POST['shipping_phone'] ) ) {
|
95 |
+
$_POST['shipping_phone'] = pw_convert_number( $_POST['shipping_phone'] );
|
96 |
}
|
97 |
|
98 |
}
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ author URI: http://www.woocommerce.ir/
|
|
5 |
plugin URI: http://www.woocommerce.ir/download/
|
6 |
Tags: persian,parsi,parsian,persians,farsi,iran,woocommerce, persian woocommerce, woocommerce farsi, iran, iranian, rtl, fa_IR,states,iranian rials,iranian tomans, woocommerce.ir,affiliate, cart, checkout, commerce, configurable, digital, download, downloadable, e-commerce, ecommerce, inventory, reports, sales, sell, shipping, shop, shopping, stock, store, tax, variable, widgets, woothemes, wordpress ecommerce
|
7 |
Requires at least: 4.4
|
8 |
-
Tested up to: 5.1
|
9 |
|
10 |
بسته ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند و امکانات جدید متناسب با ایران را به ووکامرس اضافه میکند.
|
11 |
|
@@ -14,7 +14,7 @@ Tested up to: 5.1
|
|
14 |
بسته فارسی ساز فروشگاه ساز ووکامرس شما را قادر می سازد تا ووکامرس را به صورت کامل فارسی شده همراه با امکانات کاربردی نظیر شهر های ایران، واحد های پولی ایران، درگاه های پرداخت بانکی و ابزارهای کاربردی دیگر داشته باشید.
|
15 |
|
16 |
= Compatibility =
|
17 |
-
* Woocommece 3.
|
18 |
* Wordpress 5.x
|
19 |
|
20 |
= Support =
|
@@ -44,6 +44,10 @@ Tested up to: 5.1
|
|
44 |
You can read complete documentations on the [woocommerce.ir](http://www.woocommerce.ir)
|
45 |
|
46 |
== Changelog ==
|
|
|
|
|
|
|
|
|
47 |
= 3.5.5 =
|
48 |
* بروزرسانی ترجمه و افزوده شدن ابزارهای تازه
|
49 |
* ابزار رفع خطای کدپستی در موبایل
|
@@ -153,7 +157,7 @@ You can read complete documentations on the [woocommerce.ir](http://www.woocomme
|
|
153 |
* نسخه اولیه
|
154 |
|
155 |
== Upgrade Notice ==
|
156 |
-
= 3.
|
157 |
-
*
|
158 |
== Traducciones ==
|
159 |
پشتیبانی در سایت [Woocommerce.ir](http://www.woocommerce.ir) انجام میشود.
|
5 |
plugin URI: http://www.woocommerce.ir/download/
|
6 |
Tags: persian,parsi,parsian,persians,farsi,iran,woocommerce, persian woocommerce, woocommerce farsi, iran, iranian, rtl, fa_IR,states,iranian rials,iranian tomans, woocommerce.ir,affiliate, cart, checkout, commerce, configurable, digital, download, downloadable, e-commerce, ecommerce, inventory, reports, sales, sell, shipping, shop, shopping, stock, store, tax, variable, widgets, woothemes, wordpress ecommerce
|
7 |
Requires at least: 4.4
|
8 |
+
Tested up to: 5.2.1
|
9 |
|
10 |
بسته ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند و امکانات جدید متناسب با ایران را به ووکامرس اضافه میکند.
|
11 |
|
14 |
بسته فارسی ساز فروشگاه ساز ووکامرس شما را قادر می سازد تا ووکامرس را به صورت کامل فارسی شده همراه با امکانات کاربردی نظیر شهر های ایران، واحد های پولی ایران، درگاه های پرداخت بانکی و ابزارهای کاربردی دیگر داشته باشید.
|
15 |
|
16 |
= Compatibility =
|
17 |
+
* Woocommece 3.6.x
|
18 |
* Wordpress 5.x
|
19 |
|
20 |
= Support =
|
44 |
You can read complete documentations on the [woocommerce.ir](http://www.woocommerce.ir)
|
45 |
|
46 |
== Changelog ==
|
47 |
+
= 3.6.3 =
|
48 |
+
* رفع باگ در PHP 7.2
|
49 |
+
= 3.5.5.1 =
|
50 |
+
* رفع باگ در PHP 5.6
|
51 |
= 3.5.5 =
|
52 |
* بروزرسانی ترجمه و افزوده شدن ابزارهای تازه
|
53 |
* ابزار رفع خطای کدپستی در موبایل
|
157 |
* نسخه اولیه
|
158 |
|
159 |
== Upgrade Notice ==
|
160 |
+
= 3.6.3 =
|
161 |
+
* رفع باگ در PHP 7.2
|
162 |
== Traducciones ==
|
163 |
پشتیبانی در سایت [Woocommerce.ir](http://www.woocommerce.ir) انجام میشود.
|
woocommerce-persian.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
Plugin Name: ووکامرس فارسی
|
4 |
Plugin URI: http://woocommerce.ir
|
5 |
Description: بسته فارسی ساز ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند. با فعال سازی افزونه ، بسیاری از قابلیت های مخصوص ایران به افزونه افزوده می شوند. پشتیبانی در <a href="http://www.woocommerce.ir/" target="_blank">ووکامرس پارسی</a>.
|
6 |
-
Version: 3.
|
7 |
Author: ووکامرس فارسی
|
8 |
Author URI: http://woocommerce.ir
|
9 |
WC requires at least: 3.0.0
|
10 |
-
WC tested up to: 3.
|
11 |
*/
|
12 |
|
13 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! defined( 'PW_VERSION' ) ) {
|
18 |
-
define( 'PW_VERSION', '3.
|
19 |
}
|
20 |
|
21 |
require_once( 'include/class-core.php' );
|
3 |
Plugin Name: ووکامرس فارسی
|
4 |
Plugin URI: http://woocommerce.ir
|
5 |
Description: بسته فارسی ساز ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند. با فعال سازی افزونه ، بسیاری از قابلیت های مخصوص ایران به افزونه افزوده می شوند. پشتیبانی در <a href="http://www.woocommerce.ir/" target="_blank">ووکامرس پارسی</a>.
|
6 |
+
Version: 3.6.3
|
7 |
Author: ووکامرس فارسی
|
8 |
Author URI: http://woocommerce.ir
|
9 |
WC requires at least: 3.0.0
|
10 |
+
WC tested up to: 3.6.3
|
11 |
*/
|
12 |
|
13 |
if ( ! defined( 'ABSPATH' ) ) {
|
15 |
}
|
16 |
|
17 |
if ( ! defined( 'PW_VERSION' ) ) {
|
18 |
+
define( 'PW_VERSION', '3.6.3' );
|
19 |
}
|
20 |
|
21 |
require_once( 'include/class-core.php' );
|