Layout improvements and bug fixes

James Peret 10 ans auparavant
Parent
Commettre
ed98de1dad

+ 1 - 0
Gemfile

@@ -25,6 +25,7 @@ gem 'jquery-rails'
25 25
 
26 26
 # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
27 27
 gem 'turbolinks'
28
+gem 'jquery-turbolinks'
28 29
 
29 30
 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
30 31
 gem 'jbuilder', '~> 1.2'

+ 4 - 0
Gemfile.lock

@@ -139,6 +139,9 @@ GEM
139 139
     jquery-rails (3.1.2)
140 140
       railties (>= 3.0, < 5.0)
141 141
       thor (>= 0.14, < 2.0)
142
+    jquery-turbolinks (2.1.0)
143
+      railties (>= 3.1.0)
144
+      turbolinks
142 145
     json (1.8.1)
143 146
     kgio (2.9.2)
144 147
     launchy (2.4.2)
@@ -325,6 +328,7 @@ DEPENDENCIES
325 328
   jasny_bootstrap_extension_rails
326 329
   jbuilder (~> 1.2)
327 330
   jquery-rails
331
+  jquery-turbolinks
328 332
   less-rails
329 333
   letter_opener
330 334
   mini_magick

+ 1 - 0
app/assets/javascripts/application.js

@@ -11,6 +11,7 @@
11 11
 // about supported directives.
12 12
 //
13 13
 //= require jquery
14
+//= require jquery.turbolinks	
14 15
 //= require jquery_ujs
15 16
 //= require twitter/bootstrap
16 17
 //= require bootstrap-switch

+ 190 - 156
app/assets/javascripts/start.js

@@ -1,162 +1,196 @@
1 1
 // get the value of the bottom of the #main element by adding the offset of that element plus its height, set it as a variable
2 2
 function attachHandler(jQuery) {
3
-	
4
-	$(window).on('load',function(){
5
-		$('#obscure_header').css('height', ($('#photo_header').height()));
6
-		$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));
7
-		$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));	
8
-		$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));	
9
-		$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
10
-		$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
11
-		$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
12
-		$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
13
-		$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
14
-		$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
15
-	});
16
-	
17
-	var mainbottom = $('#myCarousel').height();
18
-	
19
-	$('.popup').popover('toogle')
20
-	
21
-	// Newsletter Subscription AJAX
22
-	
23
-	$('.new_subscription').submit(function() {  
24
-	    var valuesToSubmit = $(this).serialize();
25
-	    $.ajax({
26
-	        type: "POST",
27
-	        url: $(this).attr('action'),
28
-	        data: valuesToSubmit,
29
-		   dataType: "json",
30
-		   async: true,
31
- 		   error: function(request, textStatus, errorThrown){
32
-    		   		msg = '<div class="alert alert-error span5 subscribe-alert"><h4>' + request.status + " " + errorThrown + '</h4><br>' + request.responseText + '</div>'
33
-		   		$('.new_subscription').html(msg);     
34
- 		   }, 
35
-		   success: function(data){
36
-			   $('.subscribe-alert').remove();
37
-			   switch(data.status) {
38
-			       case 'success':
39
-					 msg = '<div class="alert alert-success subscribe-alert"><h4>' + data.success + '</h4></div>';
40
-					 $('.new_subscription').html(msg); 
41
-			           break;
42
-			       case 'error':
43
-					 msg = '<div class="alert alert-error subscribe-alert"><h4>' + data.failure + '</h4></div>';
44
-					 $('.new_subscription').html(msg); 
45
-			           break;
46
-		       	  case 'invalid':
47
-					  msg = '<div class="alert alert-block subscribe-alert"><h4>' + data.invalid + '</h4></div>';
48
-					  $('.new_subscription').prepend(msg);
49
-		           	 break;
50
-			   }      
51
-		   }
52
-	    });
53
-	    return false;
54
-	});
55
-	
56
-	// on scroll, 
57
-	$(window).on('scroll',function(){
58
-
59
-	    // we round here to reduce a little workload
60
-	    stop = Math.round($(document).scrollTop());
61
-	    if (stop > mainbottom) {
62
-	        $('.navbar-inner.nav_fx').addClass('past-main');
63
-	    } else {
64
-	        $('.navbar-inner.nav_fx').removeClass('past-main');
65
-	   }
66 3
 
67
-	});
68
-
69
-	// scroll to 'header'
70
-	$(".btn-logo").click(function() {
71
-	    event.preventDefault();
72
-	    doc_with = $(document).width();
73
-	    if (doc_with > 979) {
74
-	    		$('html, body').animate({
75
-			    scrollTop: $("#myCarousel").offset().top
76
-			}, 1000);
77
-		} else if (doc_with < 979 && doc_with > 780) {
78
-	    		$('html, body').animate({
79
-			    scrollTop: ($("#myCarousel").offset().top - 56)
80
-			}, 1000);
81
-		} else {
82
-	    		$('html, body').animate({
83
-			    scrollTop: ($("#myCarousel2").offset().top - 56)
84
-			}, 1000);
85
-		}
86
-	    
87
-	});
88
-	
89
-	// scroll to 'about'
90
-	$(".btn-about").click(function() {
91
-	    event.preventDefault();
92
-	    doc_with = $(document).width();
93
-	    if (doc_with > 979) {
94
-		    $('html, body').animate({
95
-		        scrollTop: ($("#about").offset().top - 80)
96
-		    }, 1000);
97
-	    } else if (doc_with < 979 && doc_with > 780){
98
-		    $('html, body').animate({
99
-		        scrollTop: ($("#about").offset().top - 270)
100
-		    }, 1000);
101
-	    } else {
102
-		    $('html, body').animate({
103
-		        scrollTop: ($("#about").offset().top - 270)
104
-		    }, 1000);
105
-	    }
106
-	});
107
-	
108
-	// scroll to 'features'
109
-	$(".btn-features").click(function() {
110
-	    event.preventDefault();
111
-	    doc_with = $(document).width();
112
-	    if (doc_with > 979) {
113
-		    $('html, body').animate({
114
-		        scrollTop: ($("#features").offset().top - 50)
115
-		    }, 1000);
116
-	    } else if (doc_with < 979 && doc_with > 780){
117
-		    $('html, body').animate({
118
-		        scrollTop: ($("#features").offset().top - 230)
119
-		    }, 1000);
120
-	    } else {
121
-		    $('html, body').animate({
122
-		        scrollTop: ($("#features2").offset().top - 230)
123
-		    }, 1000);
124
-	    }
125
-	});
126
-	
127
-	// scroll to 'subscribe'
128
-	$(".btn-subscribe").click(function() {
129
-	    event.preventDefault();
130
-	    doc_with = $(document).width();
131
-	    if (doc_with > 979) {
132
-		    $('html, body').animate({
133
-		        scrollTop: ($("#subscribe").offset().top)
134
-		    }, 1000);
135
-	    } else if (doc_with < 979 && doc_with > 780){
136
-		    $('html, body').animate({
137
-		        scrollTop: ($("#subscribe").offset().top  - 100)
138
-		    }, 1000);
139
-	    } else {
140
-		    $('html, body').animate({
141
-		        scrollTop: ($("#subscribe2").offset().top  - 230)
142
-		    }, 1000);
143
-	    }
144
-	});
145
-	
146
-	$( window ).resize(function(){
147
-		$('#obscure_header').css('height', ($('#photo_header').height()));
148
-		$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));	
149
-		$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));
150
-		$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));		
151
-		$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
152
-		$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
153
-		var mainbottom = $('#myCarousel').offset().top + ($('#myCarousel').height()*2)-10;
154
-		$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
155
-		$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
156
-		$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
157
-		$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
158
-	});
4
+	$('#obscure_header').css('height', ($('#photo_header').height()));
5
+	$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));
6
+	$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));	
7
+	$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));	
8
+	$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
9
+	$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
10
+	$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
11
+	$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
12
+	$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
13
+	$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
14
+
159 15
 };
