$((function(){$(".image-url-generator").each((function(){var i=$(this),e=i.find("form"),d=e.find("select#id_filter_method"),l=e.find("input#id_width"),a=e.find("input#id_height"),r=e.find("input#id_closeness"),n=i.find("#result-url"),o=i.find(".loading-mask"),p=i.find("img.preview"),s=$("#note-size"),t=i.data("generatorUrl");function c(){var i=d.val();o.addClass("loading"),"original"===i?(l.prop("disabled",!0),a.prop("disabled",!0),r.prop("disabled",!0)):"width"===i?(l.prop("disabled",!1),a.prop("disabled",!0),r.prop("disabled",!0),i+="-"+l.val()):"height"===i?(l.prop("disabled",!0),a.prop("disabled",!1),r.prop("disabled",!0),i+="-"+a.val()):"min"!==i&&"max"!==i&&"fill"!==i||(l.prop("disabled",!1),a.prop("disabled",!1),"fill"===i?(r.prop("disabled",!1),i+="-"+l.val()+"x"+a.val()+"-c"+r.val()):(r.prop("disabled",!0),i+="-"+l.val()+"x"+a.val())),l.val()>$(window).width()?s.show():s.hide(),$.getJSON(t.replace("__filterspec__",i)).done((function(i){n.val(i.url),p.attr("src",i.preview_url),o.removeClass("loading")})).fail((function(i){n.val(i.responseJSON.error),p.attr("src",""),o.removeClass("loading")}))}e.on("change",$.debounce(500,c)),e.on("keyup",$.debounce(500,c)),c(),n.on("click",(function(){$(this).trigger("select")}))}))}));