Skip to content

Commit

Permalink
partials for reviewing products
Browse files Browse the repository at this point in the history
  • Loading branch information
af19 committed Jul 23, 2015
1 parent a51f5d1 commit 4640f38
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 27 deletions.
Binary file modified .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions lemonsync.cfg
@@ -0,0 +1,12 @@
[api]
api_host =
api_key =
api_access =

[dir]
watch_dir =
file_patterns = [ "*.js","*.css","*.htm", "*.jpg", "*.yaml", "*.ico", "*.png" ]
ignore_patterns = [ "*.tmp", "*.TMP", "*/.git*" ]

[store]
store_host =
2 changes: 1 addition & 1 deletion pages/contact/page-contact.htm
Expand Up @@ -31,7 +31,7 @@ <h3>Need to send a message?</h3>
<textarea rows="10" class="required input-sm form-control" placeholder="Message*" value="" name="fields[message]" id="fields_message"></textarea>
<span class="error"></span>
</div>
<input type="hidden" name="redirect" value="/sample"/>
<input type="hidden" name="redirect" value="{{ site_url('/') }}"/>
<input type="submit" class="btn-default btn" value="Submit"/>
<input type="text" name="hp" value="" style="display: none"/>
</div>
Expand Down
6 changes: 6 additions & 0 deletions pages/product/page-product.htm
Expand Up @@ -16,3 +16,9 @@
<h2>We are sorry, the requested product was not found.</h2>
{% endif %}
{{ close_form() }}
{{ partial('shop-product-review-form') }}
{{ partial('shop-product-review') }}




13 changes: 0 additions & 13 deletions pages/sample/page-sample.htm

This file was deleted.

67 changes: 67 additions & 0 deletions partials/shop-product-review-form.htm
@@ -0,0 +1,67 @@
<!-- Modal -->
<div class="modal fade" id="writeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h2 class="modal-title" id="myModalLabel">Review {{ product.name }}</h2>
</div>
<div class="modal-body">
{{ flash() }}
{{ open_form({'data-ajax-handler': 'system:onSendMessage'}) }}

<div class="row">
<div>
<input type="text" class="input-sm form-control" id="contact_name" name="fields[name]" value="" placeholder="Your name"/>
<span class="error"/><br><br>
</div>
</div>
<div class="row">
<div>
<input type="text" class="input-sm form-control" id="contact_email" name="fields[email]" value="" placeholder="Email address"/>
<span class="error"/><br><br>
</div>
</div>
<div class="row">
<div>
<input type="text" class="input-sm form-control" id="subject" name="fields[subject]" value="" placeholder="Title for your review"/>
<span class="error"/><br><br>
</div>
</div>
<div class="row">
<div>
<textarea class="input-sm form-control" id="contact_message" name="fields[message]" value="" rows="10" placeholder="Your review"></textarea>
<span class="error"/>
</div>
</div>
<div class="row">
<div class="rating">
<span id="love"></span><span id="like"></span><span id="ok"></span><span id="dont-like"></span><span id="hate"></span>
<p>&nbsp;</p>
</div>
<div>
<select style="display:none" id="item_rating" name="fields[item_rating]">
<option value="" diabled>-</option>
<option value="1">&starf;&star;&star;&star;&star;</option>
<option value="2">&starf;&starf;&star;&star;&star;</option>
<option value="3">&starf;&starf;&starf;&star;&star;</option>
<option value="4">&starf;&starf;&starf;&starf;&star;</option>
<option value="5">&starf;&starf;&starf;&starf;&starf;</option>
</select>
<span class="error"/>
</div>
</div>

</div>
<div class="modal-footer">
<input type="submit" class="btn btn-important" value="Submit" style="width: 100%"/>
<input type="text" name="hp" value="" style="display: none"/>
<input type="hidden" name="fields[shop_customer_id]" value="{{customer.id}}"/>
<input type="hidden" name="fields[shop_product_id]" value="{{product.id}}"/>
<input type="hidden" name="template" value="system:product-review"/>
<input type="hidden" name="fields[message_type]" value="review"/>
</div>
{{ close_form() }}
</div>
</div>
</div>
74 changes: 74 additions & 0 deletions partials/shop-product-review.htm
@@ -0,0 +1,74 @@
<!-- Modal -->
<div class="modal fade" id="viewModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h2 class="modal-title" id="myModalLabel">{{ product.name }}</h2>
{% set product_rating = product.rating() %}
<div class="review-header">
<p>
{% if product_rating.total_reviews %}
<span style="margin-right: -4px">
{% for i in range(1, product_rating.average_int) %}&starf;{% endfor %}
</span>
{% if product_rating.average_int != 5 %}
{% for i in range(1, 5 - product_rating.average_int) %}&star;{% endfor %}
{% endif %}
Based on {{ product_rating.total_reviews }} Reviews
{% endif %}
</p>
</div>
<div class="review-header" style="text-align: right">
<strong><a href="#reviews" data-dismiss="modal" >Write a Review</a></strong>
</div>
</div>
<div class="modal-body">

<div class="reviews">

<div>

{% for review in product.reviews() %}

{% if review.item_rating == 5 %}
<div class="review-body">&starf;&starf;&starf;&starf;&starf;</div>
{% endif %}
{% if review.item_rating == 4 %}
<div class="review-body">&starf;&starf;&starf;&starf;&star;</div>
{% endif %}
{% if review.item_rating == 3 %}
<div class="review-body">&starf;&starf;&starf;&star;&star;</div>
{% endif %}
{% if review.item_rating == 2 %}
<div class="review-body">&starf;&starf;&star;&star;&star;</div>
{% endif %}
{% if review.item_rating == 1 %}
<div class="review-body">&starf;&star;&star;&star;&star;</div>
{% endif %}

