diff --git a/Gulpfile.js b/Gulpfile.js index df3a1e6..d845de5 100755 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -13,6 +13,7 @@ var js_bottom_file = js_folder + 'module-wrapper-bottom.js'; var js_files = [ js_folder + 'socialcalcconstants.js', + js_folder + 'dialog.js', js_folder + 'socialcalc-3.js', js_folder + 'socialcalctableeditor.js', js_folder + 'formatnumber2.js', diff --git a/css/socialcalc.css b/css/socialcalc.css index 90615a3..103ee0f 100644 --- a/css/socialcalc.css +++ b/css/socialcalc.css @@ -47,4 +47,29 @@ #searchbar { float:right; } - +.socialcalc-dialog { + border: 1px solid black; + background-color:#DDD; + z-index: 100; + width: 400px; + position: absolute; +} +.socialcalc-titlebar { + float: left; + width: 100%; + border-bottom: 1px solid black; + background-color:#A0A0A0; +} +.socialcalc-titlebar-title { + float: left; + padding: 3px; + width: calc(100% - 22px - 6px); +} +.socialcalc-titlebar-cross { + float: left; + padding: 3px; + width: 16px; +} +.socialcalc-dialog-content { + padding: 6px; +} diff --git a/dist/SocialCalc.js b/dist/SocialCalc.js index a4a2738..7ed6438 100644 --- a/dist/SocialCalc.js +++ b/dist/SocialCalc.js @@ -902,6 +902,131 @@ SocialCalc.ConstantsSetImagePrefix = function(imagePrefix) { } +// +// SocialCalcSpreadsheetControl +// +/* +// The code module of the SocialCalc package that lets you embed a spreadsheet +// control with toolbar, etc., into a web page. +// +// (c) Copyright 2008, 2009, 2010 Socialtext, Inc. +// All Rights Reserved. +// + + +/* + +LEGAL NOTICES REQUIRED BY THE COMMON PUBLIC ATTRIBUTION LICENSE: + +EXHIBIT A. Common Public Attribution License Version 1.0. + +The contents of this file are subject to the Common Public Attribution License Version 1.0 (the +"License"); you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://socialcalc.org. The License is based on the Mozilla Public License Version 1.1 but +Sections 14 and 15 have been added to cover use of software over a computer network and provide for +limited attribution for the Original Developer. In addition, Exhibit A has been modified to be +consistent with Exhibit B. + +Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +KIND, either express or implied. See the License for the specific language governing rights and +limitations under the License. + +The Original Code is SocialCalc JavaScript SpreadsheetControl. + +The Original Developer is the Initial Developer. + +The Initial Developer of the Original Code is Socialtext, Inc. All portions of the code written by +Socialtext, Inc., are Copyright (c) Socialtext, Inc. All Rights Reserved. + +Contributor: Dan Bricklin. + + +EXHIBIT B. Attribution Information + +When the SpreadsheetControl is producing and/or controlling the display the Graphic Image must be +displayed on the screen visible to the user in a manner comparable to that in the +Original Code. The Attribution Phrase must be displayed as a "tooltip" or "hover-text" for +that image. The image must be linked to the Attribution URL so as to access that page +when clicked. If the user interface includes a prominent "about" display which includes +factual prominent attribution in a form similar to that in the "about" display included +with the Original Code, including Socialtext copyright notices and URLs, then the image +need not be linked to the Attribution URL but the "tool-tip" is still required. + +Attribution Copyright Notice: + + Copyright (C) 2010 Socialtext, Inc. + All Rights Reserved. + +Attribution Phrase (not exceeding 10 words): SocialCalc + +Attribution URL: http://www.socialcalc.org/ + +Graphic Image: The contents of the sc-logo.gif file in the Original Code or +a suitable replacement from http://www.socialcalc.org/licenses specified as +being for SocialCalc. + +Display of Attribution Information is required in Larger Works which are defined +in the CPAL as a work which combines Covered Code or portions thereof with code +not governed by the terms of the CPAL. + +*/ + +// +// Some of the other files in the SocialCalc package are licensed under +// different licenses. Please note the licenses of the modules you use. +// +// Code History: +// +// Initially coded by Dan Bricklin of Software Garden, Inc., for Socialtext, Inc. +// Unless otherwise specified, referring to "SocialCalc" in comments refers to this +// JavaScript version of the code, not the SocialCalc Perl code. +// + +/* + +See the comments in the main SocialCalc code module file of the SocialCalc package. + +*/ + +SocialCalc.Dialog = function(id, title, inner_html) { + var spreadsheet = SocialCalc.GetSpreadsheetControlObject(); + var vp = SocialCalc.GetViewportInfo(); + var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); + + var main = document.createElement("div"); + main.id = id + "dialog"; + main.className = "socialcalc-dialog"; + + main.style.top = ((vp.height/3)-pos.top) + "px"; + main.style.left = ((vp.width/3)-pos.left) + "px"; + + var str = '
'+ + '
'+ title +'
'+ + '
🗙
'+ + '
'+ inner_html +'
'; + + main.innerHTML = SocialCalc.LocalizeSubstrings(str); + + var cross = main.getElementsByClassName('socialcalc-titlebar-cross')[0]; + cross.addEventListener('click', function() { + main.innerHTML = ""; + SocialCalc.DragUnregister(main); + SocialCalc.KeyboardFocus(); + + if (main.parentNode) { + main.parentNode.removeChild(main); + } + }, false); + + SocialCalc.DragRegister(main.firstChild.firstChild, true, true, + {MouseDown: SocialCalc.DragFunctionStart, + MouseMove: SocialCalc.DragFunctionPosition, + MouseUp: SocialCalc.DragFunctionPosition, + Disabled: null, positionobj: main}, + spreadsheet.spreadsheetDiv); + return main; +}; + // // The main SocialCalc code module of the SocialCalc package // @@ -25234,55 +25359,23 @@ SocialCalc.SpreadsheetControl.DoFunctionList = function() { scf.FillFunctionInfo(); - str = '
%loc!Category!
'+ + str = '
%loc!Category!
'+ '
  %loc!Functions!
'+ - '
'+ - '
'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'
'+ - '
'+ - ' '+ - '
'+ + '
'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'
'+ + '
'+ + ' '+ + '
'+ '
'; - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - str = ''+ - ''+ - '
'+" %loc!Function List!"+' X 
'+ - '
'+str+'
'; - - str = SocialCalc.LocalizeSubstrings(str); - - main.innerHTML = str; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); - - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Function List!", str)); ele = document.getElementById(idp+"name"); ele.focus(); @@ -25431,43 +25524,14 @@ SocialCalc.SpreadsheetControl.DoMultiline = function() { text = SocialCalc.special_chars(text); - str = ''+ - '
'+ - SCLocSS(' '+ - ' '+ - '
'+ + str = ''+ + '
'+ + SCLocSS(' '+ + ' '+ + '
'+ ''); - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - main.innerHTML = ''+ - ''+ - '
'+ - SCLocSS(" %loc!Multi-line Input Box!")+' X 
'+ - '
'+str+'
'; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); - - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Multi-line Input Box!", str)); ele = document.getElementById(idp+"textarea"); ele.focus(); @@ -25604,8 +25668,7 @@ SocialCalc.SpreadsheetControl.DoLink = function() { popup = parts.newwin ? " checked" : ""; - str = '
'+ - ''+SCLoc("Description")+'
'+ + str = ''+SCLoc("Description")+'
'+ '
'+ ''+SCLoc("URL")+'
'+ '
'; @@ -25620,41 +25683,12 @@ SocialCalc.SpreadsheetControl.DoLink = function() { ' '+ '%loc!Show in new browser window!'+ '
'+ - '
'+ - ' '+ - ' '+ - '
'+ - ''); - - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - main.innerHTML = ''+ - ''+ - '
'+" "+SCLoc("Link Input Box")+' X 
'+ - '
'+str+'
'; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); + '
'+ + ' '+ + ' '+ + '
'); - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Link Input Box!", str)); ele = document.getElementById(idp+"url"); ele.focus(); diff --git a/dist/socialcalc.css b/dist/socialcalc.css index 90615a3..103ee0f 100644 --- a/dist/socialcalc.css +++ b/dist/socialcalc.css @@ -47,4 +47,29 @@ #searchbar { float:right; } - +.socialcalc-dialog { + border: 1px solid black; + background-color:#DDD; + z-index: 100; + width: 400px; + position: absolute; +} +.socialcalc-titlebar { + float: left; + width: 100%; + border-bottom: 1px solid black; + background-color:#A0A0A0; +} +.socialcalc-titlebar-title { + float: left; + padding: 3px; + width: calc(100% - 22px - 6px); +} +.socialcalc-titlebar-cross { + float: left; + padding: 3px; + width: 16px; +} +.socialcalc-dialog-content { + padding: 6px; +} diff --git a/js/dialog.js b/js/dialog.js new file mode 100644 index 0000000..ef424d5 --- /dev/null +++ b/js/dialog.js @@ -0,0 +1,124 @@ +// +// SocialCalcSpreadsheetControl +// +/* +// The code module of the SocialCalc package that lets you embed a spreadsheet +// control with toolbar, etc., into a web page. +// +// (c) Copyright 2008, 2009, 2010 Socialtext, Inc. +// All Rights Reserved. +// + + +/* + +LEGAL NOTICES REQUIRED BY THE COMMON PUBLIC ATTRIBUTION LICENSE: + +EXHIBIT A. Common Public Attribution License Version 1.0. + +The contents of this file are subject to the Common Public Attribution License Version 1.0 (the +"License"); you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://socialcalc.org. The License is based on the Mozilla Public License Version 1.1 but +Sections 14 and 15 have been added to cover use of software over a computer network and provide for +limited attribution for the Original Developer. In addition, Exhibit A has been modified to be +consistent with Exhibit B. + +Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +KIND, either express or implied. See the License for the specific language governing rights and +limitations under the License. + +The Original Code is SocialCalc JavaScript SpreadsheetControl. + +The Original Developer is the Initial Developer. + +The Initial Developer of the Original Code is Socialtext, Inc. All portions of the code written by +Socialtext, Inc., are Copyright (c) Socialtext, Inc. All Rights Reserved. + +Contributor: Dan Bricklin. + + +EXHIBIT B. Attribution Information + +When the SpreadsheetControl is producing and/or controlling the display the Graphic Image must be +displayed on the screen visible to the user in a manner comparable to that in the +Original Code. The Attribution Phrase must be displayed as a "tooltip" or "hover-text" for +that image. The image must be linked to the Attribution URL so as to access that page +when clicked. If the user interface includes a prominent "about" display which includes +factual prominent attribution in a form similar to that in the "about" display included +with the Original Code, including Socialtext copyright notices and URLs, then the image +need not be linked to the Attribution URL but the "tool-tip" is still required. + +Attribution Copyright Notice: + + Copyright (C) 2010 Socialtext, Inc. + All Rights Reserved. + +Attribution Phrase (not exceeding 10 words): SocialCalc + +Attribution URL: http://www.socialcalc.org/ + +Graphic Image: The contents of the sc-logo.gif file in the Original Code or +a suitable replacement from http://www.socialcalc.org/licenses specified as +being for SocialCalc. + +Display of Attribution Information is required in Larger Works which are defined +in the CPAL as a work which combines Covered Code or portions thereof with code +not governed by the terms of the CPAL. + +*/ + +// +// Some of the other files in the SocialCalc package are licensed under +// different licenses. Please note the licenses of the modules you use. +// +// Code History: +// +// Initially coded by Dan Bricklin of Software Garden, Inc., for Socialtext, Inc. +// Unless otherwise specified, referring to "SocialCalc" in comments refers to this +// JavaScript version of the code, not the SocialCalc Perl code. +// + +/* + +See the comments in the main SocialCalc code module file of the SocialCalc package. + +*/ + +SocialCalc.Dialog = function(id, title, inner_html) { + var spreadsheet = SocialCalc.GetSpreadsheetControlObject(); + var vp = SocialCalc.GetViewportInfo(); + var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); + + var main = document.createElement("div"); + main.id = id + "dialog"; + main.className = "socialcalc-dialog"; + + main.style.top = ((vp.height/3)-pos.top) + "px"; + main.style.left = ((vp.width/3)-pos.left) + "px"; + + var str = '
'+ + '
'+ title +'
'+ + '
🗙
'+ + '
'+ inner_html +'
'; + + main.innerHTML = SocialCalc.LocalizeSubstrings(str); + + var cross = main.getElementsByClassName('socialcalc-titlebar-cross')[0]; + cross.addEventListener('click', function() { + main.innerHTML = ""; + SocialCalc.DragUnregister(main); + SocialCalc.KeyboardFocus(); + + if (main.parentNode) { + main.parentNode.removeChild(main); + } + }, false); + + SocialCalc.DragRegister(main.firstChild.firstChild, true, true, + {MouseDown: SocialCalc.DragFunctionStart, + MouseMove: SocialCalc.DragFunctionPosition, + MouseUp: SocialCalc.DragFunctionPosition, + Disabled: null, positionobj: main}, + spreadsheet.spreadsheetDiv); + return main; +}; diff --git a/js/socialcalcspreadsheetcontrol.js b/js/socialcalcspreadsheetcontrol.js index fe6de2a..c87ba9f 100644 --- a/js/socialcalcspreadsheetcontrol.js +++ b/js/socialcalcspreadsheetcontrol.js @@ -2230,55 +2230,23 @@ SocialCalc.SpreadsheetControl.DoFunctionList = function() { scf.FillFunctionInfo(); - str = '
%loc!Category!
'+ + str = '
%loc!Category!
'+ '
  %loc!Functions!
'+ - '
'+ - '
'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'
'+ - '
'+ - ' '+ - '
'+ + '
'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'
'+ + '
'+ + ' '+ + '
'+ '
'; - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - str = ''+ - ''+ - '
'+" %loc!Function List!"+' X 
'+ - '
'+str+'
'; - - str = SocialCalc.LocalizeSubstrings(str); - - main.innerHTML = str; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); - - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Function List!", str)); ele = document.getElementById(idp+"name"); ele.focus(); @@ -2427,43 +2395,14 @@ SocialCalc.SpreadsheetControl.DoMultiline = function() { text = SocialCalc.special_chars(text); - str = ''+ - '
'+ - SCLocSS(' '+ - ' '+ - '
'+ + str = ''+ + '
'+ + SCLocSS(' '+ + ' '+ + '
'+ ''); - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - main.innerHTML = ''+ - ''+ - '
'+ - SCLocSS(" %loc!Multi-line Input Box!")+' X 
'+ - '
'+str+'
'; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); - - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Multi-line Input Box!", str)); ele = document.getElementById(idp+"textarea"); ele.focus(); @@ -2600,8 +2539,7 @@ SocialCalc.SpreadsheetControl.DoLink = function() { popup = parts.newwin ? " checked" : ""; - str = '
'+ - ''+SCLoc("Description")+'
'+ + str = ''+SCLoc("Description")+'
'+ '
'+ ''+SCLoc("URL")+'
'+ '
'; @@ -2616,41 +2554,12 @@ SocialCalc.SpreadsheetControl.DoLink = function() { ' '+ '%loc!Show in new browser window!'+ '
'+ - '
'+ - ' '+ - ' '+ - '
'+ - ''); - - var main = document.createElement("div"); - main.id = idp+"dialog"; - - main.style.position = "absolute"; - - var vp = SocialCalc.GetViewportInfo(); - var pos = SocialCalc.GetElementPositionWithScroll(spreadsheet.spreadsheetDiv); - - main.style.top = ((vp.height/3)-pos.top)+"px"; - main.style.left = ((vp.width/3)-pos.left)+"px"; - main.style.zIndex = 100; - main.style.backgroundColor = "#FFF"; - main.style.border = "1px solid black"; - - main.style.width = "400px"; - - main.innerHTML = ''+ - ''+ - '
'+" "+SCLoc("Link Input Box")+' X 
'+ - '
'+str+'
'; - - SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true, - {MouseDown: SocialCalc.DragFunctionStart, - MouseMove: SocialCalc.DragFunctionPosition, - MouseUp: SocialCalc.DragFunctionPosition, - Disabled: null, positionobj: main}, - spreadsheet.spreadsheetDiv); + '
'+ + ' '+ + ' '+ + '
'); - spreadsheet.spreadsheetDiv.appendChild(main); + spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Link Input Box!", str)); ele = document.getElementById(idp+"url"); ele.focus();