Skip to content

Commit

Permalink
Remove x-editable, bootstrap wysiwyg, initial product level tag input…
Browse files Browse the repository at this point in the history
…, smart.json update to point at fork of ui-dropped-event
  • Loading branch information
aaronjudd committed Apr 11, 2014
1 parent cb9e0f9 commit e0027b1
Show file tree
Hide file tree
Showing 186 changed files with 252 additions and 52,863 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
color: @input-color-placeholder;
left: 4px;
top: 5px;
padding-left: 4px;
}
input {
padding-left: 25px;
Expand All @@ -47,6 +48,7 @@
right: 6px;
top: 5px;
color: @input-color-placeholder;
padding-right: 4px;
}
#tags-submit-new {
padding-left: 5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@ Template.productDetail.helpers
Tags.find({_id: {$in: product.tagIds}}).fetch()
else
[]
stringify: (tags) ->
_.pluck(tags, "name").join(", ")

tagsComponent: ->
if Meteor.app.hasOwnerAccess()
return Template.productTagInputForm
else
return null

actualPrice: () ->
(currentProduct.get "variant")?.price

component: (field) ->
fieldComponent: (field) ->
if Meteor.app.hasOwnerAccess()
return Template.productDetailEdit
else
return Template.productDetailField


Template.productDetail.events
"click #price": ->
id = currentProduct.get("variant")._id
$('#variant-edit-form-'+id).fadeIn()

"click #add-to-cart-quantity": (event,template) ->
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -84,28 +92,32 @@ Template.productDetail.events
else
Alerts.add "Select an option before adding to cart"

"click .toggle-product-isVisible-link": (event, template) ->
Products.update(template.data._id, {$set: {isVisible: !template.data.isVisible}})

# *****************************************************
# deletes entire product
# TODO: implement revision control by using
# suspended = boolean // not visible on site
# archived = boolean // not visible in admin
# this function is a full delete
# TODO: delete from archived list
# *****************************************************
"click .delete": (event) ->
event.preventDefault()
if confirm("Delete this product?")
Products.remove (currentProduct.get "product")._id
Router.go "/"
"click .fa-facebook": ->
if Meteor.app.hasOwnerAccess()
$(".facebookMsg-edit").fadeIn()
$(".facebookMsg-edit-input").focus()

"click #edit-options": (event) ->
$("#options-modal").modal()
event.preventDefault()
"click .fa-twitter": ->
if Meteor.app.hasOwnerAccess()
$(".twitterMsg-edit").fadeIn()
$(".twitterMsg-edit-input").focus()

"click .toggle-product-isVisible-link": (event, template) ->
Products.update(template.data._id, {$set: {isVisible: !template.data.isVisible}})
"click .fa-pinterest": ->
if Meteor.app.hasOwnerAccess()
$(".pinterestMsg-edit").fadeIn()
$(".pinterestMsg-edit-input").focus()

"click .fa-instagram": ->
if Meteor.app.hasOwnerAccess()
$(".instagramMsg-edit").fadeIn()
$(".instagramMsg-edit-input").focus()

"focusout .facebookMsg-edit-input,.twitterMsg-edit-input,.pinterestMsg-edit-input": ->
Session.set "editing-"+this.field, false
$('.social-media-inputs > *').hide()

Template.productDetail.rendered = ->
if Meteor.app.hasOwnerAccess()
Expand Down Expand Up @@ -185,4 +197,61 @@ Template.productDetailField.events
$('.' + this.field + '-edit-input').focus()

Template.productDetailEdit.rendered = () ->
$('textarea').autosize()
$('textarea').autosize()

Template.productTagInputForm.events
'click #btn-tags-cancel, click body': (event,template) ->
currentTag = Session.get "currentTag"
Session.set "isEditing-"+currentTag, false

'click .tag-input-group-remove': (event,template) ->
currentTag = Session.get "currentTag"
Meteor.call "removeProductTag", @._id, currentTag

