-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Product detail hashtag manager / view
- Loading branch information
Showing
13 changed files
with
207 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/reaction-commerce/client/templates/products/productDetail/tags/tags.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Template.productDetailTags.helpers | ||
currentHashTag: () -> | ||
if currentProduct.get("product").handle is @.name | ||
return true | ||
Template.productTagInputForm.helpers | ||
hashtagMark: () -> | ||
if currentProduct.get("product").handle is @.name | ||
return "fa-bookmark" | ||
else | ||
return "fa-bookmark-o" | ||
|
||
Template.productTagInputForm.events | ||
'click .tag-input-hashtag': (event,template) -> | ||
Products.update(currentProduct.get("product")._id, {$set:{"handle":@.name}}) | ||
Router.go "product", "_id": @.name | ||
|
||
'click .tag-input-group-remove': (event,template) -> | ||
Meteor.call "removeProductTag",currentProduct.get("product")._id, @._id | ||
|
||
'click .tags-input-select': (event,template) -> | ||
$(event.currentTarget).autocomplete( | ||
delay: 0 | ||
autoFocus: true | ||
source: (request, response) -> | ||
datums = [] | ||
slug = _.slugify(request.term) | ||
Tags.find({slug: new RegExp(slug, "i")}).forEach (tag) -> | ||
datums.push( | ||
label: tag.name | ||
) | ||
response(datums) | ||
) | ||
Deps.flush() | ||
|
||
'change .tags-input-select': (event,template) -> | ||
currentTag = Session.get "currentTag" | ||
Meteor.call "updateProductTags", currentProduct.get("product")._id, $(event.currentTarget).val(), @._id, currentTag | ||
$('#tags-submit-new').val('') | ||
$('#tags-submit-new').focus() | ||
# Deps.flush() | ||
|
||
'blur.autocomplete': (event,template) -> | ||
if $(event.currentTarget).val() | ||
currentTag = Session.get "currentTag" | ||
Meteor.call "updateProductTags", currentProduct.get("product")._id, $(event.currentTarget).val(), @._id, currentTag | ||
Deps.flush() | ||
$('#tags-submit-new').val('') | ||
$('#tags-submit-new').focus() | ||
|
||
'mousedown .tag-input-group-handle': (event,template) -> | ||
Deps.flush() | ||
$(".tag-edit-list").sortable("refresh") | ||
|
||
Template.productTagInputForm.rendered = -> | ||
# ***************************************************** | ||
# Inline field editing, handling | ||
# http://vitalets.github.io/x-editable/docs.html | ||
# ***************************************************** | ||
$(".tag-edit-list").sortable | ||
items: "> li" | ||
handle: '.tag-input-group-handle' | ||
update: (event, ui) -> | ||
hashtagsList = [] | ||
uiPositions = $(@).sortable("toArray", attribute:"data-tag-id") | ||
for tag,index in uiPositions | ||
if tag then hashtagsList.push tag | ||
|
||
Products.update(currentProduct.get("product")._id, {$set: {hashtags: hashtagsList}}) |
41 changes: 41 additions & 0 deletions
41
packages/reaction-commerce/client/templates/products/productDetail/tags/tags.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template name="productTagInputForm"> | ||
<ul class="list-inline tag-edit-list" id="tag-edit-list"> | ||
{{#each ./tags}} | ||
<li data-tag-id="{{_id}}"> | ||
<div class="tag-input-group"> | ||
<span class="tag-input-group-handle"> | ||
<i class="fa fa-bars"></i> | ||
</span> | ||
<span class="tag-input"> | ||
<input type="text" class="tags-input-select" value="{{name}}" placeholder="Edit tags"/> | ||
</span> | ||
<span class="tag-input-hashtag"> | ||
<i class="fa {{hashtagMark}}"></i> | ||
</span> | ||
<span class="tag-input-group-remove"> | ||
<i class="fa fa-times-circle"></i> | ||
</span> | ||
</div> | ||
</li> | ||
{{/each}} | ||
<li data-tag-id="{{_id}}"> | ||
<div class="tag-input-group"> | ||
<span class="tag-input"> | ||
<input type="text" class="tags-input-select" value="{{name}}" placeholder="Add tags" id="tags-submit-new" autofocus/> | ||
</span> | ||
</div> | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<template name="productDetailTags"> | ||
<ul class="list-inline"> | ||
{{#each ./tags}} | ||
{{#unless currentHashTag}} | ||
<li class="list-group-item product-detail-tags-list"> | ||
<a href="{{pathForSEO "product/tag" "name"}}">{{name}}</a> | ||
</li> | ||
{{/unless}} | ||
{{/each}} | ||
</ul> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
packages/reaction-commerce/client/templates/products/productDetail/tags/tags.import.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.pdp-container { | ||
.product-detail-tags-list { | ||
padding-top: 3px; | ||
padding-bottom: 3px; | ||
} | ||
.tags { | ||
ul,li { | ||
position: relative; | ||
input { | ||
padding-left: 30px; | ||
padding-right: 40px; | ||
min-width: 175px; | ||
} | ||
float:none !important; | ||
|
||
} | ||
.tag-input-hashtag { | ||
position: absolute; | ||
right: 16px; | ||
top: 5px; | ||
color: @brand-success; | ||
padding-right: 14px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.