Permalink
Browse files

Now url updates with location.replace and does not polute browser his…

…tory
  • Loading branch information...
1 parent 0159189 commit 54e380dcc46b2d7278437d3342c4cf7e9e6e6ae5 @imathis committed Mar 14, 2013
Showing with 11 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +10 −0 assets/javascripts/modules/site.coffee
View
@@ -2,3 +2,4 @@
.sass-cache
_site
stylesheets
+javascripts/hslpicker.js
@@ -68,6 +68,8 @@ site = Backbone.View.extend
input=$('.url')
url = "#{host}/#{hash}"
+ update = @throttle ((h)-> window.location.replace(h)), 300
+ update(hash)
width = url.length*7.8
input.css width: width
input.val(url)
@@ -108,6 +110,14 @@ site = Backbone.View.extend
adjustLum: (l, color=@model.hsla())->
@model.hslaStr [color[0], color[1], color[2] + 1, @model.get('a')]
+ throttle: (fn, delay=50) ->
+ timer = null
+ ->
+ context = @
+ args = arguments
+ clearTimeout timer
+ timer = setTimeout (-> fn.apply(context, args)), delay
+
module.exports = ->
color = color()
picker(model: color, el: '#picker').render()

0 comments on commit 54e380d

Please sign in to comment.