mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-02-07 01:54:16 +01:00
Scrutinizer JS fixes
This commit is contained in:
parent
8cbfec3b0a
commit
20e5d876fa
20
js/app.js
20
js/app.js
@ -1311,17 +1311,17 @@ OC.Contacts = OC.Contacts || {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: t('contacts', 'Cancel'),
|
text: t('contacts', 'Cancel'),
|
||||||
click:function(dlg) {
|
click:function() {
|
||||||
$(this).ocdialog('close');
|
$(this).ocdialog('close');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
close: function(event, ui) {
|
close: function(/*event, ui*/) {
|
||||||
$(this).ocdialog('destroy').remove();
|
$(this).ocdialog('destroy').remove();
|
||||||
$('#add_group_dialog').remove();
|
$('#add_group_dialog').remove();
|
||||||
},
|
},
|
||||||
open: function(event, ui) {
|
open: function(/*event, ui*/) {
|
||||||
$dlg.find('input').focus();
|
$dlg.find('input').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1364,18 +1364,18 @@ OC.Contacts = OC.Contacts || {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: t('contacts', 'Cancel'),
|
text: t('contacts', 'Cancel'),
|
||||||
click:function(dlg) {
|
click:function() {
|
||||||
$(this).ocdialog('close');
|
$(this).ocdialog('close');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
close: function(event, ui) {
|
close: function(/*event, ui*/) {
|
||||||
$(this).ocdialog('destroy').remove();
|
$(this).ocdialog('destroy').remove();
|
||||||
$('#add_group_dialog').remove();
|
$('#add_group_dialog').remove();
|
||||||
self.$contactList.removeClass('dim');
|
self.$contactList.removeClass('dim');
|
||||||
},
|
},
|
||||||
open: function(event, ui) {
|
open: function(/*event, ui*/) {
|
||||||
$dlg.find('input').focus();
|
$dlg.find('input').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1465,14 +1465,13 @@ OC.Contacts = OC.Contacts || {
|
|||||||
},
|
},
|
||||||
uploadPhoto:function(filelist) {
|
uploadPhoto:function(filelist) {
|
||||||
console.log('uploadPhoto');
|
console.log('uploadPhoto');
|
||||||
var self = this;
|
|
||||||
if(!filelist) {
|
if(!filelist) {
|
||||||
$(document).trigger('status.contacts.error', {message:t('contacts','No files selected for upload.')});
|
$(document).trigger('status.contacts.error', {message:t('contacts','No files selected for upload.')});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var file = filelist[0];
|
var file = filelist[0];
|
||||||
var form = $('#file_upload_form');
|
var form = $('#file_upload_form');
|
||||||
var totalSize=0;
|
|
||||||
if(file.size > $('#max_upload').val()) {
|
if(file.size > $('#max_upload').val()) {
|
||||||
$(document).trigger('status.contacts.error', {
|
$(document).trigger('status.contacts.error', {
|
||||||
message:t(
|
message:t(
|
||||||
@ -1518,7 +1517,6 @@ OC.Contacts = OC.Contacts || {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
editPhoto:function(metadata, tmpkey) {
|
editPhoto:function(metadata, tmpkey) {
|
||||||
var $x, $y, $w, $h;
|
|
||||||
console.log('editPhoto', metadata, tmpkey);
|
console.log('editPhoto', metadata, tmpkey);
|
||||||
$('.tipsy').remove();
|
$('.tipsy').remove();
|
||||||
// Simple event handler, called from onChange and onSelect
|
// Simple event handler, called from onChange and onSelect
|
||||||
@ -1591,11 +1589,11 @@ OC.Contacts = OC.Contacts || {
|
|||||||
defaultButton: true
|
defaultButton: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
close: function(event, ui) {
|
close: function(/*event, ui*/) {
|
||||||
$(this).ocdialog('destroy').remove();
|
$(this).ocdialog('destroy').remove();
|
||||||
$container.remove();
|
$container.remove();
|
||||||
},
|
},
|
||||||
open: function(event, ui) {
|
open: function(/*event, ui*/) {
|
||||||
showCoords({x:x,y:y,w:w-10,h:h-10});
|
showCoords({x:x,y:y,w:w-10,h:h-10});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
172
js/contacts.js
172
js/contacts.js
@ -446,9 +446,9 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setAsSaving(this.$fullelem, true);
|
this.setAsSaving(this.$fullelem, true);
|
||||||
var data = JSON.stringify(this.data);
|
|
||||||
//console.log('stringified', data);
|
|
||||||
$.when(this.storage.saveAllProperties(this.metadata.backend, this.metadata.parent, this.id, {data:this.data}))
|
$.when(this.storage.saveAllProperties(this.metadata.backend, this.metadata.parent, this.id, {data:this.data}))
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if(!response.error) {
|
if(!response.error) {
|
||||||
@ -497,6 +497,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
var obj = null;
|
var obj = null;
|
||||||
var element = null;
|
var element = null;
|
||||||
var args = [];
|
var args = [];
|
||||||
|
|
||||||
if(params.obj) {
|
if(params.obj) {
|
||||||
obj = params.obj;
|
obj = params.obj;
|
||||||
args = this.argumentsFor(obj);
|
args = this.argumentsFor(obj);
|
||||||
@ -505,10 +506,8 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
} else {
|
} else {
|
||||||
args = params;
|
args = params;
|
||||||
element = params.name;
|
element = params.name;
|
||||||
var value = utils.isArray(params.value)
|
|
||||||
? $.param(params.value)
|
|
||||||
: encodeURIComponent(params.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!args) {
|
if(!args) {
|
||||||
console.log('No arguments. returning');
|
console.log('No arguments. returning');
|
||||||
return false;
|
return false;
|
||||||
@ -594,6 +593,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
self.data.FN = [{name:'FN', value:'', parameters:[]}];
|
self.data.FN = [{name:'FN', value:'', parameters:[]}];
|
||||||
}
|
}
|
||||||
self.data.FN[0]['value'] = value;
|
self.data.FN[0]['value'] = value;
|
||||||
|
// Used for sorting list elements
|
||||||
self.displayNames.fn = value;
|
self.displayNames.fn = value;
|
||||||
var nempty = true;
|
var nempty = true;
|
||||||
if(!self.data.N) {
|
if(!self.data.N) {
|
||||||
@ -625,17 +625,19 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
if(!utils.isArray(value)) {
|
if(!utils.isArray(value)) {
|
||||||
value = value.split(';');
|
|
||||||
// Then it is auto-generated from FN.
|
// Then it is auto-generated from FN.
|
||||||
var $nelems = self.$fullelem.find('.n.editor input');
|
value = value.split(';');
|
||||||
|
|
||||||
$.each(value, function(idx, val) {
|
$.each(value, function(idx, val) {
|
||||||
self.$fullelem.find('#n_' + idx).val(val).get(0).defaultValue = val;
|
self.$fullelem.find('#n_' + idx).val(val).get(0).defaultValue = val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.displayNames.fl = value.slice(0, 2).reverse().join(' ');
|
|
||||||
|
|
||||||
|
// Used for sorting list elements
|
||||||
|
self.displayNames.fl = value.slice(0, 2).reverse().join(' ');
|
||||||
self.displayNames.lf = value.slice(0, 2).join(', ').trim();
|
self.displayNames.lf = value.slice(0, 2).join(', ').trim();
|
||||||
var $fullname = self.$fullelem.find('.fullname'), fullname = '';
|
|
||||||
|
var $fullname = self.$fullelem.find('.fullname');
|
||||||
var update_fn = false;
|
var update_fn = false;
|
||||||
if(!self.data.FN) {
|
if(!self.data.FN) {
|
||||||
self.data.FN = [{name:'FN', value:'', parameters:[]}];
|
self.data.FN = [{name:'FN', value:'', parameters:[]}];
|
||||||
@ -859,36 +861,36 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
console.log('Contact.argumentsFor', $(obj));
|
console.log('Contact.argumentsFor', $(obj));
|
||||||
var args = {};
|
var args = {};
|
||||||
var ptype = this.propertyTypeFor(obj);
|
var ptype = this.propertyTypeFor(obj);
|
||||||
args['name'] = ptype;
|
args.name = ptype;
|
||||||
|
|
||||||
if(this.multi_properties.indexOf(ptype) !== -1) {
|
if(this.multi_properties.indexOf(ptype) !== -1) {
|
||||||
args['checksum'] = this.checksumFor(obj);
|
args.checksum = this.checksumFor(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($(obj).hasClass('propertycontainer')) {
|
if($(obj).hasClass('propertycontainer')) {
|
||||||
if($(obj).is('select[data-element="categories"]')) {
|
if($(obj).is('select[data-element="categories"]')) {
|
||||||
args['value'] = [];
|
args.value = [];
|
||||||
$.each($(obj).find(':selected'), function(idx, e) {
|
$.each($(obj).find(':selected'), function(idx, e) {
|
||||||
args['value'].push($(e).text());
|
args.value.push($(e).text());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
args['value'] = $(obj).val();
|
args.value = $(obj).val();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var $elements = this.propertyContainerFor(obj)
|
var $elements = this.propertyContainerFor(obj)
|
||||||
.find('input.value,select.value,textarea.value');
|
.find('input.value,select.value,textarea.value');
|
||||||
if($elements.length > 1) {
|
if($elements.length > 1) {
|
||||||
args['value'] = [];
|
args.value = [];
|
||||||
$.each($elements, function(idx, e) {
|
$.each($elements, function(idx, e) {
|
||||||
args['value'][parseInt($(e).attr('name').substr(6,1))] = $(e).val();
|
args.value[parseInt($(e).attr('name').substr(6,1))] = $(e).val();
|
||||||
//args['value'].push($(e).val());
|
//args['value'].push($(e).val());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var value = $elements.val();
|
var value = $elements.val();
|
||||||
switch(args['name']) {
|
switch(args.name) {
|
||||||
case 'BDAY':
|
case 'BDAY':
|
||||||
try {
|
try {
|
||||||
args['value'] = $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate(datepickerFormatDate, value));
|
args.value = $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate(datepickerFormatDate, value));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
$(document).trigger(
|
$(document).trigger(
|
||||||
'status.contacts.error',
|
'status.contacts.error',
|
||||||
@ -898,12 +900,12 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
args['value'] = value;
|
args.value = value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args['parameters'] = this.parametersFor(obj);
|
args.parameters = this.parametersFor(obj);
|
||||||
console.log('Contact.argumentsFor', args);
|
console.log('Contact.argumentsFor', args);
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
@ -970,8 +972,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
Contact.prototype.parametersFor = function(obj, asText) {
|
Contact.prototype.parametersFor = function(obj, asText) {
|
||||||
var parameters = {};
|
var parameters = {};
|
||||||
$.each(this.propertyContainerFor(obj)
|
$.each(this.propertyContainerFor(obj)
|
||||||
.find('select.parameter,input:checkbox:checked.parameter'),
|
.find('select.parameter,input:checkbox:checked.parameter'), function(i, elem) {
|
||||||
function(i, elem) {
|
|
||||||
var $elem = $(elem);
|
var $elem = $(elem);
|
||||||
var paramname = $elem.data('parameter');
|
var paramname = $elem.data('parameter');
|
||||||
if(!parameters[paramname]) {
|
if(!parameters[paramname]) {
|
||||||
@ -1014,7 +1015,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
this.setThumbnail(this.$dragelem);
|
this.setThumbnail(this.$dragelem);
|
||||||
return this.$dragelem;
|
return this.$dragelem;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the list item
|
* Render the list item
|
||||||
@ -1061,7 +1062,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
cursor: 'move',
|
cursor: 'move',
|
||||||
distance: 10,
|
distance: 10,
|
||||||
revert: 'invalid',
|
revert: 'invalid',
|
||||||
helper: function (e,ui) {
|
helper: function(/*event, ui*/) {
|
||||||
return self.renderDragItem().appendTo('body');
|
return self.renderDragItem().appendTo('body');
|
||||||
},
|
},
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
@ -1101,7 +1102,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
});
|
});
|
||||||
self.$groupSelect.bind('multiselectclick', function(event, ui) {
|
self.$groupSelect.bind('multiselectclick', function(event, ui) {
|
||||||
var action = ui.checked ? 'addtogroup' : 'removefromgroup';
|
var action = ui.checked ? 'addtogroup' : 'removefromgroup';
|
||||||
console.assert(typeof self.id === 'string', 'ID is not a string')
|
console.assert(typeof self.id === 'string', 'ID is not a string');
|
||||||
$(document).trigger('request.contact.' + action, {
|
$(document).trigger('request.contact.' + action, {
|
||||||
id: self.id,
|
id: self.id,
|
||||||
groupid: parseInt(ui.value)
|
groupid: parseInt(ui.value)
|
||||||
@ -1189,7 +1190,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
org: this.getPreferredValue('ORG', []).clean('').join(', '), // TODO Add parts if more than one.
|
org: this.getPreferredValue('ORG', []).clean('').join(', '), // TODO Add parts if more than one.
|
||||||
bday: bday,
|
bday: bday,
|
||||||
note: this.getPreferredValue('NOTE', '')
|
note: this.getPreferredValue('NOTE', '')
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
values = {id:'', favorite:'', name:'', nickname:'', title:'', org:'', bday:'', note:'', n0:'', n1:'', n2:'', n3:'', n4:''};
|
values = {id:'', favorite:'', name:'', nickname:'', title:'', org:'', bday:'', note:'', n0:'', n1:'', n2:'', n3:'', n4:''};
|
||||||
}
|
}
|
||||||
@ -1219,8 +1220,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$addMenu = this.$fullelem.find('#addproperty');
|
this.$addMenu = this.$fullelem.find('#addproperty');
|
||||||
this.$addMenu.on('change', function(event) {
|
this.$addMenu.on('change', function(/*event*/) {
|
||||||
//console.log('add', $(this).val());
|
|
||||||
var $opt = $(this).find('option:selected');
|
var $opt = $(this).find('option:selected');
|
||||||
self.addProperty($opt, $(this).val());
|
self.addProperty($opt, $(this).val());
|
||||||
$(this).val('');
|
$(this).val('');
|
||||||
@ -1240,7 +1240,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$(this).css('opacity', '0');
|
$(this).css('opacity', '0');
|
||||||
var $editor = $(this).next('.n.editor').first();
|
var $editor = $(this).next('.n.editor').first();
|
||||||
var bodyListener = function(e) {
|
var bodyListener = function(e) {
|
||||||
if($editor.find($(e.target)).length == 0) {
|
if($editor.find($(e.target)).length === 0) {
|
||||||
$editor.toggle('blind');
|
$editor.toggle('blind');
|
||||||
$('body').unbind('click', bodyListener);
|
$('body').unbind('click', bodyListener);
|
||||||
}
|
}
|
||||||
@ -1402,20 +1402,23 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
//console.log('$property', $property);
|
//console.log('$property', $property);
|
||||||
var meta = [];
|
var meta = [];
|
||||||
if(property.label) {
|
if(property.label) {
|
||||||
if(!property.parameters['TYPE']) {
|
if(!property.parameters.TYPE) {
|
||||||
property.parameters['TYPE'] = [];
|
property.parameters.TYPE = [];
|
||||||
}
|
}
|
||||||
property.parameters['TYPE'].push(property.label);
|
property.parameters.TYPE.push(property.label);
|
||||||
meta.push(property.label);
|
meta.push(property.label);
|
||||||
}
|
}
|
||||||
for(var param in property.parameters) {
|
for(var param in property.parameters) {
|
||||||
|
if(!property.parameters.hasOwnProperty(param)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//console.log('param', param);
|
//console.log('param', param);
|
||||||
if(param.toUpperCase() == 'PREF') {
|
if(param.toUpperCase() === 'PREF') {
|
||||||
var $cb = $property.find('input[type="checkbox"]');
|
var $cb = $property.find('input[type="checkbox"]');
|
||||||
$cb.attr('checked', 'checked');
|
$cb.attr('checked', 'checked');
|
||||||
meta.push($cb.attr('title'));
|
meta.push($cb.attr('title'));
|
||||||
}
|
}
|
||||||
else if(param.toUpperCase() == 'TYPE') {
|
else if(param.toUpperCase() === 'TYPE') {
|
||||||
for(var etype in property.parameters[param]) {
|
for(var etype in property.parameters[param]) {
|
||||||
var found = false;
|
var found = false;
|
||||||
var et = property.parameters[param][etype];
|
var et = property.parameters[param][etype];
|
||||||
@ -1434,7 +1437,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(param.toUpperCase() == 'X-SERVICE-TYPE') {
|
else if(param.toUpperCase() === 'X-SERVICE-TYPE') {
|
||||||
//console.log('setting', $property.find('select.impp'), 'to', property.parameters[param].toLowerCase());
|
//console.log('setting', $property.find('select.impp'), 'to', property.parameters[param].toLowerCase());
|
||||||
$property.find('select.rtl').val(property.parameters[param].toLowerCase());
|
$property.find('select.rtl').val(property.parameters[param].toLowerCase());
|
||||||
}
|
}
|
||||||
@ -1495,7 +1498,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
* @return A jquery object to be injected in the DOM
|
* @return A jquery object to be injected in the DOM
|
||||||
*/
|
*/
|
||||||
Contact.prototype.renderAddressProperty = function(idx, property) {
|
Contact.prototype.renderAddressProperty = function(idx, property) {
|
||||||
if(!this.detailTemplates['adr']) {
|
if(!this.detailTemplates.adr) {
|
||||||
console.warn('No template for adr', this.detailTemplates);
|
console.warn('No template for adr', this.detailTemplates);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1519,7 +1522,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
idx: idx
|
idx: idx
|
||||||
}
|
}
|
||||||
: {value:'', checksum:'new', adr0:'', adr1:'', adr2:'', adr3:'', adr4:'', adr5:'', adr6:'', idx: idx};
|
: {value:'', checksum:'new', adr0:'', adr1:'', adr2:'', adr3:'', adr4:'', adr5:'', adr6:'', idx: idx};
|
||||||
var $elem = this.detailTemplates['adr'].octemplate(values);
|
var $elem = this.detailTemplates.adr.octemplate(values);
|
||||||
var self = this;
|
var self = this;
|
||||||
$elem.find('.tooltipped.downwards:not(.onfocus)').tipsy({gravity: 'n'});
|
$elem.find('.tooltipped.downwards:not(.onfocus)').tipsy({gravity: 'n'});
|
||||||
$elem.find('.tooltipped.rightwards.onfocus').tipsy({trigger: 'focus', gravity: 'w'});
|
$elem.find('.tooltipped.rightwards.onfocus').tipsy({trigger: 'focus', gravity: 'w'});
|
||||||
@ -1528,13 +1531,12 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
var $editor = $(this).siblings('.adr.editor').first();
|
var $editor = $(this).siblings('.adr.editor').first();
|
||||||
var $viewer = $(this);
|
var $viewer = $(this);
|
||||||
var bodyListener = function(e) {
|
var bodyListener = function(e) {
|
||||||
if($editor.find($(e.target)).length == 0) {
|
if($editor.find($(e.target)).length === 0) {
|
||||||
$editor.toggle('blind');
|
$editor.toggle('blind');
|
||||||
$viewer.slideDown(550, function() {
|
$viewer.slideDown(550, function() {
|
||||||
var input = $editor.find('input').first();
|
var input = $editor.find('input').first();
|
||||||
var val = self.valueFor(input);
|
|
||||||
var params = self.parametersFor(input, true);
|
var params = self.parametersFor(input, true);
|
||||||
$(this).find('.meta').html(params['TYPE'].join('/'));
|
$(this).find('.meta').html(params.TYPE.join('/'));
|
||||||
$(this).find('.adr').html(self.valueFor($editor.find('input').first()).clean('').join(', '));
|
$(this).find('.adr').html(self.valueFor($editor.find('input').first()).clean('').join(', '));
|
||||||
$(this).next('.listactions').css('display', 'inline-block');
|
$(this).next('.listactions').css('display', 'inline-block');
|
||||||
$('body').unbind('click', bodyListener);
|
$('body').unbind('click', bodyListener);
|
||||||
@ -1550,11 +1552,11 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
.autocomplete({
|
.autocomplete({
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "http://ws.geonames.org/searchJSON",
|
url: 'http://ws.geonames.org/searchJSON',
|
||||||
dataType: "jsonp",
|
dataType: 'jsonp',
|
||||||
data: {
|
data: {
|
||||||
featureClass: "P",
|
featureClass: 'P',
|
||||||
style: "full",
|
style: 'full',
|
||||||
maxRows: 12,
|
maxRows: 12,
|
||||||
lang: $elem.data('lang'),
|
lang: $elem.data('lang'),
|
||||||
name_startsWith: request.term
|
name_startsWith: request.term
|
||||||
@ -1562,7 +1564,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
response( $.map( data.geonames, function( item ) {
|
response( $.map( data.geonames, function( item ) {
|
||||||
return {
|
return {
|
||||||
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
|
label: item.name + (item.adminName1 ? ", " + item.adminName1 : '') + ', ' + item.countryName,
|
||||||
value: item.name,
|
value: item.name,
|
||||||
country: item.countryName
|
country: item.countryName
|
||||||
};
|
};
|
||||||
@ -1572,20 +1574,20 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
},
|
},
|
||||||
minLength: 2,
|
minLength: 2,
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
if(ui.item && $.trim($elem.find('.value.country').val()).length == 0) {
|
if(ui.item && $.trim($elem.find('.value.country').val()).length === 0) {
|
||||||
$elem.find('.value.country').val(ui.item.country);
|
$elem.find('.value.country').val(ui.item.country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$elem.find('.value.country')
|
$elem.find('.value.country')
|
||||||
.autocomplete({
|
.autocomplete({
|
||||||
source: function( request, response ) {
|
source: function(request, response) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "http://ws.geonames.org/searchJSON",
|
url: 'http://ws.geonames.org/searchJSON',
|
||||||
dataType: "jsonp",
|
dataType: 'jsonp',
|
||||||
data: {
|
data: {
|
||||||
/*featureClass: "A",*/
|
/*featureClass: "A",*/
|
||||||
featureCode: "PCLI",
|
featureCode: 'PCLI',
|
||||||
/*countryBias: "true",*/
|
/*countryBias: "true",*/
|
||||||
/*style: "full",*/
|
/*style: "full",*/
|
||||||
lang: lang,
|
lang: lang,
|
||||||
@ -1612,7 +1614,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
* @return A jquery object to be injected in the DOM
|
* @return A jquery object to be injected in the DOM
|
||||||
*/
|
*/
|
||||||
Contact.prototype.renderIMProperty = function(property) {
|
Contact.prototype.renderIMProperty = function(property) {
|
||||||
if(!this.detailTemplates['impp']) {
|
if(!this.detailTemplates.impp) {
|
||||||
console.warn('No template for impp', this.detailTemplates);
|
console.warn('No template for impp', this.detailTemplates);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1620,7 +1622,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
value: property.value,
|
value: property.value,
|
||||||
checksum: property.checksum
|
checksum: property.checksum
|
||||||
} : {value: '', checksum: 'new'};
|
} : {value: '', checksum: 'new'};
|
||||||
return this.detailTemplates['impp'].octemplate(values);
|
return this.detailTemplates.impp.octemplate(values);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1646,10 +1648,10 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$elem.addClass('thumbnail');
|
$elem.addClass('thumbnail');
|
||||||
$elem.removeAttr('style');
|
$elem.removeAttr('style');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the PHOTO property.
|
* Render the PHOTO property or a generated avatar.
|
||||||
*/
|
*/
|
||||||
Contact.prototype.loadAvatar = function() {
|
Contact.prototype.loadAvatar = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -1774,7 +1776,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
pref = prop.value;
|
pref = prop.value;
|
||||||
}
|
}
|
||||||
for(var param in prop.parameters) {
|
for(var param in prop.parameters) {
|
||||||
if(param.toUpperCase() == 'PREF') {
|
if(param.toUpperCase() === 'PREF') {
|
||||||
found = true; //
|
found = true; //
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1813,7 +1815,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
|
|
||||||
$.each(categories, function(idx, category) {
|
$.each(categories, function(idx, category) {
|
||||||
if(name.toLowerCase() == $.trim(category).toLowerCase()) {
|
if(name.toLowerCase() == $.trim(category).toLowerCase()) {
|
||||||
found = true
|
found = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1951,7 +1953,6 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
});
|
});
|
||||||
$(document).bind('status.contact.moved', function(e, data) {
|
$(document).bind('status.contact.moved', function(e, data) {
|
||||||
var contact = data.contact;
|
var contact = data.contact;
|
||||||
var oldid = contact.getId();
|
|
||||||
contact.close();
|
contact.close();
|
||||||
contact.reload(data.data);
|
contact.reload(data.data);
|
||||||
self.contacts[contact.getId()] = contact;
|
self.contacts[contact.getId()] = contact;
|
||||||
@ -2014,7 +2015,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
ContactList.prototype.count = function() {
|
ContactList.prototype.count = function() {
|
||||||
return Object.keys(this.contacts.contacts).length
|
return Object.keys(this.contacts.contacts).length;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2039,7 +2040,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$(document).trigger('status.contacts.count', {
|
$(document).trigger('status.contacts.count', {
|
||||||
count: self.length
|
count: self.length
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show/hide contacts belonging to an addressbook.
|
* Show/hide contacts belonging to an addressbook.
|
||||||
@ -2081,7 +2082,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show/hide contacts belonging to shared addressbooks.
|
* Show/hide contacts belonging to shared addressbooks.
|
||||||
* @param boolean show. Whether to show or hide.
|
* @param Boolean show. Whether to show or hide.
|
||||||
*/
|
*/
|
||||||
ContactList.prototype.showSharedAddressbooks = function(show) {
|
ContactList.prototype.showSharedAddressbooks = function(show) {
|
||||||
console.log('ContactList.showSharedAddressbooks', show);
|
console.log('ContactList.showSharedAddressbooks', show);
|
||||||
@ -2099,7 +2100,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show contacts in list
|
* Show contacts in list
|
||||||
* @param Array contacts. A list of contact ids.
|
* @param String[] contacts. A list of contact ids.
|
||||||
*/
|
*/
|
||||||
ContactList.prototype.showContacts = function(contacts) {
|
ContactList.prototype.showContacts = function(contacts) {
|
||||||
console.log('showContacts', contacts);
|
console.log('showContacts', contacts);
|
||||||
@ -2127,7 +2128,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
console.time('show');
|
console.time('show');
|
||||||
$('tr.contact').filter(':visible').hide();
|
$('tr.contact').filter(':visible').hide();
|
||||||
$.each(contacts, function(idx, id) {
|
$.each(contacts, function(idx, id) {
|
||||||
var contact = self.findById(id);
|
var contact = self.findById(id);
|
||||||
if(contact === null) {
|
if(contact === null) {
|
||||||
return true; // continue
|
return true; // continue
|
||||||
}
|
}
|
||||||
@ -2139,15 +2140,17 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
// Amazingly this is slightly faster
|
// Amazingly this is slightly faster
|
||||||
//console.time('show');
|
//console.time('show');
|
||||||
for(var id in this.contacts) {
|
for(var id in this.contacts) {
|
||||||
var contact = this.findById(id);
|
if(this.contacts.hasOwnProperty(id)) {
|
||||||
if(contact === null) {
|
var contact = this.findById(id);
|
||||||
continue;
|
if(contact === null) {
|
||||||
}
|
continue;
|
||||||
if(contacts.indexOf(String(id)) === -1) {
|
}
|
||||||
contact.getListItemElement().hide();
|
if(contacts.indexOf(String(id)) === -1) {
|
||||||
} else {
|
contact.getListItemElement().hide();
|
||||||
contact.getListItemElement().show();
|
} else {
|
||||||
contact.setThumbnail();
|
contact.getListItemElement().show();
|
||||||
|
contact.setThumbnail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.timeEnd('show');*/
|
//console.timeEnd('show');*/
|
||||||
@ -2205,15 +2208,15 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Instead of having a timeout the contacts should be moved to a "Trash" backend/address book
|
* TODO: Instead of having a timeout the contacts should be moved to a "Trash" backend/address book
|
||||||
* https://github.com/owncloud/contacts/issues/107
|
* https://github.com/owncloud/contacts/issues/107
|
||||||
* @param object|object[] data An object or array of objects containing contact identification
|
* @param Object|Object[] data An object or array of objects containing contact identification
|
||||||
* {
|
* {
|
||||||
* contactid: '1234',
|
* contactid: '1234',
|
||||||
* addressbookid: '4321',
|
* addressbookid: '4321',
|
||||||
* backend: 'local'
|
* backend: 'local'
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
ContactList.prototype.delayedDelete = function(data) {
|
ContactList.prototype.delayedDelete = function(data) {
|
||||||
console.log('delayedDelete, data:', typeof data, data);
|
console.log('delayedDelete, data:', typeof data, data);
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -2289,7 +2292,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
console.log('ContactList.deleteContacts, deletionQueue', this.deletionQueue);
|
console.log('ContactList.deleteContacts, deletionQueue', this.deletionQueue);
|
||||||
|
|
||||||
if(this.deletionQueue.length === 1) {
|
if(this.deletionQueue.length === 1) {
|
||||||
contact = this.deletionQueue.shift()
|
contact = this.deletionQueue.shift();
|
||||||
// Let contact remove itself.
|
// Let contact remove itself.
|
||||||
var id = contact.getId();
|
var id = contact.getId();
|
||||||
contact.destroy(function(response) {
|
contact.destroy(function(response) {
|
||||||
@ -2311,7 +2314,8 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Make a map of backends, address books and contacts for easier processing.
|
// Make a map of backends, address books and contacts for easier processing.
|
||||||
while(contact = this.deletionQueue.shift()) {
|
do {
|
||||||
|
contact = this.deletionQueue.shift();
|
||||||
if(!contactMap[contact.getBackend()]) {
|
if(!contactMap[contact.getBackend()]) {
|
||||||
contactMap[contact.getBackend()] = {};
|
contactMap[contact.getBackend()] = {};
|
||||||
}
|
}
|
||||||
@ -2319,7 +2323,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
contactMap[contact.getBackend()][contact.getParent()] = [];
|
contactMap[contact.getBackend()][contact.getParent()] = [];
|
||||||
}
|
}
|
||||||
contactMap[contact.getBackend()][contact.getParent()].push(contact.getId());
|
contactMap[contact.getBackend()][contact.getParent()].push(contact.getId());
|
||||||
}
|
} while(this.deletionQueue.length > 0);
|
||||||
console.log('map', contactMap);
|
console.log('map', contactMap);
|
||||||
|
|
||||||
// Call each backend/addressBook to delete contacts.
|
// Call each backend/addressBook to delete contacts.
|
||||||
@ -2558,7 +2562,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$(document).trigger('status.contacts.count', {
|
$(document).trigger('status.contacts.count', {
|
||||||
count: self.length
|
count: self.length
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load contacts
|
* Load contacts
|
||||||
|
@ -112,7 +112,7 @@ OC.ContactsImporter = OC.ContactsImporter || {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
_getTemplate: function() {
|
_getTemplate: function() {
|
||||||
var defer = $.Deferred(), self = this;
|
var defer = $.Deferred();
|
||||||
if(!this.$template) {
|
if(!this.$template) {
|
||||||
$.get(OC.filePath('contacts', 'templates', 'importdialog.html'), function(tmpl) {
|
$.get(OC.filePath('contacts', 'templates', 'importdialog.html'), function(tmpl) {
|
||||||
defer.resolve($(tmpl));
|
defer.resolve($(tmpl));
|
||||||
|
@ -355,7 +355,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
);
|
);
|
||||||
console.log('url', url);
|
console.log('url', url);
|
||||||
var defer = $.Deferred();
|
var defer = $.Deferred();
|
||||||
var self = this;
|
|
||||||
$.when(
|
$.when(
|
||||||
$(photo).on('load', function() {
|
$(photo).on('load', function() {
|
||||||
defer.resolve(photo);
|
defer.resolve(photo);
|
||||||
@ -569,7 +569,6 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
: 'application/x-www-form-urlencoded';
|
: 'application/x-www-form-urlencoded';
|
||||||
var processData = !isJSON;
|
var processData = !isJSON;
|
||||||
contentType += '; charset=UTF-8';
|
contentType += '; charset=UTF-8';
|
||||||
var self = this;
|
|
||||||
var url = OC.generateUrl('apps/contacts/' + route, routeParams);
|
var url = OC.generateUrl('apps/contacts/' + route, routeParams);
|
||||||
var headers = {
|
var headers = {
|
||||||
Accept : 'application/json; charset=utf-8'
|
Accept : 'application/json; charset=utf-8'
|
||||||
@ -593,7 +592,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
.done(function(response, textStatus, jqXHR) {
|
.done(function(response, textStatus, jqXHR) {
|
||||||
defer.resolve(new JSONResponse(response, jqXHR));
|
defer.resolve(new JSONResponse(response, jqXHR));
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, error) {
|
.fail(function(jqXHR/*, textStatus, error*/) {
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
var response = jqXHR.responseText ? $.parseJSON(jqXHR.responseText) : null;
|
var response = jqXHR.responseText ? $.parseJSON(jqXHR.responseText) : null;
|
||||||
console.log('response', response);
|
console.log('response', response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user