Skip to content

Commit

Permalink
Finished transcribing most things to jade.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Mick committed Apr 15, 2015
1 parent bb33f68 commit bed870e
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 347 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
#

run:
./node_modules/grunt-cli/bin/grunt compile
./node_modules/http-server/bin/http-server _app

watch:
./node_modules/grunt-cli/bin/grunt watch
Binary file added app/img/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ body(ng-app="fastchat" layout='row' ng-controller="SidebarController")
md-toolbar
h1.md-toolbar-tools
a(ng-href='/' layout='row' flex)
img#hero-image(src='img/fastchat.png')
div(style={'line-height':'40px', 'text-indent':'15px'}) Documentation
img#hero-image(src='img/FastChat-120.png')
div(style={'line-height':'40px', 'text-indent':'15px'}) FastChat

md-content(style={'overflow': 'auto'})
ul.docs-menu
Expand All @@ -27,11 +27,12 @@ body(ng-app="fastchat" layout='row' ng-controller="SidebarController")
md-toolbar
div.md-toolbar-tools(ng-click="openMenu()")
button.menu-icon(hide-gt-sm aria-label="Toggle Menu")
img(src= root + 'img/menu.png')
img(src='img/menu.png')

md-content#main-content.md-padding(ng-view md-scroll-y flex)


script(src='//localhost:35729/livereload.js')
script(src='js/scripts/compiled.js')
script(src='js/app.js')
script(src='js/controllers/sidebar_controller.js')
81 changes: 65 additions & 16 deletions app/js/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,69 @@ fastchat.filter 'reverse', ->
(items)->
items.slice().reverse()

#
# Directive
#
fastchat.directive 'fileread', [->
scope:
fileread: "="
link: (scope, element, attributes)->
element.bind 'change', (changeEvent)->
reader = new FileReader()
reader.onload = (loadEvent)->
scope.$apply ->
scope.fileread = loadEvent.target.result
reader.readAsDataURL(changeEvent.target.files[0])
]
fastchat.factory 'menu', [
'$location',
'$rootScope',
'$anchorScroll',
'$routeParams',
'$timeout',
($location, $rootScope, $anchorScroll, $routeParams, $timeout)->

sections = [
{
hash: 'chat'
url: 'views/chat.html'
name: 'Chat'
type: 'link'
}
]

onLocationChange = ->
path = $location.path()
url = $location.url()
hash = $location.hash()
encodedHashIndex = url.indexOf('%23')
if(encodedHashIndex > 0)
hash = url.substr(encodedHashIndex + 3)
url = url.substr(0, encodedHashIndex)
urlWithoutHash = if hash then url.replace("##{hash}", '') else url

matchPage = (section, page)->
if path is page.url or "#{path}/index" is page.url
self.selectSection(section)

sections.forEach (section)->
if section?.url is urlWithoutHash
console.log 'found it', section
self.selectSection(section)
$timeout ->
$location.hash($routeParams.scrollTo)
$anchorScroll()
, 100

$rootScope.$on('$locationChangeSuccess', onLocationChange)

self = {
sections: sections

selectSection: (section)->
self.openedSection = section

toggleSelectSection: (section)->
self.openedSection = if self.openedSection is section then null else section

isSectionSelected: (section)->
self.openedSection is section

selectPage: (section, page)->
page and page.url and $location.path(page.url)
self.currentSection = section
self.currentPage = page

isPageSelected: (page)->
self.currentPage is page
}
]

#
# Routes
Expand All @@ -42,6 +91,6 @@ fastchat.config ($routeProvider, $locationProvider)->
redirectTo: '/'
}

fastchat.run (api, authService)->
fastchat.run ->
console.log('Root Running')
authService.init(api, ['/chat', '/group'])
# authService.init(api, ['/chat', '/group'])
23 changes: 23 additions & 0 deletions app/js/controllers/sidebar_controller.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

fastchat.controller 'SidebarController', ($scope, $location, menu)->
$scope.menu = menu
$scope.selectedContext = "apps"

@isSelected = (page)->
menu.isPageSelected(page)

@isOpen = (section)->
menu.isSectionSelected(section)

@toggleOpen = (section)->
menu.toggleSelectSection(section)

$scope.closeMenu = ->
$timeout( -> $mdSidenav('left').close() )

$scope.openMenu = ->
$timeout( -> $mdSidenav('left').open() )

$scope.noIndexFilter = @noIndexFilter = (item)->
item.name isnt 'index'
49 changes: 0 additions & 49 deletions app/views/chat.html

This file was deleted.

28 changes: 28 additions & 0 deletions app/views/chat.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#wrapper
section(ng-controller='ChatController')
#sidebar-wrapper
ul.sidebar-nav
li.sidebar-brand
| Groups
li(ng-repeat='group in groups | orderBy:lastMessage.sent')
a.no-wrap(href='#/chat/{{$index}}') {{ group.groupName(); }}
#page-content-wrapper
.container-fluid
h2.no-wrap {{ currentGroup.groupName() }}
#chatbox(scroll-glue='')
div(ng-repeat='message in messages.slice().reverse()')
div.chat-bubble(class="{{ message.from == profile._id ? 'me' : 'not-me' }}")
div(class="{{ message.from == profile._id ? 'my-avatar' : 'person'}}")
img.avatar(src='{{ avatars[message.from] }}')
p {{ currentGroup.usernameFromId(message.from) }}
.attachment(ng-if='message.hasMedia == true')
.spinner(ng-if='media[message._id] == undefined')
.double-bounce1
.double-bounce2
div(ng-if='media[message._id] != undefined')
img.user-attachment(src='{{ media[message._id] }}')
p.chat-text(ng-bind-html='message.toHTML()')
// End Chat Box
div
textarea#chat-input(placeholder='Send a FastChat...', ng-model='messageText', ng-keypress='handleEnter($event)')
a.btn.btn-info.send(ng-click='chat()') Send
20 changes: 0 additions & 20 deletions app/views/footer.html

This file was deleted.

17 changes: 17 additions & 0 deletions app/views/footer.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
footer.footer-3
.container
.row.v-center
.col-sm-2
a.brand(href='/index.html') FastChat
.col-sm-7
.additional-links
| Be sure to take a look to our
a(href='#') Terms of Use
| and
a(href='#/privacy') Privacy Policy
.col-sm-3
h6 Boston, MA
.address
| Address Here st number
br
| Boston, MA, 11111
88 changes: 0 additions & 88 deletions app/views/index.html

This file was deleted.

Empty file added app/views/index.jade
Empty file.
Loading

0 comments on commit bed870e

Please sign in to comment.