Produced by Araxis Merge on 5/25/2018 9:21:42 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\AraxisMergeCompare\Pri_un\ZIP\DSM-cif\Direct Implementation\java\config\config-ui\src\main\webapp\resources\jqueryform\2.47\.svn\text-base | jquery.form.js.svn-base | Tue May 22 13:50:22 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-ui\src\main\webapp\resources\jqueryform\2.47\.svn\text-base | jquery.form.js.svn-base | Wed May 23 16:41:59 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1348 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /*! | |
| 2 | * jQuery Form Plugi n | |
| 3 | * version : 2.43 (12 -MAR-2010) | |
| 4 | * @requir es jQuery v1.3.2 or later | |
| 5 | * | |
| 6 | * Example s and docu mentation at: http:/ /malsup.co m/jquery/f orm/ | |
| 7 | * Dual li censed und er the MIT and GPL l icenses: | |
| 8 | * http: //www.open source.org /licenses/ mit-licens e.php | |
| 9 | * http: //www.gnu. org/licens es/gpl.htm l | |
| 10 | */ | |
| 11 | ;(function ($) { | |
| 12 | ||
| 13 | /* | |
| 14 | Us age Note: | |
| 15 | -- --------- | |
| 16 | Do not use b oth ajaxSu bmit and a jaxForm on the same form. The se | |
| 17 | fu nctions ar e intended to be exc lusive. U se ajaxSub mit if you want | |
| 18 | to bind your own submi t handler to the for m. For ex ample, | |
| 19 | ||
| 20 | $( document). ready(func tion() { | |
| 21 | $('# myForm').b ind('submi t', functi on() { | |
| 22 | $(this ).ajaxSubm it({ | |
| 23 | target: '#output' | |
| 24 | }); | |
| 25 | return false; // <-- impor tant! | |
| 26 | }); | |
| 27 | }) ; | |
| 28 | ||
| 29 | Us e ajaxForm when you want the p lugin to m anage all the event binding | |
| 30 | fo r you. Fo r example, | |
| 31 | ||
| 32 | $( document). ready(func tion() { | |
| 33 | $('# myForm').a jaxForm({ | |
| 34 | target : '#output ' | |
| 35 | }); | |
| 36 | }) ; | |
| 37 | ||
| 38 | Wh en using a jaxForm, t he ajaxSub mit functi on will be invoked f or you | |
| 39 | at the appro priate tim e. | |
| 40 | */ | |
| 41 | ||
| 42 | /** | |
| 43 | * ajaxSub mit() prov ides a mec hanism for immediate ly submitt ing | |
| 44 | * an HTML form usin g AJAX. | |
| 45 | */ | |
| 46 | $.fn.ajaxS ubmit = fu nction(opt ions) { | |
| 47 | // fast fail if nothin g selected (http://d ev.jquery. com/ticket /2752) | |
| 48 | if (!this.le ngth) { | |
| 49 | log( 'ajaxSubmi t: skippin g submit p rocess - n o element selected') ; | |
| 50 | retu rn this; | |
| 51 | } | |
| 52 | ||
| 53 | if (typeof o ptions == 'function' ) | |
| 54 | opti ons = { su ccess: opt ions }; | |
| 55 | ||
| 56 | va r url = $. trim(this. attr('acti on')); | |
| 57 | if (url) { | |
| 58 | // c lean url ( don't incl ude hash v aue) | |
| 59 | url = (url.mat ch(/^([^#] +)/)||[])[ 1]; | |
| 60 | } | |
| 61 | ur l = url || window.lo cation.hre f || ''; | |
| 62 | ||
| 63 | op tions = $. extend({ | |
| 64 | url: url, | |
| 65 | type : this.att r('method' ) || 'GET' , | |
| 66 | ifra meSrc: /^h ttps/i.tes t(window.l ocation.hr ef || '') ? 'javascr ipt:false' : 'about: blank' | |
| 67 | }, options | | {}); | |
| 68 | ||
| 69 | // hook for manipulati ng the for m data bef ore it is extracted; | |
| 70 | // convenien t for use with rich editors li ke tinyMCE or FCKEdi tor | |
| 71 | va r veto = { }; | |
| 72 | th is.trigger ('form-pre -serialize ', [this, options, v eto]); | |
| 73 | if (veto.vet o) { | |
| 74 | log( 'ajaxSubmi t: submit vetoed via form-pre- serialize trigger'); | |
| 75 | retu rn this; | |
| 76 | } | |
| 77 | ||
| 78 | // provide o pportunity to alter form data before it is seriali zed | |
| 79 | if (options. beforeSeri alize && o ptions.bef oreSeriali ze(this, o ptions) == = false) { | |
| 80 | log( 'ajaxSubmi t: submit aborted vi a beforeSe rialize ca llback'); | |
| 81 | retu rn this; | |
| 82 | } | |
| 83 | ||
| 84 | va r a = this .formToArr ay(options .semantic) ; | |
| 85 | if (options. data) { | |
| 86 | opti ons.extraD ata = opti ons.data; | |
| 87 | for (var n in options.da ta) { | |
| 88 | if (options.d ata[n] ins tanceof Ar ray) { | |
| 89 | for (v ar k in op tions.data [n]) | |
| 90 | a.pu sh( { name : n, value : options. data[n][k] } ); | |
| 91 | } | |
| 92 | el se | |
| 93 | a.pus h( { name: n, value: options.d ata[n] } ) ; | |
| 94 | } | |
| 95 | } | |
| 96 | ||
| 97 | // give pre- submit cal lback an o pportunity to abort the submit | |
| 98 | if (options. beforeSubm it && opti ons.before Submit(a, this, opti ons) === f alse) { | |
| 99 | log( 'ajaxSubmi t: submit aborted vi a beforeSu bmit callb ack'); | |
| 100 | retu rn this; | |
| 101 | } | |
| 102 | ||
| 103 | // fire veto able 'vali date' even t | |
| 104 | th is.trigger ('form-sub mit-valida te', [a, t his, optio ns, veto]) ; | |
| 105 | if (veto.vet o) { | |
| 106 | log( 'ajaxSubmi t: submit vetoed via form-subm it-validat e trigger' ); | |
| 107 | retu rn this; | |
| 108 | } | |
| 109 | ||
| 110 | va r q = $.pa ram(a); | |
| 111 | ||
| 112 | if (options. type.toUpp erCase() = = 'GET') { | |
| 113 | opti ons.url += (options. url.indexO f('?') >= 0 ? '&' : '?') + q; | |
| 114 | opti ons.data = null; // data is n ull for 'g et' | |
| 115 | } | |
| 116 | el se | |
| 117 | opti ons.data = q; // dat a is the q uery strin g for 'pos t' | |
| 118 | ||
| 119 | va r $form = this, call backs = [] ; | |
| 120 | if (options. resetForm) callbacks .push(func tion() { $ form.reset Form(); }) ; | |
| 121 | if (options. clearForm) callbacks .push(func tion() { $ form.clear Form(); }) ; | |
| 122 | ||
| 123 | // perform a load on t he target only if da taType is not provid ed | |
| 124 | if (!options .dataType && options .target) { | |
| 125 | var oldSuccess = options .success | | function (){}; | |
| 126 | call backs.push (function( data) { | |
| 127 | var fn = options .replaceTa rget ? 're placeWith' : 'html'; | |
| 128 | $(opti ons.target )[fn](data ).each(old Success, a rguments); | |
| 129 | }); | |
| 130 | } | |
| 131 | el se if (opt ions.succe ss) | |
| 132 | call backs.push (options.s uccess); | |
| 133 | ||
| 134 | op tions.succ ess = func tion(data, status, x hr) { // j Query 1.4+ passes xh r as 3rd a rg | |
| 135 | for (var i=0, max=callba cks.length ; i < max; i++) | |
| 136 | callba cks[i].app ly(options , [data, s tatus, xhr || $form, $form]); | |
| 137 | }; | |
| 138 | ||
| 139 | // are there files to upload? | |
| 140 | va r files = $('input:f ile', this ).fieldVal ue(); | |
| 141 | va r found = false; | |
| 142 | fo r (var j=0 ; j < file s.length; j++) | |
| 143 | if ( files[j]) | |
| 144 | found = true; | |
| 145 | ||
| 146 | va r multipar t = false; | |
| 147 | // va r mp = 'mu ltipart/fo rm-data'; | |
| 148 | // mu ltipart = ($form.att r('enctype ') == mp | | $form.at tr('encodi ng') == mp ); | |
| 149 | ||
| 150 | // options.i frame allo ws user to force ifr ame mode | |
| 151 | // 06-NOV-09 : now defa ulting to iframe mod e if file input is d etected | |
| 152 | if ((fi les.length && option s.iframe ! == false) || options .iframe || found || multipart) { | |
| 153 | // hack t o fix Safa ri hang (t hanks to T im Molendi jk for thi s) | |
| 154 | // see: http://gro ups.google .com/group /jquery-de v/browse_t hread/thre ad/36395b7 ab510dd5d | |
| 155 | if (optio ns.closeKe epAlive) | |
| 156 | $ .get(optio ns.closeKe epAlive, f ileUpload) ; | |
| 157 | else | |
| 158 | f ileUpload( ); | |
| 159 | } | |
| 160 | else | |
| 161 | $.ajax(op tions); | |
| 162 | ||
| 163 | // fire 'not ify' event | |
| 164 | th is.trigger ('form-sub mit-notify ', [this, options]); | |
| 165 | re turn this; | |
| 166 | ||
| 167 | ||
| 168 | // private f unction fo r handling file uplo ads (hat t ip to YAHO O!) | |
| 169 | fu nction fil eUpload() { | |
| 170 | var form = $fo rm[0]; | |
| 171 | ||
| 172 | if ( $(':input[ name=submi t]', form) .length) { | |
| 173 | alert( 'Error: Fo rm element s must not be named "submit".' ); | |
| 174 | return ; | |
| 175 | } | |
| 176 | ||
| 177 | var opts = $.e xtend({}, $.ajaxSett ings, opti ons); | |
| 178 | var s = $.exte nd(true, { }, $.exten d(true, {} , $.ajaxSe ttings), o pts); | |
| 179 | ||
| 180 | var id = 'jqFo rmIO' + (n ew Date(). getTime()) ; | |
| 181 | var $io = $('< iframe id= "' + id + '" name="' + id + '" src="'+ o pts.iframe Src +'" on load="(jQu ery(this). data(\'for m-plugin-o nload\'))( )" />'); | |
| 182 | var io = $io[0 ]; | |
| 183 | ||
| 184 | $io. css({ posi tion: 'abs olute', to p: '-1000p x', left: '-1000px' }); | |
| 185 | ||
| 186 | var xhr = { // mock obje ct | |
| 187 | aborte d: 0, | |
| 188 | respon seText: nu ll, | |
| 189 | respon seXML: nul l, | |
| 190 | status : 0, | |
| 191 | status Text: 'n/a ', | |
| 192 | getAll ResponseHe aders: fun ction() {} , | |
| 193 | getRes ponseHeade r: functio n() {}, | |
| 194 | setReq uestHeader : function () {}, | |
| 195 | abort: function( ) { | |
| 196 | this.abo rted = 1; | |
| 197 | $io.attr ('src', op ts.iframeS rc); // ab ort op in progress | |
| 198 | } | |
| 199 | }; | |
| 200 | ||
| 201 | var g = opts.g lobal; | |
| 202 | // t rigger aja x global e vents so t hat activi ty/block i ndicators work like normal | |
| 203 | if ( g && ! $.a ctive++) $ .event.tri gger("ajax Start"); | |
| 204 | if ( g) $.event .trigger(" ajaxSend", [xhr, opt s]); | |
| 205 | ||
| 206 | if ( s.beforeSe nd && s.be foreSend(x hr, s) === false) { | |
| 207 | s.glob al && $.ac tive--; | |
| 208 | return ; | |
| 209 | } | |
| 210 | if ( xhr.aborte d) | |
| 211 | return ; | |
| 212 | ||
| 213 | var cbInvoked = false; | |
| 214 | var timedOut = 0; | |
| 215 | ||
| 216 | // a dd submitt ing elemen t to data if we know it | |
| 217 | var sub = form .clk; | |
| 218 | if ( sub) { | |
| 219 | var n = sub.name ; | |
| 220 | if (n && !sub.di sabled) { | |
| 221 | opts.ext raData = o pts.extraD ata || {}; | |
| 222 | opts.ext raData[n] = sub.valu e; | |
| 223 | if (sub. type == "i mage") { | |
| 224 | opts.extra Data[n+'.x '] = form. clk_x; | |
| 225 | opts.extra Data[n+'.y '] = form. clk_y; | |
| 226 | } | |
| 227 | } | |
| 228 | } | |
| 229 | ||
| 230 | // t ake a brea th so that pending r epaints ge t some cpu time befo re the upl oad starts | |
| 231 | func tion doSub mit() { | |
| 232 | // mak e sure for m attrs ar e set | |
| 233 | var t = $form.at tr('target '), a = $f orm.attr(' action'); | |
| 234 | ||
| 235 | // upd ate form a ttrs in IE friendly way | |
| 236 | form.s etAttribut e('target' ,id); | |
| 237 | if (fo rm.getAttr ibute('met hod') != ' POST') | |
| 238 | form.set Attribute( 'method', 'POST'); | |
| 239 | if (fo rm.getAttr ibute('act ion') != o pts.url) | |
| 240 | form.set Attribute( 'action', opts.url); | |
| 241 | ||
| 242 | // ie borks in s ome cases when setti ng encodin g | |
| 243 | if (! opts.skipE ncodingOve rride) { | |
| 244 | $form.at tr({ | |
| 245 | encoding: 'multipart /form-data ', | |
| 246 | enctype: 'multipart /form-data ' | |
| 247 | }); | |
| 248 | } | |
| 249 | ||
| 250 | // sup port timou t | |
| 251 | if (op ts.timeout ) | |
| 252 | setTimeo ut(functio n() { time dOut = tru e; cb(); } , opts.tim eout); | |
| 253 | ||
| 254 | // add "extra" d ata to for m if provi ded in opt ions | |
| 255 | var ex traInputs = []; | |
| 256 | try { | |
| 257 | if (opts .extraData ) | |
| 258 | for (var n in opts.e xtraData) | |
| 259 | ex traInputs. push( | |
| 260 | $('< input type ="hidden" name="'+n+ '" value=" '+opts.ext raData[n]+ '" />') | |
| 261 | .appen dTo(form)[ 0]); | |
| 262 | ||
| 263 | // add i frame to d oc and sub mit the fo rm | |
| 264 | $io.appe ndTo('body '); | |
| 265 | $io.data ('form-plu gin-onload ', cb); | |
| 266 | form.sub mit(); | |
| 267 | } | |
| 268 | finall y { | |
| 269 | // reset attrs and remove "e xtra" inpu t elements | |
| 270 | form.set Attribute( 'action',a ); | |
| 271 | t ? form .setAttrib ute('targe t', t) : $ form.remov eAttr('tar get'); | |
| 272 | $(extraI nputs).rem ove(); | |
| 273 | } | |
| 274 | }; | |
| 275 | ||
| 276 | if ( opts.force Sync) | |
| 277 | doSubm it(); | |
| 278 | else | |
| 279 | setTim eout(doSub mit, 10); // this le ts dom upd ates rende r | |
| 280 | ||
| 281 | var domCheckCo unt = 100; | |
| 282 | ||
| 283 | func tion cb() { | |
| 284 | if (cb Invoked) | |
| 285 | return; | |
| 286 | ||
| 287 | var ok = true; | |
| 288 | try { | |
| 289 | if (time dOut) thro w 'timeout '; | |
| 290 | // extra ct the ser ver respon se from th e iframe | |
| 291 | var data , doc; | |
| 292 | ||
| 293 | doc = io .contentWi ndow ? io. contentWin dow.docume nt : io.co ntentDocum ent ? io.c ontentDocu ment : io. document; | |
| 294 | ||
| 295 | var isXm l = opts.d ataType == 'xml' || doc.XMLDoc ument || $ .isXMLDoc( doc); | |
| 296 | log('isX ml='+isXml ); | |
| 297 | if (!isX ml && (doc .body == n ull || doc .body.inne rHTML == ' ')) { | |
| 298 | if (--domC heckCount) { | |
| 299 | // in some b rowsers (O pera) the iframe DOM is not al ways trave rsable whe n | |
| 300 | // the onloa d callback fires, so we loop a bit to ac commodate | |
| 301 | lo g('requein g onLoad c allback, D OM not ava ilable'); | |
| 302 | se tTimeout(c b, 250); | |
| 303 | re turn; | |
| 304 | } | |
| 305 | log('Could not acces s iframe D OM after 1 00 tries.' ); | |
| 306 | return; | |
| 307 | } | |
| 308 | ||
| 309 | log('res ponse dete cted'); | |
| 310 | cbInvoke d = true; | |
| 311 | xhr.resp onseText = doc.body ? doc.body .innerHTML : null; | |
| 312 | xhr.resp onseXML = doc.XMLDoc ument ? do c.XMLDocum ent : doc; | |
| 313 | xhr.getR esponseHea der = func tion(heade r){ | |
| 314 | var header s = {'cont ent-type': opts.data Type}; | |
| 315 | return hea ders[heade r]; | |
| 316 | }; | |
| 317 | ||
| 318 | if (opts .dataType == 'json' || opts.da taType == 'script') { | |
| 319 | // see if user embed ded respon se in text area | |
| 320 | var ta = d oc.getElem entsByTagN ame('texta rea')[0]; | |
| 321 | if (ta) | |
| 322 | xh r.response Text = ta. value; | |
| 323 | else { | |
| 324 | // account f or browser s injectin g pre arou nd json re sponse | |
| 325 | va r pre = do c.getEleme ntsByTagNa me('pre')[ 0]; | |
| 326 | if (pre) | |
| 327 | xhr. responseTe xt = pre.i nnerHTML; | |
| 328 | } | |
| 329 | } | |
| 330 | else if (opts.data Type == 'x ml' && !xh r.response XML && xhr .responseT ext != nul l) { | |
| 331 | xhr.respon seXML = to Xml(xhr.re sponseText ); | |
| 332 | } | |
| 333 | data = $ .httpData( xhr, opts. dataType); | |
| 334 | } | |
| 335 | catch( e){ | |
| 336 | log('err or caught: ',e); | |
| 337 | ok = fal se; | |
| 338 | xhr.erro r = e; | |
| 339 | $.handle Error(opts , xhr, 'er ror', e); | |
| 340 | } | |
| 341 | ||
| 342 | // ord ering of t hese callb acks/trigg ers is odd , but that 's how $.a jax does i t | |
| 343 | if (ok ) { | |
| 344 | opts.suc cess(data, 'success' ); | |
| 345 | if (g) $ .event.tri gger("ajax Success", [xhr, opts ]); | |
| 346 | } | |
| 347 | if (g) $.event.t rigger("aj axComplete ", [xhr, o pts]); | |
| 348 | if (g && ! --$.a ctive) $.e vent.trigg er("ajaxSt op"); | |
| 349 | if (op ts.complet e) opts.co mplete(xhr , ok ? 'su ccess' : ' error'); | |
| 350 | ||
| 351 | // cle an up | |
| 352 | setTim eout(funct ion() { | |
| 353 | $io.remo veData('fo rm-plugin- onload'); | |
| 354 | $io.remo ve(); | |
| 355 | xhr.resp onseXML = null; | |
| 356 | }, 100 ); | |
| 357 | }; | |
| 358 | ||
| 359 | func tion toXml (s, doc) { | |
| 360 | if (wi ndow.Activ eXObject) { | |
| 361 | doc = ne w ActiveXO bject('Mic rosoft.XML DOM'); | |
| 362 | doc.asyn c = 'false '; | |
| 363 | doc.load XML(s); | |
| 364 | } | |
| 365 | else | |
| 366 | doc = (n ew DOMPars er()).pars eFromStrin g(s, 'text /xml'); | |
| 367 | return (doc && d oc.documen tElement & & doc.docu mentElemen t.tagName != 'parser error') ? doc : null ; | |
| 368 | }; | |
| 369 | }; | |
| 370 | }; | |
| 371 | ||
| 372 | /** | |
| 373 | * ajaxFor m() provid es a mecha nism for f ully autom ating form submissio n. | |
| 374 | * | |
| 375 | * The adv antages of using thi s method i nstead of ajaxSubmit () are: | |
| 376 | * | |
| 377 | * 1: This method wi ll include coordinat es for <in put type=" image" /> elements ( if the ele ment | |
| 378 | * is used to s ubmit the form). | |
| 379 | * 2. This method wi ll include the submi t element' s name/val ue data (f or the ele ment that was | |
| 380 | * us ed to subm it the for m). | |
| 381 | * 3. This method bi nds the su bmit() met hod to the form for you. | |
| 382 | * | |
| 383 | * The opt ions argum ent for aj axForm wor ks exactly as it doe s for ajax Submit. a jaxForm me rely | |
| 384 | * passes the option s argument along aft er properl y binding events for submit el ements and | |
| 385 | * the for m itself. | |
| 386 | */ | |
| 387 | $.fn.ajaxF orm = func tion(optio ns) { | |
| 388 | re turn this. ajaxFormUn bind().bin d('submit. form-plugi n', functi on(e) { | |
| 389 | e.pr eventDefau lt(); | |
| 390 | $(th is).ajaxSu bmit(optio ns); | |
| 391 | }) .bind('cli ck.form-pl ugin', fun ction(e) { | |
| 392 | var target = e .target; | |
| 393 | var $el = $(ta rget); | |
| 394 | if ( !($el.is(" :submit,in put:image" ))) { | |
| 395 | // is this a chi ld element of the su bmit el? (ex: a spa n within a button) | |
| 396 | var t = $el.clos est(':subm it'); | |
| 397 | if (t. length == 0) | |
| 398 | return; | |
| 399 | target = t[0]; | |
| 400 | } | |
| 401 | var form = thi s; | |
| 402 | form .clk = tar get; | |
| 403 | if ( target.typ e == 'imag e') { | |
| 404 | if (e. offsetX != undefined ) { | |
| 405 | form.clk _x = e.off setX; | |
| 406 | form.clk _y = e.off setY; | |
| 407 | } else if (typeo f $.fn.off set == 'fu nction') { // try to use dimen sions plug in | |
| 408 | var offs et = $el.o ffset(); | |
| 409 | form.clk _x = e.pag eX - offse t.left; | |
| 410 | form.clk _y = e.pag eY - offse t.top; | |
| 411 | } else { | |
| 412 | form.clk _x = e.pag eX - targe t.offsetLe ft; | |
| 413 | form.clk _y = e.pag eY - targe t.offsetTo p; | |
| 414 | } | |
| 415 | } | |
| 416 | // c lear form vars | |
| 417 | setT imeout(fun ction() { form.clk = form.clk_ x = form.c lk_y = nul l; }, 100) ; | |
| 418 | }) ; | |
| 419 | }; | |
| 420 | ||
| 421 | // ajaxFor mUnbind un binds the event hand lers that were bound by ajaxFo rm | |
| 422 | $.fn.ajaxF ormUnbind = function () { | |
| 423 | re turn this. unbind('su bmit.form- plugin cli ck.form-pl ugin'); | |
| 424 | }; | |
| 425 | ||
| 426 | /** | |
| 427 | * formToA rray() gat hers form element da ta into an array of objects th at can | |
| 428 | * be pass ed to any of the fol lowing aja x function s: $.get, $.post, or load. | |
| 429 | * Each ob ject in th e array ha s both a ' name' and 'value' pr operty. A n example of | |
| 430 | * an arra y for a si mple login form migh t be: | |
| 431 | * | |
| 432 | * [ { nam e: 'userna me', value : ' USR ' }, { nam e: 'passwo rd', value : ' PW ' } ] | |
| 433 | * | |
| 434 | * It is t his array that is pa ssed to pr e-submit c allback fu nctions pr ovided to the | |
| 435 | * ajaxSub mit() and ajaxForm() methods. | |
| 436 | */ | |
| 437 | $.fn.formT oArray = f unction(se mantic) { | |
| 438 | va r a = []; | |
| 439 | if (this.len gth == 0) return a; | |
| 440 | ||
| 441 | va r form = t his[0]; | |
| 442 | va r els = se mantic ? f orm.getEle mentsByTag Name('*') : form.ele ments; | |
| 443 | if (!els) re turn a; | |
| 444 | fo r(var i=0, max=els.l ength; i < max; i++) { | |
| 445 | var el = els[i ]; | |
| 446 | var n = el.nam e; | |
| 447 | if ( !n) contin ue; | |
| 448 | ||
| 449 | if ( semantic & & form.clk && el.typ e == "imag e") { | |
| 450 | // han dle image inputs on the fly wh en semanti c == true | |
| 451 | if(!el .disabled && form.cl k == el) { | |
| 452 | a.push({ name: n, v alue: $(el ).val()}); | |
| 453 | a.push({ name: n+'. x', value: form.clk_ x}, {name: n+'.y', v alue: form .clk_y}); | |
| 454 | } | |
| 455 | contin ue; | |
| 456 | } | |
| 457 | ||
| 458 | var v = $.fiel dValue(el, true); | |
| 459 | if ( v && v.con structor = = Array) { | |
| 460 | for(va r j=0, jma x=v.length ; j < jmax ; j++) | |
| 461 | a.push({ name: n, v alue: v[j] }); | |
| 462 | } | |
| 463 | else if (v !== null && t ypeof v != 'undefine d') | |
| 464 | a.push ({name: n, value: v} ); | |
| 465 | } | |
| 466 | ||
| 467 | if (!semanti c && form. clk) { | |
| 468 | // i nput type= ='image' a re not fou nd in elem ents array ! handle i t here | |
| 469 | var $input = $ (form.clk) , input = $input[0], n = input .name; | |
| 470 | if ( n && !inpu t.disabled && input. type == 'i mage') { | |
| 471 | a.push ({name: n, value: $i nput.val() }); | |
| 472 | a.push ({name: n+ '.x', valu e: form.cl k_x}, {nam e: n+'.y', value: fo rm.clk_y}) ; | |
| 473 | } | |
| 474 | } | |
| 475 | re turn a; | |
| 476 | }; | |
| 477 | ||
| 478 | /** | |
| 479 | * Seriali zes form d ata into a 'submitta ble' strin g. This me thod will return a s tring | |
| 480 | * in the format: na me1=value1 &name2 =value2 | |
| 481 | */ | |
| 482 | $.fn.formS erialize = function( semantic) { | |
| 483 | // hand off t o jQuery.p aram for p roper enco ding | |
| 484 | re turn $.par am(this.fo rmToArray( semantic)) ; | |
| 485 | }; | |
| 486 | ||
| 487 | /** | |
| 488 | * Seriali zes all fi eld elemen ts in the jQuery obj ect into a query str ing. | |
| 489 | * This me thod will return a s tring in t he format: name1=val ue1&na me2=value2 | |
| 490 | */ | |
| 491 | $.fn.field Serialize = function (successfu l) { | |
| 492 | va r a = []; | |
| 493 | th is.each(fu nction() { | |
| 494 | var n = this.n ame; | |
| 495 | if ( !n) return ; | |
| 496 | var v = $.fiel dValue(thi s, success ful); | |
| 497 | if ( v && v.con structor = = Array) { | |
| 498 | for (v ar i=0,max =v.length; i < max; i++) | |
| 499 | a.push({ name: n, v alue: v[i] }); | |
| 500 | } | |
| 501 | else if (v !== null && t ypeof v != 'undefine d') | |
| 502 | a.push ({name: th is.name, v alue: v}); | |
| 503 | }) ; | |
| 504 | // hand off t o jQuery.p aram for p roper enco ding | |
| 505 | re turn $.par am(a); | |
| 506 | }; | |
| 507 | ||
| 508 | /** | |
| 509 | * Returns the value (s) of the element i n the matc hed set. For exampl e, conside r the foll owing form : | |
| 510 | * | |
| 511 | * <form> <fieldset> | |
| 512 | * <input nam e="A" type ="text" /> | |
| 513 | * <input nam e="A" type ="text" /> | |
| 514 | * <input nam e="B" type ="checkbox " value="B 1" /> | |
| 515 | * <input nam e="B" type ="checkbox " value="B 2"/> | |
| 516 | * <input nam e="C" type ="radio" v alue="C1" /> | |
| 517 | * <input nam e="C" type ="radio" v alue="C2" /> | |
| 518 | * </fiel dset></for m> | |
| 519 | * | |
| 520 | * var v = $(':text ').fieldVa lue(); | |
| 521 | * // if no values are entere d into the text inpu ts | |
| 522 | * v == [ '',''] | |
| 523 | * // if values ent ered into the text i nputs are 'foo' and 'bar' | |
| 524 | * v == [ 'foo','bar '] | |
| 525 | * | |
| 526 | * var v = $(':chec kbox').fie ldValue(); | |
| 527 | * // if neither ch eckbox is checked | |
| 528 | * v === undefined | |
| 529 | * // if both check boxes are checked | |
| 530 | * v == [ 'B1', 'B2' ] | |
| 531 | * | |
| 532 | * var v = $(':radi o').fieldV alue(); | |
| 533 | * // if neither ra dio is che cked | |
| 534 | * v === undefined | |
| 535 | * // if first radi o is check ed | |
| 536 | * v == [ 'C1'] | |
| 537 | * | |
| 538 | * The suc cessful ar gument con trols whet her or not the field element m ust be 'su ccessful' | |
| 539 | * (per ht tp://www.w 3.org/TR/h tml4/inter act/forms. html#succe ssful-cont rols). | |
| 540 | * The def ault value of the su ccessful a rgument is true. If this valu e is false the value (s) | |
| 541 | * for eac h element is returne d. | |
| 542 | * | |
| 543 | * Note: T his method *always* returns an array. I f no valid value can be determ ined the | |
| 544 | * array wil l be empty , otherwis e it will contain on e or more values. | |
| 545 | */ | |
| 546 | $.fn.field Value = fu nction(suc cessful) { | |
| 547 | fo r (var val =[], i=0, max=this.l ength; i < max; i++) { | |
| 548 | var el = this[ i]; | |
| 549 | var v = $.fiel dValue(el, successfu l); | |
| 550 | if ( v === null || typeof v == 'und efined' || (v.constr uctor == A rray && !v .length)) | |
| 551 | contin ue; | |
| 552 | v.co nstructor == Array ? $.merge(v al, v) : v al.push(v) ; | |
| 553 | } | |
| 554 | re turn val; | |
| 555 | }; | |
| 556 | ||
| 557 | /** | |
| 558 | * Returns the value of the fi eld elemen t. | |
| 559 | */ | |
| 560 | $.fieldVal ue = funct ion(el, su ccessful) { | |
| 561 | va r n = el.n ame, t = e l.type, ta g = el.tag Name.toLow erCase(); | |
| 562 | if (typeof s uccessful == 'undefi ned') succ essful = t rue; | |
| 563 | ||
| 564 | if (successf ul && (!n || el.disa bled || t == 'reset' || t == ' button' || | |
| 565 | (t = = 'checkbo x' || t == 'radio') && !el.che cked || | |
| 566 | (t = = 'submit' || t == ' image') && el.form & & el.form. clk != el || | |
| 567 | tag == 'select ' && el.se lectedInde x == -1)) | |
| 568 | return null; | |
| 569 | ||
| 570 | if (tag == ' select') { | |
| 571 | var index = el .selectedI ndex; | |
| 572 | if ( index < 0) return nu ll; | |
| 573 | var a = [], op s = el.opt ions; | |
| 574 | var one = (t = = 'select- one'); | |
| 575 | var max = (one ? index+1 : ops.len gth); | |
| 576 | for( var i=(one ? index : 0); i < m ax; i++) { | |
| 577 | var op = ops[i]; | |
| 578 | if (op .selected) { | |
| 579 | var v = op.value; | |
| 580 | if (!v) // extra p ain for IE ... | |
| 581 | v = (op.at tributes & & op.attri butes['val ue'] && !( op.attribu tes['value '].specifi ed)) ? op. text : op. value; | |
| 582 | if (one) return v; | |
| 583 | a.push(v ); | |
| 584 | } | |
| 585 | } | |
| 586 | retu rn a; | |
| 587 | } | |
| 588 | re turn el.va lue; | |
| 589 | }; | |
| 590 | ||
| 591 | /** | |
| 592 | * Clears the form d ata. Take s the foll owing acti ons on the form's in put fields : | |
| 593 | * - inpu t text fie lds will h ave their 'value' pr operty set to the em pty string | |
| 594 | * - sele ct element s will hav e their 's electedInd ex' proper ty set to -1 | |
| 595 | * - chec kbox and r adio input s will hav e their 'c hecked' pr operty set to false | |
| 596 | * - inpu ts of type submit, b utton, res et, and hi dden will *not* be e ffected | |
| 597 | * - butt on element s will *no t* be effe cted | |
| 598 | */ | |
| 599 | $.fn.clear Form = fun ction() { | |
| 600 | re turn this. each(funct ion() { | |
| 601 | $('i nput,selec t,textarea ', this).c learFields (); | |
| 602 | }) ; | |
| 603 | }; | |
| 604 | ||
| 605 | /** | |
| 606 | * Clears the select ed form el ements. | |
| 607 | */ | |
| 608 | $.fn.clear Fields = $ .fn.clearI nputs = fu nction() { | |
| 609 | re turn this. each(funct ion() { | |
| 610 | var t = this.t ype, tag = this.tagN ame.toLowe rCase(); | |
| 611 | if ( t == 'text ' || t == 'password' || tag == 'textarea ') | |
| 612 | this.v alue = ''; | |
| 613 | else if (t == 'checkbox' || t == ' radio') | |
| 614 | this.c hecked = f alse; | |
| 615 | else if (tag = = 'select' ) | |
| 616 | this.s electedInd ex = -1; | |
| 617 | }) ; | |
| 618 | }; | |
| 619 | ||
| 620 | /** | |
| 621 | * Resets the form d ata. Caus es all for m elements to be res et to thei r original value. | |
| 622 | */ | |
| 623 | $.fn.reset Form = fun ction() { | |
| 624 | re turn this. each(funct ion() { | |
| 625 | // g uard again st an inpu t with the name of ' reset' | |
| 626 | // n ote that I E reports the reset function a s an 'obje ct' | |
| 627 | if ( typeof thi s.reset == 'function ' || (type of this.re set == 'ob ject' && ! this.reset .nodeType) ) | |
| 628 | this.r eset(); | |
| 629 | }) ; | |
| 630 | }; | |
| 631 | ||
| 632 | /** | |
| 633 | * Enables or disabl es any mat ching elem ents. | |
| 634 | */ | |
| 635 | $.fn.enabl e = functi on(b) { | |
| 636 | if (b == und efined) b = true; | |
| 637 | re turn this. each(funct ion() { | |
| 638 | this .disabled = !b; | |
| 639 | }) ; | |
| 640 | }; | |
| 641 | ||
| 642 | /** | |
| 643 | * Checks/ unchecks a ny matchin g checkbox es or radi o buttons and | |
| 644 | * selects /deselects and match ing option elements. | |
| 645 | */ | |
| 646 | $.fn.selec ted = func tion(selec t) { | |
| 647 | if (select = = undefine d) select = true; | |
| 648 | re turn this. each(funct ion() { | |
| 649 | var t = this.t ype; | |
| 650 | if ( t == 'chec kbox' || t == 'radio ') | |
| 651 | this.c hecked = s elect; | |
| 652 | else if (this. tagName.to LowerCase( ) == 'opti on') { | |
| 653 | var $s el = $(thi s).parent( 'select'); | |
| 654 | if (se lect && $s el[0] && $ sel[0].typ e == 'sele ct-one') { | |
| 655 | // desel ect all ot her option s | |
| 656 | $sel.fin d('option' ).selected (false); | |
| 657 | } | |
| 658 | this.s elected = select; | |
| 659 | } | |
| 660 | }) ; | |
| 661 | }; | |
| 662 | ||
| 663 | // helper fn for con sole loggi ng | |
| 664 | // set $.f n.ajaxSubm it.debug t o true to enable deb ug logging | |
| 665 | function l og() { | |
| 666 | if ($.fn.aja xSubmit.de bug) { | |
| 667 | var msg = '[jq uery.form] ' + Array .prototype .join.call (arguments ,''); | |
| 668 | if ( window.con sole && wi ndow.conso le.log) | |
| 669 | window .console.l og(msg); | |
| 670 | else if (windo w.opera && window.op era.postEr ror) | |
| 671 | window .opera.pos tError(msg ); | |
| 672 | } | |
| 673 | }; | |
| 674 | ||
| 675 | })(jQuery) ; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.