PluginProbe
Extendify / 0.6.0
Extendify v0.6.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / util / general.js

general.js in Extendify 0.6.0, at src/util/general.js

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { isString, toLower } from 'lodash'
2 import { useUserStore } from '@extendify/state/User'
3
4 /**
5 * Will check if the given string contains the search string
6 *
7 * @param {string} string
8 * @param {string} searchString
9 */
10
11 export function search(string, searchString) {
12 // type validation
13 if (!isString(string) || !isString(searchString)) {
14 return false
15 }
16
17 // changing case
18 string = toLower(string)
19 searchString = toLower(searchString)
20
21 // comparing
22 return -1 !== searchString.indexOf(string) ? true : false
23 }
24
25 export const openModal = (source) => setModalVisibility(source, 'open')
26 // export const closeModal = () => setModalVisibility('', 'close')
27 export function setModalVisibility(source = 'broken-event', state = 'open') {
28 useUserStore.setState({
29 entryPoint: source,
30 })
31 window.dispatchEvent(
32 new CustomEvent(`extendify::${state}-library`, {
33 detail: source,
34 bubbles: true,
35 }),
36 )
37 }
38
39 export function getPluginDescription(plugin) {
40 switch (plugin) {
41 case 'editorplus':
42 return 'Editor Plus'
43 case 'ml-slider':
44 return 'MetaSlider'
45 }
46 return plugin
47 }
48
49 export function getTaxonomyName(key) {
50 switch (key) {
51 case 'siteType':
52 return 'Site Type'
53 case 'patternType':
54 return 'Content'
55 case 'layoutType':
56 return 'Page Types'
57 }
58 return key
59 }
60