'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", $(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", $(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"
axis: "x"
handle: '.tag-input-group-handle'
update: (event, ui) ->
uiPositions = $(@).sortable("toArray", attribute:"data-tag-id")
for tag,index in uiPositions
Tags.update(tag, {$set: {position: index}})
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<!-- Titles -->
<div class="row">
<div class="title">
<h1 id="title" itemprop="name">{{>component field="title" value=title}}</h1>
<h1 id="title" itemprop="name">{{>fieldComponent field="title" value=title}}</h1>
</div>
<div class="pageTitle">
<h2 id="pageTitle">{{>component field="pageTitle" value=pageTitle}}</h2>
<h2 id="pageTitle">{{>fieldComponent field="pageTitle" value=pageTitle}}</h2>
</div>
</div>
<!-- Product Details -->
Expand All @@ -38,37 +38,53 @@ <h2 id="pageTitle">{{>component field="pageTitle" value=pageTitle}}</h2>
<!-- END Left Side -->
<!-- BEGIN Right Side -->
<div class="col-sm-7 pdp-right-column">
<div class="row">
<div class="col-xs-8">
{{!-- Price Fixation --}}
<div>
<span class="price">
<i class="fa fa-usd currency-symbol"></i>
<span id="price" itemprop="price">{{actualPrice}}</span>
</span>
</div>
{{!-- Vendor / subtext --}}
<div class="vendor">
{{>fieldComponent field="vendor" value=vendor}}
</div>
</div>
<div class="col-xs-3 col-xs-offset-1">
{{!-- Social Commentary --}}
{{#if userHasRole "admin"}}
<div class="social-media">
<a href="#"><i class="fa fa-facebook fa-lg"></i></a>
<a href="#"><i class="fa fa-twitter fa-lg"></i></a>
<a href="#"><i class="fa fa-pinterest fa-lg"> </i></a>
<a href="#"><i class="fa fa-instagram fa-lg"></i></a>
<div class="social-media-inputs">
{{>fieldComponent field="facebookMsg" value=facebookMsg}}
{{>fieldComponent field="twitterMsg" value=twitterMsg}}
{{>fieldComponent field="pinterestMsg" value=pinterestMsg}}
{{>fieldComponent field="instagramMsg" value=instagramMsg}}
</div>
</div>
{{else}}
{{>productSocial}}
{{/if}}
</div>
</div>
<!-- main product information -->
<div class="row col-md-11">
{{!-- Price Fixation --}}
<div class="row">
<i class="fa fa-usd currency-symbol"> </i>
<span class="price">
<span id="price" itemprop="price">{{actualPrice}}</span>
</span>
{{>productSocial}}
</div>

{{!-- Vendor --}}
{{!-- Description --}}
<div class="row">
{{>component field="vendor" value=vendor}}
{{>fieldComponent field="description" value=description type="textarea"}}
</div>

{{!-- Tags --}}
<div class="row">
<div class="tags">
{{#if userHasRole "admin"}}
<a href="#" id="tags" data-type="select2" data-value="{{stringify tags}}"></a>
{{/if}}
</div>
<div class="row tags">
{{>tagsComponent tags=tags}}
</div>

{{!-- Description --}}
<div class="row">
{{>component field="description" value=description type="textarea"}}
</div>

{{!-- Variants --}}
{{!-- Variants & Options --}}
<div class="row options-add-to-cart">
{{>variantList}}
</div>
Expand All @@ -94,9 +110,9 @@ <h2 id="pageTitle">{{>component field="pageTitle" value=pageTitle}}</h2>

<template name="productDetailEdit">
{{#if condition type "eq" "textarea"}}
<div class="product-detail-edit {{field}}-edit">
<p class="lead product-detail-edit {{field}}-edit">
<textarea class="{{field}}-edit-input" placeholder="add a product {{camelToSpace field}}">{{value}}</textarea>
</div>
</p>
{{else}}
<div class="product-detail-edit {{field}}-edit">
<input type="text" value="{{value}}" class="{{field}}-edit-input" placeholder="product {{camelToSpace field}}"/>
Expand All @@ -106,7 +122,40 @@ <h2 id="pageTitle">{{>component field="pageTitle" value=pageTitle}}</h2>
</template>

<template name="productDetailField">
<span class="product-detail-field {{field}}">
{{value}}
</span>
{{#if condition type "eq" "textarea"}}
<p class="lead product-detail-field {{field}}">
{{value}}
</p>
{{else}}
<div class="product-detail-field {{field}}">
{{value}}
</div>
{{/if}}
</template>

<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-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>
Loading

0 comments on commit e0027b1

Please sign in to comment.