diff options
author | zotlabs <mike@macgirvin.com> | 2017-05-01 21:07:11 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-05-01 21:07:11 -0700 |
commit | 42ed73ed4ac55ac62214301097f7d72cbcb37238 (patch) | |
tree | 6c3ebd20009503627dba4d193d7e5398bb45789d /view | |
parent | 5ed5c76d3f2628ffec348a61c681c86730e383de (diff) | |
download | volse-hubzilla-42ed73ed4ac55ac62214301097f7d72cbcb37238.tar.gz volse-hubzilla-42ed73ed4ac55ac62214301097f7d72cbcb37238.tar.bz2 volse-hubzilla-42ed73ed4ac55ac62214301097f7d72cbcb37238.zip |
add cdav files
Diffstat (limited to 'view')
-rw-r--r-- | view/tpl/cdav_addressbook.tpl | 462 | ||||
-rw-r--r-- | view/tpl/cdav_calendar.tpl | 349 | ||||
-rw-r--r-- | view/tpl/cdav_widget_addressbook.tpl | 66 | ||||
-rw-r--r-- | view/tpl/cdav_widget_calendar.tpl | 121 |
4 files changed, 998 insertions, 0 deletions
diff --git a/view/tpl/cdav_addressbook.tpl b/view/tpl/cdav_addressbook.tpl new file mode 100644 index 000000000..587a95caa --- /dev/null +++ b/view/tpl/cdav_addressbook.tpl @@ -0,0 +1,462 @@ +<script> +$(document).ready(function() { + + $(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(e) { + e.preventDefault(); + var what = $(this).data('add'); + var id = $(this).data('id'); + var element = '#template-form-' + what; + var where = '#card_form_' + id; + + $(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 = '#card_form_' + $(this).data('id'); + + if(what === 'vcard-org' || what === 'vcard-title' || what === 'vcard-note') { + $(where + ' .add-' + what).show() + } + + $(element).remove(); + } + +}); +</script> +<div id="template-form-vcard-org" class="form-group form-vcard-org"> + <div class="form-group form-vcard-org"> + <input type="text" name="org" value="" placeholder="{{$org_label}}"> + <i data-remove="vcard-org" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> +</div> + +<div id="template-form-vcard-title" class="form-group form-vcard-title"> + <div class="form-group form-vcard-title"> + <input type="text" name="title" value="" placeholder="{{$title_label}}"> + <i data-remove="vcard-title" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> +</div> + +<div id="template-form-vcard-tel" class="form-group form-vcard-tel"> + <select name="tel_type[]"> + <option value="CELL">{{$mobile}}</option> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="tel[]" value="" placeholder="{{$tel_label}}"> + <i data-remove="vcard-tel" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> +</div> + +<div id="template-form-vcard-email" class="form-group form-vcard-email"> + <select name="email_type[]"> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="email[]" value="" placeholder="{{$email_label}}"> + <i data-remove="vcard-email" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> +</div> + +<div id="template-form-vcard-impp" class="form-group form-vcard-impp"> + <select name="impp_type[]"> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="impp[]" value="" placeholder="{{$impp_label}}"> + <i data-remove="vcard-impp" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> +</div> + +<div id="template-form-vcard-url" class="form-group form-vcard-url"> + <select name="url_type[]"> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="url[]" value="" placeholder="{{$url_label}}"> + <i data-remove="vcard-url" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> +</div> + +<div id="template-form-vcard-adr" class="form-group form-vcard-adr"> + <div class="form-group"> + <select name="adr_type[]"> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <label>{{$adr_label}}</label> + <i data-remove="vcard-adr" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$po_box}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$extra}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$street}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$locality}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$region}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$zip_code}}"> + </div> + <div class="form-group"> + <input type="text" name="" value="" placeholder="{{$country}}"> + </div> +</div> + +<div id="template-form-vcard-note" class="form-group form-vcard-note"> + <label>{{$note_label}}</label> + <i data-remove="vcard-note" data-id="" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + <textarea name="note" class="form-control"></textarea> +</div> + +<div class="generic-content-wrapper"> + <div class="section-title-wrapper"> + <button type="button" class="btn btn-success btn-sm float-right" onclick="openClose('create_form')"><i class="fa fa-plus-circle"></i> {{$add_card}}</button> + <h2>{{$displayname}}</h2> + </div> + <div id="create_form" class="section-content-tools-wrapper"> + <form id="card_form_new" method="post" action=""> + <input type="hidden" name="target" value="{{$id}}"> + <div class="dropdown pull-right"> + <button data-toggle="dropdown" type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle"><i class="fa fa-plus"></i> {{$add_field}}</button> + <div class="dropdown-menu dropdown-menu-right"> + <a class="dropdown-item add-vcard-org add-field" style="display: none" href="#" data-add="vcard-org" data-id="new">{{$org_label}}</a> + <a class="dropdown-item add-vcard-title add-field" style="display: none" href="#" data-add="vcard-title" data-id="new">{{$title_label}}</a> + <a class="dropdown-item add-vcard-tel add-field" href="#" data-add="vcard-tel" data-id="new">{{$tel_label}}</a> + <a class="dropdown-item add-vcard-email add-field" href="#" data-add="vcard-email" data-id="new">{{$email_label}}</a> + <a class="dropdown-item add-vcard-impp add-field" href="#" data-add="vcard-impp" data-id="new">{{$impp_label}}</a> + <a class="dropdown-item add-vcard-url add-field" href="#" data-add="vcard-url" data-id="new">{{$url_label}}</a> + <a class="dropdown-item add-vcard-adr add-field" href="#" data-add="vcard-adr" data-id="new">{{$adr_label}}</a> + <a class="dropdown-item add-vcard-note add-field" href="#" data-add="vcard-note" data-id="new">{{$note_label}}</a> + </div> + </div> + + <div class="vcard-fn-create form-group"> + <div class="form-vcard-fn-wrapper"> + <div class="form-group form-vcard-fn"> + <div class="vcard-nophoto"><i class="fa fa-user"></i></div><input type="text" name="fn" value="" placeholder="{{$name_label}}"> + </div> + </div> + </div> + + <div class="vcard-org form-group"> + <div class="form-vcard-org-wrapper"> + <div class="form-group form-vcard-org"> + <input type="text" name="org" value="" placeholder="{{$org_label}}"> + <i data-remove="vcard-org" data-id="new" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + </div> + </div> + + <div class="vcard-title form-group"> + <div class="form-vcard-title-wrapper"> + <div class="form-group form-vcard-title"> + <input type="text" name="title" value="" placeholder="{{$title_label}}"> + <i data-remove="vcard-title" data-id="new" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + </div> + </div> + + <div class="vcard-tel form-group"> + <div class="form-vcard-tel-wrapper"> + <div class="form-group form-vcard-tel"> + <select name="tel_type[]"> + <option value="CELL">{{$mobile}}</option> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="tel[]" value="" placeholder="{{$tel_label}}"> + <i data-remove="vcard-tel" data-id="new" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + </div> + </div> + + + <div class="vcard-email form-group"> + <div class="form-vcard-email-wrapper"> + <div class="form-group form-vcard-email"> + <select name="email_type[]"> + <option value="HOME">{{$home}}</option> + <option value="WORK">{{$work}}</option> + <option value="OTHER">{{$other}}</option> + </select> + <input type="text" name="email[]" value="" placeholder="{{$email_label}}"> + <i data-remove="vcard-email" data-id="new" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + </div> + </div> + + <div class="vcard-impp form-group"> + <div class="form-vcard-impp-wrapper"> + </div> + </div> + + <div class="vcard-url form-group"> + <div class="form-vcard-url-wrapper"> + </div> + </div> + + <div class="vcard-adr form-group"> + <div class="form-vcard-adr-wrapper"> + </div> + </div> + + <div class="vcard-note form-group"> + <div class="form-vcard-note-wrapper"> + </div> + </div> + + <button type="submit" name="create" value="create_card" class="btn btn-primary btn-sm pull-right">{{$create}}</button> + <button type="button" class="btn btn-outline-secondary btn-sm" onclick="openClose('create_form')">{{$cancel}}</button> + <div class="clear"></div> + </form> + </div> + + {{foreach $cards as $card}} + <form id="card_form_{{$card.id}}" method="post" action=""> + <input type="hidden" name="target" value="{{$id}}"> + <input type="hidden" name="uri" value="{{$card.uri}}"> + <div class="section-content-wrapper-np"> + <div id="vcard-cancel-{{$card.id}}" class="vcard-cancel vcard-cancel-btn" data-id="{{$card.id}}" data-action="cancel"><i class="fa fa-close"></i></div> + <div id="vcard-add-field-{{$card.id}}" class="dropdown pull-right vcard-add-field"> + <button data-toggle="dropdown" type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle"><i class="fa fa-plus"></i> {{$add_field}}</button> + <div class="dropdown-menu dropdown-menu-right"> + <a class="dropdown-item add-vcard-org add-field"{{if $card.org}} style="display: none"{{/if}} href="#" data-add="vcard-org" data-id="{{$card.id}}">{{$org_label}}</a> + <a class="dropdown-item add-vcard-title add-field"{{if $card.title}} style="display: none"{{/if}} href="#" data-add="vcard-title" data-id="{{$card.id}}">{{$title_label}}</a> + <a class="dropdown-item add-vcard-tel add-field" href="#" data-add="vcard-tel" data-id="{{$card.id}}">{{$tel_label}}</a> + <a class="dropdown-item add-vcard-email add-field" href="#" data-add="vcard-email" data-id="{{$card.id}}">{{$email_label}}</a> + <a class="dropdown-item add-vcard-impp add-field" href="#" data-add="vcard-impp" data-id="{{$card.id}}">{{$impp_label}}</a> + <a class="dropdown-item add-vcard-url add-field" href="#" data-add="vcard-url" data-id="{{$card.id}}">{{$url_label}}</a> + <a class="dropdown-item add-vcard-adr add-field" href="#" data-add="vcard-adr" data-id="{{$card.id}}">{{$adr_label}}</a> + <a class="dropdown-item add-vcard-note add-field"{{if $card.note}} style="display: none"{{/if}} href="#" data-add="vcard-note" data-id="{{$card.id}}">{{$note_label}}</a> + </div> + </div> + <div id="vcard-header-{{$card.id}}" class="vcard-header" data-id="{{$card.id}}" data-action="open"> + {{if $card.photo}}<img class="vcard-photo" src="{{$card.photo}}" width="32px" height="32px">{{else}}<div class="vcard-nophoto"><i class="fa fa-user"></i></div>{{/if}} + <span id="vcard-preview-{{$card.id}}" class="vcard-preview"> + {{if $card.fn}}<span class="vcard-fn-preview">{{$card.fn}}</span>{{/if}} + {{if $card.emails.0.address}}<span class="vcard-email-preview hidden-xs">{{$card.emails.0.address}}</span>{{/if}} + {{if $card.tels.0}}<span class="vcard-tel-preview hidden-xs">{{$card.tels.0.nr}}</span>{{/if}} + </span> + <input id="vcard-fn-{{$card.id}}" class="vcard-fn" type="text" name="fn" value="{{$card.fn}}" size="{{$card.fn|count_characters:true}}" placeholder="{{$name_label}}"> + </div> + </div> + <div id="vcard-info-{{$card.id}}" class="vcard-info section-content-wrapper"> + + <div class="vcard-org form-group"> + <div class="form-vcard-org-wrapper"> + {{if $card.org}} + <div class="form-group form-vcard-org"> + <input type="text" name="org" value="{{$card.org}}" size="{{$card.org|count_characters:true}}" placeholder="{{$org_label}}"> + <i data-remove="vcard-org" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/if}} + </div> + </div> + + <div class="vcard-title form-group"> + <div class="form-vcard-title-wrapper"> + {{if $card.title}} + <div class="form-group form-vcard-title"> + <input type="text" name="title" value="{{$card.title}}" size="{{$card.title|count_characters:true}}" placeholder="{{$title_label}}"> + <i data-remove="vcard-title" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/if}} + </div> + </div> + + + <div class="vcard-tel form-group"> + <div class="form-vcard-tel-wrapper"> + {{if $card.tels}} + {{foreach $card.tels as $tel}} + <div class="form-group form-vcard-tel"> + <select name="tel_type[]"> + <option value=""{{if $tel.type.0 != 'CELL' && $tel.type.0 != 'HOME' && $tel.type.0 != 'WORK' && $tel.type.0 != 'OTHER'}} selected="selected"{{/if}}>{{$tel.type.1}}</option> + <option value="CELL"{{if $tel.type.0 == 'CELL'}} selected="selected"{{/if}}>{{$mobile}}</option> + <option value="HOME"{{if $tel.type.0 == 'HOME'}} selected="selected"{{/if}}>{{$home}}</option> + <option value="WORK"{{if $tel.type.0 == 'WORK'}} selected="selected"{{/if}}>{{$work}}</option> + <option value="OTHER"{{if $tel.type.0 == 'OTHER'}} selected="selected"{{/if}}>{{$other}}</option> + </select> + <input type="text" name="tel[]" value="{{$tel.nr}}" size="{{$tel.nr|count_characters:true}}" placeholder="{{$tel_label}}"> + <i data-remove="vcard-tel" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/foreach}} + {{/if}} + </div> + </div> + + + <div class="vcard-email form-group"> + <div class="form-vcard-email-wrapper"> + {{if $card.emails}} + {{foreach $card.emails as $email}} + <div class="form-group form-vcard-email"> + <select name="email_type[]"> + <option value=""{{if $email.type.0 != 'HOME' && $email.type.0 != 'WORK' && $email.type.0 != 'OTHER'}} selected="selected"{{/if}}>{{$email.type.1}}</option> + <option value="HOME"{{if $email.type.0 == 'HOME'}} selected="selected"{{/if}}>{{$home}}</option> + <option value="WORK"{{if $email.type.0 == 'WORK'}} selected="selected"{{/if}}>{{$work}}</option> + <option value="OTHER"{{if $email.type.0 == 'OTHER'}} selected="selected"{{/if}}>{{$other}}</option> + </select> + <input type="text" name="email[]" value="{{$email.address}}" size="{{$email.address|count_characters:true}}" placeholder="{{$email_label}}"> + <i data-remove="vcard-email" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/foreach}} + {{/if}} + </div> + </div> + + <div class="vcard-impp form-group"> + <div class="form-vcard-impp-wrapper"> + {{if $card.impps}} + {{foreach $card.impps as $impp}} + <div class="form-group form-vcard-impp"> + <select name="impp_type[]"> + <option value=""{{if $impp.type.0 != 'HOME' && $impp.type.0 != 'WORK' && $impp.type.0 != 'OTHER'}} selected="selected"{{/if}}>{{$impp.type.1}}</option> + <option value="HOME"{{if $impp.type.0 == 'HOME'}} selected="selected"{{/if}}>{{$home}}</option> + <option value="WORK"{{if $impp.type.0 == 'WORK'}} selected="selected"{{/if}}>{{$work}}</option> + <option value="OTHER"{{if $impp.type.0 == 'OTHER'}} selected="selected"{{/if}}>{{$other}}</option> + </select> + <input type="text" name="impp[]" value="{{$impp.address}}" size="{{$impp.address|count_characters:true}}" placeholder="{{$impp_label}}"> + <i data-remove="vcard-impp" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/foreach}} + {{/if}} + </div> + </div> + + <div class="vcard-url form-group"> + <div class="form-vcard-url-wrapper"> + {{if $card.urls}} + {{foreach $card.urls as $url}} + <div class="form-group form-vcard-url"> + <select name="url_type[]"> + <option value=""{{if $url.type.0 != 'HOME' && $url.type.0 != 'WORK' && $url.type.0 != 'OTHER'}} selected="selected"{{/if}}>{{$url.type.1}}</option> + <option value="HOME"{{if $url.type.0 == 'HOME'}} selected="selected"{{/if}}>{{$home}}</option> + <option value="WORK"{{if $url.type.0 == 'WORK'}} selected="selected"{{/if}}>{{$work}}</option> + <option value="OTHER"{{if $url.type.0 == 'OTHER'}} selected="selected"{{/if}}>{{$other}}</option> + </select> + <input type="text" name="url[]" value="{{$url.address}}" size="{{$url.address|count_characters:true}}" placeholder="{{$url_label}}"> + <i data-remove="vcard-url" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + {{/foreach}} + {{/if}} + </div> + </div> + + <div class="vcard-adr form-group"> + <div class="form-vcard-adr-wrapper"> + {{if $card.adrs}} + {{foreach $card.adrs as $adr}} + <div class="form-group form-vcard-adr"> + <div class="form-group"> + <label>{{$adr_label}}</label> + <select name="adr_type[]"> + <option value=""{{if $adr.type.0 != 'HOME' && $adr.type.0 != 'WORK' && $adr.type.0 != 'OTHER'}} selected="selected"{{/if}}>{{$adr.type.1}}</option> + <option value="HOME"{{if $adr.type.0 == 'HOME'}} selected="selected"{{/if}}>{{$home}}</option> + <option value="WORK"{{if $adr.type.0 == 'WORK'}} selected="selected"{{/if}}>{{$work}}</option> + <option value="OTHER"{{if $adr.type.0 == 'OTHER'}} selected="selected"{{/if}}>{{$other}}</option> + </select> + <i data-remove="vcard-adr" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.0}}" size="{{$adr.address.0|count_characters:true}}" placeholder="{{$po_box}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.1}}" size="{{$adr.address.1|count_characters:true}}" placeholder="{{$extra}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.2}}" size="{{$adr.address.2|count_characters:true}}" placeholder="{{$street}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.3}}" size="{{$adr.address.3|count_characters:true}}" placeholder="{{$locality}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.4}}" size="{{$adr.address.4|count_characters:true}}" placeholder="{{$region}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.5}}" size="{{$adr.address.5|count_characters:true}}" placeholder="{{$zip_code}}"> + </div> + <div class="form-group"> + <input type="text" name="adr[{{$adr@index}}][]" value="{{$adr.address.6}}" size="{{$adr.address.6|count_characters:true}}" placeholder="{{$country}}"> + </div> + </div> + {{/foreach}} + {{/if}} + </div> + </div> + + <div class="vcard-note form-group form-vcard-note"> + <div class="form-vcard-note-wrapper"> + {{if $card.note}} + <label>{{$note_label}}</label> + <i data-remove="vcard-note" data-id="{{$card.id}}" class="fa fa-trash-o remove-field drop-icons fakelink"></i> + <textarea name="note" class="form-control">{{$card.note}}</textarea> + {{/if}} + </div> + </div> + + + <button type="submit" name="update" value="update_card" class="btn btn-primary btn-sm pull-right">{{$update}}</button> + <button type="submit" name="delete" value="delete_card" class="btn btn-danger btn-sm">{{$delete}}</button> + <button type="button" class="btn btn-outline-secondary btn-sm vcard-cancel-btn" data-id="{{$card.id}}" data-action="cancel">{{$cancel}}</button> + <div class="clear"></div> + </div> + </form> + {{/foreach}} +</div> diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl new file mode 100644 index 000000000..5d683d751 --- /dev/null +++ b/view/tpl/cdav_calendar.tpl @@ -0,0 +1,349 @@ +<script> + +var new_event = []; +var new_event_id = Math.random().toString(36).substring(7); +var views = {'month' : '{{$month}}', 'agendaWeek' : '{{$week}}', 'agendaDay' : '{{$day}}', 'listMonth' : '{{$list_month}}', 'listWeek' : '{{$list_week}}', 'listDay' : '{{$list_day}}'}; + +$(document).ready(function() { + $('#calendar').fullCalendar({ + eventSources: [ {{$sources}} ], + + header: false, + eventTextColor: 'white', + + lang: '{{$lang}}', + firstDay: {{$first_day}}, + + monthNames: aStr['monthNames'], + monthNamesShort: aStr['monthNamesShort'], + dayNames: aStr['dayNames'], + dayNamesShort: aStr['dayNamesShort'], + allDayText: aStr['allday'], + + timeFormat: 'HH:mm', + timezone: 'local', + + defaultTimedEventDuration: '01:00:00', + snapDuration: '00:15:00', + + dayClick: function(date, jsEvent, view) { + + if(new_event.length) + $('#calendar').fullCalendar( 'removeEventSource', new_event); + + $('#event_uri').val(''); + $('#id_title').val('New event'); + $('#calendar_select').val($("#calendar_select option:first").val()).attr('disabled', false); + $('#id_dtstart').val(date.format()); + $('#id_dtend').val(date.hasTime() ? date.add(1, 'hours').format() : date.add(1, 'days').format()); + $('#id_description').val(''); + $('#id_location').val(''); + $('#event_submit').val('create_event').html('Create'); + $('#event_delete').hide(); + + new_event = [{ id: new_event_id, title : 'New event', start: $('#id_dtstart').val(), end: $('#id_dtend').val(), editable: true, color: '#bbb' }] + $('#calendar').fullCalendar( 'addEventSource', new_event); + }, + + eventClick: function(event, jsEvent, view) { + + if(event.id == new_event_id) { + $(window).scrollTop(0); + $('.section-content-tools-wrapper, #event_form_wrapper').show(); + $('#recurrence_warning').hide(); + $('#id_title').focus().val(''); + return false; + } + + if($('main').hasClass('fullscreen') && view.type !== 'month' && event.rw) + $('#calendar').fullCalendar('option', 'height', 'auto'); + + if(new_event.length && event.rw) { + $('#calendar').fullCalendar( 'removeEventSource', new_event); + } + + if(!event.recurrent && event.rw) { + var start_clone = moment(event.start); + var noend_allday = start_clone.add(1, 'day').format('YYYY-MM-DD'); + + $(window).scrollTop(0); + $('.section-content-tools-wrapper, #event_form_wrapper').show(); + $('#recurrence_warning').hide(); + $('#id_title').focus(); + + $('#event_uri').val(event.uri); + $('#id_title').val(event.title); + $('#calendar_select').val(event.calendar_id[0] + ':' + event.calendar_id[1]).attr('disabled', true); + $('#id_dtstart').val(event.start.format()); + $('#id_dtend').val(event.end ? event.end.format() : event.start.hasTime() ? '' : noend_allday); + $('#id_description').val(event.description); + $('#id_location').val(event.location); + $('#event_submit').val('update_event').html('Update'); + $('#event_delete').show(); + } + else if(event.recurrent && event.rw) { + $('.section-content-tools-wrapper, #recurrence_warning').show(); + $('#event_form_wrapper').hide(); + $('#event_uri').val(event.uri); + $('#calendar_select').val(event.calendar_id[0] + ':' + event.calendar_id[1]).attr('disabled', true); + } + }, + + eventResize: function(event, delta, revertFunc) { + + $('#id_title').val(event.title); + $('#id_dtstart').val(event.start.format()); + $('#id_dtend').val(event.end.format()); + + $.post( 'cdav/calendar', { + 'update': 'resize', + 'id[]': event.calendar_id, + 'uri': event.uri, + 'dtstart': event.start ? event.start.format() : '', + 'dtend': event.end ? event.end.format() : '' + }) + .fail(function() { + revertFunc(); + }); + }, + + eventDrop: function(event, delta, revertFunc) { + + var start_clone = moment(event.start); + var noend_allday = start_clone.add(1, 'day').format('YYYY-MM-DD'); + + $('#id_title').val(event.title); + $('#id_dtstart').val(event.start.format()); + $('#id_dtend').val(event.end ? event.end.format() : event.start.hasTime() ? '' : noend_allday); + + $.post( 'cdav/calendar', { + 'update': 'drop', + 'id[]': event.calendar_id, + 'uri': event.uri, + 'dtstart': event.start ? event.start.format() : '', + 'dtend': event.end ? event.end.format() : event.start.hasTime() ? '' : noend_allday + }) + .fail(function() { + revertFunc(); + }); + }, + + loading: function(isLoading, view) { + $('#events-spinner').spin('tiny'); + $('#events-spinner > i').css('color', 'transparent'); + if(!isLoading) { + $('#events-spinner').spin(false); + $('#events-spinner > i').css('color', ''); + } + } + }); + + // echo the title + var view = $('#calendar').fullCalendar('getView'); + + $('#title').text(view.title); + + $('#view_selector').html(views[view.name]); + + $('.color-edit').colorpicker({ input: '.color-edit-input' }); + + $(document).on('click','#fullscreen-btn', on_fullscreen); + $(document).on('click','#inline-btn', on_inline); + + $(document).on('click','#event_submit', on_submit); + $(document).on('click','#event_more', on_more); + $(document).on('click','#event_cancel, #event_cancel_recurrent', reset_form); + $(document).on('click','#event_delete, #event_delete_recurrent', on_delete); + +}); + +function changeView(action, viewName) { + $('#calendar').fullCalendar(action, viewName); + var view = $('#calendar').fullCalendar('getView'); + + if($('main').hasClass('fullscreen')) + if(view.name !== 'month') + $('.section-content-tools-wrapper').css('display') === 'none' ? on_fullscreen() : on_inline() ; + else + on_fullscreen(); + else + on_inline(); + + $('#title').text(view.title); + $('#view_selector').html(views[view.name]); +} + +function add_remove_json_source(source, color, editable, status) { + + if(status === undefined) + status = 'fa-calendar-check-o'; + + if(status === 'drop') { + reset_form(); + $('#calendar').fullCalendar( 'removeEventSource', source ); + return; + } + + var parts = source.split('/'); + var id = parts[4]; + + var selector = '#calendar-btn-' + id; + + if($(selector).hasClass('fa-calendar-o')) { + $('#calendar').fullCalendar( 'addEventSource', { url: source, color: color, editable: editable }); + $(selector).removeClass('fa-calendar-o'); + $(selector).addClass(status); + $.get('/cdav/calendar/switch/' + id + '/1'); + } + else { + $('#calendar').fullCalendar( 'removeEventSource', source ); + $(selector).removeClass(status); + $(selector).addClass('fa-calendar-o'); + $.get('/cdav/calendar/switch/' + id + '/0'); + } +} + +function on_fullscreen() { + var view = $('#calendar').fullCalendar('getView'); + if(($('.section-content-tools-wrapper').css('display') === 'none') || ($('.section-content-tools-wrapper').css('display') !== 'none' && view.type === 'month')) + $('#calendar').fullCalendar('option', 'height', $(window).height() - $('.section-title-wrapper').outerHeight(true) - 2); // -2 is for border width (.generic-content-wrapper top and bottom) of .generic-content-wrapper +} + +function on_inline() { + var view = $('#calendar').fullCalendar('getView'); + ((view.type === 'month') ? $('#calendar').fullCalendar('option', 'height', '') : $('#calendar').fullCalendar('option', 'height', 'auto')); +} + +function on_submit() { + $.post( 'cdav/calendar', { + 'submit': $('#event_submit').val(), + 'target': $('#calendar_select').val(), + 'uri': $('#event_uri').val(), + 'title': $('#id_title').val(), + 'dtstart': $('#id_dtstart').val(), + 'dtend': $('#id_dtend').val(), + 'description': $('#id_description').val(), + 'location': $('#id_location').val() + }) + .done(function() { + $('#calendar').fullCalendar( 'refetchEventSources', [ {{$sources}} ] ); + reset_form(); + }); +} + +function on_delete() { + $.post( 'cdav/calendar', { + 'delete': 'delete', + 'target': $('#calendar_select').val(), + 'uri': $('#event_uri').val(), + }) + .done(function() { + $('#calendar').fullCalendar( 'refetchEventSources', [ {{$sources}} ] ); + reset_form(); + }); +} + +function reset_form() { + $('.section-content-tools-wrapper, #event_form_wrapper, #recurrence_warning').hide(); + + $('#event_submit').val(''); + $('#calendar_select').val(''); + $('#event_uri').val(''); + $('#id_title').val(''); + $('#id_dtstart').val(''); + $('#id_dtend').val(''); + + if(new_event.length) + $('#calendar').fullCalendar( 'removeEventSource', new_event); + + if($('#more_block').hasClass('open')) + on_more(); + + if($('main').hasClass('fullscreen')) + on_fullscreen(); +} + +function on_more() { + if($('#more_block').hasClass('open')) { + $('#event_more').html('<i class="fa fa-caret-down"></i> {{$more}}'); + $('#more_block').removeClass('open').hide(); + } + else { + $('#event_more').html('<i class="fa fa-caret-up"></i> {{$less}}'); + $('#more_block').addClass('open').show(); + } +} + +</script> + +<div class="generic-content-wrapper"> + <div class="section-title-wrapper"> + <div class="float-right"> + <div class="dropdown"> + <button id="view_selector" type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown"></button> + <div class="dropdown-menu"> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'month'); return false;">{{$month}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'agendaWeek'); return false;">{{$week}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'agendaDay'); return false;">{{$day}}</a></li> + <div class="dropdown-divider"></div> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listMonth'); return false;">{{$list_month}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listWeek'); return false;">{{$list_week}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listDay'); return false;">{{$list_day}}</a></li> + </div> + <div class="btn-group"> + <button class="btn btn-outline-secondary btn-sm" onclick="changeView('prev', false);" title="{{$prev}}"><i class="fa fa-backward"></i></button> + <button id="events-spinner" class="btn btn-outline-secondary btn-sm" onclick="changeView('today', false);" title="{{$today}}"><i class="fa fa-bullseye"></i></button> + <button class="btn btn-outline-secondary btn-sm" onclick="changeView('next', false);" title="{{$next}}"><i class="fa fa-forward"></i></button> + </div> + <button id="fullscreen-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button> + <button id="inline-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button> + </div> + </div> + <h2 id="title"></h2> + <div class="clear"></div> + </div> + <div class="section-content-tools-wrapper" style="display: none"> + <div id="recurrence_warning" style="display: none"> + <div class="section-content-warning-wrapper"> + {{$recurrence_warning}} + </div> + <div> + <button id="event_delete_recurrent" type="button" class="btn btn-danger btn-sm">{{$delete_all}}</button> + <button id="event_cancel_recurrent" type="button" class="btn btn-outline-secondary btn-sm">{{$cancel}}</button> + </div> + </div> + <div id="event_form_wrapper" style="display: none"> + <form id="event_form" method="post" action=""> + <input id="event_uri" type="hidden" name="uri" value=""> + {{include file="field_input.tpl" field=$title}} + <label for="calendar_select">{{$calendar_select_label}}</label> + <select id="calendar_select" name="target" class="form-control form-group"> + {{foreach $writable_calendars as $writable_calendar}} + <option value="{{$writable_calendar.id.0}}:{{$writable_calendar.id.1}}">{{$writable_calendar.displayname}}{{if $writable_calendar.sharer}} ({{$writable_calendar.sharer}}){{/if}}</option> + {{/foreach}} + </select> + <div id="more_block" style="display: none;"> + {{include file="field_input.tpl" field=$dtstart}} + {{include file="field_input.tpl" field=$dtend}} + {{include file="field_textarea.tpl" field=$description}} + {{include file="field_textarea.tpl" field=$location}} + </div> + <div class="form-group"> + <div class="pull-right"> + <button id="event_more" type="button" class="btn btn-outline-secondary btn-sm"><i class="fa fa-caret-down"></i> {{$more}}</button> + <button id="event_submit" type="button" value="" class="btn btn-primary btn-sm"></button> + + </div> + <div> + <button id="event_delete" type="button" class="btn btn-danger btn-sm">{{$delete}}</button> + <button id="event_cancel" type="button" class="btn btn-outline-secondary btn-sm">{{$cancel}}</button> + </div> + <div class="clear"></div> + </div> + </form> + </div> + </div> + <div class="section-content-wrapper-np"> + <div id="calendar"></div> + </div> +</div> diff --git a/view/tpl/cdav_widget_addressbook.tpl b/view/tpl/cdav_widget_addressbook.tpl new file mode 100644 index 000000000..c875dc977 --- /dev/null +++ b/view/tpl/cdav_widget_addressbook.tpl @@ -0,0 +1,66 @@ +<div class="widget"> + <h3>{{$addressbooks_label}}</h3> + {{foreach $addressbooks as $addressbook}} + <div id="addressbook-{{$addressbook.id}}" class="ml-3"> + <div class="form-group"> + <i class="fa fa-user generic-icons"></i><a href="/cdav/addressbook/{{$addressbook.id}}">{{$addressbook.displayname}}</a> + <div class="float-right"> + <i id="edit-icon" class="fa fa-pencil fakelink generic-icons" onclick="openClose('edit-addressbook-{{$addressbook.id}}')"></i> + <a href="/cdav/addressbooks/{{$addressbook.ownernick}}/{{$addressbook.uri}}/?export"><i id="download-icon" class="fa fa-cloud-download fakelink generic-icons"></i></a> + <a href="#" onclick="dropItem('/cdav/addressbook/drop/{{$addressbook.id}}', '#addressbook-{{$addressbook.id}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a> + </div> + </div> + <div id="edit-addressbook-{{$addressbook.id}}" class="sub-menu" style="display: none;"> + <form id="edit-addressbook-{{$addressbook.id}}" method="post" action=""> + <label for="edit-{{$addressbook.id}}">{{$edit_label}}</label> + <div id="edit-form-{{$addressbook.id}}" class="form-group"> + <input id="id-{{$addressbook.id}}" name="id" type="hidden" value="{{$addressbook.id}}"> + <input id="edit-{{$addressbook.id}}" name="{DAV:}displayname" type="text" value="{{$addressbook.displayname}}" class="form-control"> + </div> + <div class="form-group"> + <button type="submit" name="edit" value="edit" class="btn btn-primary btn-sm">{{$edit}}</button> + </div> + </form> + </div> + </div> + {{/foreach}} +</div> + +<div class="widget"> + <h3>{{$tools_label}}</h3> + <ul class="nav nav-pills flex-column"> + <li class="nav-item"> + <a class="nav-link" href="#" onclick="openClose('create-addressbook'); return false;"><i class="fa fa-user-plus generic-icons"></i> {{$create_label}}</a> + </li> + <div id="create-addressbook" class="sub-menu-wrapper"> + <div class="sub-menu"> + <form method="post" action=""> + <div class="form-group"> + <input id="create" name="{DAV:}displayname" type="text" placeholder="{{$create_placeholder}}" class="form-control form-group"> + <button type="submit" name="create" value="create" class="btn btn-primary btn-sm">{{$create}}</button> + </div> + </form> + </div> + </div> + <li class="nav-item"> + <a class="nav-link" href="#" onclick="openClose('upload-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> + </li> + <div id="upload-form" class="sub-menu-wrapper"> + <div class="sub-menu"> + <div class="form-group"> + <select id="import" name="target" class="form-control"> + <option value="">{{$import_placeholder}}</option> + {{foreach $addressbooks as $addressbook}} + <option value="{{$addressbook.id}}">{{$addressbook.displayname}}</option> + {{/foreach}} + </select> + </div> + <div class="form-group"> + <input class="form-control-file w-100" id="addressbook-upload-choose" type="file" name="userfile" /> + </div> + <button class="btn btn-primary btn-sm" type="submit" name="a_upload" value="a_upload">{{$upload}}</button> + </form> + </div> + </div> + </ul> +</div> diff --git a/view/tpl/cdav_widget_calendar.tpl b/view/tpl/cdav_widget_calendar.tpl new file mode 100644 index 000000000..ec2257a19 --- /dev/null +++ b/view/tpl/cdav_widget_calendar.tpl @@ -0,0 +1,121 @@ +{{if $my_calendars}} +<div class="widget"> + <h3>{{$my_calendars_label}}</h3> + {{foreach $my_calendars as $calendar}} + <div id="calendar-{{$calendar.calendarid}}"> + <div class="ml-3{{if !$calendar@last}} form-group{{/if}}"> + <i id="calendar-btn-{{$calendar.calendarid}}" class="fa {{if $calendar.switch}}fa-calendar-check-o{{else}}fa-calendar-o{{/if}} generic-icons fakelink" onclick="add_remove_json_source('{{$calendar.json_source}}', '{{$calendar.color}}', {{$calendar.editable}})" style="color: {{$calendar.color}};"></i>{{$calendar.displayname}} + <div class="float-right"> + <i id="edit-icon" class="fa fa-pencil fakelink generic-icons" onclick="openClose('edit-calendar-{{$calendar.calendarid}}')"></i> + <a href="/cdav/calendars/{{$calendar.ownernick}}/{{$calendar.uri}}/?export"><i id="download-icon" class="fa fa-cloud-download fakelink generic-icons"></i></a> + <i id="share-icon" class="fa fa-share-alt fakelink generic-icons" onclick="openClose('share-calendar-{{$calendar.calendarid}}')"></i> + <a href="#" onclick="var drop = dropItem('/cdav/calendar/drop/{{$calendar.calendarid}}/{{$calendar.instanceid}}', '#calendar-{{$calendar.calendarid}}'); if(drop) { add_remove_json_source('{{$calendar.json_source}}', '{{$calendar.color}}', {{$calendar.editable}}, 'drop'); } return false;"><i class="fa fa-trash-o drop-icons"></i></a> + </div> + <div id="share-calendar-{{$calendar.calendarid}}" class="sub-menu" style="display: none; border-color: {{$calendar.color}};"> + {{if $calendar.sharees}} + {{foreach $calendar.sharees as $sharee}} + <div id="sharee-{{$calendar.calendarid}}" class="form-group"> + <i class="fa fa-share generic-icons"></i>{{$sharee.name}} {{$sharee.access}} + <div class="pull-right"> + <a href="#" onclick="dropItem('/cdav/calendar/dropsharee/{{$calendar.calendarid}}/{{$calendar.instanceid}}/{{$sharee.hash}}', '#sharee-{{$calendar.calendarid}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a> + </div> + </div> + {{/foreach}} + {{/if}} + <form method="post" action=""> + <label for="share-{{$calendar.calendarid}}">{{$share_label}}</label> + <input name="calendarid" type="hidden" value="{{$calendar.calendarid}}"> + <input name="instanceid" type="hidden" value="{{$calendar.instanceid}}"> + <div class="form-group"> + <select id="share-{{$calendar.calendarid}}" name="sharee" class="form-control"> + {{$sharee_options}} + </select> + </div> + <div class="form-group"> + <select name="access" class="form-control"> + {{$access_options}} + </select> + </div> + <div class="form-group"> + <button type="submit" name="share" value="share" class="btn btn-primary btn-sm">{{$share}}</button> + </div> + </form> + </div> + <div id="edit-calendar-{{$calendar.calendarid}}" class="sub-menu" style="display: none; border-color: {{$calendar.color}};"> + <form id="edit-calendar-{{$calendar.calendarid}}" method="post" action="" class="colorpicker-component color-edit"> + <input id="id-{{$calendar.calendarid}}" name="id" type="hidden" value="{{$calendar.calendarid}}:{{$calendar.instanceid}}"> + <input id="color-{{$calendar.calendarid}}" name="color" type="hidden" value="{{$calendar.color}}" class="color-edit-input"> + <label for="edit-form-{{$calendar.calendarid}}">{{$edit_label}}</label> + <div id="edit-form-{{$calendar.calendarid}}" class="input-group form-group"> + <input id="create-{{$calendar.calendarid}}" name="{DAV:}displayname" type="text" value="{{$calendar.displayname}}" class="form-control"> + <span class="input-group-addon"><i></i></span> + </div> + <div class="form-group"> + <button type="submit" name="edit" value="edit" class="btn btn-primary btn-sm">{{$edit}}</button> + </div> + </form> + </div> + </div> + </div> + {{/foreach}} +</div> +{{/if}} + +{{if $shared_calendars}} +<div class="widget"> + <h3>{{$shared_calendars_label}}</h3> + {{foreach $shared_calendars as $calendar}} + <div id="shared-calendar-{{$calendar.calendarid}}" class="ml-3{{if !$calendar@last}} form-group{{/if}}"> + <i id="calendar-btn-{{$calendar.calendarid}}" class="fa {{if $calendar.switch}}{{if $calendar.access == 'read-write'}}fa-calendar-check-o{{else}}fa-calendar-times-o{{/if}}{{else}}fa-calendar-o{{/if}} generic-icons fakelink" onclick="add_remove_json_source('{{$calendar.json_source}}', '{{$calendar.color}}', {{$calendar.editable}}, {{if $calendar.access == 'read-write'}}'fa-calendar-check-o'{{else}}'fa-calendar-times-o'{{/if}})" style="color: {{$calendar.color}};"></i>{{$calendar.displayname}} ({{$calendar.sharer}}) + <div class="pull-right"> + <a href="/cdav/calendars/{{$calendar.ownernick}}/{{$calendar.uri}}/?export"><i id="download-icon" class="fa fa-cloud-download fakelink generic-icons"></i></a> + <a href="#" onclick="var drop = dropItem('/cdav/calendar/drop/{{$calendar.calendarid}}/{{$calendar.instanceid}}', '#shared-calendar-{{$calendar.calendarid}}'); if(drop) { add_remove_json_source('{{$calendar.json_source}}', '{{$calendar.color}}', {{$calendar.editable}}, 'drop'); } return false;"><i class="fa fa-trash-o drop-icons"></i></a> + </div> + </div> + {{/foreach}} +</div> +{{/if}} + +<div class="widget"> + <h3>{{$tools_label}}</h3> + <div class="nav nav-pills flex-column"> + <li class="nav-item"> + <a class="nav-link" href="#" onclick="openClose('create-calendar'); return false;"><i class="fa fa-calendar-plus-o generic-icons"></i> {{$create_label}}</a> + </li> + <div id="create-calendar" class="sub-menu-wrapper"> + <div class="sub-menu"> + <form method="post" action="" class="colorpicker-component color-edit"> + <input id="color" name="color" type="hidden" value="#3a87ad" class="color-edit-input"> + <div id="create-form" class="input-group form-group"> + <input id="create" name="{DAV:}displayname" type="text" placeholder="{{$create_placeholder}}" class="form-control"> + <span class="input-group-addon"><i></i></span> + </div> + <div class="form-group"> + <button type="submit" name="create" value="create" class="btn btn-primary btn-sm">{{$create}}</button> + </div> + </form> + </div> + </div> + <li class="nav-item"> + <a class="nav-link" href="#" onclick="openClose('upload-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> + </li> + <div id="upload-form" class="sub-menu-wrapper"> + <div class="sub-menu"> + <form enctype="multipart/form-data" method="post" action=""> + <div class="form-group"> + <select id="import" name="target" class="form-control"> + <option value="">{{$import_placeholder}}</option> + {{foreach $writable_calendars as $writable_calendar}} + <option value="{{$writable_calendar.id.0}}:{{$writable_calendar.id.1}}">{{$writable_calendar.displayname}}</option> + {{/foreach}} + </select> + </div> + <div class="form-group"> + <input class="form-control-file w-100" id="event-upload-choose" type="file" name="userfile" /> + </div> + <button class="btn btn-primary btn-sm" type="submit" name="c_upload" value="c_upload">{{$upload}}</button> + </form> + </div> + </div> + </div> +</div> |