| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  | var SN_EXTENDED = SN_EXTENDED || {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.reorder = function (cls) { | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     var divs = $('div[class=' + cls + ']'); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |     $(divs).each(function (i, div) { | 
					
						
							| 
									
										
										
										
											2011-03-15 23:58:45 -07:00
										 |  |  |         $(div).find('a.add_row').hide(); | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |         $(div).find('a.remove_row').show(); | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  |         SN_EXTENDED.replaceIndex(SN_EXTENDED.rowIndex(div), i); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     var lastDiv = $(divs).last().closest('tr'); | 
					
						
							|  |  |  |     lastDiv.addClass('supersizeme'); | 
					
						
							| 
									
										
										
										
											2011-03-15 13:08:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     $(divs).last().find('a.add_row').show(); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     if (divs.length == 1) { | 
					
						
							| 
									
										
										
										
											2011-03-16 00:25:02 -07:00
										 |  |  |         $(divs).find('a.remove_row').fadeOut("slow"); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.rowIndex = function (div) { | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     var idstr = $(div).attr('id'); | 
					
						
							|  |  |  |     var id = idstr.match(/\d+/); | 
					
						
							|  |  |  |     return id; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.rowCount = function (cls) { | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     var divs = $.find('div[class=' + cls + ']'); | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     return divs.length; | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.replaceIndex = function (elem, oldIndex, newIndex) { | 
					
						
							|  |  |  |     $(elem).find('*').each(function () { | 
					
						
							|  |  |  |         $.each(this.attributes, function (i, attrib) { | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |             var regexp = /extprofile-.*-\d.*/; | 
					
						
							|  |  |  |             var value = attrib.value; | 
					
						
							|  |  |  |             var match = value.match(regexp); | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |             if (match !== null) { | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |                 attrib.value = value.replace("-" + oldIndex, "-" + newIndex); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.resetRow = function (elem) { | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |     $(elem).find('input, textarea').attr('value', ''); | 
					
						
							| 
									
										
										
										
											2011-03-16 02:41:32 -07:00
										 |  |  |     $(elem).find('input').removeAttr('disabled'); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |     $(elem).find("select option[value='office']").attr("selected", true); | 
					
						
							| 
									
										
										
										
											2011-03-16 02:41:32 -07:00
										 |  |  |     $(elem).find("input:checkbox").attr('checked', false); | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |     $(elem).find("input[name$=-start], input[name$=-end]").each(function () { | 
					
						
							| 
									
										
										
										
											2011-03-16 02:41:32 -07:00
										 |  |  |         $(this).removeClass('hasDatepicker'); | 
					
						
							|  |  |  |         $(this).datepicker({ dateFormat: 'd M yy' }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.addRow = function () { | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     var div = $(this).closest('div'); | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     var id = div.attr('id'); | 
					
						
							|  |  |  |     var cls = div.attr('class'); | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     var index = id.match(/\d+/); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  |     var newIndex = parseInt(index) + 1; | 
					
						
							| 
									
										
										
										
											2011-03-16 03:09:06 -04:00
										 |  |  |     var newtr = $(div).closest('tr').removeClass('supersizeme').clone(); | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  |     SN_EXTENDED.replaceIndex(newtr, index, newIndex); | 
					
						
							|  |  |  |     SN_EXTENDED.resetRow(newtr); | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     $(div).closest('tr').after(newtr); | 
					
						
							|  |  |  |     SN_EXTENDED.reorder(cls); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | SN_EXTENDED.removeRow = function () { | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     var div = $(this).closest('div'); | 
					
						
							|  |  |  |     var id = $(div).attr('id'); | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     var cls = $(div).attr('class'); | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |     var that = this; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#confirm-dialog").dialog({ | 
					
						
							|  |  |  |         buttons : { | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |             "Confirm" : function () { | 
					
						
							| 
									
										
										
										
											2011-03-16 00:23:34 -07:00
										 |  |  |                 $(this).dialog("close"); | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |                 var target = $(that).closest('tr'); | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |                 target.fadeOut("slow", function () { | 
					
						
							| 
									
										
										
										
											2011-03-16 00:23:34 -07:00
										 |  |  |                     $(target).remove(); | 
					
						
							|  |  |  |                     SN_EXTENDED.reorder(cls); | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |                 }); | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |             "Cancel" : function () { | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |                 $(this).dialog("close"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-16 00:23:34 -07:00
										 |  |  |     var cnt = SN_EXTENDED.rowCount(cls); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     if (cnt > 1) { | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |         $("#confirm-dialog").dialog("open"); | 
					
						
							| 
									
										
										
										
											2011-03-14 01:49:46 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  | $(document).ready(function () { | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |     $("#confirm-dialog").dialog({ | 
					
						
							|  |  |  |         autoOpen: false, | 
					
						
							|  |  |  |         modal: true | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 21:23:34 -07:00
										 |  |  |     $("input#extprofile-manager").autocomplete({ | 
					
						
							|  |  |  |         source: 'finduser', | 
					
						
							|  |  |  |         minLength: 2 }); | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 23:51:28 -07:00
										 |  |  |     $("input[name$=-start], input[name$=-end], #extprofile-birthday").datepicker({ dateFormat: 'd M yy' }); | 
					
						
							| 
									
										
										
										
											2011-03-15 23:02:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-16 00:34:00 -07:00
										 |  |  |     var multifields = ["phone-item", "experience-item", "education-item", "im-item", 'website-item']; | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (f in multifields) { | 
					
						
							|  |  |  |         SN_EXTENDED.reorder(multifields[f]); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-15 18:45:08 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $("input#extprofile-manager").autocomplete({ | 
					
						
							|  |  |  |         source: 'finduser', | 
					
						
							|  |  |  |         minLength: 2 }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |     $(document).on('click', '.add_row', SN_EXTENDED.addRow); | 
					
						
							|  |  |  |     $(document).on('click', '.remove_row', SN_EXTENDED.removeRow); | 
					
						
							| 
									
										
										
										
											2011-03-13 16:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |     $('input:checkbox[name$=current]').each(function () { | 
					
						
							| 
									
										
										
										
											2011-03-16 02:41:32 -07:00
										 |  |  |         var input = $(this).parent().siblings('input[id$=-end]'); | 
					
						
							|  |  |  |         if ($(this).is(':checked')) { | 
					
						
							|  |  |  |             $(input).attr('disabled', 'true'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 18:52:09 +02:00
										 |  |  |     $(document).on('click', 'input:checkbox[name$=current]', function ()  { | 
					
						
							| 
									
										
										
										
											2011-03-16 02:41:32 -07:00
										 |  |  |         var input = $(this).parent().siblings('input[id$=-end]'); | 
					
						
							|  |  |  |         if ($(this).is(':checked')) { | 
					
						
							|  |  |  |             $(input).val(''); | 
					
						
							|  |  |  |             $(input).attr('disabled', 'true'); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $(input).removeAttr('disabled'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 19:33:05 -07:00
										 |  |  | }); |