Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update stuff to brunch 1.4.

  • Loading branch information...
commit 0a7d85dce4fcc90d5d312fc856801901e542b9c0 1 parent 5915f46
Paul Miller paulmillr authored
13 app/assets/humans.txt
View
@@ -1,13 +0,0 @@
-/* the humans responsible & colophon */
-/* humanstxt.org */
-
-
-/* TEAM */
- Dev: Paul Miller
- Site: paulmillr.com
- Twitter: @paulmillr
-
-/* SITE */
- Standards: HTML5, CSS3
- Components: Brunch, Backbone.js
- Software: TextMate
6 app/assets/index.html
View
@@ -6,7 +6,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title>Example brunch application</title>
+ <title>Tweet your brunch</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="stylesheets/app.css">
<script src="javascripts/vendor.js"></script>
@@ -14,8 +14,7 @@
<script>require('initialize');</script>
</head>
<body>
- <nav class="navbar navbar-fixed-top" id="navigation-container">
- </nav>
+ <nav class="navbar navbar-fixed-top" id="navigation-container"></nav>
<div class="container outer-container">
<div id="page-container" class="row">
@@ -24,7 +23,6 @@
<div class="module span7 main-content" id="content-container">
</div>
</div>
- <div id="fb-root"></div>
</div>
</body>
</html>
2  app/models/status.coffee
View
@@ -20,4 +20,4 @@ module.exports = class Status extends Model
window.clearTimeout(timeout)
mediator.publish 'tweet:add', tweet.attributes
options.success(tweet.attributes)
- return
+ return
0  app/styles/main.styl → app/styles/application.styl
View
File renamed without changes
9 app/views/tweets_view.coffee
View
@@ -1,7 +1,7 @@
mediator = require 'mediator'
CollectionView = require 'chaplin/views/collection_view'
-TweetView = require './tweet_view'
-template = require './templates/tweets'
+TweetView = require 'views/tweet_view'
+template = require 'views/templates/tweets'
module.exports = class TweetsView extends CollectionView
template: template
@@ -28,10 +28,5 @@ module.exports = class TweetsView extends CollectionView
@$('.tweets, .tweets-header').css 'display', if mediator.user then 'block' else 'none'
render: ->
- console.log 'TweetsView#render', this, @$el
super
@showHideLoginNote()
-
- afterRender: ->
- super
- console.log 'TweetsView#afterRender', @containerSelector, $(@containerSelector)
39 config.coffee
View
@@ -1,23 +1,13 @@
exports.config =
- # Edit the next line to change default build path.
- paths:
- public: 'public'
-
+ # See http://brunch.readthedocs.org/en/latest/config.html for documentation.
files:
javascripts:
- # Defines what file will be generated with `brunch generate`.
defaultExtension: 'coffee'
- # Describes how files will be compiled & joined together.
- # Available formats:
- # * 'outputFilePath'
- # * map of ('outputFilePath': /regExp that matches input path/)
- # * map of ('outputFilePath': function that takes input path)
joinTo:
'javascripts/app.js': /^app/
'javascripts/vendor.js': /^vendor/
- # Defines compilation order.
- # `vendor` files will be compiled before other ones
- # even if they are not present here.
+ 'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
+ 'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/
order:
before: [
'vendor/scripts/console-helper.js',
@@ -28,25 +18,14 @@ exports.config =
stylesheets:
defaultExtension: 'styl'
- joinTo: 'stylesheets/app.css'
+ joinTo:
+ 'stylesheets/app.css': /^(app|vendor)/
+ 'test/stylesheets/test.css': /^test/
order:
- before: [
- 'vendor/styles/bootstrap.css'
- ]
+ before: ['vendor/styles/bootstrap.css']
templates:
- defaultExtension: 'eco'
+ defaultExtension: 'hbs'
joinTo: 'javascripts/app.js'
- # Change this if you're using something other than backbone (e.g. 'ember').
- # Content of files, generated with `brunch generate` depends on the setting.
- # framework: 'backbone'
-
- # Settings of web server that will run with `brunch watch [--server]`.
- # server:
- # # Path to your server node.js module.
- # # If it's commented-out, brunch will use built-in express.js server.
- # path: 'server.coffee'
- # port: 3333
- # # Run even without `--server` option?
- # run: yes
+ framework: 'chaplin'
26 package.json
View
@@ -9,25 +9,27 @@
"url": ""
},
"engines": {
- "node": "~0.6.10"
+ "node": "~0.6.10 || 0.8 || 0.9"
},
"scripts": {
- "start": "brunch watch --server"
+ "start": "brunch watch --server",
+ "test": "brunch test"
},
"dependencies": {
- "javascript-brunch": "1.0.x || 1.1.x",
- "coffee-script-brunch": "1.0.x || 1.1.x",
+ "javascript-brunch": ">= 1.0 < 1.5",
+ "coffee-script-brunch": ">= 1.0 < 1.5",
- "css-brunch": "1.0.x || 1.1.x",
- "stylus-brunch": "1.0.x || 1.1.x",
+ "css-brunch": ">= 1.0 < 1.5",
+ "stylus-brunch": ">= 1.0 < 1.5",
- "handlebars-brunch": "1.0.x || 1.1.x",
-
- "uglify-js-brunch": "1.0.x || 1.1.x",
- "clean-css-brunch": "1.0.x || 1.1.x"
+ "handlebars-brunch": ">= 1.0 < 1.5",
+
+ "uglify-js-brunch": ">= 1.0 < 1.5",
+ "clean-css-brunch": ">= 1.0 < 1.5"
},
"devDependencies": {
- "mocha": "0.14.0",
- "expect.js": "0.1.2"
+ "chai": "1.2.0",
+ "sinon": "1.4.2",
+ "sinon-chai": "2.1.2"
}
}
88 vendor/scripts/chaplin-2dc3b2.coffee → vendor/scripts/chaplin-1.0.0-pre-f79b50a.coffee
View
@@ -275,7 +275,7 @@ require.define 'chaplin/dispatcher': (exports, require, module) ->
# Change the URL to the new controller using the router
adjustURL: (controller, params) ->
- if params.path
+ if params.path or params.path is ''
# Just use the matched path
url = params.path
@@ -460,6 +460,8 @@ require.define 'chaplin/models/collection': (exports, require, module) ->
# Insert new model
@add model, at: i
+ return
+
# Disposal
# --------
@@ -567,7 +569,7 @@ require.define 'chaplin/models/model': (exports, require, module) ->
# (i.e. an object which has the attributes as prototype)
# so primitive values might be added and altered safely.
# Map models to their attributes, recursively.
- serialize: (model) ->
+ serialize: ->
serializeAttributes this, @getAttributes()
# Disposal
@@ -646,6 +648,7 @@ require.define 'chaplin/views/layout': (exports, require, module) ->
@title = options.title
@settings = _(options).defaults
routeLinks: true
+ # Per default, jump to the top of the page
scrollTo: [0, 0]
# Listen to global events: Starting and disposing of controllers
@@ -672,8 +675,10 @@ require.define 'chaplin/views/layout': (exports, require, module) ->
# Handler for the global beforeControllerDispose event
hideOldView: (controller) ->
- # Jump to the top of the page
- scrollTo @settings.scrollTo if @settings.scrollTo
+ # Reset the scroll position
+ scrollTo = @settings.scrollTo
+ if scrollTo
+ window.scrollTo scrollTo[0], scrollTo[1]
# Hide the current view
view = controller.view
@@ -717,18 +722,29 @@ require.define 'chaplin/views/layout': (exports, require, module) ->
return if utils.modifierKeyPressed(event)
el = event.currentTarget
- href = el.getAttribute 'href'
- # Ignore empty paths even if it is a valid relative URL
- # Ignore links to fragment identifiers
- return if href is null or
+ $el = $(el)
+ href = $el.attr 'href'
+ protocol = el.protocol
+
+ protocolIsExternal = if protocol
+ protocol not in ['http:', 'https:', 'file:']
+ else
+ false
+
+ # Ignore external URLs.
+ # Technically an empty string is a valid relative URL
+ # but it doesn’t make sense to route it.')
+ return if href is undefined or
href is '' or
href.charAt(0) is '#' or
- $(el).hasClass('noscript')
+ protocolIsExternal or
+ $el.attr('target') is '_blank' or
+ $el.attr('rel') is 'external' or
+ $el.hasClass('noscript')
# Is it an external link?
- currentHostname = location.hostname.replace('.', '\\.')
- external = not ///#{currentHostname}$///i.test(el.hostname)
- if external
+ internal = el.hostname is '' or location.hostname is el.hostname
+ unless internal
# Open external links normally
# You might want to enforce opening in a new tab here:
#event.preventDefault()
@@ -1009,7 +1025,7 @@ require.define 'chaplin/views/view': (exports, require, module) ->
pass: (attribute, selector) ->
@modelBind "change:#{attribute}", (model, value) =>
$el = @$(selector)
- if $el.is(':input')
+ if $el.is('input, textarea, select, button')
$el.val value
else
$el.text value
@@ -1204,6 +1220,12 @@ require.define 'chaplin/views/collection_view': (exports, require, module) ->
# Animation duration in milliseconds (set to 0 to disable fade in)
animationDuration: 500
+ # By default, fading in is done by javascript function which can be
+ # slow on mobile devices. CSS animations are faster,
+ # but require user's manual definitions.
+ # CSS classes used are: animated-item-view, animated-item-view-end.
+ useCssAnimation: false
+
# A collection view may have a template and use one of its child elements
# as the container of the item views. If you specify `listSelector`, the
# item views will be appended to this element. If empty, $el is used.
@@ -1452,7 +1474,7 @@ defined (or the getView() must be overridden)'
view = @viewsByCid[item.cid]
if view
# Re-insert the view
- @insertView item, view, index, 0
+ @insertView item, view, index, false
else
# Create a new view, render and insert it
@renderAndInsertItem item, index
@@ -1483,7 +1505,7 @@ defined (or the getView() must be overridden)'
view
# Inserts a view into the list at the proper position
- insertView: (item, view, index = null, animationDuration = @animationDuration) ->
+ insertView: (item, view, index = null, enableAnimation = true) ->
# Get the insertion offset
position = if typeof index is 'number'
index
@@ -1502,8 +1524,11 @@ defined (or the getView() must be overridden)'
if included
# Make view transparent if animation is enabled
- $viewEl.addClass 'opacity-transitionable' if animationDuration
- $viewEl.css 'opacity', 0 if animationDuration
+ if enableAnimation
+ if @useCssAnimation
+ $viewEl.addClass 'animated-item-view'
+ else
+ $viewEl.css 'opacity', 0
else
# Hide the view if it’s filtered
$viewEl.css 'display', 'none'
@@ -1534,9 +1559,16 @@ defined (or the getView() must be overridden)'
@updateVisibleItems item, included
# Fade the view in if it was made transparent before
- if animationDuration and included
- $viewEl.addClass 'opacity-transitionable-end'
- $viewEl.animate {opacity: 1}, animationDuration
+ if enableAnimation and included
+ if @useCssAnimation
+ # Wait for DOM state change.
+ setTimeout =>
+ $viewEl.addClass 'animated-item-view-end'
+ , 0
+ else
+ $viewEl.animate {opacity: 1}, @animationDuration
+
+ return
# Remove the view for an item
removeViewForItem: (item) ->
@@ -1658,7 +1690,7 @@ require.define 'chaplin/lib/route': (exports, require, module) ->
# Save parameter name
@paramNames.push paramName
# Replace with a character class
- '([^\/]+)'
+ '([^\/\?]+)'
# Test if the route matches to a path (called by Backbone.History#loadUrl)
test: (path) ->
@@ -1800,12 +1832,14 @@ require.define 'chaplin/lib/router': (exports, require, module) ->
# Connect an address with a controller action
# Directly create a route on the Backbone.History instance
match: (pattern, target, options = {}) =>
-
- # Create a route
+ # Create the route
route = new Route pattern, target, options
-
- # Register the route at the Backbone.History instance
- Backbone.history.route route, route.handler
+ # Register the route at the Backbone.History instance.
+ # Don’t use Backbone.history.route here because it calls
+ # handlers.unshift, inserting the handler at the top of the list.
+ # Since we want routes to match in the order they were specified,
+ # we’re appending the route at the end.
+ Backbone.history.handlers.push {route, callback: route.handler}
# Route a given URL path manually, returns whether a route matched
# This looks quite like Backbone.History::loadUrl but it
@@ -1814,7 +1848,6 @@ require.define 'chaplin/lib/router': (exports, require, module) ->
route: (path) =>
# Remove leading hash or slash
path = path.replace /^(\/#|\/)/, ''
-
for handler in Backbone.history.handlers
if handler.route.test(path)
handler.callback path, changeURL: true
@@ -2050,6 +2083,7 @@ require.define 'chaplin/lib/utils': (exports, require, module) ->
configurable: false
(obj, properties...) ->
for prop in properties
+ readonlyDescriptor.value = obj[prop]
Object.defineProperty obj, prop, readonlyDescriptor
true
else
Please sign in to comment.
Something went wrong with that request. Please try again.