| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <div>
- <?php if (!empty($msgs)) : ?>
- <?php foreach ($msgs as $msgId => $msg) : ?>
- <div class="alert alert-<?php echo V::get('type', 'info', $msg); ?>">
- <?php echo $msg['message']; ?>
- <?php if ('ajax' == V::get('linkType', '', $msg)) : ?>
- <a class="btn btn-primary btn-xs" target="_blank" onclick="return msgAjaxAction(this);" href="<?php echo $msg['link']; ?>">uruchom</a>
- <?php else : ?>
- <a class="btn btn-primary btn-xs" target="_blank" href="<?php echo $msg['link']; ?>">uruchom</a>
- <?php endif; ?>
- </div>
- <?php endforeach; ?>
- <?php endif; ?>
- </div>
- <script type="text/javascript">
- function msgAjaxAction(n) {
- var $n = jQuery(n);
- $n.text($n.text() + '...').attr('disabled', 'disabled');
- function notifyAjaxCallback(data) {
- var notify = {};
- notify.type = (data && data.type)? data.type : '';
- notify.msg = (data && data.msg)? data.msg : '';
- switch (notify.type) {
- case 'success':
- if (!notify.msg) notify.msg = 'Gotowe';
- break;
- case 'error':
- if (!notify.msg) notify.msg = 'Wystąpiły błędy';
- break;
- case 'warning':
- notify.type = 'warn';
- if (!notify.msg) notify.msg = 'Wystąpiły błędy';
- break;
- default:
- notify.msg = 'Nieznany błąd';
- if (data && data.errorCode) notify.msg += ' ' + data.errorCode;
- notify.type = '';
- }
- jQuery.notify(notify.msg, notify.type);
- }
- $.ajax({
- data: {},
- dataType: 'json',
- type: "GET",
- url: $n.attr('href')
- })
- .done(function(data, textStatus, jqXHR){
- notifyAjaxCallback(data);
- $n.closest('.alert').fadeOut('slow');//.remove()
- })
- .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
- if (jqXHR.responseJSON) {
- notifyAjaxCallback(jqXHR.responseJSON);
- }
- else {
- var txt = jqXHR.responseText || 'Wystąpiły błędy';
- if (jqXHR.status == 404) {
- jQuery.notify(jqXHR.responseText, 'error');
- } else {
- jQuery.notify(jqXHR.responseText, 'warn');
- }
- }
- });
- return false;
- }
- </script>
|