src/pyams_skin/resources/js/myams.js
changeset 19 7d4bd86b3f30
parent 11 87c7662cc814
child 23 02baebfdfbe8
equal deleted inserted replaced
18:d7b0f5b72604 19:7d4bd86b3f30
     1 /*
     1 /*
     2  * MyAMS
     2  * MyAMS
     3  * « My Application Management Skin »
     3  * « My Application Management Skin »
     4  *
     4  *
     5  * $Tag: null $
     5  * $Tag$
     6  * A bootstrap based application/administration skin
     6  * A bootstrap based application/administration skin
     7  *
     7  *
     8  * Custom administration and application skin tools
     8  * Custom administration and application skin tools
     9  * Released under Zope Public License ZPL 1.1
     9  * Released under Zope Public License ZPL 1.1
    10  * ©2015 Thierry Florac <tflorac@ulthar.net>
    10  * ©2015 Thierry Florac <tflorac@ulthar.net>
  2896 		}
  2896 		}
  2897 	};
  2897 	};
  2898 
  2898 
  2899 
  2899 
  2900 	/**
  2900 	/**
       
  2901 	 * Container management
       
  2902 	 */
       
  2903 	MyAMS.container = {
       
  2904 
       
  2905 		/**
       
  2906 		 * Change container elements order
       
  2907 		 *
       
  2908 		 * This is a callback which may be used with TableDnD plug-in which allows you to
       
  2909 		 * change order of table rows.
       
  2910 		 * Rows order is stored in an hidden input which is defined in table's data attribute
       
  2911 		 * called 'data-ams-input-name'
       
  2912 		 */
       
  2913 		changeOrder: function(table, names) {
       
  2914 			var input = $('input[name="' + $(this).data('ams-input-name') + '"]', $(this));
       
  2915 			input.val(names.join(';'));
       
  2916 		},
       
  2917 
       
  2918 		/**
       
  2919 		 * Delete an element from a container table
       
  2920 		 *
       
  2921 		 * @param element
       
  2922 		 * @returns {Function}
       
  2923 		 */
       
  2924 		deleteElement: function(element) {
       
  2925 			return function() {
       
  2926 				var link = $(this);
       
  2927 				MyAMS.skin.bigBox({
       
  2928 					title: MyAMS.i18n.WARNING,
       
  2929 					content: '<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; ' + MyAMS.i18n.DELETE_WARNING,
       
  2930 					buttons: MyAMS.i18n.BTN_OK_CANCEL
       
  2931 				}, function(button) {
       
  2932 					if (button == MyAMS.i18n.BTN_OK) {
       
  2933 						var table = link.parents('table');
       
  2934 						var location = table.data('ams-location');
       
  2935 						var tr = link.parents('tr');
       
  2936 						var delete_target = tr.data('ams-delete-target') || table.data('ams-delete-target') || 'delete-element.json';
       
  2937 						var object_name = tr.data('ams-element-name');
       
  2938 						MyAMS.ajax.post(location + '/' + delete_target, {'object_name': object_name}, function(result, status) {
       
  2939 							if (result.status == 'success') {
       
  2940 								link.parents('tr').remove();
       
  2941 							}
       
  2942 						});
       
  2943 					}
       
  2944 				});
       
  2945 			}
       
  2946 		}
       
  2947 	};
       
  2948 
       
  2949 
       
  2950 	/**
  2901 	 * Generic skin features
  2951 	 * Generic skin features
  2902 	 */
  2952 	 */
  2903 	MyAMS.skin = {
  2953 	MyAMS.skin = {
  2904 
  2954 
  2905 		/**
  2955 		/**