aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-01-01 14:16:15 -0800
committerzotlabs <mike@macgirvin.com>2017-01-01 14:16:15 -0800
commitdca4de80fd8dfc2e23f6e7bec73b8bf79cdfa8ca (patch)
treec3c0f125f11a7f7e916384779ba279d08b2fc7ce /view/js
parent1436b075bfbf6a2f4abaddfd9d124153004bc45f (diff)
parentbead3e6095066990afe982fc63e86f2bbd4d109f (diff)
downloadvolse-hubzilla-dca4de80fd8dfc2e23f6e7bec73b8bf79cdfa8ca.tar.gz
volse-hubzilla-dca4de80fd8dfc2e23f6e7bec73b8bf79cdfa8ca.tar.bz2
volse-hubzilla-dca4de80fd8dfc2e23f6e7bec73b8bf79cdfa8ca.zip
Merge branch 'pcard' into dev
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_profiles.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/view/js/mod_profiles.js b/view/js/mod_profiles.js
index a7754e0c5..acc9f9953 100644
--- a/view/js/mod_profiles.js
+++ b/view/js/mod_profiles.js
@@ -1,4 +1,70 @@
$(document).ready(function() {
$('form').areYouSure(); // Warn user about unsaved settings
$('textarea').bbco_autocomplete('bbcode');
+
+ $(document).on('click', '.vcard-header, .vcard-cancel-btn', updateView);
+ $(document).on('click', '.add-field', doAdd);
+ $(document).on('click', '.remove-field', doRemove);
+
+ function updateView() {
+ var id = $(this).data('id');
+ var action = $(this).data('action');
+ var header = $('#vcard-header-' + id);
+ var cancel = $('#vcard-cancel-' + id);
+ var addField = $('#vcard-add-field-' + id);
+ var info = $('#vcard-info-' + id);
+ var vcardPreview = $('#vcard-preview-' + id);
+ var fn = $('#vcard-fn-' + id);
+
+ if(action === 'open') {
+ $(header).addClass('active');
+ $(cancel).show();
+ $(addField).show();
+ $(info).show();
+ $(fn).show();
+ $(vcardPreview).hide();
+ }
+ else {
+ $(header).removeClass('active');
+ $(cancel).hide();
+ $(addField).hide();
+ $(info).hide();
+ $(fn).hide();
+ $(vcardPreview).show();
+ }
+ }
+
+ function doAdd() {
+ var what = $(this).data('add');
+ var id = $(this).data('id');
+ var element = '#template-form-' + what;
+ var where = '#abook-edit-form';
+
+ $(element + ' .remove-field').attr('data-id', id)
+
+ if(what === 'vcard-adr') {
+ var adrCount = $(where + ' .form-' + what).length;
+ var attrName = 'adr[' + adrCount + '][]';
+ $(element + ' input').attr('name', attrName);
+ }
+
+ if(what === 'vcard-org' || what === 'vcard-title' || what === 'vcard-note') {
+ $(where + ' .add-' + what).hide()
+ }
+
+ $(element).clone().removeAttr('id').appendTo(where + ' .form-' + what + '-wrapper');
+ }
+
+ function doRemove() {
+ var what = $(this).data('remove');
+ var element = $(this).parents('div.form-' + what);
+ var where = '#abook_edit_form' + $(this).data('id');
+
+ if(what === 'vcard-org' || what === 'vcard-title' || what === 'vcard-note') {
+ $(where + ' .add-' + what).show()
+ }
+
+ $(element).remove();
+ }
+
});