Merge https://github.com/friendica/red into pending_merge
This commit is contained in:
commit
087d6744fc
@ -15,15 +15,7 @@ function nav(&$a) {
|
|||||||
$a->page['htmlhead'] .= <<< EOT
|
$a->page['htmlhead'] .= <<< EOT
|
||||||
|
|
||||||
<script>$(document).ready(function() {
|
<script>$(document).ready(function() {
|
||||||
var a;
|
$("#nav-search-text").search_autocomplete('$base/acl');
|
||||||
a = $("#nav-search-text").autocomplete({
|
|
||||||
serviceUrl: '$base/acl',
|
|
||||||
minChars: 2,
|
|
||||||
width: 250,
|
|
||||||
id: 'nav-search-text-ac',
|
|
||||||
});
|
|
||||||
a.setOptions({ autoSubmit: true, params: { type: 'x' }});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -124,8 +124,9 @@ if (typeof jQuery === 'undefined') {
|
|||||||
this.views = [];
|
this.views = [];
|
||||||
this.option = $.extend({}, Completer._getDefaults(), option);
|
this.option = $.extend({}, Completer._getDefaults(), option);
|
||||||
|
|
||||||
if (!this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') {
|
|
||||||
throw new Error('textcomplete must be called on a Textarea or a ContentEditable.');
|
if (!this.$el.is('input[type=text]') && !this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') {
|
||||||
|
throw new Error('textcomplete must be called on a input[type=text], Textarea or a ContentEditable.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element === document.activeElement) {
|
if (element === document.activeElement) {
|
||||||
@ -171,7 +172,7 @@ if (typeof jQuery === 'undefined') {
|
|||||||
if (this.option.adapter) {
|
if (this.option.adapter) {
|
||||||
Adapter = this.option.adapter;
|
Adapter = this.option.adapter;
|
||||||
} else {
|
} else {
|
||||||
if (this.$el.is('textarea')) {
|
if (this.$el.is('textarea') || this.$el.is('input[type=text]')) {
|
||||||
viewName = typeof element.selectionEnd === 'number' ? 'Textarea' : 'IETextarea';
|
viewName = typeof element.selectionEnd === 'number' ? 'Textarea' : 'IETextarea';
|
||||||
} else {
|
} else {
|
||||||
viewName = 'ContentEditable';
|
viewName = 'ContentEditable';
|
||||||
|
48
mod/acl.php
48
mod/acl.php
@ -182,49 +182,29 @@ function acl_init(&$a){
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif($type == 'x') {
|
elseif($type == 'x') {
|
||||||
|
|
||||||
$r = navbar_complete($a);
|
$r = navbar_complete($a);
|
||||||
$x = array();
|
$contacts = array();
|
||||||
$x['query'] = $search;
|
|
||||||
$x['photos'] = array();
|
|
||||||
$x['links'] = array();
|
|
||||||
$x['suggestions'] = array();
|
|
||||||
$x['data'] = array();
|
|
||||||
if($r) {
|
if($r) {
|
||||||
foreach($r as $g) {
|
foreach($r as $g) {
|
||||||
$x['photos'][] = $g['photo'];
|
$contacts[] = array(
|
||||||
$x['links'][] = $g['url'];
|
"photo" => $g['photo'],
|
||||||
$x['suggestions'][] = '@' . $g['name'];
|
"name" => $g['name'],
|
||||||
$x['data'][] = $g['name'];
|
"nick" => $g['address'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo json_encode($x);
|
|
||||||
killme();
|
|
||||||
|
|
||||||
|
$o = array(
|
||||||
|
'start' => $start,
|
||||||
|
'count' => $count,
|
||||||
|
'items' => $contacts,
|
||||||
|
);
|
||||||
|
echo json_encode($o);
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$r = array();
|
$r = array();
|
||||||
|
|
||||||
|
|
||||||
if($type == 'm' || $type == 'a' || $type == 'p') {
|
|
||||||
$x = array();
|
|
||||||
$x['query'] = $search;
|
|
||||||
$x['photos'] = array();
|
|
||||||
$x['links'] = array();
|
|
||||||
$x['suggestions'] = array();
|
|
||||||
$x['data'] = array();
|
|
||||||
if(count($r)) {
|
|
||||||
foreach($r as $g) {
|
|
||||||
$x['photos'][] = $g['micro'];
|
|
||||||
$x['links'][] = $g['url'];
|
|
||||||
$x['suggestions'][] = $g['name'];
|
|
||||||
$x['data'][] = (($type === 'p') ? '@' . str_replace(' ','_',$g['name']) : $g['id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo json_encode($x);
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
foreach($r as $g){
|
foreach($r as $g){
|
||||||
|
|
||||||
@ -284,7 +264,7 @@ function navbar_complete(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dirmode = intval(get_config('system','directory_mode'));
|
$dirmode = intval(get_config('system','directory_mode'));
|
||||||
$search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : '');
|
$search = ((x($_REQUEST,'search')) ? htmlentities($_REQUEST['search'],ENT_COMPAT,'UTF-8',false) : '');
|
||||||
if(! $search || mb_strlen($search) < 2)
|
if(! $search || mb_strlen($search) < 2)
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
*
|
*
|
||||||
* require jQuery, jquery.textcomplete
|
* require jQuery, jquery.textcomplete
|
||||||
*/
|
*/
|
||||||
|
function contact_search(term, callback, backend_url, type, extra_channels) {
|
||||||
function mysearch(term, callback, backend_url, extra_channels) {
|
// Check if there is a cached result that contains the same information we would get with a full server-side search
|
||||||
// Check if there is a cached result that contains the tsame information we would get with a full server-side search
|
// Assume type hasn't changed
|
||||||
for(t in mysearch.cache) {
|
for(t in contact_search.cache) {
|
||||||
if(term.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
|
if(term.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
|
||||||
// Filter old results locally
|
// Filter old results locally
|
||||||
var matching = mysearch.cache[t].filter(function (x) { return (x.name.indexOf(term) >= 0 || x.nick.indexOf(term) >= 0); });
|
var matching = contact_search.cache[t].filter(function (x) { return (x.name.indexOf(term) >= 0 || x.nick.indexOf(term) >= 0); });
|
||||||
callback(matching);
|
callback(matching);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -19,10 +19,10 @@ function mysearch(term, callback, backend_url, extra_channels) {
|
|||||||
start:0,
|
start:0,
|
||||||
count:100,
|
count:100,
|
||||||
search:term,
|
search:term,
|
||||||
type:'c',
|
type:type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(extra_channels)
|
if(typeof extra_channels !== 'undefined' && extra_channels)
|
||||||
postdata['extra_channels[]'] = extra_channels;
|
postdata['extra_channels[]'] = extra_channels;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -34,19 +34,19 @@ function mysearch(term, callback, backend_url, extra_channels) {
|
|||||||
// Cache results if we got them all (more information would not improve results)
|
// Cache results if we got them all (more information would not improve results)
|
||||||
// data.count represents the maximum number of items
|
// data.count represents the maximum number of items
|
||||||
if(data.items.length < data.count) {
|
if(data.items.length < data.count) {
|
||||||
mysearch.cache[term] = data.items;
|
contact_search.cache[term] = data.items;
|
||||||
}
|
}
|
||||||
callback(data.items);
|
callback(data.items);
|
||||||
},
|
},
|
||||||
}).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong.
|
}).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong.
|
||||||
}
|
}
|
||||||
mysearch.cache = {};
|
contact_search.cache = {};
|
||||||
|
|
||||||
function format(item) {
|
function contact_format(item) {
|
||||||
return "<div class='{0}' title='{4}'><img src='{1}'>{2} ({3})</div>".format(item.taggable, item.photo, item.name, ((item.label) ? item.nick + ' ' + item.label : item.nick), item.link )
|
return "<div class='{0}' title='{4}'><img src='{1}'>{2} ({3})</div>".format(item.taggable, item.photo, item.name, ((item.label) ? item.nick + ' ' + item.label : item.nick), item.link )
|
||||||
}
|
}
|
||||||
|
|
||||||
function replace(item) {
|
function editor_replace(item) {
|
||||||
// $2 ensures that prefix (@,@!) is preserved
|
// $2 ensures that prefix (@,@!) is preserved
|
||||||
var id = item.id;
|
var id = item.id;
|
||||||
// 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
|
// 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
|
||||||
@ -56,20 +56,28 @@ function replace(item) {
|
|||||||
return '$1$2'+item.nick.replace(' ','') + '+' + id;
|
return '$1$2'+item.nick.replace(' ','') + '+' + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function basic_replace(item) {
|
||||||
|
return '$1'+item.name+' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit_form(e) {
|
||||||
|
$(e).parents('form').submit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* jQuery plugin 'contact_autocomplete'
|
* jQuery plugin 'editor_autocomplete'
|
||||||
*/
|
*/
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
$.fn.contact_autocomplete = function(backend_url, extra_channels) {
|
$.fn.editor_autocomplete = function(backend_url, extra_channels) {
|
||||||
if (typeof extra_channels === 'undefined') extra_channels = false;
|
if (typeof extra_channels === 'undefined') extra_channels = false;
|
||||||
|
|
||||||
// Autocomplete contacts
|
// Autocomplete contacts
|
||||||
contacts = {
|
contacts = {
|
||||||
match: /(^|\s)(@\!*)([^ \n]+)$/,
|
match: /(^|\s)(@\!*)([^ \n]+)$/,
|
||||||
index: 3,
|
index: 3,
|
||||||
search: function(term, callback) { mysearch(term, callback, backend_url, extra_channels); },
|
search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels); },
|
||||||
replace: replace,
|
replace: editor_replace,
|
||||||
template: format,
|
template: contact_format,
|
||||||
}
|
}
|
||||||
|
|
||||||
smilies = {
|
smilies = {
|
||||||
@ -79,6 +87,56 @@ function replace(item) {
|
|||||||
template: function(item) { return item['icon'] + item['text'] },
|
template: function(item) { return item['icon'] + item['text'] },
|
||||||
replace: function(item) { return "$1"+item['text'] + ' '; },
|
replace: function(item) { return "$1"+item['text'] + ' '; },
|
||||||
}
|
}
|
||||||
|
this.attr('autocomplete','off');
|
||||||
this.textcomplete([contacts,smilies],{className:'acpopup'});
|
this.textcomplete([contacts,smilies],{className:'acpopup'});
|
||||||
};
|
};
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jQuery plugin 'search_autocomplete'
|
||||||
|
*/
|
||||||
|
(function( $ ){
|
||||||
|
$.fn.search_autocomplete = function(backend_url) {
|
||||||
|
|
||||||
|
// Autocomplete contacts
|
||||||
|
contacts = {
|
||||||
|
match: /(^@)([^\n]{2,})$/,
|
||||||
|
index: 2,
|
||||||
|
search: function(term, callback) { contact_search(term, callback, backend_url, 'x',[]); },
|
||||||
|
replace: basic_replace,
|
||||||
|
template: contact_format,
|
||||||
|
}
|
||||||
|
this.attr('autocomplete','off');
|
||||||
|
var a = this.textcomplete([contacts],{className:'acpopup',maxCount:100});
|
||||||
|
|
||||||
|
a.on('textComplete:select', function(e,value,strategy) { submit_form(this); });
|
||||||
|
|
||||||
|
};
|
||||||
|
})( jQuery );
|
||||||
|
|
||||||
|
(function( $ ){
|
||||||
|
$.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) {
|
||||||
|
|
||||||
|
if(typeof typ === 'undefined') typ = '';
|
||||||
|
if(typeof autosubmit === 'undefined') autosubmit = false;
|
||||||
|
|
||||||
|
// Autocomplete contacts
|
||||||
|
contacts = {
|
||||||
|
match: /(^)([^\n]+)$/,
|
||||||
|
index: 2,
|
||||||
|
search: function(term, callback) { contact_search(term, callback, backend_url, typ,[]); },
|
||||||
|
replace: basic_replace,
|
||||||
|
template: contact_format,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.attr('autocomplete','off');
|
||||||
|
var a = this.textcomplete([contacts],{className:'acpopup'});
|
||||||
|
|
||||||
|
if(autosubmit)
|
||||||
|
a.on('textComplete:select', function(e,value,strategy) { submit_form(this); });
|
||||||
|
|
||||||
|
if(typeof onselect !== 'undefined')
|
||||||
|
a.on('textComplete:select',function(e,value,strategy) { onselect(value); });
|
||||||
|
};
|
||||||
|
})( jQuery );
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ function updateConvItems(mode,data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* autocomplete @nicknames */
|
/* autocomplete @nicknames */
|
||||||
$(".comment-edit-form textarea").contact_autocomplete(baseurl+"/acl?f=&n=1");
|
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
|
||||||
|
|
||||||
var bimgs = $(".wall-item-body img").not(function() { return this.complete; });
|
var bimgs = $(".wall-item-body img").not(function() { return this.complete; });
|
||||||
var bimgcount = bimgs.length;
|
var bimgcount = bimgs.length;
|
||||||
@ -604,7 +604,7 @@ function updateConvItems(mode,data) {
|
|||||||
$(this).readmore({
|
$(this).readmore({
|
||||||
collapsedHeight: divmore_height,
|
collapsedHeight: divmore_height,
|
||||||
moreLink: '<a href="#" class="divgrow-showmore">'+aStr['divgrowmore']+'</a>',
|
moreLink: '<a href="#" class="divgrow-showmore">'+aStr['divgrowmore']+'</a>',
|
||||||
lessLink: '<a href="#">'+aStr['divgrowless']+'</a>'
|
lessLink: '<a href="#" class="divgrow-showmore">'+aStr['divgrowless']+'</a>'
|
||||||
});
|
});
|
||||||
$(this).addClass('divmore');
|
$(this).addClass('divmore');
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var a;
|
$("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
|
||||||
a = $("#contacts-search").autocomplete({
|
|
||||||
serviceUrl: baseurl + '/acl',
|
|
||||||
minChars: 2,
|
|
||||||
width: 250,
|
|
||||||
id: 'contact-search-ac',
|
|
||||||
});
|
|
||||||
a.setOptions({ autoSubmit: true, params: { type: 'a' }});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#contacts-search").keyup(function(event){
|
$("#contacts-search").keyup(function(event){
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var a;
|
$("#recip").contact_autocomplete(baseurl + '/acl', '', false, function(data) {
|
||||||
a = $("#recip").autocomplete({
|
$("#recip-complete").val(data.xid);
|
||||||
serviceUrl: baseurl + '/acl',
|
|
||||||
minChars: 2,
|
|
||||||
width: 250,
|
|
||||||
id: 'recip-ac',
|
|
||||||
onSelect: function(value,data) {
|
|
||||||
$("#recip-complete").val(data);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
$(document).ready(function() {
|
|
||||||
var a;
|
|
||||||
a = $("#recip").autocomplete({
|
|
||||||
serviceUrl: baseurl + '/acl',
|
|
||||||
minChars: 2,
|
|
||||||
width: 250,
|
|
||||||
id: 'recip-ac',
|
|
||||||
onSelect: function(value,data) {
|
|
||||||
$("#recip-complete").val(data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,10 +1,5 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var a;
|
$("#search-text").contact_autocomplete(baseurl + '/acl');
|
||||||
a = $("#search-text").autocomplete({
|
|
||||||
serviceUrl: baseurl + '/search_ac',
|
|
||||||
minChars: 2,
|
|
||||||
id: 'search-text-ac',
|
|
||||||
});
|
|
||||||
$('.jslider-scale ins').addClass('hidden-xs');
|
$('.jslider-scale ins').addClass('hidden-xs');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,19 +2,11 @@
|
|||||||
var ispublic = aStr['everybody'];
|
var ispublic = aStr['everybody'];
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$(document).ready(function() {
|
||||||
var a;
|
$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) {
|
||||||
a = $("#photo-edit-newtag").autocomplete({
|
$("#photo-edit-newtag").val('@' + data.name.replace(' ','_')); // TODO: Get rid of underscore
|
||||||
serviceUrl: baseurl + '/acl',
|
});
|
||||||
minChars: 2,
|
});
|
||||||
width: 250,
|
|
||||||
id: 'newtag-ac',
|
|
||||||
onSelect: function(value,data) {
|
|
||||||
$("#photo-edit-newtag").val(data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
a.setOptions({ params: { type: 'p' }});
|
|
||||||
|
|
||||||
|
|
||||||
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
|
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
|
||||||
var selstr;
|
var selstr;
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var a;
|
$("#poke-recip").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) {
|
||||||
a = $("#poke-recip").autocomplete({
|
$("#poke-recip-complete").val(data.id);
|
||||||
serviceUrl: baseurl + '/acl',
|
|
||||||
minChars: 2,
|
|
||||||
width: 250,
|
|
||||||
id: 'poke-recip-ac',
|
|
||||||
onSelect: function(value,data) {
|
|
||||||
$("#poke-recip-complete").val(data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
a.setOptions({ params: { type: 'a' }});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var a;
|
$(document).ready(function() {
|
||||||
a = $("#id_name").autocomplete({
|
$("#id_name").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) {
|
||||||
serviceUrl: baseurl + '/acl',
|
$("#id_abook").val(data.id);
|
||||||
minChars: 2,
|
});
|
||||||
width: 250,
|
});
|
||||||
id: 'id-name-ac',
|
|
||||||
onSelect: function(value,data) {
|
|
||||||
$("#id_abook").val(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
a.setOptions({ params: { type: 'a' }});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl?f=&n=1");
|
$(".comment-edit-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
|
||||||
// make auto-complete work in more places
|
// make auto-complete work in more places
|
||||||
$(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl?f=&n=1");
|
$(".wall-item-comment-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ function initEditor(cb){
|
|||||||
$("#profile-jot-text-loading").spin(false).hide();
|
$("#profile-jot-text-loading").spin(false).hide();
|
||||||
$("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
|
$("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
|
||||||
if(typeof channelId === 'undefined')
|
if(typeof channelId === 'undefined')
|
||||||
$("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
|
$("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
|
||||||
else
|
else
|
||||||
$("#profile-jot-text").contact_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections
|
$("#profile-jot-text").editor_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections
|
||||||
editor = true;
|
editor = true;
|
||||||
$("a#jot-perms-icon").colorbox({
|
$("a#jot-perms-icon").colorbox({
|
||||||
'inline' : true,
|
'inline' : true,
|
||||||
|
@ -41,7 +41,7 @@ if(plaintext != 'none') {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$("#prvmail-text").contact_autocomplete(baseurl+"/acl");
|
$("#prvmail-text").editor_autocomplete(baseurl+"/acl");
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user