Widget:KeywordSearch: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
$(document).ready(function(){ | $(document).ready(function () { | ||
var orBox = "<div class='query'> <input type='text' class='queryString' /> </div><br />"; | var orBox = "<div class='query'> <input type='text' class='queryString' /> </div><br />"; | ||
var andBox = " <input type='text' class='queryString' /> "; | var andBox = " <input type='text' class='queryString' /> "; | ||
$("#formSpace").html(orBox); | $("#formSpace").html(orBox); | ||
$(".queryString").focus(function(){$(".focused").removeClass( "focused" );$( this ).parent().addClass( "focused" ); $(".queryString").focusout(function(){if($(this).val().length <= 1){$(this).remove();}});}); | $(".queryString").focus(function () { | ||
$(".focused").removeClass("focused"); | |||
$(this).parent().addClass("focused"); | |||
$(".queryString").focusout(function () { | |||
if ($(this).val().length <= 1) { | |||
$(this).remove(); | |||
} | |||
}); | |||
}); | |||
$("#orOp").click(function () { | |||
$("#formSpace").append(orBox); | |||
$(".queryString").focus(function () { | |||
$(".focused").removeClass("focused"); | |||
$(this).parent().addClass("focused"); | |||
$(".queryString").focusout(function () { | |||
if ($(this).val().length <= 1) { | |||
$(this).remove(); | |||
} | |||
}); | |||
}); | |||
}); | |||
$("# | $("#andOp").click(function () { | ||
$(" | var andBox = "<input type='text' class='queryString' />"; | ||
$(".queryString").focus(function(){$(".focused").removeClass( "focused" );$( this ).parent().addClass( "focused" ); $(".queryString").focusout(function(){if($(this).val().length <= 1){$(this).remove();}});}); | $(".focused").append(andBox); | ||
}); | $(".queryString").focus(function () { | ||
$(".focused").removeClass("focused"); | |||
$(this).parent().addClass("focused"); | |||
$(".queryString").focusout(function () { | |||
if ($(this).val().length <= 1) { | |||
$(this).remove(); | |||
} | |||
}); | |||
}); | |||
}); | |||
$("# | $("#showQueries").click(function () { | ||
var | var testVar = []; | ||
$(". | testVar = $(".query").map(function () { | ||
return getStrings($(this).children()); | |||
} | }); | ||
}); | |||
function getStrings(obj) { | |||
var outArr = []; | |||
outArr[outArr.length] = $.each(obj, function (ind, tal) { | |||
var string = $(this).val(); | |||
return string; | |||
}); | |||
return outArr; | |||
} | |||
} | |||
</script> | </script> | ||
<form> | <form> |