Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prefer usage of data-behavior

  • Loading branch information...
commit 84b3ef0f844515b96b19385434e663c60552025f 1 parent d011c7b
@neerajdotname neerajdotname authored
View
2  nimbleshop_core/app/assets/javascripts/admin/products/edit.js.coffee
@@ -13,7 +13,7 @@ Nimbleshop.managePicture = class ManagePicture
@makePictureSortable()
deletePicture: ->
- $(".product_pictures .actions .delete").on "click", ->
+ $('[data-behavior~=delete-product-picture]').on 'click', ->
$("#delete_picture_" + $(this).attr("data-action-id")).trigger "click"
$(this).parent().parent().hide "fast"
false
View
10 nimbleshop_core/app/assets/javascripts/admin/shipit.js.coffee
@@ -1,10 +1,10 @@
$ ->
- $("a.ship-items-link").on 'click', ->
+ $('[data-behavior~=ship-items]').on 'click', ->
$(this).hide()
- $("#ship_items_action_box").show()
+ $('[data-behavior~=ship-items-box]').show()
false
- $("#ship_items_cancel").on "click", ->
- $("a.ship-items-link").show()
- $("#ship_items_action_box").hide()
+ $('[data-behavior~=ship-items-cancel]').on 'click', ->
+ $('[data-behavior~=ship-items]').show()
+ $('[data-behavior~=ship-items-box]').hide()
false
View
6 nimbleshop_core/app/views/admin/orders/_shipping_info.html.erb
@@ -8,7 +8,7 @@
<div class='shipment_tracking_info'>
<% if @order.shipping_pending? %>
- <%= link_to 'Ship items', '#', class: 'btn btn-success ship-items-link' %>
+ <%= link_to 'Ship items', '#', class: 'btn btn-success', 'data-behavior' => 'ship-items' %>
<% elsif @order.shipped? %>
<p>
Shipped on <%= @shipment.created_at.to_s(:long) %> <br/>
@@ -16,7 +16,7 @@
</p>
<% end %>
- <div id='ship_items_action_box' style='display:none;'>
+ <div id='ship_items_action_box' style='display:none;' data-behavior='ship-items-box'>
<%= form_for([:admin, @order, @shipment], html: {class: 'well form-inline'}) do |f| %>
<p>
<%= f.select :shipment_carrier_id, ShipmentCarrier.all.collect {|p| [p.name, p.id] }, {}, class: 'span2' %>
@@ -25,7 +25,7 @@
</p>
<p>
<%= f.submit 'Submit', class: 'btn btn-primary' %>
- <%= link_to 'Cancel', '#', id: 'ship_items_cancel' %>
+ <%= link_to 'Cancel', '#', id: 'ship_items_cancel', 'data-behavior' => 'ship-items-cancel' %>
</p>
<% end %>
</div>
View
2  nimbleshop_core/app/views/admin/products/_handle_pictures.html.erb
@@ -12,7 +12,7 @@
<%= link_to '#', class: 'move' do %>
<i class='icon-move icon-white'></i>
<% end %>
- <%= link_to '#', class: 'delete', "data-action-id" => picture.id do %>
+ <%= link_to '#', class: 'delete', "data-action-id" => picture.id, 'data-behavior' => 'delete-product-picture' do %>

Do you know about the data hash?

data: { action_id: picture.id, behavior: 'delete-product-picture' }

Underscores are automatically converted to dashes.

@neerajdotname Owner

@jpzwarte That's super nice. Thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
<i class='icon-remove icon-white'></i>
<% end %>
</div>
View
2  themes/nimbleshop_simply/app/assets/javascripts/nimbleshop_simply/load_states.js.coffee
@@ -3,7 +3,7 @@ window.NimbleshopSimply = window.NimbleshopSimply || {}
class NimbleshopSimply.manageStates
stateCodeField: ($country) ->
- $country.parents("div.well").find("[name$='[state_code]']")
+ $country.parents('[data-behavior~=well]').find("[name$='[state_code]']")
createOption: (state) ->
($ "<option />", text: state[0], value: state[1])
View
2  ...imbleshop_simply/app/assets/javascripts/nimbleshop_simply/remove_item_from_cart.js.coffee
@@ -1,5 +1,5 @@
$ ->
- $("a.remove-item").on "click", ->
+ $('[data-behavior~=remove-item-from-cart]').on 'click', ->
$this = $(this)
permalink = $this.data("permalink")
$("#updates_" + permalink).val 0
View
2  themes/nimbleshop_simply/app/assets/javascripts/nimbleshop_simply/thumbnail.js.coffee
@@ -1,7 +1,7 @@
# mouse enter on thumbnail displays the image on the product show page
$ ->
- $("img.thumb").on "mouseenter", ->
+ $('[data-behavior~=product-image-thumbnail]').on 'mouseenter', ->
$this = $(this)
itemIndex = $(".thumb").index($this) + 1
$(".thumbnails li:nth-child(" + itemIndex + ")").show().siblings().hide()
View
2  themes/nimbleshop_simply/app/views/nimbleshop_simply/carts/_line_item.html.erb
@@ -10,7 +10,7 @@
<%= link_to line_item.product_name, line_item.product, title: line_item.product_name %>
</strong>
<br />
- <%= link_to 'Remove', '#', title: 'Remove', class: 'delete remove-item', 'data-permalink' => line_item.product_id %>
+ <%= link_to 'Remove', '#', title: 'Remove', class: 'delete remove-item', 'data-permalink' => line_item.product_id, 'data-behavior' => 'remove-item-from-cart' %>
</div>
<div class="span2">
View
2  ..._simply/app/views/nimbleshop_simply/checkout/shipping_addresses/_billing_address.html.erb
@@ -1,4 +1,4 @@
-<div class='well' id='billing_well'>
+<div class='well' id='billing_well' data-behavior='well' >
<%= f.fields_for :billing_address do |billing_form| %>
View
2  ...simply/app/views/nimbleshop_simply/checkout/shipping_addresses/_shipping_address.html.erb
@@ -1,4 +1,4 @@
-<div class='well'>
+<div class='well' data-behavior='well'>
<%= f.fields_for :shipping_address do |shipping_form| %>
View
3  themes/nimbleshop_simply/app/views/nimbleshop_simply/products/show.html.erb
@@ -10,7 +10,6 @@
<%= link_to(image_tag(picture.picture_url(:large), alt: @product.name), picture.picture_url(:large_plus),
class: 'thumbnail fancybox',
rel: 'gallery1') %>
-
</li>
<% end %>
</ul>
@@ -24,7 +23,7 @@
<% if picture.blank? %>
&nbsp;
<% else %>
- <%= image_tag picture.picture_url(:small), alt: @product.name, class: 'thumb thumbnail' %>
+ <%= image_tag picture.picture_url(:small), alt: @product.name, class: 'thumb thumbnail', 'data-behavior' => 'product-image-thumbnail' %>
<% end %>
</td>
<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.