# HG changeset patch # User Thierry Florac # Date 1531958878 -7200 # Node ID ff73c764fa7d9d7428b7dbc2ae869c6b95de2f45 # Parent b0f7b9c8cd16bac6617b995b93478312cbe8a625 Added generic object attribute switcher function diff -r b0f7b9c8cd16 -r ff73c764fa7d src/pyams_skin/resources/js/myams.js --- a/src/pyams_skin/resources/js/myams.js Tue Jul 17 15:50:46 2018 +0200 +++ b/src/pyams_skin/resources/js/myams.js Thu Jul 19 02:07:58 2018 +0200 @@ -2,7 +2,7 @@ * MyAMS * « My Application Management Skin » * - * $Tag$ (rev. 1) + * $Tag: 0.1.17 $ (rev. 1) * A bootstrap based application/administration skin * * Custom administration and application skin tools @@ -4992,6 +4992,29 @@ } }); } + }, + + /** + * Switch element attribute + */ + switchElementAttribute: function() { + return function() { + var source = $(this); + var cell = source.parents('td').first(); + var attribute = cell.data('ams-switcher-attribute-name'); + var row = source.parents('tr').first(); + var table = row.parents('table'); + ams.ajax.post(table.data('ams-location') + '/' + + (cell.data('ams-attribute-switcher') || table.data('ams-attribute-switcher')), + {object_name: row.data('ams-element-name')}, + function(result, status) { + if (result.on) { + $('i', source).attr('class', table.data('ams-' + attribute + '-icon-on') || 'fa fa-fw fa-eye'); + } else { + $('i', source).attr('class', table.data('ams-' + attribute + '-icon-off') || 'fa fa-fw fa-eye-slash text-danger'); + } + }); + } } };