Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- construct:
- state.state = JSON.parse(window.localStorage.getItem('acme_products_state')) || stateReset()
- is localstorage set ? state.direction = ls.direction | state.direction = true && setState('direction',true)
- ===
- toggleDirection() state.direction = !state.direction setState('direction',!state.direction) $.event onClick $('#acme_sorter')
- getDirectionValue(): 'ASC' = true | 'DESC' = false !state.direction
- getDirectionTitle(): 'ascending' | 'descending'
- setFlag(bool): true | false
- toggleFlag(): state.flag = !state.flag
- isFlagged(): state.flag true | false
- isLoading(): state.loading true | false
- isValid(): state.valid true|false
- setValid(bool) : true|false
- setLoading(bool): bool ? state.loading = !state.loading
- setIsLoading(bool): true | false
- setMsg(str): str.length > 0 ? state.msg = str && setFlag(true) : null
- getMsg(): isFlagged() ? state.msg : null
- setDirection(direction): localstorage.set. state.direction = !state.direction
- getPostData(): object {price_from : price[from], price_to: price[to],direction}
- getFormData(): object {price_from : price[from], price_to: price[to],direction}
- resetState(): {price_from = 1, price_to = 5, direction = true, msg = '', flag = false, loading = false,}
- resetPrice(): {price_from = 1, price_to = 5}
- resetDirection(): state.direction setState('direction',true)= true
- isDirectionDefault(): state.direction = true ? true : false //means direction is desc
- setPostData(): object { price_from,price_to,direction }
- setFormData(): object { price_from,price_to,direction }
- getGqlQuery(): object //TODO
- getSearchCriteriaBuilder() object //TODO
- getPriceFrom(): int state.price.from
- getPriceTo(): int state.price.to
- setPriceFrom(priceFrom): state.price.from =
- setPriceTo(priceTo) state.price.to =
- setPrice(priceFrom,priceTo) state.price.to = priceFrom| state.price.from = priceTo
- getPrevState(): object
- setPrevState(obj): prevState = { ..state }
- getCurrentState(): self|this
- setStateSnapshot(state): setPrevState(state)
- getState(key = null): window.localstorage.getItem(key) any key{ direction|price_from|price_to|directionValue|directionTitle|msg|flag|loading|valid } | key == null ? this(class) : null
- setState(key,data): prevState = state && state = state[key] = newState localStorage.setItem('acme_products_state' = JSON.stringify(newState)
- before function
- setCall(data): setState(key,data)
- after function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement