watch_tower 0.0.0.1 → 0.0.1.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.todo +3 -0
- data/.travis.yml +4 -0
- data/Gemfile +0 -4
- data/README.md +48 -2
- data/TODO +3 -0
- data/ci/travis.rb +4 -1
- data/lib/watch_tower/appscript.rb +65 -7
- data/lib/watch_tower/cli/install.rb +27 -3
- data/lib/watch_tower/cli/open.rb +2 -0
- data/lib/watch_tower/cli/start.rb +3 -1
- data/lib/watch_tower/cli.rb +2 -0
- data/lib/watch_tower/config.rb +2 -0
- data/lib/watch_tower/core_ext.rb +2 -0
- data/lib/watch_tower/editor/base_appscript.rb +28 -1
- data/lib/watch_tower/editor/base_ps.rb +25 -0
- data/lib/watch_tower/editor/textmate.rb +2 -0
- data/lib/watch_tower/editor/xcode.rb +2 -0
- data/lib/watch_tower/editor.rb +2 -0
- data/lib/watch_tower/errors.rb +2 -0
- data/lib/watch_tower/eye.rb +13 -2
- data/lib/watch_tower/file_tree.rb +78 -0
- data/lib/watch_tower/project/any_based.rb +2 -0
- data/lib/watch_tower/project/git_based.rb +2 -0
- data/lib/watch_tower/project/init.rb +2 -0
- data/lib/watch_tower/project/path_based.rb +2 -0
- data/lib/watch_tower/project.rb +2 -0
- data/lib/watch_tower/server/app.rb +37 -7
- data/lib/watch_tower/server/assets/javascripts/application.js +4 -0
- data/lib/watch_tower/server/assets/javascripts/datepicker.coffee +21 -0
- data/lib/watch_tower/server/assets/javascripts/file_tree.coffee +30 -0
- data/lib/watch_tower/server/assets/javascripts/percentage.coffee +15 -5
- data/lib/watch_tower/server/assets/stylesheets/application.css +1 -0
- data/lib/watch_tower/server/assets/stylesheets/date.sass +17 -0
- data/lib/watch_tower/server/assets/stylesheets/file_tree.sass +42 -0
- data/lib/watch_tower/server/assets/stylesheets/global.sass +7 -4
- data/lib/watch_tower/server/configurations/asset.rb +2 -0
- data/lib/watch_tower/server/configurations.rb +2 -0
- data/lib/watch_tower/server/database.rb +2 -0
- data/lib/watch_tower/server/db/migrate/001_create_projects.rb +2 -0
- data/lib/watch_tower/server/db/migrate/002_create_files.rb +2 -0
- data/lib/watch_tower/server/db/migrate/003_create_time_entries.rb +2 -0
- data/lib/watch_tower/server/db/migrate/004_create_durations.rb +2 -0
- data/lib/watch_tower/server/db/migrate/005_add_hash_to_time_entries.rb +2 -0
- data/lib/watch_tower/server/db/migrate/006_add_hash_to_files.rb +2 -0
- data/lib/watch_tower/server/db/migrate/007_add_editor_to_times_entries.rb +8 -0
- data/lib/watch_tower/server/db/migrate/008_rename_editor_to_editor_name_in_times_entries.rb +5 -0
- data/lib/watch_tower/server/db/migrate/009_remove_editor_index_from_time_entries.rb +7 -0
- data/lib/watch_tower/server/db/migrate/010_add_editor_version_to_times_entries.rb +7 -0
- data/lib/watch_tower/server/helpers/asset.rb +2 -0
- data/lib/watch_tower/server/helpers/improved_partials.rb +2 -0
- data/lib/watch_tower/server/helpers/presenters.rb +33 -0
- data/lib/watch_tower/server/helpers.rb +3 -0
- data/lib/watch_tower/server/models/duration.rb +9 -0
- data/lib/watch_tower/server/models/file.rb +17 -0
- data/lib/watch_tower/server/models/project.rb +30 -0
- data/lib/watch_tower/server/models/time_entry.rb +5 -0
- data/lib/watch_tower/server/presenters/application_presenter.rb +165 -0
- data/lib/watch_tower/server/presenters/file_presenter.rb +10 -0
- data/lib/watch_tower/server/presenters/project_presenter.rb +20 -0
- data/lib/watch_tower/server/presenters.rb +13 -0
- data/lib/watch_tower/server/public/assets/{WatchTower-4d6de11e1bd34165ad91ac46fb711bf3.jpg → WatchTower-58eff0713efffbc6054defddc879e0b1.jpg} +0 -0
- data/lib/watch_tower/server/public/assets/application-4e6971066e06aa53b0c8e52c764044d1.css +389 -0
- data/lib/watch_tower/server/public/assets/application-6a1be75d4fd6a545faceb638e47a2486.js +23778 -0
- data/lib/watch_tower/server/public/assets/calendar-379834cd6e6321a940b662ace47f3032.gif +0 -0
- data/lib/watch_tower/server/public/assets/calendar-blue-d6aa74feef7ee4287532761db99a6c0a.gif +0 -0
- data/lib/watch_tower/server/public/assets/calendar-green-3752fe2996091379c8d321f759039385.gif +0 -0
- data/lib/watch_tower/server/public/assets/jquery.datepick-9c8dfe3a4d40bcafc7b182e194c13836.css +227 -0
- data/lib/watch_tower/server/public/assets/{percentage-d8589e21a5fc85d32a445f531ff8ab95.png → percentage-d0176e99520c95e93eee63738ef5d487.png} +0 -0
- data/lib/watch_tower/server/vendor/assets/images/calendar-blue.gif +0 -0
- data/lib/watch_tower/server/vendor/assets/images/calendar-green.gif +0 -0
- data/lib/watch_tower/server/vendor/assets/images/calendar.gif +0 -0
- data/lib/watch_tower/server/vendor/assets/javascripts/jquery-datepick-ext.js +266 -0
- data/lib/watch_tower/server/vendor/assets/javascripts/jquery-datepick-validation.js +232 -0
- data/lib/watch_tower/server/vendor/assets/javascripts/jquery-datepick.js +2092 -0
- data/lib/watch_tower/server/vendor/assets/stylesheets/jquery.datepick.css +226 -0
- data/lib/watch_tower/server/views/_project.haml +10 -13
- data/lib/watch_tower/server/views/index.haml +9 -6
- data/lib/watch_tower/server/views/layout.haml +7 -4
- data/lib/watch_tower/server/views/project.haml +9 -11
- data/lib/watch_tower/server.rb +8 -1
- data/lib/watch_tower/templates/{watchtower.plist → watchtower.plist.erb} +5 -6
- data/lib/watch_tower/version.rb +12 -3
- data/lib/watch_tower.rb +20 -1
- data/spec/factories.rb +2 -0
- data/spec/watch_tower/appscript_spec.rb +36 -2
- data/spec/watch_tower/editor/base_appscript_spec.rb +83 -0
- data/spec/watch_tower/editor/textmate_spec.rb +37 -0
- data/spec/watch_tower/editor/xcode_spec.rb +6 -0
- data/spec/watch_tower/eye_spec.rb +21 -0
- data/spec/watch_tower/file_tree_spec.rb +156 -0
- data/spec/watch_tower/server/app_spec.rb +64 -20
- data/spec/watch_tower/server/models/file_spec.rb +93 -31
- data/spec/watch_tower/server/models/project_spec.rb +147 -18
- data/spec/watch_tower/server/models/time_entry_spec.rb +10 -0
- data/spec/watch_tower/server/{decorator/project_decorator_spec.rb → presenters/application_presenter_spec.rb} +24 -13
- data/spec/watch_tower/server/presenters/file_presenter_spec.rb +8 -0
- data/spec/watch_tower/server/presenters/project_presenter_spec.rb +130 -0
- data/watch_tower.gemspec +10 -4
- metadata +114 -74
- data/lib/watch_tower/server/decorator/application_decorator.rb +0 -91
- data/lib/watch_tower/server/decorator/file_decorator.rb +0 -38
- data/lib/watch_tower/server/decorator/project_decorator.rb +0 -51
- data/lib/watch_tower/server/decorator.rb +0 -21
- data/lib/watch_tower/server/public/assets/application-7829b53b5ece1a16d22dc3d00f329023.css +0 -107
- data/lib/watch_tower/server/public/assets/application-e0e6b7731aade460f680331e65cf0682.js +0 -9359
- data/lib/watch_tower/server/views/_file.haml +0 -9
Binary file
|
Binary file
|
Binary file
|
data/lib/watch_tower/server/public/assets/jquery.datepick-9c8dfe3a4d40bcafc7b182e194c13836.css
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
/* Default styling for jQuery Datepicker v4.0.6. */
|
2
|
+
|
3
|
+
.datepick {
|
4
|
+
background-color: #fff;
|
5
|
+
color: #000;
|
6
|
+
border: 1px solid #444;
|
7
|
+
border-radius: 0.25em;
|
8
|
+
-moz-border-radius: 0.25em;
|
9
|
+
-webkit-border-radius: 0.25em;
|
10
|
+
font-family: Arial,Helvetica,Sans-serif;
|
11
|
+
font-size: 90%;
|
12
|
+
}
|
13
|
+
.datepick-rtl {
|
14
|
+
direction: rtl;
|
15
|
+
}
|
16
|
+
.datepick-popup {
|
17
|
+
z-index: 1000;
|
18
|
+
}
|
19
|
+
.datepick-disable {
|
20
|
+
position: absolute;
|
21
|
+
z-index: 100;
|
22
|
+
background-color: white;
|
23
|
+
opacity: 0.5;
|
24
|
+
filter: alpha(opacity=50);
|
25
|
+
}
|
26
|
+
.datepick a {
|
27
|
+
color: #fff;
|
28
|
+
text-decoration: none;
|
29
|
+
}
|
30
|
+
.datepick a.datepick-disabled {
|
31
|
+
color: #888;
|
32
|
+
cursor: auto;
|
33
|
+
}
|
34
|
+
.datepick button {
|
35
|
+
margin: 0.25em;
|
36
|
+
padding: 0.125em 0em;
|
37
|
+
background-color: #fcc;
|
38
|
+
border: none;
|
39
|
+
border-radius: 0.25em;
|
40
|
+
-moz-border-radius: 0.25em;
|
41
|
+
-webkit-border-radius: 0.25em;
|
42
|
+
font-weight: bold;
|
43
|
+
}
|
44
|
+
.datepick-nav, .datepick-ctrl {
|
45
|
+
float: left;
|
46
|
+
width: 100%;
|
47
|
+
background-color: #000;
|
48
|
+
color: #fff;
|
49
|
+
font-size: 90%;
|
50
|
+
font-weight: bold;
|
51
|
+
}
|
52
|
+
.datepick-ctrl {
|
53
|
+
background-color: #600;
|
54
|
+
}
|
55
|
+
.datepick-cmd {
|
56
|
+
width: 30%;
|
57
|
+
}
|
58
|
+
.datepick-cmd:hover {
|
59
|
+
background-color: #777;
|
60
|
+
}
|
61
|
+
.datepick-ctrl .datepick-cmd:hover {
|
62
|
+
background-color: #f08080;
|
63
|
+
}
|
64
|
+
.datepick-cmd-prevJump, .datepick-cmd-nextJump {
|
65
|
+
width: 8%;
|
66
|
+
}
|
67
|
+
a.datepick-cmd {
|
68
|
+
height: 1.5em;
|
69
|
+
}
|
70
|
+
button.datepick-cmd {
|
71
|
+
text-align: center;
|
72
|
+
}
|
73
|
+
.datepick-cmd-prev, .datepick-cmd-prevJump, .datepick-cmd-clear {
|
74
|
+
float: left;
|
75
|
+
padding-left: 2%;
|
76
|
+
}
|
77
|
+
.datepick-cmd-current, .datepick-cmd-today {
|
78
|
+
float: left;
|
79
|
+
width: 35%;
|
80
|
+
text-align: center;
|
81
|
+
}
|
82
|
+
.datepick-cmd-next, .datepick-cmd-nextJump, .datepick-cmd-close {
|
83
|
+
float: right;
|
84
|
+
padding-right: 2%;
|
85
|
+
text-align: right;
|
86
|
+
}
|
87
|
+
.datepick-rtl .datepick-cmd-prev, .datepick-rtl .datepick-cmd-prevJump,
|
88
|
+
.datepick-rtl .datepick-cmd-clear {
|
89
|
+
float: right;
|
90
|
+
padding-left: 0%;
|
91
|
+
padding-right: 2%;
|
92
|
+
text-align: right;
|
93
|
+
}
|
94
|
+
.datepick-rtl .datepick-cmd-current, .datepick-rtl .datepick-cmd-today {
|
95
|
+
float: right;
|
96
|
+
}
|
97
|
+
.datepick-rtl .datepick-cmd-next, .datepick-rtl .datepick-cmd-nextJump,
|
98
|
+
.datepick-rtl .datepick-cmd-close {
|
99
|
+
float: left;
|
100
|
+
padding-left: 2%;
|
101
|
+
padding-right: 0%;
|
102
|
+
text-align: left;
|
103
|
+
}
|
104
|
+
.datepick-month-nav {
|
105
|
+
float: left;
|
106
|
+
background-color: #777;
|
107
|
+
text-align: center;
|
108
|
+
}
|
109
|
+
.datepick-month-nav div {
|
110
|
+
float: left;
|
111
|
+
width: 12.5%;
|
112
|
+
margin: 1%;
|
113
|
+
padding: 1%;
|
114
|
+
}
|
115
|
+
.datepick-month-nav span {
|
116
|
+
color: #888;
|
117
|
+
}
|
118
|
+
.datepick-month-row {
|
119
|
+
clear: left;
|
120
|
+
}
|
121
|
+
.datepick-month {
|
122
|
+
float: left;
|
123
|
+
width: 15em;
|
124
|
+
border: 1px solid #444;
|
125
|
+
text-align: center;
|
126
|
+
}
|
127
|
+
.datepick-month-header, .datepick-month-header select, .datepick-month-header input {
|
128
|
+
height: 1.5em;
|
129
|
+
background-color: #444;
|
130
|
+
color: #fff;
|
131
|
+
font-weight: bold;
|
132
|
+
}
|
133
|
+
.datepick-month-header select, .datepick-month-header input {
|
134
|
+
height: 1.4em;
|
135
|
+
border: none;
|
136
|
+
}
|
137
|
+
.datepick-month-header input {
|
138
|
+
position: absolute;
|
139
|
+
display: none;
|
140
|
+
}
|
141
|
+
.datepick-month table {
|
142
|
+
width: 100%;
|
143
|
+
border-collapse: collapse;
|
144
|
+
}
|
145
|
+
.datepick-month thead {
|
146
|
+
border-bottom: 1px solid #aaa;
|
147
|
+
}
|
148
|
+
.datepick-month th, .datepick-month td {
|
149
|
+
margin: 0em;
|
150
|
+
padding: 0em;
|
151
|
+
font-weight: normal;
|
152
|
+
text-align: center;
|
153
|
+
}
|
154
|
+
.datepick-month th {
|
155
|
+
border: 1px solid #777;
|
156
|
+
}
|
157
|
+
.datepick-month th, .datepick-month th a {
|
158
|
+
background-color: #777;
|
159
|
+
color: #fff;
|
160
|
+
}
|
161
|
+
.datepick-month td {
|
162
|
+
background-color: #eee;
|
163
|
+
border: 1px solid #aaa;
|
164
|
+
}
|
165
|
+
.datepick-month td.datepick-week {
|
166
|
+
border: 1px solid #777;
|
167
|
+
}
|
168
|
+
.datepick-month td.datepick-week * {
|
169
|
+
background-color: #777;
|
170
|
+
color: #fff;
|
171
|
+
border: none;
|
172
|
+
}
|
173
|
+
.datepick-month a {
|
174
|
+
display: block;
|
175
|
+
width: 100%;
|
176
|
+
padding: 0.125em 0em;
|
177
|
+
background-color: #eee;
|
178
|
+
color: #000;
|
179
|
+
text-decoration: none;
|
180
|
+
}
|
181
|
+
.datepick-month span {
|
182
|
+
display: block;
|
183
|
+
width: 100%;
|
184
|
+
padding: 0.125em 0em;
|
185
|
+
}
|
186
|
+
.datepick-month td span {
|
187
|
+
color: #888;
|
188
|
+
}
|
189
|
+
.datepick-month td .datepick-other-month {
|
190
|
+
background-color: #fff;
|
191
|
+
}
|
192
|
+
.datepick-month td .datepick-weekend {
|
193
|
+
background-color: #ddd;
|
194
|
+
}
|
195
|
+
.datepick-month td .datepick-today {
|
196
|
+
background-color: #f0c0c0;
|
197
|
+
}
|
198
|
+
.datepick-month td .datepick-highlight {
|
199
|
+
background-color: #f08080;
|
200
|
+
}
|
201
|
+
.datepick-month td .datepick-selected {
|
202
|
+
background-color: #777;
|
203
|
+
color: #fff;
|
204
|
+
}
|
205
|
+
.datepick-month th.datepick-week {
|
206
|
+
background-color: #777;
|
207
|
+
color: #fff;
|
208
|
+
}
|
209
|
+
.datepick-status {
|
210
|
+
clear: both;
|
211
|
+
background-color: #ddd;
|
212
|
+
text-align: center;
|
213
|
+
}
|
214
|
+
.datepick-clear-fix {
|
215
|
+
clear: both;
|
216
|
+
}
|
217
|
+
.datepick-cover {
|
218
|
+
display: none;
|
219
|
+
display/**/: block;
|
220
|
+
position: absolute;
|
221
|
+
z-index: -1;
|
222
|
+
filter: mask();
|
223
|
+
top: -1px;
|
224
|
+
left: -1px;
|
225
|
+
width: 100px;
|
226
|
+
height: 100px;
|
227
|
+
}
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,266 @@
|
|
1
|
+
/* http://keith-wood.name/datepick.html
|
2
|
+
Datepicker extensions for jQuery v4.0.6.
|
3
|
+
Written by Keith Wood (kbwood{at}iinet.com.au) August 2009.
|
4
|
+
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
|
5
|
+
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
|
6
|
+
Please attribute the author if you use it. */
|
7
|
+
|
8
|
+
(function($) { // Hide scope, no $ conflict
|
9
|
+
|
10
|
+
var themeRollerRenderer = {
|
11
|
+
picker: '<div{popup:start} id="ui-datepicker-div"{popup:end} class="ui-datepicker ui-widget ' +
|
12
|
+
'ui-widget-content ui-helper-clearfix ui-corner-all{inline:start} ui-datepicker-inline{inline:end}">' +
|
13
|
+
'<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">' +
|
14
|
+
'{link:prev}{link:today}{link:next}</div>{months}' +
|
15
|
+
'{popup:start}<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ' +
|
16
|
+
'ui-corner-all">{button:clear}{button:close}</div>{popup:end}' +
|
17
|
+
'<div class="ui-helper-clearfix"></div></div>',
|
18
|
+
monthRow: '<div class="ui-datepicker-row-break">{months}</div>',
|
19
|
+
month: '<div class="ui-datepicker-group">' +
|
20
|
+
'<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">{monthHeader:MM yyyy}</div>' +
|
21
|
+
'<table class="ui-datepicker-calendar"><thead>{weekHeader}</thead><tbody>{weeks}</tbody></table></div>',
|
22
|
+
weekHeader: '<tr>{days}</tr>',
|
23
|
+
dayHeader: '<th>{day}</th>',
|
24
|
+
week: '<tr>{days}</tr>',
|
25
|
+
day: '<td>{day}</td>',
|
26
|
+
monthSelector: '.ui-datepicker-group',
|
27
|
+
daySelector: 'td',
|
28
|
+
rtlClass: 'ui-datepicker-rtl',
|
29
|
+
multiClass: 'ui-datepicker-multi',
|
30
|
+
defaultClass: 'ui-state-default',
|
31
|
+
selectedClass: 'ui-state-active',
|
32
|
+
highlightedClass: 'ui-state-hover',
|
33
|
+
todayClass: 'ui-state-highlight',
|
34
|
+
otherMonthClass: 'ui-datepicker-other-month',
|
35
|
+
weekendClass: 'ui-datepicker-week-end',
|
36
|
+
commandClass: 'ui-datepicker-cmd',
|
37
|
+
commandButtonClass: 'ui-state-default ui-corner-all',
|
38
|
+
commandLinkClass: '',
|
39
|
+
disabledClass: 'ui-datepicker-disabled'
|
40
|
+
};
|
41
|
+
|
42
|
+
$.extend($.datepick, {
|
43
|
+
|
44
|
+
// Template for generating a datepicker showing week of year.
|
45
|
+
weekOfYearRenderer: $.extend({}, $.datepick.defaultRenderer, {
|
46
|
+
weekHeader: '<tr><th class="datepick-week">' +
|
47
|
+
'<span title="{l10n:weekStatus}">{l10n:weekText}</span></th>{days}</tr>',
|
48
|
+
week: '<tr><td class="datepick-week">{weekOfYear}</td>{days}</tr>'
|
49
|
+
}),
|
50
|
+
|
51
|
+
// ThemeRoller template for generating a datepicker.
|
52
|
+
themeRollerRenderer: themeRollerRenderer,
|
53
|
+
|
54
|
+
// ThemeRoller template for generating a datepicker showing week of year.
|
55
|
+
themeRollerWeekOfYearRenderer: $.extend({}, themeRollerRenderer, {
|
56
|
+
weekHeader: '<tr><th class="ui-state-hover"><span>{l10n:weekText}</span></th>{days}</tr>',
|
57
|
+
week: '<tr><td class="ui-state-hover">{weekOfYear}</td>{days}</tr>'
|
58
|
+
}),
|
59
|
+
|
60
|
+
/* Don't allow weekends to be selected.
|
61
|
+
Usage: onDate: $.datepick.noWeekends.
|
62
|
+
@param date (Date) the current date
|
63
|
+
@return (object) information about this date */
|
64
|
+
noWeekends: function(date) {
|
65
|
+
return {selectable: (date.getDay() || 7) < 6};
|
66
|
+
},
|
67
|
+
|
68
|
+
/* Change the first day of the week by clicking on the day header.
|
69
|
+
Usage: onShow: $.datepick.changeFirstDay.
|
70
|
+
@param picker (jQuery) the completed datepicker division
|
71
|
+
@param inst (object) the current instance settings */
|
72
|
+
changeFirstDay: function(picker, inst) {
|
73
|
+
var target = $(this);
|
74
|
+
picker.find('th span').each(function() {
|
75
|
+
var parent = $(this).parent();
|
76
|
+
if (parent.is('.datepick-week') || parent.is('.ui-state-hover')) {
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
$('<a href="javascript:void(0)" class="' + this.className +
|
80
|
+
'" title="Change first day of the week">' + $(this).text() + '</a>').
|
81
|
+
click(function() {
|
82
|
+
var dow = parseInt(this.className.replace(/^.*datepick-dow-(\d+).*$/, '$1'), 10);
|
83
|
+
target.datepick('option', {firstDay: dow});
|
84
|
+
}).
|
85
|
+
replaceAll(this);
|
86
|
+
});
|
87
|
+
},
|
88
|
+
|
89
|
+
/* Add a callback when hovering over dates.
|
90
|
+
Usage: onShow: $.datepick.hoverCallback(handleHover).
|
91
|
+
@param onHover (function) the callback when hovering,
|
92
|
+
it receives the current date and a flag indicating selectability
|
93
|
+
as parameters on entry, and no parameters on exit,
|
94
|
+
this refers to the target input or division */
|
95
|
+
hoverCallback: function(onHover) {
|
96
|
+
return function(picker, inst) {
|
97
|
+
var target = this;
|
98
|
+
var renderer = inst.get('renderer');
|
99
|
+
picker.find(renderer.daySelector + ' a, ' + renderer.daySelector + ' span').
|
100
|
+
hover(function() {
|
101
|
+
onHover.apply(target, [$.datepick.retrieveDate(target, this),
|
102
|
+
this.nodeName.toLowerCase() == 'a']);
|
103
|
+
},
|
104
|
+
function() { onHover.apply(target, []); });
|
105
|
+
};
|
106
|
+
},
|
107
|
+
|
108
|
+
/* Highlight the entire week when hovering over it.
|
109
|
+
Usage: onShow: $.datepick.highlightWeek.
|
110
|
+
@param picker (jQuery) the completed datepicker division
|
111
|
+
@param inst (object) the current instance settings */
|
112
|
+
highlightWeek: function(picker, inst) {
|
113
|
+
var target = this;
|
114
|
+
var renderer = inst.get('renderer');
|
115
|
+
picker.find(renderer.daySelector + ' a, ' + renderer.daySelector + ' span').
|
116
|
+
hover(function() {
|
117
|
+
$(this).parents('tr').find(renderer.daySelector + ' *').
|
118
|
+
addClass(renderer.highlightedClass);
|
119
|
+
},
|
120
|
+
function() {
|
121
|
+
$(this).parents('tr').find(renderer.daySelector + ' *').
|
122
|
+
removeClass(renderer.highlightedClass);
|
123
|
+
});
|
124
|
+
},
|
125
|
+
|
126
|
+
/* Show a status bar with messages.
|
127
|
+
Usage: onShow: $.datepick.showStatus.
|
128
|
+
@param picker (jQuery) the completed datepicker division
|
129
|
+
@param inst (object) the current instance settings */
|
130
|
+
showStatus: function(picker, inst) {
|
131
|
+
var renderer = inst.get('renderer');
|
132
|
+
var isTR = (renderer.selectedClass == themeRollerRenderer.selectedClass);
|
133
|
+
var defaultStatus = inst.get('defaultStatus') || ' ';
|
134
|
+
var status = $('<div class="' + (!isTR ? 'datepick-status' :
|
135
|
+
'ui-datepicker-status ui-widget-header ui-helper-clearfix ui-corner-all') + '">' +
|
136
|
+
defaultStatus + '</div>').
|
137
|
+
insertAfter(picker.find('.datepick-month-row:last,.ui-datepicker-row-break:last'));
|
138
|
+
picker.find('*[title]').each(function() {
|
139
|
+
var title = $(this).attr('title');
|
140
|
+
$(this).removeAttr('title').hover(
|
141
|
+
function() { status.text(title || defaultStatus); },
|
142
|
+
function() { status.text(defaultStatus); });
|
143
|
+
});
|
144
|
+
},
|
145
|
+
|
146
|
+
/* Allow easier navigation by month/year.
|
147
|
+
Usage: onShow: $.datepick.monthNavigation.
|
148
|
+
@param picker (jQuery) the completed datepicker division
|
149
|
+
@param inst (object) the current instance settings */
|
150
|
+
monthNavigation: function(picker, inst) {
|
151
|
+
var target = $(this);
|
152
|
+
var renderer = inst.get('renderer');
|
153
|
+
var isTR = (renderer.selectedClass == themeRollerRenderer.selectedClass);
|
154
|
+
var minDate = inst.curMinDate();
|
155
|
+
var maxDate = inst.get('maxDate');
|
156
|
+
var monthNames = inst.get('monthNames');
|
157
|
+
var monthNamesShort = inst.get('monthNamesShort');
|
158
|
+
var month = inst.drawDate.getMonth();
|
159
|
+
var year = inst.drawDate.getFullYear();
|
160
|
+
var html = '<div class="' + (!isTR ? 'datepick-month-nav' : 'ui-datepicker-month-nav') + '"' +
|
161
|
+
' style="display: none;">';
|
162
|
+
for (var i = 0; i < monthNames.length; i++) {
|
163
|
+
var inRange = ((!minDate || new Date(year, i + 1, 0).getTime() >= minDate.getTime()) &&
|
164
|
+
(!maxDate || new Date(year, i, 1).getTime() <= maxDate.getTime()));
|
165
|
+
html += '<div>' +
|
166
|
+
(inRange ? '<a href="#" class="dp' + new Date(year, i, 1).getTime() + '"' : '<span') +
|
167
|
+
' title="' + monthNames[i] + '">' + monthNamesShort[i] +
|
168
|
+
(inRange ? '</a>' : '</span>') + '</div>';
|
169
|
+
}
|
170
|
+
for (var i = -6; i <= 6; i++) {
|
171
|
+
if (i == 0) {
|
172
|
+
continue;
|
173
|
+
}
|
174
|
+
var inRange =
|
175
|
+
((!minDate || new Date(year + i, 12 - 1, 31).getTime() >= minDate.getTime()) &&
|
176
|
+
(!maxDate || new Date(year + i, 1 - 1, 1).getTime() <= maxDate.getTime()));
|
177
|
+
html += '<div>' + (inRange ? '<a href="#" class="dp' +
|
178
|
+
new Date(year + i, month, 1).getTime() + '"' : '<span') +
|
179
|
+
' title="' + (year + i) + '">' + (year + i) +
|
180
|
+
(inRange ? '</a>' : '</span>') + '</div>';
|
181
|
+
}
|
182
|
+
html += '</div>';
|
183
|
+
html = $(html).insertAfter(picker.find('div.datepick-nav,div.ui-datepicker-header:first'));
|
184
|
+
html.find('a').click(function() {
|
185
|
+
var date = $.datepick.retrieveDate(target[0], this);
|
186
|
+
target.datepick('showMonth', date.getFullYear(), date.getMonth() + 1);
|
187
|
+
return false;
|
188
|
+
});
|
189
|
+
picker.find('div.datepick-month-header,div.ui-datepicker-month-header').click(function() {
|
190
|
+
html.slideToggle();
|
191
|
+
}).css('cursor', 'pointer');
|
192
|
+
},
|
193
|
+
|
194
|
+
/* Select an entire week when clicking on a week number.
|
195
|
+
Use in conjunction with weekOfYearRenderer or themeRollerWeekOfYearRenderer.
|
196
|
+
Usage: onShow: $.datepick.selectWeek.
|
197
|
+
@param picker (jQuery) the completed datepicker division
|
198
|
+
@param inst (object) the current instance settings */
|
199
|
+
selectWeek: function(picker, inst) {
|
200
|
+
var target = $(this);
|
201
|
+
picker.find('td.datepick-week span,td.ui-state-hover span').each(function() {
|
202
|
+
$('<a href="javascript:void(0)" class="' +
|
203
|
+
this.className + '" title="Select the entire week">' +
|
204
|
+
$(this).text() + '</a>').
|
205
|
+
click(function() {
|
206
|
+
var date = target.datepick('retrieveDate', this);
|
207
|
+
var dates = [date];
|
208
|
+
for (var i = 1; i < 7; i++) {
|
209
|
+
dates.push(date = $.datepick.add($.datepick.newDate(date), 1, 'd'));
|
210
|
+
}
|
211
|
+
if (inst.get('rangeSelect')) {
|
212
|
+
dates.splice(1, dates.length - 2);
|
213
|
+
}
|
214
|
+
target.datepick('setDate', dates).datepick('hide');
|
215
|
+
}).
|
216
|
+
replaceAll(this);
|
217
|
+
});
|
218
|
+
},
|
219
|
+
|
220
|
+
/* Select an entire month when clicking on the week header.
|
221
|
+
Use in conjunction with weekOfYearRenderer or themeRollerWeekOfYearRenderer.
|
222
|
+
Usage: onShow: $.datepick.selectMonth.
|
223
|
+
@param picker (jQuery) the completed datepicker division
|
224
|
+
@param inst (object) the current instance settings */
|
225
|
+
selectMonth: function(picker, inst) {
|
226
|
+
var target = $(this);
|
227
|
+
picker.find('th.datepick-week span,th.ui-state-hover span').each(function() {
|
228
|
+
$('<a href="javascript:void(0)" title="Select the entire month">' +
|
229
|
+
$(this).text() + '</a>').
|
230
|
+
click(function() {
|
231
|
+
var date = target.datepick('retrieveDate', $(this).parents('table').
|
232
|
+
find('td:not(.datepick-week):not(.ui-state-hover) ' +
|
233
|
+
'*:not(.datepick-other-month):not(.ui-datepicker-other-month)')[0]);
|
234
|
+
var dates = [date];
|
235
|
+
var dim = $.datepick.daysInMonth(date);
|
236
|
+
for (var i = 1; i < dim; i++) {
|
237
|
+
dates.push(date = $.datepick.add($.datepick.newDate(date), 1, 'd'));
|
238
|
+
}
|
239
|
+
if (inst.get('rangeSelect')) {
|
240
|
+
dates.splice(1, dates.length - 2);
|
241
|
+
}
|
242
|
+
target.datepick('setDate', dates).datepick('hide');
|
243
|
+
}).
|
244
|
+
replaceAll(this);
|
245
|
+
});
|
246
|
+
},
|
247
|
+
|
248
|
+
/* Select a month only instead of a single day.
|
249
|
+
Usage: onShow: $.datepick.monthOnly.
|
250
|
+
@param picker (jQuery) the completed datepicker division
|
251
|
+
@param inst (object) the current instance settings */
|
252
|
+
monthOnly: function(picker, inst) {
|
253
|
+
var target = $(this);
|
254
|
+
var selectMonth = $('<div style="text-align: center;"><button type="button">Select</button></div>').
|
255
|
+
insertAfter(picker.find('.datepick-month-row:last,.ui-datepicker-row-break:last')).
|
256
|
+
children().click(function() {
|
257
|
+
var monthYear = picker.find('.datepick-month-year:first').val().split('/');
|
258
|
+
target.datepick('setDate', $.datepick.newDate(
|
259
|
+
parseInt(monthYear[1], 10), parseInt(monthYear[0], 10), 1)).
|
260
|
+
datepick('hide');
|
261
|
+
});
|
262
|
+
picker.find('.datepick-month-row table,.ui-datepicker-row-break table').remove();
|
263
|
+
}
|
264
|
+
});
|
265
|
+
|
266
|
+
})(jQuery);
|