Skip to content

Commit f789c33

Browse files
Update web-forms.js
Ability to add and remove events Ability to add and remove events listener Add new tag back feature Create style options for progress bar
1 parent dff66ff commit f789c33

File tree

1 file changed

+125
-4
lines changed

1 file changed

+125
-4
lines changed

web-forms.js

Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* WebFormsJS 1.4 - Providing Infrastructure For Web Controls In CodeBehind Framework Owned By Elanat (elanat.net) */
1+
/* WebFormsJS 1.5 - Providing Infrastructure For Web Controls In CodeBehind Framework Owned By Elanat (elanat.net) */
22

33
/* Start Options */
44

@@ -10,6 +10,9 @@ PostBackOptions.AutoSetSubmitOnClick = true;
1010
PostBackOptions.SendDataOnlyByPostMethod = false;
1111
PostBackOptions.WebFormsTagsBackgroundColor = "#eee";
1212
PostBackOptions.SetResponseInsideDivTag = true;
13+
PostBackOptions.ProgressBarStyle = "width:100%;min-width:300px;max-width:600px;background-color:#eee;margin:2px 0px";
14+
PostBackOptions.ProgressBarPercentLoadedStyle = "position:absolute;padding:0px 4px;line-height:22px";
15+
PostBackOptions.ProgressBarValueStyle = "height:20px;background-color:#4D93DD;width:0%";
1316

1417
function cb_GetResponseLocation()
1518
{
@@ -421,6 +424,17 @@ function GetBack(FormAction, ViewState)
421424

422425
/* End Get-Back */
423426

427+
/* Start Tag-Back */
428+
429+
function TagBack(OutputPlace)
430+
{
431+
var ElementPlace = cb_GetElementByElementPlace(OutputPlace);
432+
var ActionControls = ElementPlace.getAttribute("ac");
433+
cb_SetWebFormsValues("", ActionControls, false, true);
434+
}
435+
436+
/* End Tag-Back */
437+
424438
function cb_FormDataSerialize(form, TagSubmitName, TagSubmitValue, TagSubmitType, FormIsMultiPart)
425439
{
426440
var FormString = "";
@@ -622,15 +636,15 @@ function cb_SetProgressTag(obj, form)
622636
{
623637
var DivProgressUpload = document.createElement("div");
624638
DivProgressUpload.id = "div_ProgressUpload";
625-
DivProgressUpload.setAttribute("style", "width:100%;min-width:300px;max-width:600px;background-color:#eee;margin:2px 0px");
639+
DivProgressUpload.setAttribute("style", PostBackOptions.ProgressBarStyle);
626640

627641
var DivProgressPercentLoaded = document.createElement("div");
628642
DivProgressPercentLoaded.id = "div_ProgressPercentLoaded";
629-
DivProgressPercentLoaded.setAttribute("style", "position:absolute;padding:0px 4px;line-height:22px");
643+
DivProgressPercentLoaded.setAttribute("style", PostBackOptions.ProgressBarPercentLoadedStyle);
630644

631645
var DivProgressUploadValue = document.createElement("div");
632646
DivProgressUploadValue.id = "div_ProgressUploadValue";
633-
DivProgressUploadValue.setAttribute("style", "height:20px;background-color:#4D93DD;width:0%");
647+
DivProgressUploadValue.setAttribute("style", PostBackOptions.ProgressBarValueStyle);
634648

635649
DivProgressUpload.appendChild(DivProgressPercentLoaded);
636650
DivProgressUpload.appendChild(DivProgressUploadValue);
@@ -1343,6 +1357,113 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
13431357
CurrentElement.value = Value;
13441358
}
13451359
break;
1360+
1361+
case 'E':
1362+
switch (ActionFeature)
1363+
{
1364+
case "p":
1365+
if (Value.Contains("|"))
1366+
{
1367+
var HtmlEvent = Value.GetTextBefore("|");
1368+
1369+
if (Value.GetTextAfter("|") == '+')
1370+
CurrentElement.setAttribute(HtmlEvent, "PostBack(this, true)");
1371+
else
1372+
CurrentElement.setAttribute(HtmlEvent, "PostBack(this, '" + Value.GetTextAfter("|") + "')");
1373+
}
1374+
else
1375+
CurrentElement.setAttribute(Value, "PostBack(this)");
1376+
break;
1377+
case "P":
1378+
if (Value.Contains("|"))
1379+
{
1380+
var HtmlEvent = Value.GetTextBefore("|");
1381+
1382+
if (Value.GetTextAfter("|") == '+')
1383+
CurrentElement.addEventListener(HtmlEvent, () => { PostBack(this, true); });
1384+
else
1385+
CurrentElement.addEventListener(HtmlEvent, () => { PostBack(this, Value.GetTextAfter("|")); });
1386+
break;
1387+
}
1388+
else
1389+
CurrentElement.addEventListener(Value, () => { PostBack(this); });
1390+
break;
1391+
case "g":
1392+
if (Value.Contains("|"))
1393+
{
1394+
var HtmlEvent = Value.GetTextBefore("|");
1395+
var Path = Value.GetTextAfter("|");
1396+
1397+
if (Path.Contains("|"))
1398+
{
1399+
if (Path.GetTextBefore("|") == '#')
1400+
CurrentElement.setAttribute(HtmlEvent, "GetBack('', '" + Path.GetTextAfter("|") + "')");
1401+
else
1402+
CurrentElement.setAttribute(HtmlEvent, "GetBack('" + Path.GetTextBefore("|") + "', '" + Path.GetTextAfter("|") + "')");
1403+
}
1404+
else
1405+
{
1406+
if (Path == '#')
1407+
CurrentElement.setAttribute(HtmlEvent, "GetBack()");
1408+
else
1409+
CurrentElement.setAttribute(HtmlEvent, "GetBack('" + Path + "')");
1410+
}
1411+
}
1412+
else
1413+
CurrentElement.setAttribute(Value, "GetBack(this)");
1414+
break;
1415+
case "G":
1416+
if (Value.Contains("|"))
1417+
{
1418+
var HtmlEvent = Value.GetTextBefore("|");
1419+
var Path = Value.GetTextAfter("|");
1420+
1421+
if (Path.Contains("|"))
1422+
{
1423+
if (Path.GetTextBefore("|") == '#')
1424+
CurrentElement.addEventListener(HtmlEvent, () => { GetBack("", Path.GetTextAfter("|")); });
1425+
else
1426+
CurrentElement.addEventListener(HtmlEvent, () => { GetBack(Path.GetTextBefore("|"), Path.GetTextAfter("|")); });
1427+
}
1428+
else
1429+
{
1430+
if (Path == '#')
1431+
CurrentElement.addEventListener(HtmlEvent, GetBack);
1432+
else
1433+
CurrentElement.addEventListener(HtmlEvent, () => { GetBack(Path); });
1434+
}
1435+
}
1436+
else
1437+
CurrentElement.addEventListener(Value, () => { GetBack(this); });
1438+
break;
1439+
case "t":
1440+
CurrentElement.setAttribute(Value.GetTextBefore("|"), "TagBack('" + Value.GetTextAfter("|") + "')");
1441+
break;
1442+
case "T":
1443+
CurrentElement.addEventListener(Value.GetTextBefore("|"), () => { TagBack(Value.GetTextAfter("|")); });
1444+
break;
1445+
}
1446+
break;
1447+
1448+
case 'R':
1449+
switch (ActionFeature)
1450+
{
1451+
case "p":
1452+
case "g":
1453+
case "t":
1454+
CurrentElement.removeAttribute(Value);
1455+
break;
1456+
case "P":
1457+
CurrentElement.removeEventListener(Value, () => { PostBack(this); });
1458+
break;
1459+
case "G":
1460+
CurrentElement.removeEventListener(Value, () => { GetBack(this); });
1461+
break;
1462+
case "T":
1463+
CurrentElement.removeEventListener(Value, () => { TagBack(this); });
1464+
break;
1465+
}
1466+
break;
13461467
}
13471468

13481469
switch (ActionOperation + ActionFeature)

0 commit comments

Comments
 (0)