@@ -10,59 +10,55 @@ var App = App || {};
1010 * Common init function
1111 */
1212 function init ( ajaxResponce ) {
13- /**
14- * Show details
15- */
13+ // Show details
1614 $ ( '.defaultTemplate #whiteRabbitCards .card' )
1715 . off ( 'click.showDetails' )
1816 . on ( 'click.showDetails' , function ( e ) {
1917
2018 var id = $ ( this ) . attr ( 'data-id' ) ;
2119 var result = '' ;
20+
21+ var fullName ;
22+ var location ;
23+ var reviewTitle ;
24+ var reviewBody ;
25+ var starRating ;
26+ var createdOn ;
27+
28+ // Check if we received json with more than 1 object
2229 if ( id ) {
23- var fullName = ajaxResponce [ id ] . fullName || 'no name' ;
24- var location = ajaxResponce [ id ] . location || 'no location' ;
25- var reviewTitle = ajaxResponce [ id ] . reviewTitle || 'no title' ;
26- var reviewBody = ajaxResponce [ id ] . reviewBody || 'no text' ;
30+ fullName = ajaxResponce [ id ] . fullName || 'no name' ;
31+ location = ajaxResponce [ id ] . location || 'no location' ;
32+ reviewTitle = ajaxResponce [ id ] . reviewTitle || 'no title' ;
33+ reviewBody = ajaxResponce [ id ] . reviewBody || 'no text' ;
2734 reviewBody = App . Utils . nl2br ( reviewBody ) ;
28- var starRating = ajaxResponce [ id ] . starRating || '5' ;
29- var createdOn = ajaxResponce [ id ] . createdOn || 'no date' ;
35+ starRating = ajaxResponce [ id ] . starRating || '5' ;
36+ createdOn = ajaxResponce [ id ] . createdOn || 'no date' ;
3037
31- result += '<div class="description">* Click here to hide</div>' ;
32- result += '<h2>Details</h2>' ;
33- result += '<div class="text-md-2">' ;
34- result += '<p class="pt-12"><strong>Name:</strong> ' + fullName + '</p>' ;
35- result += '<p class="pt-12"><strong>Rate:</strong> ' + starRating + '</p>' ;
36- result += '<p class="pt-12"><strong>Review title:</strong> ' + reviewTitle + '</p>' ;
37- result += '<p class="pt-12"><strong>Review body:</strong></p>' ;
38- result += '<p class="pt-12">' + reviewBody + '</p>' ;
39- result += '<p class="pt-12"><strong>Location:</strong> ' + location + '</p>' ;
40- result += '<p class="pt-12"><strong>Created:</strong> ' + createdOn + '</p>' ;
41- result += '</div>' ;
42- $ ( '#whiteRabbitDetails' ) . html ( '' ) . append ( result ) ;
4338 } else {
44- var fullName = ajaxResponce . fullName || 'no name' ;
45- var location = ajaxResponce . location || 'no location' ;
46- var reviewTitle = ajaxResponce . reviewTitle || 'no title' ;
47- var reviewBody = ajaxResponce . reviewBody || 'no text' ;
39+ fullName = ajaxResponce . fullName || 'no name' ;
40+ location = ajaxResponce . location || 'no location' ;
41+ reviewTitle = ajaxResponce . reviewTitle || 'no title' ;
42+ reviewBody = ajaxResponce . reviewBody || 'no text' ;
4843 reviewBody = App . Utils . nl2br ( reviewBody ) ;
49- var starRating = ajaxResponce . starRating || '5' ;
50- var createdOn = ajaxResponce . createdOn || 'no date' ;
51-
52- result += '<div class="description">* Click here to close</div>' ;
53- result += '<h2>Details</h2>' ;
54- result += '<div class="text-md-2">' ;
55- result += '<p class="pt-12"><strong>Name:</strong> ' + fullName + '</p>' ;
56- result += '<p class="pt-12"><strong>Rate:</strong> ' + starRating + '</p>' ;
57- result += '<p class="pt-12"><strong>Review title:</strong> ' + reviewTitle + '</p>' ;
58- result += '<p class="pt-12"><strong>Review body:</strong></p>' ;
59- result += '<p class="pt-12">' + reviewBody + '</p>' ;
60- result += '<p class="pt-12"><strong>Location:</strong> ' + location + '</p>' ;
61- result += '<p class="pt-12"><strong>Created:</strong> ' + createdOn + '</p>' ;
62- result += '</div>' ;
63- $ ( '#whiteRabbitDetails' ) . html ( '' ) . append ( result ) ;
44+ starRating = ajaxResponce . starRating || '5' ;
45+ createdOn = ajaxResponce . createdOn || 'no date' ;
6446 }
6547
48+ result += '<div class="description">* Click here to close</div>' ;
49+ result += '<h2>Details</h2>' ;
50+ result += '<div class="text-md-2">' ;
51+ result += '<p class="pt-12"><strong>Name:</strong> ' + fullName + '</p>' ;
52+ result += '<p class="pt-12"><strong>Rate:</strong> ' + starRating + '</p>' ;
53+ result += '<p class="pt-12"><strong>Review title:</strong> ' + reviewTitle + '</p>' ;
54+ result += '<p class="pt-12"><strong>Review body:</strong></p>' ;
55+ result += '<p class="pt-12">' + reviewBody + '</p>' ;
56+ result += '<p class="pt-12"><strong>Location:</strong> ' + location + '</p>' ;
57+ result += '<p class="pt-12"><strong>Created:</strong> ' + createdOn + '</p>' ;
58+ result += '</div>' ;
59+
60+ $ ( '#whiteRabbitDetails' ) . html ( '' ) . append ( result ) ;
61+
6662 /**
6763 * Hide/close details block
6864 */
0 commit comments