Do not allow past date for drop in fullcalendar - ruby-on-rails

Hi I am using fullcalendar for schdule event
Now I want to disable pas date for drop event, So I fixed using following solution
$('#calendar').fullCalendar({
eventConstraint: {
start: moment().format('YYYY-MM-DD'),
end: '2100-01-01'
},
});
It working fine, but now I want to disable few days from week too, so I added dow in eventConstraint, now its stop working
$('#calendar').fullCalendar({
eventConstraint: {
start: moment().format('YYYY-MM-DD'),
end: '2100-01-01',
dow: [ 3, 5 ]
},
});
In short I want to disable past date and allow to select only wed and fri from calendar.
Is there anyway to fix issue.

Having given this some more thought after your comments, I think this is best solved using some custom code, via the eventDrop callback:
eventDrop: function(event, delta, revertFunc) {
var day = event.start.clone();
day.startOf("day");
var dayOfWeek = day.isoWeekday();
if (day.isBefore(moment().startOf("day")) || (dayOfWeek != 3 && dayOfWeek != 5)) {
revertFunc()
}
}
This will check for both of your constraints: if the day is in the past, or that the day is not a Wednesday and not a Friday, then revertFunc() is executed, which is a fullCalendar-provided callback which sends the event back to its original location on the calendar.
Here you can find a working demo: http://jsfiddle.net/ughug9xx/2/

Related

How to update the dynamic island view after a certain interval of time in App kill state.?

I want to start the dynamic island live activity for count down timer with event title.
Like christmas in 05 days.
I am trying to update it with the help of timer in extension, but not able to update the view.
Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { [self] time in
if minute < 1 {
updateActivity(dynamicIslandType: dynamicIslandType, minute: 0)
time.invalidate()
}
I have tried this code in widget extension to update the view, but not able to get any update of the view.

iOS 7 mobile Safari no longer supports <input type="datetime"/>

I have a rather large iPad application built using PhoneGap and I was doing some testing to make sure everything was going to work appropriately in iOS 7. The most significant issue I have found is that <input type="datetime"/> is no longer supported.
I have seen several posted suggesting you need to now have two separate fields for date and time. This is a really huge change because I am using this all over the application. I am hoping this is just something broken in the beta release of iOS 7 since it is an HTML 5 standard input type but I can't seem to find any information.
Any help or thoughts would be greatly appreciated.
Support for datetime has been removed, but you can use datetime-local instead. From what I hear (can't say from whom) it's here to stay.
It looks like this input type was removed in iOS 7
http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review
Following Google Chrome, now Safari on iOS doesn’t support the
datetime input type anymore and it will fallback to text. This type
was deprecated in the standard in favor of using two inputs, date and
time for the same purpose. The problem is that datetime was compatible
with iOS from version 5.0 to 6.1; if you are using it, be careful!
I ended up using the datetime-local but you have to make sure you take into account the timezone when binding to and from the control. We want to store GMT time in the database. I used the below functions to convert back and forth during binding.
function formatHTML5DateTime(date)
{
try
{
if (typeof(date) == 'undefined' || date == null || date == '') return "";
var tmpDate = new Date(date);
// gets the timezone offset in minutes
var offset = tmpDate.getTimezoneOffset();
// apply the timezone offset in reverse to local time
var newDate = tmpDate.addMinutes(Math.abs(offset) * -1);
return newDate.toISOString().replace("Z", "");
}
catch(e)
{
return "";
}
}
function formatJSDate(date)
{
try
{
if (typeof(date) == 'undefined' || date == null || date == '') return "";
var tmpDate = new Date(date);
// gets the timezone offset in minutes
var offset = tmpDate.getTimezoneOffset();
// apply the timezone offset to UTC time
var newDate = tmpDate.addMinutes(offset);
return newDate.toISOString();
}
catch(e)
{
return "";
}
}
See the reference here
Your CSS should be change as below:
{
align-items: center;
display: -webkit-inline-flex;
overflow: hidden;
padding: 0px;
-webkit-padding-start: 1px;
}

Data Grouping - Monthly (end-of-month)

I'm having a very difficult time trying to get my data to be grouped via month. I've even gone so far as to programmatically filter through my data to return only the last day of the month and calculate the monthly value. I've tried to find a good explanation on the 'dataGrouping' property but have had no luck understanding it nor properly implementing it. Every results returns my series in a daily interval.
My questions are as follows:
Is there a minimum number of data points needed for data grouping to
work?
Under the dataGrouping.units I've tried to use this
documentation but nothing has worked for me - Still results in a
daily interval - Could someone explain this for me?
Any help on this would be GREATLY appreciated.
Are you using HighStock graph?
If yes...
Sure, it takes a lot of data to get grouping. If datagrouping option is enabled, Highstock handle automatically the switch between every grouping mode. So if you don't have a lot of data, it will not work with default settings
So, if you want to group by default, you need to force the grouping.
series:[{
[...]
dataGrouping: {
approximation: "sum",
enabled: true,
forced: true,
units: [['month',[1]]]
}
}]
EDIT
Here is a working example demo (fork of a basic highstock demo)
http://jsfiddle.net/NcNvu/
Hope it helps!
Regards
We tried a Hack around this, where we used Highstock's (Splinechart) RangeSelector, Event and DataGrouping. On click of weekly rangeselectorButton we catch this event through setExtremes. Post catching the event approximate it to "sum". If you are using two series than iterate the object. Currently doing it weekly just extend it for Monthly using corresponding UNIT
events: {
setExtremes: function (e) {
if (e.rangeSelectorButton != undefined) {
var triger = e.rangeSelectorButton;
if (triger.type == 'week') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['week', [1]];
});
} else if (triger.type == 'day') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['day', [1]];
});
}
}
}
},

