src/pyams_portal/resources/js/portal.js
changeset 140 95bee9c0ae3f
parent 130 26038059e74d
child 163 9e12eb044abf
equal deleted inserted replaced
139:e93775177b43 140:95bee9c0ae3f
   105 					MyAMS.ajax.post('add-template-row.json', {}, function(result) {
   105 					MyAMS.ajax.post('add-template-row.json', {}, function(result) {
   106 						var row_id = result.row_id;
   106 						var row_id = result.row_id;
   107 						var rows = $('.rows', '#portal_config');
   107 						var rows = $('.rows', '#portal_config');
   108 						$('<div></div>').addClass('row context-menu')
   108 						$('<div></div>').addClass('row context-menu')
   109 										.attr('data-ams-row-id', row_id)
   109 										.attr('data-ams-row-id', row_id)
   110 										.append($('<span></span>').addClass('row_id label label-success pull-right')
   110 										.append($('<strong></strong>').addClass('row_id label label-success pull-left')
   111 																  .text(row_id))
   111 																	  .text(row_id))
       
   112 										.append($('<strong></strong>').addClass('row_id label label-success pull-right')
       
   113 																	  .text(row_id))
   112 										.append($('<div></div>').addClass('slots')
   114 										.append($('<div></div>').addClass('slots')
   113 																.sortable({
   115 																.sortable({
   114 																	placeholder: 'slot-highlight',
   116 																	placeholder: 'slot-highlight',
   115 																	connectWith: '.slots',
   117 																	connectWith: '.slots',
   116 																	over: PyAMS_portal.template.overSlots,
   118 																	over: PyAMS_portal.template.overSlots,
   143 								.removeClass('already-dropped')
   145 								.removeClass('already-dropped')
   144 								.removeAttr('style')
   146 								.removeAttr('style')
   145 								.addClass('row context-menu')
   147 								.addClass('row context-menu')
   146 								.attr('data-ams-row-id', row_id)
   148 								.attr('data-ams-row-id', row_id)
   147 								.empty()
   149 								.empty()
   148 								.append($('<span></span>').addClass('row_id label label-success pull-right')
   150 								.append($('<strong></strong>').addClass('row_id label label-success pull-left')
   149 														  .text(row_id))
   151 															  .text(row_id))
       
   152 								.append($('<strong></strong>').addClass('row_id label label-success pull-right')
       
   153 															  .text(row_id))
   150 								.append($('<div></div>').addClass('slots')
   154 								.append($('<div></div>').addClass('slots')
   151 														.sortable({
   155 														.sortable({
   152 															placeholder: 'slot-highlight',
   156 															placeholder: 'slot-highlight',
   153 															connectWith: '.slots',
   157 															connectWith: '.slots',
   154 															over: PyAMS_portal.template.overSlots,
   158 															over: PyAMS_portal.template.overSlots,
   184 								{rows: JSON.stringify(ids)},
   188 								{rows: JSON.stringify(ids)},
   185 								function(result) {
   189 								function(result) {
   186 									if (result.status === 'success') {
   190 									if (result.status === 'success') {
   187 										$('.row', config).each(function (index) {
   191 										$('.row', config).each(function (index) {
   188 											$(this).attr('data-ams-row-id', index);
   192 											$(this).attr('data-ams-row-id', index);
   189 											$('span.row_id', $(this)).text(index);
   193 											$('.row_id', $(this)).text(index);
   190 										});
   194 										});
   191 									}
   195 									}
   192 								});
   196 								});
   193 			},
   197 			},
   194 
   198 
   210 												if (result.status === 'success') {
   214 												if (result.status === 'success') {
   211 													row.remove();
   215 													row.remove();
   212 													$('.row', '#portal_config').each(function (index) {
   216 													$('.row', '#portal_config').each(function (index) {
   213 														$(this).removeData()
   217 														$(this).removeData()
   214 															   .attr('data-ams-row-id', index);
   218 															   .attr('data-ams-row-id', index);
   215 														$('span.row_id', $(this)).text(index);
   219 														$('.row_id', $(this)).text(index);
   216 													});
   220 													});
   217 												}
   221 												}
   218 											});
   222 											});
   219 						}
   223 						}
   220 					});
   224 					});