Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the dialog object using a single function #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
27 changes: 26 additions & 1 deletion css/socialcalc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
254 changes: 144 additions & 110 deletions dist/SocialCalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div class="socialcalc-titlebar">'+
'<div class="socialcalc-titlebar-title">'+ title +'</div>'+
'<div class="socialcalc-titlebar-cross">&#128473;</div></div>'+
'<div class="socialcalc-dialog-content">'+ inner_html +'</div>';

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
//
Expand Down Expand Up @@ -25234,55 +25359,23 @@ SocialCalc.SpreadsheetControl.DoFunctionList = function() {

scf.FillFunctionInfo();

str = '<table><tr><td><span style="font-size:x-small;font-weight:bold">%loc!Category!</span><br>'+
str = '<table style="width: 100%;"><tr><td><span style="font-size:x-small;font-weight:bold">%loc!Category!</span><br>'+
'<select id="'+idp+'class" size="'+fcl.length+'" style="width:120px;" onchange="SocialCalc.SpreadsheetControl.FunctionClassChosen(this.options[this.selectedIndex].value);">';
for (i=0; i<fcl.length; i++) {
str += '<option value="'+fcl[i]+'"'+(i==0?' selected>':'>')+SocialCalc.special_chars(scf.FunctionClasses[fcl[i]].name)+'</option>';
}
str += '</select></td><td>&nbsp;&nbsp;</td><td id="'+idp+'list"><span style="font-size:x-small;font-weight:bold">%loc!Functions!</span><br>'+
'<select id="'+idp+'name" size="'+fcl.length+'" style="width:240px;" '+
'<select id="'+idp+'name" size="'+fcl.length+'" style="width:246px;" '+
'onchange="SocialCalc.SpreadsheetControl.FunctionChosen(this.options[this.selectedIndex].value);" ondblclick="SocialCalc.SpreadsheetControl.DoFunctionPaste();">';
str += SocialCalc.SpreadsheetControl.GetFunctionNamesStr("all");
str += '</td></tr><tr><td colspan="3">'+
'<div id="'+idp+'desc" style="width:380px;height:80px;overflow:auto;font-size:x-small;">'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'</div>'+
'<div style="width:380px;text-align:right;padding-top:6px;font-size:small;">'+
'<input type="button" value="%loc!Paste!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoFunctionPaste();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideFunctions();"></div>'+
'<div id="'+idp+'desc" style="height:80px;overflow:auto;font-size:x-small;">'+SocialCalc.SpreadsheetControl.GetFunctionInfoStr(scf.FunctionClasses[fcl[0]].items[0])+'</div>'+
'<div style="text-align:right;font-size:small;">'+
'<input type="button" value="%loc!Paste!" onclick="SocialCalc.SpreadsheetControl.DoFunctionPaste();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" onclick="SocialCalc.SpreadsheetControl.HideFunctions();"></div>'+
'</td></tr></table>';

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 = '<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr>'+
'<td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;">'+"&nbsp;%loc!Function List!"+'</td>'+
'<td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideFunctions();">&nbsp;X&nbsp;</td></tr></table>'+
'<div style="background-color:#DDD;">'+str+'</div>';

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();
Expand Down Expand Up @@ -25431,43 +25524,14 @@ SocialCalc.SpreadsheetControl.DoMultiline = function() {

text = SocialCalc.special_chars(text);

str = '<textarea id="'+idp+'textarea" style="width:380px;height:120px;margin:10px 0px 0px 6px;">'+text+'</textarea>'+
'<div style="width:380px;text-align:right;padding:6px 0px 4px 6px;font-size:small;">'+
SCLocSS('<input type="button" value="%loc!Set Cell Contents!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoMultilinePaste();">&nbsp;'+
'<input type="button" value="%loc!Clear!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoMultilineClear();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideMultiline();"></div>'+
str = '<textarea id="'+idp+'textarea" style="width:calc(100% - 6px);height:120px;margin:6px 0;">'+text+'</textarea>'+
'<div style="text-align:right;font-size:small;">'+
SCLocSS('<input type="button" value="%loc!Set Cell Contents!" onclick="SocialCalc.SpreadsheetControl.DoMultilinePaste();">&nbsp;'+
'<input type="button" value="%loc!Clear!" onclick="SocialCalc.SpreadsheetControl.DoMultilineClear();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" onclick="SocialCalc.SpreadsheetControl.HideMultiline();"></div>'+
'</div>');

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 = '<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr>'+
'<td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;">'+
SCLocSS("&nbsp;%loc!Multi-line Input Box!")+'</td>'+
'<td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideMultiline();">&nbsp;X&nbsp;</td></tr></table>'+
'<div style="background-color:#DDD;">'+str+'</div>';

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();
Expand Down Expand Up @@ -25604,8 +25668,7 @@ SocialCalc.SpreadsheetControl.DoLink = function() {

popup = parts.newwin ? " checked" : "";

str = '<div style="padding:6px 0px 4px 6px;">'+
'<span style="font-size:smaller;">'+SCLoc("Description")+'</span><br>'+
str = '<span style="font-size:smaller;">'+SCLoc("Description")+'</span><br>'+
'<input type="text" id="'+idp+'desc" style="width:380px;" value="'+SocialCalc.special_chars(parts.desc)+'"><br>'+
'<span style="font-size:smaller;">'+SCLoc("URL")+'</span><br>'+
'<input type="text" id="'+idp+'url" style="width:380px;" value="'+SocialCalc.special_chars(parts.url)+'"><br>';
Expand All @@ -25620,41 +25683,12 @@ SocialCalc.SpreadsheetControl.DoLink = function() {
'<input type="checkbox" id="'+idp+'popup"'+popup+'>&nbsp;'+
'<span style="font-size:smaller;">%loc!Show in new browser window!</span>'+
'</div>'+
'<div style="width:380px;text-align:right;padding:6px 0px 4px 6px;font-size:small;">'+
'<input type="button" value="%loc!Set Cell Contents!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoLinkPaste();">&nbsp;'+
'<input type="button" value="%loc!Clear!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoLinkClear();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideLink();"></div>'+
'</div>');

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 = '<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr>'+
'<td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;">'+"&nbsp;"+SCLoc("Link Input Box")+'</td>'+
'<td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideLink();">&nbsp;X&nbsp;</td></tr></table>'+
'<div style="background-color:#DDD;">'+str+'</div>';

SocialCalc.DragRegister(main.firstChild.firstChild.firstChild.firstChild, true, true,
{MouseDown: SocialCalc.DragFunctionStart,
MouseMove: SocialCalc.DragFunctionPosition,
MouseUp: SocialCalc.DragFunctionPosition,
Disabled: null, positionobj: main},
spreadsheet.spreadsheetDiv);
'<div style="text-align:right;font-size:small;">'+
'<input type="button" value="%loc!Set Cell Contents!" onclick="SocialCalc.SpreadsheetControl.DoLinkPaste();">&nbsp;'+
'<input type="button" value="%loc!Clear!" onclick="SocialCalc.SpreadsheetControl.DoLinkClear();">&nbsp;'+
'<input type="button" value="%loc!Cancel!" onclick="SocialCalc.SpreadsheetControl.HideLink();"></div>');

spreadsheet.spreadsheetDiv.appendChild(main);
spreadsheet.spreadsheetDiv.appendChild(SocialCalc.Dialog(idp, "%loc!Link Input Box!", str));

ele = document.getElementById(idp+"url");
ele.focus();
Expand Down
27 changes: 26 additions & 1 deletion dist/socialcalc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading