]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/ExtendedProfile/js/profiledetail.js
initialize fave, sub, and membership URIs
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / js / profiledetail.js
index 7960cee83fc2714db26aa6315def350b1e78b311..99a3f78a4332536a45e82c3c5fb6b016321e45bb 100644 (file)
@@ -16,7 +16,7 @@ SN_EXTENDED.reorder = function(cls) {
     $(divs).last().find('a.add_row').show();
 
     if (divs.length == 1) {
-        $(divs).find('a.remove_row').hide();
+        $(divs).find('a.remove_row').fadeOut("slow");
     }
 };
 
@@ -46,7 +46,13 @@ SN_EXTENDED.replaceIndex = function(elem, oldIndex, newIndex) {
 
 SN_EXTENDED.resetRow = function(elem) {
     $(elem).find('input, textarea').attr('value', '');
+    $(elem).find('input').removeAttr('disabled');
     $(elem).find("select option[value='office']").attr("selected", true);
+    $(elem).find("input:checkbox").attr('checked', false);
+    $(elem).find("input[name$=-start], input[name$=-end]").each(function() {
+        $(this).removeClass('hasDatepicker');
+        $(this).datepicker({ dateFormat: 'd M yy' });
+    });
 };
 
 SN_EXTENDED.addRow = function() {
@@ -55,9 +61,8 @@ SN_EXTENDED.addRow = function() {
     var cls = div.attr('class');
     var index = id.match(/\d+/);
     var newIndex = parseInt(index) + 1;
-    var newtr = $(div).closest('tr').clone();
+    var newtr = $(div).closest('tr').removeClass('supersizeme').clone();
     SN_EXTENDED.replaceIndex(newtr, index, newIndex);
-    $(newtr).removeClass('supersizeme');
     SN_EXTENDED.resetRow(newtr);
     $(div).closest('tr').after(newtr);
     SN_EXTENDED.reorder(cls);
@@ -68,19 +73,17 @@ SN_EXTENDED.removeRow = function() {
     var div = $(this).closest('div');
     var id = $(div).attr('id');
     var cls = $(div).attr('class');
-    var cnt = SN_EXTENDED.rowCount(cls);
-
     var that = this;
 
     $("#confirm-dialog").dialog({
         buttons : {
             "Confirm" : function() {
+                $(this).dialog("close");
                 var target = $(that).closest('tr');
                 target.fadeOut("slow", function() {
-                    $(that).remove();
+                    $(target).remove();
+                    SN_EXTENDED.reorder(cls);
                 });
-                SN_EXTENDED.reorder(cls);
-                $(this).dialog("close");
             },
             "Cancel" : function() {
                 $(this).dialog("close");
@@ -88,6 +91,8 @@ SN_EXTENDED.removeRow = function() {
         }
     });
 
+    var cnt = SN_EXTENDED.rowCount(cls);
+
     if (cnt > 1) {
         $("#confirm-dialog").dialog("open");
     }
@@ -106,7 +111,7 @@ $(document).ready(function() {
 
     $("input[name$=-start], input[name$=-end], #extprofile-birthday").datepicker({ dateFormat: 'd M yy' });
 
-    var multifields = ["phone-item", "experience-item", "education-item", "im-item"];
+    var multifields = ["phone-item", "experience-item", "education-item", "im-item", 'website-item'];
 
     for (f in multifields) {
         SN_EXTENDED.reorder(multifields[f]);
@@ -119,4 +124,21 @@ $(document).ready(function() {
     $('.add_row').live('click', SN_EXTENDED.addRow);
     $('.remove_row').live('click', SN_EXTENDED.removeRow);
 
+    $('input:checkbox[name$=current]').each(function() {
+        var input = $(this).parent().siblings('input[id$=-end]');
+        if ($(this).is(':checked')) {
+            $(input).attr('disabled', 'true');
+        }
+    });
+
+    $('input:checkbox[name$=current]').live('click', function()  {
+        var input = $(this).parent().siblings('input[id$=-end]');
+        if ($(this).is(':checked')) {
+            $(input).val('');
+            $(input).attr('disabled', 'true');
+        } else {
+            $(input).removeAttr('disabled');
+        }
+    });
+
 });