Skip to content

Instantly share code, notes, and snippets.

@jsqu99
Created April 14, 2014 02:28
Show Gist options
  • Save jsqu99/10611585 to your computer and use it in GitHub Desktop.
Save jsqu99/10611585 to your computer and use it in GitHub Desktop.
(function($) {
$.extend($.fn, {
makeCssInline: function() {
this.each(function(idx, el) {
var style = el.style;
var properties = [];
for(var property in style) {
if($(this).css(property)) {
properties.push(property + ':' + $(this).css(property));
}
}
this.style.cssText = properties.join(';');
$(this).children().makeCssInline();
});
}
});
}(jQuery));
function sendToServer(){
var html_field = $("#amount_times_constant_input_1");
var zip_field = $("#amount_times_constant_input_3");
var flattened_field = $("#amount_times_constant_input_4");
$("h2").makeCssInline();
var html = $("#contents").html();
var bg_url = $("#stage").css('background-image').replace('url(','').replace(')','');
$.ajax({
type: "POST",
url: artwork_processor_url+"/serialize-html",
data: {html:html, uuid:uuid, bg_url:bg_url},
success: function (data){
flattened_url = data['flattened_url'];
pdf_url = data['pdf_url'];
html_field.val(html);
zip_field.val(pdf_url);
flattened_field.val(flattened_url);
$("#cart-form form").submit();
}
});
}
function addToCart(){
sendToServer();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment