Renamed arguments
authorThierry Florac <thierry.florac@onf.fr>
Tue, 09 Oct 2018 16:08:34 +0200
changeset 427 b027259e7a4b
parent 426 bd690acb18e9
child 428 fd4b666b5048
Renamed arguments
src/pyams_skin/resources/js/myams.js
--- a/src/pyams_skin/resources/js/myams.js	Tue Oct 09 14:50:35 2018 +0200
+++ b/src/pyams_skin/resources/js/myams.js	Tue Oct 09 16:08:34 2018 +0200
@@ -5337,10 +5337,10 @@
 		/**
 		 * Replace given form with new content
 		 */
-		refreshContent: function(changes) {
-			var target = $('[id="' + changes.object_id + '"]');
-			target.replaceWith($(changes.content));
-			target = $('[id="' + changes.object_id + '"]');
+		refreshContent: function(options) {
+			var target = $('[id="' + options.object_id + '"]');
+			target.replaceWith($(options.content));
+			target = $('[id="' + options.object_id + '"]');
 			MyAMS.initContent(target);
 			return target;
 		},
@@ -5348,21 +5348,21 @@
 		/**
 		 * Replace given image from updated source
 		 */
-		refreshImage: function(changes) {
-			$('img[src^="' + changes.src + '"]').attr('src', changes.target);
+		refreshImage: function(options) {
+			$('img[src^="' + options.src + '"]').attr('src', options.target);
 		},
 
 		/**
 		 * Replace given widget with given content
 		 */
-		refreshWidget: function(changes) {
-			var target = $('[id="' + changes.parent_id + '"]');
-			var widget = $('[name="' + changes.widget_name + '"]', target);
+		refreshWidget: function(options) {
+			var target = $('[id="' + options.parent_id + '"]');
+			var widget = $('[name="' + options.widget_name + '"]', target);
 			if (!widget.exists()) {
-				widget = $('[name="' + changes.widget_name + ':list"]', target);
+				widget = $('[name="' + options.widget_name + ':list"]', target);
 			}
 			var label = widget.parents('.input').last();
-			label.html(changes.content);
+			label.html(options.content);
 			MyAMS.initContent(label);
 			return label;
 		},
@@ -5370,10 +5370,10 @@
 		/**
 		 * Replace given table with new content
 		 */
-		refreshTable: function(changes) {
-			var widget = $('[id="' + changes.object_id + '"]').parents('.ams-widget:first');
-			widget.replaceWith($(changes.table));
-			widget = $('[id="' + changes.object_id + '"]').parents('.ams-widget:first');
+		refreshTable: function(options) {
+			var widget = $('[id="' + options.object_id + '"]').parents('.ams-widget:first');
+			widget.replaceWith($(options.table));
+			widget = $('[id="' + options.object_id + '"]').parents('.ams-widget:first');
 			MyAMS.initContent(widget);
 			return widget;
 		},
@@ -5381,11 +5381,9 @@
 		/**
 		 * Replace given table with new content
 		 * If table is located inside a switched fieldset, fieldset is opened
-		 *
-		 * @param changes
 		 */
-		refreshSwitchedTable: function(changes) {
-			var widget = ams.skin.refreshTable(changes);
+		refreshSwitchedTable: function(options) {
+			var widget = ams.skin.refreshTable(options);
 			var legend = widget.siblings('legend');
 			if (legend.parents('fieldset:first').hasClass('switched')) {
 				legend.click();
@@ -5395,10 +5393,10 @@
 		/**
 		 * Replace given row with new content
 		 */
-		refreshRow: function(changes) {
-			var tr = $('tr[id="' + changes.object_id + '"]');
+		refreshRow: function(options) {
+			var tr = $('tr[id="' + options.object_id + '"]');
 			var table = tr.parents('table').first();
-			var new_tr = $(changes.row);
+			var new_tr = $(options.row);
 			tr.replaceWith(new_tr);
 			MyAMS.initContent(new_tr);
 			if (table.hasClass('table-dnd')) {
@@ -5411,15 +5409,15 @@
 		/**
 		 * Replace given row cell with new content
 		 */
-		refreshRowCell: function(changes) {
-			var tr = $('tr[id="' + changes.object_id + '"]');
+		refreshRowCell: function(options) {
+			var tr = $('tr[id="' + options.object_id + '"]');
 			var table = tr.parents('table').first();
 			var headRow = $('tr', $('thead', table));
-			var headCell = $('th[data-ams-column-name="' + changes.col_name + '"]', headRow);
+			var headCell = $('th[data-ams-column-name="' + options.col_name + '"]', headRow);
 			var index = $('th', headRow).index(headCell);
 			if (index > -1) {
 				var cell = $($('td', tr).get(index));
-				cell.html(changes.cell);
+				cell.html(options.cell);
 				MyAMS.initContent(cell);
 			}
 		},
@@ -6424,8 +6422,8 @@
 		});
 
 		// Enable custom MyAMS refresh events
-		$(document).on('myams.refresh', function(event, settings) {
-			MyAMS.executeFunctionByName(settings.handler || MyAMS.skin.refreshContent, event.target, settings);
+		$(document).on('myams.refresh', function(event, options) {
+			MyAMS.executeFunctionByName(options.handler || MyAMS.skin.refreshContent, event.target, options);
 		});
 		
 		// Init page content