[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/rsc/js/ -> admin.js (source)

   1  /**


   2   * General functions for the backoffice.


   3   *


   4   * b2evolution - {@link http://b2evolution.net/}


   5   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}


   6   * @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}


   7   */

   8  

   9  

  10  /**


  11   * Set the action attribute on a form, including a Safari fix.


  12   *


  13   * This is so complicated, because the form also can have a (hidden) action value.


  14   *


  15   * @return boolean


  16   */

  17  function set_new_form_action( form, newaction )

  18  {

  19      // Stupid thing: having a field called action !


  20      var saved_action = form.attributes.getNamedItem('action').value;

  21      form.attributes.getNamedItem('action').value = newaction;

  22  

  23      // FIX for Safari (2.0.2, OS X 10.4.3) - (Konqueror does not fail here)


  24      if( form.attributes.getNamedItem('action').value != newaction )

  25      { // Setting form.action failed! (This is the case for Safari)

  26          // NOTE: checking "form.action == saved_action" (or through document.getElementById()) does not work - Safari uses the input element then


  27          { // _Setting_ form.action however sets the form's action attribute (not the input element) on Safari

  28              form.action = newaction;

  29          }

  30  

  31          if( form.attributes.getNamedItem('action').value != newaction )

  32          { // Still old value, did not work.

  33              alert('Cannot set new form action.');

  34              return false;

  35          }

  36      }

  37      // END FIX for Safari


  38  

  39      return true;

  40  }

  41  

  42  

  43  /**


  44   * Open the item in a preview window (a new window with target 'b2evo_preview'), by changing


  45   * the form's action attribute and target temporarily.


  46   *


  47   * fp> This is gonna die...


  48   */

  49  function b2edit_open_preview( form, newaction )

  50  {

  51      if( form.target == 'b2evo_preview' )

  52      { // A double-click on the Preview button

  53          return false;

  54      }

  55  

  56      var saved_action = form.attributes.getNamedItem('action').value;

  57      if( ! set_new_form_action(form, newaction) )

  58      {

  59          alert( "Preview not supported. Sorry. (Could not set form.action for preview)" );

  60          return false;

  61      }

  62  

  63      form.target = 'b2evo_preview';

  64      preview_window = window.open( '', 'b2evo_preview' );

  65      preview_window.focus();

  66      // submit after target window is created.


  67      form.submit();

  68      form.attributes.getNamedItem('action').value = saved_action;

  69      form.target = '_self';

  70      return false;

  71  }

  72  

  73  

  74  /**


  75   * Submits the form after setting its action attribute to "newaction" and the blog value to "blog" (if given).


  76   *


  77   * This is used to switch to another blog or tab, but "keep" the input in the form.


  78   */

  79  function b2edit_reload( form, newaction, blog )

  80  {

  81      // Set the new form action URL:


  82      if( ! set_new_form_action(form, newaction) )

  83      {

  84          return false;

  85      }

  86  

  87      // Set the new form "action" HIDDEN value:


  88      if( form.elements.action.value == "update" )

  89      {

  90          form.elements.action.value = "edit_switchtab";

  91      }

  92      else if( form.elements.action.value == "create" )

  93      {

  94          form.elements.action.value = "new_switchtab";

  95      }

  96  

  97      // Set the blog we are switching to:


  98      if( typeof blog != 'undefined' )

  99      {

 100          form.elements.blog.value = blog;

 101      }

 102      

 103      // form.action.value = 'reload';


 104      // form.post_title.value = 'demo';


 105      // alert( form.action.value + ' ' + form.post_title.value );


 106  

 107      // disable bozo validator if active:


 108      // TODO: dh> this seems to actually delete any events attached to beforeunload, which can cause problems if e.g. a plugin hooks this event


 109      window.onbeforeunload = null;

 110      

 111      // Submit the form:


 112      form.submit();

 113  

 114      return false;

 115  }



Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics