Always unbind internal listeners when closing a modal dialog

This commit is contained in:
Frederic Guillot 2017-01-26 22:21:07 -05:00
parent c3d42a21b2
commit a371d53e63
10 changed files with 38 additions and 6 deletions

View File

@ -18,6 +18,7 @@ Bug fixes:
* Fix wrong datetime formatting when task form shows validation errors
* Empty arrays are serialized to a list instead of a dict (Json API)
* Always unbind internal listeners when closing a modal dialog
Version 1.0.37 (Jan 14, 2017)
-----------------------------

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
KB.onClick('.accordion-toggle', function(e) {
KB.onClick('.accordion-toggle', function (e) {
var sectionElement = KB.dom(e.target).parent('.accordion-section');
if (sectionElement) {

View File

@ -42,6 +42,9 @@ KB.component('confirm-buttons', function (containerElement, options) {
this.render = function () {
KB.on('modal.stop', onStop);
KB.on('modal.close', function () {
KB.removeListener('modal.stop', onStop);
});
var element = KB.dom('div')
.attr('class', 'form-actions')

View File

@ -2,7 +2,7 @@ KB.component('file-upload', function (containerElement, options) {
var inputFileElement = null;
var dropzoneElement = null;
var files = [];
var currentFileIndex = null;
var currentFileIndex = 0;
function onProgress(e) {
if (e.lengthComputable) {
@ -183,6 +183,9 @@ KB.component('file-upload', function (containerElement, options) {
this.render = function () {
KB.on('modal.submit', onSubmit);
KB.on('modal.close', function () {
KB.removeListener('modal.submit', onSubmit);
});
inputFileElement = buildFileInputElement();
dropzoneElement = buildDropzoneElement();

View File

@ -15,7 +15,6 @@ KB.component('screenshot', function (containerElement) {
for (var i = 0; i < items.length; i++) {
// Find an image in pasted elements
if (items[i].type.indexOf("image") !== -1) {
var blob = items[i].getAsFile();
// Get the image as base64 data

View File

@ -238,6 +238,11 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options)
KB.on('select.dropdown.loading.start', onLoadingStart);
KB.on('select.dropdown.loading.stop', onLoadingStop);
KB.on('modal.close', function () {
KB.removeListener('select.dropdown.loading.start', onLoadingStart);
KB.removeListener('select.dropdown.loading.stop', onLoadingStop);
});
chevronIconElement = KB.dom('i')
.attr('class', 'fa fa-chevron-down select-dropdown-chevron')
.click(toggleDropdownMenu)

View File

@ -78,6 +78,14 @@ KB.component('submit-buttons', function (containerElement, options) {
KB.on('modal.hide', onHide);
KB.on('modal.submit.label', onUpdateSubmitLabel);
KB.on('modal.close', function () {
KB.removeListener('modal.stop', onStop);
KB.removeListener('modal.disable', onDisable);
KB.removeListener('modal.enable', onEnable);
KB.removeListener('modal.hide', onHide);
KB.removeListener('modal.submit.label', onUpdateSubmitLabel);
});
var formActionElementBuilder = KB.dom('div')
.attr('class', 'form-actions')
.add(buildButton());

View File

@ -146,6 +146,9 @@ KB.component('task-move-position', function (containerElement, options) {
this.render = function () {
KB.on('modal.submit', onSubmit);
KB.on('modal.close', function () {
KB.removeListener('modal.submit', onSubmit);
});
var form = KB.dom('div')
.add(KB.dom('div').attr('id', 'message-container').build())

View File

@ -27,6 +27,16 @@ KB.trigger = function (eventType, eventData) {
}
};
KB.removeListener = function (eventType, callback) {
if (this.listeners.internals.hasOwnProperty(eventType)) {
for (var i = 0; i < this.listeners.internals[eventType].length; i++) {
if (this.listeners.internals[eventType][i] === callback) {
this.listeners.internals[eventType].splice(i, 1);
}
}
}
};
KB.onClick = function (selector, callback) {
this.listeners.clicks[selector] = callback;
};