Skip to content

Commit

Permalink
fixed; loading humane lib after dom ready
Browse files Browse the repository at this point in the history
GH #30
  • Loading branch information
wavded committed Sep 3, 2012
1 parent 7a564ce commit 58b80f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions humane.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
return function () { fn.apply(ctx,arguments) }
},
isArray: Array.isArray || function (obj) { return Object.prototype.toString.call(obj) === '[object Array]' },
domLoaded: false,
config: function (preferred, fallback) {
return preferred != null ? preferred : fallback
},
Expand Down Expand Up @@ -55,8 +54,10 @@
this.clickToClose = o.clickToClose || false
this.forceNew = o.forceNew || false

if (ENV.domLoaded) this._setupEl()
else ENV.on(win,'load',ENV.bind(this._setupEl, this))
try { this._setupEl() } // attempt to setup elements
catch (e) {
ENV.on(win,'load',ENV.bind(this._setupEl, this)) // dom wasn't ready, wait till ready
}
}

Humane.prototype = {
Expand All @@ -68,7 +69,6 @@
this.el = el
this.removeEvent = ENV.bind(this.remove,this)
this.transEvent = ENV.bind(this._afterAnimation,this)
ENV.domLoaded = true
this._run()
},
_afterTimeout: function () {
Expand Down Expand Up @@ -104,7 +104,6 @@
if (timeout > 0)
this.currentTimer = setTimeout(ENV.bind(this._afterTimeout,this), timeout)

// events['show'](type,content,'show')
if (ENV.isArray(msg.html)) msg.html = '<ul><li>'+msg.html.join('<li>')+'</ul>'

this.el.innerHTML = msg.html
Expand Down Expand Up @@ -176,7 +175,6 @@
this.el.style.display = 'none'

this._animating = false
// events['hide'](currentMessage.type, currentMessage.message,'hide');
this._run()
},
remove: function (e) {
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<html>
<head>
<title>humane.js</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" >
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta charset='utf-8'>
<link href='http://fonts.googleapis.com/css?family=Ubuntu&v2' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Cabin+Sketch:700&v2' rel='stylesheet' type='text/css'>
Expand Down

0 comments on commit 58b80f3

Please sign in to comment.