rsence 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL.rdoc +5 -3
- data/README.rdoc +23 -22
- data/VERSION +1 -1
- data/conf/default_conf.yaml +65 -29
- data/conf/rsence_command_strings.yaml +101 -71
- data/js/comm/autosync/autosync.js +3 -3
- data/js/comm/jsloader/jsloader.js +16 -3
- data/js/comm/queue/queue.js +1 -1
- data/js/comm/transporter/transporter.js +106 -83
- data/js/comm/values/values.js +8 -2
- data/js/controls/button/button.js +9 -4
- data/js/controls/button/themes/default/button.css +1 -1
- data/js/controls/checkbox/themes/default/checkbox.css +1 -1
- data/js/controls/dialogs/sheet/sheet.js +27 -18
- data/js/controls/radiobutton/themes/default/radiobutton.css +1 -1
- data/js/controls/searchfield/searchfield.coffee +2 -0
- data/js/controls/searchfield/themes/default/searchfield.css +96 -0
- data/js/controls/searchfield/themes/default/searchfield.html +12 -0
- data/js/controls/searchfield/themes/default/searchfield_parts1-ie6.gif +0 -0
- data/js/controls/searchfield/themes/default/searchfield_parts1.png +0 -0
- data/js/controls/sliders/slider/slider.js +7 -1
- data/js/controls/stepper/stepper.js +6 -1
- data/js/controls/stringview/stringview.js +50 -39
- data/js/controls/tab/tab.js +103 -7
- data/js/controls/tab/themes/default/tab.css +2 -0
- data/js/controls/textarea/themes/default/textarea.css +4 -0
- data/js/controls/textcontrol/textcontrol.js +32 -2
- data/js/controls/textcontrol/themes/default/textcontrol.css +17 -2
- data/js/controls/uploader/themes/default/uploader.css +3 -3
- data/js/controls/uploader/themes/default/uploader.html +1 -1
- data/js/controls/uploader/uploader.coffee +110 -0
- data/js/controls/window/themes/default/window.css +28 -5
- data/js/controls/window/themes/default/window.html +2 -0
- data/js/controls/window/window.js +5 -1
- data/js/core/class/class.js +22 -4
- data/js/core/elem/elem.coffee +816 -0
- data/js/core/event/event.js +2 -2
- data/js/core/rsence_ns/rsence_ns.coffee +31 -0
- data/js/core/rsence_ns/rsence_ns.js +6 -6
- data/js/datetime/calendar/calendar.coffee +307 -0
- data/js/datetime/calendar/themes/default/calendar.css +90 -9
- data/js/datetime/calendar/themes/default/calendar.html +11 -0
- data/js/datetime/calendar/themes/default/calendar_bg-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts1-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts2-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
- data/js/datetime/datetimepicker/datetimepicker.js +217 -0
- data/js/datetime/datetimevalue/datetimevalue.js +22 -5
- data/js/datetime/timesheet/themes/default/timesheet.css +51 -22
- data/js/datetime/timesheet/themes/default/timesheet.html +4 -2
- data/js/datetime/timesheet/timesheet.js +782 -192
- data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -11
- data/js/datetime/timesheet_item/themes/default/timesheet_item.html +4 -2
- data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
- data/js/datetime/timesheet_item/timesheet_item.js +158 -254
- data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +0 -274
- data/js/foundation/application/application.js +52 -9
- data/js/foundation/control/eventresponder/eventresponder.js +7 -4
- data/js/foundation/control/valueaction/valueaction.js +71 -0
- data/js/foundation/eventmanager/eventmanager.js +71 -33
- data/js/foundation/geom/rect/rect.js +39 -7
- data/js/foundation/json_renderer/json_renderer.js +278 -62
- data/js/foundation/locale_settings/locale_settings.js +131 -0
- data/js/foundation/system/system.js +40 -13
- data/js/foundation/thememanager/thememanager.js +21 -0
- data/js/foundation/view/markupview/markupview.js +12 -12
- data/js/foundation/view/view.js +221 -27
- data/js/graphics/svgcontrol/svgcontrol.js +400 -0
- data/js/lists/checkboxlist/checkboxlist.js +18 -7
- data/js/lists/listitems/listitems.js +52 -38
- data/js/lists/radiobuttonlist/radiobuttonlist.js +23 -7
- data/js/menus/menuitem/menuitem.js +5 -0
- data/js/menus/menuitem/themes/default/menuitem.css +45 -0
- data/js/menus/menuitem/themes/default/menuitem.html +4 -0
- data/js/menus/minimenu/minimenu.js +47 -16
- data/js/menus/minimenuitem/minimenuitem.js +62 -0
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.css +2 -2
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.html +0 -0
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem_checkmark.png +0 -0
- data/js/menus/popupmenu/popupmenu.js +14 -0
- data/js/menus/popupmenu/themes/default/popupmenu.css +65 -0
- data/js/menus/popupmenu/themes/default/popupmenu.html +7 -0
- data/js/menus/popupmenu/themes/default/popupmenu.png +0 -0
- data/js/no_pkg/no_pkg.js +2 -0
- data/js/util/reloadapp/reloadapp.js +1 -1
- data/js/views/scrollview/scrollview.js +6 -0
- data/lib/rsence.rb +136 -3
- data/lib/rsence/argv.rb +218 -0
- data/lib/rsence/argv/argv_util.rb +58 -0
- data/lib/rsence/argv/env_check.rb +58 -0
- data/lib/rsence/argv/help_argv.rb +15 -0
- data/lib/rsence/argv/initenv_argv.rb +218 -0
- data/lib/rsence/argv/save_argv.rb +92 -0
- data/lib/rsence/argv/startup_argv.rb +118 -0
- data/lib/rsence/argv/status_argv.rb +132 -0
- data/lib/rsence/argv/test_port.rb +32 -0
- data/lib/{daemon → rsence}/daemon.rb +67 -23
- data/lib/{conf/default.rb → rsence/default_config.rb} +18 -10
- data/lib/{plugins → rsence}/dependencies.rb +0 -0
- data/lib/{util → rsence}/gzstring.rb +0 -0
- data/lib/rsence/http.rb +3 -0
- data/lib/{http → rsence/http}/broker.rb +106 -19
- data/lib/{http → rsence/http}/rackup.rb +0 -0
- data/lib/{http → rsence/http}/request.rb +0 -4
- data/lib/{http → rsence/http}/response.rb +0 -1
- data/lib/{session → rsence}/msg.rb +17 -1
- data/lib/{plugins → rsence}/pluginmanager.rb +29 -12
- data/lib/{plugins → rsence}/plugins.rb +7 -7
- data/lib/{plugins → rsence/plugins}/gui_plugin.rb +8 -3
- data/lib/{plugins → rsence/plugins}/guiparser.rb +9 -6
- data/lib/{plugins → rsence/plugins}/plugin.rb +23 -4
- data/lib/{plugins → rsence/plugins}/plugin_base.rb +11 -1
- data/lib/{plugins → rsence/plugins}/plugin_plugins.rb +2 -2
- data/lib/{plugins → rsence/plugins}/plugin_sqlite_db.rb +0 -0
- data/lib/{plugins → rsence/plugins}/servlet.rb +0 -0
- data/lib/{session → rsence}/sessionmanager.rb +101 -39
- data/lib/{session → rsence}/sessionstorage.rb +30 -16
- data/lib/{daemon → rsence}/sigcomm.rb +0 -0
- data/lib/{transporter → rsence}/transporter.rb +13 -11
- data/lib/{values/hvalue.rb → rsence/value.rb} +6 -1
- data/lib/{values → rsence}/valuemanager.rb +1 -1
- data/plugins/client_pkg/client_pkg.rb +14 -4
- data/plugins/client_pkg/info.yaml +2 -2
- data/plugins/client_pkg/lib/client_pkg_build.rb +145 -45
- data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
- data/plugins/client_pkg/lib/client_pkg_serve.rb +1 -1
- data/plugins/main/main.rb +43 -3
- data/plugins/main/tmpl/index.html +2 -10
- data/plugins/main/values.yaml +3 -1
- data/plugins/ticket/lib/common.rb +6 -3
- data/plugins/ticket/ticket.rb +11 -3
- metadata +144 -174
- data/js/comm/autosync/js.inc +0 -0
- data/js/comm/js.inc +0 -0
- data/js/comm/jsloader/js.inc +0 -0
- data/js/comm/queue/js.inc +0 -0
- data/js/comm/session/js.inc +0 -0
- data/js/comm/sessionwatcher/js.inc +0 -0
- data/js/comm/transporter/js.inc +0 -0
- data/js/comm/urlresponder/js.inc +0 -0
- data/js/comm/values/js.inc +0 -0
- data/js/controls/button/js.inc +0 -0
- data/js/controls/checkbox/js.inc +0 -0
- data/js/controls/dialogs/alert_sheet/js.inc +0 -0
- data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/js.inc +0 -0
- data/js/controls/imageview/js.inc +0 -0
- data/js/controls/passwordcontrol/js.inc +0 -0
- data/js/controls/progress/progressbar/js.inc +0 -0
- data/js/controls/progress/progressindicator/js.inc +0 -0
- data/js/controls/radiobutton/js.inc +0 -0
- data/js/controls/sliders/slider/js.inc +0 -0
- data/js/controls/sliders/vslider/js.inc +0 -0
- data/js/controls/stepper/js.inc +0 -0
- data/js/controls/stringview/js.inc +0 -0
- data/js/controls/tab/js.inc +0 -0
- data/js/controls/textarea/js.inc +0 -0
- data/js/controls/textcontrol/js.inc +0 -0
- data/js/controls/uploader/js.inc +0 -0
- data/js/controls/uploader/uploader.js +0 -154
- data/js/controls/validatorview/js.inc +0 -0
- data/js/controls/window/js.inc +0 -0
- data/js/core/class/js.inc +0 -0
- data/js/core/elem/elem.js +0 -1325
- data/js/core/elem/js.inc +0 -0
- data/js/core/event/js.inc +0 -0
- data/js/core/iefix/js.inc +0 -0
- data/js/core/rsence_ns/js.inc +0 -0
- data/js/datetime/calendar/calendar.js +0 -198
- data/js/datetime/calendar/js.inc +0 -0
- data/js/datetime/datetimevalue/js.inc +0 -0
- data/js/datetime/timesheet/js.inc +0 -0
- data/js/datetime/timesheet/old_timesheet.js +0 -292
- data/js/datetime/timesheet/themes/default/old_timesheet.css +0 -30
- data/js/datetime/timesheet/themes/default/old_timesheet.html +0 -2
- data/js/datetime/timesheet_item/js.inc +0 -0
- data/js/datetime/timesheet_item/old_timesheet_item.js +0 -308
- data/js/datetime/timesheet_item/themes/default/old_timesheet_item.css +0 -42
- data/js/datetime/timesheet_item/themes/default/old_timesheet_item.html +0 -8
- data/js/datetime/timesheet_item_edit/js.inc +0 -0
- data/js/datetime/timesheet_item_edit/old_timesheet_item_edit.js +0 -274
- data/js/foundation/application/js.inc +0 -0
- data/js/foundation/control/controldefaults/js.inc +0 -0
- data/js/foundation/control/dummyvalue/js.inc +0 -0
- data/js/foundation/control/dyncontrol/js.inc +0 -0
- data/js/foundation/control/eventresponder/js.inc +0 -0
- data/js/foundation/control/js.inc +0 -0
- data/js/foundation/control/valuematrix/js.inc +0 -0
- data/js/foundation/control/valueresponder/js.inc +0 -0
- data/js/foundation/eventmanager/js.inc +0 -0
- data/js/foundation/geom/point/js.inc +0 -0
- data/js/foundation/geom/rect/js.inc +0 -0
- data/js/foundation/json_renderer/js.inc +0 -0
- data/js/foundation/system/js.inc +0 -0
- data/js/foundation/thememanager/js.inc +0 -0
- data/js/foundation/value/js.inc +0 -0
- data/js/foundation/view/js.inc +0 -0
- data/js/foundation/view/markupview/js.inc +0 -0
- data/js/foundation/view/morphanimation/js.inc +0 -0
- data/js/foundation/view/viewdefaults/js.inc +0 -0
- data/js/lists/checkboxlist/js.inc +0 -0
- data/js/lists/listitems/js.inc +0 -0
- data/js/lists/propertylist/js.inc +0 -0
- data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/menus/minimenu/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/minimenuitem.js +0 -33
- data/js/util/reloadapp/js.inc +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/views/centerview/js.inc +0 -0
- data/js/views/inlineview/js.inc +0 -0
- data/js/views/scrollview/js.inc +0 -0
- data/lib/conf/argv.rb +0 -880
data/js/core/elem/js.inc
DELETED
File without changes
|
data/js/core/event/js.inc
DELETED
File without changes
|
data/js/core/iefix/js.inc
DELETED
File without changes
|
data/js/core/rsence_ns/js.inc
DELETED
File without changes
|
@@ -1,198 +0,0 @@
|
|
1
|
-
/* RSence
|
2
|
-
* Copyright 2009 Riassence Inc.
|
3
|
-
* http://riassence.com/
|
4
|
-
*
|
5
|
-
* You should have received a copy of the GNU General Public License along
|
6
|
-
* with this software package. If not, contact licensing@riassence.com
|
7
|
-
*/
|
8
|
-
|
9
|
-
/*** = Description
|
10
|
-
** Use HCalendar to display a month calendar that displays days as columns
|
11
|
-
** and weeks as rows. Its value is a date/time number specified in seconds
|
12
|
-
** since or before epoch (1970-01-01 00:00:00 UTC).
|
13
|
-
***/
|
14
|
-
var//RSence.DateTime
|
15
|
-
HCalendar = HControl.extend({
|
16
|
-
componentName: 'calendar',
|
17
|
-
weekdays_localized: ['Wk','Mon','Tue','Wed','Thu','Fri','Sat','Sun'],
|
18
|
-
defaultEvents: {
|
19
|
-
mouseWheel: true
|
20
|
-
},
|
21
|
-
/** = Description
|
22
|
-
* Calls HCalendar#nextMonth or HCalendar#prevMonth based on delta
|
23
|
-
* of mouseWheel.
|
24
|
-
*
|
25
|
-
**/
|
26
|
-
mouseWheel: function(_delta){
|
27
|
-
if ( _delta < 0 ) {
|
28
|
-
this.nextMonth();
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
this.prevMonth();
|
32
|
-
}
|
33
|
-
},
|
34
|
-
|
35
|
-
/** = Description
|
36
|
-
* Refreshes weekdays.
|
37
|
-
*
|
38
|
-
**/
|
39
|
-
refreshLabel: function(){
|
40
|
-
if(!this['markupElemIds']){
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
var _weekdays_localized = this.weekdays_localized,
|
44
|
-
_weekdays_width = Math.floor(this.rect.width/_weekdays_localized.length),
|
45
|
-
_weekdays_html = [],
|
46
|
-
i = 0,
|
47
|
-
_weekdays_html_pre = ['<div style="width:'+_weekdays_width+'px;left:','px">'],
|
48
|
-
_weekdays_html_suf = '</div>';
|
49
|
-
for(;i<_weekdays_localized.length;i++){
|
50
|
-
_weekdays_html.push([
|
51
|
-
_weekdays_html_pre.join(i*_weekdays_width),
|
52
|
-
_weekdays_localized[i],
|
53
|
-
_weekdays_html_suf
|
54
|
-
].join('') );
|
55
|
-
}
|
56
|
-
ELEM.setHTML(this.markupElemIds.label, _weekdays_html.join(''));
|
57
|
-
},
|
58
|
-
|
59
|
-
/** = Description
|
60
|
-
* Checks the date range for the month which the date given as input belongs.
|
61
|
-
*
|
62
|
-
* = Parameters
|
63
|
-
* +_date+:: A Date instance to check date range from
|
64
|
-
*
|
65
|
-
* = Returns
|
66
|
-
* Array of [0] first week's date and [1] last week's date.
|
67
|
-
*
|
68
|
-
**/
|
69
|
-
calendarDateRange: function(_date){
|
70
|
-
var _date_begin = this.firstDateOfMonth(_date),
|
71
|
-
_date_end = this.lastDateOfMonth(_date),
|
72
|
-
_firstWeeksDate = this.firstDateOfWeek(_date_begin),
|
73
|
-
_lastWeeksDate = this.lastDateOfWeek(_date_end),
|
74
|
-
_week_begin = this.week(_firstWeeksDate),
|
75
|
-
_week_end = this.week(_lastWeeksDate),
|
76
|
-
_weeks = _week_end-_week_begin;
|
77
|
-
if((_weeks===5) && (_firstWeeksDate.getDate() !== 1)){
|
78
|
-
_lastWeeksDate = new Date( _lastWeeksDate.getTime() + this.msWeek );
|
79
|
-
}
|
80
|
-
else if((_weeks===5) && (_firstWeeksDate.getDate() === 1)){
|
81
|
-
_firstWeeksDate = new Date( _firstWeeksDate.getTime() - this.msWeek );
|
82
|
-
}
|
83
|
-
else if(_weeks===4){
|
84
|
-
_firstWeeksDate = new Date( _firstWeeksDate.getTime() - this.msWeek );
|
85
|
-
_lastWeeksDate = new Date( _lastWeeksDate.getTime() + this.msWeek );
|
86
|
-
}
|
87
|
-
return [
|
88
|
-
_firstWeeksDate,
|
89
|
-
_lastWeeksDate
|
90
|
-
];
|
91
|
-
},
|
92
|
-
|
93
|
-
/** = Description
|
94
|
-
* Refreshes the calendar.
|
95
|
-
*
|
96
|
-
**/
|
97
|
-
refreshValue: function(){
|
98
|
-
var _date = this.date();
|
99
|
-
this.drawCalendar(_date);
|
100
|
-
},
|
101
|
-
|
102
|
-
/** = Description
|
103
|
-
* Draws the next month on calendar.
|
104
|
-
*
|
105
|
-
**/
|
106
|
-
nextMonth: function(){
|
107
|
-
var _date = new Date( this.viewMonth[0], this.viewMonth[1]+1, 1 );
|
108
|
-
this.drawCalendar( new Date(_date.getTime() - this.tzMs(_date)) );
|
109
|
-
},
|
110
|
-
|
111
|
-
/** = Description
|
112
|
-
* Draws the previous month on calendar.
|
113
|
-
*
|
114
|
-
**/
|
115
|
-
prevMonth: function(){
|
116
|
-
var _date = new Date( this.viewMonth[0], this.viewMonth[1]-1, 1 );
|
117
|
-
this.drawCalendar( new Date(_date.getTime() - this.tzMs(_date)) );
|
118
|
-
},
|
119
|
-
viewMonth: [1970,0],
|
120
|
-
|
121
|
-
/** = Description
|
122
|
-
* Draws the calendar with the date open given as input.
|
123
|
-
*
|
124
|
-
* = Parameters
|
125
|
-
* +_date+:: The date on which calendar UI is opened at.
|
126
|
-
*
|
127
|
-
**/
|
128
|
-
drawCalendar: function(_date){
|
129
|
-
_date = (_date instanceof Date)?_date:this.date();
|
130
|
-
var _calendarDateRange = this.calendarDateRange(_date),
|
131
|
-
_monthFirst = this.firstDateOfMonth(_date),
|
132
|
-
_monthLast = this.lastDateOfMonth(_date),
|
133
|
-
_firstDate = _calendarDateRange[0],
|
134
|
-
_lastDate = _calendarDateRange[1],
|
135
|
-
_column_count = this.weekdays_localized.length,
|
136
|
-
_column_width = Math.floor((this.rect.width-1)/_column_count),
|
137
|
-
_row_height = Math.floor((this.rect.height-1-35)/6),
|
138
|
-
_week_html_pre = ['<div class="calendar_weeks_week_row" style="width:'+(this.rect.width-3)+'px;height:'+_row_height+'px;top:','px">'],
|
139
|
-
_week_html_suf = '</div>',
|
140
|
-
_col_html_pre = ['<a href="javascript:void(HSystem.views['+this.viewId+'].setValue(','));" class="calendar_weeks_week_col','" style="width:'+_column_width+'px;height:'+_row_height+'px;line-height:'+_row_height+'px;left:','px">'],
|
141
|
-
_col_html_suf = '</a>',
|
142
|
-
_col_week_pre = '<div class="calendar_weeks_week_col_wk" style="width:'+_column_width+'px;height:'+_row_height+'px;line-height:'+_row_height+'px;left:0px">',
|
143
|
-
_col_week_suf = '</div>',
|
144
|
-
_month_html = [],
|
145
|
-
_week_html,
|
146
|
-
_col_html,
|
147
|
-
_row = 0,
|
148
|
-
_col,
|
149
|
-
_colMs,
|
150
|
-
_colSecs,
|
151
|
-
_colDate,
|
152
|
-
_extraCssClass;
|
153
|
-
for(; _row<6; _row++){
|
154
|
-
_week_html = [];
|
155
|
-
for(_col = 0; _col<8; _col++){
|
156
|
-
_colDate = new Date(_firstDate.getTime()+((_row*this.msWeek)+((_col-1)*this.msDay)));
|
157
|
-
_colMs = _colDate.getTime();
|
158
|
-
if(_col===0){
|
159
|
-
_col_html = [
|
160
|
-
_col_week_pre,
|
161
|
-
this.week(_colDate),
|
162
|
-
_col_week_suf
|
163
|
-
].join('');
|
164
|
-
}
|
165
|
-
else {
|
166
|
-
_colSecs = Math.round(_colMs/1000);
|
167
|
-
if((this.value >= _colSecs) && (this.value < (_colSecs+86400))){
|
168
|
-
_extraCssClass = '_'+'sel';
|
169
|
-
}
|
170
|
-
else{
|
171
|
-
_extraCssClass = (_colDate<_monthFirst || _colDate > _monthLast)?'_'+'no':'_'+'yes';
|
172
|
-
}
|
173
|
-
_col_html = [
|
174
|
-
_col_html_pre[0],
|
175
|
-
_colSecs,
|
176
|
-
_col_html_pre[1],
|
177
|
-
_extraCssClass,
|
178
|
-
_col_html_pre[2],
|
179
|
-
(_col*_column_width),
|
180
|
-
_col_html_pre[3],
|
181
|
-
this.mday(_colDate),
|
182
|
-
_col_html_suf
|
183
|
-
].join('');
|
184
|
-
}
|
185
|
-
_week_html.push(_col_html);
|
186
|
-
}
|
187
|
-
_month_html.push([
|
188
|
-
_week_html_pre.join(_row*_row_height),
|
189
|
-
_week_html.join(''),
|
190
|
-
_week_html_suf
|
191
|
-
].join('') );
|
192
|
-
}
|
193
|
-
ELEM.setHTML(this.markupElemIds.value, _month_html.join(''));
|
194
|
-
ELEM.setHTML(this.markupElemIds.state, this.monthName(_date)+' '+this.year(_date));
|
195
|
-
this.viewMonth = [_monthFirst.getUTCFullYear(),_monthFirst.getUTCMonth()];
|
196
|
-
}
|
197
|
-
});
|
198
|
-
HCalendar.implement(HDateTime);
|
data/js/datetime/calendar/js.inc
DELETED
File without changes
|
File without changes
|
File without changes
|
@@ -1,292 +0,0 @@
|
|
1
|
-
/* RSence
|
2
|
-
* Copyright 2009 Riassence Inc.
|
3
|
-
* http://riassence.com/
|
4
|
-
*
|
5
|
-
* You should have received a copy of the GNU General Public License along
|
6
|
-
* with this software package. If not, contact licensing@riassence.com
|
7
|
-
*/
|
8
|
-
|
9
|
-
/*** = Description
|
10
|
-
** HTimesheet is a simple timesheet control.
|
11
|
-
***/
|
12
|
-
var//RSence.DateTime
|
13
|
-
HTimeSheet = HControl.extend({
|
14
|
-
|
15
|
-
componentName: 'timesheet',
|
16
|
-
|
17
|
-
/* Default amount of pixels per hour. Override with options when necessary. */
|
18
|
-
pxPerHour: 24,
|
19
|
-
|
20
|
-
/* Default amount of pixels from left. Override with options when necessary. */
|
21
|
-
itemOffsetLeft: 36,
|
22
|
-
|
23
|
-
/* Default amount of pixels from right. Override with options when necessary. */
|
24
|
-
itemOffsetRight: 0,
|
25
|
-
|
26
|
-
defaultEvents: {
|
27
|
-
draggable: true
|
28
|
-
},
|
29
|
-
|
30
|
-
controlDefaults: HControlDefaults.extend({
|
31
|
-
pxPerHour: null,
|
32
|
-
itemOffsetLeft: null,
|
33
|
-
itemOffsetRight: null,
|
34
|
-
itemMinHeight: 24,
|
35
|
-
newItemLabel: 'New Item',
|
36
|
-
constructor: function(_ctrl){
|
37
|
-
if(this.pxPerHour !== null){
|
38
|
-
_ctrl.pxPerHour = this.pxPerHour;
|
39
|
-
}
|
40
|
-
if(this.itemOffsetLeft !== null){
|
41
|
-
_ctrl.itemOffsetLeft = this.itemOffsetLeft;
|
42
|
-
}
|
43
|
-
if(this.itemOffsetRight !== null){
|
44
|
-
_ctrl.itemOffsetRight = this.itemOffsetRight;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}),
|
48
|
-
|
49
|
-
/** = Description
|
50
|
-
* Redraws the timesheet.
|
51
|
-
*
|
52
|
-
**/
|
53
|
-
refresh: function(){
|
54
|
-
if(this.drawn){
|
55
|
-
var _areaHeight = this.rect.height;
|
56
|
-
this.pxPerHour = (_areaHeight-(_areaHeight%48)) / 24;
|
57
|
-
if(this.options['hideLabel']){
|
58
|
-
this.setStyleOfPart( 'label', 'display', 'none' );
|
59
|
-
this.setStyleOfPart( 'state', 'left', '0px' );
|
60
|
-
this.itemOffsetLeft = 0;
|
61
|
-
}
|
62
|
-
else{
|
63
|
-
this.setStyleOfPart( 'label', 'height', (this.pxPerHour*24)+'px' );
|
64
|
-
}
|
65
|
-
this.setStyleOfPart( 'state', 'height', (this.pxPerHour*24)+'px' );
|
66
|
-
}
|
67
|
-
this.base();
|
68
|
-
},
|
69
|
-
|
70
|
-
/** = Description
|
71
|
-
* Refreshes the hour labels.
|
72
|
-
*
|
73
|
-
**/
|
74
|
-
refreshLabel: function(){
|
75
|
-
var hour = 1,
|
76
|
-
hours = [],
|
77
|
-
rowHeight = this.pxPerHour;
|
78
|
-
lineHeight = Math.round(this.pxPerHour/2);
|
79
|
-
for(; hour < 24; hour++){
|
80
|
-
hours.push('<div style="line-height:'+rowHeight+'px;height:'+rowHeight+'px;top:'+Math.round((hour*rowHeight)-lineHeight)+'px" class="timesheet_hours_row">'+hour+':00</div>');
|
81
|
-
}
|
82
|
-
this.markupElemIds && this.markupElemIds.label && ELEM.setHTML(this.markupElemIds.label,hours.join(''));
|
83
|
-
this.refreshState();
|
84
|
-
},
|
85
|
-
|
86
|
-
/** = Description
|
87
|
-
* Refreshes the lines which mark hours and half-hours.
|
88
|
-
*
|
89
|
-
**/
|
90
|
-
refreshState: function(){
|
91
|
-
var line = 0,
|
92
|
-
lines = [],
|
93
|
-
lineHeight = Math.round(this.pxPerHour/2);
|
94
|
-
for(; line < 48; line++){
|
95
|
-
lines.push('<div style="top:'+(line*lineHeight)+'px" class="timesheet_lines_row'+(line%2)+'"></div>');
|
96
|
-
}
|
97
|
-
this.markupElemIds && this.markupElemIds.label && ELEM.setHTML(this.markupElemIds.state,lines.join(''));
|
98
|
-
},
|
99
|
-
dragItem: false,
|
100
|
-
|
101
|
-
/** = Description
|
102
|
-
* Creates an item into timesheet with default label 'New Item'.
|
103
|
-
*
|
104
|
-
* = Parameters
|
105
|
-
* +origY+:: Y coordinate of the new item.
|
106
|
-
*
|
107
|
-
**/
|
108
|
-
createItem: function(origY){
|
109
|
-
var _lineHeight = Math.round(this.pxPerHour/2);
|
110
|
-
origY = Math.floor( origY / _lineHeight )*_lineHeight;
|
111
|
-
var maxY = _lineHeight*48,
|
112
|
-
lineHeight = Math.round(this.pxPerHour/2);
|
113
|
-
if(origY>maxY){
|
114
|
-
origY = maxY;
|
115
|
-
}
|
116
|
-
this.dragItem = this.createTimeSheetItem( { label: this.options.newItemLabel }, origY, lineHeight, 'create' );
|
117
|
-
},
|
118
|
-
|
119
|
-
/** = Description
|
120
|
-
* Dragging is used to mark items on the timesheet.
|
121
|
-
*
|
122
|
-
* = Parameters
|
123
|
-
* +x+:: x coordinate of the origin of drag
|
124
|
-
* +y+:: y coordinate of the origin of drag
|
125
|
-
*
|
126
|
-
**/
|
127
|
-
startDrag: function(x,y){
|
128
|
-
this._startDragTime = new Date().getTime();
|
129
|
-
this._startDragCoords = [x,y];
|
130
|
-
return true;
|
131
|
-
},
|
132
|
-
|
133
|
-
drag: function(x,y){
|
134
|
-
if(((new Date().getTime()) - this._startDragTime) < 200){
|
135
|
-
// only create when 200 ms has elapsed to enable clicking
|
136
|
-
return true;
|
137
|
-
}
|
138
|
-
if(this._startDragCoords[0]!==x && this._startDragCoords[1]!==y){
|
139
|
-
this.createItem(this._startDragCoords[1]-this.pageY());
|
140
|
-
EVENT.startDragging( this.dragItem );
|
141
|
-
return true;
|
142
|
-
}
|
143
|
-
},
|
144
|
-
|
145
|
-
click: function(x,y){
|
146
|
-
// deactivate all items
|
147
|
-
EVENT.changeActiveControl(this);
|
148
|
-
return true;
|
149
|
-
},
|
150
|
-
|
151
|
-
listItemViews: false,
|
152
|
-
|
153
|
-
/** = Description
|
154
|
-
* Sets the editor given as parameter as the editor of instance.
|
155
|
-
*
|
156
|
-
* = Parameters
|
157
|
-
* +_editor+::
|
158
|
-
*
|
159
|
-
**/
|
160
|
-
setEditor: function( _editor ){
|
161
|
-
this.editor = _editor;
|
162
|
-
},
|
163
|
-
|
164
|
-
/** = Description
|
165
|
-
* Returns HRect the size of given parameters and suitable for timesheet.
|
166
|
-
*
|
167
|
-
* = Parameters
|
168
|
-
* +_origY+:: Y coordinate.
|
169
|
-
* +_lineHeight+:: The height of item on time sheet.
|
170
|
-
*
|
171
|
-
**/
|
172
|
-
createItemRect: function(_origY, _lineHeight){
|
173
|
-
var _left = this.itemOffsetLeft+1,
|
174
|
-
_top = _origY+1,
|
175
|
-
_right = this.rect.width - this.itemOffsetRight - 1,
|
176
|
-
_bottom = _origY + _lineHeight - 2;
|
177
|
-
if( (_top - _bottom) < this.options.itemMinHeight ){
|
178
|
-
_bottom = _top + this.options.itemMinHeight;
|
179
|
-
}
|
180
|
-
return HRect.nu( _left, _top, _right, _bottom );
|
181
|
-
},
|
182
|
-
|
183
|
-
/** = Description
|
184
|
-
* Destructor; destroys the editor first and commences inherited die.
|
185
|
-
*
|
186
|
-
**/
|
187
|
-
die: function(){
|
188
|
-
this.editor.die();
|
189
|
-
this.base();
|
190
|
-
},
|
191
|
-
|
192
|
-
/** = Description
|
193
|
-
* Returns a new time sheet item control. By default returns an instance
|
194
|
-
* of HTimeSheetItem. Extend to use custom time sheet controls customized
|
195
|
-
* for application specific purposes.
|
196
|
-
*
|
197
|
-
* = Parameters
|
198
|
-
* *_value*:: A value object for the item.
|
199
|
-
* *_top*:: Top position, 0 by default.
|
200
|
-
* *_height*:: Height, same as half of +#pxPerHour+ by default.
|
201
|
-
* *_drogMode*:: Dragging mode. 'normal' or 'create'. Is 'normal' by default.
|
202
|
-
*
|
203
|
-
**/
|
204
|
-
createTimeSheetItem: function( _value, _top, _height, _dragMode ) {
|
205
|
-
if(_dragMode===undefined){
|
206
|
-
_dragMode = 'normal';
|
207
|
-
}
|
208
|
-
if(_top===undefined){
|
209
|
-
_top = 0;
|
210
|
-
}
|
211
|
-
if(_height===undefined){
|
212
|
-
_height = Math.round(this.pxPerHour/2);
|
213
|
-
}
|
214
|
-
var
|
215
|
-
_label = _value['label'],
|
216
|
-
_item = HTimeSheetItem.nu(
|
217
|
-
this.createItemRect( _top, _height ),
|
218
|
-
this, {
|
219
|
-
label: _label,
|
220
|
-
value: _value,
|
221
|
-
events: {
|
222
|
-
draggable: true
|
223
|
-
}
|
224
|
-
}
|
225
|
-
);
|
226
|
-
_item.dragMode = _dragMode;
|
227
|
-
return _item;
|
228
|
-
},
|
229
|
-
|
230
|
-
/** = Description
|
231
|
-
* Redraws and refreshes the values on timesheet.
|
232
|
-
*
|
233
|
-
**/
|
234
|
-
refreshValue: function(){
|
235
|
-
var
|
236
|
-
_data = this.value,
|
237
|
-
i;
|
238
|
-
if(this.listItemViews === false){
|
239
|
-
this.listItemViews = [];
|
240
|
-
}
|
241
|
-
else if(this.listItemViews.length > 0){
|
242
|
-
for( i=0; i<this.listItemViews.length; i++){
|
243
|
-
this.listItemViews[i].die();
|
244
|
-
}
|
245
|
-
this.listItemViews = [];
|
246
|
-
}
|
247
|
-
if(_data instanceof Array && _data.length > 0){
|
248
|
-
var
|
249
|
-
_value,
|
250
|
-
_item;
|
251
|
-
for( i=0; i<_data.length; i++){
|
252
|
-
_value = _data[i];
|
253
|
-
_item = this.createTimeSheetItem( _value );
|
254
|
-
this.listItemViews.push( _item );
|
255
|
-
}
|
256
|
-
}
|
257
|
-
var
|
258
|
-
_overlaps = [],
|
259
|
-
j;
|
260
|
-
for(i=0;i<this.listItemViews.length;i++){
|
261
|
-
for(j=0;j<this.listItemViews.length;j++){
|
262
|
-
if((i !== j) && (_overlaps.indexOf(i)===-1) && (_overlaps.indexOf(j)===-1)){
|
263
|
-
if(this.listItemViews[i].rect.intersects(this.listItemViews[j].rect)){
|
264
|
-
_overlaps.push(i);
|
265
|
-
}
|
266
|
-
}
|
267
|
-
}
|
268
|
-
}
|
269
|
-
var
|
270
|
-
_overlapCount = _overlaps.length+1,
|
271
|
-
_overlapLefts = {},
|
272
|
-
_itemWidth = ( this.rect.width - this.itemOffsetRight - this.itemOffsetLeft ),
|
273
|
-
_width = Math.floor( _itemWidth / _overlapCount),
|
274
|
-
_left = this.itemOffsetLeft;
|
275
|
-
for(j=0;j<_overlapCount;j++){
|
276
|
-
_overlapLefts[_overlaps[j]] = _left + (j*_width) + _width;
|
277
|
-
}
|
278
|
-
for(i=0;i<this.listItemViews.length;i++){
|
279
|
-
if(_overlaps.indexOf(i)===-1){
|
280
|
-
this.listItemViews[i].rect.setLeft(_left);
|
281
|
-
}
|
282
|
-
else {
|
283
|
-
this.listItemViews[i].rect.setLeft(_overlapLefts[i]);
|
284
|
-
}
|
285
|
-
this.listItemViews[i].rect.setWidth(_width);
|
286
|
-
}
|
287
|
-
for(i=0;i<this.listItemViews.length;i++){
|
288
|
-
this.listItemViews[i].drawRect();
|
289
|
-
}
|
290
|
-
}
|
291
|
-
});
|
292
|
-
|