App-SocialCalc-Multiplayer
view release on metacpan or search on metacpan
socialcalc/socialcalctableeditor.js view on Meta::CPAN
}
//
// EditorRenderSheet(editor)
//
// Renders the sheet and updates editor.fullgrid.
// Sets event handlers.
//
SocialCalc.EditorRenderSheet = function(editor) {
editor.EditorMouseUnregister();
editor.fullgrid = editor.context.RenderSheet(editor.fullgrid);
if (editor.ecell) editor.SetECellHeaders("selected");
SocialCalc.AssignID(editor, editor.fullgrid, "fullgrid"); // give it an id
editor.EditorMouseRegister();
}
//
// EditorScheduleSheetCommands(editor, cmdstr, saveundo, ignorebusy)
//
SocialCalc.EditorScheduleSheetCommands = function(editor, cmdstr, saveundo, ignorebusy) {
if (editor.state!="start" && !ignorebusy) { // ignore commands if editing a cell
return;
}
if (editor.busy && !ignorebusy) { // hold off on commands if doing one
editor.deferredCommands.push({cmdstr: cmdstr, saveundo: saveundo});
return;
}
switch (cmdstr) {
case "recalc":
case "redisplay":
editor.context.sheetobj.ScheduleSheetCommands(cmdstr, false);
break;
case "undo":
editor.SheetUndo();
break;
case "redo":
editor.SheetRedo();
break;
default:
editor.context.sheetobj.ScheduleSheetCommands(cmdstr, saveundo);
break;
}
}
//
// EditorSheetStatusCallback(recalcdata, status, arg, editor)
//
// Called during recalc, executing commands, etc.
//
SocialCalc.EditorSheetStatusCallback = function(recalcdata, status, arg, editor) {
var f, cell, dcmd;
var sheetobj = editor.context.sheetobj;
var signalstatus = function(s) {
for (f in editor.StatusCallback) {
if (editor.StatusCallback[f].func) {
editor.StatusCallback[f].func(editor, s, arg, editor.StatusCallback[f].params);
}
}
}
switch (status) {
case "startup":
break;
case "cmdstart":
editor.busy = true;
sheetobj.celldisplayneeded = "";
break;
case "cmdextension":
break;
case "cmdend":
signalstatus(status);
if (sheetobj.changedrendervalues) {
editor.context.PrecomputeSheetFontsAndLayouts();
editor.context.CalculateCellSkipData();
sheetobj.changedrendervalues = false;
}
if (sheetobj.celldisplayneeded && !sheetobj.renderneeded) {
cr = SocialCalc.coordToCr(sheetobj.celldisplayneeded);
cell = SocialCalc.GetEditorCellElement(editor, cr.row, cr.col);
editor.ReplaceCell(cell, cr.row, cr.col);
}
if (editor.deferredCommands.length) {
dcmd = editor.deferredCommands.shift();
editor.EditorScheduleSheetCommands(dcmd.cmdstr, dcmd.saveundo, true);
return;
}
if (sheetobj.attribs.needsrecalc &&
(sheetobj.attribs.recalc!="off" || sheetobj.recalconce)
&& editor.recalcFunction) {
editor.FitToEditTable();
sheetobj.renderneeded = false; // recalc will force a render
if (sheetobj.recalconce) delete sheetobj.recalconce; // only do once
editor.recalcFunction(editor);
}
else {
if (sheetobj.renderneeded) {
editor.FitToEditTable();
sheetobj.renderneeded = false;
editor.ScheduleRender();
}
( run in 0.602 second using v1.01-cache-2.11-cpan-6aa56a78535 )