changed loading state to occur on submit button (previously on the dropdown)

This commit is contained in:
Victor Nguyen 2013-03-04 23:11:33 +11:00
parent 6e01d0bdca
commit 419c9ea354
2 changed files with 12 additions and 8 deletions

View file

@ -25,7 +25,7 @@
function _handleSelect (e) { function _handleSelect (e) {
e.preventDefault(); e.preventDefault();
_setSelectedModel(this); _setSelectedModel(this);
_reset(model.name); _setSelectLabel(model.name);
} }
function _handleSubmit(e) { function _handleSubmit(e) {
@ -41,12 +41,17 @@
.data.fetch( model.slug, _getModifier(), _isMinified() ) .data.fetch( model.slug, _getModifier(), _isMinified() )
.then(function(response) { .then(function(response) {
CREPE.results.init(model, response); CREPE.results.init(model, response);
_reset(model.name); _setSelectLabel(model.name);
_setReady();
}); });
} }
function _setLoading (label) { function _setLoading(label) {
$trigger.button('loading'); $submit.button('loading');
}
function _setReady() {
$submit.button('complete');
} }
function _setSelectedModel(option) { function _setSelectedModel(option) {
@ -71,11 +76,10 @@
return $modifier.val(); return $modifier.val();
} }
function _reset (label) { function _setSelectLabel (label) {
var defaultLabel = 'Select a model', var defaultLabel = 'Select a model',
spacing = '   '; spacing = '   ';
$trigger $trigger
.button('reset')
.html((label || defaultLabel) + spacing) .html((label || defaultLabel) + spacing)
.append('<span class="caret"></span>'); .append('<span class="caret"></span>');
} }

View file

@ -7,7 +7,7 @@ block content
p Welcome to #{title}. That that was redudant tag line. p Welcome to #{title}. That that was redudant tag line.
form#form-specs.form-inline form#form-specs.form-inline
div#dropdown.btn-group div#dropdown.btn-group
a.btn.btn-large.dropdown-toggle(data-toggle='dropdown', data-loading-text='Fetching specs...', data-complete-text='', href='#') Select a model&nbsp;&nbsp;&nbsp; a.btn.btn-large.dropdown-toggle(data-toggle='dropdown', href='#') Select a model&nbsp;&nbsp;&nbsp;
span.caret span.caret
ul.dropdown-menu ul.dropdown-menu
each model in models each model in models
@ -18,7 +18,7 @@ block content
label#minified.checkbox label#minified.checkbox
input(type='checkbox', checked) input(type='checkbox', checked)
| Minified output | Minified output
button#submit.btn.btn-primary.btn-large Get Specs button#submit.btn.btn-primary.btn-large(data-loading-text='Fetching specs...', data-complete-text='Get Specs') Get Specs
div#results.row-fluid div#results.row-fluid
div.span4 div.span4
h3 Model Name h3 Model Name