Browse Source

Reset modal form at modal close

Vova Tkach 6 years ago
parent
commit
9de1ec8af6

+ 5 - 5
engine/wrapper/resources/scripts/assets.cp.scripts.js

@@ -36,11 +36,6 @@ function AjaxFail() {
 	window.location.reload(false);
 }
 
-function ActionUserSettings() {
-	// Reset form to remove autocomplete
-	$('form.form-user-settings')[0].reset();
-}
-
 function ActionSingOut() {
 	$.ajax({
 		type: "POST",
@@ -99,5 +94,10 @@ $(document).ready(function() {
 		if(modal_alert_place.length) {
 			modal_alert_place.html('');
 		}
+		// Reset form at modal close
+		form = $(this).find('form');
+		if(form.length) {
+			form[0].reset();
+		}
 	});
 });

+ 1 - 1
engine/wrapper/resources/scripts/assets.cp.scripts.js.go

@@ -1,4 +1,4 @@
 package scripts
 
 // https://jscompress.com/
-var File_assets_cp_scripts_js = []byte(`function GetModalAlertTmpl(a,e,s){return'<div class="alert alert-'+(s?"danger":"success")+' alert-dismissible fade show" role="alert"><strong>'+a+"</strong> "+e+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'}function ShowSystemMsg(a,e,s){var t=$(".modal.show .sys-messages");t.length||(t=$("form.alert-here .sys-messages")),t.length&&t.html(GetModalAlertTmpl(a,e,s))}function ShowSystemMsgSuccess(a,e){ShowSystemMsg(a,e,!1)}function ShowSystemMsgError(a,e){ShowSystemMsg(a,e,!0)}function AjaxDone(data){try{eval(data)}catch(a){a instanceof SyntaxError&&(console.log(data),ModalShowMsg("JavaScript Eval Error",a.message))}}function AjaxFail(){console.log("Form send fail, page will be reloaded"),window.location.reload(!1)}function ActionUserSettings(){$("form.form-user-settings")[0].reset()}function ActionSingOut(){$.ajax({type:"POST",url:"/cp/",data:{action:"singout"}}).done(function(a){AjaxDone(a)}).fail(function(){AjaxFail()})}$(document).ready(function(){$("form").each(function(){$(this).submit(function(a){var e=$(this);if(e.hasClass("loading"))a.preventDefault();else{e.addClass("loading").addClass("alert-here");var s=$(this).find("button[type=submit]");s.addClass("progress-bar-striped").addClass("progress-bar-animated"),e.find(".sys-messages").html(""),$.ajax({type:"POST",url:e.attr("action"),data:e.serialize()}).done(function(a){AjaxDone(a)}).fail(function(){AjaxFail()}).always(function(){setTimeout(function(){e.removeClass("loading").removeClass("alert-here"),s.removeClass("progress-bar-striped").removeClass("progress-bar-animated")},100)}),a.preventDefault()}})}),$(".modal.fade").on("hidden.bs.modal",function(){modal_alert_place=$(this).find(".sys-messages"),modal_alert_place.length&&modal_alert_place.html("")})});`)
+var File_assets_cp_scripts_js = []byte(`function GetModalAlertTmpl(a,e,s){return'<div class="alert alert-'+(s?"danger":"success")+' alert-dismissible fade show" role="alert"><strong>'+a+"</strong> "+e+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'}function ShowSystemMsg(a,e,s){var t=$(".modal.show .sys-messages");t.length||(t=$("form.alert-here .sys-messages")),t.length&&t.html(GetModalAlertTmpl(a,e,s))}function ShowSystemMsgSuccess(a,e){ShowSystemMsg(a,e,!1)}function ShowSystemMsgError(a,e){ShowSystemMsg(a,e,!0)}function AjaxDone(data){try{eval(data)}catch(a){a instanceof SyntaxError&&(console.log(data),ModalShowMsg("JavaScript Eval Error",a.message))}}function AjaxFail(){console.log("Form send fail, page will be reloaded"),window.location.reload(!1)}function ActionSingOut(){$.ajax({type:"POST",url:"/cp/",data:{action:"singout"}}).done(function(a){AjaxDone(a)}).fail(function(){AjaxFail()})}$(document).ready(function(){$("form").each(function(){$(this).submit(function(a){var e=$(this);if(e.hasClass("loading"))a.preventDefault();else{e.addClass("loading").addClass("alert-here");var s=$(this).find("button[type=submit]");s.addClass("progress-bar-striped").addClass("progress-bar-animated"),e.find(".sys-messages").html(""),$.ajax({type:"POST",url:e.attr("action"),data:e.serialize()}).done(function(a){AjaxDone(a)}).fail(function(){AjaxFail()}).always(function(){setTimeout(function(){e.removeClass("loading").removeClass("alert-here"),s.removeClass("progress-bar-striped").removeClass("progress-bar-animated")},100)}),a.preventDefault()}})}),$(".modal.fade").on("hidden.bs.modal",function(){modal_alert_place=$(this).find(".sys-messages"),modal_alert_place.length&&modal_alert_place.html(""),form=$(this).find("form"),form.length&&form[0].reset()})});`)

File diff suppressed because it is too large
+ 0 - 0
engine/wrapper/resources/templates/cp.base.go


+ 1 - 1
engine/wrapper/resources/templates/cp.base.html

@@ -81,7 +81,7 @@
 							<img class="rounded-circle" src="{{$.Data.UserAvatarLink}}">{{$.Data.UserEmail}}
 						</a>
 						<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nbAccountDropdown">
-							<a class="dropdown-item" href="javascript:;" onclick="ActionUserSettings();" data-toggle="modal" data-target="#sys-modal-user-settings" data-backdrop="static" data-keyboard="false">Settings</a>
+							<a class="dropdown-item" href="javascript:;" data-toggle="modal" data-target="#sys-modal-user-settings" data-backdrop="static" data-keyboard="false">Settings</a>
 							<div class="dropdown-divider"></div>
 							<a class="dropdown-item" href="javascript:ActionSingOut();">Sing out</a>
 						</div>

Some files were not shown because too many files changed in this diff