src/pyams_skin/resources/js/myams.js
changeset 383 86e1eae8090e
parent 380 86957fbcdcc5
child 389 092c4ab71fc0
equal deleted inserted replaced
382:ef2df998d59d 383:86e1eae8090e
  4977 		 * Switch element visibility
  4977 		 * Switch element visibility
  4978 		 */
  4978 		 */
  4979 		switchElementVisibility: function() {
  4979 		switchElementVisibility: function() {
  4980 			return function() {
  4980 			return function() {
  4981 				var source = $(this);
  4981 				var source = $(this);
  4982 				var element = source.parents('tr').first();
  4982 				var cell = source.parents('td').first();
  4983 				var container = element.parents('table');
  4983 				var row = source.parents('tr').first();
  4984 				ams.ajax.post(container.data('ams-location') + '/' +
  4984 				var table = row.parents('table');
  4985 							  container.data('ams-visibility-switcher'),
  4985 				$('i', source).attr('class', 'fa fa-fw fa-spinner fa-pulse');
  4986 					{object_name: element.data('ams-element-name')},
  4986 				ams.ajax.post(table.data('ams-location') + '/' +
       
  4987 							 (cell.data('ams-attribute-switcher') || table.data('ams-attribute-switcher')),
       
  4988 					{object_name: row.data('ams-element-name')},
  4987 					function(result, status) {
  4989 					function(result, status) {
  4988 						if (result.visible) {
  4990 						if (result.visible) {
  4989 							$('i', source).attr('class', 'fa fa-fw fa-eye');
  4991 							$('i', source).attr('class', 'fa fa-fw fa-eye');
  4990 						} else {
  4992 						} else {
  4991 							$('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
  4993 							$('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
  5002 				var source = $(this);
  5004 				var source = $(this);
  5003 				var cell = source.parents('td').first();
  5005 				var cell = source.parents('td').first();
  5004 				var attribute = cell.data('ams-switcher-attribute-name');
  5006 				var attribute = cell.data('ams-switcher-attribute-name');
  5005 				var row = source.parents('tr').first();
  5007 				var row = source.parents('tr').first();
  5006 				var table = row.parents('table');
  5008 				var table = row.parents('table');
       
  5009 				$('i', source).attr('class', 'fa fa-fw fa-spinner fa-pulse');
  5007 				ams.ajax.post(table.data('ams-location') + '/' +
  5010 				ams.ajax.post(table.data('ams-location') + '/' +
  5008 							  (cell.data('ams-attribute-switcher') || table.data('ams-attribute-switcher')),
  5011 							  (cell.data('ams-attribute-switcher') || table.data('ams-attribute-switcher')),
  5009 					{object_name: row.data('ams-element-name')},
  5012 					{object_name: row.data('ams-element-name')},
  5010 					function(result, status) {
  5013 					function(result, status) {
  5011 						if (result.on) {
  5014 						if (result[attribute] || result['on']) {
  5012 							$('i', source).attr('class', table.data('ams-' + attribute + '-icon-on') || 'fa fa-fw fa-eye');
  5015 							$('i', source).attr('class', table.data('ams-' + attribute + '-icon-on') || 'fa fa-fw fa-check-square-o');
  5013 						} else {
  5016 						} else {
  5014 							$('i', source).attr('class', table.data('ams-' + attribute + '-icon-off') || 'fa fa-fw fa-eye-slash text-danger');
  5017 							$('i', source).attr('class', table.data('ams-' + attribute + '-icon-off') || 'fa fa-fw fa-check-square txt-color-silver opacity-75');
  5015 						}
  5018 						}
  5016 					});
  5019 					});
  5017 			}
  5020 			}
  5018 		}
  5021 		}
  5019 	};
  5022 	};