Search Hot word search associative words

Source: Internet
Author: User

/*
So.js
HEAD search Box JS All the logic is here
by SUNHW 2014-9-22
*/
T.dom.ready (function () {
Search for drop-down associative words
F.load (' Widget.autocomplete.autoComplete ', function () {
var mask = t.get (' So-mask ');
if (!mask) return;
This.show ({
Renderto: ' Soautoword ',
Rendercontentto: ' Soautowrap ',
Padding:1,
Listener: ' So ',
PROXY:F.CONFIG.Q + '/api/search_hint ',
Proxytype:function () {
return document.all? ' Jsonp ': ' Ajax ';
},
Filter: ' Key ',
LINEHEIGHT:32,
PROXYDELAY:500,
Render:function (value, index) {
return value;
},
Handler:function (data, index) {
index = parseint (index, 10);
This.options.listener.value = Data[index];
Document.forms.msearch.submit ();
},
Change:function (data, index) {
index = parseint (index, 10);
var value = Data[index];
This.options.listener.value = value;
},
Show:function (data) {
if (!data.length) {
return false;
}
T.setstyle (Mask, ' height ', this.options.renderContentTo.offsetHeight);
T.show (mask);
},
Close:function () {
T.hide (mask);
T.setstyle (Mask, ' height ', 0);
},
Display:function () {
T.setstyle (Mask, ' height ', this.options.renderContentTo.offsetHeight);
T.show (mask);
}
});
});
Search Hot Words
(function () {
var so = T.get (' so '),
Sounit = T.get (' Sounit '),
Sohotword = T.get (' Sohotword '),
Soautoword = T.get (' Soautoword ');
if (!so | |!sounit) return;
var timer = 0, ttl = 200;
var val = T.trim (so.value), Soword = null;
var onfocus = function () {
Cleartime ();
if (T.trim (so.value) = = val) {
So.value = ";
}
T.addclass (Sounit, ' Show-panel ');
OnKeyup ();
};
var onBlur = function () {
Cleartime ();
Timer = setTimeout (function () {
if (T.trim (so.value). length = = 0) {
So.value = val;
}
T.removeclass (Sounit, ' Show-panel ');
}, TTL);
};
var onKeyup = function (e) {
if (So.value && t.dom.hasclass (sounit, ' Show-panel ')) {
T.hide (Sohotword);
T.show (Soautoword);
}else{
T.hide (Soautoword);
T.show (Sohotword);
}
};
var onSubmit = function (e) {
E= T.event.get (e);
var value = T.trim (So.value);
if (!value | | value = = ") {
T.event.stop (e);
return false;
};
};
var cleartime = function () {
Cleartimeout (timer);
};
Soword = t.getattr (So, ' Soword ');
if (Soword) {
So.value = decodeURIComponent (Soword);
}
T.on (So, ' focus ', onfocus);
T.on (So, ' blur ', OnBlur);
T.on (So, ' KeyUp ', onKeyup);
T.on (document.forms[' Msearch '), ' submit ', onSubmit);
})();
});

Search Hot word search associative words

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.