balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

general.js (1169B)


      1 import { isString, toLower } from 'lodash'
      2 import { useUserStore } from '../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)
     23         ? true
     24         : false
     25 }
     26 
     27 export const openModal = (source) => setModalVisibility(source, 'open')
     28 // export const closeModal = () => setModalVisibility('', 'close')
     29 export function setModalVisibility(source = 'broken-event', state = 'open') {
     30     useUserStore.setState({
     31         entryPoint: source,
     32     })
     33     window.dispatchEvent(new CustomEvent(`extendify-sdk::${state}-library`, {
     34         detail: source,
     35         bubbles: true,
     36     }))
     37 }
     38 
     39 export function getPluginDescription(plugin) {
     40     switch (plugin) {
     41         case 'editorplus': return 'Editor Plus'
     42         case 'ml-slider': return 'MetaSlider'
     43     }
     44     return plugin
     45 }