PP.Ui.cropText2

Syntax

PP.Ui.cropText2(text1: String, text2: String, width: Number, terminator: String, separator: String, postfix: String, isRtl: boolean, node: HTMLElement);

Parameters

text1. First checked string.

text2. Second checked string.

width. Checked width.

terminator. Text inserted to the string end when checked text does not fit into the item with indicated width.

separator. Text used to separate original strings.

postfix. Text inserted to the end of cropped and merged string.

isRtl. Writing order. Argument is not used, it is required to not change method signature.

node. DOM node to insert in the text.

Description

The cropText2 method is used to merge and crop two strings if they do not fit into the item by width.

Comments

The method returns a JSON object with the following fields:

Field name Type Brief description
Text String Text of output string.
Original String Merged checked strings separated by separator with suffix at the end.
IsCroped Boolean It determines whether strings were cropped. Available values:
  • true. Strings are cropped.

  • false. Strings are not cropped.

Example

To execute the example, it is required to have link to PP.js script file. The following code is executed in the browser console. Check whether the First String and the Second String fit into the item with the 150 width. If it does not fit then a part of string which fits will be shown. At the end of each string there will be the "..." text and at the total string there will be the ! character:

console.log(PP.Ui.cropText2("First text", "Second text", 150, "...", ":", "!").Text);

As a result the console displays the result of strings truncation:

First te... Second ...!

See also:

PP.Ui