summaryrefslogtreecommitdiff
path: root/data/js
diff options
context:
space:
mode:
authormorkt <morkt@users.noreply.github.com>2015-11-10 06:06:54 +0400
committermorkt <morkt@users.noreply.github.com>2015-11-10 06:06:54 +0400
commitd488967ebdde36bf2c959f1d4e1c55c622887bf8 (patch)
treedeed89549ba634260924c932021be0de1796d62e /data/js
parentddbf3ae0ae530954b0e105e99819c85cfe4de17c (diff)
parent052b78e84b4c7379f107cfaa5f9cede09b8b1b7b (diff)
Merge branch 'master' into poll
Diffstat (limited to 'data/js')
-rw-r--r--data/js/dropdownsearch.js28
-rw-r--r--data/js/iv.js22
-rw-r--r--data/js/lib.js2
-rw-r--r--data/js/misc.js21
-rw-r--r--data/js/vnscr.js2
5 files changed, 35 insertions, 40 deletions
diff --git a/data/js/dropdownsearch.js b/data/js/dropdownsearch.js
index 35bd1443..e7c42dc0 100644
--- a/data/js/dropdownsearch.js
+++ b/data/js/dropdownsearch.js
@@ -41,6 +41,7 @@ function box() {
function init(obj, url, trfunc, serfunc, retfunc) {
obj.setAttribute('autocomplete', 'off');
obj.onkeydown = keydown;
+ obj.onclick = obj.onchange = obj.oninput = function() { return textchanged(obj); };
obj.onblur = blur;
obj.ds_returnFunc = retfunc;
obj.ds_trFunc = trfunc;
@@ -48,6 +49,7 @@ function init(obj, url, trfunc, serfunc, retfunc) {
obj.ds_searchURL = url;
obj.ds_selectedId = 0;
obj.ds_dosearch = null;
+ obj.ds_lastVal = obj.value;
}
function blur() {
@@ -65,7 +67,7 @@ function setselected(obj, id) {
function setvalue(obj) {
if(obj.ds_selectedId != 0)
- obj.value = obj.ds_serFunc(byId('ds_box_'+obj.ds_selectedId).ds_itemData, obj);
+ obj.value = obj.ds_lastVal = obj.ds_serFunc(byId('ds_box_'+obj.ds_selectedId).ds_itemData, obj);
if(obj.ds_returnFunc)
obj.ds_returnFunc(obj);
@@ -110,6 +112,21 @@ function updown(obj, up) {
return false;
}
+function textchanged(obj) {
+ // Ignore this event if the text hasn't actually changed.
+ if(obj.ds_lastVal == obj.value)
+ return true;
+ obj.ds_lastVal = obj.value;
+
+ // perform search after a timeout
+ if(obj.ds_dosearch)
+ clearTimeout(obj.ds_dosearch);
+ obj.ds_dosearch = setTimeout(function() {
+ search(obj);
+ }, 500);
+ return true;
+}
+
function keydown(ev) {
var c = document.layers ? ev.which : document.all ? event.keyCode : ev.keyCode;
var obj = this;
@@ -123,14 +140,7 @@ function keydown(ev) {
if(c == 38 || c == 40) // up / down
return updown(obj, c == 38);
- // perform search after a timeout
- if(obj.ds_dosearch)
- clearTimeout(obj.ds_dosearch);
- obj.ds_dosearch = setTimeout(function() {
- search(obj);
- }, 500);
-
- return true;
+ return textchanged(obj);
}
function search(obj) {
diff --git a/data/js/iv.js b/data/js/iv.js
index 75754a90..f1593d22 100644
--- a/data/js/iv.js
+++ b/data/js/iv.js
@@ -1,14 +1,14 @@
/* Simple image viewer widget. Usage:
*
- * <a href="full_image.jpg" rel="iv:{width}x{height}:{category}">..</a>
+ * <a href="full_image.jpg" data-iv="{width}x{height}:{category}">..</a>
*
* Clicking on the above link will cause the image viewer to open
* full_image.jpg. The {category} part can be empty or absent. If it is not
* empty, next/previous links will show up to point to the other images within
* the same category.
*
- * ivInit() should be called when links with "iv:" tags are dynamically added
- * or removed from the DOM.
+ * ivInit() should be called when links with "data-iv" attributes are
+ * dynamically added or removed from the DOM.
*/
// Cache of image categories and the list of associated link objects. Used to
@@ -21,10 +21,10 @@ function init() {
var l = byName('a');
for(var i=0;i<l.length;i++) {
var o = l[i];
- if(o.rel.substr(0,3) == 'iv:' && o.id != 'ivprev' && o.id != 'ivnext') {
+ if(o.getAttribute('data-iv') && o.id != 'ivprev' && o.id != 'ivnext') {
n++;
o.onclick = show;
- var cat = o.rel.split(':')[2];
+ var cat = o.getAttribute('data-iv').split(':')[1];
if(cat) {
if(!cats[cat])
cats[cat] = [];
@@ -60,23 +60,23 @@ function fixnav(lnk, cat, i, dir) {
var a = cat ? findnav(cat, i, dir) : 0;
lnk.style.visibility = a ? 'visible' : 'hidden';
lnk.href = a ? a.href : '#';
- lnk.rel = a ? a.rel : '';
lnk.iv_i = a ? a.iv_i : 0;
+ lnk.setAttribute('data-iv', a ? a.getAttribute('data-iv') : '');
}
function show() {
var u = this.href;
- var opt = this.rel.split(':');
+ var opt = this.getAttribute('data-iv').split(':');
var idx = this.iv_i;
var view = byId('iv_view');
var full = byId('ivfull');
- fixnav(byId('ivprev'), opt[2], idx, -1);
- fixnav(byId('ivnext'), opt[2], idx, 1);
+ fixnav(byId('ivprev'), opt[1], idx, -1);
+ fixnav(byId('ivnext'), opt[1], idx, 1);
// calculate dimensions
- var w = Math.floor(opt[1].split('x')[0]);
- var h = Math.floor(opt[1].split('x')[1]);
+ var w = Math.floor(opt[0].split('x')[0]);
+ var h = Math.floor(opt[0].split('x')[1]);
var ww = typeof(window.innerWidth) == 'number' ? window.innerWidth : document.documentElement.clientWidth;
var wh = typeof(window.innerHeight) == 'number' ? window.innerHeight : document.documentElement.clientHeight;
var st = typeof(window.pageYOffset) == 'number' ? window.pageYOffset : document.body && document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
diff --git a/data/js/lib.js b/data/js/lib.js
index 675f2baa..7d0f6b18 100644
--- a/data/js/lib.js
+++ b/data/js/lib.js
@@ -83,7 +83,7 @@ window.tag = function() {
continue;
if(typeof arguments[i] == 'object' && !arguments[i].appendChild) {
for(attr in arguments[i]) {
- if(attr == 'style')
+ if(attr == 'style' || attr.match(/^data-/))
el.setAttribute(attr, arguments[i][attr]);
else
el[ attr == 'class' ? 'className' : attr == 'for' ? 'htmlFor' : attr ] = arguments[i][attr];
diff --git a/data/js/misc.js b/data/js/misc.js
index 89572e82..f41e8140 100644
--- a/data/js/misc.js
+++ b/data/js/misc.js
@@ -1,18 +1,3 @@
-// search box
-byId('sq').onfocus = function () {
- if(this.value == mt('_menu_emptysearch')) {
- this.value = '';
- this.style.fontStyle = 'normal'
- }
-};
-byId('sq').onblur = function () {
- if(this.value.length < 1) {
- this.value = mt('_menu_emptysearch');
- this.style.fontStyle = 'italic'
- }
-};
-
-
function ulist_redirect(type, path, formcode, args) {
var r = new RegExp('/('+type+'[0-9]+).*$');
location.href = location.href.replace(r, '/$1')+path
@@ -210,7 +195,7 @@ if(byId('batchedit'))
// mouse-over price information / disclaimer
(function(){
if(byId('buynow')) {
- var l = byClass(byId('buynow'), 'acronym', 'pricenote');
+ var l = byClass(byId('buynow'), 'abbr', 'pricenote');
for(var i=0; i<l.length; i++) {
l[i].buynow_last = l[i].title;
l[i].title = null;
@@ -257,12 +242,12 @@ if(byId('not') && byId('vns'))
// Language selector
(function(){
var d = byId('lang_select');
- var flag = byName(d, 'acronym')[0];
+ var flag = byName(d, 'abbr')[0];
ddInit(d, 'bottom', function(lnk) {
var lst = tag('ul', null);
for(var i=0; i<VARS.l10n_lang.length; i++) {
var ln = VARS.l10n_lang[i];
- var icon = tag('acronym', {'class':'icons lang '+ln[0]}, ' ');
+ var icon = tag('abbr', {'class':'icons lang '+ln[0]}, ' ');
lst.appendChild(tag('li', {'class':'lang_selector'}, hasClass(flag, ln[0])
? tag('i', icon, ln[1])
: tag('a', {href:'/setlang?lang='+ln[0]+';ref='+encodeURIComponent(location.pathname+location.search)}, icon, ln[1])
diff --git a/data/js/vnscr.js b/data/js/vnscr.js
index acde013d..08d3ffae 100644
--- a/data/js/vnscr.js
+++ b/data/js/vnscr.js
@@ -98,7 +98,7 @@ function loaded(tr, id, width, height) {
tr.scr_loading = 0;
setContent(byName(tr, 'td')[0],
- tag('a', {href: URL(tr.scr_id, 'f'), rel:'iv:'+dim+':edit'},
+ tag('a', {href: URL(tr.scr_id, 'f'), 'data-iv':dim+':edit'},
tag('img', {src: URL(tr.scr_id, 't')})
)
);