Commit 61d1a0087064026650573340213f7b2e8ff51585
1 parent
3d10c1fb
Exists in
master
and in
8 other branches
UI working
Showing
3 changed files
with
24 additions
and
30 deletions
Show diff stats
js/main.js
1 | -define(['handlebars'], function(Handlebars){ | 1 | +define(['handlebars','handlebars_helpers','jquery'], function(Handlebars){ |
2 | 2 | ||
3 | 3 | ||
4 | /* global Handlebars, $ */ | 4 | /* global Handlebars, $ */ |
5 | // The template code | 5 | // The template code |
6 | - var templateSource = document.getElementById('proposal-template').innerHTML; | 6 | + var templateSource = $('#proposal-template').html(); |
7 | 7 | ||
8 | // compile the template | 8 | // compile the template |
9 | var template = Handlebars.compile(templateSource); | 9 | var template = Handlebars.compile(templateSource); |
@@ -529,6 +529,7 @@ define(['handlebars'], function(Handlebars){ | @@ -529,6 +529,7 @@ define(['handlebars'], function(Handlebars){ | ||
529 | votedProposals.push(id); | 529 | votedProposals.push(id); |
530 | } | 530 | } |
531 | $.cookie("votedProposals", JSON.stringify(votedProposals), {expires : 999 }) ; | 531 | $.cookie("votedProposals", JSON.stringify(votedProposals), {expires : 999 }) ; |
532 | + return votedProposals; | ||
532 | }, | 533 | }, |
533 | hasProposalbeenVoted: function(id) { | 534 | hasProposalbeenVoted: function(id) { |
534 | if (typeof($.cookie("votedProposals")) == "undefined") { | 535 | if (typeof($.cookie("votedProposals")) == "undefined") { |
@@ -571,29 +572,14 @@ define(['handlebars'], function(Handlebars){ | @@ -571,29 +572,14 @@ define(['handlebars'], function(Handlebars){ | ||
571 | }); | 572 | }); |
572 | }); | 573 | }); |
573 | 574 | ||
574 | - | ||
575 | - | ||
576 | - | ||
577 | - | ||
578 | - | ||
579 | - | ||
580 | - | ||
581 | - | ||
582 | - | ||
583 | - | ||
584 | - | ||
585 | - | ||
586 | if('onhashchange' in window){ | 575 | if('onhashchange' in window){ |
587 | 576 | ||
588 | window.onhashchange = function(){ | 577 | window.onhashchange = function(){ |
589 | Main.locationHashChanged.apply(Main); | 578 | Main.locationHashChanged.apply(Main); |
590 | } | 579 | } |
591 | - | ||
592 | }else{ | 580 | }else{ |
593 | console.log('The browser not supports the hashchange event!'); | 581 | console.log('The browser not supports the hashchange event!'); |
594 | } | 582 | } |
595 | 583 | ||
596 | - | ||
597 | - | ||
598 | - | 584 | + return Main; |
599 | }); | 585 | }); |
test/SpecRunner.html
@@ -7,24 +7,30 @@ | @@ -7,24 +7,30 @@ | ||
7 | <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png"> | 7 | <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png"> |
8 | <link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css"> | 8 | <link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css"> |
9 | 9 | ||
10 | - <script src="../js/require.js"></script> | ||
11 | - <script src="../js/handlebars-v3.0.1.js"></script> | ||
12 | - <script src="../js/handlebars-helpers.js"></script> | 10 | + |
11 | + | ||
13 | <script src="lib/jasmine-2.2.0/jasmine.js"></script> | 12 | <script src="lib/jasmine-2.2.0/jasmine.js"></script> |
14 | <script src="lib/jasmine-2.2.0/jasmine-html.js"></script> | 13 | <script src="lib/jasmine-2.2.0/jasmine-html.js"></script> |
15 | - <script src="lib/jasmine-2.2.0/boot.js"></script> | 14 | + <!-- // <script src="lib/jasmine-2.2.0/boot.js"></script> --> |
16 | 15 | ||
17 | <script type="text/javascript"> | 16 | <script type="text/javascript"> |
18 | 17 | ||
19 | - var require = { | ||
20 | - paths: { | ||
21 | - "domReady": "lib/requirejs-plugins/domReady", | ||
22 | - "model": "../js" | ||
23 | - } | ||
24 | - }; | 18 | + // var require = { |
19 | + // paths: { | ||
20 | + // "domReady": "lib/requirejs-plugins/domReady", | ||
21 | + // "model": "../js", | ||
22 | + // "handlebars": '../js/handlebars-v3.0.1', | ||
23 | + // "handlebars_helpers": '../js/handlebars-helpers', | ||
24 | + // "jquery":'../js/jquery-2.1.3.min' | ||
25 | + // } | ||
26 | + // }; | ||
25 | 27 | ||
26 | </script> | 28 | </script> |
27 | 29 | ||
30 | + <script src="../js/require.js" data-main="../js/requirejs-config.js" ></script> | ||
31 | + <!-- // <script src="../js/handlebars-v3.0.1.js"></script> --> | ||
32 | + <!-- // <script src="../js/handlebars-helpers.js"></script> --> | ||
33 | + | ||
28 | <!-- include source files here... --> | 34 | <!-- include source files here... --> |
29 | <!-- <script src="../js/main.js"></script> --> | 35 | <!-- <script src="../js/main.js"></script> --> |
30 | 36 | ||
@@ -54,6 +60,7 @@ | @@ -54,6 +60,7 @@ | ||
54 | 60 | ||
55 | </script> | 61 | </script> |
56 | 62 | ||
63 | + | ||
57 | <!-- // <script src="spec/MainSpec.js"></script> --> | 64 | <!-- // <script src="spec/MainSpec.js"></script> --> |
58 | 65 | ||
59 | </head> | 66 | </head> |
test/spec/MainSpec.js
1 | -define(["model/main"],function(){ | 1 | +define(["model/main"],function(Main){ |
2 | 2 | ||
3 | describe("addVotedProposal", function(){ | 3 | describe("addVotedProposal", function(){ |
4 | it("Should register a voted id", function(){ | 4 | it("Should register a voted id", function(){ |
5 | - addVotedProposal(1).toEqual(true); | 5 | + expect(Main.addVotedProposal(1)).toContain(1); |
6 | + | ||
6 | }); | 7 | }); |
7 | }); | 8 | }); |
8 | }); | 9 | }); |