Fossil

Check-in [617e23bea3]
Login

Check-in [617e23bea3]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added settings popup to chat. Currently only 1 setting - toggling the page header/footer on/off.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 617e23bea3ea057a0fe33c9cb34e141666a4770fb8ba93e31f3d80290287b89a
User & Date: stephan 2020-12-25 10:04:14.946
Context
2020-12-25
11:06
Moved chat.c inline CSS style to default.css. Various chat layout tweaks. ... (check-in: 467dbc8fd7 user: stephan tags: trunk)
10:04
Added settings popup to chat. Currently only 1 setting - toggling the page header/footer on/off. ... (check-in: 617e23bea3 user: stephan tags: trunk)
09:39
chat.js restructuring/cleanup - no functional changes. ... (check-in: 12682568f0 user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/chat.c.
153
154
155
156
157
158
159

160
161
162
163
164
165
166
  @ </style>
  @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
  @ <div id='chat-input-area'>
  @   <div id='chat-input-line'>
  @     <input type="text" name="msg" id="sbox" \
  @      placeholder="Type message here.">
  @     <input type="submit" value="Send">

  @   </div>
  @   <div id='chat-input-file-area'>
  @     <div class='file-selection-wrapper'>
  @       <div class='help-buttonlet'>
  @        Select a file to upload, drag/drop a file into this spot,
  @        or paste an image from the clipboard if supported by
  @        your environment.







>







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  @ </style>
  @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
  @ <div id='chat-input-area'>
  @   <div id='chat-input-line'>
  @     <input type="text" name="msg" id="sbox" \
  @      placeholder="Type message here.">
  @     <input type="submit" value="Send">
  @     <span id="chat-settings-button" class="settings-icon"></span>
  @   </div>
  @   <div id='chat-input-file-area'>
  @     <div class='file-selection-wrapper'>
  @       <div class='help-buttonlet'>
  @        Select a file to upload, drag/drop a file into this spot,
  @        or paste an image from the clipboard if supported by
  @        your environment.
Changes to src/chat.js.
346
347
348
349
350
351
352












































353
354
355
356
357
358
359
      // truncation off the right edge of the page.
      const pRect = f.popup.e.getBoundingClientRect();
      x -= pRect.width/3*2;
    }
    f.popup.show(x, y);
  }/*handleLegendClicked()*/;













































  /** Callback for poll() to inject new content into the page.  jx ==
      the response from /chat-poll. If atEnd is true, the message is
      appended to the end of the chat list, else the beginning (the
      default). */
  const newcontent = function f(jx,atEnd){
    if(!f.processPost){
      /** Processes chat message m, placing it either the start (if atEnd







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
      // truncation off the right edge of the page.
      const pRect = f.popup.e.getBoundingClientRect();
      x -= pRect.width/3*2;
    }
    f.popup.show(x, y);
  }/*handleLegendClicked()*/;

  (function(){/*Set up #chat-settings-button */
    const settingsButton = document.querySelector('#chat-settings-button');
    var popupSize = undefined/*placement workaround*/;
    const settingsPopup = new F.PopupWidget({
      cssClass: ['fossil-tooltip', 'chat-settings-popup'],
      adjustY: function(y){
        const rect = settingsButton.getBoundingClientRect();
        return rect.top + rect.height;
      }
    });
    settingsPopup.installClickToHide();
    const btnToggleBody = D.button("Toggle page body");
    D.append(settingsPopup.e, btnToggleBody);
    const toggleBody = function f(){
      if(f.isHidden) D.removeClass(f.elemsToToggle, 'hidden');
      else D.addClass(f.elemsToToggle, 'hidden');
      f.isHidden = !f.isHidden;
    };
    toggleBody.elemsToToggle = [];
    toggleBody.isHidden = false;
    document.body.childNodes.forEach(function(e){
      if(!e.classList) return/*TEXT nodes and such*/;
      else if(!e.classList.contains('content')){
        toggleBody.elemsToToggle.push(e);
      }
      settingsPopup.hide();
    });
    btnToggleBody.addEventListener('click', toggleBody);
    settingsButton.addEventListener('click',function(){
      settingsPopup.show(settingsButton);
    });
    /* Find an ideal X position for the popup, directly under the settings
       button, based on the size of the popup... */
    settingsPopup.show(document.body);
    popupSize = settingsPopup.e.getBoundingClientRect();
    settingsPopup.hide();
    settingsPopup.options.adjustX = function(x){
      const rect = settingsButton.getBoundingClientRect();
      console.debug("popupSize = ",popupSize);
      return rect.right - popupSize.width;
    };
  })()/*#chat-settings-button setup*/;

  
  /** Callback for poll() to inject new content into the page.  jx ==
      the response from /chat-poll. If atEnd is true, the message is
      appended to the end of the chat list, else the beginning (the
      default). */
  const newcontent = function f(jx,atEnd){
    if(!f.processPost){
      /** Processes chat message m, placing it either the start (if atEnd
Changes to src/default.css.
1530
1531
1532
1533
1534
1535
1536

1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549


























body.chat .chat-message-popup > .toolbar > button {
  flex: 1 1 auto;
}

body.chat .load-msg-toolbar  {
  border-radius: 0.25em;
  padding: 0.1em 0.2em;

}
body.chat .load-msg-toolbar.all-done {
  opacity: 0.5;
}
body.chat .load-msg-toolbar > div {
  display: flex;
  flex-direction: row;
  justify-content: stretch;
  flex-wrap: wrap;
}
body.chat .load-msg-toolbar > div > button {
  flex: 1 1 auto;
}

































>













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
body.chat .chat-message-popup > .toolbar > button {
  flex: 1 1 auto;
}

body.chat .load-msg-toolbar  {
  border-radius: 0.25em;
  padding: 0.1em 0.2em;
  margin-bottom: 1em;
}
body.chat .load-msg-toolbar.all-done {
  opacity: 0.5;
}
body.chat .load-msg-toolbar > div {
  display: flex;
  flex-direction: row;
  justify-content: stretch;
  flex-wrap: wrap;
}
body.chat .load-msg-toolbar > div > button {
  flex: 1 1 auto;
}

.settings-icon {
  /* Icon source: https://de.wikipedia.org/wiki/Datei:OOjs_UI_icon_settings.svg
     MIT License. */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0, 0, 24, 24'%3e%3cg id='settings'%3e%3cpath id='gear' d='M3 4h3v2h-3zM12 4h9v2h-9zM8 3h2c.552 0 1 .448 1 1v2c0 .552-.448 1-1 1h-2c-.552 0-1-.448-1-1v-2c0-.552.448-1 1-1zM3 11h9v2h-9zM18 11h3v2h-3zM14 10h2c.552 0 1 .448 1 1v2c0 .552-.448 1-1 1h-2c-.552 0-1-.448-1-1v-2c0-.552.448-1 1-1zM3 18h6v2h-6zM15 18h6v2h-6zM11 17h2c.552 0 1 .448 1 1v2c0 .552-.448 1-1 1h-2c-.552 0-1-.448-1-1v-2c0-.552.448-1 1-1z'/%3e%3c/g%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  display: inline-block;
  min-height: 1em;
  max-height: 1em;
  min-width: 1em;
  max-width: 1em;
  margin: 0;
  padding: 0.2em/*needed to avoid image truncation*/;
}
body.chat #chat-settings-button {
}
body.chat .chat-settings-popup {
  font-size: 0.8em;
  text-align: left;
  opacity: 0.8;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.25em;
}