|
@@ -4,9 +4,70 @@
|
|
|
<?php foreach ($msgs as $msgId => $msg) : ?>
|
|
<?php foreach ($msgs as $msgId => $msg) : ?>
|
|
|
<div class="alert alert-<?php echo V::get('type', 'info', $msg); ?>">
|
|
<div class="alert alert-<?php echo V::get('type', 'info', $msg); ?>">
|
|
|
<?php echo $msg['message']; ?>
|
|
<?php echo $msg['message']; ?>
|
|
|
- <a class="btn btn-primary btn-xs" target="_blank" href="<?php echo $msg['link']; ?>">uruchom</a>
|
|
|
|
|
|
|
+ <?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>
|
|
</div>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</div>
|
|
</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>
|