Created
July 23, 2009 11:00
-
-
Save paulanthonywilson/152734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bind_label_hiding(){ | |
$("div.feedback_row label").each(function(index, item){ | |
var field = $("#" + $(item).attr("for")); | |
field.bind("focus", function(){ | |
$(item).hide(); | |
}); | |
field.bind("blur", function(){ | |
if (jQuery.trim(field.attr("value")) == "") $(item).show(); | |
}); | |
if (jQuery.trim(field.attr("value")) != "") $(item).hide(); | |
}); | |
} | |
function attach_feedback_ujs(){ | |
// bind_label_hiding(); | |
bind_tab_activation(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("FeedbackLabelHiding", function(){ | |
describe("on load ", function(){ | |
before(function(){ | |
$("#labeltext1").show(); | |
}); | |
describe("with no text entered ", function(){ | |
it("should not hide the label", function(){ | |
$("#text1").attr("value", ""); | |
attach_feedback_ujs(); | |
expect($("#labeltext1")).to(be_visible); | |
}); | |
}); | |
describe("with text entered ", function(){ | |
it("should hide the label", function(){ | |
$("#text1").attr("value", "hi"); | |
attach_feedback_ujs(); | |
expect($("#labeltext1")).to_not(be_visible); | |
}); | |
}); | |
describe("with empty string entered ", function(){ | |
it("should not hide the label", function(){ | |
$("#text1").attr("value", " "); | |
attach_feedback_ujs(); | |
expect($("#labeltext1")).to(be_visible); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment