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
 
(17 intermediate revisions by the same user not shown)
Line 26: Line 26:
var andBox = " <input type='text' class='queryString' /> ";
var andBox = " <input type='text' class='queryString' /> ";
$("#formSpace").html(orBox);
$("#formSpace").html(orBox);
$(".queryString").focus(function () {
$(".queryString").focusin(function () {
$(".focused").removeClass("focused");
$(".focused").removeClass("focused");
$(this).parent().addClass("focused");
$(this).parent().addClass("focused");
$(".queryString").focusout(function () {
$(".queryString").focusout(function () {
if ($(this).val().length <= 1) {
if ($(this).val().length <= 1) {
$(this).remove();
$(this).remove();
                                        if($(this).parent().length === 0){
}
                                              console.log($(this).parent());
                        clearEmptyDivs();
                                              $(this).parent().remove();
                                        }
}
});
});
});
});
 
function clearEmptyDivs(){
$.each($(":br"), function(){
console.log($(this).parent());
}
$.each($(".query"), function(){
if($(this).children().length === 0){
$(this).remove();
}
});
}
$("#orOp").click(function () {
$("#orOp").click(function () {
$("#formSpace").append(orBox);
$("#formSpace").append(orBox);
Line 48: Line 54:
if ($(this).val().length <= 1) {
if ($(this).val().length <= 1) {
$(this).remove();
$(this).remove();
                                        if($(this).parent().length === 0){
console.log($(this).parent());
                                              $(this).parent().remove();
                                        }
}
}
clearEmptyDivs();
});
});
});
});
Line 66: Line 69:
if ($(this).val().length <= 1) {
if ($(this).val().length <= 1) {
$(this).remove();
$(this).remove();
                                        if($(this).parent().length === 0){
console.log($(this).parent());
                                              $(this).parent().remove();
                                        }
}
}
clearEmptyDivs();
});
});
});
});

Latest revision as of 15:59, 23 October 2013