compass-jquery-plugin 0.3.2.3 → 0.3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +54 -37
- data/VERSION.yml +1 -1
- data/lib/handle_attributes.rb +4 -4
- data/lib/handle_js_files.rb +5 -5
- data/lib/jqtouch_theme.rb +2 -2
- data/lib/jquery/dynatree.rb +2 -2
- data/lib/jquery/emulators.rb +1 -1
- data/lib/jquery/flash_messages.rb +6 -6
- data/lib/jquery/graphics.rb +5 -0
- data/lib/jquery/gridify/assertions.rb +1 -1
- data/lib/jquery/gridify/grid.rb +76 -59
- data/lib/jquery/gridify/grid_column.rb +73 -67
- data/lib/jquery/gridify/grid_finder.rb +79 -79
- data/lib/jquery/gridify/grid_options.rb +154 -149
- data/lib/jquery/gridify/grid_view.rb +143 -143
- data/lib/jquery/gridify.rb +25 -25
- data/lib/jquery/ical/calendar.rb +2 -2
- data/lib/jquery/ical/event.rb +48 -44
- data/lib/jquery/ical/helpers/ui_event_helper.rb +3 -3
- data/lib/jquery/jqgrid/jqgrid.rb +58 -58
- data/lib/jquery/jqgrid.rb +1 -1
- data/lib/jquery/jqtouch.rb +1 -1
- data/lib/jquery/jquery.rb +117 -117
- data/lib/jquery/jquery_auto_complete.rb +9 -9
- data/lib/jquery/jquery_json_response.rb +12 -12
- data/lib/jquery/jquery_selector_assertions.rb +55 -53
- data/lib/jquery/jstree.rb +2 -2
- data/lib/jquery/mobile.rb +1 -1
- data/lib/jquery/ribbon.rb +2 -2
- data/lib/jquery/secret_sauce/controller/ui_dialog_controls.rb +5 -5
- data/lib/jquery/secret_sauce/controller/ui_grid_controls.rb +5 -5
- data/lib/jquery/secret_sauce/helpers/ui_dialog_helper.rb +1 -1
- data/lib/jquery/secret_sauce/helpers/ui_form_helper.rb +39 -39
- data/lib/jquery/secret_sauce/helpers/ui_grid_helper.rb +74 -74
- data/lib/jquery/secret_sauce/model/find_for_grid.rb +21 -21
- data/lib/jquery/secret_sauce.rb +1 -1
- data/lib/jquery/tools.rb +1 -1
- data/lib/jquery_mobile_theme.rb +2 -2
- data/lib/jquery_ui_theme.rb +12 -12
- data/templates/dynatree/config/initializers/dynatree.rb +3 -3
- data/templates/dynatree/jquery/dynatree/aero.scss +16 -16
- data/templates/dynatree/jquery/dynatree/aqua.scss +16 -16
- data/templates/dynatree/jquery/dynatree/crystal.scss +16 -16
- data/templates/dynatree/jquery/dynatree/xp.scss +17 -17
- data/templates/dynatree/jquery.dynatree.js +2926 -2912
- data/templates/emulators/config/initializers/emulators.rb +6 -6
- data/templates/graphics/config/initializers/graphics.rb +5 -0
- data/templates/graphics/jquery/ganttView.scss +89 -0
- data/templates/graphics/jquery.ganttView.js +1669 -0
- data/templates/graphics/jquery.ganttView.min.js +70 -0
- data/templates/{jquery → graphics}/jquery.sparkline.js +466 -438
- data/templates/{jquery → graphics}/jquery.sparkline.min.js +0 -0
- data/templates/graphics/manifest.rb +9 -0
- data/templates/jqgrid/config/initializers/jqgrid.rb +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ar.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-bg.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cat.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-cn.js +137 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cs.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-da.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-de.js +138 -132
- data/templates/jqgrid/i18n/jqgrid/locale-el.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-en.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-es.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-fa.js +19 -16
- data/templates/jqgrid/i18n/jqgrid/locale-fi.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-fr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-gl.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-he.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-hu.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-it.js +8 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ja.js +139 -136
- data/templates/jqgrid/i18n/jqgrid/locale-nl.js +4 -1
- data/templates/jqgrid/i18n/jqgrid/locale-no.js +14 -1
- data/templates/jqgrid/i18n/jqgrid/locale-pl.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt.js +130 -124
- data/templates/jqgrid/i18n/jqgrid/locale-ro.js +144 -138
- data/templates/jqgrid/i18n/jqgrid/locale-ru.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sk.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sr.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-sv.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-tr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-ua.js +132 -126
- data/templates/jqgrid/jquery.jqGrid.js +12735 -10444
- data/templates/jqgrid/jquery.jqGrid.min.js +477 -469
- data/templates/jqgrid/public/stylesheets/ellipsis-xbl.xml +12 -10
- data/templates/jqtouch/config/initializers/jqtouch.rb +3 -3
- data/templates/jqtouch/jquery/touch/jqtouch.scss +1 -1
- data/templates/jqtouch/jquery.jqtouch.js +10025 -10043
- data/templates/jquery/config/initializers/jquery.rb +2 -4
- data/templates/jquery/history.adapter.jquery.js +71 -0
- data/templates/jquery/history.adapter.jquery.min.js +4 -0
- data/templates/jquery/history.html4.js +690 -0
- data/templates/jquery/history.html4.min.js +21 -0
- data/templates/jquery/history.js +1297 -0
- data/templates/jquery/history.min.js +29 -0
- data/templates/jquery/i18n/jquery.ui/datepicker-af.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ar-DZ.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-ar.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-az.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-bg.js +8 -8
- data/templates/jquery/i18n/jquery.ui/datepicker-bs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ca.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-cs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-da.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-de.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-el.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-AU.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-GB.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-NZ.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-es.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-et.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fa.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-fi.js +15 -15
- data/templates/jquery/i18n/jquery.ui/datepicker-fo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr-CH.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr.js +22 -22
- data/templates/jquery/i18n/jquery.ui/datepicker-gl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-he.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.min.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-hy.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-id.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-is.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-it.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ja.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ko.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-kz.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lv.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ml.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ms.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-no.js +16 -16
- data/templates/jquery/i18n/jquery.ui/datepicker-no.min.js +2 -2
- data/templates/jquery/i18n/jquery.ui/datepicker-pl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt-BR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-rm.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-ro.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ru.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sq.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr-SR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sv.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-ta.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-th.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-tr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-uk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-vi.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-CN.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-HK.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-TW.js +20 -20
- data/templates/jquery/{partials → jquery/ui}/_flash_messages.scss +0 -0
- data/templates/jquery/jquery/ui/_theme.scss +14 -13
- data/templates/jquery/jquery/ui/contextMenu/configure.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/cut.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/exit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/paste.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/rename.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/show.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/trash.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu.scss +16 -10
- data/templates/jquery/jquery-ui.js +11839 -23066
- data/templates/jquery/jquery-ui.min.js +401 -795
- data/templates/jquery/jquery.bgiframe.js +27 -25
- data/templates/jquery/jquery.contextMenu.js +209 -196
- data/templates/jquery/jquery.cookie.js +3 -1
- data/templates/jquery/jquery.dotimeout.js +236 -228
- data/templates/jquery/jquery.dst.js +154 -151
- data/templates/jquery/jquery.farbtastic.js +293 -293
- data/templates/jquery/jquery.flashMessages.js +26 -0
- data/templates/jquery/jquery.flashMessages.min.js +1 -0
- data/templates/jquery/jquery.form.js +803 -786
- data/templates/jquery/jquery.haml.js +248 -247
- data/templates/jquery/jquery.hotkeys.js +89 -89
- data/templates/jquery/jquery.js +8141 -8106
- data/templates/jquery/jquery.layout.js +2451 -2415
- data/templates/jquery/jquery.min.js +167 -166
- data/templates/jquery/jquery.mousewheel.js +62 -54
- data/templates/jquery/jquery.offline.js +171 -171
- data/templates/jquery/jquery.pngFix.js +76 -76
- data/templates/jquery/jquery.replacetext.js +83 -83
- data/templates/jquery/jquery.themeswitchertool.js +202 -177
- data/templates/jquery/jquery.tmpl.js +478 -473
- data/templates/jquery/jquery.tmplPlus.js +82 -81
- data/templates/jquery/jrails.js +178 -175
- data/templates/jquery/json.js +77 -7
- data/templates/jquery/json2.js +480 -0
- data/templates/jquery/json2.min.js +7 -0
- data/templates/jquery/lib/tasks/haml.rake +2 -2
- data/templates/jquery/manifest.rb +21 -17
- data/templates/jstree/jquery.jstree.js +5967 -4536
- data/templates/mobile/config/initializers/mobile.rb +1 -1
- data/templates/mobile/jquery/mobile/_base.scss +944 -927
- data/templates/mobile/jquery/mobile/default.scss +61 -48
- data/templates/mobile/jquery/mobile/valencia.scss +56 -42
- data/templates/mobile/jquery.mobile.js +4461 -4347
- data/templates/mobile/jquery.mobile.min.js +11 -2
- data/templates/mobile/lib/tasks/jquery.mobile.rake +12 -12
- data/templates/ribbon/config/initializers/ribbon.rb +2 -2
- data/templates/ribbon/jquery.ribbon.js +50 -29
- data/templates/secret_sauce/secret_sauce.js +8 -8
- data/templates/tools/flowplayer.js +945 -1
- data/templates/tools/jquery.tools.js +4645 -4335
- data/templates/tools/jquery.tools.min.js +37 -37
- data/templates/tools/lib/tasks/jquery.tools.rake +4 -4
- data/templates/tools/swfobject.js +813 -773
- metadata +33 -21
- data/templates/jquery/haml.js +0 -506
- data/templates/jquery/haml.min.js +0 -5
- data/templates/jquery/jquery/ui/contextMenu/door.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_paste.png +0 -0
- data/templates/jquery/jquery.compat-1.3.js +0 -291
- data/templates/jquery/jquery.compat-1.3.min.js +0 -6
- data/templates/jquery/jquery.flash_messages.js +0 -5
- data/templates/jquery/jquery.flash_messages.min.js +0 -1
- data/templates/jquery/jquery.history.js +0 -194
- data/templates/jquery/jquery.history.min.js +0 -5
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'jquery/emulators'
|
2
2
|
|
3
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :blackberry_landscape
|
4
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :blackberry_portrait
|
5
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :ipad_landscape
|
6
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :ipad_portrait
|
3
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :blackberry_landscape => ['compiled/emulators/blackberry.landscape.css']
|
4
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :blackberry_portrait => ['compiled/emulators/blackberry.portrait.css']
|
5
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :ipad_landscape => ['compiled/emulators/ipad.landscape.css']
|
6
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :ipad_portrait => ['compiled/emulators/ipad.portrait.css']
|
7
7
|
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :iphone_landscape => ['compiled/emulators/iphone.landscape.css']
|
8
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :iphone_portrait
|
8
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :iphone_portrait => ['compiled/emulators/iphone.portrait.css']
|
9
9
|
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :palm_landscape => ['compiled/emulators/palm.landscape.css']
|
10
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :palm_portrait
|
10
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :palm_portrait => ['compiled/emulators/palm.portrait.css']
|
@@ -0,0 +1,5 @@
|
|
1
|
+
require 'jquery/graphics'
|
2
|
+
|
3
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :ganttView => ['compiled/jquery/ganttView.css']
|
4
|
+
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :ganttView => ['jquery.ganttView.min']
|
5
|
+
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :sparklines => ['jquery.sparkline.min']
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
jQuery.ganttView v.0.8.0
|
3
|
+
Copyright (c) 2010 JC Grubbs - jc.grubbs@devmynd.com
|
4
|
+
MIT License Applies
|
5
|
+
*/
|
6
|
+
|
7
|
+
div {
|
8
|
+
&.ganttview-hzheader-month, &.ganttview-hzheader-day, &.ganttview-vtheader, &.ganttview-vtheader-item-name, &.ganttview-vtheader-series, &.ganttview-grid, &.ganttview-grid-row-cell {
|
9
|
+
float: left; }
|
10
|
+
&.ganttview-hzheader-month, &.ganttview-hzheader-day {
|
11
|
+
text-align: center; }
|
12
|
+
&.ganttview-grid-row-cell.last, &.ganttview-hzheader-day.last, &.ganttview-hzheader-month.last {
|
13
|
+
border-right: none; }
|
14
|
+
&.ganttview {
|
15
|
+
border: 1px solid #999; }
|
16
|
+
&.ganttview-hzheader-month {
|
17
|
+
width: 60px;
|
18
|
+
height: 20px;
|
19
|
+
border-right: 1px solid #d0d0d0;
|
20
|
+
line-height: 20px; }
|
21
|
+
&.ganttview-hzheader-day {
|
22
|
+
width: 20px;
|
23
|
+
height: 20px;
|
24
|
+
border-right: 1px solid #f0f0f0;
|
25
|
+
border-top: 1px solid #d0d0d0;
|
26
|
+
line-height: 20px;
|
27
|
+
color: #777; }
|
28
|
+
&.ganttview-vtheader {
|
29
|
+
margin-top: 41px;
|
30
|
+
width: 240px;
|
31
|
+
overflow: hidden;
|
32
|
+
background-color: #fff; }
|
33
|
+
&.ganttview-vtheader-item {
|
34
|
+
overflow: hidden;
|
35
|
+
color: #666; }
|
36
|
+
&.ganttview-vtheader-item-name {
|
37
|
+
width: 100px;
|
38
|
+
padding-left: 5px;
|
39
|
+
border-top: 1px solid #d0d0d0;
|
40
|
+
line-height: 16px; }
|
41
|
+
&.ganttview-vtheader-series-name {
|
42
|
+
width: 130px;
|
43
|
+
height: 31px;
|
44
|
+
border-top: 1px solid #d0d0d0;
|
45
|
+
line-height: 16px;
|
46
|
+
padding-left: 5px; }
|
47
|
+
&.ganttview-slide-container {
|
48
|
+
overflow: auto;
|
49
|
+
border-left: 1px solid #999; }
|
50
|
+
&.ganttview-grid-row-cell {
|
51
|
+
width: 20px;
|
52
|
+
height: 31px;
|
53
|
+
border-right: 1px solid #f0f0f0;
|
54
|
+
border-top: 1px solid #f0f0f0;
|
55
|
+
&.ganttview-weekend {
|
56
|
+
background-color: #fafafa; } }
|
57
|
+
&.ganttview-blocks {
|
58
|
+
margin-top: 40px; }
|
59
|
+
&.ganttview-block-container {
|
60
|
+
height: 28px;
|
61
|
+
padding-top: 4px; }
|
62
|
+
&.ganttview-block {
|
63
|
+
position: relative;
|
64
|
+
height: 25px;
|
65
|
+
background-color: #E5ECF9;
|
66
|
+
border: 1px solid #c0c0c0;
|
67
|
+
border-radius: 3px;
|
68
|
+
-moz-border-radius: 3px;
|
69
|
+
-webkit-border-radius: 3px; }
|
70
|
+
&.ganttview-block-text {
|
71
|
+
position: absolute;
|
72
|
+
height: 12px;
|
73
|
+
font-size: 0.8em;
|
74
|
+
color: #999;
|
75
|
+
padding: 2px 3px; }
|
76
|
+
&.ganttview-block div.ui-resizable-handle.ui-resizable-s {
|
77
|
+
bottom: 0; } }
|
78
|
+
|
79
|
+
/* Horizontal Header */
|
80
|
+
|
81
|
+
/* Vertical Header */
|
82
|
+
|
83
|
+
/* Slider */
|
84
|
+
|
85
|
+
/* Grid */
|
86
|
+
|
87
|
+
/* Blocks */
|
88
|
+
|
89
|
+
/* Adjustments for jQuery UI Styling */
|
@@ -0,0 +1,1669 @@
|
|
1
|
+
/**
|
2
|
+
* @version: 1.0 Alpha-1
|
3
|
+
* @author: Coolite Inc. http://www.coolite.com/
|
4
|
+
* @date: 2008-05-13
|
5
|
+
* @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
|
6
|
+
* @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
|
7
|
+
* @website: http://www.datejs.com/
|
8
|
+
*/
|
9
|
+
Date.CultureInfo = {name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|aft(er)?|from|hence)/i,subtract:/^(\-|bef(ore)?|ago)/i,yesterday:/^yes(terday)?/i,today:/^t(od(ay)?)?/i,tomorrow:/^tom(orrow)?/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^mn|min(ute)?s?/i,hour:/^h(our)?s?/i,week:/^w(eek)?s?/i,month:/^m(onth)?s?/i,day:/^d(ay)?s?/i,year:/^y(ear)?s?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a(?!u|p)|p)/i},timezones:[
|
10
|
+
{name:"UTC",offset:"-000"},
|
11
|
+
{name:"GMT",offset:"-000"},
|
12
|
+
{name:"EST",offset:"-0500"},
|
13
|
+
{name:"EDT",offset:"-0400"},
|
14
|
+
{name:"CST",offset:"-0600"},
|
15
|
+
{name:"CDT",offset:"-0500"},
|
16
|
+
{name:"MST",offset:"-0700"},
|
17
|
+
{name:"MDT",offset:"-0600"},
|
18
|
+
{name:"PST",offset:"-0800"},
|
19
|
+
{name:"PDT",offset:"-0700"}
|
20
|
+
]};
|
21
|
+
(function() {
|
22
|
+
var $D = Date,$P = $D.prototype,$C = $D.CultureInfo,p = function(s, l) {
|
23
|
+
if (!l) {
|
24
|
+
l = 2;
|
25
|
+
}
|
26
|
+
return("000" + s).slice(l * -1);
|
27
|
+
};
|
28
|
+
$P.clearTime = function() {
|
29
|
+
this.setHours(0);
|
30
|
+
this.setMinutes(0);
|
31
|
+
this.setSeconds(0);
|
32
|
+
this.setMilliseconds(0);
|
33
|
+
return this;
|
34
|
+
};
|
35
|
+
$P.setTimeToNow = function() {
|
36
|
+
var n = new Date();
|
37
|
+
this.setHours(n.getHours());
|
38
|
+
this.setMinutes(n.getMinutes());
|
39
|
+
this.setSeconds(n.getSeconds());
|
40
|
+
this.setMilliseconds(n.getMilliseconds());
|
41
|
+
return this;
|
42
|
+
};
|
43
|
+
$D.today = function() {
|
44
|
+
return new Date().clearTime();
|
45
|
+
};
|
46
|
+
$D.compare = function(date1, date2) {
|
47
|
+
if (isNaN(date1) || isNaN(date2)) {
|
48
|
+
throw new Error(date1 + " - " + date2);
|
49
|
+
} else if (date1 instanceof Date && date2 instanceof Date) {
|
50
|
+
return(date1 < date2) ? -1 : (date1 > date2) ? 1 : 0;
|
51
|
+
} else {
|
52
|
+
throw new TypeError(date1 + " - " + date2);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
$D.equals = function(date1, date2) {
|
56
|
+
return(date1.compareTo(date2) === 0);
|
57
|
+
};
|
58
|
+
$D.getDayNumberFromName = function(name) {
|
59
|
+
var n = $C.dayNames,m = $C.abbreviatedDayNames,o = $C.shortestDayNames,s = name.toLowerCase();
|
60
|
+
for (var i = 0; i < n.length; i++) {
|
61
|
+
if (n[i].toLowerCase() == s || m[i].toLowerCase() == s || o[i].toLowerCase() == s) {
|
62
|
+
return i;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return-1;
|
66
|
+
};
|
67
|
+
$D.getMonthNumberFromName = function(name) {
|
68
|
+
var n = $C.monthNames,m = $C.abbreviatedMonthNames,s = name.toLowerCase();
|
69
|
+
for (var i = 0; i < n.length; i++) {
|
70
|
+
if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) {
|
71
|
+
return i;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return-1;
|
75
|
+
};
|
76
|
+
$D.isLeapYear = function(year) {
|
77
|
+
return((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
|
78
|
+
};
|
79
|
+
$D.getDaysInMonth = function(year, month) {
|
80
|
+
return[31,($D.isLeapYear(year) ? 29 : 28),31,30,31,30,31,31,30,31,30,31][month];
|
81
|
+
};
|
82
|
+
$D.getTimezoneAbbreviation = function(offset) {
|
83
|
+
var z = $C.timezones,p;
|
84
|
+
for (var i = 0; i < z.length; i++) {
|
85
|
+
if (z[i].offset === offset) {
|
86
|
+
return z[i].name;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return null;
|
90
|
+
};
|
91
|
+
$D.getTimezoneOffset = function(name) {
|
92
|
+
var z = $C.timezones,p;
|
93
|
+
for (var i = 0; i < z.length; i++) {
|
94
|
+
if (z[i].name === name.toUpperCase()) {
|
95
|
+
return z[i].offset;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
return null;
|
99
|
+
};
|
100
|
+
$P.clone = function() {
|
101
|
+
return new Date(this.getTime());
|
102
|
+
};
|
103
|
+
$P.compareTo = function(date) {
|
104
|
+
return Date.compare(this, date);
|
105
|
+
};
|
106
|
+
$P.equals = function(date) {
|
107
|
+
return Date.equals(this, date || new Date());
|
108
|
+
};
|
109
|
+
$P.between = function(start, end) {
|
110
|
+
return this.getTime() >= start.getTime() && this.getTime() <= end.getTime();
|
111
|
+
};
|
112
|
+
$P.isAfter = function(date) {
|
113
|
+
return this.compareTo(date || new Date()) === 1;
|
114
|
+
};
|
115
|
+
$P.isBefore = function(date) {
|
116
|
+
return(this.compareTo(date || new Date()) === -1);
|
117
|
+
};
|
118
|
+
$P.isToday = function() {
|
119
|
+
return this.isSameDay(new Date());
|
120
|
+
};
|
121
|
+
$P.isSameDay = function(date) {
|
122
|
+
return this.clone().clearTime().equals(date.clone().clearTime());
|
123
|
+
};
|
124
|
+
$P.addMilliseconds = function(value) {
|
125
|
+
this.setMilliseconds(this.getMilliseconds() + value);
|
126
|
+
return this;
|
127
|
+
};
|
128
|
+
$P.addSeconds = function(value) {
|
129
|
+
return this.addMilliseconds(value * 1000);
|
130
|
+
};
|
131
|
+
$P.addMinutes = function(value) {
|
132
|
+
return this.addMilliseconds(value * 60000);
|
133
|
+
};
|
134
|
+
$P.addHours = function(value) {
|
135
|
+
return this.addMilliseconds(value * 3600000);
|
136
|
+
};
|
137
|
+
$P.addDays = function(value) {
|
138
|
+
this.setDate(this.getDate() + value);
|
139
|
+
return this;
|
140
|
+
};
|
141
|
+
$P.addWeeks = function(value) {
|
142
|
+
return this.addDays(value * 7);
|
143
|
+
};
|
144
|
+
$P.addMonths = function(value) {
|
145
|
+
var n = this.getDate();
|
146
|
+
this.setDate(1);
|
147
|
+
this.setMonth(this.getMonth() + value);
|
148
|
+
this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth())));
|
149
|
+
return this;
|
150
|
+
};
|
151
|
+
$P.addYears = function(value) {
|
152
|
+
return this.addMonths(value * 12);
|
153
|
+
};
|
154
|
+
$P.add = function(config) {
|
155
|
+
if (typeof config == "number") {
|
156
|
+
this._orient = config;
|
157
|
+
return this;
|
158
|
+
}
|
159
|
+
var x = config;
|
160
|
+
if (x.milliseconds) {
|
161
|
+
this.addMilliseconds(x.milliseconds);
|
162
|
+
}
|
163
|
+
if (x.seconds) {
|
164
|
+
this.addSeconds(x.seconds);
|
165
|
+
}
|
166
|
+
if (x.minutes) {
|
167
|
+
this.addMinutes(x.minutes);
|
168
|
+
}
|
169
|
+
if (x.hours) {
|
170
|
+
this.addHours(x.hours);
|
171
|
+
}
|
172
|
+
if (x.weeks) {
|
173
|
+
this.addWeeks(x.weeks);
|
174
|
+
}
|
175
|
+
if (x.months) {
|
176
|
+
this.addMonths(x.months);
|
177
|
+
}
|
178
|
+
if (x.years) {
|
179
|
+
this.addYears(x.years);
|
180
|
+
}
|
181
|
+
if (x.days) {
|
182
|
+
this.addDays(x.days);
|
183
|
+
}
|
184
|
+
return this;
|
185
|
+
};
|
186
|
+
var $y,$m,$d;
|
187
|
+
$P.getWeek = function() {
|
188
|
+
var a,b,c,d,e,f,g,n,s,w;
|
189
|
+
$y = (!$y) ? this.getFullYear() : $y;
|
190
|
+
$m = (!$m) ? this.getMonth() + 1 : $m;
|
191
|
+
$d = (!$d) ? this.getDate() : $d;
|
192
|
+
if ($m <= 2) {
|
193
|
+
a = $y - 1;
|
194
|
+
b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0);
|
195
|
+
c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0);
|
196
|
+
s = b - c;
|
197
|
+
e = 0;
|
198
|
+
f = $d - 1 + (31 * ($m - 1));
|
199
|
+
} else {
|
200
|
+
a = $y;
|
201
|
+
b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0);
|
202
|
+
c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0);
|
203
|
+
s = b - c;
|
204
|
+
e = s + 1;
|
205
|
+
f = $d + ((153 * ($m - 3) + 2) / 5) + 58 + s;
|
206
|
+
}
|
207
|
+
g = (a + b) % 7;
|
208
|
+
d = (f + g - e) % 7;
|
209
|
+
n = (f + 3 - d) | 0;
|
210
|
+
if (n < 0) {
|
211
|
+
w = 53 - ((g - s) / 5 | 0);
|
212
|
+
} else if (n > 364 + s) {
|
213
|
+
w = 1;
|
214
|
+
} else {
|
215
|
+
w = (n / 7 | 0) + 1;
|
216
|
+
}
|
217
|
+
$y = $m = $d = null;
|
218
|
+
return w;
|
219
|
+
};
|
220
|
+
$P.getISOWeek = function() {
|
221
|
+
$y = this.getUTCFullYear();
|
222
|
+
$m = this.getUTCMonth() + 1;
|
223
|
+
$d = this.getUTCDate();
|
224
|
+
return p(this.getWeek());
|
225
|
+
};
|
226
|
+
$P.setWeek = function(n) {
|
227
|
+
return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek());
|
228
|
+
};
|
229
|
+
$D._validate = function(n, min, max, name) {
|
230
|
+
if (typeof n == "undefined") {
|
231
|
+
return false;
|
232
|
+
} else if (typeof n != "number") {
|
233
|
+
throw new TypeError(n + " is not a Number.");
|
234
|
+
} else if (n < min || n > max) {
|
235
|
+
throw new RangeError(n + " is not a valid value for " + name + ".");
|
236
|
+
}
|
237
|
+
return true;
|
238
|
+
};
|
239
|
+
$D.validateMillisecond = function(value) {
|
240
|
+
return $D._validate(value, 0, 999, "millisecond");
|
241
|
+
};
|
242
|
+
$D.validateSecond = function(value) {
|
243
|
+
return $D._validate(value, 0, 59, "second");
|
244
|
+
};
|
245
|
+
$D.validateMinute = function(value) {
|
246
|
+
return $D._validate(value, 0, 59, "minute");
|
247
|
+
};
|
248
|
+
$D.validateHour = function(value) {
|
249
|
+
return $D._validate(value, 0, 23, "hour");
|
250
|
+
};
|
251
|
+
$D.validateDay = function(value, year, month) {
|
252
|
+
return $D._validate(value, 1, $D.getDaysInMonth(year, month), "day");
|
253
|
+
};
|
254
|
+
$D.validateMonth = function(value) {
|
255
|
+
return $D._validate(value, 0, 11, "month");
|
256
|
+
};
|
257
|
+
$D.validateYear = function(value) {
|
258
|
+
return $D._validate(value, 0, 9999, "year");
|
259
|
+
};
|
260
|
+
$P.set = function(config) {
|
261
|
+
if ($D.validateMillisecond(config.millisecond)) {
|
262
|
+
this.addMilliseconds(config.millisecond - this.getMilliseconds());
|
263
|
+
}
|
264
|
+
if ($D.validateSecond(config.second)) {
|
265
|
+
this.addSeconds(config.second - this.getSeconds());
|
266
|
+
}
|
267
|
+
if ($D.validateMinute(config.minute)) {
|
268
|
+
this.addMinutes(config.minute - this.getMinutes());
|
269
|
+
}
|
270
|
+
if ($D.validateHour(config.hour)) {
|
271
|
+
this.addHours(config.hour - this.getHours());
|
272
|
+
}
|
273
|
+
if ($D.validateMonth(config.month)) {
|
274
|
+
this.addMonths(config.month - this.getMonth());
|
275
|
+
}
|
276
|
+
if ($D.validateYear(config.year)) {
|
277
|
+
this.addYears(config.year - this.getFullYear());
|
278
|
+
}
|
279
|
+
if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) {
|
280
|
+
this.addDays(config.day - this.getDate());
|
281
|
+
}
|
282
|
+
if (config.timezone) {
|
283
|
+
this.setTimezone(config.timezone);
|
284
|
+
}
|
285
|
+
if (config.timezoneOffset) {
|
286
|
+
this.setTimezoneOffset(config.timezoneOffset);
|
287
|
+
}
|
288
|
+
if (config.week && $D._validate(config.week, 0, 53, "week")) {
|
289
|
+
this.setWeek(config.week);
|
290
|
+
}
|
291
|
+
return this;
|
292
|
+
};
|
293
|
+
$P.moveToFirstDayOfMonth = function() {
|
294
|
+
return this.set({day:1});
|
295
|
+
};
|
296
|
+
$P.moveToLastDayOfMonth = function() {
|
297
|
+
return this.set({day:$D.getDaysInMonth(this.getFullYear(), this.getMonth())});
|
298
|
+
};
|
299
|
+
$P.moveToNthOccurrence = function(dayOfWeek, occurrence) {
|
300
|
+
var shift = 0;
|
301
|
+
if (occurrence > 0) {
|
302
|
+
shift = occurrence - 1;
|
303
|
+
}
|
304
|
+
else if (occurrence === -1) {
|
305
|
+
this.moveToLastDayOfMonth();
|
306
|
+
if (this.getDay() !== dayOfWeek) {
|
307
|
+
this.moveToDayOfWeek(dayOfWeek, -1);
|
308
|
+
}
|
309
|
+
return this;
|
310
|
+
}
|
311
|
+
return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift);
|
312
|
+
};
|
313
|
+
$P.moveToDayOfWeek = function(dayOfWeek, orient) {
|
314
|
+
var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7;
|
315
|
+
return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff);
|
316
|
+
};
|
317
|
+
$P.moveToMonth = function(month, orient) {
|
318
|
+
var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12;
|
319
|
+
return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff);
|
320
|
+
};
|
321
|
+
$P.getOrdinalNumber = function() {
|
322
|
+
return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1;
|
323
|
+
};
|
324
|
+
$P.getTimezone = function() {
|
325
|
+
return $D.getTimezoneAbbreviation(this.getUTCOffset());
|
326
|
+
};
|
327
|
+
$P.setTimezoneOffset = function(offset) {
|
328
|
+
var here = this.getTimezoneOffset(),there = Number(offset) * -6 / 10;
|
329
|
+
return this.addMinutes(there - here);
|
330
|
+
};
|
331
|
+
$P.setTimezone = function(offset) {
|
332
|
+
return this.setTimezoneOffset($D.getTimezoneOffset(offset));
|
333
|
+
};
|
334
|
+
$P.hasDaylightSavingTime = function() {
|
335
|
+
return(Date.today().set({month:0,day:1}).getTimezoneOffset() !== Date.today().set({month:6,day:1}).getTimezoneOffset());
|
336
|
+
};
|
337
|
+
$P.isDaylightSavingTime = function() {
|
338
|
+
return(this.hasDaylightSavingTime() && new Date().getTimezoneOffset() === Date.today().set({month:6,day:1}).getTimezoneOffset());
|
339
|
+
};
|
340
|
+
$P.getUTCOffset = function() {
|
341
|
+
var n = this.getTimezoneOffset() * -10 / 6,r;
|
342
|
+
if (n < 0) {
|
343
|
+
r = (n - 10000).toString();
|
344
|
+
return r.charAt(0) + r.substr(2);
|
345
|
+
} else {
|
346
|
+
r = (n + 10000).toString();
|
347
|
+
return"+" + r.substr(1);
|
348
|
+
}
|
349
|
+
};
|
350
|
+
$P.getElapsed = function(date) {
|
351
|
+
return(date || new Date()) - this;
|
352
|
+
};
|
353
|
+
if (!$P.toISOString) {
|
354
|
+
$P.toISOString = function() {
|
355
|
+
function f(n) {
|
356
|
+
return n < 10 ? '0' + n : n;
|
357
|
+
}
|
358
|
+
|
359
|
+
return'"' + this.getUTCFullYear() + '-' +
|
360
|
+
f(this.getUTCMonth() + 1) + '-' +
|
361
|
+
f(this.getUTCDate()) + 'T' +
|
362
|
+
f(this.getUTCHours()) + ':' +
|
363
|
+
f(this.getUTCMinutes()) + ':' +
|
364
|
+
f(this.getUTCSeconds()) + 'Z"';
|
365
|
+
};
|
366
|
+
}
|
367
|
+
$P._toString = $P.toString;
|
368
|
+
$P.toString = function(format) {
|
369
|
+
var x = this;
|
370
|
+
if (format && format.length == 1) {
|
371
|
+
var c = $C.formatPatterns;
|
372
|
+
x.t = x.toString;
|
373
|
+
switch (format) {case"d":return x.t(c.shortDate);case"D":return x.t(c.longDate);case"F":return x.t(c.fullDateTime);case"m":return x.t(c.monthDay);case"r":return x.t(c.rfc1123);case"s":return x.t(c.sortableDateTime);case"t":return x.t(c.shortTime);case"T":return x.t(c.longTime);case"u":return x.t(c.universalSortableDateTime);case"y":return x.t(c.yearMonth);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
var ord = function(n) {
|
377
|
+
switch (n * 1) {case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";
|
378
|
+
}
|
379
|
+
};
|
380
|
+
return format ? format.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g, function(m) {
|
381
|
+
if (m.charAt(0) === "\\") {
|
382
|
+
return m.replace("\\", "");
|
383
|
+
}
|
384
|
+
x.h = x.getHours;
|
385
|
+
switch (m) {case"hh":return p(x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12));case"h":return x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12);case"HH":return p(x.h());case"H":return x.h();case"mm":return p(x.getMinutes());case"m":return x.getMinutes();case"ss":return p(x.getSeconds());case"s":return x.getSeconds();case"yyyy":return p(x.getFullYear(), 4);case"yy":return p(x.getFullYear());case"dddd":return $C.dayNames[x.getDay()];case"ddd":return $C.abbreviatedDayNames[x.getDay()];case"dd":return p(x.getDate());case"d":return x.getDate();case"MMMM":return $C.monthNames[x.getMonth()];case"MMM":return $C.abbreviatedMonthNames[x.getMonth()];case"MM":return p((x.getMonth() + 1));case"M":return x.getMonth() + 1;case"t":return x.h() < 12 ? $C.amDesignator.substring(0, 1) : $C.pmDesignator.substring(0, 1);case"tt":return x.h() < 12 ? $C.amDesignator : $C.pmDesignator;case"S":return ord(x.getDate());default:return m;
|
386
|
+
}
|
387
|
+
}) : this._toString();
|
388
|
+
};
|
389
|
+
}());
|
390
|
+
(function() {
|
391
|
+
var $D = Date,$P = $D.prototype,$C = $D.CultureInfo,$N = Number.prototype;
|
392
|
+
$P._orient = +1;
|
393
|
+
$P._nth = null;
|
394
|
+
$P._is = false;
|
395
|
+
$P._same = false;
|
396
|
+
$P._isSecond = false;
|
397
|
+
$N._dateElement = "day";
|
398
|
+
$P.next = function() {
|
399
|
+
this._orient = +1;
|
400
|
+
return this;
|
401
|
+
};
|
402
|
+
$D.next = function() {
|
403
|
+
return $D.today().next();
|
404
|
+
};
|
405
|
+
$P.last = $P.prev = $P.previous = function() {
|
406
|
+
this._orient = -1;
|
407
|
+
return this;
|
408
|
+
};
|
409
|
+
$D.last = $D.prev = $D.previous = function() {
|
410
|
+
return $D.today().last();
|
411
|
+
};
|
412
|
+
$P.is = function() {
|
413
|
+
this._is = true;
|
414
|
+
return this;
|
415
|
+
};
|
416
|
+
$P.same = function() {
|
417
|
+
this._same = true;
|
418
|
+
this._isSecond = false;
|
419
|
+
return this;
|
420
|
+
};
|
421
|
+
$P.today = function() {
|
422
|
+
return this.same().day();
|
423
|
+
};
|
424
|
+
$P.weekday = function() {
|
425
|
+
if (this._is) {
|
426
|
+
this._is = false;
|
427
|
+
return(!this.is().sat() && !this.is().sun());
|
428
|
+
}
|
429
|
+
return false;
|
430
|
+
};
|
431
|
+
$P.at = function(time) {
|
432
|
+
return(typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time);
|
433
|
+
};
|
434
|
+
$N.fromNow = $N.after = function(date) {
|
435
|
+
var c = {};
|
436
|
+
c[this._dateElement] = this;
|
437
|
+
return((!date) ? new Date() : date.clone()).add(c);
|
438
|
+
};
|
439
|
+
$N.ago = $N.before = function(date) {
|
440
|
+
var c = {};
|
441
|
+
c[this._dateElement] = this * -1;
|
442
|
+
return((!date) ? new Date() : date.clone()).add(c);
|
443
|
+
};
|
444
|
+
var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx = ("january february march april may june july august september october november december").split(/\s/),px = ("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear").split(/\s/),nth = ("final first second third fourth fifth").split(/\s/),de;
|
445
|
+
$P.toObject = function() {
|
446
|
+
var o = {};
|
447
|
+
for (var i = 0; i < px.length; i++) {
|
448
|
+
o[px[i].toLowerCase()] = this["get" + pxf[i]]();
|
449
|
+
}
|
450
|
+
return o;
|
451
|
+
};
|
452
|
+
$D.fromObject = function(config) {
|
453
|
+
config.week = null;
|
454
|
+
return Date.today().set(config);
|
455
|
+
};
|
456
|
+
var df = function(n) {
|
457
|
+
return function() {
|
458
|
+
if (this._is) {
|
459
|
+
this._is = false;
|
460
|
+
return this.getDay() == n;
|
461
|
+
}
|
462
|
+
if (this._nth !== null) {
|
463
|
+
if (this._isSecond) {
|
464
|
+
this.addSeconds(this._orient * -1);
|
465
|
+
}
|
466
|
+
this._isSecond = false;
|
467
|
+
var ntemp = this._nth;
|
468
|
+
this._nth = null;
|
469
|
+
var temp = this.clone().moveToLastDayOfMonth();
|
470
|
+
this.moveToNthOccurrence(n, ntemp);
|
471
|
+
if (this > temp) {
|
472
|
+
throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + ".");
|
473
|
+
}
|
474
|
+
return this;
|
475
|
+
}
|
476
|
+
return this.moveToDayOfWeek(n, this._orient);
|
477
|
+
};
|
478
|
+
};
|
479
|
+
var sdf = function(n) {
|
480
|
+
return function() {
|
481
|
+
var t = $D.today(),shift = n - t.getDay();
|
482
|
+
if (n === 0 && $C.firstDayOfWeek === 1 && t.getDay() !== 0) {
|
483
|
+
shift = shift + 7;
|
484
|
+
}
|
485
|
+
return t.addDays(shift);
|
486
|
+
};
|
487
|
+
};
|
488
|
+
for (var i = 0; i < dx.length; i++) {
|
489
|
+
$D[dx[i].toUpperCase()] = $D[dx[i].toUpperCase().substring(0, 3)] = i;
|
490
|
+
$D[dx[i]] = $D[dx[i].substring(0, 3)] = sdf(i);
|
491
|
+
$P[dx[i]] = $P[dx[i].substring(0, 3)] = df(i);
|
492
|
+
}
|
493
|
+
var mf = function(n) {
|
494
|
+
return function() {
|
495
|
+
if (this._is) {
|
496
|
+
this._is = false;
|
497
|
+
return this.getMonth() === n;
|
498
|
+
}
|
499
|
+
return this.moveToMonth(n, this._orient);
|
500
|
+
};
|
501
|
+
};
|
502
|
+
var smf = function(n) {
|
503
|
+
return function() {
|
504
|
+
return $D.today().set({month:n,day:1});
|
505
|
+
};
|
506
|
+
};
|
507
|
+
for (var j = 0; j < mx.length; j++) {
|
508
|
+
$D[mx[j].toUpperCase()] = $D[mx[j].toUpperCase().substring(0, 3)] = j;
|
509
|
+
$D[mx[j]] = $D[mx[j].substring(0, 3)] = smf(j);
|
510
|
+
$P[mx[j]] = $P[mx[j].substring(0, 3)] = mf(j);
|
511
|
+
}
|
512
|
+
var ef = function(j) {
|
513
|
+
return function() {
|
514
|
+
if (this._isSecond) {
|
515
|
+
this._isSecond = false;
|
516
|
+
return this;
|
517
|
+
}
|
518
|
+
if (this._same) {
|
519
|
+
this._same = this._is = false;
|
520
|
+
var o1 = this.toObject(),o2 = (arguments[0] || new Date()).toObject(),v = "",k = j.toLowerCase();
|
521
|
+
for (var m = (px.length - 1); m > -1; m--) {
|
522
|
+
v = px[m].toLowerCase();
|
523
|
+
if (o1[v] != o2[v]) {
|
524
|
+
return false;
|
525
|
+
}
|
526
|
+
if (k == v) {
|
527
|
+
break;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
return true;
|
531
|
+
}
|
532
|
+
if (j.substring(j.length - 1) != "s") {
|
533
|
+
j += "s";
|
534
|
+
}
|
535
|
+
return this["add" + j](this._orient);
|
536
|
+
};
|
537
|
+
};
|
538
|
+
var nf = function(n) {
|
539
|
+
return function() {
|
540
|
+
this._dateElement = n;
|
541
|
+
return this;
|
542
|
+
};
|
543
|
+
};
|
544
|
+
for (var k = 0; k < px.length; k++) {
|
545
|
+
de = px[k].toLowerCase();
|
546
|
+
$P[de] = $P[de + "s"] = ef(px[k]);
|
547
|
+
$N[de] = $N[de + "s"] = nf(de);
|
548
|
+
}
|
549
|
+
$P._ss = ef("Second");
|
550
|
+
var nthfn = function(n) {
|
551
|
+
return function(dayOfWeek) {
|
552
|
+
if (this._same) {
|
553
|
+
return this._ss(arguments[0]);
|
554
|
+
}
|
555
|
+
if (dayOfWeek || dayOfWeek === 0) {
|
556
|
+
return this.moveToNthOccurrence(dayOfWeek, n);
|
557
|
+
}
|
558
|
+
this._nth = n;
|
559
|
+
if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) {
|
560
|
+
this._isSecond = true;
|
561
|
+
return this.addSeconds(this._orient);
|
562
|
+
}
|
563
|
+
return this;
|
564
|
+
};
|
565
|
+
};
|
566
|
+
for (var l = 0; l < nth.length; l++) {
|
567
|
+
$P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l);
|
568
|
+
}
|
569
|
+
}());
|
570
|
+
(function() {
|
571
|
+
Date.Parsing = {Exception:function(s) {
|
572
|
+
this.message = "Parse error at '" + s.substring(0, 10) + " ...'";
|
573
|
+
}};
|
574
|
+
var $P = Date.Parsing;
|
575
|
+
var _ = $P.Operators = {rtoken:function(r) {
|
576
|
+
return function(s) {
|
577
|
+
var mx = s.match(r);
|
578
|
+
if (mx) {
|
579
|
+
return([mx[0],s.substring(mx[0].length)]);
|
580
|
+
} else {
|
581
|
+
throw new $P.Exception(s);
|
582
|
+
}
|
583
|
+
};
|
584
|
+
},token:function(s) {
|
585
|
+
return function(s) {
|
586
|
+
return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s);
|
587
|
+
};
|
588
|
+
},stoken:function(s) {
|
589
|
+
return _.rtoken(new RegExp("^" + s));
|
590
|
+
},until:function(p) {
|
591
|
+
return function(s) {
|
592
|
+
var qx = [],rx = null;
|
593
|
+
while (s.length) {
|
594
|
+
try {
|
595
|
+
rx = p.call(this, s);
|
596
|
+
} catch(e) {
|
597
|
+
qx.push(rx[0]);
|
598
|
+
s = rx[1];
|
599
|
+
continue;
|
600
|
+
}
|
601
|
+
break;
|
602
|
+
}
|
603
|
+
return[qx,s];
|
604
|
+
};
|
605
|
+
},many:function(p) {
|
606
|
+
return function(s) {
|
607
|
+
var rx = [],r = null;
|
608
|
+
while (s.length) {
|
609
|
+
try {
|
610
|
+
r = p.call(this, s);
|
611
|
+
} catch(e) {
|
612
|
+
return[rx,s];
|
613
|
+
}
|
614
|
+
rx.push(r[0]);
|
615
|
+
s = r[1];
|
616
|
+
}
|
617
|
+
return[rx,s];
|
618
|
+
};
|
619
|
+
},optional:function(p) {
|
620
|
+
return function(s) {
|
621
|
+
var r = null;
|
622
|
+
try {
|
623
|
+
r = p.call(this, s);
|
624
|
+
} catch(e) {
|
625
|
+
return[null,s];
|
626
|
+
}
|
627
|
+
return[r[0],r[1]];
|
628
|
+
};
|
629
|
+
},not:function(p) {
|
630
|
+
return function(s) {
|
631
|
+
try {
|
632
|
+
p.call(this, s);
|
633
|
+
} catch(e) {
|
634
|
+
return[null,s];
|
635
|
+
}
|
636
|
+
throw new $P.Exception(s);
|
637
|
+
};
|
638
|
+
},ignore:function(p) {
|
639
|
+
return p ? function(s) {
|
640
|
+
var r = null;
|
641
|
+
r = p.call(this, s);
|
642
|
+
return[null,r[1]];
|
643
|
+
} : null;
|
644
|
+
},product:function() {
|
645
|
+
var px = arguments[0],qx = Array.prototype.slice.call(arguments, 1),rx = [];
|
646
|
+
for (var i = 0; i < px.length; i++) {
|
647
|
+
rx.push(_.each(px[i], qx));
|
648
|
+
}
|
649
|
+
return rx;
|
650
|
+
},cache:function(rule) {
|
651
|
+
var cache = {},r = null;
|
652
|
+
return function(s) {
|
653
|
+
try {
|
654
|
+
r = cache[s] = (cache[s] || rule.call(this, s));
|
655
|
+
} catch(e) {
|
656
|
+
r = cache[s] = e;
|
657
|
+
}
|
658
|
+
if (r instanceof $P.Exception) {
|
659
|
+
throw r;
|
660
|
+
} else {
|
661
|
+
return r;
|
662
|
+
}
|
663
|
+
};
|
664
|
+
},any:function() {
|
665
|
+
var px = arguments;
|
666
|
+
return function(s) {
|
667
|
+
var r = null;
|
668
|
+
for (var i = 0; i < px.length; i++) {
|
669
|
+
if (px[i] == null) {
|
670
|
+
continue;
|
671
|
+
}
|
672
|
+
try {
|
673
|
+
r = (px[i].call(this, s));
|
674
|
+
} catch(e) {
|
675
|
+
r = null;
|
676
|
+
}
|
677
|
+
if (r) {
|
678
|
+
return r;
|
679
|
+
}
|
680
|
+
}
|
681
|
+
throw new $P.Exception(s);
|
682
|
+
};
|
683
|
+
},each:function() {
|
684
|
+
var px = arguments;
|
685
|
+
return function(s) {
|
686
|
+
var rx = [],r = null;
|
687
|
+
for (var i = 0; i < px.length; i++) {
|
688
|
+
if (px[i] == null) {
|
689
|
+
continue;
|
690
|
+
}
|
691
|
+
try {
|
692
|
+
r = (px[i].call(this, s));
|
693
|
+
} catch(e) {
|
694
|
+
throw new $P.Exception(s);
|
695
|
+
}
|
696
|
+
rx.push(r[0]);
|
697
|
+
s = r[1];
|
698
|
+
}
|
699
|
+
return[rx,s];
|
700
|
+
};
|
701
|
+
},all:function() {
|
702
|
+
var px = arguments,_ = _;
|
703
|
+
return _.each(_.optional(px));
|
704
|
+
},sequence:function(px, d, c) {
|
705
|
+
d = d || _.rtoken(/^\s*/);
|
706
|
+
c = c || null;
|
707
|
+
if (px.length == 1) {
|
708
|
+
return px[0];
|
709
|
+
}
|
710
|
+
return function(s) {
|
711
|
+
var r = null,q = null;
|
712
|
+
var rx = [];
|
713
|
+
for (var i = 0; i < px.length; i++) {
|
714
|
+
try {
|
715
|
+
r = px[i].call(this, s);
|
716
|
+
} catch(e) {
|
717
|
+
break;
|
718
|
+
}
|
719
|
+
rx.push(r[0]);
|
720
|
+
try {
|
721
|
+
q = d.call(this, r[1]);
|
722
|
+
} catch(ex) {
|
723
|
+
q = null;
|
724
|
+
break;
|
725
|
+
}
|
726
|
+
s = q[1];
|
727
|
+
}
|
728
|
+
if (!r) {
|
729
|
+
throw new $P.Exception(s);
|
730
|
+
}
|
731
|
+
if (q) {
|
732
|
+
throw new $P.Exception(q[1]);
|
733
|
+
}
|
734
|
+
if (c) {
|
735
|
+
try {
|
736
|
+
r = c.call(this, r[1]);
|
737
|
+
} catch(ey) {
|
738
|
+
throw new $P.Exception(r[1]);
|
739
|
+
}
|
740
|
+
}
|
741
|
+
return[rx,(r ? r[1] : s)];
|
742
|
+
};
|
743
|
+
},between:function(d1, p, d2) {
|
744
|
+
d2 = d2 || d1;
|
745
|
+
var _fn = _.each(_.ignore(d1), p, _.ignore(d2));
|
746
|
+
return function(s) {
|
747
|
+
var rx = _fn.call(this, s);
|
748
|
+
return[
|
749
|
+
[rx[0][0],r[0][2]],
|
750
|
+
rx[1]
|
751
|
+
];
|
752
|
+
};
|
753
|
+
},list:function(p, d, c) {
|
754
|
+
d = d || _.rtoken(/^\s*/);
|
755
|
+
c = c || null;
|
756
|
+
return(p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c)));
|
757
|
+
},set:function(px, d, c) {
|
758
|
+
d = d || _.rtoken(/^\s*/);
|
759
|
+
c = c || null;
|
760
|
+
return function(s) {
|
761
|
+
var r = null,p = null,q = null,rx = null,best = [
|
762
|
+
[],
|
763
|
+
s
|
764
|
+
],last = false;
|
765
|
+
for (var i = 0; i < px.length; i++) {
|
766
|
+
q = null;
|
767
|
+
p = null;
|
768
|
+
r = null;
|
769
|
+
last = (px.length == 1);
|
770
|
+
try {
|
771
|
+
r = px[i].call(this, s);
|
772
|
+
} catch(e) {
|
773
|
+
continue;
|
774
|
+
}
|
775
|
+
rx = [
|
776
|
+
[r[0]],
|
777
|
+
r[1]
|
778
|
+
];
|
779
|
+
if (r[1].length > 0 && !last) {
|
780
|
+
try {
|
781
|
+
q = d.call(this, r[1]);
|
782
|
+
} catch(ex) {
|
783
|
+
last = true;
|
784
|
+
}
|
785
|
+
} else {
|
786
|
+
last = true;
|
787
|
+
}
|
788
|
+
if (!last && q[1].length === 0) {
|
789
|
+
last = true;
|
790
|
+
}
|
791
|
+
if (!last) {
|
792
|
+
var qx = [];
|
793
|
+
for (var j = 0; j < px.length; j++) {
|
794
|
+
if (i != j) {
|
795
|
+
qx.push(px[j]);
|
796
|
+
}
|
797
|
+
}
|
798
|
+
p = _.set(qx, d).call(this, q[1]);
|
799
|
+
if (p[0].length > 0) {
|
800
|
+
rx[0] = rx[0].concat(p[0]);
|
801
|
+
rx[1] = p[1];
|
802
|
+
}
|
803
|
+
}
|
804
|
+
if (rx[1].length < best[1].length) {
|
805
|
+
best = rx;
|
806
|
+
}
|
807
|
+
if (best[1].length === 0) {
|
808
|
+
break;
|
809
|
+
}
|
810
|
+
}
|
811
|
+
if (best[0].length === 0) {
|
812
|
+
return best;
|
813
|
+
}
|
814
|
+
if (c) {
|
815
|
+
try {
|
816
|
+
q = c.call(this, best[1]);
|
817
|
+
} catch(ey) {
|
818
|
+
throw new $P.Exception(best[1]);
|
819
|
+
}
|
820
|
+
best[1] = q[1];
|
821
|
+
}
|
822
|
+
return best;
|
823
|
+
};
|
824
|
+
},forward:function(gr, fname) {
|
825
|
+
return function(s) {
|
826
|
+
return gr[fname].call(this, s);
|
827
|
+
};
|
828
|
+
},replace:function(rule, repl) {
|
829
|
+
return function(s) {
|
830
|
+
var r = rule.call(this, s);
|
831
|
+
return[repl,r[1]];
|
832
|
+
};
|
833
|
+
},process:function(rule, fn) {
|
834
|
+
return function(s) {
|
835
|
+
var r = rule.call(this, s);
|
836
|
+
return[fn.call(this, r[0]),r[1]];
|
837
|
+
};
|
838
|
+
},min:function(min, rule) {
|
839
|
+
return function(s) {
|
840
|
+
var rx = rule.call(this, s);
|
841
|
+
if (rx[0].length < min) {
|
842
|
+
throw new $P.Exception(s);
|
843
|
+
}
|
844
|
+
return rx;
|
845
|
+
};
|
846
|
+
}};
|
847
|
+
var _generator = function(op) {
|
848
|
+
return function() {
|
849
|
+
var args = null,rx = [];
|
850
|
+
if (arguments.length > 1) {
|
851
|
+
args = Array.prototype.slice.call(arguments);
|
852
|
+
} else if (arguments[0]instanceof Array) {
|
853
|
+
args = arguments[0];
|
854
|
+
}
|
855
|
+
if (args) {
|
856
|
+
for (var i = 0,px = args.shift(); i < px.length; i++) {
|
857
|
+
args.unshift(px[i]);
|
858
|
+
rx.push(op.apply(null, args));
|
859
|
+
args.shift();
|
860
|
+
return rx;
|
861
|
+
}
|
862
|
+
} else {
|
863
|
+
return op.apply(null, arguments);
|
864
|
+
}
|
865
|
+
};
|
866
|
+
};
|
867
|
+
var gx = "optional not ignore cache".split(/\s/);
|
868
|
+
for (var i = 0; i < gx.length; i++) {
|
869
|
+
_[gx[i]] = _generator(_[gx[i]]);
|
870
|
+
}
|
871
|
+
var _vector = function(op) {
|
872
|
+
return function() {
|
873
|
+
if (arguments[0]instanceof Array) {
|
874
|
+
return op.apply(null, arguments[0]);
|
875
|
+
} else {
|
876
|
+
return op.apply(null, arguments);
|
877
|
+
}
|
878
|
+
};
|
879
|
+
};
|
880
|
+
var vx = "each any all".split(/\s/);
|
881
|
+
for (var j = 0; j < vx.length; j++) {
|
882
|
+
_[vx[j]] = _vector(_[vx[j]]);
|
883
|
+
}
|
884
|
+
}());
|
885
|
+
(function() {
|
886
|
+
var $D = Date,$P = $D.prototype,$C = $D.CultureInfo;
|
887
|
+
var flattenAndCompact = function(ax) {
|
888
|
+
var rx = [];
|
889
|
+
for (var i = 0; i < ax.length; i++) {
|
890
|
+
if (ax[i]instanceof Array) {
|
891
|
+
rx = rx.concat(flattenAndCompact(ax[i]));
|
892
|
+
} else {
|
893
|
+
if (ax[i]) {
|
894
|
+
rx.push(ax[i]);
|
895
|
+
}
|
896
|
+
}
|
897
|
+
}
|
898
|
+
return rx;
|
899
|
+
};
|
900
|
+
$D.Grammar = {};
|
901
|
+
$D.Translator = {hour:function(s) {
|
902
|
+
return function() {
|
903
|
+
this.hour = Number(s);
|
904
|
+
};
|
905
|
+
},minute:function(s) {
|
906
|
+
return function() {
|
907
|
+
this.minute = Number(s);
|
908
|
+
};
|
909
|
+
},second:function(s) {
|
910
|
+
return function() {
|
911
|
+
this.second = Number(s);
|
912
|
+
};
|
913
|
+
},meridian:function(s) {
|
914
|
+
return function() {
|
915
|
+
this.meridian = s.slice(0, 1).toLowerCase();
|
916
|
+
};
|
917
|
+
},timezone:function(s) {
|
918
|
+
return function() {
|
919
|
+
var n = s.replace(/[^\d\+\-]/g, "");
|
920
|
+
if (n.length) {
|
921
|
+
this.timezoneOffset = Number(n);
|
922
|
+
} else {
|
923
|
+
this.timezone = s.toLowerCase();
|
924
|
+
}
|
925
|
+
};
|
926
|
+
},day:function(x) {
|
927
|
+
var s = x[0];
|
928
|
+
return function() {
|
929
|
+
this.day = Number(s.match(/\d+/)[0]);
|
930
|
+
};
|
931
|
+
},month:function(s) {
|
932
|
+
return function() {
|
933
|
+
this.month = (s.length == 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s) / 4 : Number(s) - 1;
|
934
|
+
};
|
935
|
+
},year:function(s) {
|
936
|
+
return function() {
|
937
|
+
var n = Number(s);
|
938
|
+
this.year = ((s.length > 2) ? n : (n + (((n + 2000) < $C.twoDigitYearMax) ? 2000 : 1900)));
|
939
|
+
};
|
940
|
+
},rday:function(s) {
|
941
|
+
return function() {
|
942
|
+
switch (s) {case"yesterday":this.days = -1;break;case"tomorrow":this.days = 1;break;case"today":this.days = 0;break;case"now":this.days = 0;this.now = true;break;
|
943
|
+
}
|
944
|
+
};
|
945
|
+
},finishExact:function(x) {
|
946
|
+
x = (x instanceof Array) ? x : [x];
|
947
|
+
for (var i = 0; i < x.length; i++) {
|
948
|
+
if (x[i]) {
|
949
|
+
x[i].call(this);
|
950
|
+
}
|
951
|
+
}
|
952
|
+
var now = new Date();
|
953
|
+
if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) {
|
954
|
+
this.day = now.getDate();
|
955
|
+
}
|
956
|
+
if (!this.year) {
|
957
|
+
this.year = now.getFullYear();
|
958
|
+
}
|
959
|
+
if (!this.month && this.month !== 0) {
|
960
|
+
this.month = now.getMonth();
|
961
|
+
}
|
962
|
+
if (!this.day) {
|
963
|
+
this.day = 1;
|
964
|
+
}
|
965
|
+
if (!this.hour) {
|
966
|
+
this.hour = 0;
|
967
|
+
}
|
968
|
+
if (!this.minute) {
|
969
|
+
this.minute = 0;
|
970
|
+
}
|
971
|
+
if (!this.second) {
|
972
|
+
this.second = 0;
|
973
|
+
}
|
974
|
+
if (this.meridian && this.hour) {
|
975
|
+
if (this.meridian == "p" && this.hour < 12) {
|
976
|
+
this.hour = this.hour + 12;
|
977
|
+
} else if (this.meridian == "a" && this.hour == 12) {
|
978
|
+
this.hour = 0;
|
979
|
+
}
|
980
|
+
}
|
981
|
+
if (this.day > $D.getDaysInMonth(this.year, this.month)) {
|
982
|
+
throw new RangeError(this.day + " is not a valid value for days.");
|
983
|
+
}
|
984
|
+
var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second);
|
985
|
+
if (this.timezone) {
|
986
|
+
r.set({timezone:this.timezone});
|
987
|
+
} else if (this.timezoneOffset) {
|
988
|
+
r.set({timezoneOffset:this.timezoneOffset});
|
989
|
+
}
|
990
|
+
return r;
|
991
|
+
},finish:function(x) {
|
992
|
+
x = (x instanceof Array) ? flattenAndCompact(x) : [x];
|
993
|
+
if (x.length === 0) {
|
994
|
+
return null;
|
995
|
+
}
|
996
|
+
for (var i = 0; i < x.length; i++) {
|
997
|
+
if (typeof x[i] == "function") {
|
998
|
+
x[i].call(this);
|
999
|
+
}
|
1000
|
+
}
|
1001
|
+
var today = $D.today();
|
1002
|
+
if (this.now && !this.unit && !this.operator) {
|
1003
|
+
return new Date();
|
1004
|
+
} else if (this.now) {
|
1005
|
+
today = new Date();
|
1006
|
+
}
|
1007
|
+
var expression = !!(this.days && this.days !== null || this.orient || this.operator);
|
1008
|
+
var gap,mod,orient;
|
1009
|
+
orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1);
|
1010
|
+
if (!this.now && "hour minute second".indexOf(this.unit) != -1) {
|
1011
|
+
today.setTimeToNow();
|
1012
|
+
}
|
1013
|
+
if (this.month || this.month === 0) {
|
1014
|
+
if ("year day hour minute second".indexOf(this.unit) != -1) {
|
1015
|
+
this.value = this.month + 1;
|
1016
|
+
this.month = null;
|
1017
|
+
expression = true;
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
if (!expression && this.weekday && !this.day && !this.days) {
|
1021
|
+
var temp = Date[this.weekday]();
|
1022
|
+
this.day = temp.getDate();
|
1023
|
+
if (!this.month) {
|
1024
|
+
this.month = temp.getMonth();
|
1025
|
+
}
|
1026
|
+
this.year = temp.getFullYear();
|
1027
|
+
}
|
1028
|
+
if (expression && this.weekday && this.unit != "month") {
|
1029
|
+
this.unit = "day";
|
1030
|
+
gap = ($D.getDayNumberFromName(this.weekday) - today.getDay());
|
1031
|
+
mod = 7;
|
1032
|
+
this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod);
|
1033
|
+
}
|
1034
|
+
if (this.month && this.unit == "day" && this.operator) {
|
1035
|
+
this.value = (this.month + 1);
|
1036
|
+
this.month = null;
|
1037
|
+
}
|
1038
|
+
if (this.value != null && this.month != null && this.year != null) {
|
1039
|
+
this.day = this.value * 1;
|
1040
|
+
}
|
1041
|
+
if (this.month && !this.day && this.value) {
|
1042
|
+
today.set({day:this.value * 1});
|
1043
|
+
if (!expression) {
|
1044
|
+
this.day = this.value * 1;
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
if (!this.month && this.value && this.unit == "month" && !this.now) {
|
1048
|
+
this.month = this.value;
|
1049
|
+
expression = true;
|
1050
|
+
}
|
1051
|
+
if (expression && (this.month || this.month === 0) && this.unit != "year") {
|
1052
|
+
this.unit = "month";
|
1053
|
+
gap = (this.month - today.getMonth());
|
1054
|
+
mod = 12;
|
1055
|
+
this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod);
|
1056
|
+
this.month = null;
|
1057
|
+
}
|
1058
|
+
if (!this.unit) {
|
1059
|
+
this.unit = "day";
|
1060
|
+
}
|
1061
|
+
if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) {
|
1062
|
+
this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator == "add") ? 1 : -1) + (this.value || 0) * orient;
|
1063
|
+
} else if (this[this.unit + "s"] == null || this.operator != null) {
|
1064
|
+
if (!this.value) {
|
1065
|
+
this.value = 1;
|
1066
|
+
}
|
1067
|
+
this[this.unit + "s"] = this.value * orient;
|
1068
|
+
}
|
1069
|
+
if (this.meridian && this.hour) {
|
1070
|
+
if (this.meridian == "p" && this.hour < 12) {
|
1071
|
+
this.hour = this.hour + 12;
|
1072
|
+
} else if (this.meridian == "a" && this.hour == 12) {
|
1073
|
+
this.hour = 0;
|
1074
|
+
}
|
1075
|
+
}
|
1076
|
+
if (this.weekday && !this.day && !this.days) {
|
1077
|
+
var temp = Date[this.weekday]();
|
1078
|
+
this.day = temp.getDate();
|
1079
|
+
if (temp.getMonth() !== today.getMonth()) {
|
1080
|
+
this.month = temp.getMonth();
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
if ((this.month || this.month === 0) && !this.day) {
|
1084
|
+
this.day = 1;
|
1085
|
+
}
|
1086
|
+
if (!this.orient && !this.operator && this.unit == "week" && this.value && !this.day && !this.month) {
|
1087
|
+
return Date.today().setWeek(this.value);
|
1088
|
+
}
|
1089
|
+
if (expression && this.timezone && this.day && this.days) {
|
1090
|
+
this.day = this.days;
|
1091
|
+
}
|
1092
|
+
return(expression) ? today.add(this) : today.set(this);
|
1093
|
+
}};
|
1094
|
+
var _ = $D.Parsing.Operators,g = $D.Grammar,t = $D.Translator,_fn;
|
1095
|
+
g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/);
|
1096
|
+
g.timePartDelimiter = _.stoken(":");
|
1097
|
+
g.whiteSpace = _.rtoken(/^\s*/);
|
1098
|
+
g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/);
|
1099
|
+
var _C = {};
|
1100
|
+
g.ctoken = function(keys) {
|
1101
|
+
var fn = _C[keys];
|
1102
|
+
if (!fn) {
|
1103
|
+
var c = $C.regexPatterns;
|
1104
|
+
var kx = keys.split(/\s+/),px = [];
|
1105
|
+
for (var i = 0; i < kx.length; i++) {
|
1106
|
+
px.push(_.replace(_.rtoken(c[kx[i]]), kx[i]));
|
1107
|
+
}
|
1108
|
+
fn = _C[keys] = _.any.apply(null, px);
|
1109
|
+
}
|
1110
|
+
return fn;
|
1111
|
+
};
|
1112
|
+
g.ctoken2 = function(key) {
|
1113
|
+
return _.rtoken($C.regexPatterns[key]);
|
1114
|
+
};
|
1115
|
+
g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour));
|
1116
|
+
g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour));
|
1117
|
+
g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour));
|
1118
|
+
g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour));
|
1119
|
+
g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute));
|
1120
|
+
g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute));
|
1121
|
+
g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second));
|
1122
|
+
g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second));
|
1123
|
+
g.hms = _.cache(_.sequence([g.H,g.m,g.s], g.timePartDelimiter));
|
1124
|
+
g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian));
|
1125
|
+
g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian));
|
1126
|
+
g.z = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone));
|
1127
|
+
g.zz = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone));
|
1128
|
+
g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone));
|
1129
|
+
g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([g.tt,g.zzz]));
|
1130
|
+
g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix);
|
1131
|
+
g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day));
|
1132
|
+
g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day));
|
1133
|
+
g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function(s) {
|
1134
|
+
return function() {
|
1135
|
+
this.weekday = s;
|
1136
|
+
};
|
1137
|
+
}));
|
1138
|
+
g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month));
|
1139
|
+
g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month));
|
1140
|
+
g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month));
|
1141
|
+
g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year));
|
1142
|
+
g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year));
|
1143
|
+
g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year));
|
1144
|
+
g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year));
|
1145
|
+
_fn = function() {
|
1146
|
+
return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext")));
|
1147
|
+
};
|
1148
|
+
g.day = _fn(g.d, g.dd);
|
1149
|
+
g.month = _fn(g.M, g.MMM);
|
1150
|
+
g.year = _fn(g.yyyy, g.yy);
|
1151
|
+
g.orientation = _.process(g.ctoken("past future"), function(s) {
|
1152
|
+
return function() {
|
1153
|
+
this.orient = s;
|
1154
|
+
};
|
1155
|
+
});
|
1156
|
+
g.operator = _.process(g.ctoken("add subtract"), function(s) {
|
1157
|
+
return function() {
|
1158
|
+
this.operator = s;
|
1159
|
+
};
|
1160
|
+
});
|
1161
|
+
g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday);
|
1162
|
+
g.unit = _.process(g.ctoken("second minute hour day week month year"), function(s) {
|
1163
|
+
return function() {
|
1164
|
+
this.unit = s;
|
1165
|
+
};
|
1166
|
+
});
|
1167
|
+
g.value = _.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/), function(s) {
|
1168
|
+
return function() {
|
1169
|
+
this.value = s.replace(/\D/g, "");
|
1170
|
+
};
|
1171
|
+
});
|
1172
|
+
g.expression = _.set([g.rday,g.operator,g.value,g.unit,g.orientation,g.ddd,g.MMM]);
|
1173
|
+
_fn = function() {
|
1174
|
+
return _.set(arguments, g.datePartDelimiter);
|
1175
|
+
};
|
1176
|
+
g.mdy = _fn(g.ddd, g.month, g.day, g.year);
|
1177
|
+
g.ymd = _fn(g.ddd, g.year, g.month, g.day);
|
1178
|
+
g.dmy = _fn(g.ddd, g.day, g.month, g.year);
|
1179
|
+
g.date = function(s) {
|
1180
|
+
return((g[$C.dateElementOrder] || g.mdy).call(this, s));
|
1181
|
+
};
|
1182
|
+
g.format = _.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function(fmt) {
|
1183
|
+
if (g[fmt]) {
|
1184
|
+
return g[fmt];
|
1185
|
+
} else {
|
1186
|
+
throw $D.Parsing.Exception(fmt);
|
1187
|
+
}
|
1188
|
+
}), _.process(_.rtoken(/^[^dMyhHmstz]+/), function(s) {
|
1189
|
+
return _.ignore(_.stoken(s));
|
1190
|
+
}))), function(rules) {
|
1191
|
+
return _.process(_.each.apply(null, rules), t.finishExact);
|
1192
|
+
});
|
1193
|
+
var _F = {};
|
1194
|
+
var _get = function(f) {
|
1195
|
+
return _F[f] = (_F[f] || g.format(f)[0]);
|
1196
|
+
};
|
1197
|
+
g.formats = function(fx) {
|
1198
|
+
if (fx instanceof Array) {
|
1199
|
+
var rx = [];
|
1200
|
+
for (var i = 0; i < fx.length; i++) {
|
1201
|
+
rx.push(_get(fx[i]));
|
1202
|
+
}
|
1203
|
+
return _.any.apply(null, rx);
|
1204
|
+
} else {
|
1205
|
+
return _get(fx);
|
1206
|
+
}
|
1207
|
+
};
|
1208
|
+
g._formats = g.formats(["\"yyyy-MM-ddTHH:mm:ssZ\"","yyyy-MM-ddTHH:mm:ssZ","yyyy-MM-ddTHH:mm:ssz","yyyy-MM-ddTHH:mm:ss","yyyy-MM-ddTHH:mmZ","yyyy-MM-ddTHH:mmz","yyyy-MM-ddTHH:mm","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","MMddyyyy","ddMMyyyy","Mddyyyy","ddMyyyy","Mdyyyy","dMyyyy","yyyy","Mdyy","dMyy","d"]);
|
1209
|
+
g._start = _.process(_.set([g.date,g.time,g.expression], g.generalDelimiter, g.whiteSpace), t.finish);
|
1210
|
+
g.start = function(s) {
|
1211
|
+
try {
|
1212
|
+
var r = g._formats.call({}, s);
|
1213
|
+
if (r[1].length === 0) {
|
1214
|
+
return r;
|
1215
|
+
}
|
1216
|
+
} catch(e) {
|
1217
|
+
}
|
1218
|
+
return g._start.call({}, s);
|
1219
|
+
};
|
1220
|
+
$D._parse = $D.parse;
|
1221
|
+
$D.parse = function(s) {
|
1222
|
+
var r = null;
|
1223
|
+
if (!s) {
|
1224
|
+
return null;
|
1225
|
+
}
|
1226
|
+
if (s instanceof Date) {
|
1227
|
+
return s;
|
1228
|
+
}
|
1229
|
+
try {
|
1230
|
+
r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
|
1231
|
+
} catch(e) {
|
1232
|
+
return null;
|
1233
|
+
}
|
1234
|
+
return((r[1].length === 0) ? r[0] : null);
|
1235
|
+
};
|
1236
|
+
$D.getParseFunction = function(fx) {
|
1237
|
+
var fn = $D.Grammar.formats(fx);
|
1238
|
+
return function(s) {
|
1239
|
+
var r = null;
|
1240
|
+
try {
|
1241
|
+
r = fn.call({}, s);
|
1242
|
+
} catch(e) {
|
1243
|
+
return null;
|
1244
|
+
}
|
1245
|
+
return((r[1].length === 0) ? r[0] : null);
|
1246
|
+
};
|
1247
|
+
};
|
1248
|
+
$D.parseExact = function(s, fx) {
|
1249
|
+
return $D.getParseFunction(fx)(s);
|
1250
|
+
};
|
1251
|
+
}());
|
1252
|
+
|
1253
|
+
|
1254
|
+
/*
|
1255
|
+
jQuery.ganttView v.0.8.8
|
1256
|
+
Copyright (c) 2010 JC Grubbs - jc.grubbs@devmynd.com
|
1257
|
+
MIT License Applies
|
1258
|
+
*/
|
1259
|
+
|
1260
|
+
/*
|
1261
|
+
Options
|
1262
|
+
-----------------
|
1263
|
+
showWeekends: boolean
|
1264
|
+
data: object
|
1265
|
+
cellWidth: number
|
1266
|
+
cellHeight: number
|
1267
|
+
slideWidth: number
|
1268
|
+
dataUrl: string
|
1269
|
+
behavior: {
|
1270
|
+
clickable: boolean,
|
1271
|
+
draggable: boolean,
|
1272
|
+
resizable: boolean,
|
1273
|
+
onClick: function,
|
1274
|
+
onDrag: function,
|
1275
|
+
onResize: function
|
1276
|
+
}
|
1277
|
+
*/
|
1278
|
+
|
1279
|
+
(function (jQuery) {
|
1280
|
+
|
1281
|
+
jQuery.fn.ganttView = function () {
|
1282
|
+
|
1283
|
+
var args = Array.prototype.slice.call(arguments);
|
1284
|
+
|
1285
|
+
if (args.length == 1 && typeof(args[0]) == "object") {
|
1286
|
+
build.call(this, args[0]);
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
if (args.length == 2 && typeof(args[0]) == "string") {
|
1290
|
+
handleMethod.call(this, args[0], args[1]);
|
1291
|
+
}
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
function build(options) {
|
1295
|
+
|
1296
|
+
var els = this;
|
1297
|
+
var defaults = {
|
1298
|
+
showWeekends: true,
|
1299
|
+
cellWidth: 21,
|
1300
|
+
cellHeight: 31,
|
1301
|
+
slideWidth: 400,
|
1302
|
+
vHeaderWidth: 100,
|
1303
|
+
behavior: {
|
1304
|
+
clickable: true,
|
1305
|
+
draggable: true,
|
1306
|
+
resizable: true
|
1307
|
+
}
|
1308
|
+
};
|
1309
|
+
|
1310
|
+
var opts = jQuery.extend(true, defaults, options);
|
1311
|
+
|
1312
|
+
if (opts.data) {
|
1313
|
+
build();
|
1314
|
+
} else if (opts.dataUrl) {
|
1315
|
+
jQuery.getJSON(opts.dataUrl, function (data) {
|
1316
|
+
opts.data = data;
|
1317
|
+
build();
|
1318
|
+
});
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
function build() {
|
1322
|
+
|
1323
|
+
var minDays = Math.floor((opts.slideWidth / opts.cellWidth) + 5);
|
1324
|
+
var startEnd = DateUtils.getBoundaryDatesFromData(opts.data, minDays);
|
1325
|
+
opts.start = startEnd[0];
|
1326
|
+
opts.end = startEnd[1];
|
1327
|
+
|
1328
|
+
els.each(function () {
|
1329
|
+
|
1330
|
+
var container = jQuery(this);
|
1331
|
+
var div = jQuery("<div>", { "class": "ganttview" });
|
1332
|
+
new Chart(div, opts).render();
|
1333
|
+
container.append(div);
|
1334
|
+
|
1335
|
+
var w = jQuery("div.ganttview-vtheader", container).outerWidth() +
|
1336
|
+
jQuery("div.ganttview-slide-container", container).outerWidth();
|
1337
|
+
container.css("width", (w + 2) + "px");
|
1338
|
+
|
1339
|
+
new Behavior(container, opts).apply();
|
1340
|
+
});
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
function handleMethod(method, value) {
|
1345
|
+
|
1346
|
+
if (method == "setSlideWidth") {
|
1347
|
+
var div = $("div.ganttview", this);
|
1348
|
+
div.each(function () {
|
1349
|
+
var vtWidth = $("div.ganttview-vtheader", div).outerWidth();
|
1350
|
+
$(div).width(vtWidth + value + 1);
|
1351
|
+
$("div.ganttview-slide-container", this).width(value);
|
1352
|
+
});
|
1353
|
+
}
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
var Chart = function(div, opts) {
|
1357
|
+
|
1358
|
+
function render() {
|
1359
|
+
addVtHeader(div, opts.data, opts.cellHeight);
|
1360
|
+
|
1361
|
+
var slideDiv = jQuery("<div>", {
|
1362
|
+
"class": "ganttview-slide-container",
|
1363
|
+
"css": { "width": opts.slideWidth + "px" }
|
1364
|
+
});
|
1365
|
+
|
1366
|
+
dates = getDates(opts.start, opts.end);
|
1367
|
+
addHzHeader(slideDiv, dates, opts.cellWidth);
|
1368
|
+
addGrid(slideDiv, opts.data, dates, opts.cellWidth, opts.showWeekends);
|
1369
|
+
addBlockContainers(slideDiv, opts.data);
|
1370
|
+
addBlocks(slideDiv, opts.data, opts.cellWidth, opts.start);
|
1371
|
+
div.append(slideDiv);
|
1372
|
+
applyLastClass(div.parent());
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
1376
|
+
|
1377
|
+
// Creates a 3 dimensional array [year][month][day] of every day
|
1378
|
+
// between the given start and end dates
|
1379
|
+
function getDates(start, end) {
|
1380
|
+
var dates = [];
|
1381
|
+
dates[start.getFullYear()] = [];
|
1382
|
+
dates[start.getFullYear()][start.getMonth()] = [start]
|
1383
|
+
var last = start;
|
1384
|
+
while (last.compareTo(end) == -1) {
|
1385
|
+
var next = last.clone().addDays(1);
|
1386
|
+
if (!dates[next.getFullYear()]) {
|
1387
|
+
dates[next.getFullYear()] = [];
|
1388
|
+
}
|
1389
|
+
if (!dates[next.getFullYear()][next.getMonth()]) {
|
1390
|
+
dates[next.getFullYear()][next.getMonth()] = [];
|
1391
|
+
}
|
1392
|
+
dates[next.getFullYear()][next.getMonth()].push(next);
|
1393
|
+
last = next;
|
1394
|
+
}
|
1395
|
+
return dates;
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
function addVtHeader(div, data, cellHeight) {
|
1399
|
+
var headerDiv = jQuery("<div>", { "class": "ganttview-vtheader" });
|
1400
|
+
for (var i = 0; i < data.length; i++) {
|
1401
|
+
var itemDiv = jQuery("<div>", { "class": "ganttview-vtheader-item" });
|
1402
|
+
itemDiv.append(jQuery("<div>", {
|
1403
|
+
"class": "ganttview-vtheader-item-name",
|
1404
|
+
"css": { "height": (data[i].series.length * cellHeight) + "px" }
|
1405
|
+
}).append(data[i].name));
|
1406
|
+
var seriesDiv = jQuery("<div>", { "class": "ganttview-vtheader-series" });
|
1407
|
+
for (var j = 0; j < data[i].series.length; j++) {
|
1408
|
+
seriesDiv.append(jQuery("<div>", { "class": "ganttview-vtheader-series-name" })
|
1409
|
+
.append(data[i].series[j].name));
|
1410
|
+
}
|
1411
|
+
itemDiv.append(seriesDiv);
|
1412
|
+
headerDiv.append(itemDiv);
|
1413
|
+
}
|
1414
|
+
div.append(headerDiv);
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
function addHzHeader(div, dates, cellWidth) {
|
1418
|
+
var headerDiv = jQuery("<div>", { "class": "ganttview-hzheader" });
|
1419
|
+
var monthsDiv = jQuery("<div>", { "class": "ganttview-hzheader-months" });
|
1420
|
+
var daysDiv = jQuery("<div>", { "class": "ganttview-hzheader-days" });
|
1421
|
+
var totalW = 0;
|
1422
|
+
for (var y in dates) {
|
1423
|
+
for (var m in dates[y]) {
|
1424
|
+
var w = dates[y][m].length * cellWidth;
|
1425
|
+
totalW = totalW + w;
|
1426
|
+
monthsDiv.append(jQuery("<div>", {
|
1427
|
+
"class": "ganttview-hzheader-month",
|
1428
|
+
"css": { "width": (w - 1) + "px" }
|
1429
|
+
}).append(monthNames[m] + "/" + y));
|
1430
|
+
for (var d in dates[y][m]) {
|
1431
|
+
daysDiv.append(jQuery("<div>", { "class": "ganttview-hzheader-day" })
|
1432
|
+
.append(dates[y][m][d].getDate()));
|
1433
|
+
}
|
1434
|
+
}
|
1435
|
+
}
|
1436
|
+
monthsDiv.css("width", totalW + "px");
|
1437
|
+
daysDiv.css("width", totalW + "px");
|
1438
|
+
headerDiv.append(monthsDiv).append(daysDiv);
|
1439
|
+
div.append(headerDiv);
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
function addGrid(div, data, dates, cellWidth, showWeekends) {
|
1443
|
+
var gridDiv = jQuery("<div>", { "class": "ganttview-grid" });
|
1444
|
+
var rowDiv = jQuery("<div>", { "class": "ganttview-grid-row" });
|
1445
|
+
for (var y in dates) {
|
1446
|
+
for (var m in dates[y]) {
|
1447
|
+
for (var d in dates[y][m]) {
|
1448
|
+
var cellDiv = jQuery("<div>", { "class": "ganttview-grid-row-cell" });
|
1449
|
+
if (DateUtils.isWeekend(dates[y][m][d]) && showWeekends) {
|
1450
|
+
cellDiv.addClass("ganttview-weekend");
|
1451
|
+
}
|
1452
|
+
rowDiv.append(cellDiv);
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
}
|
1456
|
+
var w = jQuery("div.ganttview-grid-row-cell", rowDiv).length * cellWidth;
|
1457
|
+
rowDiv.css("width", w + "px");
|
1458
|
+
gridDiv.css("width", w + "px");
|
1459
|
+
for (var i = 0; i < data.length; i++) {
|
1460
|
+
for (var j = 0; j < data[i].series.length; j++) {
|
1461
|
+
gridDiv.append(rowDiv.clone());
|
1462
|
+
}
|
1463
|
+
}
|
1464
|
+
div.append(gridDiv);
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
function addBlockContainers(div, data) {
|
1468
|
+
var blocksDiv = jQuery("<div>", { "class": "ganttview-blocks" });
|
1469
|
+
for (var i = 0; i < data.length; i++) {
|
1470
|
+
for (var j = 0; j < data[i].series.length; j++) {
|
1471
|
+
blocksDiv.append(jQuery("<div>", { "class": "ganttview-block-container" }));
|
1472
|
+
}
|
1473
|
+
}
|
1474
|
+
div.append(blocksDiv);
|
1475
|
+
}
|
1476
|
+
|
1477
|
+
function addBlocks(div, data, cellWidth, start) {
|
1478
|
+
var rows = jQuery("div.ganttview-blocks div.ganttview-block-container", div);
|
1479
|
+
var rowIdx = 0;
|
1480
|
+
for (var i = 0; i < data.length; i++) {
|
1481
|
+
for (var j = 0; j < data[i].series.length; j++) {
|
1482
|
+
var series = data[i].series[j];
|
1483
|
+
var size = DateUtils.daysBetween(series.start, series.end) + 1;
|
1484
|
+
var offset = DateUtils.daysBetween(start, series.start);
|
1485
|
+
var block = jQuery("<div>", {
|
1486
|
+
"class": "ganttview-block",
|
1487
|
+
"title": series.name + ", " + size + " days",
|
1488
|
+
"css": {
|
1489
|
+
"width": ((size * cellWidth) - 9) + "px",
|
1490
|
+
"margin-left": ((offset * cellWidth) + 3) + "px"
|
1491
|
+
}
|
1492
|
+
});
|
1493
|
+
addBlockData(block, data[i], series);
|
1494
|
+
if (data[i].series[j].color) {
|
1495
|
+
block.css("background-color", data[i].series[j].color);
|
1496
|
+
}
|
1497
|
+
block.append(jQuery("<div>", { "class": "ganttview-block-text" }).text(size));
|
1498
|
+
jQuery(rows[rowIdx]).append(block);
|
1499
|
+
rowIdx = rowIdx + 1;
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
|
1504
|
+
function addBlockData(block, data, series) {
|
1505
|
+
// This allows custom attributes to be added to the series data objects
|
1506
|
+
// and makes them available to the 'data' argument of click, resize, and drag handlers
|
1507
|
+
var blockData = { id: data.id, name: data.name };
|
1508
|
+
jQuery.extend(blockData, series);
|
1509
|
+
block.data("block-data", blockData);
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
function applyLastClass(div) {
|
1513
|
+
jQuery("div.ganttview-grid-row div.ganttview-grid-row-cell:last-child", div).addClass("last");
|
1514
|
+
jQuery("div.ganttview-hzheader-days div.ganttview-hzheader-day:last-child", div).addClass("last");
|
1515
|
+
jQuery("div.ganttview-hzheader-months div.ganttview-hzheader-month:last-child", div).addClass("last");
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
return {
|
1519
|
+
render: render
|
1520
|
+
};
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
var Behavior = function (div, opts) {
|
1524
|
+
|
1525
|
+
function apply() {
|
1526
|
+
|
1527
|
+
if (opts.behavior.clickable) {
|
1528
|
+
bindBlockClick(div, opts.behavior.onClick);
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
if (opts.behavior.resizable) {
|
1532
|
+
bindBlockResize(div, opts.cellWidth, opts.start, opts.behavior.onResize);
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
if (opts.behavior.draggable) {
|
1536
|
+
bindBlockDrag(div, opts.cellWidth, opts.start, opts.behavior.onDrag);
|
1537
|
+
}
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
function bindBlockClick(div, callback) {
|
1541
|
+
jQuery("div.ganttview-block", div).live("click", function () {
|
1542
|
+
if (callback) {
|
1543
|
+
callback(jQuery(this).data("block-data"));
|
1544
|
+
}
|
1545
|
+
});
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
function bindBlockResize(div, cellWidth, startDate, callback) {
|
1549
|
+
jQuery("div.ganttview-block", div).resizable({
|
1550
|
+
grid: cellWidth,
|
1551
|
+
handles: "e,w",
|
1552
|
+
stop: function () {
|
1553
|
+
var block = jQuery(this);
|
1554
|
+
updateDataAndPosition(div, block, cellWidth, startDate);
|
1555
|
+
if (callback) {
|
1556
|
+
callback(block.data("block-data"));
|
1557
|
+
}
|
1558
|
+
}
|
1559
|
+
});
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
function bindBlockDrag(div, cellWidth, startDate, callback) {
|
1563
|
+
jQuery("div.ganttview-block", div).draggable({
|
1564
|
+
axis: "x",
|
1565
|
+
grid: [cellWidth, cellWidth],
|
1566
|
+
stop: function () {
|
1567
|
+
var block = jQuery(this);
|
1568
|
+
updateDataAndPosition(div, block, cellWidth, startDate);
|
1569
|
+
if (callback) {
|
1570
|
+
callback(block.data("block-data"));
|
1571
|
+
}
|
1572
|
+
}
|
1573
|
+
});
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
function updateDataAndPosition(div, block, cellWidth, startDate) {
|
1577
|
+
var container = jQuery("div.ganttview-slide-container", div);
|
1578
|
+
var scroll = container.scrollLeft();
|
1579
|
+
var offset = block.offset().left - container.offset().left - 1 + scroll;
|
1580
|
+
|
1581
|
+
// Set new start date
|
1582
|
+
var daysFromStart = Math.round(offset / cellWidth);
|
1583
|
+
var newStart = startDate.clone().addDays(daysFromStart);
|
1584
|
+
block.data("block-data").start = newStart;
|
1585
|
+
|
1586
|
+
// Set new end date
|
1587
|
+
var width = block.outerWidth();
|
1588
|
+
var numberOfDays = Math.round(width / cellWidth) - 1;
|
1589
|
+
block.data("block-data").end = newStart.clone().addDays(numberOfDays);
|
1590
|
+
jQuery("div.ganttview-block-text", block).text(numberOfDays + 1);
|
1591
|
+
|
1592
|
+
// Remove top and left properties to avoid incorrect block positioning,
|
1593
|
+
// set position to relative to keep blocks relative to scrollbar when scrolling
|
1594
|
+
block.css("top", "").css("left", "")
|
1595
|
+
.css("position", "relative").css("margin-left", offset + "px");
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
return {
|
1599
|
+
apply: apply
|
1600
|
+
};
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
var ArrayUtils = {
|
1604
|
+
|
1605
|
+
contains: function (arr, obj) {
|
1606
|
+
var has = false;
|
1607
|
+
for (var i = 0; i < arr.length; i++) {
|
1608
|
+
if (arr[i] == obj) {
|
1609
|
+
has = true;
|
1610
|
+
}
|
1611
|
+
}
|
1612
|
+
return has;
|
1613
|
+
}
|
1614
|
+
};
|
1615
|
+
|
1616
|
+
var DateUtils = {
|
1617
|
+
|
1618
|
+
daysBetween: function (start, end) {
|
1619
|
+
if (!start || !end) {
|
1620
|
+
return 0;
|
1621
|
+
}
|
1622
|
+
start = Date.parse(start);
|
1623
|
+
end = Date.parse(end);
|
1624
|
+
if (start.getYear() == 1901 || end.getYear() == 8099) {
|
1625
|
+
return 0;
|
1626
|
+
}
|
1627
|
+
var count = 0, date = start.clone();
|
1628
|
+
while (date.compareTo(end) == -1) {
|
1629
|
+
count = count + 1;
|
1630
|
+
date.addDays(1);
|
1631
|
+
}
|
1632
|
+
return count;
|
1633
|
+
},
|
1634
|
+
|
1635
|
+
isWeekend: function (date) {
|
1636
|
+
return date.getDay() % 6 == 0;
|
1637
|
+
},
|
1638
|
+
|
1639
|
+
getBoundaryDatesFromData: function (data, minDays) {
|
1640
|
+
var minStart = new Date();
|
1641
|
+
maxEnd = new Date();
|
1642
|
+
for (var i = 0; i < data.length; i++) {
|
1643
|
+
for (var j = 0; j < data[i].series.length; j++) {
|
1644
|
+
var start = Date.parse(data[i].series[j].start);
|
1645
|
+
var end = Date.parse(data[i].series[j].end)
|
1646
|
+
if (i == 0 && j == 0) {
|
1647
|
+
minStart = start;
|
1648
|
+
maxEnd = end;
|
1649
|
+
}
|
1650
|
+
if (minStart.compareTo(start) == 1) {
|
1651
|
+
minStart = start;
|
1652
|
+
}
|
1653
|
+
if (maxEnd.compareTo(end) == -1) {
|
1654
|
+
maxEnd = end;
|
1655
|
+
}
|
1656
|
+
}
|
1657
|
+
}
|
1658
|
+
|
1659
|
+
// Insure that the width of the chart is at least the slide width to avoid empty
|
1660
|
+
// whitespace to the right of the grid
|
1661
|
+
if (DateUtils.daysBetween(minStart, maxEnd) < minDays) {
|
1662
|
+
maxEnd = minStart.clone().addDays(minDays);
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
return [minStart, maxEnd];
|
1666
|
+
}
|
1667
|
+
};
|
1668
|
+
|
1669
|
+
})(jQuery);
|