diff --git a/assets/js/main.js b/assets/js/main.js index 1cb16ff..22a056a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,17 +1,33 @@ $(window).on('ajaxErrorMessage', function(event, message){ event.preventDefault(); + /*if(document.flashflag){ + document.romanov_flashoptions.message = message; + document.romanov_flashsettings.type = 'danger'; + $.notify(document.romanov_flashoptions, document.romanov_flashsettings); + }else{ + $.notify({ + message: message + },{ + type: 'danger', + placement: { + from: "top", + align: "center" + }, + delay: 10000 + }); + }*/ }); $(window).on('ajaxError', function(event, obj, context, status) { var message; var showfm = function(message){ if(document.flashflag){ - document.romanov_flashoptions.message = message[key][0]; + document.romanov_flashoptions.message = message; document.romanov_flashsettings.type = 'danger'; $.notify(document.romanov_flashoptions, document.romanov_flashsettings); }else{ $.notify({ - message: message[key][0] + message: message },{ type: 'danger', placement: { @@ -21,17 +37,24 @@ $(window).on('ajaxError', function(event, obj, context, status) { delay: 10000 }); } - } + }; if (typeof status.responseJSON === 'undefined') { - message = status.responseText.match(/^\"(.*)\"\s/)[1]; + if (typeof status.responseText !== 'undefined') { + message = status.responseText.match(/^\"(.*)\"\s/); + if (message && typeof message[1] !== 'undefined') { + message = message[1]; + } else { + message = status.responseText; + } + } } else { message = status.responseJSON.X_OCTOBER_ERROR_FIELDS; } if( typeof message === 'object' ) { - for (var key in message) { - showfm(message); - } - }else{ + $.each(message, function(){ + showfm(this[0]); + }); + }else if(typeof message !== 'undefined'){ showfm(message); } }); @@ -49,4 +72,4 @@ $(document).ready(function(){ } } }); -}); \ No newline at end of file +});