Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4774a7a6
Commit
4774a7a6
authored
Jul 23, 2013
by
Rashid Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated date picker js
parent
e404ebc8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
305 additions
and
94 deletions
+305
-94
common/lib/datepicker.js
+305
-94
No files found.
common/lib/datepicker.js
View file @
4774a7a6
...
@@ -35,46 +35,38 @@
...
@@ -35,46 +35,38 @@
this
.
element
=
$
(
element
);
this
.
element
=
$
(
element
);
this
.
language
=
options
.
language
||
this
.
element
.
data
(
'date-language'
)
||
"en"
;
this
.
language
=
options
.
language
||
this
.
element
.
data
(
'date-language'
)
||
"en"
;
this
.
language
=
this
.
language
in
dates
?
this
.
language
:
this
.
language
.
split
(
'-'
)[
0
];
//Check if "de-DE" style date is available, if not language should fallback to 2 letter code eg "de"
this
.
language
=
this
.
language
in
dates
?
this
.
language
:
"en"
;
this
.
language
=
this
.
language
in
dates
?
this
.
language
:
"en"
;
this
.
format
=
DPGlobal
.
parseFormat
(
options
.
format
||
this
.
element
.
data
(
'date-format'
)
||
'mm/dd/yyyy'
);
this
.
isRTL
=
dates
[
this
.
language
].
rtl
||
false
;
this
.
picker
=
$
(
DPGlobal
.
template
)
this
.
format
=
DPGlobal
.
parseFormat
(
options
.
format
||
this
.
element
.
data
(
'date-format'
)
||
dates
[
this
.
language
].
format
||
'mm/dd/yyyy'
);
.
appendTo
(
'body'
)
this
.
isInline
=
false
;
.
on
({
click
:
$
.
proxy
(
this
.
click
,
this
)
});
this
.
isInput
=
this
.
element
.
is
(
'input'
);
this
.
isInput
=
this
.
element
.
is
(
'input'
);
this
.
component
=
this
.
element
.
is
(
'.date'
)
?
this
.
element
.
find
(
'.add-on'
)
:
false
;
this
.
component
=
this
.
element
.
is
(
'.date'
)
?
this
.
element
.
find
(
'.add-on
, .btn
'
)
:
false
;
this
.
hasInput
=
this
.
component
&&
this
.
element
.
find
(
'input'
).
length
;
this
.
hasInput
=
this
.
component
&&
this
.
element
.
find
(
'input'
).
length
;
if
(
this
.
component
&&
this
.
component
.
length
===
0
)
if
(
this
.
component
&&
this
.
component
.
length
===
0
)
this
.
component
=
false
;
this
.
component
=
false
;
if
(
this
.
isInput
)
{
this
.
forceParse
=
true
;
this
.
element
.
on
({
if
(
'forceParse'
in
options
)
{
focus
:
$
.
proxy
(
this
.
show
,
this
),
this
.
forceParse
=
options
.
forceParse
;
keyup
:
$
.
proxy
(
this
.
update
,
this
),
}
else
if
(
'dateForceParse'
in
this
.
element
.
data
())
{
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
this
.
forceParse
=
this
.
element
.
data
(
'date-force-parse'
);
});
}
else
{
if
(
this
.
component
&&
this
.
hasInput
){
// For components that are not readonly, allow keyboard nav
this
.
element
.
find
(
'input'
).
on
({
focus
:
$
.
proxy
(
this
.
show
,
this
),
keyup
:
$
.
proxy
(
this
.
update
,
this
),
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
});
this
.
component
.
on
(
'click'
,
$
.
proxy
(
this
.
show
,
this
));
}
else
{
this
.
element
.
on
(
'click'
,
$
.
proxy
(
this
.
show
,
this
));
}
}
}
$
(
document
).
on
(
'mousedown'
,
function
(
e
)
{
this
.
picker
=
$
(
DPGlobal
.
template
);
// Clicked outside the datepicker, hide it
this
.
_buildEvents
();
if
(
$
(
e
.
target
).
closest
(
'.datepicker'
).
length
==
0
)
{
this
.
_attachEvents
();
that
.
hide
();
}
if
(
this
.
isInline
)
{
});
this
.
picker
.
addClass
(
'datepicker-inline'
).
appendTo
(
this
.
element
);
}
else
{
this
.
picker
.
addClass
(
'datepicker-dropdown dropdown-menu'
);
}
if
(
this
.
isRTL
){
this
.
picker
.
addClass
(
'datepicker-rtl'
);
this
.
picker
.
find
(
'.prev i, .next i'
)
.
toggleClass
(
'icon-arrow-left icon-arrow-right'
);
}
this
.
autoclose
=
false
;
this
.
autoclose
=
false
;
if
(
'autoclose'
in
options
)
{
if
(
'autoclose'
in
options
)
{
...
@@ -90,6 +82,7 @@
...
@@ -90,6 +82,7 @@
this
.
keyboardNavigation
=
this
.
element
.
data
(
'date-keyboard-navigation'
);
this
.
keyboardNavigation
=
this
.
element
.
data
(
'date-keyboard-navigation'
);
}
}
this
.
viewMode
=
this
.
startViewMode
=
0
;
switch
(
options
.
startView
||
this
.
element
.
data
(
'date-start-view'
)){
switch
(
options
.
startView
||
this
.
element
.
data
(
'date-start-view'
)){
case
2
:
case
2
:
case
'decade'
:
case
'decade'
:
...
@@ -99,39 +92,156 @@
...
@@ -99,39 +92,156 @@
case
'year'
:
case
'year'
:
this
.
viewMode
=
this
.
startViewMode
=
1
;
this
.
viewMode
=
this
.
startViewMode
=
1
;
break
;
break
;
case
0
:
case
'month'
:
default
:
this
.
viewMode
=
this
.
startViewMode
=
0
;
break
;
}
}
this
.
minViewMode
=
options
.
minViewMode
||
this
.
element
.
data
(
'date-min-view-mode'
)
||
0
;
if
(
typeof
this
.
minViewMode
===
'string'
)
{
switch
(
this
.
minViewMode
)
{
case
'months'
:
this
.
minViewMode
=
1
;
break
;
case
'years'
:
this
.
minViewMode
=
2
;
break
;
default
:
this
.
minViewMode
=
0
;
break
;
}
}
this
.
viewMode
=
this
.
startViewMode
=
Math
.
max
(
this
.
startViewMode
,
this
.
minViewMode
);
this
.
todayBtn
=
(
options
.
todayBtn
||
this
.
element
.
data
(
'date-today-btn'
)
||
false
);
this
.
todayBtn
=
(
options
.
todayBtn
||
this
.
element
.
data
(
'date-today-btn'
)
||
false
);
this
.
todayHighlight
=
(
options
.
todayHighlight
||
this
.
element
.
data
(
'date-today-highlight'
)
||
false
);
this
.
todayHighlight
=
(
options
.
todayHighlight
||
this
.
element
.
data
(
'date-today-highlight'
)
||
false
);
this
.
calendarWeeks
=
false
;
if
(
'calendarWeeks'
in
options
)
{
this
.
calendarWeeks
=
options
.
calendarWeeks
;
}
else
if
(
'dateCalendarWeeks'
in
this
.
element
.
data
())
{
this
.
calendarWeeks
=
this
.
element
.
data
(
'date-calendar-weeks'
);
}
if
(
this
.
calendarWeeks
)
this
.
picker
.
find
(
'tfoot th.today'
)
.
attr
(
'colspan'
,
function
(
i
,
val
){
return
parseInt
(
val
)
+
1
;
});
this
.
_allow_update
=
false
;
this
.
weekStart
=
((
options
.
weekStart
||
this
.
element
.
data
(
'date-weekstart'
)
||
dates
[
this
.
language
].
weekStart
||
0
)
%
7
);
this
.
weekStart
=
((
options
.
weekStart
||
this
.
element
.
data
(
'date-weekstart'
)
||
dates
[
this
.
language
].
weekStart
||
0
)
%
7
);
this
.
weekEnd
=
((
this
.
weekStart
+
6
)
%
7
);
this
.
weekEnd
=
((
this
.
weekStart
+
6
)
%
7
);
this
.
startDate
=
-
Infinity
;
this
.
startDate
=
-
Infinity
;
this
.
endDate
=
Infinity
;
this
.
endDate
=
Infinity
;
this
.
daysOfWeekDisabled
=
[];
this
.
setStartDate
(
options
.
startDate
||
this
.
element
.
data
(
'date-startdate'
));
this
.
setStartDate
(
options
.
startDate
||
this
.
element
.
data
(
'date-startdate'
));
this
.
setEndDate
(
options
.
endDate
||
this
.
element
.
data
(
'date-enddate'
));
this
.
setEndDate
(
options
.
endDate
||
this
.
element
.
data
(
'date-enddate'
));
this
.
setDaysOfWeekDisabled
(
options
.
daysOfWeekDisabled
||
this
.
element
.
data
(
'date-days-of-week-disabled'
));
this
.
fillDow
();
this
.
fillDow
();
this
.
fillMonths
();
this
.
fillMonths
();
this
.
_allow_update
=
true
;
this
.
update
();
this
.
update
();
this
.
showMode
();
this
.
showMode
();
if
(
this
.
isInline
)
{
this
.
show
();
}
};
};
Datepicker
.
prototype
=
{
Datepicker
.
prototype
=
{
constructor
:
Datepicker
,
constructor
:
Datepicker
,
_events
:
[],
_secondaryEvents
:
[],
_applyEvents
:
function
(
evs
){
for
(
var
i
=
0
,
el
,
ev
;
i
<
evs
.
length
;
i
++
){
el
=
evs
[
i
][
0
];
ev
=
evs
[
i
][
1
];
el
.
on
(
ev
);
}
},
_unapplyEvents
:
function
(
evs
){
for
(
var
i
=
0
,
el
,
ev
;
i
<
evs
.
length
;
i
++
){
el
=
evs
[
i
][
0
];
ev
=
evs
[
i
][
1
];
el
.
off
(
ev
);
}
},
_buildEvents
:
function
(){
if
(
this
.
isInput
)
{
// single input
this
.
_events
=
[
[
this
.
element
,
{
focus
:
$
.
proxy
(
this
.
show
,
this
),
keyup
:
$
.
proxy
(
this
.
update
,
this
),
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
}]
];
}
else
if
(
this
.
component
&&
this
.
hasInput
){
// component: input + button
this
.
_events
=
[
// For components that are not readonly, allow keyboard nav
[
this
.
element
.
find
(
'input'
),
{
focus
:
$
.
proxy
(
this
.
show
,
this
),
keyup
:
$
.
proxy
(
this
.
update
,
this
),
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
}],
[
this
.
component
,
{
click
:
$
.
proxy
(
this
.
show
,
this
)
}]
];
}
else
if
(
this
.
element
.
is
(
'div'
))
{
// inline datepicker
this
.
isInline
=
true
;
}
else
{
this
.
_events
=
[
[
this
.
element
,
{
click
:
$
.
proxy
(
this
.
show
,
this
)
}]
];
}
this
.
_secondaryEvents
=
[
[
this
.
picker
,
{
click
:
$
.
proxy
(
this
.
click
,
this
)
}],
[
$
(
window
),
{
resize
:
$
.
proxy
(
this
.
place
,
this
)
}],
[
$
(
document
),
{
mousedown
:
$
.
proxy
(
function
(
e
)
{
// Clicked outside the datepicker, hide it
if
(
$
(
e
.
target
).
closest
(
'.datepicker.datepicker-inline, .datepicker.datepicker-dropdown'
).
length
===
0
)
{
this
.
hide
();
}
},
this
)
}]
];
},
_attachEvents
:
function
(){
this
.
_detachEvents
();
this
.
_applyEvents
(
this
.
_events
);
},
_detachEvents
:
function
(){
this
.
_unapplyEvents
(
this
.
_events
);
},
_attachSecondaryEvents
:
function
(){
this
.
_detachSecondaryEvents
();
this
.
_applyEvents
(
this
.
_secondaryEvents
);
},
_detachSecondaryEvents
:
function
(){
this
.
_unapplyEvents
(
this
.
_secondaryEvents
);
},
show
:
function
(
e
)
{
show
:
function
(
e
)
{
if
(
!
this
.
isInline
)
this
.
picker
.
appendTo
(
'body'
);
this
.
picker
.
show
();
this
.
picker
.
show
();
this
.
height
=
this
.
component
?
this
.
component
.
outerHeight
()
:
this
.
element
.
outerHeight
();
this
.
height
=
this
.
component
?
this
.
component
.
outerHeight
()
:
this
.
element
.
outerHeight
();
this
.
update
();
this
.
place
();
this
.
place
();
$
(
window
).
on
(
'resize'
,
$
.
proxy
(
this
.
place
,
this
));
this
.
_attachSecondaryEvents
();
if
(
e
)
{
if
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
preventDefault
();
}
}
this
.
element
.
trigger
({
this
.
element
.
trigger
({
...
@@ -141,14 +251,20 @@
...
@@ -141,14 +251,20 @@
},
},
hide
:
function
(
e
){
hide
:
function
(
e
){
this
.
picker
.
hide
();
if
(
this
.
isInline
)
return
;
$
(
window
).
off
(
'resize'
,
this
.
place
);
if
(
!
this
.
picker
.
is
(
':visible'
))
return
;
this
.
picker
.
hide
().
detach
();
this
.
_detachSecondaryEvents
();
this
.
viewMode
=
this
.
startViewMode
;
this
.
viewMode
=
this
.
startViewMode
;
this
.
showMode
();
this
.
showMode
();
if
(
!
this
.
isInput
)
{
$
(
document
).
off
(
'mousedown'
,
this
.
hide
);
if
(
}
this
.
forceParse
&&
if
(
e
&&
e
.
currentTarget
.
value
)
(
this
.
isInput
&&
this
.
element
.
val
()
||
this
.
hasInput
&&
this
.
element
.
find
(
'input'
).
val
()
)
)
this
.
setValue
();
this
.
setValue
();
this
.
element
.
trigger
({
this
.
element
.
trigger
({
type
:
'hide'
,
type
:
'hide'
,
...
@@ -156,9 +272,20 @@
...
@@ -156,9 +272,20 @@
});
});
},
},
remove
:
function
()
{
this
.
hide
();
this
.
_detachEvents
();
this
.
_detachSecondaryEvents
();
this
.
picker
.
remove
();
delete
this
.
element
.
data
().
datepicker
;
if
(
!
this
.
isInput
)
{
delete
this
.
element
.
data
().
date
;
}
},
getDate
:
function
()
{
getDate
:
function
()
{
var
d
=
this
.
getUTCDate
();
var
d
=
this
.
getUTCDate
();
return
new
Date
(
d
.
getTime
()
+
(
d
.
getTimezoneOffset
()
*
60000
))
return
new
Date
(
d
.
getTime
()
+
(
d
.
getTimezoneOffset
()
*
60000
))
;
},
},
getUTCDate
:
function
()
{
getUTCDate
:
function
()
{
...
@@ -175,17 +302,23 @@
...
@@ -175,17 +302,23 @@
},
},
setValue
:
function
()
{
setValue
:
function
()
{
var
formatted
=
DPGlobal
.
formatDate
(
this
.
date
,
this
.
format
,
this
.
language
);
var
formatted
=
this
.
getFormattedDate
(
);
if
(
!
this
.
isInput
)
{
if
(
!
this
.
isInput
)
{
if
(
this
.
component
){
if
(
this
.
component
){
this
.
element
.
find
(
'input'
).
prop
(
'value'
,
formatted
);
this
.
element
.
find
(
'input'
).
val
(
formatted
);
}
}
this
.
element
.
data
(
'date'
,
formatted
);
this
.
element
.
data
(
'date'
,
formatted
);
}
else
{
}
else
{
this
.
element
.
prop
(
'value'
,
formatted
);
this
.
element
.
val
(
formatted
);
}
}
},
},
getFormattedDate
:
function
(
format
)
{
if
(
format
===
undefined
)
format
=
this
.
format
;
return
DPGlobal
.
formatDate
(
this
.
date
,
format
,
this
.
language
);
},
setStartDate
:
function
(
startDate
){
setStartDate
:
function
(
startDate
){
this
.
startDate
=
startDate
||-
Infinity
;
this
.
startDate
=
startDate
||-
Infinity
;
if
(
this
.
startDate
!==
-
Infinity
)
{
if
(
this
.
startDate
!==
-
Infinity
)
{
...
@@ -204,23 +337,48 @@
...
@@ -204,23 +337,48 @@
this
.
updateNavArrows
();
this
.
updateNavArrows
();
},
},
setDaysOfWeekDisabled
:
function
(
daysOfWeekDisabled
){
this
.
daysOfWeekDisabled
=
daysOfWeekDisabled
||
[];
if
(
!
$
.
isArray
(
this
.
daysOfWeekDisabled
))
{
this
.
daysOfWeekDisabled
=
this
.
daysOfWeekDisabled
.
split
(
/,
\s
*/
);
}
this
.
daysOfWeekDisabled
=
$
.
map
(
this
.
daysOfWeekDisabled
,
function
(
d
)
{
return
parseInt
(
d
,
10
);
});
this
.
update
();
this
.
updateNavArrows
();
},
place
:
function
(){
place
:
function
(){
if
(
this
.
isInline
)
return
;
var
zIndex
=
parseInt
(
this
.
element
.
parents
().
filter
(
function
()
{
var
zIndex
=
parseInt
(
this
.
element
.
parents
().
filter
(
function
()
{
return
$
(
this
).
css
(
'z-index'
)
!=
'auto'
;
return
$
(
this
).
css
(
'z-index'
)
!=
'auto'
;
}).
first
().
css
(
'z-index'
))
+
10
;
}).
first
().
css
(
'z-index'
))
+
10
;
var
offset
=
this
.
component
?
this
.
component
.
offset
()
:
this
.
element
.
offset
();
var
offset
=
this
.
component
?
this
.
component
.
parent
().
offset
()
:
this
.
element
.
offset
();
var
height
=
this
.
component
?
this
.
component
.
outerHeight
(
true
)
:
this
.
element
.
outerHeight
(
true
);
this
.
picker
.
css
({
this
.
picker
.
css
({
top
:
offset
.
top
+
this
.
height
,
top
:
offset
.
top
+
height
,
left
:
offset
.
left
,
left
:
offset
.
left
,
zIndex
:
zIndex
zIndex
:
zIndex
});
});
},
},
_allow_update
:
true
,
update
:
function
(){
update
:
function
(){
this
.
date
=
DPGlobal
.
parseDate
(
if
(
!
this
.
_allow_update
)
return
;
this
.
isInput
?
this
.
element
.
prop
(
'value'
)
:
this
.
element
.
data
(
'date'
)
||
this
.
element
.
find
(
'input'
).
prop
(
'value'
),
this
.
format
,
this
.
language
var
date
,
fromArgs
=
false
;
);
if
(
arguments
&&
arguments
.
length
&&
(
typeof
arguments
[
0
]
===
'string'
||
arguments
[
0
]
instanceof
Date
))
{
date
=
arguments
[
0
];
fromArgs
=
true
;
}
else
{
date
=
this
.
isInput
?
this
.
element
.
val
()
:
this
.
element
.
data
(
'date'
)
||
this
.
element
.
find
(
'input'
).
val
();
}
this
.
date
=
DPGlobal
.
parseDate
(
date
,
this
.
format
,
this
.
language
);
if
(
fromArgs
)
this
.
setValue
();
if
(
this
.
date
<
this
.
startDate
)
{
if
(
this
.
date
<
this
.
startDate
)
{
this
.
viewDate
=
new
Date
(
this
.
startDate
);
this
.
viewDate
=
new
Date
(
this
.
startDate
);
}
else
if
(
this
.
date
>
this
.
endDate
)
{
}
else
if
(
this
.
date
>
this
.
endDate
)
{
...
@@ -232,8 +390,13 @@
...
@@ -232,8 +390,13 @@
},
},
fillDow
:
function
(){
fillDow
:
function
(){
var
dowCnt
=
this
.
weekStart
;
var
dowCnt
=
this
.
weekStart
,
var
html
=
'<tr>'
;
html
=
'<tr>'
;
if
(
this
.
calendarWeeks
){
var
cell
=
'<th class="cw"> </th>'
;
html
+=
cell
;
this
.
picker
.
find
(
'.datepicker-days thead tr:first-child'
).
prepend
(
cell
);
}
while
(
dowCnt
<
this
.
weekStart
+
7
)
{
while
(
dowCnt
<
this
.
weekStart
+
7
)
{
html
+=
'<th class="dow">'
+
dates
[
this
.
language
].
daysMin
[(
dowCnt
++
)
%
7
]
+
'</th>'
;
html
+=
'<th class="dow">'
+
dates
[
this
.
language
].
daysMin
[(
dowCnt
++
)
%
7
]
+
'</th>'
;
}
}
...
@@ -242,8 +405,8 @@
...
@@ -242,8 +405,8 @@
},
},
fillMonths
:
function
(){
fillMonths
:
function
(){
var
html
=
''
;
var
html
=
''
,
var
i
=
0
i
=
0
;
while
(
i
<
12
)
{
while
(
i
<
12
)
{
html
+=
'<span class="month">'
+
dates
[
this
.
language
].
monthsShort
[
i
++
]
+
'</span>'
;
html
+=
'<span class="month">'
+
dates
[
this
.
language
].
monthsShort
[
i
++
]
+
'</span>'
;
}
}
...
@@ -258,13 +421,13 @@
...
@@ -258,13 +421,13 @@
startMonth
=
this
.
startDate
!==
-
Infinity
?
this
.
startDate
.
getUTCMonth
()
:
-
Infinity
,
startMonth
=
this
.
startDate
!==
-
Infinity
?
this
.
startDate
.
getUTCMonth
()
:
-
Infinity
,
endYear
=
this
.
endDate
!==
Infinity
?
this
.
endDate
.
getUTCFullYear
()
:
Infinity
,
endYear
=
this
.
endDate
!==
Infinity
?
this
.
endDate
.
getUTCFullYear
()
:
Infinity
,
endMonth
=
this
.
endDate
!==
Infinity
?
this
.
endDate
.
getUTCMonth
()
:
Infinity
,
endMonth
=
this
.
endDate
!==
Infinity
?
this
.
endDate
.
getUTCMonth
()
:
Infinity
,
currentDate
=
this
.
date
.
valueOf
(),
currentDate
=
this
.
date
&&
this
.
date
.
valueOf
(),
today
=
new
Date
();
today
=
new
Date
();
this
.
picker
.
find
(
'.datepicker-days thead th
:eq(1)
'
)
this
.
picker
.
find
(
'.datepicker-days thead th
.switch
'
)
.
text
(
dates
[
this
.
language
].
months
[
month
]
+
' '
+
year
);
.
text
(
dates
[
this
.
language
].
months
[
month
]
+
' '
+
year
);
this
.
picker
.
find
(
'tfoot th.today'
)
this
.
picker
.
find
(
'tfoot th.today'
)
.
text
(
dates
[
this
.
language
].
today
)
.
text
(
dates
[
this
.
language
].
today
)
.
toggle
(
this
.
todayBtn
);
.
toggle
(
this
.
todayBtn
!==
false
);
this
.
updateNavArrows
();
this
.
updateNavArrows
();
this
.
fillMonths
();
this
.
fillMonths
();
var
prevMonth
=
UTCDate
(
year
,
month
-
1
,
28
,
0
,
0
,
0
,
0
),
var
prevMonth
=
UTCDate
(
year
,
month
-
1
,
28
,
0
,
0
,
0
,
0
),
...
@@ -279,6 +442,21 @@
...
@@ -279,6 +442,21 @@
while
(
prevMonth
.
valueOf
()
<
nextMonth
)
{
while
(
prevMonth
.
valueOf
()
<
nextMonth
)
{
if
(
prevMonth
.
getUTCDay
()
==
this
.
weekStart
)
{
if
(
prevMonth
.
getUTCDay
()
==
this
.
weekStart
)
{
html
.
push
(
'<tr>'
);
html
.
push
(
'<tr>'
);
if
(
this
.
calendarWeeks
){
// ISO 8601: First week contains first thursday.
// ISO also states week starts on Monday, but we can be more abstract here.
var
// Start of current week: based on weekstart/current date
ws
=
new
Date
(
+
prevMonth
+
(
this
.
weekStart
-
prevMonth
.
getUTCDay
()
-
7
)
%
7
*
864
e5
),
// Thursday of this week
th
=
new
Date
(
+
ws
+
(
7
+
4
-
ws
.
getUTCDay
())
%
7
*
864
e5
),
// First Thursday of year, year from thursday
yth
=
new
Date
(
+
(
yth
=
UTCDate
(
th
.
getUTCFullYear
(),
0
,
1
))
+
(
7
+
4
-
yth
.
getUTCDay
())
%
7
*
864
e5
),
// Calendar week: ms between thursdays, div ms per day, div 7 days
calWeek
=
(
th
-
yth
)
/
864
e5
/
7
+
1
;
html
.
push
(
'<td class="cw">'
+
calWeek
+
'</td>'
);
}
}
}
clsName
=
''
;
clsName
=
''
;
if
(
prevMonth
.
getUTCFullYear
()
<
year
||
(
prevMonth
.
getUTCFullYear
()
==
year
&&
prevMonth
.
getUTCMonth
()
<
month
))
{
if
(
prevMonth
.
getUTCFullYear
()
<
year
||
(
prevMonth
.
getUTCFullYear
()
==
year
&&
prevMonth
.
getUTCMonth
()
<
month
))
{
...
@@ -293,10 +471,11 @@
...
@@ -293,10 +471,11 @@
prevMonth
.
getUTCDate
()
==
today
.
getDate
())
{
prevMonth
.
getUTCDate
()
==
today
.
getDate
())
{
clsName
+=
' today'
;
clsName
+=
' today'
;
}
}
if
(
prevMonth
.
valueOf
()
==
currentDate
)
{
if
(
currentDate
&&
prevMonth
.
valueOf
()
==
currentDate
)
{
clsName
+=
' active'
;
clsName
+=
' active'
;
}
}
if
(
prevMonth
.
valueOf
()
<
this
.
startDate
||
prevMonth
.
valueOf
()
>
this
.
endDate
)
{
if
(
prevMonth
.
valueOf
()
<
this
.
startDate
||
prevMonth
.
valueOf
()
>
this
.
endDate
||
$
.
inArray
(
prevMonth
.
getUTCDay
(),
this
.
daysOfWeekDisabled
)
!==
-
1
)
{
clsName
+=
' disabled'
;
clsName
+=
' disabled'
;
}
}
html
.
push
(
'<td class="day'
+
clsName
+
'">'
+
prevMonth
.
getUTCDate
()
+
'</td>'
);
html
.
push
(
'<td class="day'
+
clsName
+
'">'
+
prevMonth
.
getUTCDate
()
+
'</td>'
);
...
@@ -306,14 +485,14 @@
...
@@ -306,14 +485,14 @@
prevMonth
.
setUTCDate
(
prevMonth
.
getUTCDate
()
+
1
);
prevMonth
.
setUTCDate
(
prevMonth
.
getUTCDate
()
+
1
);
}
}
this
.
picker
.
find
(
'.datepicker-days tbody'
).
empty
().
append
(
html
.
join
(
''
));
this
.
picker
.
find
(
'.datepicker-days tbody'
).
empty
().
append
(
html
.
join
(
''
));
var
currentYear
=
this
.
date
.
getUTCFullYear
();
var
currentYear
=
this
.
date
&&
this
.
date
.
getUTCFullYear
();
var
months
=
this
.
picker
.
find
(
'.datepicker-months'
)
var
months
=
this
.
picker
.
find
(
'.datepicker-months'
)
.
find
(
'th:eq(1)'
)
.
find
(
'th:eq(1)'
)
.
text
(
year
)
.
text
(
year
)
.
end
()
.
end
()
.
find
(
'span'
).
removeClass
(
'active'
);
.
find
(
'span'
).
removeClass
(
'active'
);
if
(
currentYear
==
year
)
{
if
(
currentYear
&&
currentYear
==
year
)
{
months
.
eq
(
this
.
date
.
getUTCMonth
()).
addClass
(
'active'
);
months
.
eq
(
this
.
date
.
getUTCMonth
()).
addClass
(
'active'
);
}
}
if
(
year
<
startYear
||
year
>
endYear
)
{
if
(
year
<
startYear
||
year
>
endYear
)
{
...
@@ -342,6 +521,8 @@
...
@@ -342,6 +521,8 @@
},
},
updateNavArrows
:
function
()
{
updateNavArrows
:
function
()
{
if
(
!
this
.
_allow_update
)
return
;
var
d
=
new
Date
(
this
.
viewDate
),
var
d
=
new
Date
(
this
.
viewDate
),
year
=
d
.
getUTCFullYear
(),
year
=
d
.
getUTCFullYear
(),
month
=
d
.
getUTCMonth
();
month
=
d
.
getUTCMonth
();
...
@@ -375,7 +556,6 @@
...
@@ -375,7 +556,6 @@
},
},
click
:
function
(
e
)
{
click
:
function
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
preventDefault
();
var
target
=
$
(
e
.
target
).
closest
(
'span, td, th'
);
var
target
=
$
(
e
.
target
).
closest
(
'span, td, th'
);
if
(
target
.
length
==
1
)
{
if
(
target
.
length
==
1
)
{
...
@@ -401,10 +581,7 @@
...
@@ -401,10 +581,7 @@
break
;
break
;
case
'today'
:
case
'today'
:
var
date
=
new
Date
();
var
date
=
new
Date
();
date
.
setUTCHours
(
0
);
date
=
UTCDate
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
0
,
0
,
0
);
date
.
setUTCMinutes
(
0
);
date
.
setUTCSeconds
(
0
);
date
.
setUTCMilliseconds
(
0
);
this
.
showMode
(
-
2
);
this
.
showMode
(
-
2
);
var
which
=
this
.
todayBtn
==
'linked'
?
null
:
'view'
;
var
which
=
this
.
todayBtn
==
'linked'
?
null
:
'view'
;
...
@@ -416,19 +593,29 @@
...
@@ -416,19 +593,29 @@
if
(
!
target
.
is
(
'.disabled'
))
{
if
(
!
target
.
is
(
'.disabled'
))
{
this
.
viewDate
.
setUTCDate
(
1
);
this
.
viewDate
.
setUTCDate
(
1
);
if
(
target
.
is
(
'.month'
))
{
if
(
target
.
is
(
'.month'
))
{
var
day
=
1
;
var
month
=
target
.
parent
().
find
(
'span'
).
index
(
target
);
var
month
=
target
.
parent
().
find
(
'span'
).
index
(
target
);
var
year
=
this
.
viewDate
.
getUTCFullYear
();
this
.
viewDate
.
setUTCMonth
(
month
);
this
.
viewDate
.
setUTCMonth
(
month
);
this
.
element
.
trigger
({
this
.
element
.
trigger
({
type
:
'changeMonth'
,
type
:
'changeMonth'
,
date
:
this
.
viewDate
date
:
this
.
viewDate
});
});
if
(
this
.
minViewMode
==
1
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
0
,
0
,
0
,
0
));
}
}
else
{
}
else
{
var
year
=
parseInt
(
target
.
text
(),
10
)
||
0
;
var
year
=
parseInt
(
target
.
text
(),
10
)
||
0
;
var
day
=
1
;
var
month
=
0
;
this
.
viewDate
.
setUTCFullYear
(
year
);
this
.
viewDate
.
setUTCFullYear
(
year
);
this
.
element
.
trigger
({
this
.
element
.
trigger
({
type
:
'changeYear'
,
type
:
'changeYear'
,
date
:
this
.
viewDate
date
:
this
.
viewDate
});
});
if
(
this
.
minViewMode
==
2
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
0
,
0
,
0
,
0
));
}
}
}
this
.
showMode
(
-
1
);
this
.
showMode
(
-
1
);
this
.
fill
();
this
.
fill
();
...
@@ -440,7 +627,7 @@
...
@@ -440,7 +627,7 @@
var
year
=
this
.
viewDate
.
getUTCFullYear
(),
var
year
=
this
.
viewDate
.
getUTCFullYear
(),
month
=
this
.
viewDate
.
getUTCMonth
();
month
=
this
.
viewDate
.
getUTCMonth
();
if
(
target
.
is
(
'.old'
))
{
if
(
target
.
is
(
'.old'
))
{
if
(
month
==
0
)
{
if
(
month
==
=
0
)
{
month
=
11
;
month
=
11
;
year
-=
1
;
year
-=
1
;
}
else
{
}
else
{
...
@@ -480,8 +667,8 @@
...
@@ -480,8 +667,8 @@
}
}
if
(
element
)
{
if
(
element
)
{
element
.
change
();
element
.
change
();
if
(
this
.
autoclose
)
{
if
(
this
.
autoclose
&&
(
!
which
||
which
==
'date'
)
)
{
this
.
hide
();
this
.
hide
();
}
}
}
}
},
},
...
@@ -625,9 +812,19 @@
...
@@ -625,9 +812,19 @@
showMode
:
function
(
dir
)
{
showMode
:
function
(
dir
)
{
if
(
dir
)
{
if
(
dir
)
{
this
.
viewMode
=
Math
.
max
(
0
,
Math
.
min
(
2
,
this
.
viewMode
+
dir
));
this
.
viewMode
=
Math
.
max
(
this
.
minViewMode
,
Math
.
min
(
2
,
this
.
viewMode
+
dir
));
}
}
this
.
picker
.
find
(
'>div'
).
hide
().
filter
(
'.datepicker-'
+
DPGlobal
.
modes
[
this
.
viewMode
].
clsName
).
show
();
/*
vitalets: fixing bug of very special conditions:
jquery 1.7.1 + webkit + show inline datepicker in bootstrap popover.
Method show() does not set display css correctly and datepicker is not shown.
Changed to .css('display', 'block') solve the problem.
See https://github.com/vitalets/x-editable/issues/37
In jquery 1.7.2+ everything works fine.
*/
//this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
this
.
picker
.
find
(
'>div'
).
hide
().
filter
(
'.datepicker-'
+
DPGlobal
.
modes
[
this
.
viewMode
].
clsName
).
css
(
'display'
,
'block'
);
this
.
updateNavArrows
();
this
.
updateNavArrows
();
}
}
};
};
...
@@ -660,7 +857,7 @@
...
@@ -660,7 +857,7 @@
monthsShort
:
[
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
"Jul"
,
"Aug"
,
"Sep"
,
"Oct"
,
"Nov"
,
"Dec"
],
monthsShort
:
[
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
"Jul"
,
"Aug"
,
"Sep"
,
"Oct"
,
"Nov"
,
"Dec"
],
today
:
"Today"
today
:
"Today"
}
}
}
}
;
var
DPGlobal
=
{
var
DPGlobal
=
{
modes
:
[
modes
:
[
...
@@ -680,28 +877,28 @@
...
@@ -680,28 +877,28 @@
navStep
:
10
navStep
:
10
}],
}],
isLeapYear
:
function
(
year
)
{
isLeapYear
:
function
(
year
)
{
return
(((
year
%
4
===
0
)
&&
(
year
%
100
!==
0
))
||
(
year
%
400
===
0
))
return
(((
year
%
4
===
0
)
&&
(
year
%
100
!==
0
))
||
(
year
%
400
===
0
))
;
},
},
getDaysInMonth
:
function
(
year
,
month
)
{
getDaysInMonth
:
function
(
year
,
month
)
{
return
[
31
,
(
DPGlobal
.
isLeapYear
(
year
)
?
29
:
28
),
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
][
month
]
return
[
31
,
(
DPGlobal
.
isLeapYear
(
year
)
?
29
:
28
),
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
][
month
]
;
},
},
validParts
:
/dd
?
|mm
?
|MM
?
|yy
(?:
yy
)?
/g
,
validParts
:
/dd
?
|
DD
?
|
mm
?
|MM
?
|yy
(?:
yy
)?
/g
,
nonpunctuation
:
/
[^
-
\/
:-@
\[
-`{-~
\t\n\r]
+/g
,
nonpunctuation
:
/
[^
-
\/
:-@
\[
\u
3400-
\u
9fff
-`{-~
\t\n\r]
+/g
,
parseFormat
:
function
(
format
){
parseFormat
:
function
(
format
){
// IE treats \0 as a string end in inputs (truncating the value),
// IE treats \0 as a string end in inputs (truncating the value),
// so it's a bad format delimiter, anyway
// so it's a bad format delimiter, anyway
var
separators
=
format
.
replace
(
this
.
validParts
,
'
\
0'
).
split
(
'
\
0'
),
var
separators
=
format
.
replace
(
this
.
validParts
,
'
\
0'
).
split
(
'
\
0'
),
parts
=
format
.
match
(
this
.
validParts
);
parts
=
format
.
match
(
this
.
validParts
);
if
(
!
separators
||
!
separators
.
length
||
!
parts
||
parts
.
length
==
0
){
if
(
!
separators
||
!
separators
.
length
||
!
parts
||
parts
.
length
==
=
0
){
throw
new
Error
(
"Invalid date format."
);
throw
new
Error
(
"Invalid date format."
);
}
}
return
{
separators
:
separators
,
parts
:
parts
};
return
{
separators
:
separators
,
parts
:
parts
};
},
},
parseDate
:
function
(
date
,
format
,
language
)
{
parseDate
:
function
(
date
,
format
,
language
)
{
if
(
date
instanceof
Date
)
return
date
;
if
(
date
instanceof
Date
)
return
date
;
if
(
/^
[
-+
]\d
+
[
dmwy
]([\s
,
]
+
[
-+
]\d
+
[
dmwy
])
*$/
.
test
(
date
))
{
if
(
/^
[
\-
+
]\d
+
[
dmwy
]([\s
,
]
+
[\
-
+
]\d
+
[
dmwy
])
*$/
.
test
(
date
))
{
var
part_re
=
/
([
-+
]\d
+
)([
dmwy
])
/
,
var
part_re
=
/
([
\
-
+
]\d
+
)([
dmwy
])
/
,
parts
=
date
.
match
(
/
([
-+
]\d
+
)([
dmwy
])
/g
),
parts
=
date
.
match
(
/
([
\
-
+
]\d
+
)([
dmwy
])
/g
),
part
,
dir
;
part
,
dir
;
date
=
new
Date
();
date
=
new
Date
();
for
(
var
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
...
@@ -746,10 +943,18 @@
...
@@ -746,10 +943,18 @@
setters_map
[
'M'
]
=
setters_map
[
'MM'
]
=
setters_map
[
'mm'
]
=
setters_map
[
'm'
];
setters_map
[
'M'
]
=
setters_map
[
'MM'
]
=
setters_map
[
'mm'
]
=
setters_map
[
'm'
];
setters_map
[
'dd'
]
=
setters_map
[
'd'
];
setters_map
[
'dd'
]
=
setters_map
[
'd'
];
date
=
UTCDate
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
0
,
0
,
0
);
date
=
UTCDate
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
0
,
0
,
0
);
if
(
parts
.
length
==
format
.
parts
.
length
)
{
var
fparts
=
format
.
parts
.
slice
();
for
(
var
i
=
0
,
cnt
=
format
.
parts
.
length
;
i
<
cnt
;
i
++
)
{
// Remove noop parts
if
(
parts
.
length
!=
fparts
.
length
)
{
fparts
=
$
(
fparts
).
filter
(
function
(
i
,
p
){
return
$
.
inArray
(
p
,
setters_order
)
!==
-
1
;
}).
toArray
();
}
// Process remainder
if
(
parts
.
length
==
fparts
.
length
)
{
for
(
var
i
=
0
,
cnt
=
fparts
.
length
;
i
<
cnt
;
i
++
)
{
val
=
parseInt
(
parts
[
i
],
10
);
val
=
parseInt
(
parts
[
i
],
10
);
part
=
f
ormat
.
parts
[
i
];
part
=
fparts
[
i
];
if
(
isNaN
(
val
))
{
if
(
isNaN
(
val
))
{
switch
(
part
)
{
switch
(
part
)
{
case
'MM'
:
case
'MM'
:
...
@@ -775,7 +980,7 @@
...
@@ -775,7 +980,7 @@
for
(
var
i
=
0
,
s
;
i
<
setters_order
.
length
;
i
++
){
for
(
var
i
=
0
,
s
;
i
<
setters_order
.
length
;
i
++
){
s
=
setters_order
[
i
];
s
=
setters_order
[
i
];
if
(
s
in
parsed
&&
!
isNaN
(
parsed
[
s
]))
if
(
s
in
parsed
&&
!
isNaN
(
parsed
[
s
]))
setters_map
[
s
](
date
,
parsed
[
s
])
setters_map
[
s
](
date
,
parsed
[
s
])
;
}
}
}
}
return
date
;
return
date
;
...
@@ -783,6 +988,8 @@
...
@@ -783,6 +988,8 @@
formatDate
:
function
(
date
,
format
,
language
){
formatDate
:
function
(
date
,
format
,
language
){
var
val
=
{
var
val
=
{
d
:
date
.
getUTCDate
(),
d
:
date
.
getUTCDate
(),
D
:
dates
[
language
].
daysShort
[
date
.
getUTCDay
()],
DD
:
dates
[
language
].
days
[
date
.
getUTCDay
()],
m
:
date
.
getUTCMonth
()
+
1
,
m
:
date
.
getUTCMonth
()
+
1
,
M
:
dates
[
language
].
monthsShort
[
date
.
getUTCMonth
()],
M
:
dates
[
language
].
monthsShort
[
date
.
getUTCMonth
()],
MM
:
dates
[
language
].
months
[
date
.
getUTCMonth
()],
MM
:
dates
[
language
].
months
[
date
.
getUTCMonth
()],
...
@@ -795,7 +1002,7 @@
...
@@ -795,7 +1002,7 @@
seps
=
$
.
extend
([],
format
.
separators
);
seps
=
$
.
extend
([],
format
.
separators
);
for
(
var
i
=
0
,
cnt
=
format
.
parts
.
length
;
i
<
cnt
;
i
++
)
{
for
(
var
i
=
0
,
cnt
=
format
.
parts
.
length
;
i
<
cnt
;
i
++
)
{
if
(
seps
.
length
)
if
(
seps
.
length
)
date
.
push
(
seps
.
shift
())
date
.
push
(
seps
.
shift
())
;
date
.
push
(
val
[
format
.
parts
[
i
]]);
date
.
push
(
val
[
format
.
parts
[
i
]]);
}
}
return
date
.
join
(
''
);
return
date
.
join
(
''
);
...
@@ -810,7 +1017,7 @@
...
@@ -810,7 +1017,7 @@
contTemplate
:
'<tbody><tr><td colspan="7"></td></tr></tbody>'
,
contTemplate
:
'<tbody><tr><td colspan="7"></td></tr></tbody>'
,
footTemplate
:
'<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
footTemplate
:
'<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
};
};
DPGlobal
.
template
=
'<div class="datepicker
dropdown-menu
">'
+
DPGlobal
.
template
=
'<div class="datepicker">'
+
'<div class="datepicker-days">'
+
'<div class="datepicker-days">'
+
'<table class=" table-condensed">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplate
+
DPGlobal
.
headTemplate
+
...
@@ -833,4 +1040,7 @@
...
@@ -833,4 +1040,7 @@
'</table>'
+
'</table>'
+
'</div>'
+
'</div>'
+
'</div>'
;
'</div>'
;
}(
window
.
jQuery
);
$
.
fn
.
datepicker
.
DPGlobal
=
DPGlobal
;
}(
window
.
jQuery
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment