Created
April 14, 2014 02:28
-
-
Save jsqu99/10611585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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