Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/neon-calendar.js
1292 views
1
/**
2
* Neon Calendar Script
3
*
4
* Developed by Arlind Nushi - www.laborator.co
5
*/
6
7
var neonCalendar = neonCalendar || {};
8
9
;(function($, window, undefined)
10
{
11
"use strict";
12
13
$(document).ready(function()
14
{
15
neonCalendar.$container = $(".calendar-env");
16
17
$.extend(neonCalendar, {
18
isPresent: neonCalendar.$container.length > 0
19
});
20
21
// Mail Container Height fit with the document
22
if(neonCalendar.isPresent)
23
{
24
neonCalendar.$sidebar = neonCalendar.$container.find('.calendar-sidebar');
25
neonCalendar.$body = neonCalendar.$container.find('.calendar-body');
26
27
28
// Checkboxes
29
var $cb = neonCalendar.$body.find('table thead input[type="checkbox"], table tfoot input[type="checkbox"]');
30
31
$cb.on('click', function()
32
{
33
$cb.attr('checked', this.checked).trigger('change');
34
35
calendar_toggle_checkbox_status(this.checked);
36
});
37
38
// Highlight
39
neonCalendar.$body.find('table tbody input[type="checkbox"]').on('change', function()
40
{
41
$(this).closest('tr')[this.checked ? 'addClass' : 'removeClass']('highlight');
42
});
43
44
45
// Setup Calendar
46
if($.isFunction($.fn.fullCalendar))
47
{
48
var calendar = $('#calendar');
49
50
calendar.fullCalendar({
51
header: {
52
left: 'title',
53
right: 'month,agendaWeek,agendaDay today prev,next'
54
},
55
56
//defaultView: 'basicWeek',
57
58
editable: true,
59
firstDay: 1,
60
height: 600,
61
droppable: true,
62
drop: function(date, allDay) {
63
64
var $this = $(this),
65
eventObject = {
66
title: $this.text(),
67
start: date,
68
allDay: allDay,
69
className: $this.data('event-class')
70
};
71
72
calendar.fullCalendar('renderEvent', eventObject, true);
73
74
$this.remove();
75
}
76
});
77
78
$("#draggable_events li a").draggable({
79
zIndex: 999,
80
revert: true,
81
revertDuration: 0
82
}).on('click', function()
83
{
84
return false;
85
});
86
}
87
else
88
{
89
alert("Please include full-calendar script!");
90
}
91
92
93
$("body").on('submit', '#add_event_form', function(ev)
94
{
95
ev.preventDefault();
96
97
var text = $("#add_event_form input");
98
99
if(text.val().length == 0)
100
return false;
101
102
var classes = ['', 'color-green', 'color-blue', 'color-orange', 'color-primary', ''],
103
_class = classes[ Math.floor(classes.length * Math.random()) ],
104
$event = $('<li><a href="#"></a></li>');
105
106
$event.find('a').text(text.val()).addClass(_class).attr('data-event-class', _class);
107
108
$event.appendTo($("#draggable_events"));
109
110
$("#draggable_events li a").draggable({
111
zIndex: 999,
112
revert: true,
113
revertDuration: 0
114
}).on('click', function()
115
{
116
return false;
117
});
118
119
fit_calendar_container_height();
120
121
$event.hide().slideDown('fast');
122
text.val('');
123
124
return false;
125
});
126
}
127
});
128
129
})(jQuery, window);
130
131
132
function fit_calendar_container_height()
133
{
134
if(neonCalendar.isPresent)
135
{
136
if(neonCalendar.$sidebar.height() < neonCalendar.$body.height())
137
{
138
neonCalendar.$sidebar.height( neonCalendar.$body.height() );
139
}
140
else
141
{
142
var old_height = neonCalendar.$sidebar.height();
143
144
neonCalendar.$sidebar.height('');
145
146
if(neonCalendar.$sidebar.height() < neonCalendar.$body.height())
147
{
148
neonCalendar.$sidebar.height(old_height);
149
}
150
}
151
}
152
}
153
154
function reset_calendar_container_height()
155
{
156
if(neonCalendar.isPresent)
157
{
158
neonCalendar.$sidebar.height('auto');
159
}
160
}
161
162
function calendar_toggle_checkbox_status(checked)
163
{
164
neonCalendar.$body.find('table tbody input[type="checkbox"]' + (checked ? '' : ':checked')).attr('checked', ! checked).click();
165
}
166