Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new CoffeeScript #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,10 @@ Then, when you open Inkscape, go to File > New, and choose InteractiveMockup fro
MagicMarkup is written in CoffeeScript and uses jQuery. You'll
need CoffeeScript installed to develop.

You may install CoffeeScript either via:
You may install CoffeeScript via:

gem install coffee-script
npm install coffeescript

...or...

npm install coffee-script

...Depending on if you are using Ruby & Gem or Node.js & NPM.
As CoffeeScript is JavaScript, we suggest installing Node.js
and using `npm` for installation.

Build magicmockup.js using `cake build` - this will compile magicmockup.coffee and concatenate it with the dependencies in the deps/ directory.

There is a really simple script included for helping you to
Expand Down
24 changes: 13 additions & 11 deletions magicmockup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ = @jQuery
# Do the heavy lifting
# (right now, there's only "next" for switching pages; more to come)
_dispatch = (context, [command, val]) ->
act =
act = {
load: (url) ->
url = url.shift()
window.location = url || val
Expand All @@ -57,7 +57,7 @@ $ = @jQuery
location = '' if location is defaultLayer

window.location.hash = location

show: (show_layers) ->
for layer in show_layers
$(layers[layer]).show()
Expand All @@ -80,9 +80,10 @@ $ = @jQuery
time = parseInt(time) * 1000
$(layers[layer])
.attr('opacity', 1)
.animate svgOpacity: 0.0, time, easing, () ->
# Reset opacity but hide
.animate { svgOpacity: 0.0 }, time, easing, () ->
# Reset opacity but hide
$(this).hide().attr 'opacity', 1
}

params = val?.split ','
act[command]?(params)
Expand Down Expand Up @@ -167,13 +168,13 @@ $ = @jQuery
# Alter hover CSS if there's a hover filter
if filter.hover
hover = if isHovered then "url(##{filter.hover})" else "none"
$this.css filter: hover
$this.css({ filter: hover })

# Skip if already hoverable
return if $this.data('hoverable')

# We're handling the hoverable state now
$this.data('hoverable', true).css(cursor: 'pointer')
$this.data('hoverable', true).css({ cursor: 'pointer' })

return

Expand All @@ -187,13 +188,14 @@ $ = @jQuery

$(window).bind 'hashchange', _showLayer

$doc.delegate 'g'
click : _handleClick
hover : _handleHover
$doc.delegate 'g', {
click: _handleClick
hover: _handleHover
}


{init} # Public exports
{ init } # Public exports


# Hack to attach the init to <svg/> for an unobtrusive SVG onload
$('svg').attr onload: 'magicmockup.init()'
$('svg').attr { onload: 'magicmockup.init()' }
Loading