diff --git a/Gemfile b/Gemfile
index 5457180..4d9d58c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,4 +2,6 @@
# the following line to use "https"
source 'http://rubygems.org'
-gem "middleman", "~>3.0.13"
\ No newline at end of file
+gem "middleman", "~>3.0.13"
+gem "haml"
+gem "sass"
\ No newline at end of file
diff --git a/Gemfile.lock b/Gemfile.lock
index c8c38bf..361ca2d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -97,4 +97,6 @@ PLATFORMS
ruby
DEPENDENCIES
+ haml
middleman (~> 3.0.13)
+ sass
diff --git a/config.rb b/config.rb
index 45fbfbd..d8a1d32 100644
--- a/config.rb
+++ b/config.rb
@@ -1,3 +1,4 @@
+require 'haml'
###
# Compass
###
diff --git a/source/index.html.erb b/source/index.html.erb
deleted file mode 100644
index 7537cd6..0000000
--- a/source/index.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
----
-title: Welcome to Middleman
----
-
-
-
Middleman is Watching
-
- <%= link_to "Read Online Documentation", "http://middlemanapp.com/" %>
-
-
\ No newline at end of file
diff --git a/source/index.html.haml b/source/index.html.haml
new file mode 100644
index 0000000..e69de29
diff --git a/source/javascripts/example.coffee b/source/javascripts/example.coffee
new file mode 100644
index 0000000..1cbeeff
--- /dev/null
+++ b/source/javascripts/example.coffee
@@ -0,0 +1,5 @@
+launcher = KeyLauncher.on 'command+j', ()->
+ alert "is jquery loaded? #{ typeof(jQuery) is undefined }"
+, requires:[
+ "http://code.jquery.com/jquery-1.9.1.min.js"
+]
diff --git a/source/javascripts/keylauncher.coffee b/source/javascripts/keylauncher.coffee
index ab44865..1877697 100644
--- a/source/javascripts/keylauncher.coffee
+++ b/source/javascripts/keylauncher.coffee
@@ -6,7 +6,7 @@
KeyLauncher.VERSION = "0.0.1"
-KeyLauncher.on = (keycommand, launchFn=->, options={})->
+KeyLauncher.on = (keycommand, launchFn, options={})->
throw "Must specify a valid key command" unless keycommand?
launcher = new KeyLauncher.Launcher
@@ -14,4 +14,5 @@ KeyLauncher.on = (keycommand, launchFn=->, options={})->
fn: launchFn || ->
requires: options.requires || []
- key(keycommand, launcher.run)
+ key keycommand, ->
+ launcher.run.call(launcher)
diff --git a/source/javascripts/keylauncher/launcher.coffee b/source/javascripts/keylauncher/launcher.coffee
index 1cc41ed..a80871c 100644
--- a/source/javascripts/keylauncher/launcher.coffee
+++ b/source/javascripts/keylauncher/launcher.coffee
@@ -1,17 +1,33 @@
+# KeyLauncher.Launcher is an internal class that sets up the dependencies
+# and then runs the specified function if they are all loaded
class window.KeyLauncher.Launcher
_dependencies: {}
constructor: (@options={})->
@fn = options.fn
@command = options.command
-
+
for dependency in @options.requires
@_dependencies[dependency] = loaded: false
+ # The run method gets triggered when the keycommand
+ # is detected, it will ensure all of the dependencies
+ # are loaded and once it is comfortable they are, then
+ # it will run the user specified method and launch the
+ # application.
+ run: ()->
+ return @onReady() if @isReady()
+
+ for dependency, status of @_dependencies when status.loaded isnt true
+ KeyLauncher.util.loadScript dependency, =>
+ @_dependencies[dependency].loaded = true
+
requires: (dependency)->
@_dependencies[dependency] =
loaded: false
+ #### Private Methods
+
isReady: ()->
ready = true
diff --git a/source/javascripts/keylauncher/loader.coffee b/source/javascripts/keylauncher/loader.coffee
index 64ffb40..d65411a 100644
--- a/source/javascripts/keylauncher/loader.coffee
+++ b/source/javascripts/keylauncher/loader.coffee
@@ -8,7 +8,7 @@ KeyLauncher.util.loadScript = (url, options={}, callback) ->
loaded = loadedScripts
timers = scriptTimers
- if _.isFunction(options) and !callback?
+ if typeof(options) is "function" and !callback?
callback = options
options = {}
diff --git a/source/layouts/layout.erb b/source/layouts/layout.erb
deleted file mode 100644
index 365985b..0000000
--- a/source/layouts/layout.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
- <%= data.page.title || "The Middleman" %>
-
- <%= stylesheet_link_tag "normalize", "all" %>
- <%= javascript_include_tag "all" %>
-
-
-
- <%= yield %>
-
-
\ No newline at end of file
diff --git a/source/layouts/layout.html.haml b/source/layouts/layout.html.haml
new file mode 100644
index 0000000..bac3962
--- /dev/null
+++ b/source/layouts/layout.html.haml
@@ -0,0 +1,6 @@
+!!!
+%html
+ %head
+ %title Keylauncher.js
+ %body
+ = javascript_include_tag 'keylauncher', 'example'
\ No newline at end of file