Phonegap, Cordova watchposition fire success every 1 second

Platform: iOS6/OSx Lion.
I'm trying to puzzle out the way Phonegap/Cordova work with navigator.geolocation.watchPosition.
The docs says that the option "maximumAge" is the one that ask the system for retrieve the position.
So with these options:
{ maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }
I espect the position request will be fired every 3 seconds?
And no matter what maximumAge I put the success is fired every 1 second...
Anyone can explain please?
Thanks Bye
Rob
I am currently working around this issue by using getCurrentPosition with a setInterval. I'm not sure what the consequences may be, but this seems to give me the most control and appears to be the most consistent method across platforms.
// call this once
setupWatch(3000);
// sets up the interval at the specified frequency
function setupWatch(freq) {
// global var here so it can be cleared on logout (or whenever).
activeWatch = setInterval(watchLocation, freq);
}
// this is what gets called on the interval.
function watchLocation() {
var gcp = navigator.geolocation.getCurrentPosition(
updateUserLoc, onLocationError, {
enableHighAccuracy: true
});
// console.log(gcp);
}
// do something with the results
function updateUserLoc(position) {
var location = {
lat : position.coords.latitude,
lng : position.coords.longitude
};
console.log(location.lat);
console.log(location.lng);
}
// stop watching
function logout() {
clearInterval(activeWatch);
}

jQuery UI DatePicker - Disable all days except last day of month

I'm trying to use the jquery UI datepicker to show a calendar with only the last day of the month selectable.
I've successfully used the beforeShowDay event to disable days of the week but not sure how I'd use this to disable everything but the last day of the month.
beforeShowDay is called for every date shown on the calender. When beforeShowDay is called, you need to determine if the date passed to it is the last day of the month.
The following JScript will return the last day of the month for a given year and month.
function LastDayOfMonth(Year, Month)
{
return(new Date((new Date(Year, Month+1,1))-1)).getDate();
}
Use the following code to determine if the beforeShowDay's date is the last of the month:
$('.selector').datepicker({
beforeShowDay: function (date) {
//getDate() returns the day (0-31)
if (date.getDate() == LastDayOfMonth(date.getFullYear(),date.getMonth())) {
return [true, ''];
}
return [false, ''];
}
});
function LastDayOfMonth(Year, Month) {
//set next month first day
//substract one day from it.
return new Date(new Date(Year, Month+1,1)-1).getDate();
}
This will work

Resources