Skip to content

Instantly share code, notes, and snippets.

@etiennetalbot
Last active December 17, 2015 12:19
Show Gist options
  • Select an option

  • Save etiennetalbot/5609005 to your computer and use it in GitHub Desktop.

Select an option

Save etiennetalbot/5609005 to your computer and use it in GitHub Desktop.
A capsule to put your CoffeeScript into.Basic OOP CoffeeScript file
window.App = window.App or {}
window.App.Module = do (document = document, window = window, $ = jQuery) ->
# Module's common variables (private)
_vars =
yThreshold: 0
windowHeight: 0
videoPlaying: null
videoToPlay: null
# Module's common elements (private)
_els = {}
# --------------------------------------------
# Sets the common elements and returns true when it's done (private)
# Function is called on init to make sure elements exist
# @Params: none
# @Returns: true
#
_setElements = ->
_els =
$links: $ 'a'
$window: $ window
$milestones: $ '.js-milestone'
$flowslidr1: $ '.js-flowslidr-1'
true
# --------------------------------------------
# Some private method
# Function is called on init and on scroll
# @Params: none
# @Returns: undefined
#
_privateMethod = ->
console.log 'hi'
return
# --------------------------------------------
# Init Common methods (public)
# Function is called on document ready
# @Params: none
# @Returns: undefined
#
init = ->
if _setElements()
# Call those methods like you mean it!!
_privateMethod()
# Events on!
# _els.$window.on 'scroll', _privateMethod
return
# Return all public methods
init: init
# Start this module
jQuery(document).on 'ready', App.Module.init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment