fuck yeah, flash messages

This commit is contained in:
Sven Fuchs 2012-10-09 15:16:54 +02:00
parent 9237770180
commit 847c120bd7
12 changed files with 50 additions and 34 deletions

View File

@ -43,7 +43,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-api.git
revision: 5d9c867142162b20d8471530f7447bd4af93c0e4
revision: 18bffa246014e0ae380734277eb180021f1eb2b4
specs:
travis-api (0.0.1)
backports (~> 2.5)
@ -61,7 +61,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-core.git
revision: adaa3d48f48a2a002827a2f15078323e53be1d10
revision: 45cb3ef8222af247c862e4b8a31c7033927d7048
branch: sf-travis-api
specs:
travis-core (0.0.1)

View File

@ -1,5 +1,5 @@
require 'travis/log'
require 'emoij'
require 'config/emoij'
@Travis.Helpers =
compact: (object) ->

View File

@ -1,2 +1,6 @@
{{#each flash in controller}}
{{#view Travis.FlashItemView flashBinding="flash"}}
<p>{{view.message}}</p>
<a class="close" {{action close target="view"}}></a>
{{/view}}
{{/each}}

View File

@ -1,11 +1,25 @@
@Travis.reopen
FlashView: Travis.View.extend
elementId: 'flash'
tagName: 'ul'
templateName: 'layouts/flash'
countBinding: 'controller.length'
flashBinding: 'controller.firstObject'
classNameBindings: ['flash.type']
messageBinding: 'flash.message'
display: (->
@set('classNames', if @get('count') == 0 then [] else ['display'])
).observes('count')
FlashItemView: Travis.View.extend
tagName: 'li'
classNameBindings: ['type']
type: (->
@get('flash') && Ember.keys(@get('flash'))[0]
).property('flash')
message: (->
@get('flash') && @get('flash')[@get('type')]
).property('flash')
close: (event) ->
@get('controller').shiftObject()
@get('controller').removeObject(@get('flash'))

View File

@ -28,12 +28,9 @@ jQuery.support.cors = true
if options.data && method != 'GET' && method != 'get'
options.data = JSON.stringify(options.data)
if options.success
success = options.success
success = options.success || (->)
options.success = (data) =>
if Travis.app?.router && data.flash
console.log(data.flash)
Travis.app.router.flashController.pushObject(data.flash)
Travis.app.router.flashController.pushObjects(data.flash) if Travis.app?.router && data.flash
delete data.flash
success.call(this, data)

View File

@ -49,12 +49,13 @@ require 'ext/ember/namespace'
$ =>
app.initialize()
app.router.flashController.pushObject({ error: 'error!' })
loadConfig: (callback) ->
@ajax.get '/config', (data) =>
$.extend @config, data.config
console.log "Connecting to #{data.config.api_endpoint}"
callback(data.config)
require 'travis/ajax'
require 'app'

View File

@ -3,22 +3,22 @@
#flash
display: none
margin: -20px -40px 20px -30px
padding: 15px 40px 15px 30px
color: gray
font-weight: bold
border-bottom: 1px solid $color-border-light
@include box-shadow(transparent 0 0 0 0, $color-border-normal 0 1px 6px 0, transparent 0 0 0 0, transparent 0 0 0 0)
&.success, &.notice, &.error
display: block
li
position: relative
padding: 15px 40px 15px 30px
&.success
.success
background-color: #ebfcc2
&.notice
.notice
background-color: lightGoldenrodYellow
&.error
.error
background-color: #f5d7d3
p

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -958,7 +958,6 @@ li {
#flash {
display: none;
margin: -20px -40px 20px -30px;
padding: 15px 40px 15px 30px;
color: gray;
font-weight: bold;
border-bottom: 1px solid #dddddd;
@ -966,9 +965,10 @@ li {
-moz-box-shadow: transparent 0 0 0 0, #cccccc 0 1px 6px 0, transparent 0 0 0 0, transparent 0 0 0 0;
box-shadow: transparent 0 0 0 0, #cccccc 0 1px 6px 0, transparent 0 0 0 0, transparent 0 0 0 0;
}
/* line 12, /Users/sven/Development/projects/travis/travis-web/assets/styles/app/flash.sass */
#flash.success, #flash.notice, #flash.error {
display: block;
/* line 11, /Users/sven/Development/projects/travis/travis-web/assets/styles/app/flash.sass */
#flash li {
position: relative;
padding: 15px 40px 15px 30px;
}
/* line 15, /Users/sven/Development/projects/travis/travis-web/assets/styles/app/flash.sass */
#flash .success {

View File

@ -1 +1 @@
3c986040
5643087a