Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

Commit

Permalink
Little refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 6, 2016
1 parent 231370f commit 11a62e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 13 additions & 8 deletions assets/js/src/__init.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

window.Uno = Uno =
version: '2.6.10'

search:
container: -> $('#results')
form: (action) -> $('#search-container')[action]()

loadingBar: (action) -> $('.pace')[action]()
app: do -> document.body
is: (k, v=!'undefined') -> this.app.dataset[k] is v

context: ->
# get the context from the first class name of body
# https://github.com/TryGhost/Ghost/wiki/Context-aware-Filters-and-Helpers
className = document.body.className.split(' ')[0].split('-')[0]
if className is '' then 'error' else className

app: do -> document.body
search:
container: -> $('#results')
form: (action) -> $('#search-container')[action]()

is: (property, value) -> this.app.dataset[property] is value
loadingBar: (action) -> $('.pace')[action]()

timeAgo: (selector) ->
$(selector).each ->
Expand All @@ -38,3 +36,10 @@ window.Uno = Uno =
return 'mobile' if (w <= 480)
return 'tablet' if (w <= 1024)
'desktop'

Uno.app.dataset.page = Uno.context()
Uno.app.dataset.device = Uno.device()

$('#profile-title').text window.profile_title if window.profile_title
$('#profile-resume').text window.profile_resume if window.profile_resume

9 changes: 1 addition & 8 deletions assets/js/src/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

$ ->

$('#profile-title').text window.profile_title if window.profile_title
$('#profile-resume').text window.profile_resume if window.profile_resume

el = Uno.app
el.dataset.page = Uno.context()
el.dataset.device = Uno.device()

if Uno.is 'device', 'desktop'
$('a').not('[href*="mailto:"]').click ->
if this.href.indexOf(location.hostname) is -1
window.open $(this).attr 'href'
false
else
FastClick.attach el
FastClick.attach Uno.app

if Uno.is 'page', 'home'
Uno.timeAgo '#posts-list time'
Expand Down

0 comments on commit 11a62e5

Please sign in to comment.