Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TadHTMLPrompt

TadHTMLPrompt (Library)

This is a class that his used for running Drafts commands. These commands are based on the slash command approach of other systems.

Hierarchy

  • TadHTMLPrompt

Index

Constructors

constructor

  • Creates new instance of TadHTMLPrompt class.

    Returns TadHTMLPrompt

Properties

buttonCancel

buttonCancel: string

The HTML that constructs the cancel button on the form. This HTML is defaulted in the constructor() function, but can be overridden. You could customise what the button does, its name, or set it to a null string to simply not include a cancel button.

buttonSubmit

buttonSubmit: string

The HTML that constructs the submit button on the form. This HTML is defaulted in the constructor() function, but can be overridden. You could customise what the button does, its name, or set it to a null string to simply not include a submit button.

content

content: string

The body content to include in the tad-fd form in the body of the HTML of the preview.

css

css: string

The main CSS to be used in the preview window.

hideInterface

hideInterface: Boolean

Determines if the preview window should have the interface bar shown. Deafulted to true by the constructor() function, which will cause the interface to be hidden.

html

html: string

The base HTML of the preview window. Note that it includes template placeholders for five regions:

  • tadpreview_content - the main content.
  • tadpreview_css - the main CSS.
  • tadpreview_title - the window title.
  • tadpreview_submit - the submit button.
  • tadpreview_cancel - the cancel button. These entries are populated from the corresponding class properties.

title

title: string

The title of the preview window.

Methods

TA_draft

  • TA_draft(p_dLoad?: Draft, p_strLabel?: string, p_intLimit?: number, p_intRed?: number): Draft
  • Display an HTML prompt for draft creation/editing. This function displays a simple pop-up drafts editor. The editor includes a field for capturing draft content, a word count, a checkbox to mark the flagged status of the draft, and an expandable section showing existing tag association and a field to add new tags (comma separated list). The function can be used to not only create a new draft, but also to edit an existing one. It is a very simple editor and is in no way intended to replace the main draft editor. Rather it is a way to quickly add or update a draft without leaving the current draft - useful on devices that do not suport multi-windowing, or within the context of an executing action. The function returns undefined if the editor was cancelled, and the edited (and updated) draft object if submitted.

    Parameters

    • Optional p_dLoad: Draft

      the draft object to load into the pop-up editor, defaults to null, which is what should be used to specify creation of a new draft.

    • Optional p_strLabel: string

      the label to use for the large text field, defaults to "Content".

    • Optional p_intLimit: number

      an optional limit to the number of characters that can be entered.

    • Optional p_intRed: number

      an optional specification of after how many characters a countdown will be displayed in red.

      // Example
      let obj1 = new TadHTMLPrompt;
      //Create a new draft
      obj1.TA_draft();
      //Edit the current draft, set the label and set some editing constraints
      obj1.TA_draft(draft, "Current Draft Content to be Edited", 5000, 4750);

    Returns Draft

TA_dropDown

  • TA_dropDown(p_strLabel: string, p_astrList: string[]): string
  • Display an HTML prompt containing a drop down list. The function returns the value of the drop down field, or undefined if cancelled.

    Parameters

    • p_strLabel: string

      the label to be associated with the drop down list.

    • p_astrList: string[]

      the array of strings with which to populate the drop down list.

      // Example
      let obj1 = new TadHTMLPrompt;
      alert(obj1.TA_dropDown("Select an option", ["alpha","bravo","charlie"]));

    Returns string

TA_filterField

  • TA_filterField(p_strLabel: string, p_astrList: string[]): string
  • Display an HTML prompt containing a filter list. This is displayed as a test field, but as the user enters text, it filters a list that displays beneath it of 'known' values. Any value can be entered, but generally the idea is to use the list to populate the field with a known value. This is particularly useful for long lists. The user can match using a tap, mouse click, or cursor key navigation, and selecting enter while the focus is on the text field will automatically submit. The function returns the value of the text field, or undefined of cancelled. One limitation is that the array of entries cannot (currently) include a backtick.

    Parameters

    • p_strLabel: string

      the label to be associated with the text field.

    • p_astrList: string[]

      the array of strings with which to populate the drop down list that shows beneath the text field.

      // Example
      let obj1 = new TadHTMLPrompt;
      alert(obj1.TA_filterField("Select an option", ["Alan","Albert","Alfred"]));

    Returns string

TA_message

  • TA_message(p_strContent: string): void
  • Simple function to show some HTML and an OK button for informational purposes. The function uses TADpoLe's standard HTML Prompt set-up, but strips out the standard submit button and renames cancel to OK. This allows the prompt to still be closed by ESC, but we also don't expect to process any return. This is intended to just by a quick way to produce a pop-up information window with a lot more styling and layout control than you get with a simple JavaScript alert.

    Parameters

    • p_strContent: string

      the HTML content to be used in the prompt.

      // Example
      let obj1 = new TadHTMLPrompt;
      obj1.TA_message("<h1>Hello World</h1>");

    Returns void

TA_show

  • TA_show(): string
  • Display the HTML prompt and return the form contents as an object. The function returns an object whose properties relate to the form field IDs and can be accessed using the same name. If cancelled, the function returns undefined.

    // Example
    let obj1 = new TadHTMLPrompt;
    obj1.content = `<label for="fname">First Name:</label><input type="text" id="fnamefield" name="fname"><br>
         <label for="lname">Last Name:</label><input type="text" id="lnamefield" name="lname">`
    let objData = obj1.TA_show();
    if (objData != undefined)
    {
        alert(objData.fnamefield);
        alert(objData.lnamefield);
    }

    Returns string

TA_textFieldLarge

  • TA_textFieldLarge(p_strLabel: string, p_intLimit?: number, p_intRed?: number): string
  • Display an HTML prompt with a single large text entry field. This function must receive a label for the text field to be displayed. It may optionally also accept a maximum size for the field. If no maximum size is set, the field will use a character counter. If a maximum size is specified, the character counter will count down, and change to red once a specified number of characters is reached (the default if unspecified is 10% of the maximum number of characters that can be entered). The function may also include some initial text to be edited. The function returns the content of the field if submitted, and undefined if cancelled.

    Parameters

    • p_strLabel: string

      the label to use for the large text field.

    • Optional p_intLimit: number

      an optional limit to the number of characters that can be entered.

    • Optional p_intRed: number

      an optional specification of after how many characters a countdown will be displayed in red.

    Returns string

TA_textFields

  • TA_textFields(p_astrField: string[]): object
  • Display an HTML prompt containing multiple text entry fields. This function accepts an array of arrays. The inner arrays consist of two strings, the field label text, and the field ID. The function takes each pair of data from the outer array and builds a text field for it. The data object containing the values for each of those IDs is then returned.

    Parameters

    • p_astrField: string[]

      an array containing 2-element arrays for the field label text and the field ID.

      // Example
      let obj1 = new TadHTMLPrompt;
      let objData = obj1.TA_textFields([["First Name", "firstName"], ["Middle Name", "middleName"], ["Surname", "lastName"]]);
      alert(`My name is ${objData.firstName} ${objData.middleName} ${objData.lastName}`);

    Returns object