web/data/cubicweb.edition.js
changeset 10434 8e04ab5582d9
parent 10394 f9fc7b2a192e
child 10456 e7ee508a8b2f
equal deleted inserted replaced
10433:523a7f098066 10434:8e04ab5582d9
   535         jQuery(child).remove();
   535         jQuery(child).remove();
   536     }
   536     }
   537 }
   537 }
   538 
   538 
   539 /**
   539 /**
   540  * .. function:: setFormsTarget(node)
       
   541  *
       
   542  * called on load to set target and iframeso object.
       
   543  *
       
   544  * .. note::
       
   545  *
       
   546  *    This was a hack to make form loop handling XHTML compliant.
       
   547  *    Since we do not care about xhtml any longer, this may go away.
       
   548  *
       
   549  * .. note::
       
   550  *
       
   551  *   `object` nodes might be a potential replacement for iframes
       
   552  *
       
   553  * .. note::
       
   554  *
       
   555  *    The form's `target` attribute should probably become a simple data-target
       
   556  *    immediately generated server-side.
       
   557  *    Since we don't do xhtml any longer, the iframe should probably be either
       
   558  *    reconsidered or at least emitted server-side.
       
   559  */
       
   560 function setFormsTarget(node) {
       
   561     var $node = jQuery(node || document.body);
       
   562     $node.find('form').each(function() {
       
   563         var form = jQuery(this);
       
   564         var target = form.attr('cubicweb:target');
       
   565         if (target) {
       
   566             form.attr('target', target);
       
   567             /* do not use display: none because some browsers ignore iframe
       
   568              * with no display */
       
   569             form.append(IFRAME({
       
   570                 name: target,
       
   571                 id: target,
       
   572                 src: 'javascript: void(0)',
       
   573                 width: '0px',
       
   574                 height: '0px'
       
   575             }));
       
   576             form.removeAttr('cubicweb:target'); // useles from now on, pop it
       
   577                                                 // to make IE9 happy
       
   578         }
       
   579     });
       
   580 }
       
   581 
       
   582 jQuery(document).ready(function() {
       
   583     setFormsTarget();
       
   584 });
       
   585 
       
   586 /**
       
   587  * .. function:: validateForm(formid, action, onsuccess, onfailure)
   540  * .. function:: validateForm(formid, action, onsuccess, onfailure)
   588  *
   541  *
   589  * called on traditionnal form submission : the idea is to try
   542  * called on traditionnal form submission : the idea is to try
   590  * to post the form. If the post is successful, `validateForm` redirects
   543  * to post the form. If the post is successful, `validateForm` redirects
   591  * to the appropriate URL. Otherwise, the validation errors are displayed
   544  * to the appropriate URL. Otherwise, the validation errors are displayed