1/* 2--- 3 4requires: [AbacusAD, MooTools, Class, Class.Extras, DomReady, Element, Element.Event] 5 6provides: [AbacusAD.OtherQuestion] 7 8... 9*/ 10 11(function ($, window, document) { 12 $(window).addEvent("domready", function () { 13 $$(".field.other input, .field.other select").each(function (element) { 14 new AbacusAD.OtherQuestion(element); 15 }); 16 }); 17 18 AbacusAD.OtherQuestion = new Class({ 19 Implements: [Options], 20 options: {}, 21 22 initialize: function (element, options) { 23 this.element = $(element); 24 this.setOptions(options); 25 26 this.setEvents(); 27 }, 28 29 setEvents: function () { 30 var self = this, 31 element = 32 this.element.get("type") == "radio" 33 ? this.element.getParent(".group").getElements("input[type=radio]") 34 : this.element, 35 eventType = this.element.get("type").contains("select") 36 ? "change" 37 : "click"; 38 39 element.addEvent(eventType, function () { 40 self.showHide(this, this.get("type")); 41 }); 42 }, 43 44 showHide: function (element, type) { 45 var inputNext = 46 element.getNext("input.text") || 47 element.getParent().getNext("input.text"), 48 label = inputNext ? inputNext.getPrevious("label") : null, 49 inputParent = element 50 .getParent(".group") 51 .getElement(".other input.text"), 52 parent = element.getParent(".other"), 53 value = type.contains("select") 54 ? element.get("value").contains("other") 55 : null, 56 showLabel = element.getParent(".otherwithlabel"); 57 58 // Radio buttons 59 if (type == "radio") { 60 // Show text input 61 if (parent) { 62 inputNext.removeClass("hide"); 63 } else { 64 inputParent.addClass("hide"); 65 } 66 67 // Show label 68 if (parent && showLabel) { 69 label.removeClass("hide"); 70 } else { 71 inputParent.getPrevious("label").addClass("hide"); 72 } 73 74 // Checkboxes and select dropdowns 75 } else if (type != "text") { 76 // Show text input 77 if (element.checked || value) { 78 inputNext.removeClass("hide"); 79 } else { 80 inputNext.addClass("hide"); 81 } 82 83 // Show label 84 if ((element.checked || value) && showLabel) { 85 label.removeClass("hide"); 86 } else { 87 label.addClass("hide"); 88 } 89 } 90 } 91 }); 92})(document.id, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.