Skip to content

Instantly share code, notes, and snippets.

@jansanchez
Last active December 12, 2015 18:38
Show Gist options
  • Save jansanchez/fc3de4c507dc5095a56c to your computer and use it in GitHub Desktop.
Save jansanchez/fc3de4c507dc5095a56c to your computer and use it in GitHub Desktop.
modulo yOSON: reset_cookie
###
Módulo para resetear la cookie de busqueda
@module reset_cookie
@author Jan Sanchez
###
yOSON.AppCore.addModule "reset_cookie", (Sb) ->
st = {}
dom = {}
defaults = {
parent : '.list_locations'
el : 'li a'
cookieName : 'search_online'
newCookie : yOSON.tmp.cookie_online
}
catchDom = () ->
dom.parent = $(st.parent)
dom.el = $(st.el, dom.parent)
return
subscribeEvents = () ->
dom.el.on 'click', events.toReset
dom.el.on 'mouseup', events.toReset
return
events = {
toReset: (e) ->
fn.resetCookie(st.cookieName, st.newCookie)
mouseup: (e) ->
if e.which is 3 or e.which is 2
fn.resetCookie(st.cookieName, st.newCookie)
e.preventDefault()
}
fn = {
resetCookie : (cookieName, cookie) ->
fn.saveCookie(cookieName, cookie)
return
saveCookie: (cookieName, cookie) ->
Cookie.create(cookieName, JSON.stringify(cookie))
return
}
initialize = (opts) ->
st = $.extend({}, defaults, opts)
catchDom()
subscribeEvents()
return
return {
init: initialize
}
,["js/libs/jquery.validate.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment