Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The programmatically-generated input-with-label elements now use an inner LABEL, instead of SPAN, and auto-generated INPUT element IDs to go with the labels (which require an ID). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fileedit-ajaxify |
Files: | files | file ages | folders |
SHA3-256: |
b46d11b871ef23d63880a8650592a954 |
User & Date: | stephan 2020-05-13 16:41:41 |
Context
2020-05-13
| ||
16:44 | Minor doc fix. ... (check-in: ae594780 user: stephan tags: fileedit-ajaxify) | |
16:41 | The programmatically-generated input-with-label elements now use an inner LABEL, instead of SPAN, and auto-generated INPUT element IDs to go with the labels (which require an ID). ... (check-in: b46d11b8 user: stephan tags: fileedit-ajaxify) | |
2020-05-12
| ||
16:26 | Fixed a potential corner-case bug which would have broken fossil.fetch() if a user had defined their own fossil.fetch.onerror() impl before calling fossil.fetch() the first time. ... (check-in: 695dde00 user: stephan tags: fileedit-ajaxify) | |
Changes
Changes to src/default_css.txt.
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | } .input-with-label > input[type=checkbox] { vertical-align: sub; } .input-with-label > input[type=radio] { vertical-align: sub; } | | > | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | } .input-with-label > input[type=checkbox] { vertical-align: sub; } .input-with-label > input[type=radio] { vertical-align: sub; } .input-with-label > label { font-weight: initial; margin: 0 0.25em 0 0.25em; vertical-align: middle; } |
Changes to src/style.c.
︙ | ︙ | |||
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 | cgi_reset_content(); webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr); } #if INTERFACE # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);} #endif /* ** Outputs a labeled checkbox element. zWrapperId is an optional ID ** value for the containing element (see below). zFieldName is the ** form element name. zLabel is the label for the checkbox. zValue is ** the optional value for the checkbox. zTip is an optional tooltip, ** which gets set as the "title" attribute of the outermost ** element. If isChecked is true, the checkbox gets the "checked" ** attribute set, else it is not. ** ** Resulting structure: ** ** <span class='input-with-label' title={{zTip}} id={{zWrapperId}}> ** <input type='checkbox' name={{zFieldName}} value={{zValue}} ** {{isChecked ? " checked : ""}}/> | > > > > > > > > > > > > | > | | > | 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 | cgi_reset_content(); webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr); } #if INTERFACE # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);} #endif /* ** Returns a pseudo-random input field ID, for use in associating an ** ID-less input field with a label. The memory is owned by the ** caller. */ static char * style_next_input_id(){ static int inputID = 0; ++inputID; return mprintf("input-id-%d", inputID); } /* ** Outputs a labeled checkbox element. zWrapperId is an optional ID ** value for the containing element (see below). zFieldName is the ** form element name. zLabel is the label for the checkbox. zValue is ** the optional value for the checkbox. zTip is an optional tooltip, ** which gets set as the "title" attribute of the outermost ** element. If isChecked is true, the checkbox gets the "checked" ** attribute set, else it is not. ** ** Resulting structure: ** ** <span class='input-with-label' title={{zTip}} id={{zWrapperId}}> ** <input type='checkbox' name={{zFieldName}} value={{zValue}} ** id='A RANDOM VALUE' ** {{isChecked ? " checked : ""}}/> ** <label for='ID OF THE INPUT FIELD'>{{zLabel}}</label> ** </span> ** ** zLabel, and zValue are required. zFieldName, zWrapperId, and zTip ** are may be NULL or empty. ** ** Be sure that the input-with-label CSS class is defined sensibly, in ** particular, having its display:inline-block is useful for alignment ** purposes. */ void style_labeled_checkbox(const char * zWrapperId, const char *zFieldName, const char * zLabel, const char * zValue, int isChecked, const char * zTip){ char * zLabelID = style_next_input_id(); CX("<span class='input-with-label'"); if(zTip && *zTip){ CX(" title='%h'", zTip); } if(zWrapperId && *zWrapperId){ CX(" id='%s'",zWrapperId); } CX("><input type='checkbox' id='%s' ", zLabelID); if(zFieldName && *zFieldName){ CX("name='%s' ",zFieldName); } CX("value='%T'%s/>", zValue ? zValue : "", isChecked ? " checked" : ""); CX("<label for='%s'>%h</label></span>", zLabelID, zLabel); fossil_free(zLabelID); } /* ** Outputs a SELECT list from a compile-time list of integers. ** The vargs must be a list of (const char *, int) pairs, terminated ** with a single NULL. Each pair is interpreted as... ** |
︙ | ︙ | |||
1370 1371 1372 1373 1374 1375 1376 | ** (see below). ** ** zTooltip is an optional value for the SELECT's title attribute. ** ** The structure of the emitted HTML is: ** ** <span class='input-with-label' title={{zToolTip}} id={{zWrapperId}}> | | | > > | | > | 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 | ** (see below). ** ** zTooltip is an optional value for the SELECT's title attribute. ** ** The structure of the emitted HTML is: ** ** <span class='input-with-label' title={{zToolTip}} id={{zWrapperId}}> ** <label for='SELECT ELEMENT ID'>{{zLabel}}</span> ** <select id='RANDOM ID' name={{zFieldName}}>...</select> ** </span> ** ** Example: ** ** style_select_list_int("my-grapes", "my_grapes", "Grapes", ** "Select the number of grapes", ** atoi(PD("my_field","0")), ** "", 1, "2", 2, "Three", 3, ** NULL); ** */ void style_select_list_int(const char * zWrapperId, const char *zFieldName, const char * zLabel, const char * zToolTip, int selectedVal, ... ){ char * zLabelID = style_next_input_id(); va_list vargs; va_start(vargs,selectedVal); CX("<span class='input-with-label'"); if(zToolTip && *zToolTip){ CX(" title='%h'",zToolTip); } if(zWrapperId && *zWrapperId){ CX(" id='%s'",zWrapperId); } CX(">"); if(zLabel && *zLabel){ CX("<label label='%s'>%h</label>", zLabelID, zLabel); } CX("<select name='%s' id='%s'>",zFieldName, zLabelID); while(1){ const char * zOption = va_arg(vargs,char *); int v; if(NULL==zOption){ break; } v = va_arg(vargs,int); CX("<option value='%d'%s>", v, v==selectedVal ? " selected" : ""); if(*zOption){ CX("%s", zOption); }else{ CX("%d",v); } CX("</option>\n"); } CX("</select>\n"); CX("</span>\n"); va_end(vargs); fossil_free(zLabelID); } /* ** The C-string counterpart of style_select_list_int(), this variant ** differs only in that its variadic arguments are C-strings in pairs ** of (optionLabel, optionValue). If a given optionLabel is an empty ** string, the corresponding optionValue is used as its label. If any |
︙ | ︙ | |||
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 | ** "1", "One", "2", "Two", "", "3", ** NULL); */ void style_select_list_str(const char * zWrapperId, const char *zFieldName, const char * zLabel, const char * zToolTip, char const * zSelectedVal, ... ){ va_list vargs; va_start(vargs,zSelectedVal); if(!zSelectedVal){ zSelectedVal = __FILE__/*some string we'll never match*/; } CX("<span class='input-with-label'"); if(zToolTip && *zToolTip){ CX(" title='%h'",zToolTip); } if(zWrapperId && *zWrapperId){ CX(" id='%s'",zWrapperId); } CX(">"); if(zLabel && *zLabel){ | > | | > | 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 | ** "1", "One", "2", "Two", "", "3", ** NULL); */ void style_select_list_str(const char * zWrapperId, const char *zFieldName, const char * zLabel, const char * zToolTip, char const * zSelectedVal, ... ){ char * zLabelID = style_next_input_id(); va_list vargs; va_start(vargs,zSelectedVal); if(!zSelectedVal){ zSelectedVal = __FILE__/*some string we'll never match*/; } CX("<span class='input-with-label'"); if(zToolTip && *zToolTip){ CX(" title='%h'",zToolTip); } if(zWrapperId && *zWrapperId){ CX(" id='%s'",zWrapperId); } CX(">"); if(zLabel && *zLabel){ CX("<label for='%s'>%h</label>", zLabelID, zLabel); } CX("<select name='%s' id='%s'>",zFieldName, zLabelID); while(1){ const char * zLabel = va_arg(vargs,char *); const char * zVal; if(NULL==zLabel){ break; } zVal = va_arg(vargs,char *); CX("<option value='%T'%s>", zVal, 0==fossil_strcmp(zVal, zSelectedVal) ? " selected" : ""); if(*zLabel){ CX("%s", zLabel); }else{ CX("%h",zVal); } CX("</option>\n"); } CX("</select>\n"); CX("</span>\n"); va_end(vargs); fossil_free(zLabelID); } /* ** The first time this is called, it emits code to install and ** bootstrap the window.fossil object, using the built-in file ** fossil.bootstrap.js (not to be confused with bootstrap.js). |
︙ | ︙ |