Sha256: afb5f8df4d940497b5e143f045545c881d5541dc2c2593a616ce49f9b9cb366f

Contents?: true

Size: 1.49 KB

Versions: 37

Compression:

Stored size: 1.49 KB

Contents

document.observe("dom:loaded", function() {
  shop_product_index = new ShopProductIndex();
  shop_product_index.initialize();
})

var ShopProductIndex = Class.create({
  
  initialize: function() {
    this.sortCategories();
    this.sortProducts();
  },
  
  sortCategories: function() {
    var route = shop.getRoute('sort_admin_shop_categories_path');
    
    Sortable.create('categories', {
      overlap:    'vertical',
      only:       'category',
      handle:     'move',
      onUpdate: function() {
        new Ajax.Request(route, {
          method: 'put',
          parameters: {
            'categories':   Sortable.serialize('categories')
          }
        })
      }
    })
  },
  
  sortProducts: function() {
    var route = shop.getRoute('sort_admin_shop_products_path');
    
    var categories = new Array();
    $$('li.category').each(function(el) {
      categories.push($(el).id + '_products');
    })
    
    categories.each(function(category) { 
      Sortable.create(category, {
        overlap:      'vertical',
        only:         'product',
        handle:       'move',
        dropOnEmpty:  true,
        hoverclass:   'hover',
        containment:  categories,
        onUpdate: function() {
          new Ajax.Request(route, {
            method:   'put',
            parameters: {
              'category_id':  $(category).readAttribute('data-id'),
              'products':     Sortable.serialize(category)
            }
          })
        }.bind(this)
      })
    })
  }
  
})

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
radiant-shop-extension-0.94.8 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.7 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.6 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.5 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.4 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.3 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.2 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.1 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.94.0 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.93.3 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.93.2 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.93.1 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.93.0 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.11 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.10 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.9 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.8 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.7 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.6 public/javascripts/admin/extensions/shop/products/index.js
radiant-shop-extension-0.92.3 public/javascripts/admin/extensions/shop/products/index.js