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