praiadeseselle/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.min.js

1 line
2.7 KiB
JavaScript
Raw Permalink Normal View History

2022-03-08 15:55:41 +01:00
function initPageEditForm(){$("#ProcessPageEdit:not(.ProcessPageEditSingleField)").WireTabs({items:$("#ProcessPageEdit > .Inputfields > .InputfieldWrapper"),id:"PageEditTabs",skipRememberTabIDs:["ProcessPageEditDelete"]});$("#submit_delete").click(function(){if(!$("#delete_page").is(":checked")){$("#wrap_delete_page label").effect("highlight",{},500);return}$(this).before("<input type='hidden' name='submit_delete' value='1' />");$("#ProcessPageEdit").submit()});$(document).on("click","button[type=submit]",function(e){if($("body").hasClass("pw-uploading")){return confirm($("#ProcessPageEdit").attr("data-uploading"))}});if(typeof InputfieldSubmitDropdown!="undefined"){var $dropdownTemplate=$("ul.pw-button-dropdown:not(.pw-button-dropdown-init)");$("button[type=submit]").each(function(){var $button=$(this);var name=$button.attr("name");if($button.hasClass("pw-no-dropdown"))return;if(name.indexOf("submit")==-1||name.indexOf("_draft")>-1)return;if(name.indexOf("_save")==-1&&name.indexOf("_publish")==-1)return;InputfieldSubmitDropdown.init($button,$dropdownTemplate)})}var $viewLink=$("#_ProcessPageEditView");var $viewMenu=$("#_ProcessPageEditViewDropdown");var color=$viewLink.css("color");$("#_ProcessPageEditViewDropdownToggle").css("color",color);$viewLink.click(function(){var action=$viewLink.attr("data-action");if(action=="this"||action=="new"||!action.length)return true;$viewMenu.find(".page-view-action-"+action+" > a").click();return false});var $template=$("#template");var templateID=$template.val();$template.on("change",function(){if($(this).val()==templateID){$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-on")}else{$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-off")}});$(document).on("wiretabclick",function(event,$newTab,$oldTab){if($newTab.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit:not(#wrap_submit_delete):visible").addClass("pw-hidden-tmp").hide()}else if($oldTab.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit.pw-hidden-tmp").removeClass("pw-hidden-tmp").show()}});var $title=$("body").hasClass("AdminThemeReno")?$("#title"):$("#pw-content-title");if($title.length){var $titleInput=null;if(typeof ProcessWire.config.LanguageSupport!=="undefined"){if(typeof ProcessWire.config.LanguageSupport.language!=="undefined"){$titleInput=$("#Inputfield_title__"+ProcessWire.config.LanguageSupport.language.id)}}if(!$titleInput||!$titleInput.length||!$titleInput.val().length)$titleInput=$("#Inputfield_title");if(!$titleInput.length||!$titleInput.val().length)$titleInput=$("#Inputfield__pw_page_name");if($titleInput.length){var title=$titleInput.val();if(title.length)$titleInput.on("input",function(){var val=$(this).val();$title.text(val.length>0?val:title)})}}}