[Pkg-mozext-commits] [wot] 207/226: Fixed issue with non-latin tags
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository wot.
commit 1fb31a3b246c19d75e0ffc3b6b2839f15e7a5042
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Wed Mar 19 11:29:28 2014 +0200
Fixed issue with non-latin tags
---
content/libs/bootstrap-tagautocomplete.js | 10 +++++-----
content/libs/bootstrap-typeahead.js | 4 ++--
content/rw/ratingwindow.js | 25 +++++++++++++++++--------
content/rw/wot.js | 3 ++-
4 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/content/libs/bootstrap-tagautocomplete.js b/content/libs/bootstrap-tagautocomplete.js
index 1b44645..6fdd47d 100644
--- a/content/libs/bootstrap-tagautocomplete.js
+++ b/content/libs/bootstrap-tagautocomplete.js
@@ -52,7 +52,7 @@
this.after();
- setCaretPosition(this.$element[0], position)
+ setCaretPosition(this.$element[0], position)
return this.hide()
}
@@ -83,10 +83,10 @@
var query = this.query;
var position = getCaretPosition(this.$element[0]);
query = query.substring(0, position);
- var regex = new RegExp("(^|\\s)([" + this.options.character + "][\\w-]*)$");
+ var regex = new RegExp("(^|\\s)([" + this.options.character + "][\\w\u0400-\u04FF]*)$");
var result = regex.exec(query);
if(result && result[2])
- return result[2].trim().toLowerCase();
+ return result[2].trim().toLocaleLowerCase();
return '';
}
@@ -104,10 +104,10 @@
this.index_for_split = range.startOffset - this.length_of_query;
this.node = range.startContainer
- return ~item.toLowerCase().indexOf(tquery)
+ return ~item.toLocaleLowerCase().indexOf(tquery)
}
- , highlighter: function (item) {
+ , highlighter: function (item) {
var query = this.extractor().replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>'
diff --git a/content/libs/bootstrap-typeahead.js b/content/libs/bootstrap-typeahead.js
index 44cfc6e..994538d 100644
--- a/content/libs/bootstrap-typeahead.js
+++ b/content/libs/bootstrap-typeahead.js
@@ -110,7 +110,7 @@
}
, matcher: function (item) {
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
+ return ~item.toLocaleLowerCase().indexOf(this.query.toLocaleLowerCase())
}
, sorter: function (items) {
@@ -120,7 +120,7 @@
, item
while (item = items.shift()) {
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
+ if (!item.toLocaleLowerCase().indexOf(this.query.toLocaleLowerCase())) beginswith.push(item)
else if (~item.indexOf(this.query)) caseSensitive.push(item)
else caseInsensitive.push(item)
}
diff --git a/content/rw/ratingwindow.js b/content/rw/ratingwindow.js
index 4c0c1b1..4106096 100644
--- a/content/rw/ratingwindow.js
+++ b/content/rw/ratingwindow.js
@@ -2774,7 +2774,11 @@ $.extend(wot, { ratingwindow: {
var rw = wot.ratingwindow,
bgwot = rw.get_bg("wot");
- return bgwot.core.tags.mytags;
+ return bgwot.core.tags.mytags.map(function(item){
+ // update the "index" value of the tag (make it normalized)
+ item.value_indx = String(item.value).toLocaleLowerCase();
+ return item;
+ });
},
get_popular_tags: function () {
@@ -2782,7 +2786,11 @@ $.extend(wot, { ratingwindow: {
var rw = wot.ratingwindow,
bgwot = rw.get_bg("wot");
- return bgwot.core.tags.popular_tags;
+ return bgwot.core.tags.popular_tags.map(function(item){
+ // update the "index" value of the tag (make it normalized)
+ item.value_indx = String(item.value).toLocaleLowerCase();
+ return item;
+ });
},
update_mytags: function (force) {
@@ -2815,7 +2823,7 @@ $.extend(wot, { ratingwindow: {
var _this = wot.ratingwindow.wg,
popular_groups = _this.get_popular_tags(),
res = popular_groups.filter(function(item){
- if (item.value == tag) return true;
+ if (item.value_indx == tag.toLocaleLowerCase()) return true;
});
return res.length > 0;
@@ -2825,7 +2833,7 @@ $.extend(wot, { ratingwindow: {
var _this = wot.ratingwindow.wg,
tags = _this.get_tags(),
res = tags.filter(function(item){
- if (item.value == tag) return true;
+ if (item.value_indx == tag.toLocaleLowerCase()) return true;
});
return res.length > 0;
@@ -3014,7 +3022,7 @@ $.extend(wot, { ratingwindow: {
})
);
- tags_ac.sort();
+// tags_ac.sort();
tags_ac = tags_ac.map(function (item) { return "#" + item }); // prepend with # char since it is required by the autocomplete feature
@@ -3045,9 +3053,10 @@ $.extend(wot, { ratingwindow: {
var $tag, info,
tag = list[j],
- tag_value = tag.value;
+ tag_value = tag.value,
+ tag_value_indx = tag_value.toLocaleLowerCase();
- if (prev[tag_value]) continue; // don't show one tag more than one time (if it was in mytags list)
+ if (prev[tag_value_indx]) continue; // don't show one tag more than one time (if it was in mytags list)
$tag = $("<li></li>")
.addClass("wg-tag")
@@ -3071,7 +3080,7 @@ $.extend(wot, { ratingwindow: {
$tags.append($tag);
- prev[tag_value] = true; // remember that we showed the tag
+ prev[tag_value_indx] = true; // remember that we showed the tag
}
}
diff --git a/content/rw/wot.js b/content/rw/wot.js
index 13a5f97..229a72a 100644
--- a/content/rw/wot.js
+++ b/content/rw/wot.js
@@ -970,7 +970,8 @@ var wot = {
if (tag && !_tags[tag]) {
tags.push({
- value: tag // tag's text
+ value: tag, // tag's text
+ value_indx: tag.toLocaleLowerCase() // index value of the tag
});
_tags[tag] = true; // remember the tag to avoid duplications
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git
More information about the Pkg-mozext-commits
mailing list