functionenablePWImageDialogButtons(){var$buttonPane=parent.jQuery(".ui-dialog-buttonpane");$buttonPane.find("button").button("enable");return}functiondisablePWImageDialogButtons(){var$buttonPane=parent.jQuery(".ui-dialog-buttonpane");$buttonPane.find("button").button("disable");return}functionclosePWImageDialog(){parent.jQuery("iframe.ui-dialog-content").dialog("close")}functionsetupProcessSaveReloaded(fileID,isNew){if(isNew){varoffsetTop=parent.jQuery("#"+fileID).offset().top-20;parent.jQuery("html, body").animate({scrollTop:offsetTop},1e3,"swing");parent.jQuery("#"+fileID).hide();setTimeout(function(){parent.jQuery("#"+fileID).slideDown()},900)}else{parent.jQuery("#"+fileID).find("img").hide();setTimeout(function(){parent.jQuery("#"+fileID).find("img").fadeIn("normal",function(){parent.jQuery("#"+fileID).find(".gridImage__edit").trigger("click")})},500)}closePWImageDialog()}functionsetupProcessSave(fieldName,fileID,isNew){varfinished=false;var$inputfield=parent.jQuery("#wrap_Inputfield_"+fieldName);if(!$inputfield.length){$inputfield=parent.jQuery("#"+fileID).closest(".InputfieldImage")}$inputfield.trigger("reload");parent.jQuery(".Inputfield").on("reloaded",function(){if(finished)return;finished=true;if(fileID.length>0){setTimeout(function(){setupProcessSaveReloaded(fileID,isNew)},250)}})}functionrefreshPageEditField(fieldName){parent.jQuery("#wrap_Inputfield_"+fieldName).trigger("reload")}functionsetupExecuteVariations(){$(document).on("click","input#delete_all",function(event){if($(this).is(":checked")){$("input.delete").prop("checked",true)}else{$("input.delete").prop("checked",false)}event.stopPropagation()});varmagnificOptions={type:"image",closeOnContentClick:true,closeBtnInside:true};$("a.preview").magnificPopup(magnificOptions);var$varcnt=$("#varcnt_id");varvarcntID=$varcnt.val();varvarcnt=$varcnt.attr("data-cnt");window.parent.jQuery("#"+varcntID).text(varcnt)}functionsetupSelectedImage(){varcroppingActive=false;varinputPixelsActive=false;var$form=$("#selected_image_settings");var$container=$("#selected_image_container");var$img=$("#selected_image");var$hidpi=$("#selected_image_hidpi");varfullWidth;varminWidth=0;varminHeight=0;functionsetupImage($img){varoriginalWidth=$img.width();varmaxWidth=9999;varmaxHeight=9999;functionupdateHidpiCheckbox(w){if(w<fullWidth-fullWidth*.2){if(!$hidpi.is(":visible"))$hidpi.closest("label").fadeIn();$hidpi.prop("disabled",false)}else{$hidpi.prop("disabled",true);if($hidpi.is(":visible"))$hidpi.closest("label").fadeOut()}}functionpopulateResizeDimensions(){varw=Math.round($img.width());varh=Math.round($img.height());var$link=$("#wrap_link_original");if((h>=maxHeight||w>=maxWidth)&&$form.hasClass("croppable")){w=maxWidth;h=maxHeight;$("#selected_image_link").prop("checked",false);$link.hide()}else{if(!$link.is(":visible")){$link.fadeIn();if($link.attr("data-was-checked")==1){$link.prop("checked",true)}}}$("#input_width").val(w);$("#input_height").val(h);$img.attr("width",w);$img.attr("height",h);updateHidpiCheckbox(w);var$latin=$("#latin");if($latin.is(":visible"))$latin.height(h);if(!$form.hasClass("rte")){var$useResize=$("#selected_image_resize");if(originalWidth<=w){$useResize.hide()}else{if(!$useResize.is(":visible"))$useResize.fadeIn()}}}functionsetupImageResizable(){$img.resizable({aspectRatio:true,handles:"n, ne, e, se, s, sw, w",alsoResize:"#selected_image_container",maxWidth:maxWidth,maxHeight:maxHeight,minWidth:10,minHeight:10,start:function(){$form.addClass("resizing_active")},stop:function(){$img.attr("width",$img.width()).attr("height",$img.height());if(originalWidth!=$img.width()){$img.addClass("resized");if(!$form.hasClass("rte")){var$resizeYes=$("#selected_image_resize_yes");if(!$resizeYes.is(":checked")){$resizeYes.prop("checked",true);$("#selected_image_resize_no").prop("checked",false)}}}$form.removeClass("resizing_active");if($("#resize_action").hasClass("on"))$("#resize_action").trigger("click").mouseout()},resize:populateResizeDimensions});$img.addClass("resizable_setup")}varcropData=null;functionsetupImageCroppable