BlissROMs updates
New Images
New Downloads section
Less Lag
diff --git a/js/conditionize.js b/js/conditionize.js
new file mode 100644
index 0000000..a9075fc
--- /dev/null
+++ b/js/conditionize.js
@@ -0,0 +1,42 @@
+/* * * * * * * * * * * * * * * * * *
+* Show/hide fields conditionally
+* * * * * * * * * * * * * * * * * */
+(function($) {
+ $.fn.conditionize = function(options){
+
+ var settings = $.extend({
+ hideJS: true
+ }, options );
+
+ $.fn.showOrHide = function(listenTo, listenFor, $section) {
+ if ($(listenTo).is('select, input[type=text]') && $(listenTo).val() == listenFor ) {
+ $section.slideDown();
+ }
+ else if ($(listenTo + ":checked").val() == listenFor) {
+ $section.slideDown();
+ }
+ else {
+ $section.slideUp();
+ }
+ }
+
+ return this.each( function() {
+ var listenTo = "[name=" + $(this).data('cond-option') + "]";
+ var listenFor = $(this).data('cond-value');
+ var $section = $(this);
+
+ //Set up event listener
+ $(listenTo).on('change', function() {
+ $.fn.showOrHide(listenTo, listenFor, $section);
+ });
+ //If setting was chosen, hide everything first...
+ if (settings.hideJS) {
+ $(this).hide();
+ }
+ //Show based on current value on page load
+ $.fn.showOrHide(listenTo, listenFor, $section);
+ });
+ }
+}(jQuery));
+
+ $('.conditional').conditionize();
\ No newline at end of file