<div class="review-body" style="text-align: right; font-size: 1.1rem;">
<p>{{ review.created_at|date('M jS, Y') }}</p>

</div>
<div class="review-body" >

<p><strong>{{ review.title }}</strong></p>
<p><em>{{ review.comment }}</em></p>
</div>
<div class="review-body" style="text-align: right; font-size: 1.1rem;">
<p>{{ review.from_name }}</p>
</div>


<hr>

{% endfor %}

</div>

</div>

</div>
</div>
</div>
38 changes: 29 additions & 9 deletions partials/shop-product.htm
Expand Up @@ -21,12 +21,6 @@
</div>

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Indicators -->
<!-- <ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol> -->

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
Expand Down Expand Up @@ -98,9 +92,35 @@ <h2>{{ product.manufacturer.name }}</h2>
</div>
</div>
<div class="add-to-cart-div">
<a class="btn btn-important add-to-cart" data-ajax-handler="shop:onAddToCart" data-ajax-update="#product-page=shop-product, #mini-cart=shop-minicart, #cart-totals=shop-minicart-totals" >Add to Cart </a>

<a class="btn btn-important add-to-cart" data-ajax-handler="shop:onAddToCart" data-ajax-update="#product-page=shop-product, #mini-cart=shop-minicart, #cart-totals=shop-minicart-totals" >Add to Cart </a>
</div>
</div>

<!-- Button trigger modal -->
<div class="col-md-12">
<hr>
{% set product_rating = product.rating() %}
<p>
{% if product_rating.total_reviews %}
<span style="margin-right: -4px">
{% for i in range(1, product_rating.average_int) %}&starf;{% endfor %}
</span>
{% if product_rating.average_int != 5 %}{% for i in range(1, 5 - product_rating.average_int) %}&star;{% endfor %}{% endif %}
({{ product_rating.total_reviews }})
{% else %}
&star;&star;&star;&star;&star;
(no reviews yet)
{% endif %}

<span class="modal-controls">
{% if product_rating.total_reviews %}
<a href="#reviews" data-toggle="modal" data-target="#writeModal">write</a>
<a href="#reviews" data-toggle="modal" data-target="#viewModal">view</a>
{% else %}
<a href="#reviews" data-toggle="modal" data-target="#writeModal">write</a>
{% endif %}
</span>
</p>
</div>

<div class="to-cart-flash col-md-12">
Expand All @@ -116,7 +136,7 @@ <h2>{{ product.manufacturer.name }}</h2>
<h5>This product is temporarily unavailable</h5>
<div>
{% endif %}


</div>
</div>
Expand Down
60 changes: 58 additions & 2 deletions resources/js/main.js
Expand Up @@ -59,7 +59,7 @@ $('.banner').hammer().bind('swipeleft', function() {
// Move Login and Cart to top of nav on mobile
$('.navbar-right').prependTo('.navbar-collapse');

// animate falsh message ('add to cart') off screen.
// animate falsh message ('add to cart').
$( document ).ajaxSuccess(function( event, request, settings ) {
if ( $( '.to-cart-flash > .success' ).length ) {
var customeMsg = $( '.custome-msg' ).text();
Expand All @@ -85,9 +85,17 @@ $('.banner').hammer().bind('swipeleft', function() {
});

$(window).scroll(function() {
var scrollTop = $(window).scrollTop(),

var scrollTop;
var elementOffset;
var distance;

if ( $('.home-box').length ) {
scrollTop = $(window).scrollTop(),
elementOffset = $('.home-box').offset().top,
distance = (elementOffset - scrollTop);
}

if (distance <= 200 && windowWidth() <= 768) {
$('.home-box-content').show();

Expand All @@ -106,4 +114,52 @@ $('.banner').hammer().bind('swipeleft', function() {
}
}); // END

// Star Rating
$('.rating > span').click(function() {
var currentId = $(this).attr('id');
if ( currentId === 'hate' ) {
$('#hate').addClass('select');
$( '#dont-like, #ok, #like, #love' ).removeClass('select');
$('.rating > p').text( 'I hate it' );
$("#item_rating").val('1');
}
if ( currentId === 'dont-like' ) {
$( '#hate, #dont-like' ).addClass('select');
$( '#ok, #like, #love' ).removeClass('select');
$('.rating > p').text( 'I don\'t like it' );
$("#item_rating").val('2');
}
if ( currentId === 'ok' ) {
$( '#hate, #dont-like, #ok' ).addClass('select');
$( '#like, #love' ).removeClass('select');
$('.rating > p').text( 'It\'s ok' );
$("#item_rating").val('3');
}
if ( currentId === 'like' ) {
$( '#hate, #dont-like, #ok, #like' ).addClass('select');
$( '#love' ).removeClass('select');
$('.rating > p').text( 'I like it' );
$("#item_rating").val('4');
}
if ( currentId === 'love' ) {
$( '#hate, #dont-like, #ok, #like, #love' ).addClass('select');
$('.rating > p').text( 'I love it' );
$("#item_rating").val('5');
}

}); // END

// Review Modal
$('.review-header a').click(function() {
$('#writeModal').modal({
show: true
});
});
$('#writeModal').on('hidden.bs.modal', function () {
$('body').css({
'padding-right':'0'
});
}); // END


});

0 comments on commit 4640f38

Please sign in to comment.