From e30ea7a493190451cd635fb7f8b5da178caa5c45 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 19 Aug 2020 07:57:35 +0200 Subject: [PATCH 1/8] Added JS for dialog --- application/views/interface_assets/footer.php | 36 +++++++++++++++++++ application/views/interface_assets/header.php | 4 +++ 2 files changed, 40 insertions(+) diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index cc4097e8..9344c130 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1432,5 +1432,41 @@ $(document).ready(function(){ + + uri->segment(2) == "was") { ?> + + + diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index db636686..73a67fbd 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -29,6 +29,10 @@ + uri->segment(2) == "was") { ?> + + + uri->segment(1) == "adif") { ?> From 712bbf184047880abacf84e588df95a6bb7bb08a Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 24 Aug 2020 20:16:06 +0200 Subject: [PATCH 2/8] More work on QSO dialog for WAS award. --- application/controllers/Awards.php | 13 ++ application/controllers/Qso.php | 63 ++++++++++ application/models/Was.php | 4 +- application/views/interface_assets/footer.php | 111 ++++++++++++++---- 4 files changed, 163 insertions(+), 28 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index d1e4d9cf..6e01f71c 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -369,6 +369,19 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } + public function was_details_ajax() { + $this->load->model('logbook_model'); + + $state = str_replace('"', "", $this->input->post("State")); + $band = str_replace('"', "", $this->input->post("Band")); + $data['results'] = $this->logbook_model->was_qso_details($state, $band); + + // Render Page + $data['page_title'] = "Log View - WAS"; + $data['filter'] = "state ".$state. " and ".$band; + $this->load->view('awards/was/details_ajax', $data); + } + public function iota () { $this->load->model('iota'); $data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 846e5741..4b50ccc8 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -124,6 +124,36 @@ class QSO extends CI_Controller { $this->load->view('qso/edit_done'); } } + + function edit_ajax() { + + $this->load->model('logbook_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $id = str_replace('"', "", $this->input->post("id")); + $query = $this->logbook_model->qso_info($id); + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('time_on', 'Start Date', 'required'); + $this->form_validation->set_rules('time_off', 'End Date', 'required'); + $this->form_validation->set_rules('callsign', 'Callsign', 'required'); + + $data['qso'] = $query->row(); + $data['dxcc'] = $this->logbook_model->fetchDxcc(); + $data['iota'] = $this->logbook_model->fetchIota(); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('qso/edit', $data); + } + else + { + $this->logbook_model->edit(); + $this->session->set_flashdata('notice', 'Record Updated'); + $this->load->view('qso/edit_done'); + } + } function qsl_rcvd($id, $method) { $this->load->model('logbook_model'); @@ -138,6 +168,27 @@ class QSO extends CI_Controller { redirect('logbook'); } + + function qsl_rcvd_ajax() { + $id = str_replace('"', "", $this->input->post("id")); + $method = str_replace('"', "", $this->input->post("method")); + + $this->load->model('logbook_model'); + $this->load->model('user_model'); + + header('Content-Type: application/json'); + + if(!$this->user_model->authorize(2)) { + echo json_encode(array('message' => 'Error')); + + } + else { + // Update Logbook to Mark Paper Card Received + $this->logbook_model->paperqsl_update($id, $method); + + echo json_encode(array('message' => 'OK')); + } + } /* Delete QSO */ function delete($id) { @@ -156,6 +207,18 @@ class QSO extends CI_Controller { redirect($_SERVER['HTTP_REFERER']); } } + + /* Delete QSO */ + function delete_ajax() { + $id = str_replace('"', "", $this->input->post("id")); + + $this->load->model('logbook_model'); + + $this->logbook_model->delete($id); + header('Content-Type: application/json'); + echo json_encode(array('message' => 'OK')); + return; + } function band_to_freq($band, $mode) { diff --git a/application/models/Was.php b/application/models/Was.php index 451e342d..b366661e 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -87,14 +87,14 @@ class was extends CI_Model { if ($postdata['worked'] != NULL) { $wasBand = $this->getWasWorked($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = ''; + $bandWas[$line->col_state][$band] = ''; $states[$line->col_state]['count']++; } } if ($postdata['confirmed'] != NULL) { $wasBand = $this->getWasConfirmed($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = ''; + $bandWas[$line->col_state][$band] = ''; $states[$line->col_state]['count']++; } } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 9344c130..22515671 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1437,34 +1437,93 @@ $(document).ready(function(){ From fe0a7577266b179b510ac8818f064a8fde4a5f67 Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 25 Aug 2020 22:03:54 +0200 Subject: [PATCH 3/8] Edit QSO is working with bootstrapdialog and ajax. --- application/controllers/Qso.php | 31 +- application/views/interface_assets/footer.php | 26 +- application/views/qso/edit_ajax.php | 519 ++++++++++++++++++ 3 files changed, 559 insertions(+), 17 deletions(-) create mode 100644 application/views/qso/edit_ajax.php diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 4b50ccc8..27f5370b 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -129,30 +129,31 @@ class QSO extends CI_Controller { $this->load->model('logbook_model'); $this->load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - $id = str_replace('"', "", $this->input->post("id")); - $query = $this->logbook_model->qso_info($id); $this->load->library('form_validation'); - $this->form_validation->set_rules('time_on', 'Start Date', 'required'); - $this->form_validation->set_rules('time_off', 'End Date', 'required'); - $this->form_validation->set_rules('callsign', 'Callsign', 'required'); + if(!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); + } + + $id = str_replace('"', "", $this->input->post("id")); + $query = $this->logbook_model->qso_info($id); $data['qso'] = $query->row(); $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['iota'] = $this->logbook_model->fetchIota(); - if ($this->form_validation->run() == FALSE) - { - $this->load->view('qso/edit', $data); - } - else - { - $this->logbook_model->edit(); - $this->session->set_flashdata('notice', 'Record Updated'); - $this->load->view('qso/edit_done'); + $this->load->view('qso/edit_ajax', $data); + } + + function qso_save_ajax() { + $this->load->model('logbook_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $this->logbook_model->edit(); } function qsl_rcvd($id, $method) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 22515671..a619718c 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1448,6 +1448,7 @@ $(document).ready(function(){ BootstrapDialog.show({ title: 'QSO Data', size: BootstrapDialog.SIZE_WIDE, + cssClass: 'qso-dialog', nl2br: false, message: html, buttons: [{ @@ -1491,7 +1492,7 @@ $(document).ready(function(){ btnOKClass: 'btn-danger', callback: function(result) { if(result) { - //BootstrapDialog.closeAll() + $(".edit-dialog").modal('hide'); var baseURL= ""; $.ajax({ url: baseURL + 'index.php/qso/delete_ajax', @@ -1499,7 +1500,8 @@ $(document).ready(function(){ data: {'id': id }, success: function(data) { - $(".bootstrap-dialog-message").append('
×The contact with ' + call + ' has been deleted!
'); + $(".alert").remove(); + $(".bootstrap-dialog-message").prepend('
×The contact with ' + call + ' has been deleted!
'); $("#qso_" + id).remove(); // removes qso from table in dialog } }); @@ -1518,6 +1520,7 @@ $(document).ready(function(){ success: function(html) { BootstrapDialog.show({ title: 'QSO Data', + cssClass: 'edit-dialog', size: BootstrapDialog.SIZE_WIDE, nl2br: false, message: html, @@ -1525,6 +1528,25 @@ $(document).ready(function(){ } }); } + + function qso_save() { + var baseURL= ""; + var myform = document.getElementById("qsoform"); + var fd = new FormData(myform); + $.ajax({ + url: baseURL + 'index.php/qso/qso_save_ajax', + data: fd, + cache: false, + processData: false, + contentType: false, + type: 'POST', + success: function (dataofconfirm) { + $(".edit-dialog").modal('hide'); + $(".qso-dialog").modal('hide'); + location.reload(); + } + }); + } diff --git a/application/views/qso/edit_ajax.php b/application/views/qso/edit_ajax.php new file mode 100644 index 00000000..dd776d10 --- /dev/null +++ b/application/views/qso/edit_ajax.php @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+ + +
+ +
+ + + + + +
+ + Delete QSO +
+
+
+ +
+
+
+
+ + + + + From 5fc4c65ff9e6fe22625bc46d6091809879d495da Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 25 Aug 2020 22:04:54 +0200 Subject: [PATCH 4/8] Added missing file. --- .../views/view_log/partial/log_ajax.php | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 application/views/view_log/partial/log_ajax.php diff --git a/application/views/view_log/partial/log_ajax.php b/application/views/view_log/partial/log_ajax.php new file mode 100644 index 00000000..cffb7a85 --- /dev/null +++ b/application/views/view_log/partial/log_ajax.php @@ -0,0 +1,172 @@ +
+ + + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + + + + + + config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + session->userdata('user_eqsl_name') != "") { ?> + + + session->userdata('user_lotw_name') != "") { ?> + + + + + + + + result() as $row) { ?> + + COL_PRIMARY_KEY .'">'; ?> + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + + + + COL_SAT_NAME != null) { ?> + + + + + + config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + + session->userdata('user_eqsl_name') != ""){ ?> + + + + session->userdata('user_lotw_name') != "") { ?> + + + + config->item('callsign_tags') == true) { ?> + station_callsign)) { ?> + + + + + + + + + +
DateTimeCallModeSentRecvBandCountryQSLeQSLLoTWStation
COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?>COL_PRIMARY_KEY; ?>" href="javascript:;">COL_CALL)); ?> + COL_MODE; ?>COL_RST_SENT; ?> COL_STX) { ?>COL_STX;?>COL_STX_STRING) { ?>COL_STX_STRING;?>COL_RST_RCVD; ?> COL_SRX) { ?>COL_SRX;?>COL_SRX_STRING) { ?>COL_SRX_STRING;?>COL_SAT_NAME; ?>COL_BAND); ?>COL_COUNTRY; ?> + ">▲ + ">▼ + + + + COL_EQSL_QSL_RCVD =='Y') { ?> + COL_PRIMARY_KEY."/".$row->COL_CALL."/".$row->COL_MODE."/".$row->COL_BAND."/".date('H', $timestamp)."/".date('i', $timestamp)."/".date('d', $timestamp)."/".date('m', $timestamp)."/".date('Y', $timestamp)); ?>" data-fancybox="images" data-width="528" data-height="336">▼ + + ▼ + + + + COL_LOTW_QSL_SENT != ''){ ?> + + + + + station_callsign; ?> + + +
+ + pagination)){ ?> + '; + $config['full_tag_close'] = ''; + $config['attributes'] = ['class' => 'page-link']; + $config['first_link'] = false; + $config['last_link'] = false; + $config['first_tag_open'] = '
  • '; + $config['first_tag_close'] = '
  • '; + $config['prev_link'] = '«'; + $config['prev_tag_open'] = '
  • '; + $config['prev_tag_close'] = '
  • '; + $config['next_link'] = '»'; + $config['next_tag_open'] = '
  • '; + $config['next_tag_close'] = '
  • '; + $config['last_tag_open'] = '
  • '; + $config['last_tag_close'] = '
  • '; + $config['cur_tag_open'] = '
  • '; + $config['cur_tag_close'] = '(current)
  • '; + $config['num_tag_open'] = '
  • '; + $config['num_tag_close'] = '
  • '; + $this->pagination->initialize($config); + ?> + + pagination->create_links(); ?> + + + +
    + From 1a2bcd2e9aa636e3895bda0a7ae1150fab5f79de Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 26 Aug 2020 07:45:52 +0200 Subject: [PATCH 5/8] Added missing CSS and JS for bootstrapdialog. From here: https://github.com/GedMarc/bootstrap4-dialog --- .../css/bootstrap-dialog.min.css | 1 + .../js/bootstrapdialog/js/bootstrap-dialog.js | 1436 +++++++++++++++++ 2 files changed, 1437 insertions(+) create mode 100644 assets/js/bootstrapdialog/css/bootstrap-dialog.min.css create mode 100644 assets/js/bootstrapdialog/js/bootstrap-dialog.js diff --git a/assets/js/bootstrapdialog/css/bootstrap-dialog.min.css b/assets/js/bootstrapdialog/css/bootstrap-dialog.min.css new file mode 100644 index 00000000..ed8e1451 --- /dev/null +++ b/assets/js/bootstrapdialog/css/bootstrap-dialog.min.css @@ -0,0 +1 @@ +.bootstrap-dialog .modal-header{border-top-left-radius:4px;border-top-right-radius:4px}.bootstrap-dialog .bootstrap-dialog-title{color:#fff;display:inline-block;font-size:16px}.bootstrap-dialog .bootstrap-dialog-message{font-size:14px}.bootstrap-dialog .bootstrap-dialog-button-icon{margin-right:3px}.bootstrap-dialog .bootstrap-dialog-close-button{font-size:20px;float:right;opacity:.9;filter:alpha(opacity=90)}.bootstrap-dialog .bootstrap-dialog-close-button:hover{cursor:pointer;opacity:1;filter:alpha(opacity=100)}@media(min-width:1172px){.bootstrap-dialog .modal-xl{max-width:95%}}.bootstrap-dialog .modal-lg .bootstrap4-dialog-button:first-child{margin-top:8px}.bootstrap-dialog.type-default .modal-header{background-color:#fff}.bootstrap-dialog.type-default .bootstrap-dialog-title{color:#333}.bootstrap-dialog.type-info .modal-header{background-color:#17a2b8}.bootstrap-dialog.type-primary .modal-header{background-color:#007bff}.bootstrap-dialog.type-secondary .modal-header{background-color:#6c757d}.bootstrap-dialog.type-success .modal-header{background-color:#28a745}.bootstrap-dialog.type-warning .modal-header{background-color:#ffc107}.bootstrap-dialog.type-danger .modal-header{background-color:#dc3545}.bootstrap-dialog.type-light .modal-header{background-color:#f8f9fa}.bootstrap-dialog.type-dark .modal-header{background-color:#343a40}.bootstrap-dialog.size-large .bootstrap-dialog-title{font-size:24px}.bootstrap-dialog.size-large .bootstrap-dialog-close-button{font-size:30px}.bootstrap-dialog.size-large .bootstrap-dialog-message{font-size:18px}.bootstrap-dialog .icon-spin{display:inline-block;-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.bootstrap-dialog-footer-buttons{display:flex}@-moz-keyframes spin{0{-moz-transform:rotate(0)}100%{-moz-transform:rotate(359deg)}}@-webkit-keyframes spin{0{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0{-o-transform:rotate(0)}100%{-o-transform:rotate(359deg)}}@-ms-keyframes spin{0{-ms-transform:rotate(0)}100%{-ms-transform:rotate(359deg)}}@keyframes spin{0{transform:rotate(0)}100%{transform:rotate(359deg)}}.bootstrap-dialog-header{display:contents} \ No newline at end of file diff --git a/assets/js/bootstrapdialog/js/bootstrap-dialog.js b/assets/js/bootstrapdialog/js/bootstrap-dialog.js new file mode 100644 index 00000000..e7de661a --- /dev/null +++ b/assets/js/bootstrapdialog/js/bootstrap-dialog.js @@ -0,0 +1,1436 @@ +/* global define */ + +/* ================================================ + * Make use of Bootstrap's modal more monkey-friendly. + * + * For Bootstrap 3. + * + * javanoob@hotmail.com + * + * https://github.com/nakupanda/bootstrap3-dialog + * + * Licensed under The MIT License. + * ================================================ */ +(function (root, factory) { + + "use strict"; + + // CommonJS module is defined + if (typeof module !== 'undefined' && module.exports) { + module.exports = factory(require('jquery'), require('bootstrap')); + } + // AMD module is defined + else if (typeof define === "function" && define.amd) { + define("bootstrap-dialog", ["jquery", "bootstrap"], function ($) { + return factory($); + }); + } else { + // planted over the root! + root.BootstrapDialog = factory(root.jQuery); + } + +}(this ? this : window, function ($) { + + "use strict"; + + /* ================================================ + * Definition of BootstrapDialogModal. + * Extend Bootstrap Modal and override some functions. + * BootstrapDialogModal === Modified Modal. + * ================================================ */ + var Modal = $.fn.modal.Constructor; + var BootstrapDialogModal = function (element, options) { + if (/4\.1\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4 + return new Modal(element, options); + } else { + Modal.call(this, element, options); + } + }; + BootstrapDialogModal.getModalVersion = function () { + var version = null; + if (typeof $.fn.modal.Constructor.VERSION === 'undefined') { + version = 'v3.1'; + } else if (/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)) { + version = 'v3.2'; + } else if (/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)) { + version = 'v3.3'; // v3.3.1, v3.3.2 + } else if (/4\.\d\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4 + version = 'v4.1'; + } else { + version = 'v3.3.4'; + } + + return version; + }; + BootstrapDialogModal.ORIGINAL_BODY_PADDING = parseInt(($('body').css('padding-right') || 0), 10); + BootstrapDialogModal.METHODS_TO_OVERRIDE = {}; + BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.1'] = {}; + BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.2'] = { + hide: function (e) { + if (e) { + e.preventDefault(); + } + e = $.Event('hide.bs.modal'); + + this.$element.trigger(e); + + if (!this.isShown || e.isDefaultPrevented()) { + return; + } + + this.isShown = false; + + // Remove css class 'modal-open' when the last opened dialog is closing. + var openedDialogs = this.getGlobalOpenedDialogs(); + if (openedDialogs.length === 0) { + this.$body.removeClass('modal-open'); + } + + this.resetScrollbar(); + this.escape(); + + $(document).off('focusin.bs.modal'); + + this.$element + .removeClass('in') + .attr('aria-hidden', true) + .off('click.dismiss.bs.modal'); + + $.support.transition && this.$element.hasClass('fade') ? + this.$element + .one('bsTransitionEnd', $.proxy(this.hideModal, this)) + .emulateTransitionEnd(300) : + this.hideModal(); + } + }; + BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3'] = { + /** + * Overrided. + * + * @returns {undefined} + */ + setScrollbar: function () { + var bodyPad = BootstrapDialogModal.ORIGINAL_BODY_PADDING; + if (this.bodyIsOverflowing) { + this.$body.css('padding-right', bodyPad + this.scrollbarWidth); + } + }, + /** + * Overrided. + * + * @returns {undefined} + */ + resetScrollbar: function () { + var openedDialogs = this.getGlobalOpenedDialogs(); + if (openedDialogs.length === 0) { + this.$body.css('padding-right', BootstrapDialogModal.ORIGINAL_BODY_PADDING); + } + }, + /** + * Overrided. + * + * @returns {undefined} + */ + hideModal: function () { + this.$element.hide(); + this.backdrop($.proxy(function () { + var openedDialogs = this.getGlobalOpenedDialogs(); + if (openedDialogs.length === 0) { + this.$body.removeClass('modal-open'); + } + this.resetAdjustments(); + this.resetScrollbar(); + this.$element.trigger('hidden.bs.modal'); + }, this)); + } + }; + BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); + BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.1'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); //FIXME for BootstrapV4 + BootstrapDialogModal.prototype = { + constructor: BootstrapDialogModal, + /** + * New function, to get the dialogs that opened by BootstrapDialog. + * + * @returns {undefined} + */ + getGlobalOpenedDialogs: function () { + var openedDialogs = []; + $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { + if (dialogInstance.isRealized() && dialogInstance.isOpened()) { + openedDialogs.push(dialogInstance); + } + }); + + return openedDialogs; + } + }; + + // Add compatible methods. + BootstrapDialogModal.prototype = $.extend(BootstrapDialogModal.prototype, Modal.prototype, BootstrapDialogModal.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); + + /* ================================================ + * Definition of BootstrapDialog. + * ================================================ */ + var BootstrapDialog = function (options) { + this.defaultOptions = $.extend(true, { + id: BootstrapDialog.newGuid(), + buttons: [], + data: {}, + onshow: null, + onshown: null, + onhide: null, + onhidden: null + }, BootstrapDialog.defaultOptions); + this.indexedButtons = {}; + this.registeredButtonHotkeys = {}; + this.draggableData = { + isMouseDown: false, + mouseOffset: {} + }; + this.realized = false; + this.opened = false; + this.initOptions(options); + this.holdThisInstance(); + }; + + BootstrapDialog.BootstrapDialogModal = BootstrapDialogModal; + + /** + * Some constants. + */ + BootstrapDialog.NAMESPACE = 'bootstrap-dialog'; + BootstrapDialog.TYPE_DEFAULT = 'type-default'; + BootstrapDialog.TYPE_INFO = 'type-info'; + BootstrapDialog.TYPE_PRIMARY = 'type-primary'; + BootstrapDialog.TYPE_SECONDARY = 'type-secondary'; + BootstrapDialog.TYPE_SUCCESS = 'type-success'; + BootstrapDialog.TYPE_WARNING = 'type-warning'; + BootstrapDialog.TYPE_DANGER = 'type-danger'; + BootstrapDialog.TYPE_DARK = 'type-dark'; + BootstrapDialog.TYPE_LIGHT = 'type-light'; + BootstrapDialog.DEFAULT_TEXTS = {}; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Default'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = 'Information'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = 'Primary'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SECONDARY] = 'Secondary'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS] = 'Success'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING] = 'Warning'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER] = 'Danger'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DARK] = 'Dark'; + BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_LIGHT] = 'Light'; + BootstrapDialog.DEFAULT_TEXTS['OK'] = 'OK'; + BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = 'Cancel'; + BootstrapDialog.DEFAULT_TEXTS['CONFIRM'] = 'Confirmation'; + BootstrapDialog.SIZE_NORMAL = 'size-normal'; + BootstrapDialog.SIZE_SMALL = 'size-small'; + BootstrapDialog.SIZE_WIDE = 'size-wide'; // size-wide is equal to modal-lg + BootstrapDialog.SIZE_EXTRAWIDE = 'size-extrawide'; // size-wide is equal to modal-lg + BootstrapDialog.SIZE_LARGE = 'size-large'; + BootstrapDialog.BUTTON_SIZES = {}; + BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = ''; + BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_SMALL] = 'btn-small'; + BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_WIDE] = 'btn-block'; + BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg'; + BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk'; + BootstrapDialog.BUTTONS_ORDER_CANCEL_OK = 'btns-order-cancel-ok'; + BootstrapDialog.BUTTONS_ORDER_OK_CANCEL = 'btns-order-ok-cancel'; + BootstrapDialog.Z_INDEX_BACKDROP = 1040; + BootstrapDialog.Z_INDEX_MODAL = 1050; + + /** + * Default options. + */ + BootstrapDialog.defaultOptions = { + type: BootstrapDialog.TYPE_PRIMARY, + size: BootstrapDialog.SIZE_NORMAL, + cssClass: '', + title: null, + message: null, + nl2br: true, + closable: true, + closeByBackdrop: true, + closeByKeyboard: true, + closeIcon: '×', + spinicon: BootstrapDialog.ICON_SPINNER, + autodestroy: true, + draggable: false, + animate: true, + description: '', + tabindex: -1, + btnsOrder: BootstrapDialog.BUTTONS_ORDER_CANCEL_OK + }; + + /** + * Config default options. + */ + BootstrapDialog.configDefaultOptions = function (options) { + BootstrapDialog.defaultOptions = $.extend(true, BootstrapDialog.defaultOptions, options); + }; + + /** + * Open / Close all created dialogs all at once. + */ + BootstrapDialog.dialogs = {}; + BootstrapDialog.openAll = function () { + $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { + dialogInstance.open(); + }); + }; + BootstrapDialog.closeAll = function () { + $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { + dialogInstance.close(); + }); + }; + + /** + * Get dialog instance by given id. + * + * @returns dialog instance + */ + BootstrapDialog.getDialog = function (id) { + var dialog = null; + if (typeof BootstrapDialog.dialogs[id] !== 'undefined') { + dialog = BootstrapDialog.dialogs[id]; + } + + return dialog; + }; + + /** + * Set a dialog. + * + * @returns the dialog that has just been set. + */ + BootstrapDialog.setDialog = function (dialog) { + BootstrapDialog.dialogs[dialog.getId()] = dialog; + + return dialog; + }; + + /** + * Alias of BootstrapDialog.setDialog(dialog) + * + * @param {type} dialog + * @returns {unresolved} + */ + BootstrapDialog.addDialog = function (dialog) { + return BootstrapDialog.setDialog(dialog); + }; + + /** + * Move focus to next visible dialog. + */ + BootstrapDialog.moveFocus = function () { + var lastDialogInstance = null; + $.each(BootstrapDialog.dialogs, function (id, dialogInstance) { + if (dialogInstance.isRealized() && dialogInstance.isOpened()) { + lastDialogInstance = dialogInstance; + } + }); + if (lastDialogInstance !== null) { + lastDialogInstance.getModal().focus(); + } + }; + + BootstrapDialog.METHODS_TO_OVERRIDE = {}; + BootstrapDialog.METHODS_TO_OVERRIDE['v3.1'] = { + /** + * To make multiple opened dialogs look better. + * + * Will be removed in later version, after Bootstrap Modal >= 3.3.0, updating z-index is unnecessary. + */ + updateZIndex: function () { + if (this.isOpened()) { + var zIndexBackdrop = BootstrapDialog.Z_INDEX_BACKDROP; + var zIndexModal = BootstrapDialog.Z_INDEX_MODAL; + var dialogCount = 0; + $.each(BootstrapDialog.dialogs, function (dialogId, dialogInstance) { + if (dialogInstance.isRealized() && dialogInstance.isOpened()) { + dialogCount++; + } + }); + var $modal = this.getModal(); + var $backdrop = this.getModalBackdrop($modal); //FIXME for BootstrapV4 + $modal.css('z-index', zIndexModal + (dialogCount - 1) * 20); + $backdrop.css('z-index', zIndexBackdrop + (dialogCount - 1) * 20); + } + + return this; + }, + open: function () { + !this.isRealized() && this.realize(); + this.getModal().modal('show'); + this.updateZIndex(); + + return this; + } + }; + BootstrapDialog.METHODS_TO_OVERRIDE['v3.2'] = { + updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], + open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'] + }; + BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {}; + BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']); + BootstrapDialog.METHODS_TO_OVERRIDE['v4.0'] = { //FIXME for BootstrapV4 + getModalBackdrop: function ($modal) { + return $($modal.data('bs.modal')._backdrop); + }, + updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], + open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'], + getModalForBootstrapDialogModal: function () { + return this.getModal().get(0); + } + }; + BootstrapDialog.METHODS_TO_OVERRIDE['v4.1'] = { //FIXME for BootstrapV4 + getModalBackdrop: function ($modal) { + return $($modal.data('bs.modal')._backdrop); + }, + updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], + open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'], + getModalForBootstrapDialogModal: function () { + return this.getModal().get(0); + } + }; + BootstrapDialog.prototype = { + constructor: BootstrapDialog, + initOptions: function (options) { + this.options = $.extend(true, this.defaultOptions, options); + + return this; + }, + holdThisInstance: function () { + BootstrapDialog.addDialog(this); + + return this; + }, + initModalStuff: function () { + + + this.setModal(this.createModal()) + .setModalDialog(this.createModalDialog()) + .setModalContent(this.createModalContent()) + .setModalHeader(this.createModalHeader()) + .setModalBody(this.createModalBody()) + .setModalFooter(this.createModalFooter()); + + this.getModal().append(this.getModalDialog()); + this.getModalDialog().append(this.getModalContent()); + this.getModalContent() + .append(this.getModalHeader()) + .append(this.getModalBody()) + .append(this.getModalFooter()); + + + + return this; + }, + createModal: function () { + var $modal = $(''); + $modal.prop('id', this.getId()); + $modal.attr('aria-labelledby', this.getId() + '_title'); + + return $modal; + }, + getModal: function () { + return this.$modal; + }, + setModal: function ($modal) { + this.$modal = $modal; + + return this; + }, + getModalBackdrop: function ($modal) { //FIXME for BootstrapV4 + return $modal.data('bs.modal').$backdrop; + }, + getModalForBootstrapDialogModal: function () { //FIXME for BootstrapV4 + return this.getModal(); + }, + createModalDialog: function () { + return $(''); + }, + getModalDialog: function () { + return this.$modalDialog; + }, + setModalDialog: function ($modalDialog) { + this.$modalDialog = $modalDialog; + + return this; + }, + createModalContent: function () { + return $(''); + }, + getModalContent: function () { + return this.$modalContent; + }, + setModalContent: function ($modalContent) { + this.$modalContent = $modalContent; + + return this; + }, + createModalHeader: function () { + return $(''); + }, + getModalHeader: function () { + return this.$modalHeader; + }, + setModalHeader: function ($modalHeader) { + this.$modalHeader = $modalHeader; + + return this; + }, + createModalBody: function () { + return $(''); + }, + getModalBody: function () { + return this.$modalBody; + }, + setModalBody: function ($modalBody) { + this.$modalBody = $modalBody; + + return this; + }, + createModalFooter: function () { + return $(''); + }, + getModalFooter: function () { + return this.$modalFooter; + }, + setModalFooter: function ($modalFooter) { + this.$modalFooter = $modalFooter; + + return this; + }, + createDynamicContent: function (rawContent) { + var content = null; + if (typeof rawContent === 'function') { + content = rawContent.call(rawContent, this); + } else { + content = rawContent; + } + if (typeof content === 'string') { + content = this.formatStringContent(content); + } + + return content; + }, + formatStringContent: function (content) { + if (this.options.nl2br) { + return content.replace(/\r\n/g, '
    ').replace(/[\r\n]/g, '
    '); + } + + return content; + }, + setData: function (key, value) { + this.options.data[key] = value; + + return this; + }, + getData: function (key) { + return this.options.data[key]; + }, + setId: function (id) { + this.options.id = id; + + return this; + }, + getId: function () { + return this.options.id; + }, + getType: function () { + return this.options.type; + }, + setType: function (type) { + this.options.type = type; + this.updateType(); + + return this; + }, + updateType: function () { + if (this.isRealized()) { + var types = [BootstrapDialog.TYPE_DEFAULT, + BootstrapDialog.TYPE_INFO, + BootstrapDialog.TYPE_PRIMARY, + BootstrapDialog.TYPE_SECONDARY, + BootstrapDialog.TYPE_SUCCESS, + BootstrapDialog.TYPE_WARNING, + BootstrapDialog.TYPE_DARK, + BootstrapDialog.TYPE_LIGHT, + BootstrapDialog.TYPE_DANGER]; + + this.getModal().removeClass(types.join(' ')).addClass(this.getType()); + } + + return this; + }, + getSize: function () { + return this.options.size; + }, + setSize: function (size) { + this.options.size = size; + this.updateSize(); + + return this; + }, + updateSize: function () { + if (this.isRealized()) { + var dialog = this; + + // Dialog size + this.getModal().removeClass(BootstrapDialog.SIZE_NORMAL) + .removeClass(BootstrapDialog.SIZE_SMALL) + .removeClass(BootstrapDialog.SIZE_WIDE) + .removeClass(BootstrapDialog.SIZE_EXTRAWIDE) + .removeClass(BootstrapDialog.SIZE_LARGE); + this.getModal().addClass(this.getSize()); + + // Smaller dialog. + this.getModalDialog().removeClass('modal-sm'); + if (this.getSize() === BootstrapDialog.SIZE_SMALL) { + this.getModalDialog().addClass('modal-sm'); + } + + // Wider dialog. + this.getModalDialog().removeClass('modal-lg'); + if (this.getSize() === BootstrapDialog.SIZE_WIDE) { + this.getModalDialog().addClass('modal-lg'); + } + // Extra Wide Dialog. + this.getModalDialog().removeClass('modal-xl'); + if (this.getSize() === BootstrapDialog.SIZE_EXTRAWIDE) { + this.getModalDialog().addClass('modal-xl'); + } + + // Button size + $.each(this.options.buttons, function (index, button) { + var $button = dialog.getButton(button.id); + var buttonSizes = ['btn-lg', 'btn-sm', 'btn-xs']; + var sizeClassSpecified = false; + if (typeof button['cssClass'] === 'string') { + var btnClasses = button['cssClass'].split(' '); + $.each(btnClasses, function (index, btnClass) { + if ($.inArray(btnClass, buttonSizes) !== -1) { + sizeClassSpecified = true; + } + }); + } + if (!sizeClassSpecified) { + $button.removeClass(buttonSizes.join(' ')); + $button.addClass(dialog.getButtonSize()); + } + }); + } + + return this; + }, + getCssClass: function () { + return this.options.cssClass; + }, + setCssClass: function (cssClass) { + this.options.cssClass = cssClass; + + return this; + }, + getTitle: function () { + return this.options.title; + }, + setTitle: function (title) { + this.options.title = title; + this.updateTitle(); + + return this; + }, + updateTitle: function () { + if (this.isRealized()) { + var title = this.getTitle() !== null ? this.createDynamicContent(this.getTitle()) : this.getDefaultText(); + this.getModalHeader().find('.' + this.getNamespace('title')).html('').append(title).prop('id', this.getId() + '_title'); + } + + return this; + }, + getMessage: function () { + return this.options.message; + }, + setMessage: function (message) { + this.options.message = message; + this.updateMessage(); + + return this; + }, + updateMessage: function () { + if (this.isRealized()) { + var message = this.createDynamicContent(this.getMessage()); + this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message); + } + + return this; + }, + isClosable: function () { + return this.options.closable; + }, + setClosable: function (closable) { + this.options.closable = closable; + this.updateClosable(); + + return this; + }, + setCloseByBackdrop: function (closeByBackdrop) { + this.options.closeByBackdrop = closeByBackdrop; + + return this; + }, + canCloseByBackdrop: function () { + return this.options.closeByBackdrop; + }, + setCloseByKeyboard: function (closeByKeyboard) { + this.options.closeByKeyboard = closeByKeyboard; + + return this; + }, + canCloseByKeyboard: function () { + return this.options.closeByKeyboard; + }, + isAnimate: function () { + return this.options.animate; + }, + setAnimate: function (animate) { + this.options.animate = animate; + + return this; + }, + updateAnimate: function () { + if (this.isRealized()) { + this.getModal().toggleClass('fade', this.isAnimate()); + } + + return this; + }, + getSpinicon: function () { + return this.options.spinicon; + }, + setSpinicon: function (spinicon) { + this.options.spinicon = spinicon; + + return this; + }, + addButton: function (button) { + this.options.buttons.push(button); + + return this; + }, + addButtons: function (buttons) { + var that = this; + $.each(buttons, function (index, button) { + that.addButton(button); + }); + + return this; + }, + getButtons: function () { + return this.options.buttons; + }, + setButtons: function (buttons) { + this.options.buttons = buttons; + this.updateButtons(); + + return this; + }, + /** + * If there is id provided for a button option, it will be in dialog.indexedButtons list. + * + * In that case you can use dialog.getButton(id) to find the button. + * + * @param {type} id + * @returns {undefined} + */ + getButton: function (id) { + if (typeof this.indexedButtons[id] !== 'undefined') { + return this.indexedButtons[id]; + } + + return null; + }, + getButtonSize: function () { + if (typeof BootstrapDialog.BUTTON_SIZES[this.getSize()] !== 'undefined') { + return BootstrapDialog.BUTTON_SIZES[this.getSize()]; + } + + return ''; + }, + updateButtons: function () { + if (this.isRealized()) { + if (this.getButtons().length === 0) { + this.getModalFooter().hide(); + } else { + this.getModalFooter().show().closest('.modal-footer').append(this.createFooterButtons()); + } + } + + return this; + }, + isAutodestroy: function () { + return this.options.autodestroy; + }, + setAutodestroy: function (autodestroy) { + this.options.autodestroy = autodestroy; + }, + getDescription: function () { + return this.options.description; + }, + setDescription: function (description) { + this.options.description = description; + + return this; + }, + setTabindex: function (tabindex) { + this.options.tabindex = tabindex; + + return this; + }, + getTabindex: function () { + return this.options.tabindex; + }, + updateTabindex: function () { + if (this.isRealized()) { + this.getModal().attr('tabindex', this.getTabindex()); + } + + return this; + }, + getDefaultText: function () { + return BootstrapDialog.DEFAULT_TEXTS[this.getType()]; + }, + getNamespace: function (name) { + return BootstrapDialog.NAMESPACE + '-' + name; + }, + createHeaderContent: function () { + var $container = $('
    '); + $container.addClass(this.getNamespace('header')); + + // title + $container.append(this.createTitleContent()); + + // Close button + $container.append(this.createCloseButton()); + + return $container; + }, + createTitleContent: function () { + var $title = $('
    '); + $title.addClass(this.getNamespace('title')); + + return $title; + }, + createCloseButton: function () { + var $container = $('
    '); + $container.addClass(this.getNamespace('close-button')); + var $icon = $(''); + $icon.append(this.options.closeIcon); + $container.append($icon); + $container.on('click', { dialog: this }, function (event) { + event.data.dialog.close(); + }); + + return $container; + }, + createBodyContent: function () { + var $container = $('
    '); + $container.addClass(this.getNamespace('body')); + + // Message + $container.append(this.createMessageContent()); + + return $container; + }, + createMessageContent: function () { + var $message = $('
    '); + $message.addClass(this.getNamespace('message')); + + return $message; + }, + createFooterContent: function () { + var $container = $('
    '); + $container.addClass(this.getNamespace('footer')); + + return $container; + }, + createFooterButtons: function () { + var that = this; + + var $container = that.$modalFooter;// $('
    '); + //$container.addClass(this.getNamespace('footer-buttons')); + + + this.indexedButtons = {}; + $.each(this.options.buttons, function (index, button) { + if (!button.id) { + button.id = BootstrapDialog.newGuid(); + } + var $button = that.createButton(button); + that.indexedButtons[button.id] = $button; + $container.append($button); + }); + + return $container; + }, + createButton: function (button) { + var $button = $(''); + $button.prop('id', button.id); + $button.data('button', button); + + // Icon + if (typeof button.icon !== 'undefined' && $.trim(button.icon) !== '') { + $button.append(this.createButtonIcon(button.icon)); + } + + // Label + if (typeof button.label !== 'undefined') { + $button.append(button.label); + } + + // title + if (typeof button.title !== 'undefined') { + $button.attr('title', button.title); + } + + // Css class + if (typeof button.cssClass !== 'undefined' && $.trim(button.cssClass) !== '') { + $button.addClass(button.cssClass); + } else { + $button.addClass('btn-secondary'); + } + + // Data attributes + if (typeof button.data === 'object' && button.data.constructor === {}.constructor) { + $.each(button.data, function (key, value) { + $button.attr('data-' + key, value); + }); + } + + // Hotkey + if (typeof button.hotkey !== 'undefined') { + this.registeredButtonHotkeys[button.hotkey] = $button; + } + + // Button on click + $button.on('click', { dialog: this, $button: $button, button: button }, function (event) { + var dialog = event.data.dialog; + var $button = event.data.$button; + var button = $button.data('button'); + if (button.autospin) { + $button.toggleSpin(true); + } + if (typeof button.action === 'function') { + return button.action.call($button, dialog, event); + } + }); + + // Dynamically add extra functions to $button + this.enhanceButton($button); + + //Initialize enabled or not + if (typeof button.enabled !== 'undefined') { + $button.toggleEnable(button.enabled); + } + + $button.addClass("bootstrap4-dialog-button"); + + return $button; + }, + /** + * Dynamically add extra functions to $button + * + * Using '$this' to reference 'this' is just for better readability. + * + * @param {type} $button + * @returns {_L13.BootstrapDialog.prototype} + */ + enhanceButton: function ($button) { + $button.dialog = this; + + // Enable / Disable + $button.toggleEnable = function (enable) { + var $this = this; + if (typeof enable !== 'undefined') { + $this.prop("disabled", !enable).toggleClass('disabled', !enable); + } else { + $this.prop("disabled", !$this.prop("disabled")); + } + + return $this; + }; + $button.enable = function () { + var $this = this; + $this.toggleEnable(true); + + return $this; + }; + $button.disable = function () { + var $this = this; + $this.toggleEnable(false); + + return $this; + }; + + // Icon spinning, helpful for indicating ajax loading status. + $button.toggleSpin = function (spin) { + var $this = this; + var dialog = $this.dialog; + var $icon = $this.find('.' + dialog.getNamespace('button-icon')); + if (typeof spin === 'undefined') { + spin = !($button.find('.icon-spin').length > 0); + } + if (spin) { + $icon.hide(); + $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin')); + } else { + $icon.show(); + $button.find('.icon-spin').remove(); + } + + return $this; + }; + $button.spin = function () { + var $this = this; + $this.toggleSpin(true); + + return $this; + }; + $button.stopSpin = function () { + var $this = this; + $this.toggleSpin(false); + + return $this; + }; + + return this; + }, + createButtonIcon: function (icon) { + var $icon = $(''); + $icon.addClass(this.getNamespace('button-icon')).addClass(icon); + + return $icon; + }, + /** + * Invoke this only after the dialog is realized. + * + * @param {type} enable + * @returns {undefined} + */ + enableButtons: function (enable) { + $.each(this.indexedButtons, function (id, $button) { + $button.toggleEnable(enable); + }); + + return this; + }, + /** + * Invoke this only after the dialog is realized. + * + * @returns {undefined} + */ + updateClosable: function () { + if (this.isRealized()) { + // Close button + this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable()); + } + + return this; + }, + /** + * Set handler for modal event 'show.bs.modal'. + * This is a setter! + */ + onShow: function (onshow) { + this.options.onshow = onshow; + + return this; + }, + /** + * Set handler for modal event 'shown.bs.modal'. + * This is a setter! + */ + onShown: function (onshown) { + this.options.onshown = onshown; + + return this; + }, + /** + * Set handler for modal event 'hide.bs.modal'. + * This is a setter! + */ + onHide: function (onhide) { + this.options.onhide = onhide; + + return this; + }, + /** + * Set handler for modal event 'hidden.bs.modal'. + * This is a setter! + */ + onHidden: function (onhidden) { + this.options.onhidden = onhidden; + + return this; + }, + isRealized: function () { + return this.realized; + }, + setRealized: function (realized) { + this.realized = realized; + + return this; + }, + isOpened: function () { + return this.opened; + }, + setOpened: function (opened) { + this.opened = opened; + + return this; + }, + handleModalEvents: function () { + this.getModal().on('show.bs.modal', { dialog: this }, function (event) { + var dialog = event.data.dialog; + dialog.setOpened(true); + if (dialog.isModalEvent(event) && typeof dialog.options.onshow === 'function') { + var openIt = dialog.options.onshow(dialog); + if (openIt === false) { + dialog.setOpened(false); + } + + return openIt; + } + }); + this.getModal().on('shown.bs.modal', { dialog: this }, function (event) { + var dialog = event.data.dialog; + dialog.isModalEvent(event) && typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog); + }); + this.getModal().on('hide.bs.modal', { dialog: this }, function (event) { + var dialog = event.data.dialog; + dialog.setOpened(false); + if (dialog.isModalEvent(event) && typeof dialog.options.onhide === 'function') { + var hideIt = dialog.options.onhide(dialog); + if (hideIt === false) { + dialog.setOpened(true); + } + + return hideIt; + } + }); + this.getModal().on('hidden.bs.modal', { dialog: this }, function (event) { + var dialog = event.data.dialog; + dialog.isModalEvent(event) && typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog); + if (dialog.isAutodestroy()) { + dialog.setRealized(false); + delete BootstrapDialog.dialogs[dialog.getId()]; + $(this).remove(); + } + BootstrapDialog.moveFocus(); + if ($('.modal').hasClass('in')) { + $('body').addClass('modal-open'); + } + }); + + // ESC key support + this.getModal().on('keyup', { dialog: this }, function (event) { + event.which === 27 && event.data.dialog.isClosable() && event.data.dialog.canCloseByKeyboard() && event.data.dialog.close(); + }); + + // Button hotkey + this.getModal().on('keyup', { dialog: this }, function (event) { + var dialog = event.data.dialog; + if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') { + var $button = $(dialog.registeredButtonHotkeys[event.which]); + !$button.prop('disabled') && !$button.is(':focus') && $button.focus().trigger('click'); + } + }); + + return this; + }, + isModalEvent: function (event) { + return typeof event.namespace !== 'undefined' && event.namespace === 'bs.modal'; + }, + makeModalDraggable: function () { + if (this.options.draggable) { + this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', { dialog: this }, function (event) { + var dialog = event.data.dialog; + dialog.draggableData.isMouseDown = true; + var dialogOffset = dialog.getModalDialog().offset(); + dialog.draggableData.mouseOffset = { + top: event.clientY - dialogOffset.top, + left: event.clientX - dialogOffset.left + }; + }); + this.getModal().on('mouseup mouseleave', { dialog: this }, function (event) { + event.data.dialog.draggableData.isMouseDown = false; + }); + $('body').on('mousemove', { dialog: this }, function (event) { + var dialog = event.data.dialog; + if (!dialog.draggableData.isMouseDown) { + return; + } + dialog.getModalDialog().offset({ + top: event.clientY - dialog.draggableData.mouseOffset.top, + left: event.clientX - dialog.draggableData.mouseOffset.left + }); + }); + } + + return this; + }, + realize: function () { + this.initModalStuff(); + this.getModal().addClass(BootstrapDialog.NAMESPACE) + .addClass(this.getCssClass()); + this.updateSize(); + if (this.getDescription()) { + this.getModal().attr('aria-describedby', this.getDescription()); + } + //this.getModalFooter().append(this.createFooterContent()); + this.getModalHeader().append(this.createHeaderContent()); + this.getModalBody().append(this.createBodyContent()); + this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModalForBootstrapDialogModal(), { //FIXME for BootstrapV4 + backdrop: (this.isClosable() && this.canCloseByBackdrop()) ? true : 'static', + keyboard: false, + show: false + })); + this.makeModalDraggable(); + this.handleModalEvents(); + this.setRealized(true); + this.updateButtons(); + this.updateType(); + this.updateTitle(); + this.updateMessage(); + this.updateClosable(); + this.updateAnimate(); + this.updateSize(); + this.updateTabindex(); + + return this; + }, + open: function () { + !this.isRealized() && this.realize(); + this.getModal().modal('show'); + + return this; + }, + close: function () { + !this.isRealized() && this.realize(); + this.getModal().modal('hide'); + + return this; + } + }; + + // Add compatible methods. + BootstrapDialog.prototype = $.extend(BootstrapDialog.prototype, BootstrapDialog.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); + + /** + * RFC4122 version 4 compliant unique id creator. + * + * Added by https://github.com/tufanbarisyildirim/ + * + * @returns {String} + */ + BootstrapDialog.newGuid = function () { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + }; + + /* ================================================ + * For lazy people + * ================================================ */ + + /** + * Shortcut function: show + * + * @param {type} options + * @returns the created dialog instance + */ + BootstrapDialog.show = function (options) { + return new BootstrapDialog(options).open(); + }; + + /** + * Alert window + * + * @returns the created dialog instance + */ + BootstrapDialog.alert = function () { + var alertOptions = {}; + var defaultAlertOptions = { + type: BootstrapDialog.TYPE_PRIMARY, + title: null, + message: null, + closable: false, + draggable: false, + buttonLabel: BootstrapDialog.DEFAULT_TEXTS.OK, + buttonHotkey: null, + callback: null + }; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { + alertOptions = $.extend(true, defaultAlertOptions, arguments[0]); + } else { + alertOptions = $.extend(true, defaultAlertOptions, { + message: arguments[0], + callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null + }); + } + + var dialog = new BootstrapDialog(alertOptions); + dialog.setData('callback', alertOptions.callback); + dialog.addButton({ + label: alertOptions.buttonLabel, + hotkey: alertOptions.buttonHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { + return false; + } + dialog.setData('btnClicked', true); + + return dialog.close(); + } + }); + if (typeof dialog.options.onhide === 'function') { + dialog.onHide(function (dialog) { + var hideIt = true; + if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { + hideIt = dialog.getData('callback')(false); + } + if (hideIt === false) { + return false; + } + hideIt = this.onhide(dialog); + + return hideIt; + }.bind({ + onhide: dialog.options.onhide + })); + } else { + dialog.onHide(function (dialog) { + var hideIt = true; + if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { + hideIt = dialog.getData('callback')(false); + } + + return hideIt; + }); + } + + return dialog.open(); + }; + + /** + * Confirm window + * + * @returns the created dialog instance + */ + BootstrapDialog.confirm = function () { + var confirmOptions = {}; + var defaultConfirmOptions = { + type: BootstrapDialog.TYPE_PRIMARY, + title: null, + message: null, + closable: false, + draggable: false, + btnCancelLabel: BootstrapDialog.DEFAULT_TEXTS.CANCEL, + btnCancelClass: null, + btnCancelHotkey: null, + btnOKLabel: BootstrapDialog.DEFAULT_TEXTS.OK, + btnOKClass: null, + btnOKHotkey: null, + btnsOrder: BootstrapDialog.defaultOptions.btnsOrder, + callback: null + }; + if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { + confirmOptions = $.extend(true, defaultConfirmOptions, arguments[0]); + } else { + confirmOptions = $.extend(true, defaultConfirmOptions, { + message: arguments[0], + callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null + }); + } + if (confirmOptions.btnOKClass === null) { + confirmOptions.btnOKClass = ['btn', confirmOptions.type.split('-')[1]].join('-'); + } + + var dialog = new BootstrapDialog(confirmOptions); + dialog.setData('callback', confirmOptions.callback); + + var buttons = [{ + label: confirmOptions.btnCancelLabel, + cssClass: confirmOptions.btnCancelClass, + hotkey: confirmOptions.btnCancelHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, false) === false) { + return false; + } + + return dialog.close(); + } + }, { + label: confirmOptions.btnOKLabel, + cssClass: confirmOptions.btnOKClass, + hotkey: confirmOptions.btnOKHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { + return false; + } + + return dialog.close(); + } + }]; + if (confirmOptions.btnsOrder === BootstrapDialog.BUTTONS_ORDER_OK_CANCEL) { + buttons.reverse(); + } + dialog.addButtons(buttons); + + return dialog.open(); + + }; + + /** + * Warning window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.warning = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_WARNING, + message: message + }).open(); + }; + + /** + * Danger window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.danger = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_DANGER, + message: message + }).open(); + }; + + /** + * Success window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.success = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_SUCCESS, + message: message + }).open(); + }; + + return BootstrapDialog; + +})); From a6e32226cc0d878773416653ace20685b05c556a Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 13 Sep 2020 08:16:36 +0200 Subject: [PATCH 6/8] File for loading details about WAS QSO in JS was missing. --- application/views/awards/was/details_ajax.php | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 application/views/awards/was/details_ajax.php diff --git a/application/views/awards/was/details_ajax.php b/application/views/awards/was/details_ajax.php new file mode 100644 index 00000000..59ba1c0e --- /dev/null +++ b/application/views/awards/was/details_ajax.php @@ -0,0 +1,3 @@ +
    Filtering on
    + + load->view('view_log/partial/log_ajax') ?> From 9e97266b793d4a4c6461da56b1482bfd8db9db8b Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 13 Sep 2020 11:51:11 +0100 Subject: [PATCH 7/8] Fixed missing js libraries --- .../bootstrapdialog/css/bootstrap-dialog.css | 161 ++++++++++++++++++ .../js/bootstrap-dialog.min.js | 1 + 2 files changed, 162 insertions(+) create mode 100644 assets/js/bootstrapdialog/css/bootstrap-dialog.css create mode 100644 assets/js/bootstrapdialog/js/bootstrap-dialog.min.js diff --git a/assets/js/bootstrapdialog/css/bootstrap-dialog.css b/assets/js/bootstrapdialog/css/bootstrap-dialog.css new file mode 100644 index 00000000..1470687e --- /dev/null +++ b/assets/js/bootstrapdialog/css/bootstrap-dialog.css @@ -0,0 +1,161 @@ +.bootstrap-dialog { + /* dialog types */ + /** + * Icon animation + * Copied from font-awesome: http://fontawesome.io/ + **/ + /** End of icon animation **/ +} + +.bootstrap-dialog .modal-header { + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.bootstrap-dialog .bootstrap-dialog-title { + color: #fff; + display: inline-block; + font-size: 16px; +} + +.bootstrap-dialog .bootstrap-dialog-message { + font-size: 14px; +} + +.bootstrap-dialog .bootstrap-dialog-button-icon { + margin-right: 3px; +} + +.bootstrap-dialog .bootstrap-dialog-close-button { + font-size: 20px; + float: right; + opacity: 0.9; + filter: alpha(opacity=90); +} + +.bootstrap-dialog .bootstrap-dialog-close-button:hover { + cursor: pointer; + opacity: 1; + filter: alpha(opacity=100); +} + +@media (min-width: 1172px) { + .bootstrap-dialog .modal-xl { + max-width: 95%; + } +} +.bootstrap-dialog .modal-lg .bootstrap4-dialog-button:first-child { + margin-top: 8px; +} + +.bootstrap-dialog.type-default .modal-header { + background-color: #fff; +} + +.bootstrap-dialog.type-default .bootstrap-dialog-title { + color: #333; +} + +.bootstrap-dialog.type-info .modal-header { + background-color: #17a2b8; +} + +.bootstrap-dialog.type-primary .modal-header { + background-color: #007bff; +} + +.bootstrap-dialog.type-secondary .modal-header { + background-color: #6c757d; +} + +.bootstrap-dialog.type-success .modal-header { + background-color: #28a745; +} + +.bootstrap-dialog.type-warning .modal-header { + background-color: #ffc107; +} + +.bootstrap-dialog.type-danger .modal-header { + background-color: #dc3545; +} + +.bootstrap-dialog.type-light .modal-header { + background-color: #f8f9fa; +} + +.bootstrap-dialog.type-dark .modal-header { + background-color: #343a40; +} + +.bootstrap-dialog.size-large .bootstrap-dialog-title { + font-size: 24px; +} + +.bootstrap-dialog.size-large .bootstrap-dialog-close-button { + font-size: 30px; +} + +.bootstrap-dialog.size-large .bootstrap-dialog-message { + font-size: 18px; +} + +.bootstrap-dialog .icon-spin { + display: inline-block; + -moz-animation: spin 2s infinite linear; + -o-animation: spin 2s infinite linear; + -webkit-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; +} + +.bootstrap-dialog-footer-buttons { + display: flex; +} + +@-moz-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + } +} +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + } +} +@-o-keyframes spin { + 0% { + -o-transform: rotate(0deg); + } + 100% { + -o-transform: rotate(359deg); + } +} +@-ms-keyframes spin { + 0% { + -ms-transform: rotate(0deg); + } + 100% { + -ms-transform: rotate(359deg); + } +} +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(359deg); + } +} +.bootstrap-dialog-header { + display: contents; +} + +/*# sourceMappingURL=bootstrap-dialog.css.map */ + +/*# sourceMappingURL=bootstrap-dialog.css.map */ diff --git a/assets/js/bootstrapdialog/js/bootstrap-dialog.min.js b/assets/js/bootstrapdialog/js/bootstrap-dialog.min.js new file mode 100644 index 00000000..5b251b8d --- /dev/null +++ b/assets/js/bootstrapdialog/js/bootstrap-dialog.min.js @@ -0,0 +1 @@ +(function(a,b){if(typeof module!=="undefined"&&module.exports){module.exports=b(require("jquery"),require("bootstrap"))}else{if(typeof define==="function"&&define.amd){define("bootstrap-dialog",["jquery","bootstrap"],function(c){return b(c)})}else{a.BootstrapDialog=b(a.jQuery)}}}(this?this:window,function(d){var b=d.fn.modal.Constructor;var c=function(f,e){if(/4\.1\.\d+/.test(d.fn.modal.Constructor.VERSION)){return new b(f,e)}else{b.call(this,f,e)}};c.getModalVersion=function(){var e=null;if(typeof d.fn.modal.Constructor.VERSION==="undefined"){e="v3.1"}else{if(/3\.2\.\d+/.test(d.fn.modal.Constructor.VERSION)){e="v3.2"}else{if(/3\.3\.[1,2]/.test(d.fn.modal.Constructor.VERSION)){e="v3.3"}else{if(/4\.\d\.\d+/.test(d.fn.modal.Constructor.VERSION)){e="v4.1"}else{e="v3.3.4"}}}}return e};c.ORIGINAL_BODY_PADDING=parseInt((d("body").css("padding-right")||0),10);c.METHODS_TO_OVERRIDE={};c.METHODS_TO_OVERRIDE["v3.1"]={};c.METHODS_TO_OVERRIDE["v3.2"]={hide:function(g){if(g){g.preventDefault()}g=d.Event("hide.bs.modal");this.$element.trigger(g);if(!this.isShown||g.isDefaultPrevented()){return}this.isShown=false;var f=this.getGlobalOpenedDialogs();if(f.length===0){this.$body.removeClass("modal-open")}this.resetScrollbar();this.escape();d(document).off("focusin.bs.modal");this.$element.removeClass("in").attr("aria-hidden",true).off("click.dismiss.bs.modal");d.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",d.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}};c.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var e=c.ORIGINAL_BODY_PADDING;if(this.bodyIsOverflowing){this.$body.css("padding-right",e+this.scrollbarWidth)}},resetScrollbar:function(){var e=this.getGlobalOpenedDialogs();if(e.length===0){this.$body.css("padding-right",c.ORIGINAL_BODY_PADDING)}},hideModal:function(){this.$element.hide();this.backdrop(d.proxy(function(){var e=this.getGlobalOpenedDialogs();if(e.length===0){this.$body.removeClass("modal-open")}this.resetAdjustments();this.resetScrollbar();this.$element.trigger("hidden.bs.modal")},this))}};c.METHODS_TO_OVERRIDE["v3.3.4"]=d.extend({},c.METHODS_TO_OVERRIDE["v3.3"]);c.METHODS_TO_OVERRIDE["v4.1"]=d.extend({},c.METHODS_TO_OVERRIDE["v3.3"]);c.prototype={constructor:c,getGlobalOpenedDialogs:function(){var e=[];d.each(a.dialogs,function(g,f){if(f.isRealized()&&f.isOpened()){e.push(f)}});return e}};c.prototype=d.extend(c.prototype,b.prototype,c.METHODS_TO_OVERRIDE[c.getModalVersion()]);var a=function(e){this.defaultOptions=d.extend(true,{id:a.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},a.defaultOptions);this.indexedButtons={};this.registeredButtonHotkeys={};this.draggableData={isMouseDown:false,mouseOffset:{}};this.realized=false;this.opened=false;this.initOptions(e);this.holdThisInstance()};a.BootstrapDialogModal=c;a.NAMESPACE="bootstrap-dialog";a.TYPE_DEFAULT="type-default";a.TYPE_INFO="type-info";a.TYPE_PRIMARY="type-primary";a.TYPE_SECONDARY="type-secondary";a.TYPE_SUCCESS="type-success";a.TYPE_WARNING="type-warning";a.TYPE_DANGER="type-danger";a.TYPE_DARK="type-dark";a.TYPE_LIGHT="type-light";a.DEFAULT_TEXTS={};a.DEFAULT_TEXTS[a.TYPE_DEFAULT]="Default";a.DEFAULT_TEXTS[a.TYPE_INFO]="Information";a.DEFAULT_TEXTS[a.TYPE_PRIMARY]="Primary";a.DEFAULT_TEXTS[a.TYPE_SECONDARY]="Secondary";a.DEFAULT_TEXTS[a.TYPE_SUCCESS]="Success";a.DEFAULT_TEXTS[a.TYPE_WARNING]="Warning";a.DEFAULT_TEXTS[a.TYPE_DANGER]="Danger";a.DEFAULT_TEXTS[a.TYPE_DARK]="Dark";a.DEFAULT_TEXTS[a.TYPE_LIGHT]="Light";a.DEFAULT_TEXTS.OK="OK";a.DEFAULT_TEXTS.CANCEL="Cancel";a.DEFAULT_TEXTS.CONFIRM="Confirmation";a.SIZE_NORMAL="size-normal";a.SIZE_SMALL="size-small";a.SIZE_WIDE="size-wide";a.SIZE_EXTRAWIDE="size-extrawide";a.SIZE_LARGE="size-large";a.BUTTON_SIZES={};a.BUTTON_SIZES[a.SIZE_NORMAL]="";a.BUTTON_SIZES[a.SIZE_SMALL]="btn-small";a.BUTTON_SIZES[a.SIZE_WIDE]="btn-block";a.BUTTON_SIZES[a.SIZE_LARGE]="btn-lg";a.ICON_SPINNER="glyphicon glyphicon-asterisk";a.BUTTONS_ORDER_CANCEL_OK="btns-order-cancel-ok";a.BUTTONS_ORDER_OK_CANCEL="btns-order-ok-cancel";a.Z_INDEX_BACKDROP=1040;a.Z_INDEX_MODAL=1050;a.defaultOptions={type:a.TYPE_PRIMARY,size:a.SIZE_NORMAL,cssClass:"",title:null,message:null,nl2br:true,closable:true,closeByBackdrop:true,closeByKeyboard:true,closeIcon:"×",spinicon:a.ICON_SPINNER,autodestroy:true,draggable:false,animate:true,description:"",tabindex:-1,btnsOrder:a.BUTTONS_ORDER_CANCEL_OK};a.configDefaultOptions=function(e){a.defaultOptions=d.extend(true,a.defaultOptions,e)};a.dialogs={};a.openAll=function(){d.each(a.dialogs,function(f,e){e.open()})};a.closeAll=function(){d.each(a.dialogs,function(f,e){e.close()})};a.getDialog=function(f){var e=null;if(typeof a.dialogs[f]!=="undefined"){e=a.dialogs[f]}return e};a.setDialog=function(e){a.dialogs[e.getId()]=e;return e};a.addDialog=function(e){return a.setDialog(e)};a.moveFocus=function(){var e=null;d.each(a.dialogs,function(g,f){if(f.isRealized()&&f.isOpened()){e=f}});if(e!==null){e.getModal().focus()}};a.METHODS_TO_OVERRIDE={};a.METHODS_TO_OVERRIDE["v3.1"]={updateZIndex:function(){if(this.isOpened()){var g=a.Z_INDEX_BACKDROP;var h=a.Z_INDEX_MODAL;var i=0;d.each(a.dialogs,function(j,k){if(k.isRealized()&&k.isOpened()){i++}});var f=this.getModal();var e=this.getModalBackdrop(f);f.css("z-index",h+(i-1)*20);e.css("z-index",g+(i-1)*20)}return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");this.updateZIndex();return this}};a.METHODS_TO_OVERRIDE["v3.2"]={updateZIndex:a.METHODS_TO_OVERRIDE["v3.1"]["updateZIndex"],open:a.METHODS_TO_OVERRIDE["v3.1"]["open"]};a.METHODS_TO_OVERRIDE["v3.3"]={};a.METHODS_TO_OVERRIDE["v3.3.4"]=d.extend({},a.METHODS_TO_OVERRIDE["v3.1"]);a.METHODS_TO_OVERRIDE["v4.0"]={getModalBackdrop:function(e){return d(e.data("bs.modal")._backdrop)},updateZIndex:a.METHODS_TO_OVERRIDE["v3.1"]["updateZIndex"],open:a.METHODS_TO_OVERRIDE["v3.1"]["open"],getModalForBootstrapDialogModal:function(){return this.getModal().get(0)}};a.METHODS_TO_OVERRIDE["v4.1"]={getModalBackdrop:function(e){return d(e.data("bs.modal")._backdrop)},updateZIndex:a.METHODS_TO_OVERRIDE["v3.1"]["updateZIndex"],open:a.METHODS_TO_OVERRIDE["v3.1"]["open"],getModalForBootstrapDialogModal:function(){return this.getModal().get(0)}};a.prototype={constructor:a,initOptions:function(e){this.options=d.extend(true,this.defaultOptions,e);return this},holdThisInstance:function(){a.addDialog(this);return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var e=d('');e.prop("id",this.getId());e.attr("aria-labelledby",this.getId()+"_title");return e},getModal:function(){return this.$modal},setModal:function(e){this.$modal=e;return this},getModalBackdrop:function(e){return e.data("bs.modal").$backdrop},getModalForBootstrapDialogModal:function(){return this.getModal()},createModalDialog:function(){return d('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(e){this.$modalDialog=e;return this},createModalContent:function(){return d('')},getModalContent:function(){return this.$modalContent},setModalContent:function(e){this.$modalContent=e;return this},createModalHeader:function(){return d('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(e){this.$modalHeader=e;return this},createModalBody:function(){return d('')},getModalBody:function(){return this.$modalBody},setModalBody:function(e){this.$modalBody=e;return this},createModalFooter:function(){return d('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(e){this.$modalFooter=e;return this},createDynamicContent:function(f){var e=null;if(typeof f==="function"){e=f.call(f,this)}else{e=f}if(typeof e==="string"){e=this.formatStringContent(e)}return e},formatStringContent:function(e){if(this.options.nl2br){return e.replace(/\r\n/g,"
    ").replace(/[\r\n]/g,"
    ")}return e},setData:function(e,f){this.options.data[e]=f;return this},getData:function(e){return this.options.data[e]},setId:function(e){this.options.id=e;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(e){this.options.type=e;this.updateType();return this},updateType:function(){if(this.isRealized()){var e=[a.TYPE_DEFAULT,a.TYPE_INFO,a.TYPE_PRIMARY,a.TYPE_SECONDARY,a.TYPE_SUCCESS,a.TYPE_WARNING,a.TYPE_DARK,a.TYPE_LIGHT,a.TYPE_DANGER];this.getModal().removeClass(e.join(" ")).addClass(this.getType())}return this},getSize:function(){return this.options.size},setSize:function(e){this.options.size=e;this.updateSize();return this},updateSize:function(){if(this.isRealized()){var e=this;this.getModal().removeClass(a.SIZE_NORMAL).removeClass(a.SIZE_SMALL).removeClass(a.SIZE_WIDE).removeClass(a.SIZE_EXTRAWIDE).removeClass(a.SIZE_LARGE);this.getModal().addClass(this.getSize());this.getModalDialog().removeClass("modal-sm");if(this.getSize()===a.SIZE_SMALL){this.getModalDialog().addClass("modal-sm")}this.getModalDialog().removeClass("modal-lg");if(this.getSize()===a.SIZE_WIDE){this.getModalDialog().addClass("modal-lg")}this.getModalDialog().removeClass("modal-xl");if(this.getSize()===a.SIZE_EXTRAWIDE){this.getModalDialog().addClass("modal-xl")}d.each(this.options.buttons,function(g,i){var k=e.getButton(i.id);var f=["btn-lg","btn-sm","btn-xs"];var j=false;if(typeof i.cssClass==="string"){var h=i.cssClass.split(" ");d.each(h,function(l,m){if(d.inArray(m,f)!==-1){j=true}})}if(!j){k.removeClass(f.join(" "));k.addClass(e.getButtonSize())}})}return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(e){this.options.cssClass=e;return this},getTitle:function(){return this.options.title},setTitle:function(e){this.options.title=e;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var e=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(e).prop("id",this.getId()+"_title")}return this},getMessage:function(){return this.options.message},setMessage:function(e){this.options.message=e;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var e=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(e)}return this},isClosable:function(){return this.options.closable},setClosable:function(e){this.options.closable=e;this.updateClosable();return this},setCloseByBackdrop:function(e){this.options.closeByBackdrop=e;return this},canCloseByBackdrop:function(){return this.options.closeByBackdrop},setCloseByKeyboard:function(e){this.options.closeByKeyboard=e;return this},canCloseByKeyboard:function(){return this.options.closeByKeyboard},isAnimate:function(){return this.options.animate},setAnimate:function(e){this.options.animate=e;return this},updateAnimate:function(){if(this.isRealized()){this.getModal().toggleClass("fade",this.isAnimate())}return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(e){this.options.spinicon=e;return this},addButton:function(e){this.options.buttons.push(e);return this},addButtons:function(f){var e=this;d.each(f,function(g,h){e.addButton(h)});return this},getButtons:function(){return this.options.buttons},setButtons:function(e){this.options.buttons=e;this.updateButtons();return this},getButton:function(e){if(typeof this.indexedButtons[e]!=="undefined"){return this.indexedButtons[e]}return null},getButtonSize:function(){if(typeof a.BUTTON_SIZES[this.getSize()]!=="undefined"){return a.BUTTON_SIZES[this.getSize()]}return""},updateButtons:function(){if(this.isRealized()){if(this.getButtons().length===0){this.getModalFooter().hide()}else{this.getModalFooter().show().closest(".modal-footer").append(this.createFooterButtons())}}return this},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(e){this.options.autodestroy=e},getDescription:function(){return this.options.description},setDescription:function(e){this.options.description=e;return this},setTabindex:function(e){this.options.tabindex=e;return this},getTabindex:function(){return this.options.tabindex},updateTabindex:function(){if(this.isRealized()){this.getModal().attr("tabindex",this.getTabindex())}return this},getDefaultText:function(){return a.DEFAULT_TEXTS[this.getType()]},getNamespace:function(e){return a.NAMESPACE+"-"+e},createHeaderContent:function(){var e=d("
    ");e.addClass(this.getNamespace("header"));e.append(this.createTitleContent());e.append(this.createCloseButton());return e},createTitleContent:function(){var e=d("
    ");e.addClass(this.getNamespace("title"));return e},createCloseButton:function(){var f=d("
    ");f.addClass(this.getNamespace("close-button"));var e=d('');e.append(this.options.closeIcon);f.append(e);f.on("click",{dialog:this},function(g){g.data.dialog.close()});return f},createBodyContent:function(){var e=d("
    ");e.addClass(this.getNamespace("body"));e.append(this.createMessageContent());return e},createMessageContent:function(){var e=d("
    ");e.addClass(this.getNamespace("message"));return e},createFooterContent:function(){var e=d("
    ");e.addClass(this.getNamespace("footer"));return e},createFooterButtons:function(){var e=this;var f=e.$modalFooter;this.indexedButtons={};d.each(this.options.buttons,function(g,h){if(!h.id){h.id=a.newGuid()}var i=e.createButton(h);e.indexedButtons[h.id]=i;f.append(i)});return f},createButton:function(e){var f=d('');f.prop("id",e.id);f.data("button",e);if(typeof e.icon!=="undefined"&&d.trim(e.icon)!==""){f.append(this.createButtonIcon(e.icon))}if(typeof e.label!=="undefined"){f.append(e.label)}if(typeof e.title!=="undefined"){f.attr("title",e.title)}if(typeof e.cssClass!=="undefined"&&d.trim(e.cssClass)!==""){f.addClass(e.cssClass)}else{f.addClass("btn-secondary")}if(typeof e.data==="object"&&e.data.constructor==={}.constructor){d.each(e.data,function(g,h){f.attr("data-"+g,h)})}if(typeof e.hotkey!=="undefined"){this.registeredButtonHotkeys[e.hotkey]=f}f.on("click",{dialog:this,$button:f,button:e},function(i){var h=i.data.dialog;var j=i.data.$button;var g=j.data("button");if(g.autospin){j.toggleSpin(true)}if(typeof g.action==="function"){return g.action.call(j,h,i)}});this.enhanceButton(f);if(typeof e.enabled!=="undefined"){f.toggleEnable(e.enabled)}f.addClass("bootstrap4-dialog-button");return f},enhanceButton:function(e){e.dialog=this;e.toggleEnable=function(f){var g=this;if(typeof f!=="undefined"){g.prop("disabled",!f).toggleClass("disabled",!f)}else{g.prop("disabled",!g.prop("disabled"))}return g};e.enable=function(){var f=this;f.toggleEnable(true);return f};e.disable=function(){var f=this;f.toggleEnable(false);return f};e.toggleSpin=function(i){var h=this;var g=h.dialog;var f=h.find("."+g.getNamespace("button-icon"));if(typeof i==="undefined"){i=!(e.find(".icon-spin").length>0)}if(i){f.hide();e.prepend(g.createButtonIcon(g.getSpinicon()).addClass("icon-spin"))}else{f.show();e.find(".icon-spin").remove()}return h};e.spin=function(){var f=this;f.toggleSpin(true);return f};e.stopSpin=function(){var f=this;f.toggleSpin(false);return f};return this},createButtonIcon:function(f){var e=d("");e.addClass(this.getNamespace("button-icon")).addClass(f);return e},enableButtons:function(e){d.each(this.indexedButtons,function(g,f){f.toggleEnable(e)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(e){this.options.onshow=e;return this},onShown:function(e){this.options.onshown=e;return this},onHide:function(e){this.options.onhide=e;return this},onHidden:function(e){this.options.onhidden=e;return this},isRealized:function(){return this.realized},setRealized:function(e){this.realized=e;return this},isOpened:function(){return this.opened},setOpened:function(e){this.opened=e;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(g){var f=g.data.dialog;f.setOpened(true);if(f.isModalEvent(g)&&typeof f.options.onshow==="function"){var e=f.options.onshow(f);if(e===false){f.setOpened(false)}return e}});this.getModal().on("shown.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.isModalEvent(f)&&typeof e.options.onshown==="function"&&e.options.onshown(e)});this.getModal().on("hide.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.setOpened(false);if(e.isModalEvent(f)&&typeof e.options.onhide==="function"){var g=e.options.onhide(e);if(g===false){e.setOpened(true)}return g}});this.getModal().on("hidden.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.isModalEvent(f)&&typeof e.options.onhidden==="function"&&e.options.onhidden(e);if(e.isAutodestroy()){e.setRealized(false);delete a.dialogs[e.getId()];d(this).remove()}a.moveFocus();if(d(".modal").hasClass("in")){d("body").addClass("modal-open")}});this.getModal().on("keyup",{dialog:this},function(e){e.which===27&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByKeyboard()&&e.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(f){var e=f.data.dialog;if(typeof e.registeredButtonHotkeys[f.which]!=="undefined"){var g=d(e.registeredButtonHotkeys[f.which]);!g.prop("disabled")&&!g.is(":focus")&&g.focus().trigger("click")}});return this},isModalEvent:function(e){return typeof e.namespace!=="undefined"&&e.namespace==="bs.modal"},makeModalDraggable:function(){if(this.options.draggable){this.getModalHeader().addClass(this.getNamespace("draggable")).on("mousedown",{dialog:this},function(g){var f=g.data.dialog;f.draggableData.isMouseDown=true;var e=f.getModalDialog().offset();f.draggableData.mouseOffset={top:g.clientY-e.top,left:g.clientX-e.left}});this.getModal().on("mouseup mouseleave",{dialog:this},function(e){e.data.dialog.draggableData.isMouseDown=false});d("body").on("mousemove",{dialog:this},function(f){var e=f.data.dialog;if(!e.draggableData.isMouseDown){return}e.getModalDialog().offset({top:f.clientY-e.draggableData.mouseOffset.top,left:f.clientX-e.draggableData.mouseOffset.left})})}return this},realize:function(){this.initModalStuff();this.getModal().addClass(a.NAMESPACE).addClass(this.getCssClass());this.updateSize();if(this.getDescription()){this.getModal().attr("aria-describedby",this.getDescription())}this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().data("bs.modal",new c(this.getModalForBootstrapDialogModal(),{backdrop:(this.isClosable()&&this.canCloseByBackdrop())?true:"static",keyboard:false,show:false}));this.makeModalDraggable();this.handleModalEvents();this.setRealized(true);this.updateButtons();this.updateType();this.updateTitle();this.updateMessage();this.updateClosable();this.updateAnimate();this.updateSize();this.updateTabindex();return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");return this},close:function(){!this.isRealized()&&this.realize();this.getModal().modal("hide");return this}};a.prototype=d.extend(a.prototype,a.METHODS_TO_OVERRIDE[c.getModalVersion()]);a.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(g){var f=Math.random()*16|0,e=g==="x"?f:(f&3|8);return e.toString(16)})};a.show=function(e){return new a(e).open()};a.alert=function(){var g={};var e={type:a.TYPE_PRIMARY,title:null,message:null,closable:false,draggable:false,buttonLabel:a.DEFAULT_TEXTS.OK,buttonHotkey:null,callback:null};if(typeof arguments[0]==="object"&&arguments[0].constructor==={}.constructor){g=d.extend(true,e,arguments[0])}else{g=d.extend(true,e,{message:arguments[0],callback:typeof arguments[1]!=="undefined"?arguments[1]:null})}var f=new a(g);f.setData("callback",g.callback);f.addButton({label:g.buttonLabel,hotkey:g.buttonHotkey,action:function(h){if(typeof h.getData("callback")==="function"&&h.getData("callback").call(this,true)===false){return false}h.setData("btnClicked",true);return h.close()}});if(typeof f.options.onhide==="function"){f.onHide(function(h){var i=true;if(!h.getData("btnClicked")&&h.isClosable()&&typeof h.getData("callback")==="function"){i=h.getData("callback")(false)}if(i===false){return false}i=this.onhide(h);return i}.bind({onhide:f.options.onhide}))}else{f.onHide(function(h){var i=true;if(!h.getData("btnClicked")&&h.isClosable()&&typeof h.getData("callback")==="function"){i=h.getData("callback")(false)}return i})}return f.open()};a.confirm=function(){var g={};var h={type:a.TYPE_PRIMARY,title:null,message:null,closable:false,draggable:false,btnCancelLabel:a.DEFAULT_TEXTS.CANCEL,btnCancelClass:null,btnCancelHotkey:null,btnOKLabel:a.DEFAULT_TEXTS.OK,btnOKClass:null,btnOKHotkey:null,btnsOrder:a.defaultOptions.btnsOrder,callback:null};if(typeof arguments[0]==="object"&&arguments[0].constructor==={}.constructor){g=d.extend(true,h,arguments[0])}else{g=d.extend(true,h,{message:arguments[0],callback:typeof arguments[1]!=="undefined"?arguments[1]:null})}if(g.btnOKClass===null){g.btnOKClass=["btn",g.type.split("-")[1]].join("-")}var e=new a(g);e.setData("callback",g.callback);var f=[{label:g.btnCancelLabel,cssClass:g.btnCancelClass,hotkey:g.btnCancelHotkey,action:function(i){if(typeof i.getData("callback")==="function"&&i.getData("callback").call(this,false)===false){return false}return i.close()}},{label:g.btnOKLabel,cssClass:g.btnOKClass,hotkey:g.btnOKHotkey,action:function(i){if(typeof i.getData("callback")==="function"&&i.getData("callback").call(this,true)===false){return false}return i.close()}}];if(g.btnsOrder===a.BUTTONS_ORDER_OK_CANCEL){f.reverse()}e.addButtons(f);return e.open()};a.warning=function(e,f){return new a({type:a.TYPE_WARNING,message:e}).open()};a.danger=function(e,f){return new a({type:a.TYPE_DANGER,message:e}).open()};a.success=function(e,f){return new a({type:a.TYPE_SUCCESS,message:e}).open()};return a})); \ No newline at end of file From a95232c46ac8a9696799de2a6d218002d98ce261 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 13 Sep 2020 11:52:48 +0100 Subject: [PATCH 8/8] [Stats] Removed DrawQSLChart as it was throwing an error due to not being used --- application/views/statistics/index.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/views/statistics/index.php b/application/views/statistics/index.php index ba4009fd..a1a79a94 100644 --- a/application/views/statistics/index.php +++ b/application/views/statistics/index.php @@ -8,8 +8,6 @@ google.setOnLoadCallback(drawModeChart); google.setOnLoadCallback(drawBandChart); google.setOnLoadCallback(drawSatChart); - google.setOnLoadCallback(drawQSLChart); - // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and