/*
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