Permalink
Browse files

Upgraded to Tracy's drag palette images and their radii,

made click without drag on drag palette not do commands,
and put in fix for Safari copy/paste problems.
Also upgraded socialcalcviewer.js to handle repeating macros.
  • Loading branch information...
1 parent 4594429 commit 4a2a35d397fd5d1e1046bcabede4c5aa81fbd5fa @DanBricklin committed Jul 5, 2010
View
@@ -649,9 +649,16 @@ This all gives us a way to set startup macros, etc.
2010-05-13:
Fixed IE6 and IE7+ compatibility issues with drag palette. Uses .gif for IE6, .png otherwise.
+2010-07-05:
+Upgraded to Tracy's drag palette images, including making radii setable constants.
+Made click without drag on drag palette not do any commands.
+Put in a fix for Safari 5 problem with copy/paste (involving onbeforepaste default behavior).
+
TO DO:
+Check out <= and >= Test Criteria!
+
Make defaultCommentStyle work with defaultImagePrefix.
Handle bad settings
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -225,6 +225,8 @@ SocialCalc.Constants = {
//** SocialCalc.CellHandles
+ CH_radius1: 29.0, // extent of inner circle within 90px image
+ CH_radius2: 41.0, // extent of outer circle within 90px image
s_CHfillAllTooltip: "Fill Contents and Formats Down/Right", // tooltip for fill all handle
s_CHfillContentsTooltip: "Fill Contents Only Down/Right", // tooltip for fill formulas handle
s_CHmovePasteAllTooltip: "Move Contents and Formats", // etc.
View
@@ -529,6 +529,15 @@ SocialCalc.CreateTableEditor = function(editor, width, height) {
editor.pasteTextarea = ta;
AssignID(editor, editor.pasteTextarea, "pastetextarea");
+ if (navigator.userAgent.match(/Safari\//) &&!navigator.userAgent.match(/Chrome\//)) { // special code for Safari 5 change
+ window.removeEventListener('beforepaste', SocialCalc.SafariPasteFunction, false);
+ window.addEventListener('beforepaste', SocialCalc.SafariPasteFunction, false);
+ window.removeEventListener('beforecopy', SocialCalc.SafariPasteFunction, false);
+ window.addEventListener('beforecopy', SocialCalc.SafariPasteFunction, false);
+ window.removeEventListener('beforecut', SocialCalc.SafariPasteFunction, false);
+ window.addEventListener('beforecut', SocialCalc.SafariPasteFunction, false);
+ }
+
editor.toplevel.appendChild(editor.pasteTextarea);
SocialCalc.MouseWheelRegister(editor.toplevel, {WheelMove: SocialCalc.EditorProcessMouseWheel, editor: editor});
@@ -551,6 +560,12 @@ SocialCalc.CreateTableEditor = function(editor, width, height) {
}
+// Special code needed for change that occurred with Safari 5 that made paste not work for some reason
+
+SocialCalc.SafariPasteFunction = function(e) {
+ e.preventDefault();
+ }
+
//
// SocialCalc.ResizeTableEditor(editor, width, height)
//
@@ -3518,6 +3533,8 @@ SocialCalc.CellHandles = function(editor) {
this.noCursorSuffix = false;
+ this.movedmouse = false; // used to detect no-op
+
this.draghandle = document.createElement("div");
SocialCalc.setStyles(this.draghandle, "display:none;position:absolute;zIndex:8;border:1px solid white;width:4px;height:4px;fontSize:1px;backgroundColor:#0E93D8;cursor:default;");
this.draghandle.innerHTML = '&nbsp;';
@@ -3654,7 +3671,7 @@ SocialCalc.CellHandlesMouseMoveOnHandle = function(e) {
editor.cellhandles.ShowCellHandles(true, true); // show move handles, too
if (target == cellhandles.dragpalette) {
- var whichhandle = SocialCalc.SegmentDivHit([24.0, 36.0], editor.cellhandles.dragpalette, clientX, clientY);
+ var whichhandle = SocialCalc.SegmentDivHit([scc.CH_radius1, scc.CH_radius2], editor.cellhandles.dragpalette, clientX, clientY);
if (whichhandle==0) { // off of active part of palette
SocialCalc.CellHandlesHoverTimeout();
return;
@@ -3688,7 +3705,7 @@ SocialCalc.CellHandlesMouseMoveOnHandle = function(e) {
// array = a new segtable for this subquadrant
//
// Alternatively, segtable can be:
-// [diameter 1, diameter 2] and it returns 0 if no hit,
+// [radius 1, radius 2] and it returns 0 if no hit,
// -1, -2, -3, -4 for inner quadrants, and +1...+4 for outer quadrants
//
@@ -3859,6 +3876,8 @@ SocialCalc.CellHandlesMouseDown = function(e) {
var cellhandles = editor.cellhandles;
+ cellhandles.movedmouse = false; // detect no-op
+
if (cellhandles.timer) { // cancel timer
window.clearTimeout(cellhandles.timer);
cellhandles.timer = null;
@@ -3872,7 +3891,7 @@ SocialCalc.CellHandlesMouseDown = function(e) {
range = editor.range;
- var whichhandle = SocialCalc.SegmentDivHit([24.0, 36.0], editor.cellhandles.dragpalette, clientX, clientY);
+ var whichhandle = SocialCalc.SegmentDivHit([scc.CH_radius1, scc.CH_radius2], editor.cellhandles.dragpalette, clientX, clientY);
if (whichhandle==1 || whichhandle==-1 || whichhandle==0) {
cellhandles.ShowCellHandles(true, false); // hide move handles
return;
@@ -3882,32 +3901,32 @@ SocialCalc.CellHandlesMouseDown = function(e) {
if (whichhandle==-3) {
cellhandles.dragtype = "Fill";
- mouseinfo.element = editor.cellhandles.fillhandle;
+// mouseinfo.element = editor.cellhandles.fillhandle;
cellhandles.noCursorSuffix = false;
}
else if (whichhandle==3) {
cellhandles.dragtype = "FillC";
- mouseinfo.element = editor.cellhandles.fillhandle;
+// mouseinfo.element = editor.cellhandles.fillhandle;
cellhandles.noCursorSuffix = false;
}
else if (whichhandle==-2) {
cellhandles.dragtype = "Move";
- mouseinfo.element = editor.cellhandles.movehandle1;
+// mouseinfo.element = editor.cellhandles.movehandle1;
cellhandles.noCursorSuffix = true;
}
else if (whichhandle==-4) {
cellhandles.dragtype = "MoveI";
- mouseinfo.element = editor.cellhandles.movehandle2;
+// mouseinfo.element = editor.cellhandles.movehandle2;
cellhandles.noCursorSuffix = false;
}
else if (whichhandle==2) {
cellhandles.dragtype = "MoveC";
- mouseinfo.element = editor.cellhandles.movehandle1;
+// mouseinfo.element = editor.cellhandles.movehandle1;
cellhandles.noCursorSuffix = true;
}
else if (whichhandle==4) {
cellhandles.dragtype = "MoveIC";
- mouseinfo.element = editor.cellhandles.movehandle2;
+// mouseinfo.element = editor.cellhandles.movehandle2;
cellhandles.noCursorSuffix = false;
}
@@ -4015,6 +4034,9 @@ SocialCalc.CellHandlesMouseMove = function(e) {
crstart = SocialCalc.coordToCr(editor.cellhandles.startingcoord);
crend = SocialCalc.coordToCr(result.coord);
+
+ cellhandles.movedmouse = true; // did move, so not no-op
+
switch (cellhandles.dragtype) {
case "Fill":
case "FillC":
@@ -4265,7 +4287,16 @@ SocialCalc.CellHandlesMouseUp = function(e) {
break;
}
+ if (!cellhandles.movedmouse) { // didn't move: just leave one cell selected
+ cellhandles.dragtype = "Nothing";
+ }
+
switch (cellhandles.dragtype) {
+ case "Nothing":
+ editor.Range2Remove();
+ editor.RangeRemove();
+ break;
+
case "Fill":
case "FillC":
View
@@ -159,6 +159,13 @@ SocialCalc.SpreadsheetViewer = function() {
this.statuslineFull = true;
this.noRecalc = true; // don't do a recalc when loaded, so no need for external sheet routines
+ // Repeating macro info
+
+ this.repeatingMacroTimer = null;
+ this.repeatingMacroInterval = 60; // default to 60 seconds
+ this.repeatingMacroCommands = ""; // what to execute
+
+
SocialCalc.CurrentSpreadsheetViewerObject = this; // remember this for rendezvousing on events
return;
@@ -258,6 +265,8 @@ SocialCalc.InitializeSpreadsheetViewer = function(spreadsheet, node, height, wid
SocialCalc.SpreadsheetViewerLoadSave = function(spreadsheet, savestr) {
+ var rmstr, pos, t, t2;
+
var parts = spreadsheet.DecodeSpreadsheetSave(savestr);
if (parts) {
if (parts.sheet) {
@@ -267,9 +276,24 @@ SocialCalc.SpreadsheetViewerLoadSave = function(spreadsheet, savestr) {
if (parts.edit) {
spreadsheet.editor.LoadEditorSettings(savestr.substring(parts.edit.start, parts.edit.end));
}
- if (parts.startupmacro) {
+ if (parts.startupmacro) { // executed now
spreadsheet.editor.EditorScheduleSheetCommands(savestr.substring(parts.startupmacro.start, parts.startupmacro.end), false, true);
}
+ if (parts.repeatingmacro) { // first line tells how many seconds before first execution. Last cmd must be "cmdextension repeatmacro delay" to continue repeating.
+ rmstr = savestr.substring(parts.repeatingmacro.start, parts.repeatingmacro.end);
+ rmstr = rmstr.replace("\r", ""); // make sure no CR, only LF
+ pos = rmstr.indexOf("\n");
+ if (pos > 0) {
+ t = rmstr.substring(0, pos)-0; // get number
+ t2 = t;
+// if (!(t > 0)) t = 60; // handles NAN, too
+ spreadsheet.repeatingMacroInterval = t;
+ spreadsheet.repeatingMacroCommands = rmstr.substring(pos+1);
+ if (t2 > 0) { // zero means don't start yet
+ spreadsheet.repeatingMacroTimer = window.setTimeout(SocialCalc.SpreadsheetViewerDoRepeatingMacro, spreadsheet.repeatingMacroInterval * 1000);
+ }
+ }
+ }
}
if (spreadsheet.editor.context.sheetobj.attribs.recalc=="off" || spreadsheet.noRecalc) {
spreadsheet.editor.ScheduleRender();
@@ -280,6 +304,49 @@ SocialCalc.SpreadsheetViewerLoadSave = function(spreadsheet, savestr) {
}
//
+// SocialCalc.SpreadsheetViewerDoRepeatingMacro
+//
+// Called by a timer. Executes repeatingMacroCommands once.
+// Use the "startcmdextension repeatmacro delay" command last to schedule this again.
+//
+
+SocialCalc.SpreadsheetViewerDoRepeatingMacro = function() {
+
+ var spreadsheet = SocialCalc.GetSpreadsheetViewerObject();
+ var editor = spreadsheet.editor;
+
+ spreadsheet.repeatingMacroTimer = null;
+
+ SocialCalc.SheetCommandInfo.CmdExtensionCallbacks.repeatmacro = {func:SocialCalc.SpreadsheetViewerRepeatMacroCommand, data:null};
+
+ editor.EditorScheduleSheetCommands(spreadsheet.repeatingMacroCommands);
+
+}
+
+SocialCalc.SpreadsheetViewerRepeatMacroCommand = function(name, data, sheet, cmd, saveundo) {
+
+ var spreadsheet = SocialCalc.GetSpreadsheetViewerObject();
+
+ var rest = cmd.RestOfString();
+ var t = rest-0; // get number
+ if (!(t > 0)) t = spreadsheet.repeatingMacroInterval; // handles NAN, too, using last value
+ spreadsheet.repeatingMacroInterval = t;
+
+ spreadsheet.repeatingMacroTimer = window.setTimeout(SocialCalc.SpreadsheetViewerDoRepeatingMacro, spreadsheet.repeatingMacroInterval * 1000);
+
+}
+
+SocialCalc.SpreadsheetViewerStopRepeatingMacro = function() {
+
+ var spreadsheet = SocialCalc.GetSpreadsheetViewerObject();
+
+ if (spreadsheet.repeatingMacroTimer) {
+ window.clearTimeout(spreadsheet.repeatingMacroTimer);
+ spreadsheet.repeatingMacroTimer = null;
+ }
+}
+
+//
// SocialCalc.SpreadsheetViewerDoButtonCmd(e, buttoninfo, bobj)
//
// xxx
@@ -555,6 +622,10 @@ SocialCalc.SpreadsheetViewerDecodeSpreadsheetSave = function(spreadsheet, str) {
var parts = {};
var partlist = [];
+var hasreturnonly = /[^\n]\r[^\n]/;
+if (hasreturnonly.test(str)) {
+str = str.replace(/([^\n])\r([^\n])/g, "$1\r\n$2");
+}
pos1 = str.search(/^MIME-Version:\s1\.0/mi);
if (pos1 < 0) return parts;

0 comments on commit 4a2a35d

Please sign in to comment.