ecl1pse/spree_flash_sales

View on GitHub
app/assets/javascripts/admin/spree_flash_sales.js.erb

Summary

Maintainability
Test Coverage
//= require admin/spree_backend
//= require jquery.datetimepicker

handle_datetime_picker_fields = function(){
  $('.timepicker').datetimepicker({
    showOn: "focus",
    showTimezone: true,
    showSecond: true,
    dateFormat: "yy/mm/dd",
    timeFormat: "HH:mm:ss z",
    timeOnlyTitle: "Time only",
    timeText: "Time",
    hourText: "Hour",
    minuteText: "Minute",
    secondText: "Second",
    currentText: "Current",
    closeText: "Close"
  });

}

$(document).ready(function(){
  handle_datetime_picker_fields();
});


$(function() {
  $( "tbody#sortable" ).sortable({
    out: function() {
      send_order($( "#sortable" ).sortable( "serialize", { key: "flash_sale[product_sorting][]"}));
    }
  });
    $( "tbody#sortable" ).disableSelection();
  });

function send_order(value) {
  $.ajax({
            type: "POST",
            url: "",
            data: value, 
            dataType: 'json', 
            success: function(data) {
            }
    })
    .fail(function() {
            console.log( "error" );
    });
}