-
Notifications
You must be signed in to change notification settings - Fork 49
/
shopifyFD.min.js
127 lines (127 loc) · 72.1 KB
/
shopifyFD.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
(function(){if(0>document.URL.indexOf("myshopify.com/admin"))return alert("Error: Shopify Admin not found");if("undefined"===typeof Shopify)return alert("Error: Shopify object not found");if("undefined"===typeof jQuery)return alert("Error: jQuery not found");if(document.getElementById("shopifyfd-css"))"object"===typeof Shopify&&Shopify.Flash&&Shopify.Flash.error?Shopify.Flash.error("Error: ShopifyFD already loaded"):alert("Error: ShopifyFD already loaded");else if("classList"in document.createElement("_")&&
(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))){var p=window.shopifyfdTranslation||{save:"Save",edit:"Edit","delete":"Delete",about_shopifyfd:"About ShopifyFD",select_or_create_metafield:"Select or create a metafield",reload_page:"Reload page to check results.",add_new_metafield:"Add New Metafield",edit_metafield:"Edit Metafield",metafield_deleted:"Metafield deleted",hide_from_sitemap:"Hide from Sitemap"},k={alpha:!1,omega:!1,metafields:{},data:{},
cache:{}};(function(){var b=document.createElement("link");b.type="text/css";b.rel="stylesheet";b.id="shopifyfd-css";b.href="//freakdesign-us.s3.amazonaws.com/shopify/shopifyFD/s/shopifyFD.min.css?20160718";document.getElementsByTagName("head")[0].appendChild(b)})();var X='<label class="metafield-next-label next-label">'+p.add_new_metafield+'</label><input class="ssb" maxlength="20" type="text" id="metafield_namespace" placeholder="namespace" list="fd-dl-namespace"><datalist id="fd-dl-namespace"></datalist><input class="ssb" maxlength="30" type="text" id="metafield_key" placeholder="key" list="fd-dl-key"><datalist id="fd-dl-key"></datalist><textarea class="ssb" id="metafield_value" placeholder="value"></textarea><input type="hidden" id="metafield_id"><a class="btn btn-slim fd-btn savemymeta" id="shopifyjs_savemetafield">'+
p.save+'</a> <a class="int btn btn-slim fd-btn savemymeta" id="shopifyjs_savemetafield_int">Save as Integer</a> <a id="shopifyjs_copymetafield" class="btn btn-slim hide btn-primary tooltip tooltip-bottom"><span class="tooltip-container"><span class="tooltip-label">Copy Metafield to Virtual Clipboard</span></span>Copy</a> <a class="btn btn-slim hide delete tooltip tooltip-bottom" id="shopifyjs_deletemetafield"><span class="tooltip-container"><span class="tooltip-label">There is no undo. Be careful...</span></span>'+
p["delete"]+'</a><p style="margin:1em 0;line-height:1"><small><span class="metafield-save-note">Please note: Using the save button top right will NOT save these metafields. Be sure to click '+p.save+' above.<br><br></span><a id="advanced_meta_features" href="#">Toggle helper buttons</a></small></p><div id="advanced_meta" class="hide"><p style="border-bottom: 1px solid #ccc;margin-bottom:.5em">Handle Helper <a id="adv_clear_cache" style="float:right" href="#">Clear cache</a></p><p><a id="adv_get_collections" class="btn fd-btn" href="">Get collections</a></p><p><a id="adv_get_products" class="btn fd-btn" href="">Get 250 products</a></p></div>',
y='<option value="">'+p.select_or_create_metafield+"</option>",L='<div class="vbox fadein"><fieldset><select>'+y+'</select><input id="mv_namespace" placeholder="namespace" /><input id="mv_key" placeholder="key" /><input id="mv_value" placeholder="value" /></fieldset><span class="mybuttons"><a class="save btn btn-slim" href="#">'+p.save+'</a> <a class="btn btn-slim saveinteger" href="#">'+p.save+' as Integer</a> <a title="'+p["delete"]+'" class="btn-slim delete hidden" href="#">'+p["delete"]+"</a></span></div>",
Y='<div class="vbox-single-card next-card"><div class="next-card__section"><h2 class="next-heading--quarter-margin">Variant Metafields</h2><div id="vrow" class="single-variant">'+L+"</div></div></div>",C=function(b){"undefined"===typeof b&&(b=[location.protocol,"//",location.host,location.pathname].join(""));var c=b.split("/");b=c[c.length-2];c=c.pop();return[b,c,location.search.substring(1)]},E=function(b){return b.replace(/[\\]/g,"\\\\").replace(/["]/g,'\\"').replace(/[\/]/g,"\\/").replace(/[\b]/g,
"\\b").replace(/[\f]/g,"\\f").replace(/[\n]/g,"\\n").replace(/[\r]/g,"\\r").replace(/[\t]/g,"\\t")},r=function(b){if("undefined"!==typeof b&&"function"===typeof Turbolinks)try{Turbolinks.visit(b)}catch(c){return!1}},Z=function(b,c){return b.getAttribute("value")?c.getAttribute("value")?b.innerHTML>c.innerHTML?1:-1:1:-1},M=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(b){return!1}},f=function(b,c){"function"===typeof Shopify.Flash.error&&"function"===typeof Shopify.Flash.notice&&
(c?Shopify.Flash.error(b):Shopify.Flash.notice(b))},g=function(b,c){if("undefined"===typeof c)return k[b];k[b]=c},aa=function(){"undefined"===typeof k.data.themeId&&$.ajax({type:"GET",url:"/admin/themes.json",success:function(b){if(b){k.data.themes=b.themes;for(var c=0,a=b.themes.length;c<a;c++)"main"===b.themes[c].role&&(k.data.themeId=b.themes[c].id)}}})},N=function(b,c){if("undefined"===typeof b||!b)return!1;var a=$("iframe:first").contents().find("#tinymce:first");if(!a.length)return!1;a=a.html();
a={metafield:{namespace:"backups",key:b,value:a,value_type:"string"}};if("undefined"!==typeof c){if(0>window.location.href.indexOf("/admin/products/")||!$("#autosave").hasClass("active"))return!1;$("#autosave").addClass("is-loading").removeClass("active");a.metafield.namespace="autosave";a.metafield.key="html"}var d=[location.protocol,"//",location.host,location.pathname,"/metafields.json"].join("");"articles"===g("alpha")&&(d="/admin/articles/"+b+"/metafields.json");$.ajax({type:"POST",url:d,dataType:"json",
data:a,success:function(b){t();"undefined"===typeof c?f("Backup saved"):$("#autosave").removeClass("is-loading").addClass("active")},error:function(b){b=JSON.parse(b.responseText);f(b.errors.value[0],!0)}});return!0},z=function(b,c){"undefined"===typeof c&&(c=[location.protocol,"//",location.host,location.pathname].join(""));var a="/metafields.json",d=C(c),e=d[0];d=d[1];"undefined"===typeof b||isNaN(b)||(a="/metafields/"+b+".json");return"general"===d?"/admin"+a:c=[location.protocol,"//",location.host,
"/admin/",e,"/",d,a].join("")},u=function(b,c){var a=z()+"?limit=250",d=$("body");k.cache.fullscreenMetafield=$(".metafield-fullscreen-btn");if(k.cache.fullscreenMetafield.length)k.cache.fullscreenMetafield.on("click",function(){d.hasClass("fullscreen-metafield")?d.removeClass("fullscreen-metafield"):d.addClass("fullscreen-metafield")});$.getJSON(a,function(a){var c="",d=g("datalistNamespace")||["global","test","theme"],e=g("datalistKey")||[];if(a=a.metafields){g("m",a);g("hasbackup",!1);$("#restorebackup").hide();
"products"!==g("alpha")&&"collections"!==g("alpha")&&"pages"!==g("alpha")||ba();var h=$("#metacount");h.text(a.length).removeClass("hide");0===a.length&&h.addClass("hide");h=0;for(var n=a.length;h<n;h++)c+='<option data-type="'+a[h].value_type+'" data-id="'+a[h].id+'">'+a[h].namespace+"."+a[h].key+"</option>",k.metafields[a[h].id]={namespace:a[h].namespace,value:a[h].value,key:a[h].key},"backups"==a[h].namespace&&!1===g("hasbackup")&&($("#restorebackup").show(),g("hasbackup",!0),O()),"seo"===a[h].namespace&&
"hidden"===a[h].key&&1===a[h].value&&F(a[h].id),d.push(a[h].namespace),e.push(a[h].key);d=G(d);e=G(e);g("datalistNamespace",d);g("datalistKey",e);c='<select id="metafieldselect" class="ssb">'+y+c+"</select>"}else c='<select id="metafieldselect" class="ssb">'+y+"</select>";b.html(c).append(X);for(h=0;h<d.length;h++)c=$("<option />",{value:d[h]}),$("#fd-dl-namespace").append(c);for(h=0;h<e.length;h++)c=$("<option />",{value:e[h]}),$("#fd-dl-key").append(c);$("#advanced_meta_features").off("click").on("click",
function(){$("#advanced_meta").eq(0).toggleClass("hide");return!1});$("#adv_clear_cache").off("click").on("click",function(){$("#advanced_meta").find("select").remove().end().find("a").show();g("products",!1);g("collections",!1);return!1});$("#adv_get_products").off("click").on("click",function(){var a=$(this),b=function(b){for(var c="",d=$("<select />").change(function(){var a=$(this);$("#metafield_value").val(a.val())}).html('<option value="">Add product handle as value</option>'),e=0,q=b.products.length;e<
q;e++)c+='<option value="'+b.products[e].handle+'">'+b.products[e].title+"</option>";d.append(c);a.after(d).hide()};if(g("products")){var c=g("products");b(c)}else $.ajax({type:"GET",url:"/admin/products.json?limit=250",dataType:"json",success:function(a){a.products.length&&(g("products",a),b(a))},fail:function(){f("Failed to load products",!0)}});return!1});$("#adv_get_collections").off("click").on("click",function(){var a=$(this),b=function(b){for(var c="",d=$("<select />",{}).change(function(){var a=
$(this);$("#metafield_value").val(a.val())}).html('<option value="">Add collection handle as value</option>'),e=0,q=b.collections.length;e<q;e++)c+='<option value="'+b.collections[e].handle+'">'+b.collections[e].title+"</option>";d.append(c);a.after(d).hide()};if(g("collections")){var c=g("collections");b(c)}else $.ajax({type:"GET",url:"/admin/collections.json?limit=250",dataType:"json",success:function(a){a.collections.length&&(g("collections",a),b(a))},error:function(){f("Failed to load collections",
!0)}});return!1});$("#metafieldselect").change(function(){var a=$(this).find(":selected");if(a.attr("data-id")){var b=k.metafields[a.attr("data-id")];$(".metafield-next-label").text(p.edit_metafield);$("#metafield_namespace").val(b.namespace).prop("disabled",!0);$("#metafield_key").val(b.key).prop("disabled",!0);$("#metafield_value").val(b.value);$("#metafield_id").val(a.attr("data-id"));$("#shopifyjs_deletemetafield").removeClass("hide")}else P()});$("#shopifyjs_deletemetafield").on("click",function(a){a.preventDefault();
a=$("#metafield_id").val()||!1;if(!a)return f("Object ID Missing",!0),!1;a=z(a);-1<a.indexOf("?show_all_images")||-1<a.indexOf("products.json")||$.ajax({type:"DELETE",url:a,success:function(a){f(p.metafield_deleted);t()},error:function(a){f("Failed to delete",!0)}})});$(".metafield-content a.savemymeta").off("click").on("click",function(){var a="string";$(this).hasClass("int")&&(a="integer");var b=$("#metafield_namespace").val(),c=$("#metafield_key").val(),d=$("#metafield_value").val(),e=$("#metafield_id").val();
b={metafield:{namespace:b,key:c,value:d,value_type:a}};a={metafield:{id:e,value:d,value_type:a}};5<e.length?(e=z(e),$.ajax({type:"PUT",url:e,dataType:"json",data:a,success:function(a){t();w(a);f("Metafield updated")}})):(e=z(),$.ajax({type:"POST",url:e,dataType:"json",data:b,success:function(a){t();f("Metafield saved")},error:function(a){a=JSON.parse(a.responseText);var b="";a.errors.namespace&&(b+="Namespace "+E(a.errors.namespace[0])+". ");a.errors.key&&(b+="Key "+E(a.errors.key[0])+". ");a.errors.value&&
(b+="Value "+E(a.errors.value[0])+". ");f("Metafield failed to save: "+b,!0)}}));return!1})})},ca=function(){var b=$("iframe:first").contents().find("#tinymce:first");if(!b.length)return!1;var c=["href","target","class","src"];b.find("*").each(function(a,b){for(a=b.attributes.length-1;0<=a;a--)0>c.indexOf(b.attributes[a].name)&&b.removeAttribute(b.attributes[a].name)})},P=function(){$(".metafield-next-label").text(p.add_new_metafield);$("#metafield_namespace").val("").prop("disabled",!1);$("#metafield_key").val("").prop("disabled",
!1);$("#metafield_value").val("");$("#metafield_id").val("");$("#shopifyjs_deletemetafield").addClass("hide")},I=function(b){b=document.getElementsByClassName(".action-bar__top-links".replace(".",""));if(b.length&&!document.getElementsByClassName("view-json-endpoint-link").length){var c=document.createElement("a");c.innerHTML="View JSON";c.target="_blank";c.classList.add("btn","action-bar__link","btn--link");c.href=["//",location.host,location.pathname].join("")+".json";b[0].appendChild(c)}},ea=function(){if(function(){var b=
document.createElement("div");return"draggable"in b||"ondragstart"in b&&"ondrop"in b}()){w("has dnd");var b=document.documentElement;b.ondragover=function(){this.className="dragit";return!1};b.ondragleave=function(){this.className="";return!1};b.ondragend=function(){this.className="";return!1};b.ondrop=function(b){b.preventDefault&&b.preventDefault();var a=b.dataTransfer.files,c=a.length,e=0,l=new FileReader,m={};l.onload=function(b){w("load");b=b.target.result.split(",")[1];m[e]={name:a[e].name,
data:b};e++;e<c?(f("Reading file ["+(e+1)+"] contents..."),l.readAsDataURL(a[e])):da(m)};c&&(document.documentElement.className="dragit",f("Reading file ["+(e+1)+"] contents..."),l.readAsDataURL(a[e]));return!1}}},da=function(b){var c=k.data.themeId;if(!c||isNaN(c))return f("Theme ID not found",!0),!1;var a=Object.keys(b).length,d=0;"themes"==g("alpha")&&(c=g("omega"));"settings"!=g("omega")||isNaN(g("alpha"))||(c=g("alpha"));var e=function(){$.ajax({type:"PUT",url:"/admin/themes/"+c+"/assets.json",
data:{asset:{key:"assets/"+b[d].name,attachment:b[d].data}},success:function(){f(b[d].name+" uploaded ("+(d+1)+"/"+a+")");d++;d<a?e():document.documentElement.className=""},error:function(){f("File upload failed",!0)}})};e()},Q=function(b,c,a){if("undefined"===typeof b)return!1;f("Updating Variant "+(c+1)+"/"+b.length+"...");"undefined"===typeof c&&(c=0);"undefined"===typeof a&&(a=!1);$.ajax({type:"PUT",url:"/admin/variants/"+b[c].variant.id,dataType:"json",data:b[c],success:function(d){++c;c<b.length?
Q(b,c,a):(f("Variants updated"),"function"===typeof a&&a())},error:function(){f("Update failed",!0)}})},R=function(b,c,a,d,e,l){l="undefined"!==typeof l?"integer":"string";var m="post",v="/admin/variants/"+b+"/metafields.json";c={metafield:{namespace:c,key:a,value:d,value_type:l}};if(e.length){if(isNaN(e))return!1;c={metafield:{id:e,value:d,value_type:l}};v="/admin/variants/"+b+"/metafields/"+e+".json";m="put"}$.ajax({type:m,url:v,data:c,success:function(a){w(a);x(b);f("Metafield saved")},error:function(a){x(b);
f("Error Saving",!0)}})},fa=function(b,c){var a="/admin/variants/"+b+"/metafields/"+c+".json";if(-1<a.indexOf("?")||-1<a.indexOf("products.json"))return!1;$.ajax({type:"DELETE",url:a,success:function(a){w(a);x(b);f(p.metafield_deleted)},error:function(a){x(b);f("Failed to delete",!0)}})},x=function(b){if("undefined"===typeof b||isNaN(b)||!b)return f("Could not find ID",!0),!1;$("#mv_namespace").val("").prop("disabled",!1);$("#mv_key").val("").prop("disabled",!1);$("#mv_value").val("");g("current_vid",
"");var c=function(a){return'<option class="meta" value="'+a.id+'">'+a.namespace+"."+a.key+"</option>"};$.ajax({type:"GET",url:"/admin/variants/"+b+"/metafields.json",success:function(a){$("#vrow option.meta").remove();if(a=a.metafields)g("vm",a),a.length?$("#vrow select").addClass("active"):$("#vrow select").removeClass("active");for(var d=0,e=a.length;d<e;d++)$("#vrow select").append(c(a[d]));$("#vrow .save").off("click").on("click",function(){g("current_vid")||g("current_vid","");R(b,$("#mv_namespace").val(),
$("#mv_key").val(),$("#mv_value").val(),g("current_vid"));return!1});$("#vrow .saveinteger").off("click").on("click",function(){g("current_vid")||g("current_vid","");R(b,$("#mv_namespace").val(),$("#mv_key").val(),$("#mv_value").val(),g("current_vid"),!0);return!1});$("#vrow .delete").addClass("hidden").off("click").on("click",function(){fa(b,g("current_vid"));return!1});$("#vrow select").eq(0).off("change").change(function(){var a=$(this).val();g("current_vid",a);w(g("vm"));if(a.length){$("#mv_namespace").prop("disabled",
!0);$("#mv_key").prop("disabled",!0);$("#vrow .delete").removeClass("hidden");a:{for(var b,c=0,d=g("vm").length;c<d;c++)if(b=g("vm")[c],parseInt(b.id)==parseInt(a)){a=b;break a}a=!1}a&&($("#mv_namespace").val(a.namespace),$("#mv_key").val(a.key),$("#mv_value").val(a.value))}else $("#mv_namespace").val("").prop("disabled",!1),$("#mv_key").val("").prop("disabled",!1),$("#mv_value").val(""),$("#vrow .delete").addClass("hidden")});$("#vrow .mybuttons").fadeIn()},error:function(a){f("Error grabbing metafields",
!0)}});window.dispatchEvent(new Event("resize"))},ha=function(){$("td.vid input").on("change",function(){var b=$(this);b.val(b.attr("data-val"))}).on("click",function(){$(this).select()});var b=$(".edit-variant-metafield");b.on("click",function(c){c.preventDefault();var a=$(this);$("#vrow").remove();if(a.hasClass("active"))a.removeClass("active");else{b.removeClass("active");a.addClass("active");c=a.attr("data-val");g("currentvrow",c);$("tr.variant.active").removeClass("active");a=a.parent().parent().parent();
var d=a.find("td").length+1;a.addClass("active").after('<tr id="vrow"><td colspan="'+d+'">'+L+"</td></tr>");x(c)}})},ia=function(b){if("product"!==b||null!==document.getElementById("removealltags"))return!0;b=$("ul.js-tag-list").eq(0).parent();b.length?(b.append('<a style="margin-top:.75em" id="removealltags" href="#" class="fd-btn btn btn-destroy">Remove all tags</a>'),$("#removealltags").on("click",function(b){b.preventDefault();$("ul.next-token-list").eq(0).find("a").click()})):f("ShopifyFD error : btn_removealltags : target html not found",
!0)},w=function(b){g("debug")&&console.log(b)},B=function(b,c,a,d){w("fdmodal");var e=$("#fdmodal");if(b){e.length&&e.remove();b=$('<div id="fdmodal" class="modalWindow"><div class="main content"><header></header></div></div>');a&&b.find("header").html("<h2>"+a+"</h2>");c&&(c=$("<div/>",{}).append(c),b.find("div.main.content").append(c));if(d)d=$('<a href="#" class="close-modal"></a>'),d.on("click",function(){B(!1);return!1}),b.find("header").prepend(d).end().fadeIn();else b.fadeIn().on("click",function(){B(!1)});
$("body").append(b)}else e.off("click").remove()},ja=function(){var b=$(".ui-title-bar .ui-title-bar__heading-group");if(!b.length)return f("ShopifyFD error : setup_discounts : target html not found",!0),!1;var c=$("<ul/>",{"class":"segmented",id:"discount_buttons"}),a=$("<li/>"),d=$("<a/>",{"class":"btn btn-separate disabled",href:"#"}).html("Bulk create").on("click",function(a){a.preventDefault()});a.append(d);c.append(a);b.after(c)},ka=function(){var b=$(".ui-layout__section--secondary .ui-layout__item:last"),
c=$(".action-bar__top-links");if(b.length){var a=$('<div class="ui-layout__item"><div class="next-card"></div></div>');a.find(".next-card").append('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>');
b.after(a);b=$("div.metafield-content");u(b)}else f("ShopifyFD error : setup_single_article : Metafield target HTML not found",!0);c.length?(b=$("<button/>",{"class":"btn action-bar__link btn--link",href:"#"}).html("Duplicate").on("click",function(a){a.preventDefault();$(this);$.getJSON(["//",location.host,location.pathname].join("")+".json",function(a){$.ajax({type:"POST",url:"/admin/blogs/"+a.article.blog_id+"/articles.json",dataType:"json",data:{article:{author:a.article.author,blog_id:a.article.blog_id,
body_html:a.article.body_html,summary_html:a.article.summary_html,tags:a.article.tags,template_suffix:a.article.template_suffix,title:a.article.title+" [copy]",published:!1}},success:function(a){r("/admin/blogs/"+a.article.blog_id+"/articles/"+a.article.id)},error:function(a){f("Error saving",!0)}})})}),c.append(b)):f("ShopifyFD error : setup_single_article : Header button missing",!0);0===$("#rte_extra").length&&($("#article-content_parent:first").append('<div class="sst" id="rte_extra"><a class="btn btn-slim fd-btn tooltip btn-destroy tooltip-bottom" id="clearformatting" href="#"><span class="tooltip-container"><span class="tooltip-label">Will remove all HTML on click</span></span>Purge HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="clear-html-attributes" href="#"><span class="tooltip-container"><span class="tooltip-label">Removes HTML attributes except for <br>target,class,href & src</span></span>Clean HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="createbackup" href="#"><span class="tooltip-container"><span class="tooltip-label">Save contents as metafield</span></span>Backup</a> <a class="btn btn-slim fd-btn" style="display:none;" id="restorebackup" href="#">Restore Backup</a> <a class="btn btn-slim fd-btn" id="save_images_to_meta" href="#">Images to Metafields</a></div>'),
D())},O=function(){$("#restorebackup").show().on("click",function(b){b.preventDefault();a:{g("omega");b=$("iframe:first").contents().find("#tinymce:first");var c=g("m");if(c)for(var a=0,d=c.length;a<d;a++){if("backups"===c[a].namespace){b.html(c[a].value);f("Backup restored");break a}}else f("Error, nothing to restore",!0)}})},D=function(){var b=$("#restorebackup");b.length&&(g("hasbackup")?O():b.hide());$("#clearformatting").on("click",function(a){a.preventDefault();a=$("iframe:first").contents().find("#tinymce:first");
if(a.length){var b=document.createElement("div");b.innerHTML=a.html();a.text(b.textContent||b.innerText||"")}});$("#clear-html-attributes").on("click",function(a){a.preventDefault();ca()});$("#createbackup").on("click",function(a){a.preventDefault();N(g("omega"))});$("#save_images_to_meta").on("click",function(a){a.preventDefault();la()});b=$("#rte-show-html");if(b.length){var c=$('<button name="" type="button" class="btn rte-tools__source-btn btn-slim fullscreen-rte-btn"><svg class="next-icon next-icon--color-slate next-icon--size-12"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg></button>');
c.on("click",function(a){a.preventDefault();a=document.querySelectorAll('[data-context="descriptionRte"]');a.length&&a[0].classList.toggle("fullscreen-rte")});b.before(c)}},la=function(){var b=$("iframe:first").contents().find("#tinymce:first").find("img");if(b&&b.length){var c="";b.each(function(a){var d=$(this).prop("src").replace(/https:/i,"");c+=d;a<b.length-1&&(c+=",")});var a={metafield:{namespace:"helpers",key:"images",value:c,value_type:"string"}},d=[location.protocol,"//",location.host,location.pathname,
"/metafields.json"].join("");"articles"===g("alpha")&&(d="/admin/articles/"+g("omega")+"/metafields.json");$.ajax({type:"POST",url:d,dataType:"json",data:a,success:function(a){t();f("Images saved to metafield")},error:function(a){f("Error saving",!0)}})}else f("No images found",!0)},G=function(b){b=b.concat();for(var c=0;c<b.length;++c)for(var a=c+1;a<b.length;++a)b[c]===b[a]&&b.splice(a--,1);return b},S=function(){if(!document.getElementsByClassName("sku-count-cell").length){var b=$(".next-tab__container:first");
if(!b.length)return!1;var c=$("<div />",{"class":"row s-none sku-count-cell"});$.ajax({type:"GET",url:"/admin/settings/general.json",dataType:"json",success:function(a){var d=!1;try{g("shop_settings",a.shop_settings),d=a.shop_settings.total_skus,c.html(e)}catch(l){}if(d){var e='<div style="background: #e3e7ea;"class="header-notice">You are using %1 skus</div>'.replace("%1",d);c.html(e);b.before(c)}}})}},ma=function(){S();var b=$(".action-bar__top-links");if(!b.length)return f("Error : setup_products_list : html not found",
!0),!1;$("#showsku").length&&$("#showsku").remove();var c=$("<button/>",{"class":"btn action-bar__link btn--link"}).html("Show SKUs & ID").on("click",function(a){a.preventDefault();var b=[],c=$("#all-products td.name a[href]");c.each(function(){b.push($(this).attr("href").split(/[/]+/).pop())});if(b.length){var l=$(this);l.addClass("is-loading disabled");var m=function(a,b){$.ajax({type:"GET",url:"/admin/products/"+a[b]+".json?fields=variants",dataType:"json",success:function(d){var e=d.product.variants[0].sku;
d=d.product.variants[0].id;var h="";if(e||d)e&&(h='<span title="SKU" class="sku label badge badge--small badge--left-margin animated fadein">'+e+"</span>"),c.eq(b).before(h+'<span title="VariantID" class="variant-label badge badge--small badge--left-margin animated fadein">'+d+"</span>");b+1<a.length?m(a,b+1):(f("SKUs and Variant IDs Loaded"),l.removeClass("is-loading").text("Data Loaded"))}})};f("Loading SKUs and Variant IDs, please wait...");m(b,0)}});b.append(c)},T=function(){if("undefined"===
typeof k.data.themes)$.ajax({type:"GET",url:"/admin/themes.json",success:function(a){if(a){k.data.themes=a.themes;for(var b=0,c=a.themes.length;b<c;b++)"main"===a.themes[b].role&&(k.data.themeId=a.themes[b].id);T()}}});else{var b=function(a){if("undefined"===typeof k.data.themes||"undefined"===typeof a)return!1;a=parseInt(a);for(var b=k.data.themes.length-1;0<=b;b--)if(k.data.themes[b].id===a)return k.data.themes[b]},c=$(".ui-stack.published-theme__stack:first");$(".unpublished-theme-title");for(var a=
$(".themes-list__row[id]"),d=[],e=0;e<a.length;e++){var l=a[e].id.split("_").pop();d.push(l);var m=a.eq(e).find("div:first"),g=b(l),h="";g&&(h+="<br>Created at: "+(new Date(g.created_at)).toString(),h+="<br>Updated at: "+(new Date(g.updated_at)).toString());m.after('<div style="font-size:90%;opacity:.5" class="theme-data" data-id="'+l+'">Theme ID: '+l+h+"</div>")}c.length&&(a=$(".published-themes .ui-button--primary:first").attr("href"),"undefined"!==typeof a&&-1<a.indexOf("/admin/themes")&&(l=a.split("/")[3],
d.push(l),g=b(l),h="",g&&(h+="<br>Created at: "+(new Date(g.created_at)).toString(),h+="<br>Updated at: "+(new Date(g.updated_at)).toString()),c.after('<div style="font-size:90%;opacity:.5" class="theme-data" data-id="'+l+'">Theme ID: '+l+h+"</div>")));2>d.length||(b=$(".action-bar__top-links"),b.length&&(c=$("<button/>",{"class":"btn action-bar__link btn--link",style:"margin-right: 10px;"}).text("Export all themes").on("click",function(a){a.preventDefault();for(a=0;a<d.length;a++)$.ajax({type:"POST",
data:{_method:"post"},url:"/admin/themes/"+d[a]+"/export"});f(d.length+" export request"+(1<d.length?"s":"")+" sent. Check your inbox")}),b.after(c)))}},na=function(b){var c=$(".header .header__primary-actions:first");if(!c.length)return!1;$.ajax({type:"GET",url:"/admin/link_lists.json",dataType:"json",success:function(a){if(a){a=a.link_lists;for(var b="",e=0,f=a.length;e<f;e++)g("omega")!==a[e].id.toString()&&(b+='<option value="'+a[e].id+'">'+a[e].title+"</option>");a=$("<select />",{"class":"header-select fadein"}).append("<option>Edit other Menu</option>",
b).change(function(){var a=$(this).val();a&&r("/admin/link_lists/"+a)});c.prepend(a)}},error:function(a){f("Error loading linklist data",!0)}})},J=function(){var b=$(".menus-table.next-table--line-items td").not("[class]"),c=function(){$.ajax({type:"GET",url:"/admin/collections.json?limit=250",dataType:"json",success:function(a){for(var b=$.param({utf8:"\u2713","link_list[handle]":"all-collections","link_list[title]":"All Collections"}),c=[],d=0,q=a.collections.length;d<q;++d){c.push({position:d+
1,title:a.collections[d].title,link_type:"collection",subject_id:a.collections[d].id});var f={};f["link_list[links][][position]"]=d+1;f["link_list[links][][title]"]=a.collections[d].title;f["link_list[links][][link_type]"]="collection";f["link_list[links][][subject_id]"]=a.collections[d].id;b+="&"+$.param(f)}e(b)},error:function(){f("Error! Are you sure you have access to collections?",!0)}});return!1},a=function(){$.ajax({type:"GET",url:"/admin/pages.json?limit=250",dataType:"json",success:function(a){for(var b=
$.param({utf8:"\u2713","link_list[handle]":"all-pages","link_list[title]":"All Pages"}),c=[],d=0,q=a.pages.length;d<q;++d){c.push({position:d+1,title:a.pages[d].title,link_type:"page",subject_id:a.pages[d].id});var f={};f["link_list[links][][position]"]=d+1;f["link_list[links][][title]"]=a.pages[d].title;f["link_list[links][][link_type]"]="page";f["link_list[links][][subject_id]"]=a.pages[d].id;b+="&"+$.param(f)}e(b)},error:function(){f("Error! Are you sure you have access to pages?",!0)}});return!1},
d=function(){$.ajax({type:"GET",url:"/admin/products/vendors.json",dataType:"json",success:function(a){for(var b=$.param({utf8:"\u2713","link_list[handle]":"all-vendors","link_list[title]":"All Vendors"}),c=[],d=0,f=a.vendors.length;d<f;++d){var q={position:d+1,title:a.vendors[d],link_type:"http",subject:"/collections/vendors?q="+encodeURIComponent(a.vendors[d].toLowerCase()).replace(/%20/g,"+")},h={};h["link_list[links][][position]"]=d+1;h["link_list[links][][title]"]=a.vendors[d];h["link_list[links][][link_type]"]=
"http";h["link_list[links][][subject]"]="/collections/vendors?q="+encodeURIComponent(a.vendors[d].toLowerCase()).replace(/%20/g,"+");b+="&"+$.param(h);c.push(q)}e(b)}})},e=function(a,b){"undefined"===typeof b&&(b=1);"undefined"!==typeof a&&$.ajax({type:"POST",url:"/admin/link_lists",data:a,success:function(a,b,c){(b=c.getResponseHeader("X-XHR-Redirected-To"))?(a=b.split("/").pop(),isNaN(a)?f("Error creating linklist - ID not returned",!0):(f("Link list added"),r("/admin/link_lists/"+a))):(a=$(a).find("form").eq(0).attr("action").split("/").pop(),
isNaN(a)||(f("Link list added"),r("/admin/link_lists/"+a)))},error:function(){f("Error creating linklist",!0)}})},l=$("<a/>",{href:"#","class":"btn btn-slim has-loading",style:"margin-right:1.5em"}).html("Copy").on("click",function(a){a.preventDefault();a=$(this);var b=a.parent().parent().find('a[href^="/admin/link_lists"]:first');if(b.length){if(a.addClass("is-loading"),b=b.attr("href").split("/").pop(),!isNaN(b)){b=parseInt(b);var c=g("link_lists");a=!1;for(var d=0;d<c.length;d++)if(b===c[d].id){a=
c[d];break}if(a){b=e;var h=h+"utf8=\u2713"+("&link_list[title]="+a.title+" [COPY]");h+="&link_list[handle]="+a.handle+"-copy";for(c=0;c<a.links.length;c++)h+="&link_list[links][][title]="+a.links[c].title,h+="&link_list[links][][link_type]="+a.links[c].link_type,h+="&link_list[links][][subject_params]="+(a.links[c].subject_params||""),h+="&link_list[links][][subject_id]="+(a.links[c].subject_id||""),h+="&link_list[links][][subject]="+a.links[c].subject;b(h)}}}else f("Can not copy this linklist. ID was not found",
!0)}),m=$("<a />",{href:"#","class":"btn btn-slim btn-destroy has-loading",style:"margin-right:1.5em"}).html("Delete").on("click",function(a){a.preventDefault();var b=$(this);a=b.parent().parent().find('a[href^="/admin/link_lists"]').eq(0);a.length&&(b.addClass("is-loading"),a=a.attr("href").split("/").pop(),isNaN(a)||$.ajax({type:"POST",url:"/admin/link_lists/"+a,data:{utf8:"\u2713",_method:"delete"},success:function(a){b.removeClass("is-loading").closest("tr").addClass("disable").css({opacity:".2",
"pointer-events":"none"})}}))});1<b.length?(b.append("<br><br>",l,m),$.ajax({type:"GET",url:"/admin/link_lists.json",dataType:"json",success:function(a){a&&a.link_lists&&(g("link_lists",a.link_lists),b.each(function(b){$(this).parent().find("h3").append('<span class="fadein" style="color:#ccc;display: block;font-size: 11px;font-family: monospace;">'+a.link_lists[b].handle+"</span>")}))}})):b.append("<br><br>",l);l=$(".ui-annotated-section__description").eq(0);m=$("<a/>",{"class":"btn tooltip-bottom tooltip fd-btn sst",
href:"#"}).html('<span class="tooltip-container"><span class="tooltip-label">Create a menu with every collection</span></span>Create Collections menu').on("click",function(){$(this).addClass("is-loading disabled");c();return!1});var v=$("<a/>",{"class":"btn tooltip-bottom tooltip fd-btn sst",href:"#"}).html('<span class="tooltip-container"><span class="tooltip-label">Create a menu with every page</span></span>Create Pages menu').on("click",function(){$(this).addClass("is-loading disabled");a();return!1}),
h=$("<a/>",{"class":"btn tooltip-bottom tooltip fd-btn sst",href:"#"}).html('<span class="tooltip-container"><span class="tooltip-label">Create a menu with all vendors</span></span>Create Vendor menu').on("click",function(){$(this).addClass("is-loading disabled");d();return!1});l.length&&l.append("<br>",m,"<br>",v,"<br>",h);l=$('.ui-annotated-section__description a[href="/admin/link_lists/new"]');if(l.length&&(m=$("#link_lists .next-grid--no-outside-padding a:last-child"),m.length)){var n="";2<m.length&&
(m.each(function(){var a=$(this),b=a.parent().parent().find("h3").text();a=a.attr("href");b.length&&a.length&&(n+='<option value="'+a+'">'+b+"</option>")}),n.length&&(m=$("<select />",{style:"width: 100%"}).on("change",function(){var a=$(this).val();a.length&&r(a)}).html('<option value="">Select Menu</option>'+n),v=$("<div />",{"class":"sst"}),v.append('<label class="next-label">Select a menu to quickly edit.</label>',m),l.after(v)))}},K=function(b){if("undefined"!==typeof b&&b.length){var c=b[0];
if("object"===typeof c){var a=$('textarea[name="bulk-redirect-log"]'),d=a.val();$.ajax({type:"POST",url:"/admin/redirects.json",dataType:"json",data:c,success:function(c){d+=c.redirect.path+", "+c.redirect.target+", success\n";a.val(d);b.shift();0<b.length?K(b):f("Bulk redirection additions complete")},error:function(e){d+=c.redirect.path+", "+c.redirect.target+", "+e.responseJSON.errors.path[0]+"\n";a.val(d);b.shift();0<b.length?K(b):f("Bulk redirection additions complete")}})}}},oa=function(){if(!document.getElementsByClassName("bulk-redirect-panel").length){$(".header .header__secondary-actions:first");
var b=$(".next-card.has-bulk-actions");b.length||(b=$("#url_redirects"));if(!b.length)return f("Could not add bulk redirect panel",!0),!1;var c=$('<div class="bulk-redirect-panel next-grid next-grid--outer-grid" style="border-bottom: 1px solid #DADADA;margin-bottom: 1em;padding-bottom: 1em;"><div class="next-grid__cell next-grid__cell--third"><h2 class="next-heading">Bulk Redirects</h2><p>To bulk add redirects manually add the path (old url) and target (new url) separated with a comma to the input box. As with any bulk action, run a small sample first before processing 1000s of items.<br><br></p><ul><li>One redirect per line.</li><li>A log will show progress and any errors</li></ul></div><div class="next-grid__cell"><h2 class="next-heading">Paste URLs</h2><p>An example of the redirect is shown below:<br><code>http://freakdesign.com.au/old-url,http://freakdesign.com.au/new-url</code><br>or<br><code>/old-url,/pages/new-url</code></p><br><textarea name="bulk-redirect-paste"></textarea><br><br><button class="redirect-process btn fd-btn btn-primary">Add Redirects</button> <button class="redirect-reload btn fd-btn">Reload page</button><div class="fadein hide bulk-redirect-log"><br><br><h2 class="next-heading">Activity Log</h2><textarea name="bulk-redirect-log"></textarea></div></div></div>'),
a=c.find(".redirect-process"),d=c.find(".redirect-reload"),e=c.find('textarea[name="bulk-redirect-paste"]'),l=c.find('textarea[name="bulk-redirect-log"]');d.on("click",function(a){a.preventDefault();r("/admin/redirects?"+Math.floor(1E6*Math.random()))});a.on("click",function(a){a.preventDefault();a=e.val().replace(/ /g,"");if(!(4>a.length)&&(a=a.split("\n"),a.length)){for(var b=[],c=0;c<a.length;c++){var d=a[c].split(",");2===d.length&&(d[0]=d[0].trim(),d[1]=d[1].trim(),"/"!==d[1].substring(0,1)&&
"http"!==d[1].substring(0,4)&&(d[1]="/"+d[1]),b.push({redirect:{path:d[0],target:d[1]}}))}b.length&&(l.val("").parent().removeClass("hide"),K(b))}});b.prepend(c)}},pa=function(){S();I(!0);g("collections",!1);var b=$(".ui-title-bar .ui-title-bar__heading-group");if(b.length){var c=$("<ul/>",{"class":"segmented"}),a=$("<li/>"),d=$("<a/>",{"class":"btn fd-btn",style:"margin-left:.5em",href:"#"}).text("Show Product Count").on("click",function(a){a.preventDefault();$.ajax({type:"GET",url:"/admin/collections.json?limit=250",
dataType:"json",success:function(a){if(a.collections.length){g("collections",a);for(var b=a.collections.length-1;0<=b;b--){var c=$("#collections-results").find('a[href="/admin/collections/'+a.collections[b].id+'"]:last');0===c.find("span").length&&c.append('<span class="sku label badge badge--small badge--left-margin">'+a.collections[b].products_count+"</span>")}}}})}),e=$("<a/>",{"class":"btn fd-btn",href:"#",title:"Add tags to entire collection"}).html("Bulk edit tags").on("click",function(){B(!0,
'<div><div class="clearfix em"><div class="half">Choose a collection</div><div class="half"><select data-action="collection"><option value="">Loading, please wait...</option></select></div></div><div class="clearfix em"><div class="half">Choose an action</div><div class="half"><select data-action="action"><option value="add">Add</option><option value="set">Set</option><option value="remove">Remove</option><option disabled value="toggle">Toggle</option><option value="purge" style="background:red;color:#fff">DELETE ALL</option></select></div></div><div class="clearfix em"><div class="half">Set the tag</div><div class="half"><input /></div></div><div class="half"><a class="btn" data-action="update_tags">Update tags</a></div><div class="half"><small>Add: Adds tags to the existing ones<br>Set: Replaces tags with new ones<br>Remove: Removes matching tags<br>Toggle: Future Use, disabled...</small></div></div>',
"Edit tags for all products in a collection",!0);var a=$("#fdmodal"),b=a.find('select[data-action="action"]'),c=a.find("a").eq(1),d=a.find('select[data-action="collection"]'),e=a.find("input").eq(0);b.change(function(a){"purge"==b.val()||"set"==b.val()?("purge"==b.val()&&e.val("").attr("disabled","disabled"),c.addClass("delete")):(e.removeAttr("disabled"),c.removeClass("delete"))});var q=function(a,b,d,e){var f=a.products[b].id,h={product:{id:f,tags:d}};c.text(b+1+"/"+a.products.length);$.ajax({type:"PUT",
url:"/admin/products/"+f+".json",data:h,dataType:"json",success:function(c){++b;b<a.products.length?q(a,b,d,e):"function"===typeof e&&e()}})},k=function(a,b,d,e){if(a.products[b].tags){var f=d.replace(/, /g,",").split(","),h=a.products[b].tags.replace(/, /g,",").split(",");h=$(h).not(f).get()+"";f=a.products[b].id;h={product:{id:f,tags:h}};c.text(b+1+"/"+a.products.length);$.ajax({type:"PUT",url:"/admin/products/"+f+".json",data:h,dataType:"json",success:function(c){++b;b<a.products.length?k(a,b,
d,e):"function"===typeof e&&e()}})}else++b,b<a.products.length?k(a,b,d,e):"function"===typeof e&&e()},A=function(a,b,d,e){var f=d.replace(/, /g,",").split(","),h=a.products[b].tags.split(",");h=G(f.concat(h))+"";f=a.products[b].id;h={product:{id:f,tags:h}};c.text(b+1+"/"+a.products.length);$.ajax({type:"PUT",url:"/admin/products/"+f+".json",data:h,dataType:"json",success:function(c){++b;b<a.products.length?A(a,b,d,e):e()}})};c.on("click",function(){d.val().length?("add"===b.val()&&e.val().length&&
$.ajax({type:"GET",url:"/admin/products.json?collection_id="+d.val()+"&fields=id,tags",dataType:"json",success:function(a){c.addClass("disabled");A(a,0,e.val(),function(){f("Done. Tags have been added");c.text("Update tags").removeClass("disabled")})}}),"purge"!==b.val()&&"set"!==b.val()||$.ajax({type:"GET",url:"/admin/products.json?collection_id="+d.val()+"&fields=id",dataType:"json",success:function(a){c.addClass("disabled");q(a,0,e.val(),function(){f("Done.");c.text("Update tags").removeClass("disabled")})}}),
"remove"===b.val()&&$.ajax({type:"GET",url:"/admin/products.json?collection_id="+d.val()+"&fields=id,tags",dataType:"json",success:function(a){c.addClass("disabled");k(a,0,e.val(),function(){f("Matched tags have been removed.");c.text("Update tags").removeClass("disabled")})}})):f("Choose a collection",!0);return!1});b.hide();$.ajax({type:"GET",url:"/admin/collections.json?limit=250",dataType:"json",success:function(a){if(a.collections.length){g("collections",a);for(var c="",e=0,f=a.collections.length;e<
f;e++){var h='<option value="'+a.collections[e].id+'">',l=a.collections[e].title,A=document.createElement("div");A.appendChild(document.createTextNode(l));c+=h+A.innerHTML+"</option>"}d.append(c).find("option:eq(0)").text("Select a collection");b.show()}}});return!1});a.append(e,d);c.append(a);b.after(c)}else f("ShopifyFD error : setup_collections : target html not found")},ba=function(){if(M()){var b=$('<div class="metafield-copy-paste sst"><a class="fd-btn btn btn-slim" id="fd_copymetafields">Copy All Metafields</a> <a class="fd-btn btn btn-slim" id="fd_pastemetafields">Paste Metafields</a> <a class="btn btn-slim tooltip tooltip-bottom" href="#" id="fd_whatmetafields"><span class="tooltip-container"><span class="tooltip-label">View what is in the clipboard</span></span>?</a></div>'),
c=b.find("#fd_pastemetafields"),a=b.find("#fd_whatmetafields");b.find("#fd_copymetafields").on("click",function(b){b.preventDefault();"undefined"!==typeof g("m")?0<g("m").length?(localStorage.metafieldCopy=JSON.stringify(g("m")),f(g("m").length+" Metafields copied"),c.show(),a.show()):f("No metafields to copy",!0):(c.hide(),a.hide())});a.on("click",function(a){a.preventDefault();if("undefined"!==typeof localStorage.metafieldCopy){a="";var b=!1;try{b=JSON.parse(localStorage.metafieldCopy)}catch(n){return!1}if(b){for(var c=
0,d=b.length;c<d;c++){var f=b[c].value,h=document.createElement("div");h.innerHTML=f;a+="<p><strong>"+b[c].namespace+"."+b[c].key+" ("+b[c].value_type+")</strong><br>"+(h.textContent||h.innerText)+"</p><hr>"}B(!0,a,"In the virtual clipboard...")}}});c.on("click",function(a){a.preventDefault();"undefined"!==typeof localStorage.metafieldCopy?(a=JSON.parse(localStorage.metafieldCopy),a.length?(g("m-copy",a),U(g("m-copy"),0)):f("Nothing to paste",!0)):f("Nothing to paste",!0)});"undefined"===typeof localStorage.metafieldCopy&&
(c.hide(),a.hide());$(".metafield-content").after(b)}},U=function(b,c){if("undefined"===typeof b||"undefined"===typeof c)return!1;f("Pasting metafields...");var a={metafield:{namespace:b[c].namespace,key:b[c].key,value:b[c].value,value_type:b[c].value_type}};$.ajax({type:"POST",url:[location.protocol,"//",location.host,location.pathname,"/metafields.json"].join(""),dataType:"json",data:a,success:function(a){c+1<b.length?U(b,++c):(t(),f("All metafields pasted!"))}})},qa=function(b,c){if("undefined"===
typeof b||isNaN(b))return!1;$.ajax({type:"PUT",url:"/admin/products/"+b+".json",dataType:"json",data:{product:{id:b,images:[""]}},success:function(a){$("#product-images").parent().remove();f("Images deleted. Reload product to check...")}})},ra=function(){if(!document.getElementsByClassName("seo-hide-button").length){var b=$("#ChannelsPublishingPanel");if(b.length){var c=$("<a />",{"class":"btn fd-btn seo-hide-button"}).text(p.hide_from_sitemap).on("click",function(a){a.preventDefault();(a=$(this).attr("data-id"))?
$.ajax({type:"DELETE",url:["//",location.host,location.pathname].join("")+"/metafields/"+a+".json",success:function(a){t()},error:function(a){f("Failed to delete",!0)}}):$.ajax({type:"POST",url:["//",location.host,location.pathname].join("")+"/metafields.json",dataType:"json",data:{metafield:{namespace:"seo",key:"hidden",value:1,value_type:"integer"}},success:function(a){t()},error:function(){f("Failed to save metafield",!0)}})}),a=$('<section class="ui-card__section"><div class="ui-type-container"><div class="ui-stack ui-stack--wrap ui-stack--alignment-center"><div class="ui-stack-item ui-stack-item--fill"><h3 class="ui-subheading">Sitemap</h3><p style="margin:1em 0">Add metafield to remove this product from the sitemap. It is <b>very</b> important that you <a href="https://help.shopify.com/api/tutorials/updating-seo-data#hide-an-object-from-search-engines-and-sitemaps" target="_blank">understand</a> what doing this means. If you don\'t, leave it alone.</p></div></div></div></section>');
a.find(".ui-stack-item").append(c);b.append(a)}else console.warn("add_sitemap_button(): target not found")}},sa=function(){clearInterval(g("autosave"));I(!0);if(!document.getElementsByClassName("next-card-metafield").length){var b=$(".next-grid__cell--third:first");b.length||(b=$(".ui-layout__section--secondary .ui-layout__item:first"));b.length?(b.prepend('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),
b=$("div.metafield-content"),u(b)):f("ShopifyFD error : setup_products : Metafield target HTML not found",!0)}var c=$(".action-bar__top-links");c.length&&!document.getElementsByClassName("product-switcher").length&&$.ajax({type:"GET",url:"/admin/products.json?limit=250&fields=id,title",dataType:"json",success:function(a){if(a){a=a.products;var b="",d=a.length;if(250<d)return!0;for(var e=0;e<d;e++)g("omega")!==a[e].id.toString()&&(b+='<option value="'+a[e].id+'">'+a[e].title+"</option>");a=$("<select />",
{"class":"product-switcher header-select fadein"}).append("<option selected>Edit other Product</option>",b).change(function(){var a=$(this).val();a&&r("/admin/products/"+a)});c.append(a)}},error:function(a){f("Error loading linklist data",!0)}});b=$("#product-collections");if(b.length){var a=b.find(".product-collections-list a.btn");if(a.length){var d=$("<a />",{"class":"btn fd-btn btn-destroy"}).text("Remove from all").on("click",function(b){b.preventDefault();a.trigger("click")});b.append(d)}}else console.warn("collectionPanel not found");
if(!document.getElementsByClassName("additional-product-actions").length){b=$("#product-outer-variants");d=$('<div class="additional-product-actions ui-layout__item"><div class="next-card"><div class="next-card__header"><div class="wrappable"><div class="wrappable__item"><h2 class="next-heading">Additional actions</h2></div></div></div><section class="next-card__section additional-product-content"></section></div>');var e=d.find(".additional-product-content");if(!document.getElementsByClassName("remove-all-images").length){var l=
$("<a />",{"class":"btn btn-destroy tooltip tooltip-bottom"}).html('Remove all images<span class="tooltip-container"><span class="tooltip-label">Instant, and no undo</span></span>').on("click",function(a){a.preventDefault();$(this);a=window.location.pathname.split("/").pop();qa(a)});e.append(l)}b.after(d)}null===document.getElementById("rte_extra")&&($("#product-description_iframecontainer").eq(0).after('<div class="sst" id="rte_extra"><a class="btn btn-slim fd-btn tooltip btn-destroy tooltip-bottom" id="clearformatting" href="#"><span class="tooltip-container"><span class="tooltip-label">Will remove all HTML on click</span></span>Purge HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="clear-html-attributes" href="#"><span class="tooltip-container"><span class="tooltip-label">Removes HTML attributes except for <br>target,class,href & src</span></span>Clean HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="createbackup" href="#"><span class="tooltip-container"><span class="tooltip-label">Save contents as metafield</span></span>Backup</a> <a class="btn btn-slim fd-btn" style="display:none;" id="restorebackup" href="#">Restore Backup</a> <a class="btn btn-slim fd-btn" id="save_images_to_meta" href="#">Images to Metafields</a></div>'),
$("#rte_extra").append(' <a id="autosave" tabindex="-1" class="btn btn-slim has-loading" href="#">Autosave</a>'),D(),$("#autosave").on("click",function(){var a=$(this);a.hasClass("active")?(f("Autosave disabled"),clearInterval(g("autosave")),a.removeClass("active")):(f("Autosave enabled"),a.addClass("active"),g("autosave",setInterval(function(){-1<window.location.href.indexOf("/admin/products/")?N(g("omega"),!0)||clearInterval(g("autosave")):clearInterval(g("autosave"))},3E4)));return!1}));ia("product");
b=$("#product-outer-variants");var m=m||{};if(!document.getElementsByClassName("bulk-variants-section").length)if(b.length){var k=$("<div />",{"class":"next-card__section fadein hide bulk-variants-section",style:"background: #f4f5f7;"}),h=$("<a />",{"class":"btn--link",style:"margin-left:1em;margin-top: -3px;"}).text("Bulk Edits").on("click",function(a){a.preventDefault();k.toggleClass("hide")});k.html('<h2>Edit all variants</h2><p style="margin: .5em 0 1em;font-size: 12px;border-bottom: 1px solid #ccc;padding-bottom: .5em;">Bulk Editing comes with risks. Proceed with caution.</p><label style="margin-top:1.5em">Set Compare at Price<br><small>0 will clear the compare at price</small></label><input type="number" style="width:50%" value="0"> <a class="bulk-compare-save tooltip tooltip-bottom btn btn-slim fd-btn"><span class="tooltip-container"><span class="tooltip-label">Save Compare at Price for all variants</span></span>Save</a>');
d=k.find("a.bulk-compare-save");var n=k.find("input");d.on("click",function(a){a.preventDefault();var b=$(this);b.addClass("is-loading").attr("style","margin-left:1em;text-indent: -9999px;");a=function(){b.removeClass("is-loading").attr("style","margin-left:1em")};var c=n.val();if(isNaN(c)||"0"===c||""===c)c=null;if((c||null===c)&&"object"===typeof m)if(1<Object.keys(m).length)if(Object.keys(m).length===$("tr.variant").length){var d=[],e;for(e in m){var h=m[e],g;for(g in h)h.hasOwnProperty(g)&&d.push({variant:{id:h[g],
compare_at_price:c}})}d.length&&Q(d,0,a)}else f("Unexpected variant found.",!0);else f("You only have 1 variant. No need to bulk edit",!0)});b.find(".ui-card:first").append(k)}else f("ShopifyFD error : setup_products : Inventory target HTML not found",!0);if(!document.getElementsByClassName("edit-variant-metafield").length)if(d=$("#product-inner-variants th:last-child"),d.length){d.before('<th class="variants-table__heading--indent-right tr">ID</th>');d=$("th.tc:first");d.length&&"Inventory"===d.text()&&
d.text("#").prop("title","Quantity");var q=$("tr.variant");q.each(function(a){var b=q.eq(a).find("td:last a:first").prop("href").split("/").pop(),c=$("input#variant_ids_"+b),d=$("<a />",{"class":"edit-variant-metafield","data-val":b}).html('<span><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" width="16" height="16" viewBox="0 0 12 12" enable-background="new 0 0 12 12" xml:space="preserve"><path fill="currentColor" d="M0 0v12h12V0H0zM11 11H1V1h10V11zM5 9h2V7h2V5H7V3H5v2H3v2h2V9z"></path></svg></span>');
m["variant_"+a]={id:b};c.after(d);a='<td class="vid new-variants-table__cell"><input class="mock-edit-on-hover tr" data-action="selectall" data-val="'+b+'" type="text" value="'+b+'" /></td>';$(this).find("td:last-child").before(a)}).promise().done(function(){ha();window.dispatchEvent(new Event("resize"))})}else document.getElementsByClassName("vbox-single-card").length||null==document.getElementById("product_variant_id")||(d=document.getElementById("product_variant_id").value,$("#product-outer-variants").after(Y),
x(d));document.getElementsByClassName("set-preferred-collection").length||(d=$("ul.product-collections-list"),d.length&&d.find("li").each(function(){var a=$(this),b=a.find("a").eq(0).attr("href").split("/").pop(),c=$("<a/>",{"class":"tooltip tooltip-bottom set-preferred-collection",href:"#"}).html('<span class="next-icon next-icon--10" style="background:#21C2A8;left: -.5em;"></span><span class="tooltip-container"><span class="tooltip-label">Set a metafield with this collection handle</span></span>').on("click",
function(a){a.preventDefault();"undefined"!==b&&$.ajax({type:"GET",url:"/admin/collections/"+b+".json?fields=handle",dataType:"json",success:function(a){"undefined"!==typeof a&&(a=a.collection.handle,$.ajax({type:"POST",url:["//",location.host,location.pathname].join("")+"/metafields.json",dataType:"json",data:{metafield:{namespace:"collection",key:"preferred",value:a,value_type:"string"}},success:function(a){t();f("Preferred collection metafield saved")},error:function(a){a=JSON.parse(a.responseText);
f(a.errors.value[0],!0)}}))},error:function(){f("Failed to load collection",!0)}})});a.find("div.next-grid:first").prepend(c)}));ra();if(!document.getElementsByClassName("edit-selected-weights").length&&(d=$("div.bulk-actions").eq(0),d.length)){var H=$("<a/>",{href:"#","class":"btn fd-btn btn-slim hide edit-selected-weights",style:"padding-left:.5em"}).text("Edit selected weights").on("click",function(){B(!0,'<label>New weight (grams)</label><input class="half" min="0" type="number" data-action="update-variant-weight" /><a data-action="update-variant-weight" href="#" class="btn btn-slim">Save</a><br><br><small>Note: You may need to reload this page before Shopify will show the new weight in the dashboard.</small>',
"Edit weight",!0);var a=$('a[data-action="update-variant-weight"]'),b=$('input[data-action="update-variant-weight"]');if(a.length&&b.length)a.on("click",function(){var c=$('tr.variant input[type="checkbox"]:checked');if(c.length&&!isNaN(b.val())){var d=[];c.each(function(){var a=$(this).val();isNaN(a)||d.push(parseInt(a))});var e=function(c,d){$.ajax({type:"PUT",url:"/admin/variants/"+d[c],dataType:"json",data:{variant:{id:d[0],grams:b.val()}},success:function(b){++c;c<d.length?e(c,d):(f("Weight updated"),
a.removeClass("is-loading").text(p.save))}})};a.addClass("is-loading").text("");e(0,d)}else f("Did you set a weight?",!0);return!1});return!1});d.append(H);$('tr.variant input[type="checkbox"]').on("change",function(){1<$('tr.variant input[type="checkbox"]:checked').length?H.removeClass("hide"):H.addClass("hide")})}b.length&&"object"===typeof m&&1<Object.keys(m).length&&b.find(".ui-card__header .btn--link:last").after(h)},ta=function(){var b=$(".ui-layout__section--secondary .ui-layout__item:last");
if(b.length){var c=$('<div class="ui-layout__item"><div class="next-card"></div></div>');c.find(".next-card").append('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>');
b.after(c);u($("div.metafield-content"))}else f("ShopifyFD error : setup_pages : Metafield target HTML not found",!0);0===$("#rte_extra").length&&($("#page-content_iframecontainer").eq(0).after('<div class="sst" id="rte_extra"><a class="btn btn-slim fd-btn tooltip btn-destroy tooltip-bottom" id="clearformatting" href="#"><span class="tooltip-container"><span class="tooltip-label">Will remove all HTML on click</span></span>Purge HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="clear-html-attributes" href="#"><span class="tooltip-container"><span class="tooltip-label">Removes HTML attributes except for <br>target,class,href & src</span></span>Clean HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="createbackup" href="#"><span class="tooltip-container"><span class="tooltip-label">Save contents as metafield</span></span>Backup</a> <a class="btn btn-slim fd-btn" style="display:none;" id="restorebackup" href="#">Restore Backup</a> <a class="btn btn-slim fd-btn" id="save_images_to_meta" href="#">Images to Metafields</a></div>'),
D());var a=$(".action-bar__top-links");a.length?$.ajax({type:"GET",url:"/admin/pages.json?limit=250&fields=id,title",dataType:"json",success:function(b){if(b){b=b.pages;for(var c="",d=0,f=b.length;d<f;d++)g("omega")!==b[d].id.toString()&&(c+='<option value="'+b[d].id+'">'+b[d].title+"</option>");b=$("<select />",{id:"shopifyjs_llselect","class":"header-select"}).append("<option selected>Edit other Page</option>",c).change(function(){var a=$(this).val();a&&r("/admin/pages/"+a)});b.find("option").sort(Z).appendTo(b);
a.after(b)}},error:function(a){f("Error loading page data",!0)}}):f("ShopifyFD error : setup_pages : Page switcher target HTML not found",!0)},V=function(b){try{JSON.parse(b)}catch(c){return!1}return!0},ua=function(){var b=function(){for(var a=["price","weight"],b=0;b<a.length;b++)V(localStorage["rates_"+a[b]])&&($('button.paste-rates[data-type="'+a[b]+'"]')[0].disabled=!1)},c=function(a,b){for(var c=0;c<k.data.shipping_zones.length;c++)if(k.data.shipping_zones[c].id===parseInt(a))return"undefined"===
typeof b?k.data.shipping_zones[c]:k.data.shipping_zones[c][b+"_based_shipping_rates"];return!1};(function(a){$.ajax({type:"GET",dataType:"json",url:"/admin/settings/shipping_zones.json",success:function(b){k.data.shipping_zones=b.shipping_zones;"function"===typeof a&&a(b)},error:function(a){f("Error getting JSON rates",!0)}})})(function(a){if(M()){a=["price","weight"];for(var d={},e={},f={price:'<input type="hidden" name="shipping_zone[rates][][min_order_subtotal]" value="%min_order_subtotal%""><input type="hidden" name="shipping_zone[rates][][max_order_subtotal]" value="%max_order_subtotal%">',
weight:'<input type="hidden" name="shipping_zone[rates][][weight_low]" value="%weight_low%"><input type="hidden" name="shipping_zone[rates][][weight_high]" value="%weight_high%">'},g=['<tr class="pasted-rate" style="opacity:.5;font-style:italic"><td><input name="shipping_zone[rates][][name]" value="%name%"></td><td>%range%</td><td>%amount%</td><td class="shipping-rate__actions type--right"><input type="hidden" name="shipping_zone[rates][][id]" value=""><input type="hidden" name="shipping_zone[rates][][price]" value="%price%"><input type="hidden" name="shipping_zone[rates][][type]" value="%type%">',
'Pasted<button class="btn btn--plain btn-remove-paste"><svg class="next-icon next-icon--size-10 next-icon--slate-lighter"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-remove"></use></svg></button></td></tr>'],k=$(".header__primary-actions .btn-primary"),h=function(a,b){var c=g.join(f[b]);for(d in a)a.hasOwnProperty(d)&&(c=-1<["max_order_subtotal","weight_high"].indexOf(d)&&!a[d]?c.replace("%"+d+"%",""):c.replace("%"+d+"%",a[d]));var d="";"weight"===b?d=parseInt(a.weight_low).toFixed(2)+
" "+Shopify.shop.settings.defaultWeightUnit+" - "+parseInt(a.weight_high).toFixed(2)+" "+Shopify.shop.settings.defaultWeightUnit:"price"===b&&(d=a.max_order_subtotal?Shopify.shop.settings.money_symbol+a.min_order_subtotal+" - "+Shopify.shop.settings.money_symbol+a.max_order_subtotal:Shopify.shop.settings.money_symbol+a.min_order_subtotal+" and up");c=c.replace("%range%",d);c=c.replace("%type%",b);return c=0===parseInt(a.price)?c.replace("%amount%","Free"):c.replace("%amount%",Shopify.shop.settings.money_symbol+
a.price)},n=0;n<a.length;n++)d[a[n]]=$('button[data-bind-event-click="'+a[n]+"BasedShippingRateModal.open(), "+a[n]+'BasedShippingRateModal.new()"]'),e[a[n]]=$('.table-wrapper[data-bind-show="'+a[n]+'BasedShippingRatesViewer.hasRates()"] .js-rates-container'),d[a[n]].length&&($('.copy-paste-rates[data-type="'+a[n]+'"]').length||d[a[n]].before('<button data-type="'+a[n]+'" class="copy-rates btn">Copy</button> <button data-type="'+a[n]+'" class="paste-rates btn" disabled>Paste</button> '));a=$("button.copy-rates");
d=$("button.paste-rates");a.on("click",function(a){a.preventDefault();var d=$(this);a=d.data("type");d.blur();d=C();localStorage["rates_"+a]=JSON.stringify(c(d[1],a));b()});d.on("click",function(a){a.preventDefault();var b=$(this);a=b.data("type");b.blur();if(V(localStorage["rates_"+a])&&"undefined"!==typeof e[a]&&(b=JSON.parse(localStorage["rates_"+a]),b.length)){C();$('div[data-bind-show="'+a+'BasedShippingRatesViewer.hasRates()"]')[0].classList.remove("hide");var c=$('div[data-bind-show="!'+a+
'BasedShippingRatesViewer.hasRates()"]');c.length&&c[0].classList.add("hide");for(c=0;c<b.length;c++)e[a].append(h(b[c],a));$(".btn-remove-paste").off("click").on("click",function(a){a.preventDefault();$(this).parents(".pasted-rate").remove()});k.length&&(k[0].disabled=!1,k[0].classList.remove("disabled"))}});b()}})},va=function(){var b=$(".ui-layout__section--secondary .ui-layout__item:last"),c=$(".ui-title-bar");b.length?(b.prepend('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),
b=$("div.metafield-content"),u(b),0===$("#rte_extra").length&&($("#collection-description_iframecontainer").eq(0).after('<div class="sst" id="rte_extra"><a class="btn btn-slim fd-btn tooltip btn-destroy tooltip-bottom" id="clearformatting" href="#"><span class="tooltip-container"><span class="tooltip-label">Will remove all HTML on click</span></span>Purge HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="clear-html-attributes" href="#"><span class="tooltip-container"><span class="tooltip-label">Removes HTML attributes except for <br>target,class,href & src</span></span>Clean HTML</a> <a class="btn btn-slim fd-btn tooltip tooltip-bottom" id="createbackup" href="#"><span class="tooltip-container"><span class="tooltip-label">Save contents as metafield</span></span>Backup</a> <a class="btn btn-slim fd-btn" style="display:none;" id="restorebackup" href="#">Restore Backup</a> <a class="btn btn-slim fd-btn" id="save_images_to_meta" href="#">Images to Metafields</a></div>'),
D())):f("ShopifyFD error : setup_custom_collections : target html not found",!0);if(c.length){b=$("<ul/>",{"class":"segmented",id:"copy-object"});var a=$("<li/>"),d=$("<a/>",{"class":"fd-btn btn btn-separate",href:"#"}).html("Duplicate").on("click",function(a){a.preventDefault();$(this).addClass("disabled is-loading");$.getJSON(["//",location.host,location.pathname].join("")+".json",function(a){delete a.collection.disjunctive;delete a.collection.handle;delete a.collection.id;delete a.collection.products_count;
delete a.collection.published_at;delete a.collection.published_scope;delete a.collection.updated_at;a.collection.published=!1;a.collection.title+=" [copy]";var b={},c="/admin/custom_collections.json",d=a.collection.collection_type;delete a.collection.collection_type;"smart"===d?(b.smart_collection=a.collection,c="/admin/smart_collections.json"):b.custom_collection=a.collection;if("smart"===d)$.ajax({type:"POST",url:c,contentType:"application/json;charset=utf-8",data:JSON.stringify(b),success:function(a){try{var b=
a[Object.keys(a)[0]].id;"undefined"!==b&&r("/admin/collections/"+b)}catch(za){}},error:function(){f("Error duplicating.",!0)}});else{var e=0,g=window.location.pathname.split("/").pop(),l=function(a,d,e,h){"undefined"!==typeof a&&"undefined"!==typeof d&&("undefined"===typeof e&&(e=1),"undefined"===typeof h&&(h=[]),f("Duplicating collection, please wait..."),$.ajax({type:"GET",url:"/admin/collects.json?limit=250&fields=product_id&page="+e+"&collection_id="+a,success:function(g){h=h.concat(g.collects);
250*e>d?(b.custom_collection.collects=h,$.ajax({type:"POST",url:c,contentType:"application/json;charset=utf-8",data:JSON.stringify(b),success:function(a){try{var b=a[Object.keys(a)[0]].id;"undefined"!==b&&r("/admin/collections/"+b)}catch(Aa){}},error:function(){f("Error duplicating.",!0)}})):l(a,d,++e,h)}}))};(function(){$.ajax({type:"GET",url:"/admin/collects/count.json?collection_id="+g,success:function(a){e=a.count;0<e&&l(g,e,1)}})})()}})});a.append(d);b.append(a);c.prepend(b)}else f("ShopifyFD error : setup_single_article : Header button missing",
!0)},wa=function(){var b=$(".ui-title-bar .ui-title-bar__heading-group");if(b.length){var c=$("<ul/>",{"class":"segmented",id:"get_all_images"}),a=$("<li/>"),d=$("<a/>",{"class":"btn",href:"#",style:"margin-left:1em"}).html("Download file list").on("click",function(){var a=$(this);(function(){var b=[];a.addClass("is-loading").attr("style","margin-left:1em;text-indent: -9999px;");var c=function(d){"undefined"===typeof d&&(d="/admin/settings/files");$.ajax({url:d,success:function(e){e=$(e);for(var h=
e.find(".next-input.next-input--readonly"),g=0;g<h.length;g++)b.push(h[g].value);e=e.find("#assets-table").next(".next-card__section").find("a:last");e=e.length?e[0].href:"";d!==e?c(e):(a.removeClass("is-loading").removeAttr("style"),b.length?(e="files-list-"+Math.floor(Date.now()/1E3)+".txt","undefined"===typeof e&&(e="blob-"+Math.floor(Date.now()/1E3)+".txt"),h=document.createElement("a"),document.body.appendChild(h),h.style="display: none",g=new Blob(["\ufeff",b],{type:"text/plain"}),g=window.URL.createObjectURL(g),
h.href=g,h.download=e,h.click(),window.URL.revokeObjectURL(g)):f("No files exist. Nothing to list.",!0))}})};c()})();return!1});a.append(d);c.append(a);b.after(c)}},W=function(b){b=$(".ui-layout__section--secondary .ui-layout__item:last");if(b.length){var c=$('<div class="ui-layout__item"><div class="next-card"></div></div>');c.find(".next-card").append('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>');
b.after(c);b=$("div.metafield-content");u(b)}else f("ShopifyFD error : setup_single_order : target html not found",!0)},xa=function(){var b=$('.no-wrap a[data-nested-link-target="true"]');if(!b.length)return!1;var c=!1;b.append('<div class="bubble hide fadein"><div class="bubble-content p"><div class="pr"><ul class="unstyled"></ul></div></div></div>').css({position:"relative"}).hover(function(){var a=$(this);c=setTimeout(function(){var b=a.find("ul").eq(0),c=a.attr("href");$("div.bubble").addClass("hide");
a.data("order")?a.find("div.bubble").removeClass("hide"):$.ajax({type:"GET",url:c+".json",success:function(c){if(c){for(var d=c.order.line_items,e=c.order.fulfillments,f="",g=0,k=d.length;g<k;g++)f+='<li style="white-space:normal">'+d[g].quantity+" × "+d[g].name+"</li>";c.order.fulfillment_status&&e.length&&(f+='<li style="white-space:normal;border-top: 1px solid #ccc;margin-top: .5em;padding-top: .5em;">Tracking#: <b>'+e[0].tracking_number+"</b></li>");a.data("order",f);b.html(f);a.find("div.bubble").removeClass("hide")}}})},
100)},function(){clearTimeout(c);$(this).find("div.bubble").addClass("hide")})},F=function(b){"undefined"!==typeof b?$(".seo-hide-button").addClass("active").attr("data-id",b).text("Show in Sitemap"):$(".seo-hide-button").removeClass("active").removeAttr("data-id").text(p.hide_from_sitemap)},t=function(){var b=z();$.getJSON(b,function(b){var a="";b=b.metafields;F();if(b.length){g("m",b);$("#metacount").text(b.length).removeClass("hide");for(var c=0,e=b.length;c<e;c++)a+='<option data-type="'+b[c].value_type+
'" data-id="'+b[c].id+'">'+b[c].namespace+"."+b[c].key+"</option>",k.metafields[b[c].id]={namespace:b[c].namespace,value:b[c].value,key:b[c].key},"backups"===b[c].namespace&&$("#restorebackup").show(),"seo"===b[c].namespace&&"hidden"===b[c].key&&1===b[c].value&&F(b[c].id);a=y+a}else $("#metacount").text("0").addClass("hide"),g("m",!1),$("#restorebackup").hide(),a=y;$("#metafieldselect").html(a);P()})},ya=function(){if(!$("#toggleBigMode").length){var b=$(".ui-app-frame__main");if(b.length){var c=
$("<a/>",{id:"toggleBigMode",title:"Toggle navigation"}).on("click",function(){$("body").toggleClass("big-view");return!1});c[0].innerHTML="<";b.append(c)}}};(function(){document.getElementsByTagName("html")[0].className+=" shopifyfd-loaded";ea();aa();var b=document.querySelectorAll('a[href="/admin/products"]');b.length&&(b[0].href="/admin/products?limit=250");b=document.querySelectorAll('a[href="'+[location.protocol,"//",location.host].join("")+'/admin/apps"]');b.length&&(b[0].href="/admin/apps/installed");
setInterval(function(){k.cache.content=document.getElementById("content");if(!k.cache.content.classList.contains("loading")){ya();if(!document.getElementById("shopifyfdnav")){var b=document.querySelectorAll(".ui-nav .ui-nav__group")[0];if(b){var a=document.createElement("div");a.innerHTML='<ul id="shopifyfdnav" class="fadein ui-nav__group ui-nav__group--parent"><li class="ui-nav__item ui-nav__item--parent"><a href="https://freakdesign.com.au/pages/shopifyfd" target="_blank" class="ui-nav__link ui-nav__link--parent" style="color: #21c2a8;"><svg class="next-icon next-icon--size-20 next-icon--no-nudge" style="fill:#27c3aa"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-settings"></use> </svg><span class="ui-nav__label ui-nav__label--parent">ShopifyFD</span></a></li></ul>';
b.parentNode.insertBefore(a,b.nextSibling)}}var d=C();b=!1;a=d[0];var e=d[1];d=d[2];"next"===e||"prev"===e||a===g("alpha")&&e===g("omega")?"next"!==e&&"prev"!==e&&d!=k.queryString&&("products"!==a||isNaN(e)?"admin"===a&&"products"===e?b=!0:"admin"===a&&"redirects"===e&&(b=!0):b=!0):b=!0;if(b)if(k.alpha=a,k.omega=e,k.queryString=d,"customers"===a&&!isNaN(e))b=$(".ui-layout__section--secondary .ui-layout__item:last"),b.length?(a=$('<div class="ui-layout__item"><div class="next-card"></div></div>'),
a.find(".next-card").append('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),b.after(a),b=$("div.metafield-content"),
u(b)):f("ShopifyFD error : setup_customers : target HTML not found");else if("articles"===a&&!isNaN(e))ka();else if("blogs"===a&&!isNaN(e))targetHTML=$(".ui-layout__section--secondary .ui-layout__item:last"),targetHTML.length?(targetHTML.prepend('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),
b=$("div.metafield-content"),u(b)):f("ShopifyFD error : setup_blogs : target html not found",!0);else if("collections"===a&&!isNaN(e))va();else if("menus"===a&&!isNaN(e))na();else if("orders"===a&&!isNaN(e))W();else if("draft_orders"===a&&!isNaN(e))W("drafts");else if("pages"===a&&!isNaN(e))ta();else if("products"===a&&!isNaN(e))sa();else if("variants"===a&&!isNaN(e))I(!0),b=$("#variant-edit-card"),b.length&&(b.after('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),
u($("div.metafield-content")));else if(!("admin"===a&&"articles"===e||"admin"===a&&"apps"===e||"admin"===a&&"bulk"===e||"admin"===a&&"channels"===e))if("admin"===a&&"collections"===e)pa();else if("admin"===a&&"discounts"===e)ja();else if("admin"!==a||"draft_orders"!==e)if("admin"!==a||"gift_cards"!==e)if("admin"===a&&"menus"===e)J();else if("admin"===a&&"links"===e)J();else if("admin"===a&&"link_lists"===e)J();else if("admin"===a&&"orders"===e)xa();else if("admin"===a&&"products"===e)ma();else if("admin"===
a&&"redirects"===e)oa();else if("admin"!==a||"reports"!==e)if("admin"===a&&"themes"===e)T();else if("admin"!==a||"transfers"!==e)if("online_store"!==a||"preferences"!==e)"settings"===a&&"account"===e?$(".ui-annotated-section:last").after('<section class="ui-annotated-section"><div class="ui-annotated-section__annotation"><div class="ui-annotated-section__title"><h2 class="next-heading next-heading--no-margin">Purge / Delete all site content</h2></div><div class="ui-annotated-section__description"><p>Delete all content on the store to start fresh</p></div></div><div class="ui-annotated-section__content"><div class="next-card"><div class="next-card__section"><p>Coming soon...</p></div></div></div></section>'):
"settings"===a&&"files"===e?wa():"settings"===a&&"general"===e?(b=$("#settings-general section:first"),b.length&&(a=$("<section />",{"class":"ui-annotated-section"}),e=$("<div>",{"class":"ui-annotated-section__annotation"}),d=$("<div>",{"class":"ui-annotated-section__content"}),e.html('<div class="ui-annotated-section__title"><h2 class="next-heading next-heading--no-margin">Store Metafields</h2></div><div class="ui-annotated-section__description"><p>Edit your shop level metafields here. Review the <a target="_blank" href="http://docs.shopify.com/themes/liquid-documentation/objects/metafield">Shopify documentation</a> for more info on Metafields.</p></div>'),
d.html('<div class="next-card-metafield next-card next-card--aside fadein"><section class="next-card__section"><h3 class="next-heading">Metafields <svg class="next-icon next-icon--size-16 metafield-fullscreen-btn"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-website"></use></svg><span id="metacount" class="hide">0</span></h3><div class="metafield-content content"><i class="ico ico-20 ico-20-loading"></i></div></section></div>'),a.append(e,d),b.after(a),b=$("div.metafield-content"),
$(".next-card-metafield").removeClass("next-card--aside"),u(b))):"settings"===a&&"shipping"===e?$(".ui-annotated-section__annotation .ui-annotated-section__description").eq(2).append("<br><br><p>Shipping rates copy and paste has moved into each shipping zone.</p>"):"shipping_zones"!==a||isNaN(e)||ua()}},1E3);f("ShopifyFD loaded")})()}else f("Browser unsupported (classList)")})();