mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
fix developer-jquery
This commit is contained in:
parent
b03808533d
commit
d9bb325652
|
@ -1,60 +0,0 @@
|
|||
function split(val) { return val.split( /,\s*/ ); }
|
||||
function extractLast(term) { return split(term).pop(); }
|
||||
|
||||
function autocompleteAdd(obj, sPath, multiple) {
|
||||
if (multiple) {
|
||||
obj.bind("keydown", function(event) {
|
||||
if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
.autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
url: sPath,
|
||||
type: 'post',
|
||||
data: {
|
||||
value: extractLast(request.term),
|
||||
security_ls_key: LIVESTREET_SECURITY_KEY
|
||||
},
|
||||
success: function(data) {
|
||||
response(data.aItems);
|
||||
}
|
||||
});
|
||||
},
|
||||
search: function() {
|
||||
var term = extractLast(this.value);
|
||||
if (term.length < 2) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
return false;
|
||||
},
|
||||
select: function(event, ui) {
|
||||
var terms = split(this.value);
|
||||
terms.pop();
|
||||
terms.push(ui.item.value);
|
||||
terms.push("");
|
||||
this.value = terms.join(", ");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
obj.autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
url: sPath,
|
||||
type: 'post',
|
||||
data: {
|
||||
value: extractLast(request.term),
|
||||
security_ls_key: LIVESTREET_SECURITY_KEY
|
||||
},
|
||||
success: function(data) {
|
||||
response(data.aItems);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -130,6 +130,68 @@ ls = (function ($) {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Автокомплитер
|
||||
*/
|
||||
ls.autocomplete = (function ($) {
|
||||
/**
|
||||
* Добавляет автокомплитер к полю ввода
|
||||
*/
|
||||
this.add = function(obj, sPath, multiple) {
|
||||
if (multiple) {
|
||||
obj.bind("keydown", function(event) {
|
||||
if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
.autocomplete({
|
||||
source: function(request, response) {
|
||||
ls.ajax(sPath,{value: ls.autocomplete.extractLast(request.term)},function(data){
|
||||
response(data.aItems);
|
||||
});
|
||||
},
|
||||
search: function() {
|
||||
var term = ls.autocomplete.extractLast(this.value);
|
||||
if (term.length < 2) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
return false;
|
||||
},
|
||||
select: function(event, ui) {
|
||||
var terms = ls.autocomplete.split(this.value);
|
||||
terms.pop();
|
||||
terms.push(ui.item.value);
|
||||
terms.push("");
|
||||
this.value = terms.join(", ");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
obj.autocomplete({
|
||||
source: function(request, response) {
|
||||
ls.ajax(sPath,{value: ls.autocomplete.extractLast(request.term)},function(data){
|
||||
response(data.aItems);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.split = function(val) {
|
||||
return val.split( /,\s*/ );
|
||||
}
|
||||
|
||||
this.extractLast = function(term) {
|
||||
return ls.autocomplete.split(term).pop();
|
||||
}
|
||||
|
||||
return this;
|
||||
}).call(ls.autocomplete || {},jQuery);
|
||||
|
||||
|
||||
|
||||
(ls.options || {}).debug=1;
|
||||
|
||||
|
||||
|
@ -164,10 +226,10 @@ $(document).ready(function(){
|
|||
|
||||
|
||||
// Автокомплит
|
||||
autocompleteAdd($(".autocomplete-tags-sep"), aRouter['ajax']+'autocompleter/tag/', true);
|
||||
autocompleteAdd($(".autocomplete-users"), aRouter['ajax']+'autocompleter/user/', true);
|
||||
autocompleteAdd($(".autocomplete-city"), aRouter['ajax']+'autocompleter/city/', false);
|
||||
autocompleteAdd($(".autocomplete-country"), aRouter['ajax']+'autocompleter/country/', false);
|
||||
ls.autocomplete.add($(".autocomplete-tags-sep"), aRouter['ajax']+'autocompleter/tag/', true);
|
||||
ls.autocomplete.add($(".autocomplete-users"), aRouter['ajax']+'autocompleter/user/', true);
|
||||
ls.autocomplete.add($(".autocomplete-city"), aRouter['ajax']+'autocompleter/city/', false);
|
||||
ls.autocomplete.add($(".autocomplete-country"), aRouter['ajax']+'autocompleter/country/', false);
|
||||
|
||||
|
||||
// Скролл
|
||||
|
|
|
@ -11,7 +11,6 @@ $config['head']['default']['js'] = array(
|
|||
"___path.static.skin___/js/libs/markitup/jquery.markitup.js",
|
||||
"___path.static.skin___/js/libs/markitup/sets/default/set.js",
|
||||
"___path.static.skin___/js/main.js",
|
||||
"___path.static.skin___/js/autocomplete.js",
|
||||
"___path.static.skin___/js/favourite.js",
|
||||
"___path.static.skin___/js/blocks.js",
|
||||
"___path.static.skin___/js/talk.js",
|
||||
|
|
Loading…
Reference in a new issue