<!-- Source: https://docs.squirro.com/en/latest/technical/widgets/sdk/utils.html -->
# Utils

## confirm

**`class confirm()`**

**`confirm.confirmModal(message, acceptCb, refuseCb, textYes="Ok", textNo="Cancel")`**

Renders a modal dialog asking the user a yes/no question.

Arguments

- `message` (`String`) – The message that the user will be asked
- `acceptCb` (`function`) – Will be called if the user accepts
- `refuseCb` (`function`) – Will be called if the user denies
- `textYes` (`String`) – Text to be displayed in the Yes button
- `textNo` (`String`) – Text to be displayed in the No button

Returns

**View** – The view that got instanced.

**Examples:**

```js
var modal = Utils.confirmModal('Are you sure?', () => {}, () => {}, 'Sure', 'Not Really');
```

## cssEscape

**`class cssEscape()`**

**`static cssEscape.escape(string, escapeNonASCII=true)`**

Escapes a string so it can be used for CSS classes

Arguments

- `string` (`String`) – String to escape
- `escapeNonASCII` (`Boolean`) – Whether to escape non ASCII characters

Returns

**String** – Escaped string

**Examples:**

```js
var escaped = Utils.cssEscape.escape('foo');
```

## facetParser

**`class facetParser()`**

**`static facetParser.parse(query)`**

Parses the query and returns facets as a JSON object.

Arguments

- `query` (`String`) – Query to parse

Returns

**Object** – Parsed facets

**Examples:**

```js
var facets = Utils.facetParser.parse('foo:bar');
```

## itemModal

**`class itemModal()`**

**`static itemModal.ItemModalOptions()`**

Arguments

- `project` (`Model`) – The project (this.project)
- `collection` (`Collection`) – The item collection (for navigation)
- `pdfPageJump` (`Boolean`) – Whether to jump to pdf first page
- `matching` (`Boolean`) – Whether to show matching pages
- `wideModal` (`Boolean`) – Whether to make the modal wide
- `customTemplate` (`Template`) – Custom template for the modal content view
- `customTemplateParams` (`Object`) – Parameters object to pass into the custom template

**`static itemModal.open(item, options)`**

Opens a item detail modal with custom parameters

Arguments

- `item` (`String`) – Item to open
- `options` (`ItemModalOptions`) – Options

**Examples:**

```js
Utils.itemModal.open(item);
```

## queryparam

**`class queryparam()`**

**`static queryparam.parse()`**

Parses the current URL and returns the params (hash) object in the form of a JSON

Returns

**Object** – Params object

**Examples:**

```js
var params = Utils.queryparam.parse();
```
