allow ViewOptionHashes for selectable options, fixed new selectable bugs
This commit is contained in:
parent
1f02eb5f91
commit
6f4ab74340
|
@ -19,7 +19,7 @@ setDefaults({
|
||||||
maxTime: 24
|
maxTime: 24
|
||||||
});
|
});
|
||||||
|
|
||||||
views.agendaWeek = function(element, options) {
|
views.agendaWeek = function(element, options, viewName) {
|
||||||
return new Agenda(element, options, {
|
return new Agenda(element, options, {
|
||||||
render: function(date, delta) {
|
render: function(date, delta) {
|
||||||
if (delta) {
|
if (delta) {
|
||||||
|
@ -46,10 +46,10 @@ views.agendaWeek = function(element, options) {
|
||||||
this.option('columnFormat')
|
this.option('columnFormat')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, viewName);
|
||||||
};
|
};
|
||||||
|
|
||||||
views.agendaDay = function(element, options) {
|
views.agendaDay = function(element, options, viewName) {
|
||||||
return new Agenda(element, options, {
|
return new Agenda(element, options, {
|
||||||
render: function(date, delta) {
|
render: function(date, delta) {
|
||||||
if (delta) {
|
if (delta) {
|
||||||
|
@ -66,10 +66,10 @@ views.agendaDay = function(element, options) {
|
||||||
this.option('columnFormat')
|
this.option('columnFormat')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, viewName);
|
||||||
};
|
};
|
||||||
|
|
||||||
function Agenda(element, options, methods) {
|
function Agenda(element, options, methods, viewName) {
|
||||||
|
|
||||||
var head, body, bodyContent, bodyTable, bg,
|
var head, body, bodyContent, bodyTable, bg,
|
||||||
colCnt,
|
colCnt,
|
||||||
|
@ -111,6 +111,7 @@ function Agenda(element, options, methods) {
|
||||||
return addMinutes(start, options.defaultEventMinutes);
|
return addMinutes(start, options.defaultEventMinutes);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
view.name = viewName;
|
||||||
view.init(element, options);
|
view.init(element, options);
|
||||||
|
|
||||||
|
|
||||||
|
@ -965,16 +966,17 @@ function Agenda(element, options, methods) {
|
||||||
|
|
||||||
var selected = false;
|
var selected = false;
|
||||||
var daySelectionMousedown = selection_dayMousedown(
|
var daySelectionMousedown = selection_dayMousedown(
|
||||||
view, hoverListener, cellDate, renderDayOverlay, clearOverlay, reportSelection, unselect
|
view, hoverListener, cellDate, cellIsAllDay, renderDayOverlay, clearOverlay, reportSelection, unselect
|
||||||
);
|
);
|
||||||
|
|
||||||
function slotSelectionMousedown(ev) {
|
function slotSelectionMousedown(ev) {
|
||||||
if (view.option('selectable')) {
|
if (view.option('selectable')) {
|
||||||
unselect();
|
unselect();
|
||||||
|
var _mousedownElement = this;
|
||||||
var dates;
|
var dates;
|
||||||
hoverListener.start(function(cell, origCell) {
|
hoverListener.start(function(cell, origCell) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
if (cell && cell.col == origCell.col) {
|
if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) {
|
||||||
var d1 = cellDate(origCell);
|
var d1 = cellDate(origCell);
|
||||||
var d2 = cellDate(cell);
|
var d2 = cellDate(cell);
|
||||||
dates = [
|
dates = [
|
||||||
|
@ -988,9 +990,12 @@ function Agenda(element, options, methods) {
|
||||||
dates = null;
|
dates = null;
|
||||||
}
|
}
|
||||||
}, ev);
|
}, ev);
|
||||||
$(document).one('mouseup', function() {
|
$(document).one('mouseup', function(ev) {
|
||||||
hoverListener.stop();
|
hoverListener.stop();
|
||||||
if (dates) {
|
if (dates) {
|
||||||
|
if (+dates[0] == +dates[1]) {
|
||||||
|
view.trigger('dayClick', _mousedownElement, dates[0], false, ev);
|
||||||
|
}
|
||||||
reportSelection(dates[0], dates[3], false);
|
reportSelection(dates[0], dates[3], false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
17
src/grid.js
17
src/grid.js
|
@ -6,7 +6,7 @@ setDefaults({
|
||||||
weekMode: 'fixed'
|
weekMode: 'fixed'
|
||||||
});
|
});
|
||||||
|
|
||||||
views.month = function(element, options) {
|
views.month = function(element, options, viewName) {
|
||||||
return new Grid(element, options, {
|
return new Grid(element, options, {
|
||||||
render: function(date, delta) {
|
render: function(date, delta) {
|
||||||
if (delta) {
|
if (delta) {
|
||||||
|
@ -46,10 +46,10 @@ views.month = function(element, options) {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, viewName);
|
||||||
};
|
};
|
||||||
|
|
||||||
views.basicWeek = function(element, options) {
|
views.basicWeek = function(element, options, viewName) {
|
||||||
return new Grid(element, options, {
|
return new Grid(element, options, {
|
||||||
render: function(date, delta) {
|
render: function(date, delta) {
|
||||||
if (delta) {
|
if (delta) {
|
||||||
|
@ -77,10 +77,10 @@ views.basicWeek = function(element, options) {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, viewName);
|
||||||
};
|
};
|
||||||
|
|
||||||
views.basicDay = function(element, options) {
|
views.basicDay = function(element, options, viewName) {
|
||||||
return new Grid(element, options, {
|
return new Grid(element, options, {
|
||||||
render: function(date, delta) {
|
render: function(date, delta) {
|
||||||
if (delta) {
|
if (delta) {
|
||||||
|
@ -98,7 +98,7 @@ views.basicDay = function(element, options) {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, viewName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ views.basicDay = function(element, options) {
|
||||||
var tdHeightBug;
|
var tdHeightBug;
|
||||||
|
|
||||||
|
|
||||||
function Grid(element, options, methods) {
|
function Grid(element, options, methods, viewName) {
|
||||||
|
|
||||||
var tm, firstDay,
|
var tm, firstDay,
|
||||||
nwe, // no weekends (int)
|
nwe, // no weekends (int)
|
||||||
|
@ -135,6 +135,7 @@ function Grid(element, options, methods) {
|
||||||
return cloneDate(event.start);
|
return cloneDate(event.start);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
view.name = viewName;
|
||||||
view.init(element, options);
|
view.init(element, options);
|
||||||
|
|
||||||
|
|
||||||
|
@ -528,7 +529,7 @@ function Grid(element, options, methods) {
|
||||||
|
|
||||||
var selected = false;
|
var selected = false;
|
||||||
var selectionMousedown = selection_dayMousedown(
|
var selectionMousedown = selection_dayMousedown(
|
||||||
view, hoverListener, cellDate, renderDayOverlay, clearOverlay, reportSelection, unselect
|
view, hoverListener, cellDate, function(){return true}, renderDayOverlay, clearOverlay, reportSelection, unselect
|
||||||
);
|
);
|
||||||
|
|
||||||
view.select = function(startDate, endDate, allDay) {
|
view.select = function(startDate, endDate, allDay) {
|
||||||
|
|
|
@ -215,7 +215,8 @@ $.fn.fullCalendar = function(options) {
|
||||||
newViewElement = absoluteViewElement =
|
newViewElement = absoluteViewElement =
|
||||||
$("<div class='fc-view fc-view-" + v + "' style='position:absolute'/>")
|
$("<div class='fc-view fc-view-" + v + "' style='position:absolute'/>")
|
||||||
.appendTo(content),
|
.appendTo(content),
|
||||||
options
|
options,
|
||||||
|
v // the view's name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
header.find('div.fc-button-' + v).addClass(tm + '-state-active');
|
header.find('div.fc-button-' + v).addClass(tm + '-state-active');
|
||||||
}
|
}
|
||||||
|
|
||||||
view.name = viewName = v;
|
viewName = v;
|
||||||
render(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
|
render(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
|
||||||
content.css('overflow', '');
|
content.css('overflow', '');
|
||||||
if (oldView) {
|
if (oldView) {
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
|
|
||||||
|
|
||||||
function selection_dayMousedown(view, hoverListener, cellDate, renderSelection, clearSelection, reportSelection, unselect) {
|
function selection_dayMousedown(view, hoverListener, cellDate, cellIsAllDay, renderSelection, clearSelection, reportSelection, unselect) {
|
||||||
return function(ev) {
|
return function(ev) {
|
||||||
if (view.option('selectable')) {
|
if (view.option('selectable')) {
|
||||||
unselect();
|
unselect();
|
||||||
|
var _mousedownElement = this;
|
||||||
var dates;
|
var dates;
|
||||||
hoverListener.start(function(cell, origCell) {
|
hoverListener.start(function(cell, origCell) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
if (cell) {
|
if (cell && cellIsAllDay(cell)) {
|
||||||
dates = [ cellDate(origCell), cellDate(cell) ].sort(cmp);
|
dates = [ cellDate(origCell), cellDate(cell) ].sort(cmp);
|
||||||
renderSelection(dates[0], addDays(cloneDate(dates[1]), 1), true);
|
renderSelection(dates[0], addDays(cloneDate(dates[1]), 1), true);
|
||||||
|
}else{
|
||||||
|
dates = null;
|
||||||
}
|
}
|
||||||
}, ev);
|
}, ev);
|
||||||
$(document).one('mouseup', function(ev) {
|
$(document).one('mouseup', function(ev) {
|
||||||
if (hoverListener.stop()) { // over a cell?
|
hoverListener.stop();
|
||||||
|
if (dates) {
|
||||||
|
if (+dates[0] == +dates[1]) {
|
||||||
|
view.trigger('dayClick', _mousedownElement, dates[0], true, ev);
|
||||||
|
}
|
||||||
reportSelection(dates[0], dates[1], true);
|
reportSelection(dates[0], dates[1], true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,6 +26,12 @@
|
||||||
//weekends: false,
|
//weekends: false,
|
||||||
//allDaySlot: false,
|
//allDaySlot: false,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
/*
|
||||||
|
selectable: {
|
||||||
|
month: false,
|
||||||
|
agenda: true
|
||||||
|
},
|
||||||
|
*/
|
||||||
//selectHelper: true,
|
//selectHelper: true,
|
||||||
/*
|
/*
|
||||||
selectHelper: function(start, end) {
|
selectHelper: function(start, end) {
|
||||||
|
|
Loading…
Reference in a new issue