Permalink
Browse files

Fix form state

  • Loading branch information...
alexanderte committed Apr 26, 2013
1 parent ded52c0 commit a3275183dfb0ed62e5037e301e291ceec942e469
Showing with 33 additions and 51 deletions.
  1. +5 −7 frontend/index.html
  2. +3 −20 frontend/views/home.coffee
  3. +6 −6 frontend/views/home.js
  4. +8 −8 frontend/views/navbar.coffee
  5. +11 −10 frontend/views/navbar.js
View
@@ -42,7 +42,7 @@
<% if (route != 'home') { %>
<form class="navbar-form pull-right" onsubmit="return false;">
<div class="input-append">
- <input <% if (state == 'loading') { %>disabled="true"<% } %>id="web-page" type="text" placeholder="Web page" value="<%= webPage %>" class="span4">
+ <input <% if (state == 'loading') { %>disabled="true"<% } %>id="web-page" type="text" value="<%= webPage %>" class="span4">
<button <% if (state == 'loading') { %>class="btn disabled" disabled="true"<% } else { %>class="btn" <% } %> id="set-web-page" value="Set"><%= _set %></button>
</div>
</form>
@@ -58,12 +58,10 @@ <h1><%= userTestingTool %></h1>
<p class="lead"><%= description %></p>
<p class="lead"><%= enterWebPage %></p>
<form class="form-inline" onsubmit="return false;">
- <fieldset>
- <div class="input-append">
- <input id="web-page-2" type="text" placeholder="Web page" value="<%= webPage %>" class="span4 input-large">
- <button id="set-web-page-2" class="btn btn-primary"><%= startTesting %></a>
- </div>
- <fieldset>
+ <div class="input-append">
+ <input <% if (state == 'loading') { %>disabled="true"<% } %>id="web-page-2" type="text" value="<%= webPage %>" class="span4 input-large">
+ <button <% if (state == 'loading') { %>class="btn btn-primary disabled" disabled="true"<% } else { %>class="btn btn-primary" <% } %> id="set-web-page-2" value="Set"><%= startTesting %></button>
+ </div>
</form>
<hr>
<p>
View
@@ -19,22 +19,6 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
@options.testRun.bind('change:webPage', () ->
$('#web-page-2').val(@options.testRun.get('webPage'))
, this)
-
-
- #@options.testRun.bind('change:state', () ->
- # if @options.testRun.get('state') == 'loaded' or @options.testRun.get('state') == 'error'
- # $('#web-page-2').removeClass 'disabled'
- # $('#web-page-2').attr('disabled', false)
- # $('#set-web-page-2').removeClass 'disabled'
- # $('#set-web-page-2').attr('disabled', false)
- # else
- # $('#web-page-2').addClass 'disabled'
- # $('#web-page-2').attr('disabled', true)
- # $('#web-page-2').blur() # Possibly not needed here
- # $('#set-web-page-2').addClass 'disabled'
- # $('#set-web-page-2').attr('disabled', true)
-
- #, this)
render: () ->
@$el.html(_.template($('#home-template').html(), {
webPage: @options.testRun.get('webPage')
@@ -43,11 +27,10 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
enterWebPage: @options.locale.translate('home_enter_web_page')
startTesting: @options.locale.translate('home_start_testing')
reportIssue: @options.locale.translate('home_report_issue')
+ state: @options.testRun.get('state')
}))
$('#web-page-2').focus()
setWebPage: () ->
- if @options.testRun.get('webPage') == $('#web-page-2').val()
- @options.router.navigate 'test', true
- else
- @options.testRun.setWebPage($('#web-page-2').val())
+ @options.testRun.setWebPage($('#web-page-2').val())
+ @options.router.navigate 'test', { trigger: true }
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -5,19 +5,12 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
'click button#set-web-page': 'setWebPage'
'click a.language': 'changeLanguage'
}
- getCurrentRoute: () ->
- if not Backbone.history.fragment
- return 'home'
- else if Backbone.history.fragment.substr(0, 4) is 'test'
- return 'test'
- else
- return Backbone.history.fragment
-
initialize: () ->
@render()
@options.router.bind('all', @render, this)
@options.locale.on('change:locale', @render , this)
+ @options.testRun.bind('change:state', @render , this)
render: () ->
@$el.html(_.template($('#navbar-template').html(), {
webPage: @options.testRun.get('webPage'),
@@ -31,6 +24,13 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
_languageNorwegian: @options.locale.translate('navbar_language_norwegian')
_set: @options.locale.translate('navbar_set')
}))
+ getCurrentRoute: () ->
+ if not Backbone.history.fragment
+ return 'home'
+ else if Backbone.history.fragment.substr(0, 4) is 'test'
+ return 'test'
+ else
+ return Backbone.history.fragment
setWebPage: () ->
@options.testRun.setWebPage($('#web-page').val())
changeLanguage: (e) ->
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit a327518

Please sign in to comment.