Sphider v1.3.5 Modification
---------------------------
Name And Version
----------------
[MOD] Placeholder v1.0.0
Description
-----------
This mod will add a placeholder to your search box. and be removed
when it loses focus.
01. replace the following code from search_form.html with the code from code1.txt
<input type="text" name="query" id="query" size="40" value="<? print quote_replace($query);?>" action="include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500">
02. Add the code from code2.txt to the header file. Somewhere between <head> AND </head>
03. Copy placeholder.js to the include folder.
CODE1.TXT
<input type="text" name="query" id="query" size="40" value="<?php print quote_replace($query);?>" action="include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500" placeholder="Search" onfocus="cph(this.id);" onblur="aph(this.id);">
CODE2.TXT
<script language="javascript" src="include/placeholder.js" type="text/javascript"></script>
PLACEHOLDER.JS
function aph(elID) {
if(document.getElementById(elID)) {
var el = document.getElementById(elID);
console.log(el);
var pH = el.getAttribute('placeholder');
console.log(el.getAttribute('placeholder'));
if(pH !== 'undefined' && el.value == '') {
el.value = pH;
el.className += 'placeheld';
}
}
}
function cph(elID) {
if(document.getElementById(elID)) {
var el = document.getElementById(elID);
console.log(el);
var pH = el.getAttribute('placeholder');
if(pH !== 'undefined' && el.value == pH) {
el.value = '';
el.className = el.className.replace('placeheld','');
}
}
}
var myElIDs = ['myinput','myinput2'];
console.log(myElIDs);
for(var i in myElIDs) {
if(document.getElementById(myElIDs)) {
console.log(document.getElementById(myElIDs));
aph(myElIDs);
}
}
By David Sierowski