1ShadowForm = function () 2{ 3 if (arguments.length) 4 { 5 this.src = arguments[0]; 6 this.tgt = arguments[1]; 7 var i, c, els = this.src.elements, n, visto = {}, el, shadow = this, t, tgtEl; 8 9 for (i = 0, c = els.length; i < c; i++) 10 { 11 el = els[i]; 12 if (!visto[n = this.getName(el)] && n.length) 13 { 14 switch(t = this.getType(el)) 15 { 16 default: 17 jQuery(el).blur(this.anonCopyToTgt(shadow)); 18 if (t.match(/^(submit|image)$/)) 19 { 20 jQuery(el).click(this.anonSubmitClick(shadow)); 21 } 22 break; 23 } 24 25 if (tgtEl = this.getElByName(n, this.tgt)) 26 { 27 this.setElVal(el, this.getElVal(tgtEl)); 28 } 29 30 visto[n] = true; 31 } 32 } 33 34 if (arguments[2]) 35 { 36 arguments[2](this); 37 } 38 } 39} 40new ShadowForm(); 41ShadowForm.prototype = 42{ 43 "src": null, 44 "tgt": null, 45 "getName": function(el) 46 { 47 var n; 48 if (n = el.name) 49 { 50 return n; 51 } 52 else if (el.length && el[0]) 53 { 54 return el[0].name; 55 } 56 else 57 { 58 return ""; 59 } 60 }, 61 "getElByName": function(name, form) 62 { 63 var el = form[name]; 64 if (!el) 65 { 66 el = jQuery("*[name='"+name+"']", form).get(); 67 } 68 return el; 69 }, 70 "getType": function(el) 71 { 72 var t; 73 if (t = el.type) 74 { 75 return t; 76 } 77 else if (el.length && el[0]) 78 { 79 return el[0].type; 80 } 81 else 82 { 83 return ""; 84 } 85 }, 86 "setElVal": function(el, value) 87 { 88 var i, c, opts; 89 90 switch (this.getType(el)) 91 { 92 case 'radio': 93 for (i = 0, c = el.length; i < c; i++) 94 { 95 if (el[i].value == value) 96 { 97 el[i].checked = true; 98 break; 99 } 100 } 101 break; 102 case 'checkbox': 103 if (el.value == value) 104 { 105 el.checked = true; 106 } 107 else 108 { 109 el.checked = false; 110 } 111 break; 112 case 'select-one': 113 opts = el.options; 114 for (i = 0, c = opts.length; i < c; i++) 115 { 116 if (opts[i].value == value) 117 { 118 opts[i].selected = true; 119 break; 120 } 121 } 122 break; 123 default: 124 el.value = value; 125 break; 126 } 127 }, 128 "getElVal": function(el) 129 { 130 var i, c, opts, value = ""; 131 132 switch (this.getType(el)) 133 { 134 case 'radio': 135 for (i = 0, c = el.length; i < c; i++) 136 { 137 if (el[i].checked) 138 { 139 value = el[i].value; 140 break; 141 } 142 } 143 break; 144 case 'checkbox': 145 if (el.checked) 146 { 147 value = el.value; 148 } 149 break; 150 case 'select-one': 151 value = el.options[el.selectedIndex].value; 152 break; 153 default: 154 value = el.value; 155 break; 156 } 157 return value ? value : ""; 158 }, 159 "copyToTgt": function(elSrc) 160 { 161 var n = this.getName(elSrc); 162 var tgtEl = this.getElByName(n, this.tgt); 163 var srcEl = this.getElByName(n, this.src); 164 if (tgtEl && srcEl) 165 { 166 this.setElVal(tgtEl, this.getElVal(srcEl)); 167 } 168 }, 169 "anonCopyToTgt": function(shadow) 170 { 171 var f = function() 172 { 173 shadow.copyToTgt(this); 174 }; 175 return f; 176 }, 177 "submitClick": function(elSrc) 178 { 179 var tgtEl = this.getElByName(this.getName(elSrc), this.tgt); 180 181 if (tgtEl) 182 { 183 jQuery(tgtEl).trigger("click"); 184 } 185 }, 186 "anonSubmitClick": function(shadow) 187 { 188 var f = function() 189 { 190 shadow.submitClick(this); 191 return false; 192 }; 193 return f; 194 } 195};
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.