Skip to content

Commit 9712b95

Browse files
committed
Updated comments, added MIT license, put in fix for 'fixed' drop-targets.
1 parent 4f32c29 commit 9712b95

File tree

8 files changed

+124
-66
lines changed

8 files changed

+124
-66
lines changed

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (C) 2013 Peter Maloy
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

css/rc_calendar.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@
3535
position: absolute;
3636
left: 0;
3737
bottom: 0; }
38-
.rc_event #sgrip {
39-
width: 20px;
40-
height: 10px;
41-
border: 1px solid #888;
42-
border-top: none;
43-
-webkit-border-bottom-right-radius: 6px;
44-
-webkit-border-bottom-left-radius: 6px;
45-
-moz-border-radius-bottomright: 6px;
46-
-moz-border-radius-bottomleft: 6px;
47-
border-bottom-right-radius: 6px;
48-
border-bottom-left-radius: 6px;
49-
text-align: center;
50-
position: absolute;
51-
bottom: -11px;
52-
left: 40px;
53-
font-size: 50%; }
5438

5539
.rc_week {
5640
font-family: metrophobic,arial;

js/rc_calendar.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
//=============================================================================
12
//
23
// Resource Calendar Plugin
34
// ========================
5+
// Flexible booking management system. This file contains:
6+
// rc_calendar - routes rendering of calendars and bookings to
7+
// app-specific rendering functions (examples
8+
// provided in test.html)
9+
// - handles DOM events related to bookings
410
//
11+
// rc_resource - groups bookings for a particular resource such as a
12+
// room or member of staff. When rendering a calendar
13+
// for a particular day, the associated Resource returns
14+
// a list of bookings for that day
15+
//
16+
// rc_eventManager
17+
// - manages movement of bookings between resources
18+
// - calls user-supplied functions for booking retrieval,
19+
// persistence and deletion
20+
//=============================================================================
21+
// Author : Peter Maloy, August 2013
22+
// Repository: https://github.com/geekbrit/ResCal
23+
//=============================================================================
524
(function($) {
625

726
var defaults = {
@@ -119,9 +138,9 @@ function Calendar( element, options )
119138
//
120139
t.resources = [];
121140
element.find('resource').each( function(i,element) {
122-
t.resources[$(this).attr('id')] = new Resource( $(this), t.options.insert_policy );
141+
t.resources[$(this).attr('id')] = new rc_resource( $(this), t.options.insert_policy );
123142
});
124-
t.resources['unassigned_event_resource'] = new Resource( $('#unassigned_event_resource'), function(){} );
143+
t.resources['unassigned_event_resource'] = new rc_resource( $('#unassigned_event_resource'), function(){} );
125144

126145
t.initialize_events = function(){
127146
t.eventmanager = new rc_EventManager( t.options.retrieve,
@@ -375,8 +394,11 @@ function Calendar( element, options )
375394
$('.ui-droppable').each(function(){
376395

377396
var parent = $(this).parent();
378-
var viewableTop = parent.position().top;
379-
var viewableBottom = viewableTop + parent.height();
397+
// fixed elements get left behind in the coordinate system when the page is scrolled
398+
var adjust_scroll = (parent.css('position') == 'fixed') ? $('body').scrollTop() : 0;
399+
var viewableTop = parent.position().top + adjust_scroll;
400+
var viewableBottom = viewableTop + parent.height() + adjust_scroll;
401+
380402
var pos = ui.position;
381403

382404
if( pos.top > viewableTop &&
@@ -559,8 +581,8 @@ function rc_EventManager( retrieve_events, save_event, delete_event, resources,
559581

560582

561583
//
562-
// Resource Class
563-
// --------------
584+
// rc_resource Class
585+
// -----------------
564586
// Calendars are associated with one or more resources
565587
// When a Calendar is rendered, it retrieves a list of Events from each
566588
// associated Resource for each timeslot being rendered.
@@ -581,7 +603,7 @@ function rc_EventManager( retrieve_events, save_event, delete_event, resources,
581603
//
582604

583605

584-
function Resource( resource_element, insert_policy ) {
606+
function rc_resource( resource_element, insert_policy ) {
585607
var t = this;
586608

587609
//

js/rc_utilities.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// modifying rc_calendar.js.
1818
//
1919
//=============================================================================
20+
// Author : Peter Maloy, August 2013
21+
// Repository: https://github.com/geekbrit/ResCal
22+
//=============================================================================
2023

2124
function rc_notify( title, text, type ) {
2225
$.pnotify({

sass/rc_calendar.scss

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
//=============================================================================
3+
// Author : Peter Maloy, August 2013
4+
// Repository: https://github.com/geekbrit/ResCal
5+
//=============================================================================
6+
*/
7+
18
$mins15 : 18px;
29
$mins20 : 24px;
310
$mins30 : 36px;
@@ -56,24 +63,6 @@ $col_7days_width : 595/7 - 1px;
5663
left:0;
5764
bottom:0;
5865
}
59-
60-
#sgrip{
61-
width:20px;
62-
height:10px;
63-
border: 1px solid #888;
64-
border-top:none;
65-
-webkit-border-bottom-right-radius: 6px;
66-
-webkit-border-bottom-left-radius: 6px;
67-
-moz-border-radius-bottomright: 6px;
68-
-moz-border-radius-bottomleft: 6px;
69-
border-bottom-right-radius: 6px;
70-
border-bottom-left-radius: 6px;
71-
text-align:center;
72-
position:absolute;
73-
bottom:-11px;
74-
left:40px;
75-
font-size:50%;
76-
}
7766
}
7867

7968
.rc_week {

sass/test.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
//=============================================================================
3+
// Author : Peter Maloy, August 2013
4+
// Repository: https://github.com/geekbrit/ResCal
5+
//=============================================================================
6+
*/
7+
18
body{
29
overflow:auto;
310
}
@@ -104,6 +111,7 @@ body{
104111
width:auto;
105112
height: 160px;
106113
}
114+
107115
.form_datepicker{
108116
font-size:80%;
109117
position:absolute;

templates/week.template.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
2-
//
3-
// This function is registered as "postcalrender", a callback to be executed
4-
// after every rerender of the calendars
5-
//
6-
// calendar_state gives access to the public state of the calendar
7-
//
8-
function adjust_calendar_width( calendar_state )
9-
{
10-
// expand width of containers to accommodate pesky scrollbar
11-
// this is specific to the template used in the test system, but the techniques used
12-
// may be useful in similar templates where the calendar is scrollable
13-
var first_week = $('.rc_bodyweek').first();
14-
var days = $(first_week).find('.rc_day_target');
15-
var first = $(days).first();
16-
var last = $(days).last();
17-
var retries = 5;
18-
while( --retries && $(first).offset().top != $(last).offset().top ){
19-
$('.rc_week').animate({width: "+=10px"},0);
20-
}
21-
}
22-
1+
//=============================================================================
2+
// Author : Peter Maloy, August 2013
3+
// Repository: https://github.com/geekbrit/ResCal
4+
//=============================================================================
235

246
//
257
// Compile Render Functions

test.html

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
<!--
2+
//=============================================================================
3+
// Resource Calendar Usage Example
4+
// -------------------------------
5+
//
6+
// One Calendar may have multiple resources, and events (bookings)
7+
// can be freely dragged between those resources. This example shows
8+
// a "calendar-week" for each of three resources, in this case rooms.
9+
//
10+
// It would also be possible to show a single "calendar-day" with all
11+
// the resources side by side, or a month per resource could be shown.
12+
//
13+
// To accomplish this, different rendering templates for rendering a
14+
// calendar and for rendering an event would be required, and the
15+
// default "render" and "render_event" options would be overridden
16+
// when instantiating the rc_calendar.
17+
//
18+
// This file contains:
19+
// * Minimal page layout code
20+
// * Resource declarations with parameters that can be used for
21+
// automatic sanity-checking of booking placement (for example,
22+
// ensuring that a 250 person conference is not booked into a
23+
// room with a 10 person capacity)
24+
// * A (hidden) form that is used as the template for the popup
25+
// booking-editing form when a booking is clicked
26+
// * Example templates. These are embedded within <script> tags;
27+
// I'd have prefered to keep them out of the html page, but
28+
// alternative options have other issues (javascript "HereDoc"
29+
// implementations not being cross-browser compatible & so on).
30+
// * Javascript functions for validating event placement, and
31+
// managing persistent storage. These would be application-
32+
// specific in a real system, so I have kept them separate from
33+
// the Resource Calendar javascript files.
34+
// * rc_calendar instantiation example in the document ready function
35+
//
36+
//=============================================================================
37+
// Author : Peter Maloy, August 2013
38+
// Repository: https://github.com/geekbrit/ResCal
39+
//=============================================================================
40+
-->
141
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
242
<html>
343
<head>
@@ -11,9 +51,9 @@
1151
<body>
1252
<div class='header'>
1353
<h1>Resource Calendar Demo Page</h1>
14-
<p>Rendering of calendars and events has been abstracted out to a javascript template file that
15-
uses the "doT.js" templating system [<a href='http://olado.github.io/doT/'>http://olado.github.io/doT/</a>].
16-
This layout is just one possible way to use the Resource Calendar system; it is fully customizable.</p>
54+
<p>Rendering of calendars and events has been abstracted out to javascript template functions that
55+
use the "doT.js" templating system [<a href='http://olado.github.io/doT/'>http://olado.github.io/doT/</a>].
56+
This layout is just one possible way to use the Resource Calendar system; it is fully customizable and configurable.</p>
1757
<p>Source code for the Resource Calendar jquery plugin, and a description of functionality implemented so far, can be found at: <a href="https://github.com/geekbrit/ResCal">https://github.com/geekbrit/ResCal</a></p>
1858
</div>
1959
<div id='new_events' class='event_palette'>
@@ -191,6 +231,7 @@ <h3>Resource Calendar</h3>
191231
<!-- END TEMPLATES - - - - - - - - - - - - - - - - - - - - - - - - - - -->
192232

193233
<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
234+
<!-- jquery-ui down-revved because 1.10.3 has issues with dragging in scrolled pages -->
194235
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" type="text/javascript"></script>
195236
<script src="js/jquery.pnotify.js" type="text/javascript"></script>
196237
<script src="js/moment.min.js" type="text/javascript"></script>
@@ -258,6 +299,28 @@ <h3>Resource Calendar</h3>
258299
}
259300

260301

302+
//
303+
// This function is registered as "postcalrender", a callback to be executed
304+
// after every rerender of the calendars
305+
//
306+
// calendar_state gives access to the public state of the calendar
307+
//
308+
function adjust_calendar_width( calendar_state )
309+
{
310+
// expand width of containers to accommodate pesky scrollbar
311+
// this is specific to the template used in the test system, but the techniques used
312+
// may be useful in similar templates where the calendar is scrollable
313+
var first_week = $('.rc_bodyweek').first();
314+
var days = $(first_week).find('.rc_day_target');
315+
var first = $(days).first();
316+
var last = $(days).last();
317+
var retries = 5;
318+
while( --retries && $(first).offset().top != $(last).offset().top ){
319+
$('.rc_week').animate({width: "+=10px"},0);
320+
}
321+
}
322+
323+
261324
//
262325
// This function is needed as a callback when the user clicks on a new
263326
// date using a datepicker dialog. The callback mechanism doesn't let

0 commit comments

Comments
 (0)