Skip to content

Commit 0d4243e

Browse files
authored
Update datepicker-api-doc.md
1 parent f263d5d commit 0d4243e

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed

datepicker-api-doc.md

+184
Original file line numberDiff line numberDiff line change
@@ -1 +1,185 @@
11
# Hijri/Gregorian Datepicker API Documentation
2+
3+
 
4+
5+
## Constructor
6+
### Syntax
7+
```javascript
8+
new Datepicker([isHijriMode[, fullYear[, monthIndex[, firstDay[, language[, colorTheme[, width]]]]]]]);
9+
```
10+
11+
### Parameters
12+
- **`isHijriMode`** (optional)<br>
13+
Boolean value representing the dates mode<br>
14+
`true`: Hijri dates<br>
15+
`false`: Gregorian dates<br>
16+
Default: `false`
17+
18+
- **`fullYear`** (optional)<br>
19+
Integer value representing the full year. Allow value below 1 (0 or negative value) that indicates before Hijra/Gregorian era. Value 0 for 1 BH/BE, -1 for 2 BH/BE, and so forth.<br>
20+
Default: current year
21+
22+
- **`monthIndex`** (optional)<br>
23+
Integer value representing the month, beginning with 0 for Muharram/January to 11 for Dhul-Hijja/December.<br>
24+
Default: index of current month
25+
26+
- **`firstDay`** (optional)<br>
27+
Integer value representing the first day of week (0-6).<br>
28+
Default: `1` (Monday)
29+
30+
- **`language`** (optional)<br>
31+
String value representing the language used by the widget. Currently three languages are supported.<br>
32+
`"ar"`: Arabic<br>
33+
`"en"`: English<br>
34+
`"id"`: Indonesian<br>
35+
Default: `"en"`
36+
37+
- **`colorTheme`** (optional)<br>
38+
Integer value representing the color index (0-22) or string value representing the color theme used by the widget.<br>
39+
<code>&nbsp;0</code> or `"amber"`<br>
40+
<code>&nbsp;1</code> or `"aqua"`<br>
41+
<code>&nbsp;2</code> or `"black"`<br>
42+
<code>&nbsp;3</code> or `"blue"`<br>
43+
<code>&nbsp;4</code> or `"blue-grey"`"<br>
44+
<code>&nbsp;5</code> or `"brown"`<br>
45+
<code>&nbsp;6</code> or `"cyan"`<br>
46+
<code>&nbsp;7</code> or `"dark-grey"`<br>
47+
<code>&nbsp;8</code> or `"deep-orange"`<br>
48+
<code>&nbsp;9</code> or `"deep-purple"`<br>
49+
`10` or `"green"`<br>
50+
`11` or `"grey"`<br>
51+
`12` or `"indigo"`<br>
52+
`13` or `"khaki"`<br>
53+
`14` or `"light-blue"`<br>
54+
`15` or `"light-green"`<br>
55+
`16` or `"lime"`<br>
56+
`17` or `"orange"`<br>
57+
`18` or `"pink"`<br>
58+
`19` or `"purple"`<br>
59+
`20` or `"red"`<br>
60+
`21` or `"teal"`<br>
61+
`22` or `"yellow"`<br>
62+
Default: random color theme
63+
64+
- **`width`** (optional)<br>
65+
Numeric value representing the width of the widget (280-600) in pixel.<br>
66+
Default: `300` pixel
67+
68+
## `Datepicker` Instance Methods
69+
- **`.attachTo(parentElement)`**<br>
70+
Attach this widget element into a parent HTML element designated by `parentElement`.
71+
72+
- **`.getElement()`**<br>
73+
Returns this widget element.
74+
75+
- **`.getOppositePickedDate()`**<br>
76+
Returns an opposite date instance of current dates mode. If the current dates mode is Gregorian then this method will return a `HijriDate` instance, whereas if the current dates mode is Hijri then a `Date` instance will be returned.
77+
78+
- **`.getPickedDate()`**<br>
79+
Returns an instance of `Date` or `HijriDate` depend on widget current dates mode. To conserve the memory, it's important to note that each instance returned by a call to this method, all of them are the same instance and only differs from the moment it represents.
80+
81+
- **`.hide()`**<br>
82+
Hides this widget.
83+
84+
- **`.pick()`**<br>
85+
Shows this widget. This is the same with `.show()` method.
86+
87+
- **`.resetDate(fullYear, monthIndex)`**<br>
88+
Resets the dates with an integer value pointed by `fullYear` and an integer value pointed by `monthIndex`.
89+
90+
- **`.setFirstDayOfWeek(firstDay)`**<br>
91+
Sets the first day of week with an integer value (0-6) pointed by `firstDay`.
92+
93+
- **`.setFullYear(fullYear)`**<br>
94+
Sets the full year with an integer value pointed by `fullYear`.
95+
96+
- **`.setHijriMode(hijriMode)`**<br>
97+
Sets the dates mode with a boolean value pointed by `hijriMode`.<br>
98+
`true`: Hijri dates<br>
99+
`false`: Gregorian dates
100+
101+
- **`.setLanguage(language)`**<br>
102+
Sets the language used by this widget with a string value pointed by `languge`.<br>
103+
`"ar"`: Arabic<br>
104+
`"en"`: English<br>
105+
`"id"`: Indonesian
106+
107+
- **`.setMonth(monthIndex)`**<br>
108+
Sets the month index with an integer value (0-11) pointed by `monthIndex`.
109+
110+
- **`.setTheme([colorTheme])`**<br>
111+
Sets the widget color theme with an integer value (0-22) as color index or a string value as color name pointed by `colorTheme`. If this `colorTheme` isn't specified then a random color theme will be applied.<br>
112+
<code>&nbsp;0</code> or `"amber"`<br>
113+
<code>&nbsp;1</code> or `"aqua"`<br>
114+
<code>&nbsp;2</code> or `"black"`<br>
115+
<code>&nbsp;3</code> or `"blue"`<br>
116+
<code>&nbsp;4</code> or `"blue-grey"`"<br>
117+
<code>&nbsp;5</code> or `"brown"`<br>
118+
<code>&nbsp;6</code> or `"cyan"`<br>
119+
<code>&nbsp;7</code> or `"dark-grey"`<br>
120+
<code>&nbsp;8</code> or `"deep-orange"`<br>
121+
<code>&nbsp;9</code> or `"deep-purple"`<br>
122+
`10` or `"green"`<br>
123+
`11` or `"grey"`<br>
124+
`12` or `"indigo"`<br>
125+
`13` or `"khaki"`<br>
126+
`14` or `"light-blue"`<br>
127+
`15` or `"light-green"`<br>
128+
`16` or `"lime"`<br>
129+
`17` or `"orange"`<br>
130+
`18` or `"pink"`<br>
131+
`19` or `"purple"`<br>
132+
`20` or `"red"`<br>
133+
`21` or `"teal"`<br>
134+
`22` or `"yellow"`
135+
136+
- **`.setTime(time)`**<br>
137+
Sets the dates to an integer value pointed by `time` as the time represented by number of milliseconds.
138+
139+
- **`.setWidth(width)`**<br>
140+
Sets the widget width in pixel with a numeric value (280-600) pointed by `width`.
141+
142+
- **`.show()`**<br>
143+
Shows the widget. This is the same with `.pick()` method.
144+
145+
- **`.today()`**<br>
146+
Sets the dates to current year and month.
147+
148+
## `Datepicker` Instance Properties
149+
- **`.onPicked`**<br>
150+
Assign this property to a function that do some processes when a date was picked. Please note that every time a date is picked, the `.hide()` method always called afterwards.<br>
151+
For example:
152+
```javascript
153+
let datepicker = new Datepicker();
154+
datepicker.onPicked = function() {
155+
// do stuff
156+
};
157+
```
158+
159+
## `Date.prototype` and `HijriDate.prototype` Instance Extended Methods
160+
By using this library, the following methods will be added to both `Date.prototype` and `HijriDate.prototype` instances.
161+
- **`.getDateString()`**
162+
Returns the picked dates as a human readable string in accordance with predetemined dates mode (Gregorian or Hijri). For example "Friday, 4 January 2019 AD" for the Gregorian dates mode or "Jumu'ah, 27 Rabi'ul-Akhir 1440 H" for the Hijri dates mode.
163+
164+
- **`.getMonthName([monthIndex])`**
165+
Returns the name of desired month index (0-11) that pointed by `monthIndex` as a human readable string ("January"-"December" or "Muharram"-"Dhul-Hijja"). If `monthIndex` is omitted, instead the current month's name will be returned.
166+
167+
- **`.getWeekdayName([day])`**
168+
Returns the name of desired day of week (0-6) that pointed by `day` as a human readable string ("Sunday"-"Saturday" or "Ahad"-"Sabt"). If `day` is omitted, instead the name of current day of week will be returned.
169+
170+
- **`.getWeekdayShortName([day])`**
171+
Returns the short name of desired day of week (0-6) that pointed by `day` as a human readable string ("Sun"-"Sat" or "Ahd"-"Sab"). If `day` is omitted, instead the short name of current day of week will be returned.
172+
173+
- **`.getYearString([fullYear])`**
174+
Returns the desired full year in integer value that pointed by `fullYear` followed by era suffix as a human readable string. If `fullYear` is omitted, instead the string of current full year will be returned.
175+
176+
&nbsp;
177+
178+
&nbsp;
179+
180+
&nbsp;
181+
182+
---
183+
#### Designed By ZulNs
184+
##### @Gorontalo, 8 January 2019
185+
---

0 commit comments

Comments
 (0)