{I" class:ETI"ProcessedAsset;FI"logical_path;TI" spree/backend/promotions.js;FI" pathname;TI"o/usr/local/rvm/gems/ruby-2.1.2/gems/spree_backend-2.2.4/app/assets/javascripts/spree/backend/promotions.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+TI" length;TiY I" digest;TI"%b40bf1fbbf0e3040fc616f93d17dcbfc;FI" source;TI"Y var initProductActions = function () { 'use strict'; // Add classes on promotion items for design $(document).on('mouseover mouseout', 'a.delete', function (event) { if (event.type === 'mouseover') { $(this).parent().addClass('action-remove'); } else { $(this).parent().removeClass('action-remove'); } }); $('#promotion-filters').find('.variant_autocomplete').variantAutocomplete(); $('.calculator-fields').each(function () { var $fields_container = $(this); var $type_select = $fields_container.find('.type-select'); var $settings = $fields_container.find('.settings'); var $warning = $fields_container.find('.warning'); var originalType = $type_select.val(); $warning.hide(); $type_select.change(function () { if ($(this).val() === originalType) { $warning.hide(); $settings.show(); $settings.find('input').removeProp('disabled'); } else { $warning.show(); $settings.hide(); $settings.find('input').prop('disabled', 'disabled'); } }); }); // // CreateLineItems Promotion Action // (function () { var hideOrShowItemTables = function () { $('.promotion_action table').each(function () { if ($(this).find('td').length === 0) { $(this).hide(); } else { $(this).show(); } }); }; hideOrShowItemTables(); // Remove line item var setupRemoveLineItems = function () { $('.remove_promotion_line_item').on('click', function () { var line_items_el = $($('.line_items_string')[0]); var finder = new RegExp($(this).data('variant-id') + "x\\d+"); line_items_el.val(line_items_el.val().replace(finder, '')); $(this).parents('tr').remove(); hideOrShowItemTables(); }); }; setupRemoveLineItems(); // Add line item to list $('.promotion_action.create_line_items button.add').unbind('click').click(function () { var $container = $(this).parents('.promotion_action'); var product_name = $container.find('input[name="add_product_name"]').val(); var variant_id = $container.find('input[name="add_variant_id"]').val(); var quantity = $container.find('input[name="add_quantity"]').val(); if (variant_id) { // Add to the table var newRow = '' + product_name + '' + quantity + ''; $container.find('table').append(newRow); // Add to serialized string in hidden text field var $hiddenField = $container.find('.line_items_string'); $hiddenField.val($hiddenField.val() + ',' + variant_id + 'x' + quantity); setupRemoveLineItems(); hideOrShowItemTables(); } return false; }); })(); }; $(document).ready(function () { initProductActions(); }); ;TI"dependency_digest;TI"%5e1a76c466ef1c9ff4a280dc93842540;FI"required_paths;T[I"o/usr/local/rvm/gems/ruby-2.1.2/gems/spree_backend-2.2.4/app/assets/javascripts/spree/backend/promotions.js;FI"dependency_paths;T[{I" path;TI"o/usr/local/rvm/gems/ruby-2.1.2/gems/spree_backend-2.2.4/app/assets/javascripts/spree/backend/promotions.js;FI" mtime;TI"2014-09-04T18:28:45-04:00;TI" digest;TI"%928fdb2f364092bc4a61f56907142c38;FI" _version;TI"%5ef14a844324cba3e114bd0123f88a5e;F