160 16
 
161 17
 $(document).ready(attachHandler);
162
-$(document).load(attachHandler);
18
+$(document).load(attachHandler);
19
+
20
+
21
+
22
+
23
+
24
+
25
+$(window).on('load',function(){
26
+	$('#obscure_header').css('height', ($('#photo_header').height()));
27
+	$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));
28
+	$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));	
29
+	$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));	
30
+	$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
31
+	$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
32
+	$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
33
+	$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
34
+	$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
35
+	$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
36
+});
37
+
38
+$(window).on('ready',function(){
39
+	$('#obscure_header').css('height', ($('#photo_header').height()));
40
+	$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));
41
+	$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));	
42
+	$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));	
43
+	$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
44
+	$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
45
+	$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
46
+	$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
47
+	$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
48
+	$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
49
+});
50
+
51
+var mainbottom = $('#myCarousel').height();
52
+
53
+
54
+
55
+$( window ).resize(function(){
56
+	$('#obscure_header').css('height', ($('#photo_header').height()));
57
+	$('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height()));	
58
+	$('#obscure_subscribe').css('height', ($('#photo_subscribe').height()));
59
+	$('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height()));		
60
+	$('#myCarousel.carousel.slide').css('height', ($('#photo_header').height()));
61
+	$('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height()));
62
+	var mainbottom = $('#myCarousel').offset().top + ($('#myCarousel').height()*2)-10;
63
+	$('#tagline_header').css('top', (($('#photo_header').height()/7)*-5));
64
+	$('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8));
65
+	$('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8));
66
+	$('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7));
67
+});
68
+
69
+
70
+
71
+$('.popup').popover('toogle')
72
+
73
+// Newsletter Subscription AJAX
74
+
75
+$('.new_subscription').submit(function() {  
76
+    var valuesToSubmit = $(this).serialize();
77
+    $.ajax({
78
+        type: "POST",
79
+        url: $(this).attr('action'),
80
+        data: valuesToSubmit,
81
+	   dataType: "json",
82
+	   async: true,
83
+	   error: function(request, textStatus, errorThrown){
84
+	   		msg = '<div class="alert alert-error span5 subscribe-alert"><h4>' + request.status + " " + errorThrown + '</h4><br>' + request.responseText + '</div>'
85
+	   		$('.new_subscription').html(msg);     
86
+	   }, 
87
+	   success: function(data){
88
+		   $('.subscribe-alert').remove();
89
+		   switch(data.status) {
90
+		       case 'success':
91
+				 msg = '<div class="alert alert-success subscribe-alert"><h4>' + data.success + '</h4></div>';
92
+				 $('.new_subscription').html(msg); 
93
+		           break;
94
+		       case 'error':
95
+				 msg = '<div class="alert alert-error subscribe-alert"><h4>' + data.failure + '</h4></div>';
96
+				 $('.new_subscription').html(msg); 
97
+		           break;
98
+	       	  case 'invalid':
99
+				  msg = '<div class="alert alert-block subscribe-alert"><h4>' + data.invalid + '</h4></div>';
100
+				  $('.new_subscription').prepend(msg);
101
+	           	 break;
102
+		   }      
103
+	   }
104
+    });
105
+    return false;
106
+});
107
+
108
+// on scroll, 
109
+$(window).on('scroll',function(){
110
+
111
+    // we round here to reduce a little workload
112
+    stop = Math.round($(document).scrollTop());
113
+    if (stop > mainbottom) {
114
+        $('.navbar-inner.nav_fx').addClass('past-main');
115
+    } else {
116
+        $('.navbar-inner.nav_fx').removeClass('past-main');
117
+   }
118
+
119
+});
120
+
121
+// scroll to 'header'
122
+$(".btn-logo").click(function() {
123
+    event.preventDefault();
124
+    doc_with = $(document).width();
125
+    if (doc_with > 979) {
126
+    		$('html, body').animate({
127
+		    scrollTop: $("#myCarousel").offset().top
128
+		}, 1000);
129
+	} else if (doc_with < 979 && doc_with > 780) {
130
+    		$('html, body').animate({
131
+		    scrollTop: ($("#myCarousel").offset().top - 56)
132
+		}, 1000);
133
+	} else {
134
+    		$('html, body').animate({
135
+		    scrollTop: ($("#myCarousel2").offset().top - 56)
136
+		}, 1000);
137
+	}
138
+    
139
+});
140
+
141
+// scroll to 'about'
142
+$(".btn-about").click(function() {
143
+    event.preventDefault();
144
+    doc_with = $(document).width();
145
+    if (doc_with > 979) {
146
+	    $('html, body').animate({
147
+	        scrollTop: ($("#about").offset().top - 80)
148
+	    }, 1000);
149
+    } else if (doc_with < 979 && doc_with > 780){
150
+	    $('html, body').animate({
151
+	        scrollTop: ($("#about").offset().top - 270)
152
+	    }, 1000);
153
+    } else {
154
+	    $('html, body').animate({
155
+	        scrollTop: ($("#about").offset().top - 270)
156
+	    }, 1000);
157
+    }
158
+});
159
+
160
+// scroll to 'features'
161
+$(".btn-features").click(function() {
162
+    event.preventDefault();
163
+    doc_with = $(document).width();
164
+    if (doc_with > 979) {
165
+	    $('html, body').animate({
166
+	        scrollTop: ($("#features").offset().top - 50)
167
+	    }, 1000);
168
+    } else if (doc_with < 979 && doc_with > 780){
169
+	    $('html, body').animate({
170
+	        scrollTop: ($("#features").offset().top - 230)
171
+	    }, 1000);
172
+    } else {
173
+	    $('html, body').animate({
174
+	        scrollTop: ($("#features2").offset().top - 230)
175
+	    }, 1000);
176
+    }
177
+});
178
+
179
+// scroll to 'subscribe'
180
+$(".btn-subscribe").click(function() {
181
+    event.preventDefault();
182
+    doc_with = $(document).width();
183
+    if (doc_with > 979) {
184
+	    $('html, body').animate({
185
+	        scrollTop: ($("#subscribe").offset().top)
186
+	    }, 1000);
187
+    } else if (doc_with < 979 && doc_with > 780){
188
+	    $('html, body').animate({
189
+	        scrollTop: ($("#subscribe").offset().top  - 100)
190
+	    }, 1000);
191
+    } else {
192
+	    $('html, body').animate({
193
+	        scrollTop: ($("#subscribe2").offset().top  - 230)
194
+	    }, 1000);
195
+    }
196
+});

+ 36 - 10
app/assets/stylesheets/avalanche_theme.css.less

@@ -2,8 +2,9 @@
2 2
 // ------------------------------------------------
3 3
 
4 4
 @import "avl2_theme/colors.less";
5
-@import "avl2_theme/buttons.less";
6
-@import "avl2_theme/panel.less";
5
+//@import "avl2_theme/buttons.less";
6
+//@import "avl2_theme/forms.less";
7
+//@import "avl2_theme/panel.less";
7 8
 
8 9
 html, body {
9 10
     height: 100%;
@@ -295,15 +296,18 @@ footer {
295 296
 	background-color: transparent;
296 297
 }
297 298
 
298
-footer .column .column-inner {
299
-	min-height: 90px
300
-}
299
+footer .column5 .column-inner { min-height: 90px }
300
+footer .column5 .column-inner.centered { min-height: 75px }
301
+
302
+footer .column3 .column-inner { min-height: 100px }
303
+footer .column3 .column-inner.centered { min-height: 85px }
301 304
 
302
-footer .column .column-inner.centered {
303
-	min-height: 75px
305
+.column3 {
306
+	width: 33%;
307
+	float: left;
304 308
 }
305 309
 
306
-.column {
310
+.column5 {
307 311
 	width: 20%;
308 312
 	float: left;
309 313
 }
@@ -339,10 +343,19 @@ footer .column .column-inner.centered {
339 343
 .column-inner.centered {
340 344
 	padding-top: 25px;
341 345
 }
346
+
347
+.column-inner div:nth-child(1) { margin-left: 15px; }
348
+.column-inner div:nth-child(2) { margin-right: 15px; }
342 349
 		
343
-footer .column .column-inner i {
350
+footer .column5 .column-inner i {
351
+	margin-right: 15px;
352
+	margin-left: 15px;
353
+}
354
+
355
+footer .column3 .column-inner i {
344 356
 	margin-right: 15px;
345 357
 	margin-left: 15px;
358
+	font-size: 21px;
346 359
 }
347 360
 
348 361
 footer .copyright {
@@ -354,6 +367,17 @@ footer hr {
354 367
 	margin-bottom: 10px;
355 368
 }
356 369
 
370
+footer .links_mobile {
371
+	width: 220px;
372
+	margin-left: auto;
373
+	margin-right: auto;
374
+	margin-top: 20px;
375
+	margin-bottom: 25px;
376
+	height: 80px;
377
+}
378
+
379
+.footer-email { word-break: break-all; }
380
+
357 381
 // Hacks
358 382
 
359 383
 .videoWrapper {
@@ -372,4 +396,6 @@ footer hr {
372 396
 
373 397
 .nav-tabs > .active > a, .nav-tabs > .active.clickable > a:hover, .nav-tabs > .active.clickable > a:focus {
374 398
 	cursor: pointer;
375
-}
399
+}
400
+
401
+.no-margin-bottom { margin-bottom: 0px;}

+ 26 - 0
app/assets/stylesheets/avl2_theme/buttons.less

@@ -52,4 +52,30 @@
52 52
 .btn-link:hover {
53 53
 	border: none;
54 54
 	background-color: transparent;
55
+}
56
+
57
+
58
+// btn inverse
59
+button.btn.inverse, input[type="submit"].btn.inverse {
60
+	background-color: @white;
61
+	color: @black;
62
+}
63
+
64
+// btn inverse hover
65
+button.btn.inverse:hover, input[type="submit"].btn.inverse:hover {
66
+	background-color: @light-gray;
67
+	color: @black;
68
+}
69
+
70
+// btn inverse sucess
71
+button.btn.btn-success.inverse, input[type="submit"].btn.btn-success.inverse {
72
+	background-color: lighten(@green, 20%);
73
+	color: @black;
74
+}
75
+
76
+// btn inverse sucess hover
77
+button.btn.btn-success.inverse:hover, input[type="submit"].btn.btn-success.inverse:hover {
78
+	background-color: @green;
79
+	color: @black;
80
+	border: 2px solid darken(@green, 20%);
55 81
 }

+ 28 - 0
app/assets/stylesheets/avl2_theme/forms.less

@@ -0,0 +1,28 @@
1
+// Forms
2
+
3
+@import "colors.less";
4
+
5
+div.form-group {
6
+	label.control-label {
7
+		font-family: Avenir-Light;
8
+		font-size: 18px;
9
+		color: @dark-gray;
10
+		line-height: 26px;
11
+	}
12
+
13
+	
14
+}
15
+
16
+input.form-control.input-block-level { min-height: 42px;}
17
+
18
+select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
19
+	display: inline-block;
20
+	height: 26px;
21
+	padding: 6px;
22
+	margin-bottom: 10px;
23
+	font-family: Avenir-Medium;
24
+	font-size: 18px;
25
+	line-height: 26px;
26
+	color: @dark-gray;
27
+	vertical-align: middle;
28
+}

+ 7 - 0
app/assets/stylesheets/avl2_theme/panel.less

@@ -63,6 +63,13 @@
63 63
 				color: #1D1D26;
64 64
 				line-height: 26px;
65 65
 				.theme-box-padding;
66
+				.secondary {
67
+					font-family: Avenir-Light;
68
+					font-size: 18px;
69
+					color: #1D1D26;
70
+					line-height: 29px;
71
+					font-style: oblique;
72
+				}
66 73
 			}
67 74
 		}
68 75
 		.accordion {

+ 4 - 2
app/controllers/missions_controller.rb

@@ -52,7 +52,7 @@ class MissionsController < ApplicationController
52 52
   # POST /missions.json
53 53
   def create
54 54
     @mission = Mission.new(mission_params)
55
-
55
+    @mission.owner = current_user
56 56
     respond_to do |format|
57 57
       if @mission.save
58 58
         format.html { redirect_to mission_control_path(@mission), notice: 'Mission was successfully created.' }
@@ -91,7 +91,7 @@ class MissionsController < ApplicationController
91 91
   def take_agent_role
92 92
     mission = Mission.friendly.find(params[:id])
93 93
     agent = mission.mission_agents.friendly.find(params[:agent])
94
-    candidate = MissionCandidate.create!(user: current_user, mission_agent: agent, status: 'closed', mode: 'take_agent_role')
94
+    candidate = MissionCandidate.create!(user: current_user, mission_agent: agent, status: 1, mode: 'take_agent_role')
95 95
     agent.user = current_user
96 96
     respond_to do |format|
97 97
       if agent.save
@@ -130,6 +130,8 @@ class MissionsController < ApplicationController
130 130
       submission.validated_by = current_user
131 131
       submission.date_validated = Time.now
132 132
       submission.save
133
+      submission.agent_step.update(completed: true)
134
+      mission.check_for_completion
133 135
       redirect_to mission_control_path(mission)
134 136
     end
135 137
   end

+ 12 - 0
app/models/mission.rb

@@ -20,4 +20,16 @@ class Mission < ActiveRecord::Base
20 20
     return self.mission_agents.count
21 21
   end
22 22
   
23
+  def check_for_completion
24
+    self.mission_agents.each do |agent|
25
+      agent.agent_steps.each do |step|
26
+        if step.completed == true || step.completed == nil
27
+          return false
28
+        end
29
+      end
30
+    end
31
+    self.update(status: 3)
32
+    return true
33
+  end
34
+  
23 35
 end

+ 4 - 0
app/models/mission_candidate.rb

@@ -1,4 +1,8 @@
1 1
 class MissionCandidate < ActiveRecord::Base
2 2
   belongs_to :user
3 3
   belongs_to :mission_agent
4
+  
5
+  # status
6
+  # 0 = open
7
+  # 1 = closed
4 8
 end

+ 74 - 59
app/views/layouts/_footer.html.erb

@@ -2,62 +2,77 @@
2 2
 	<% color = 'black' %>
3 3
 <% end %>
4 4
 
5
-<footer class="footer-<%= color %>">
6
-	<div class="container">
7
-		<div class="row">
8
-			<div class="column first">
9
-				<div class="column-inner first centered">
10
-			    	     <ul class="nav btn">
11
-			    	          <li class="dropdown">
12
-			    	            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
13
-			    	              <%= t('landing_page.lang') %>
14
-			    	              <span class="caret"></span>
15
-			    	            </a>
16
-			    	            <ul class="dropdown-menu dropdown-menu-right" role="menu">
17
-			    	              <li>
18
-			    	                <%= link_to t('landing_page.en'), change_locale_path(:en) %>
19
-			    	              </li>
20
-			    	              <li>
21
-			    	                <%= link_to t('landing_page.pt-BR'), change_locale_path(:"pt-BR") %>
22
-			    	              </li>
23
-			    	            </ul>
24
-			    	          </li>
25
-			    	      </ul>
26
-				 </div>
27
-			 </div>
28
-			 <div class="column">
29
-				 <div class="column-inner">
30
-  		 		    <%= link_to (t 'nav.home'), root_path  %><br>
31
-				    <%= link_to "Blog", blog_path  %><br>
32
-				    <%= link_to (t 'contact.contact'), contact_messages_path  %><br>
33
-				    <% if user_signed_in? %>
34
-				    	<%= link_to (t "registration.account"), edit_user_registration_path, class: "btn-account" %><br>
35
-				    <% else %>
36
-  		 		    	<%= link_to (t "registration.sign_in"), new_user_session_path, class: "btn-login" %><br>
37
-				    <% end %>
38
-			    </div>
39
-			 </div>
40
-			 <div class="column">
41
-				 <div class="column-inner">
42
-				 	<p><%= t 'contact.contact'%><br><a href="mailto:<%= t 'contact.email_contact'%>@avalanche.network"><%= t 'contact.email_contact'%>@avalanche.network</a><br><%= t 'contact.current_location'%></p>
43
-				 </div>
44
-			 </div>
45
-			 <div class="column">
46
-				 <div class="column-inner centered">
47
-					 <a href="https://www.facebook.com/pages/Avalanche-Network/932907863393529"><i class="fa fa-facebook-square fa-4x"></i></a>
48
-				 	 <a href="https://twitter.com/avalanche_net"><i class="fa fa-twitter fa-4x"></i></a>
49
-				</div>
50
-			 </div>
51
-			 <div class="column">
52
-				 <div class="column-inner last centered">
53
-				  	<a href="https://mixpanel.com/f/partner"><img src="//cdn.mxpnl.com/site_media/images/partner/badge_light.png" alt="Mobile Analytics" /></a>
54
-				</div>
55
-			 </div>
56
-		</div>
57
-		<div class="row" style="max-width: 1150px;
58
-margin-left: 0px;">
59
-			<hr style="margin-top: 20px; border-top: 1px solid #000000;">
60
-			<p class="copyright" style="text-align: center;">&copy; Avalanche Network <%= Time.now.year %></p>
61
-		</div>
62
-	</div>
63
-</footer>
5
+<%= content_tag(:footer, class: "footer-#{color}") do %>
6
+	<%= content_tag(:div, class: 'container') do %>
7
+		
8
+		<% # Desktop %>
9
+		<%= content_tag(:div, class: 'row visible-desktop') do %>
10
+			<%= content_tag(:div, class: 'column5 first') do %>
11
+				<%= content_tag(:div, class: 'column-inner first centered') do %>
12
+					<%= render 'layouts/footer/footer_language' %>
13
+				<% end %>
14
+			 <% end %>
15
+			 <%= content_tag(:div, class: 'column5') do %>
16
+			 	<%= content_tag(:div, class: 'column-inner') do %>
17
+					<%= render 'layouts/footer/footer_links' %>
18
+				<% end %>
19
+			 <% end %>
20
+			 <%= content_tag(:div, class: 'column5') do %>
21
+			 	<%= content_tag(:div, class: 'column-inner') do %>
22
+					<%= render 'layouts/footer/footer_contact' %>
23
+				<% end %>
24
+			 <% end %>
25
+			 <%= content_tag(:div, class: 'column5') do %>
26
+			 	<%= content_tag(:div, class: 'column-inner centered') do %>
27
+					<%= render 'layouts/footer/footer_social' %>
28
+				<% end %>
29
+			 <% end %>
30
+			 <%= content_tag(:div, class: 'column5') do %>
31
+			 	<%= content_tag(:div, class: 'column-inner last centered') do %>
32
+					<%= render 'layouts/footer/footer_partners' %>
33
+				<% end %>
34
+			 <% end %>
35
+		<% end %>
36
+		
37
+		<% # tablet %>
38
+		<%= content_tag(:div, class: 'row visible-tablet') do %>
39
+			<%= content_tag(:div, class: 'column3 first') do %>
40
+				<%= content_tag(:div, class: 'column-inner first centered') do %>
41
+					<%= render 'layouts/footer/footer_language' %><br>
42
+					<% render 'layouts/footer/footer_partners' %>
43
+				<% end %>
44
+			 <% end %>
45
+			 <%= content_tag(:div, class: 'column3') do %>
46
+			 	<%= content_tag(:div, class: 'column-inner') do %>
47
+					<%= render 'layouts/footer/footer_links' %>
48
+				<% end %>
49
+			 <% end %>
50
+			 <%= content_tag(:div, class: 'column3') do %>
51
+			 	<%= content_tag(:div, class: 'column-inner last') do %>
52
+					<%= render 'layouts/footer/footer_contact' %>
53
+					<%= render 'layouts/footer/footer_social' %>
54
+				<% end %>
55
+			 <% end %>
56
+		<% end %>
57
+		
58
+		<% # phone %>
59
+		<%= content_tag(:div, class: 'row visible-phone') do %>
60
+			<%= content_tag(:hr, '', style: 'margin-top: 20px; border-top: 1px solid #000000;') %>
61
+			<%= content_tag(:div, class: '') do %>
62
+				<%= content_tag(:div, class: 'centered last') do %>
63
+					<%= render 'layouts/footer/footer_language' %><br>
64
+					<%= content_tag(:div, class: 'links_mobile') do %>
65
+						<%= render 'layouts/footer/footer_links' %><br>
66
+					<% end %>
67
+					<%= render 'layouts/footer/footer_contact' %><br>
68
+					<%= render 'layouts/footer/footer_social' %>
69
+				<% end %>
70
+			 <% end %>
71
+		<% end %>
72
+		
73
+		<%= content_tag(:div, class: 'row', style: 'max-width: 1150px; margin-left: 0px;') do %>
74
+			<%= content_tag(:hr, '', style: 'margin-top: 20px; border-top: 1px solid #000000;') %>
75
+			<%= content_tag(:p, "&copy; Avalanche Network #{Time.now.year}".html_safe, class: 'copyright', style: 'text-align: center;')%>
76
+		<% end %>
77
+	<% end %>
78
+<% end %>

+ 1 - 1
app/views/layouts/application.html.erb

@@ -39,7 +39,7 @@
39 39
   <body>
40 40
     <div class="wrapper">
41 41
 	    <div class="navbar navbar-fixed-top">
42
-	      <div class="navbar-inner past-main">
42
+	      <div class="navbar-inner <%= if params[:controller] == 'start' then 'nav_fx' else 'past-main' end %>">
43 43
 	        <div class="container">
44 44
 	          <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
45 45
 	            <span class="icon-bar"></span>

+ 5 - 0
app/views/layouts/footer/_footer_contact.html.erb

@@ -0,0 +1,5 @@
1
+<p>
2
+	<%= t 'contact.contact'%><br>
3
+	<a class="footer-email" href="mailto:<%= t 'contact.email_contact'%>@avalanche.network"><%= t 'contact.email_contact'%>@avalanche.network</a><br>
4
+	<%= t 'contact.current_location'%>
5
+</p>

+ 16 - 0
app/views/layouts/footer/_footer_language.html.erb

@@ -0,0 +1,16 @@
1
+<ul class="nav btn">
2
+     <li class="dropdown">
3
+       <a class="dropdown-toggle" data-toggle="dropdown" href="#">
4
+         <%= t('landing_page.lang') %>
5
+         <span class="caret"></span>
6
+       </a>
7
+       <ul class="dropdown-menu dropdown-menu-right" role="menu">
8
+         <li>
9
+           <%= link_to t('landing_page.en'), change_locale_path(:en) %>
10
+         </li>
11
+         <li>
12
+           <%= link_to t('landing_page.pt-BR'), change_locale_path(:"pt-BR") %>
13
+         </li>
14
+       </ul>
15
+     </li>
16
+ </ul>

+ 17 - 0
app/views/layouts/footer/_footer_links.html.erb

@@ -0,0 +1,17 @@
1
+<%= content_tag(:div, class: 'pull-left') do %>
2
+	<%= link_to (t 'nav.home'), root_path  %><br>
3
+	<% link_to "Blog", blog_path  %>Blog<br>
4
+	<% link_to (t 'contact.contact'), contact_messages_path  %><%= t 'contact.contact' %><br>
5
+	<%= t 'contact.support' %>
6
+<% end %>
7
+<%= content_tag(:div, class: 'pull-right') do %>
8
+	<%= link_to (t 'missions.missions'), missions_path  %><br>
9
+	<%= link_to (t 'missions.agents'), agent_list_path  %><br>
10
+	<% if user_signed_in? %>
11
+		<%= link_to (t 'agent.dashboard'), dashboard_path  %><br>
12
+		<%= link_to (t "registration.account"), edit_user_registration_path, class: "btn-account" %><br>
13
+	<% else %>
14
+		<%= link_to (t "registration.sign_in"), new_user_session_path, class: "btn-login" %><br>
15
+		<%= link_to (t "registration.sign_up"), new_user_registration_path, class: "btn-login" %><br>
16
+	<% end %>
17
+<% end %>

+ 1 - 0
app/views/layouts/footer/_footer_partners.html.erb

@@ -0,0 +1 @@
1
+<a href="https://mixpanel.com/f/partner"><img src="//cdn.mxpnl.com/site_media/images/partner/badge_light.png" alt="Mobile Analytics" /></a>

+ 3 - 0
app/views/layouts/footer/_footer_social.html.erb

@@ -0,0 +1,3 @@
1
+
2
+	<a href="https://www.facebook.com/pages/Avalanche-Network/932907863393529"><i class="fa fa-facebook-square fa-4x"></i></a>
3
+	<a href="https://twitter.com/avalanche_net"><i class="fa fa-twitter fa-4x"></i></a>

+ 21 - 10
app/views/missions/_step_submission.html.erb

@@ -14,17 +14,28 @@
14 14
 		<% end %>
15 15
 		<%= content_tag(:div, class: 'panel-body collapse', id: validation_id) do %>
16 16
 			<%= content_tag(:div, class: 'panel-content') do %>
17
-					
18
-				<% # Form %>
19
-				<%= content_tag(:div, class: "panel-text") do %>
20
-					
21
-					<%= f.fields_for :submission_contents, SubmissionContent.new, show_empty: true do |f| %>
22
-						<%= f.alert_message "Please fix the errors below." %>
23
-						<%= f.fields_for SubmissionText.new, as: :submission, show_empty: true do |f| %>
24
-							<%= f.text_field :content %>
25
-						<% end %>
26
-					<% end %>
27 17
 
18
+				<% last_step_submission = StepSubmission.find_all_by_agent_step_id(step.id).last %>
19
+				<% if last_step_submission %>
20
+					<% if last_step_submission.validated == nil && current_user == last_step_submission.agent_step.mission_agent.user %>
21
+						<% # waiting for validation, draw the answer %>
22
+						<%= render :partial => 'step_submission_content', locals: {step: step, f: f, last_step_submission: last_step_submission} %>
23
+					<% elsif last_step_submission.validated == false && current_user == last_step_submission.agent_step.mission_agent.user%>
24
+						<% # draw the form %>
25
+						<%= render :partial => 'step_submission_form', locals: {step: step, f: f, step_submission: step_submission} %>
26
+					<% else %>
27
+						<% # step completed, draw the answer%>
28
+						<%= render :partial => 'step_submission_content', locals: {step: step, f: f, last_step_submission: last_step_submission} %>
29
+					<% end%>
30
+				<% elsif agent.user == current_user %>
31
+					<% # step content hasn't been submited, draw the form' %>
32
+					<%= render :partial => 'step_submission_form', locals: {step: step, f: f, step_submission: step_submission} %>
33
+				<% else %>
34
+					<% # No submission and not the user agent%>
35
+					<% # Form %>
36
+					<%= content_tag(:div, class: "panel-text") do %>
37
+						<%= content_tag(:p, (t 'mission.waiting_for_agent_submission'), class: 'secondary') %>
38
+					<% end %>
28 39
 				<% end %>
29 40
 				
30 41
 			<% end %>

+ 4 - 0
app/views/missions/_step_submission_content.html.erb

@@ -0,0 +1,4 @@
1
+<% # Submited Content %>
2
+<%= content_tag(:div, class: "panel-text") do %>
3
+	<%= content_tag(:p, last_step_submission.submission_contents.last.submission.content, class: 'no-margin-bottom') %>
4
+<% end %>

+ 9 - 0
app/views/missions/_step_submission_form.html.erb

@@ -0,0 +1,9 @@
1
+<% # Form %>
2
+<%= content_tag(:div, class: "panel-text") do %>
3
+	<%= f.fields_for :submission_contents, SubmissionContent.new, show_empty: true do |f| %>
4
+		<%= f.alert_message "Please fix the errors below." %>
5
+		<%= f.fields_for SubmissionText.new, as: :submission, show_empty: true do |f| %>
6
+			<%= f.text_field :content, class: 'input-block-level' %>
7
+		<% end %>
8
+	<% end %>
9
+<% end %>

+ 4 - 4
app/views/missions/show_agent_details.html.erb

@@ -23,7 +23,7 @@
23 23
 			<%= content_tag(:h4, ((t 'mission.objective') + ':') ) %>
24 24
 			<%= content_tag(:p, @agent.objective.html_safe) %>
25 25
 			<%= content_tag(:h4, ((t 'mission.instructions') + ':') ) %>
26
-			<%= @agent.briefing.html_safe %>
26
+			<%= @agent.briefing.html_safe if @agent.briefing  %>
27 27
 		<% end %>
28 28
 		<%= content_tag(:div, class: 'span4') do %>
29 29
 			<% if @agent.is_assigned %>
@@ -78,7 +78,7 @@
78 78
 										<span class="label label-success pull-right">Validated</span>
79 79
 									<% elsif step.is_validating %>
80 80
 										<span class="label label-warning pull-right">Waiting for validation</span>
81
-									<% else %>
81
+									<% elsif step.mission_agent.user == current_user %>
82 82
 										<%= f.button :submit, class: 'btn btn-small btn-success pull-right' %>
83 83
 									<% end %>
84 84
 								<% end %>
@@ -87,9 +87,9 @@
87 87
 						<%= content_tag(:div, class: 'panel-body collapse', id: ('collapse_step_'+ step.step.to_s)) do %>
88 88
 							<%= content_tag(:div, class: "panel-content") do %>
89 89
 								<%= content_tag(:div, class: "panel-text") do %>
90
-									<%= step.description.html_safe %>
90
+									<%= step.description.html_safe if step.description %>
91 91
 								<% end %>
92
-								<%= render :partial => 'step_submission', locals: {step: step, f: f, step_submission: step_submission} %>
92
+								<%= render :partial => 'step_submission', locals: {step: step, f: f, step_submission: step_submission, agent: @agent} %>
93 93
 							
94 94
 							<% end %>
95 95
 						<% end %>

+ 2 - 2
app/views/start/index.html.erb

@@ -248,7 +248,7 @@
248 248
 				      <%= f.form_group :email, style: 'margin-top: -35px;' do %>
249 249
 				        	<%= f.text_field :email, hide_label: true, placeholder: 'Email', class: 'span4 input-large', required: true, style: 'height: 30px; font-size: 24px; padding-top: 10px;' %>
250 250
 				      <% end %>
251
-				      <%= f.submit (t 'subscription.submit'), class: 'btn btn-large', id: 'submit_subscription' %>
251
+				      <%= f.submit (t 'subscription.submit'), class: 'btn btn-large inverse btn-success', id: 'submit_subscription' %>
252 252
 				    <% end %>
253 253
 			    </div>
254 254
 		    </div>
@@ -288,7 +288,7 @@
288 288
       <%= f.form_group :email, style: 'margin-top: -35px;' do %>
289 289
         	<%= f.text_field :email, hide_label: true, placeholder: 'Email', id: 'subscription_email_mobile', class: 'span4', required: true, style: 'height: 50px; font-size: 24px; padding-top: 5px;' %>
290 290
       <% end %>
291
-      <%= f.submit (t 'subscription.submit'), class: 'btn btn-large', id: 'submit_subscription_mobile' %>
291
+      <%= f.submit (t 'subscription.submit'), class: 'btn btn-large btn-success', id: 'submit_subscription_mobile' %>
292 292
     <% end %>
293 293
 </div>
294 294