cl01/wp-content/plugins/socialsnap/assets/js/admin-editor.js
2025-02-24 12:39:24 +08:00

1 line
22 KiB
JavaScript
Executable File

!function(n){var o=window.MutationObserver||window.WebKitMutationObserver;n.fn.attrchange=function(s,e){var t,i,a;return"object"==typeof s?(t={trackValues:!1,callback:n.noop},"function"==typeof s?t.callback=s:n.extend(t,s),t.trackValues&&this.each(function(s,e){var t,i={};for(s=0,attrs=e.attributes,l=attrs.length;s<l;s++)i[(t=attrs.item(s)).nodeName]=t.value;n(this).data("attr-old-value",i)}),o?(i={subtree:!1,attributes:!0,attributeOldValue:t.trackValues},a=new o(function(s){s.forEach(function(s){var e=s.target;t.trackValues&&(s.newValue=n(e).attr(s.attributeName)),"connected"===n(e).data("attrchange-status")&&t.callback.call(e,s)})}),this.data("attrchange-method","Mutation Observer").data("attrchange-status","connected").data("attrchange-obs",a).each(function(){a.observe(this,i)})):function(){var s=document.createElement("p"),e=!1;if(s.addEventListener)s.addEventListener("DOMAttrModified",function(){e=!0},!1);else{if(!s.attachEvent)return;s.attachEvent("onDOMAttrModified",function(){e=!0})}return s.setAttribute("id","target"),e}()?this.data("attrchange-method","DOMAttrModified").data("attrchange-status","connected").on("DOMAttrModified",function(s){(s=s.originalEvent?s.originalEvent:s).attributeName=s.attrName,s.oldValue=s.prevValue,"connected"===n(this).data("attrchange-status")&&t.callback.call(this,s)}):"onpropertychange"in document.body?this.data("attrchange-method","propertychange").data("attrchange-status","connected").on("propertychange",function(s){s.attributeName=window.event.propertyName,function(s,e){var t;s&&(s=this.data("attr-old-value"),0<=e.attributeName.indexOf("style")?(s.style||(s.style={}),t=e.attributeName.split("."),e.attributeName=t[0],e.oldValue=s.style[t[1]],e.newValue=t[1]+":"+this.prop("style")[n.camelCase(t[1])],s.style[t[1]]=e.newValue):(e.oldValue=s[e.attributeName],e.newValue=this.attr(e.attributeName),s[e.attributeName]=e.newValue),this.data("attr-old-value",s))}.call(n(this),t.trackValues,s),"connected"===n(this).data("attrchange-status")&&t.callback.call(this,s)}):this):"string"==typeof s&&n.fn.attrchange.hasOwnProperty("extensions")&&n.fn.attrchange.extensions.hasOwnProperty(s)?n.fn.attrchange.extensions[s].call(this,e):void 0}}(jQuery),function(e){jQuery.fn[e]=function(s){return s?this.on("resize",(t=s,function(){var s=this,e=arguments;n?clearTimeout(n):a&&t.apply(s,e),n=setTimeout(function(){a||t.apply(s,e),n=null},i||100)})):this.trigger(e);var t,i,a,n}}((jQuery,"ss_smartresize")),function(o){var i={init:function(){o(document).ready(i.ready),o(window).on("load",i.load),o(window).ss_smartresize(i.resize)},ready:function(){i.binds(),i.countChars()},load:function(){},resize:function(){},openModal:function(){o("body,html").addClass("ss-no-scroll"),o("body").addClass("ss-open-modal"),o("body").on("keyup",i.closeModalKey);var s="";tinyMCE.activeEditor&&(s=tinyMCE.activeEditor.selection.getContent({format:"text"})),o("#ss_ctt_quote_content").val(s),o("#ss_ctt_tweet_content").val(s)},closeModal:function(){o("body,html").removeClass("ss-no-scroll"),o("body").removeClass("ss-open-modal"),o("body").off("keyup",i.closeModalKey),o("#ss-modal input[type=text]:not(.ss-has-default), #ss-modal textarea:not(.ss-has-default)").val(""),o("#ss-modal select option").removeAttr("selected"),o("#ss-modal select option:first").attr("selected","selected")},closeModalKey:function(s){27==s.keyCode&&i.closeModal()},binds:function(){o(document).on("click",".ss-mce-button, .mce-i-socialsnap-menu-icon, .wp-media-buttons-icon.socialsnap-menu-icon",function(s){s.preventDefault(),i.openModal(),i.countChars()}),o(document).on("click",".ss-close-modal",function(s){s.preventDefault(),i.closeModal()}),o(".ss-metabox-wrapper").on("click","li > a",function(s){s.preventDefault();var s=o(this),e=s.closest(".ss-metabox-wrapper");e.find(".ss-metabox-tabs > li").removeClass("current-menu-item"),e.find(".ss-metabox-content .ss-active").removeClass("ss-active"),s.parent().addClass("current-menu-item"),s=s.attr("href").substring(1),e.find('.ss-tab[data-id="'+s+'"]').addClass("ss-active"),i.countChars()}),o(document).on("click","#ss-insert-shortcode",function(s){function e(s){return s.replace(/[\u00A0-\u9999<>\&]/g,function(s){return"&#"+s.charCodeAt(0)+";"})}s.preventDefault();var s=o("#ss-modal").find(".ss-metabox-content .ss-active").data("id"),t="";"ss-click-to-tweet-editor"===s&&(console.log(o("#ss_ctt_tweet_content").val()),console.log(e(o("#ss_ctt_tweet_content").val())),t=(t=(t=(t+="[ss_click_to_tweet")+' tweet="'+e(o("#ss_ctt_tweet_content").val())+'"')+' content="'+e(o("#ss_ctt_quote_content").val())+'"')+' style="'+o("#ss_ctt_style option:selected").val()+'"',"default"!==o("#ss_ctt_post_link option:selected").val()&&(t+=' link="'+o("#ss_ctt_post_link option:selected").val()+'"'),"default"!==o("#ss_ctt_include_via option:selected").val()&&(t+=' via="'+o("#ss_ctt_include_via option:selected").val()+'"'),t+="]",wp.media.editor.insert(t)),"ss-social-share-editor"===s&&(t+="[ss_social_share",""!=o("#ss_ss_networks").val()&&(t+=' networks="'+o("#ss_ss_networks").val()+'"'),t=(t=(t=(t=(t=(t=(t=(t+=' align="'+o("#ss_ss_button_align option:selected").val()+'"')+' shape="'+o("#ss_ss_button_shape option:selected").val()+'"')+' size="'+o("#ss_ss_button_size option:selected").val()+'"')+' labels="'+o("#ss_ss_button_labels option:selected").val()+'"')+' spacing="'+(o("#ss_ss_button_spacing").is(":checked")?1:0)+'"')+' hide_on_mobile="'+(o("#ss_ss_hide_on_mobile").is(":checked")?1:0)+'"')+' total="'+(o("#ss_ss_total_count").is(":checked")?1:0)+'"')+' all_networks="'+(o("#ss_ss_all_networks").is(":checked")?1:0)+'"',o("#ss_ss_total_count_style").length&&(t+=' inline_total_style="'+o("#ss_ss_total_count_style option:selected").val()+'"'),o("#ss_ss_total_count_placement").length&&(t+=' total_share_placement="'+o("#ss_ss_total_count_placement option:selected").val()+'"'),o("#ss_ss_hover_animation").length&&(t+=' hover_animation="'+o("#ss_ss_hover_animation option:selected").val()+'"'),o("#ss_ss_button_target_editor").length&&o("#ss_ss_button_target_editor").val()&&(t+=' share_target="'+o("#ss_ss_button_target_editor").val()+'"'),t+="]",wp.media.editor.insert(t)),"ss-social-follow-editor"===s&&(t+="[ss_social_follow",""!=o("#ss_sf_networks").val()&&(t+=' networks="'+o("#ss_sf_networks").val()+'"'),o.each({size:"ss_sf_button_size",spacing:"ss_sf_button_spacing",columns:"ss_sf_button_columns",vertical:"ss_sf_button_vertical",scheme:"ss_sf_button_scheme",total_followers:"ss_sf_total_followers",button_followers:"ss_sf_button_followers",labels:"ss_sf_button_labels"},function(s,e){"default"!==o("#"+e).val()&&(t+=" "+s+'="'+o("#"+e).val()+'"')}),t+="]",wp.media.editor.insert(t)),i.closeModal()}),o(".ss-field-wrapper").on("click",".ss-upload-button",function(s){s.preventDefault();var e,t,s=o(this),i="",a="#"+s.attr("id").replace("_button",""),n=wp.media.frames.file_frame=wp.media({title:socialsnap_editor.l10n.upload_title,button:{text:socialsnap_editor.l10n.use_file},multiple:s.data("multiple"),library:{type:s.data("type").split(",")}});n.on("select",function(){e=n.state().get("selection").first().toJSON();var s=o(a+"-preview");"image"===e.type?(t=e.editLink,i=(void 0!==e.sizes.medium?e.sizes.medium:e).url,s.find(".ss-video-name").remove(),s.find("img").length?s.find("img").attr("src",i):s.append("<img src="+i+" />"),o(a).val(e.url).trigger("change"),o(a+"_img_id").val(e.id),o(a+"_edit").attr("href",t),o(a+"_dimension").html(e.width+"px x "+e.height+"px"),s.addClass("mime-type-image")):"video"===e.type&&(s.find("img").remove(),s.find(".ss-video-name").length?s.find(".ss-video-name").html(e.filename):s.append('<span class="ss-video-name">'+e.filename+"</em></span>"),o(a).val(e.url).trigger("change"),o(a+"_img_id").val(e.id),o(a+"_dimension").html(e.width+"px x "+e.height+"px"),s.addClass("mime-type-video"))}),n.open()}),o(".ss-field-wrapper").on("click",".ss-remove-image",function(s){s.preventDefault();var s="#"+o(this).attr("id").replace("_remove",""),e=o(s+"-preview");e.find("img").remove(),e.find(".ss-video-name").remove(),e.removeClass().addClass("show-upload-image"),o(s+"_img_id").val("").trigger("change")}),o("#ss-sap-meta-settings").on("click",function(s){o('.ss-metabox-tabs a[href="#ss-sap-metabox"]').click()})},countChars:function(){var s,e;o(".ss-count-char").each(function(){o(this).siblings("textarea, input[type=text]").on("input",function(){s=o(this).siblings(".ss-count-char"),e=s.data("count"),(e=e-o(this).val().length)<0?s.addClass("exceeded"):s.removeClass("exceeded"),s.find("strong").html(e)})}),o(".ss-field-wrapper textarea, .ss-field-wrapper input[type=text]").trigger("input")}};i.init(),window.socialsnapeditor=i}(jQuery),function(o){var e={init:function(){o(document).ready(e.ready),o(window).on("load",e.load),o(window).ss_smartresize(e.resize)},ready:function(){e.dependencyOptions(),e.shareNetworks(),e.followNetworks(),e.colorPicker(),e.binds()},load:function(){},resize:function(){},colorPicker:function(){o(".ss-color-picker-element").length&&(o(".ss-color-picker-element").iris({width:310,hide:!0,palettes:!0,mode:"hsl",change:function(s,e){o(s.target).siblings(".ss-color-value").css("background-color",e.color.toString()),o(s.target).siblings("input[type=hidden]").val(e.color.toString()).trigger("change")}}),o(".ss-color-picker").on("click",function(s){s.preventDefault();s=o(this);s.hasClass("ss-opened")||(s.addClass("ss-opened").find(".ss-color-picker-element").iris("show"),o("#ss-settings-wrapper").on("click",e.closeColorPicker))}))},closeColorPicker:function(s){o(".ss-color-picker").find("."+s.target.classList[0]).length||(o(".ss-color-picker-element").iris("hide"),o("#ss-settings-wrapper").off("click",e.closeColorPicker),o(".ss-color-picker").removeClass("ss-opened"))},followNetworks:function(s){o("#ss-settings-wrapper").on("click",".ss-configure-follow-network",function(s){s.preventDefault();var e=o("#ss-sf-networks-popup"),s=o(this);e.hasClass("ss-open")||(e.removeClass("ss-hidden"),setTimeout(function(){e.addClass("ss-open")},10)),e.find(".ss-sf-setup-title").html(s.closest(".ss-follow-network").data("name")),e.find(".ss-sf-network-settings").addClass("ss-hidden"),e.find(".ss-sf-network-settings-"+s.closest(".ss-follow-network").data("id")).removeClass("ss-hidden")}),o("#ss-settings-wrapper").on("click",".ss-follow-authorize.ss-button, .ss-disconnect-authenticated-user",function(s){o(this).html(socialsnap_admin.wait_text).siblings(".spinner").addClass("visible")}),o(".ss-follow-networks").sortable({containment:"#ss-left-panel",delay:150,start:function(s,e){o(this).data("start-position",e.item.index())},update:function(s,t){var i=o(this).data("start-position"),e=(o("#ss-sf-networks-popup .ss-popup-content").each(function(s,e){i>t.item.index()?o(this).children("div:eq("+i+")").insertBefore(o(this).children("div:eq("+t.item.index()+")")):o(this).children("div:eq("+i+")").insertAfter(o(this).children("div:eq("+t.item.index()+")"))}),o("#ss-right-panel .ss-follow-preview-shortcode .ss-follow-wrapper").each(function(s,e){i>t.item.index()?o(this).children("div:eq("+i+")").insertBefore(o(this).children("div:eq("+t.item.index()+")")):o(this).children("div:eq("+i+")").insertAfter(o(this).children("div:eq("+t.item.index()+")"))}),o(this).sortable("toArray",{attribute:"data-id"}));o(this).parent().find(".ss-social-follow-order").val(e.join(";")).trigger("change")}})},shareNetworks:function(s){function n(s){s=s||o(".ss-share-networks");var e="";return s.find(".ss-ss-network").each(function(){e+=o(this).data("id")+";"}),e=e.slice(0,-1)}o(".ss-share-networks").sortable({containment:"#ss-left-panel",update:function(s,e){o(this).find(".ss-social-share-order").val(n(o(this))).trigger("change")}}),o(".ss-share-networks").on("click",".ss-ss-remove",function(s){s.preventDefault();s=o(this).parent().parent().data("id");o(this).parent().parent().remove(),o("#ss-ss-networks-popup").find("[data-id="+s+"]").removeClass("selected"),o(".ss-share-networks").find(".ss-social-share-order").val(n(o(".ss-share-networks"))).trigger("change")}),o(".ss-share-networks").on("click",".ss-ss-edit",function(s){s.preventDefault(),o(this).parent().parent().find("input").focus().select()}),o("#ss-settings-wrapper").on("click","#ss-add-share-networks",function(s){s.preventDefault(),o("#ss-ss-networks-popup").hasClass("ss-open")?(o("#ss-ss-networks-popup").removeClass("ss-open"),setTimeout(function(){o("#ss-ss-networks-popup").addClass("ss-hidden")},400)):(o("#ss-ss-networks-popup").removeClass("ss-hidden"),setTimeout(function(){o("#ss-ss-networks-popup").addClass("ss-open")},100)),o("#ss-ss-networks-popup .ss-popup-network > a").removeClass("selected"),o(".ss-share-networks").find(".ss-ss-network").each(function(){id=o(this).data("id"),o("#ss-ss-networks-popup").find("[data-id="+id+"]").addClass("selected")}),o(".ss-share-networks").find(".ss-social-share-order").val(n()).trigger("change")}),o(".ss-close-modal").click(function(s){s.preventDefault();var e=o(this);e.closest(".ss-add-networks-popup").hasClass("ss-open")&&(e.closest(".ss-add-networks-popup").removeClass("ss-open"),setTimeout(function(){e.closest(".ss-add-networks-popup").addClass("ss-hidden")},400))}),o("#ss-ss-networks-popup").on("click",".ss-popup-network > a",function(s){s.preventDefault();var s=o(".ss-share-networks"),e=s.attr("id"),t=o(this),i=t.data("id"),a=t.data("name");s.find(".ss-"+i+"-color").length?t.hasClass("selected")?(t.removeClass("selected"),s.find(".ss-"+i+"-color").parent().remove()):t.addClass("selected"):(t.addClass("selected"),t=t.data("mobile-only")?"Mobile only":'<li>Desktop<span class="ss-small-toggle"><input type="checkbox" name="'+e+"["+i+'][desktop_visibility]" id="ss-ss-visibility-desktop-'+i+'" checked="checked"><label for="ss-ss-visibility-desktop-'+i+'"></label></span></li><li>Mobile<span class="ss-small-toggle"><input type="checkbox" name="'+e+"["+i+'][mobile_visibility]" id="ss-ss-visibility-mobile-'+i+'" checked="checked"><label for="ss-ss-visibility-mobile-'+i+'"></label></span></li>',s.append('<div class="ss-ss-network" data-id="'+i+'"><i class="ss ss-'+i+'-color">'+socialsnap_admin.icons[i]+'</i><input type="text" class="ss-ss-name" name="'+e+"["+i+'][text]" value="'+a+'" placeholder="Enter network label" /><div class="ss-ss-actions"><a href="#" class="ss-ss-edit ss-tooltip" data-title="Change label"><i class="ss">'+socialsnap_admin.icons.edit+'</i></a><div class="ss-ss-mobile-visibility ss-tooltip" data-title="Device visibility"><i class="ss">'+socialsnap_admin.icons.eye+'</i><ul class="ss-ss-visibility-dropdown">'+t+'</ul></div><a href="#" class="ss-ss-remove ss-tooltip" data-title="Remove"><i class="ss">'+socialsnap_admin.icons.close+"</i></a></div></div>")),o(".ss-share-networks").find(".ss-social-share-order").val(n()).trigger("change")})},binds:function(){o("#ss-settings-wrapper").on("click","#ss-import-settings",function(s){s.preventDefault(),o(this).siblings("#ss-upload-import-file").click()}),o("#ss-settings-wrapper").on("change","#ss-upload-import-file",function(s){var e,t,i;this.files.length<1||(e=this.files[0],(t=o(this)).siblings(".ss-file-name").html(e.name),o("#ss-import-settings").attr("disabled","disabled").siblings(".spinner").addClass("visible"),o("#ss-settings-wrapper").addClass("ss-saving"),(i=new FormData).append("action","socialsnap_settings_import"),i.append("nonce",o("#ss-import-settings").data("nonce")),i.append("file",e),o.ajax({type:"POST",url:socialsnap_admin.ajaxurl,processData:!1,contentType:!1,cache:!1,data:i,success:function(s){t.siblings(".ss-file-name").html(s.data.message),o("#ss-import-settings").removeAttr("disabled","disabled").siblings(".spinner").removeClass("visible"),o("#ss-settings-wrapper").removeClass("ss-saving"),"success"===s.data.code&&location.reload(),t.val("").trigger("change")}}))}),o("#ss-settings-wrapper").on("click","#ss-restore-settings",function(s){s.preventDefault(),window.confirm(o(this).data("confirm"))&&(o(this).attr("disabled","disabled").siblings(".spinner").addClass("visible"),o("#ss-settings-wrapper").addClass("ss-saving"),s={action:"socialsnap_settings_restore",nonce:o(this).data("nonce")},o.post(socialsnap_admin.ajaxurl,s,function(s){location.reload(!0)}))}),o("#ss-settings-wrapper").on("click",".ss-upload-button",function(s){s.preventDefault();var e,s=o(this),t="#"+s.attr("id").replace("_button",""),i=wp.media.frames.file_frame=wp.media({title:s.data("title"),button:{text:s.data("button")},multiple:!1,library:{type:"image"}});i.on("select",function(){if("image"!==(e=i.state().get("selection").first().toJSON()).type)return!1;o(t+"-preview").find("img").length?o(t+"-preview").find("img").attr("src",e.url):o(t+"-preview").append("<img src="+e.url+" />"),o(t).val(e.url).trigger("change"),o(t+"_img_id").val(e.id),o(t+"_remove").removeClass("hidden")}),i.open()}),o("#ss-settings-wrapper").on("click",".ss-remove-image",function(s){s.preventDefault();var s=o(this),e="#"+s.attr("id").replace("_remove","");o(e+"-preview").find("img").remove(),o(e+"_img_id").val("").trigger("change"),o(e).val("").trigger("change"),s.addClass("hidden")}),o("#ss-settings-wrapper").on("click",".ss-button-element .ss-button",function(s){var e=o(this);this.hasAttribute("data-action")&&(s.preventDefault(),s=!0,s=this.hasAttribute("data-confirm")?window.confirm(this.getAttribute("data-confirm")):s)&&(e.attr("disabled","disabled").siblings(".spinner").addClass("visible"),o("#ss-settings-wrapper").addClass("ss-saving"),s={action:this.getAttribute("data-action"),_ajax_nonce:socialsnap_admin.nonce},o.post(socialsnap_admin.ajaxurl,s,function(s){e.removeAttr("disabled","disabled").siblings(".spinner").removeClass("visible"),s.success&&s.data.message&&alert(s.data.message),location.reload()}))});function e(){o(".ss-dropdown").removeClass("ss-open").find("ul").slideUp(90),o(document).off("click",e)}o("#ss-settings-wrapper").on("click",".ss-dropdown",function(s){s.preventDefault(),s.stopPropagation(),o(this).hasClass("ss-open")?e():(s=o(this),e(),s.addClass("ss-open").find("ul").slideDown(90),o(document).on("click",e))}),o("#ss-settings-wrapper").on("click",".ss-dropdown-values > li",function(s){s.preventDefault();var e,t,i,s=o(this);"1"==s.parent().data("multiselect")?(e=s.data("value"),t=s.html(),i=s.closest(".ss-field-wrapper").attr("id").replace("_wrapper",""),s.closest(".ss-dropdown-wrapper").find(".ss-dropdown-selected-values").append('<div class="ss-dropdown-single-value">'+t+'<a href="#" class="ss-ss-remove"><i class="ss">'+socialsnap_admin.icons.close+'</i></a><input type="hidden" name="'+i+'[]" value="'+e+'" /></div>'),s.closest(".ss-dropdown").find("span").html(t),s.closest(".ss-dropdown-wrapper").find(".ss-dropdown-selected-values .ss-trigger").trigger("change"),s.hide()):(s.closest(".ss-dropdown-wrapper").find("input").val(s.data("value")).trigger("change"),s.closest(".ss-dropdown-wrapper").find("li").removeClass("ss-current"),s.addClass("ss-current"),s.closest(".ss-dropdown").find("span").html(s.html()))}),o("#ss-settings-wrapper").on("click",".ss-dropdown-selected-values .ss-ss-remove",function(s){s.preventDefault();s=o(this);s.closest(".ss-dropdown-wrapper").find(".ss-dropdown-values").find('li[data-value="'+s.siblings("input").val()+'"]').show(),s.closest(".ss-dropdown-wrapper").find(".ss-trigger").trigger("change"),s.parent().remove()}),o("#ss-settings-wrapper").on("keyup mouseup","input[type=number]",function(s){o(this).attr("value",o(this).val())}),o("#ss-settings-wrapper").on("focus","input[readonly]",function(s){if("text"===o(this).attr("type")&&!o(this).hasClass("ss-upload-url")&&!o(this).hasClass("ss-follow-username-profile")){var e=o(this);e.select();try{document.execCommand("copy"),e.parent().addClass("ss-copied-text"),setTimeout(function(){e.parent().removeClass("ss-copied-text")},1500)}catch(s){alert(s+"Press Ctrl/Cmd+C to copy")}}}),o("#ss-settings-wrapper").on("change","#ss_social_follow_connect_networks_facebook_accounts",function(s){var e=o(this).find(":selected").data("slug");o("#ss_social_follow_connect_networks_facebook_profile_username").val(e),o("#ss_social_follow_connect_networks_facebook_profile_url").val("https://facebook.com/"+e+"/"),e=o.isNumeric(e)?o(this).find(":selected").html():e,o(".ss-follow-network[data-id=facebook] .ss-follow-network-account").html(e)}),o("#ss-settings-wrapper").on("click",".ss-open-popup",function(s){s.preventDefault();var e=o("#"+o(this).data("popup-id"));o(this);o(".ss-add-networks-popup").removeClass("ss-open").addClass("ss-hidden"),e.hasClass("ss-open")||(e.removeClass("ss-hidden"),setTimeout(function(){e.addClass("ss-open")},10))})},dependencyOptions:function(){function s(s){this.el=s}s.prototype={init:function(){this.cacheElements(),this.bindEvents()},cacheElements:function(){this.$child=o(this.el),this.vals=this.$child.data("dependency-value");var s=this.$child.data("dependency-mother");this.$mother=o("#"+s),this.mother_vals="";this.$grandmother=!1,void 0!==o("#"+this.$mother.attr("id")+"_wrapper").data("dependency-mother")&&(s=o("#"+this.$mother.attr("id")+"_wrapper").data("dependency-mother"),this.$grandmother=o("#"+s),this.mother_vals=o("#"+this.$mother.attr("id")+"_wrapper").data("dependency-value"))},bindEvents:function(){var s=this;this.$mother.on("change",this.resolveDependency.bind(this)),this.$mother.attrchange({callback:s.resolveDependency.bind(s)}),this.$grandmother&&(this.$grandmother.on("change",this.resolveDependency.bind(this)),this.$grandmother.attrchange({callback:s.resolveDependency.bind(s)})),o(window).on("load",function(){setTimeout(s.resolveDependencyLoad.bind(s),100)})},resolveDependencyLoad:function(){var s=this.$mother.val(),e=!this.$grandmother||this.$grandmother.val();this.$grandmother&&this.$grandmother.is(":checkbox")&&(e=this.$grandmother.is(":checked")),this.$mother.is(":checkbox")&&(s=this.$mother.is(":checked")),this.hasValue(s)&&(!this.$grandmother||this.motherHasValue(e))?this.show():this.hide()},resolveDependency:function(){var s=this.$mother.val(),e=!this.$grandmother||this.$grandmother.val();this.$grandmother&&this.$grandmother.is(":checkbox")&&(e=this.$grandmother.is(":checked")),this.$mother.is(":checkbox")&&(s=this.$mother.is(":checked")),this.hasValue(s)&&(!this.$grandmother||this.motherHasValue(e))?this.show():this.hide()},hasValue:function(s){return-1!==this.vals.indexOf(s)},motherHasValue:function(s){return-1!==this.mother_vals.indexOf(s)},show:function(){this.$child.hasClass("ss-toggle-element")?this.$child[0].style.display="flex":this.$child[0].style.display="block"},hide:function(){this.$child[0].style.display="none"}},o("[data-dependency-mother]").each(function(){new s(this).init()})}};e.init(),window.socialsnapfields=e}(jQuery);