Skip to content

Commit

Permalink
Passes cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeymckay committed Nov 9, 2011
1 parent ca7105a commit 8cecb06
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 150 deletions.
37 changes: 28 additions & 9 deletions app/_attachments/css.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,33 @@ $("head").append "
font-size: 150%;
}
legend{
font-weight: bold;
}
fieldset fieldset legend{
font-weight: normal;
}
label{
display: block;
}
fieldset{
border-width: 1px;
border-style: solid;
margin: 5px;
padding: 5px;
}
fieldset[data-type=horizontal] label{
display: inline;
}
fieldset[data-type=horizontal] input{
margin-right:20px;
}
span.timer-seconds{
float:right;
margin-right:10px;
Expand All @@ -44,8 +67,8 @@ $("head").append "
}
.grid{
text-align: center;
float: left;
text-align: center;
width: 50px;
height: 50px;
margin: 3px;
Expand Down Expand Up @@ -82,20 +105,16 @@ $("head").append "
border-style: solid;
}
@media screen and (orientation:portrait){
.grid-width{
width: 360px;
}
}
@media screen and (orientation:landscape) {
.grid-width{
width: 670px;
}
.toggle-row-portrait{
display: none;
}
}
.grid-row{
display: block;
}
.toggle-row{
background-color: #{blue};
width: 30px;
Expand Down
2 changes: 1 addition & 1 deletion app/_attachments/css.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/_attachments/egra.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ $(document).ready ->
<a data-ajax='false' data-role='button' href='#{document.location.pathname}?role=enumerator'>My completed assessments</a>
<a data-ajax='false' data-role='button' href='#{document.location.pathname}?Assessment.The Gambia EGRA May 2011'>Start assessment</a>
"
$.mobile.initializePage()
return

switch document.location.search
Expand Down Expand Up @@ -95,7 +94,6 @@ EarlyGradeReadingAssessment.showMenu = (message = "") ->
#{documents.join("<br/>")}
</div>
"
$.mobile.initializePage()
error: ->
throw "Could not GET #{url}"

Expand Down Expand Up @@ -167,6 +165,7 @@ EarlyGradeReadingAssessment.loadFromCouch = (path) ->
$("div[data-role='page']").hide()
assessment.currentPage = assessment.pages[0]
$("##{assessment.currentPage.pageId}").show()
$("##{assessment.currentPage.pageId}").trigger("pageshow")

_.each $('button:contains(Next)'), (button) ->
new MBP.fastButton button, ->
Expand Down
5 changes: 2 additions & 3 deletions app/_attachments/egra.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ $(document).ready(function() {
switch ($.deparam.querystring().role) {
case "enumerator":
$("div[data-role='content']").html(" <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?role=enumerator'>My completed assessments</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.The Gambia EGRA May 2011'>Start assessment</a> ");
$.mobile.initializePage();
return;
}
switch (document.location.search) {
Expand Down Expand Up @@ -76,8 +75,7 @@ EarlyGradeReadingAssessment.showMenu = function(message) {
}
return _results;
})();
$("div[data-role='content']").html(" " + message + " <!-- <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.EGRA Prototype'>Load 'Assessment.EGRA Prototype' from Couch</a> --> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.The Gambia EGRA May 2011'>Load sample assessment</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.Test'>Demo single subtest</a> <!-- <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?deleteFromCouch=true'>Delete all 'Assessment.EGRA' documents from Couch</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?loadFromTestDataSaveToCouch=true'>Load from Test Data Save To Couch</a> --> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?SyncToCentral=true'>Send local results to TangerineCentral.com</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?SyncFromCentral=true'>Update system</a> <a data-ajax='false' data-role='button' href='csv.html?database=the-gambia-egra-may-2011'>Download aggregated results as CSV file (spreadsheet format)</a> <a data-ajax='false' data-role='button' href='/egra/_design/tangerine-cloud/index.html'>Create/edit assessments</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?compact=true'>Compact database</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?printout=true'>Generate printout</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?studentPrintout=true'>Student printout</a> <div data-role='collapsible' data-collapsed='true'> <h3>Documents</h3> " + (documents.join("<br/>")) + " </div> ");
return $.mobile.initializePage();
return $("div[data-role='content']").html(" " + message + " <!-- <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.EGRA Prototype'>Load 'Assessment.EGRA Prototype' from Couch</a> --> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.The Gambia EGRA May 2011'>Load sample assessment</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?Assessment.Test'>Demo single subtest</a> <!-- <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?deleteFromCouch=true'>Delete all 'Assessment.EGRA' documents from Couch</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?loadFromTestDataSaveToCouch=true'>Load from Test Data Save To Couch</a> --> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?SyncToCentral=true'>Send local results to TangerineCentral.com</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?SyncFromCentral=true'>Update system</a> <a data-ajax='false' data-role='button' href='csv.html?database=the-gambia-egra-may-2011'>Download aggregated results as CSV file (spreadsheet format)</a> <a data-ajax='false' data-role='button' href='/egra/_design/tangerine-cloud/index.html'>Create/edit assessments</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?compact=true'>Compact database</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?printout=true'>Generate printout</a> <a data-ajax='false' data-role='button' href='" + document.location.pathname + "?studentPrintout=true'>Student printout</a> <div data-role='collapsible' data-collapsed='true'> <h3>Documents</h3> " + (documents.join("<br/>")) + " </div> ");
}, this),
error: function() {
throw "Could not GET " + url;
Expand Down Expand Up @@ -118,6 +116,7 @@ EarlyGradeReadingAssessment.loadFromCouch = function(path) {
$("div[data-role='page']").hide();
assessment.currentPage = assessment.pages[0];
$("#" + assessment.currentPage.pageId).show();
$("#" + assessment.currentPage.pageId).trigger("pageshow");
_.each($('button:contains(Next)'), function(button) {
return new MBP.fastButton(button, function() {
return assessment.nextPage();
Expand Down
23 changes: 11 additions & 12 deletions app/_attachments/models/assessment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ class Assessment
result = for page,i in @pages
page.render()
result = result.join("")
result += "
<div data-role='dialog' id='_infoPage'>
<div data-role='header'>
<h1>Information</h1>
</div>
<div data-role='content'>
</div><!-- /content -->
</div>
"
# result += "
# <div data-role='dialog' id='_infoPage'>
# <div data-role='header'>
# <h1>Information</h1>
# </div>
# <div data-role='content'>
# </div><!-- /content -->
# </div>
# "
callback(result) if callback?
return result

Expand Down Expand Up @@ -255,13 +255,15 @@ class Assessment
page.pageId == @currentPage.nextPage
$("##{@currentPage.pageId}").show()
window.scrollTo(0,0)
$("##{@currentPage.pageId}").trigger("pageshow")

backPage: ->
$("##{@currentPage.pageId}").hide()
@currentPage = _.find @pages, (page) =>
page.pageId == @currentPage.previousPage
$("##{@currentPage.pageId}").show()
window.scrollTo(0,0)
$("##{@currentPage.pageId}").trigger("pageshow")


Assessment.load = (url, callback) ->
Expand Down Expand Up @@ -303,7 +305,6 @@ Assessment.loadFromHTTP = (url, callback) ->
type: 'GET',
dataType: 'json',
success: (result) ->
try
assessment = new Assessment(result.name)
pages = []
for urlPath in result.urlPathsForPages
Expand All @@ -313,8 +314,6 @@ Assessment.loadFromHTTP = (url, callback) ->
pages.push result
assessment.setPages(pages)
callback(assessment) if callback?
catch error
console.log "Error in Assessment.loadFromHTTP:" + error

error: ->
throw "Failed to load: #{url}"
Expand Down
45 changes: 21 additions & 24 deletions app/_attachments/models/assessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ Assessment = (function() {
return _results;
}).call(this);
result = result.join("");
result += " <div data-role='dialog' id='_infoPage'> <div data-role='header'> <h1>Information</h1> </div> <div data-role='content'> </div><!-- /content --> </div> ";
if (callback != null) {
callback(result);
}
Expand Down Expand Up @@ -369,15 +368,17 @@ Assessment = (function() {
return page.pageId === this.currentPage.nextPage;
}, this));
$("#" + this.currentPage.pageId).show();
return window.scrollTo(0, 0);
window.scrollTo(0, 0);
return $("#" + this.currentPage.pageId).trigger("pageshow");
};
Assessment.prototype.backPage = function() {
$("#" + this.currentPage.pageId).hide();
this.currentPage = _.find(this.pages, __bind(function(page) {
return page.pageId === this.currentPage.previousPage;
}, this));
$("#" + this.currentPage.pageId).show();
return window.scrollTo(0, 0);
window.scrollTo(0, 0);
return $("#" + this.currentPage.pageId).trigger("pageshow");
};
return Assessment;
})();
Expand Down Expand Up @@ -435,27 +436,23 @@ Assessment.loadFromHTTP = function(url, callback) {
dataType: 'json',
success: function(result) {
var pages, urlPath, _i, _len, _ref;
try {
assessment = new Assessment(result.name);
pages = [];
_ref = result.urlPathsForPages;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
urlPath = _ref[_i];
url = baseUrl + urlPath;
JQueryMobilePage.loadFromHTTP({
url: url,
async: false
}, __bind(function(result) {
result.assessment = assessment;
return pages.push(result);
}, this));
}
assessment.setPages(pages);
if (callback != null) {
return callback(assessment);
}
} catch (error) {
return console.log("Error in Assessment.loadFromHTTP:" + error);
assessment = new Assessment(result.name);
pages = [];
_ref = result.urlPathsForPages;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
urlPath = _ref[_i];
url = baseUrl + urlPath;
JQueryMobilePage.loadFromHTTP({
url: url,
async: false
}, __bind(function(result) {
result.assessment = assessment;
return pages.push(result);
}, this));
}
assessment.setPages(pages);
if (callback != null) {
return callback(assessment);
}
},
error: function() {
Expand Down
Loading

0 comments on commit 8cecb06

Please sign in to comment.