src/pyams_skin/resources/js/myams.js
changeset 83 e7386933c184
parent 80 181b3a0ee15a
child 99 c628592aa86e
--- a/src/pyams_skin/resources/js/myams.js	Tue Sep 08 17:31:03 2015 +0200
+++ b/src/pyams_skin/resources/js/myams.js	Wed Sep 09 11:53:09 2015 +0200
@@ -110,6 +110,17 @@
 		},
 
 		/*
+		 * Get object if it supports given CSS class,
+		 * otherwise looks for parents
+		 */
+		objectWithClass: function(klass) {
+			if (this.hasClass(klass))
+				return this;
+			else
+				return this.parents('.' + klass);
+		},
+
+		/*
 		 * Build an array of attributes of the given selection
 		 */
 		listattr: function(attr) {
@@ -1682,8 +1693,9 @@
 		/**
 		 * Register a callback which should be called when a dialog is shown
 		 */
-		registerShownCallback: function(callback, dialog) {
-			if (dialog) {
+		registerShownCallback: function(callback, element) {
+			var dialog = element.objectWithClass('modal-dialog');
+			if (dialog.exists()) {
 				var callbacks = dialog.data('shown-callbacks');
 				if (callbacks === undefined) {
 					callbacks = [];
@@ -1704,8 +1716,9 @@
 		/**
 		 * Register a callback which should be called when a dialog is closed
 		 */
-		registerHideCallback: function(callback, dialog) {
-			if (dialog) {
+		registerHideCallback: function(callback, element) {
+			var dialog = element.objectWithClass('modal-dialog');
+			if (dialog.exists()) {
 				var callbacks = dialog.data('hide-callbacks');
 				if (callbacks === undefined) {
 					callbacks = [];