aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-12-20 18:43:20 -0800
committerzotlabs <mike@macgirvin.com>2016-12-20 18:43:20 -0800
commit493aa9f20d3a48132a83b1da0c643f80c038e617 (patch)
tree89063b5605fd9b5982395ec66ed919f45a9c6b2b /view/js
parent6ff462abf39b76fb8ad6f5734c058e9b19dbc774 (diff)
downloadvolse-hubzilla-493aa9f20d3a48132a83b1da0c643f80c038e617.tar.gz
volse-hubzilla-493aa9f20d3a48132a83b1da0c643f80c038e617.tar.bz2
volse-hubzilla-493aa9f20d3a48132a83b1da0c643f80c038e617.zip
progress on abook_vcard
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_connedit.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/view/js/mod_connedit.js b/view/js/mod_connedit.js
index 84fff5ed1..252ed9e7c 100644
--- a/view/js/mod_connedit.js
+++ b/view/js/mod_connedit.js
@@ -16,6 +16,71 @@ $(document).ready(function() {
connectFullShare();
});
+ $(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();
+ }
+
});
function connectFullShare() {