$('#edit_name').click(function(){Contacts.UI.Card.editName()});
$('#edit_name').keydown(function(){Contacts.UI.Card.editName()});
+ $('#phototools li a').click(function() {
+ $(this).tipsy('hide');
+ });
+ $('#contacts_details_photo_wrapper').hover(
+ function () {
+ $('#phototools').slideDown(200);
+ },
+ function () {
+ $('#phototools').slideUp(200);
+ }
+ );
+ $('#phototools').hover(
+ function () {
+ $(this).removeClass('transparent');
+ },
+ function () {
+ $(this).addClass('transparent');
+ }
+ );
+ $('#phototools .upload').click(function() {
+ $('#file_upload_start').trigger('click');
+ });
+ $('#phototools .cloud').click(function() {
+ OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true);
+ });
/* Initialize the photo edit dialog */
$('#edit_photo_dialog').dialog({
autoOpen: false, modal: true, height: 'auto', width: 'auto'
loadPhotoHandlers:function(){
$('#phototools li a').tipsy('hide');
$('#phototools li a').tipsy();
- $('#phototools li a').click(function() {
- $(this).tipsy('hide');
- });
- $('#contacts_details_photo_wrapper').hover(
- function () {
- $('#phototools').slideDown(200);
- },
- function () {
- $('#phototools').slideUp(200);
- }
- );
- $('#phototools').hover(
- function () {
- $(this).removeClass('transparent');
- },
- function () {
- $(this).addClass('transparent');
- }
- );
if(this.data.PHOTO) {
$('#phototools .delete').click(function() {
$(this).tipsy('hide');
$(this).tipsy('hide');
Contacts.UI.Card.editCurrentPhoto();
});
+ $('#phototools .delete').show();
+ $('#phototools .edit').show();
} else {
$('#phototools .delete').hide();
$('#phototools .edit').hide();
}
- $('#phototools .upload').click(function() {
- $('#file_upload_start').trigger('click');
- });
- $('#phototools .cloud').click(function() {
- OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true);
- });
},
cloudPhotoSelected:function(path){
$.getJSON(OC.filePath('contacts', 'ajax', 'oc_photo.php'),{'path':path,'id':Contacts.UI.Card.id},function(jsondata){
});
},
loadPhoto:function(refresh){
+ var self = this;
+ var refreshstr = (refresh?'&refresh=1'+Math.random():'')
$('#phototools li a').tipsy('hide');
var wrapper = $('#contacts_details_photo_wrapper');
- wrapper.addClass('wait');
+ wrapper.addClass('loading').addClass('wait');
+
+ var img = new Image();
+ $(img).load(function () {
+ $('img.contacts_details_photo').remove()
+ $(this).addClass('contacts_details_photo').hide();
+ wrapper.removeClass('loading').removeClass('wait');
+ $(this).insertAfter($('#phototools')).fadeIn();
+ }).error(function () {
+ // notify the user that the image could not be loaded
+ $(t('contacts','something went wrong.')).insertAfter($('#phototools'));
+ }).attr('src', OC.linkTo('contacts', 'photo.php')+'?id='+self.id+refreshstr);
+
$.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum);
- wrapper.html(jsondata.data.page).ready(function(){ wrapper.removeClass('wait').tipsy() });
Contacts.UI.Card.loadPhotoHandlers();
}
else{
- wrapper.removeClass('wait');
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
$('#file_upload_form').show();
- $('#contacts_propertymenu_dropdown a[data-type="PHOTO"]').parent().hide();
},
editCurrentPhoto:function(){
$.getJSON(OC.filePath('contacts', 'ajax', 'currentphoto.php'),{'id':this.id},function(jsondata){
var target = $('#crop_target');
var form = $('#cropform');
var wrapper = $('#contacts_details_photo_wrapper');
+ var self = this;
wrapper.addClass('wait');
form.submit();
target.load(function(){
var response=jQuery.parseJSON(target.contents().text());
if(response != undefined && response.status == 'success'){
// load cropped photo.
- wrapper.html(response.data.page).ready(function(){ wrapper.removeClass('wait') });
+ self.loadPhoto(true);
Contacts.UI.Card.data.PHOTO = true;
- Contacts.UI.Card.loadPhotoHandlers();
}else{
OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
wrapper.removeClass('wait');
<iframe name="file_upload_target" id='file_upload_target' src=""></iframe>
<div class="tip propertycontainer" id="contacts_details_photo_wrapper" title="<?php echo $l->t('Drop photo to upload'); ?> (max <?php echo $_['uploadMaxHumanFilesize']; ?>)" data-element="PHOTO">
+ <ul id="phototools" class="transparent hidden">
+ <li><a class="svg delete" title="<?php echo $l->t('Delete current photo'); ?>"></a></li>
+ <li><a class="svg edit" title="<?php echo $l->t('Edit current photo'); ?>"></a></li>
+ <li><a class="svg upload" title="<?php echo $l->t('Upload new photo'); ?>"></a></li>
+ <li><a class="svg cloud" title="<?php echo $l->t('Select photo from ownCloud'); ?>"></a></li>
+ </ul>
</div>
+ <img />
</div> <!-- contact_photo -->
<div id="contact_identity" class="contactsection">
<div id="contacts_propertymenu">
<button class="button" id="contacts_propertymenu_button"><?php echo $l->t('Add field'); ?></button>
<ul id="contacts_propertymenu_dropdown" role="menu" class="hidden">
- <li><a role="menuitem" data-type="PHOTO"><?php echo $l->t('Profile picture'); ?></a></li>
<li><a role="menuitem" data-type="ORG"><?php echo $l->t('Organization'); ?></a></li>
<li><a role="menuitem" data-type="NICKNAME"><?php echo $l->t('Nickname'); ?></a></li>
<li><a role="menuitem" data-type="BDAY"><?php echo $l->t('Birthday'); ?></a></li>