[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/js/ui/ -> plogui.js (source)

   1  /**

   2   * when adding a new form, checks that there is at least one category selected

   3   */
   4  function submitNewPost(form)
   5  {
   6      if( form.postCategories.selectedIndex == -1 ) {
   7          // we have no category selected!

   8          window.alert(msgErrorNoCategorySelected);
   9          return false;
  10      }  
  11      
  12      return true;
  13  }
  14  
  15  /**

  16   * The following functions are called when clicking the "save draft and continue" button

  17   */
  18  function saveDraftArticleAjax()
  19  {
  20      // if there is no category selected, then we won't save a draft!

  21      form = document.getElementById( "newPost" );
  22      
  23      if( form.postTopic.value == '' ) {
  24          window.alert( msgErrorPostTopic );
  25          return false;
  26      }
  27      
  28      // Can't use form.postText.value, becasue the form.postText.value still "null"

  29      if( htmlAreaEnabled ) {
  30          postText = tinyMCE.getContent('postText');
  31      } else {
  32          postText = form.postText.value;
  33      }
  34      
  35      if (postText == '') {
  36          window.alert( msgErrorPostText );
  37          return false;
  38      }
  39      
  40      if( !submitNewPost( form ))
  41          return false;    
  42  
  43      var formData = getPostEditFormElements( "newPost" );
  44      var url = plogAdminBaseUrl;
  45      var params = 'op=saveDraftArticleAjax&'+formData;
  46      var myAjax = new Ajax.Request(
  47                      url,
  48                      {method: 'post', parameters: params, onComplete: saveDraftArticleResponse}
  49                      );    
  50  }
  51  
  52  function saveDraftArticleResponse(originalRequest)
  53  {
  54      //put returned XML in the textarea

  55      var xmldoc = originalRequest.responseXML;
  56      var id = xmldoc.getElementsByTagName('id')[0].firstChild.nodeValue;
  57      var message = xmldoc.getElementsByTagName('message')[0].firstChild.nodeValue;
  58      $( 'postId' ).value = id;
  59      window.alert(message);
  60  }
  61  
  62  /**

  63   * The following functions are called when clicking the "add category" button

  64   */
  65  function addArticleCategoryAjax()
  66  {
  67      var categoryName = $F('newArticleCategory');
  68      if (categoryName != '')
  69      {
  70          var url = plogAdminBaseUrl;
  71          var params = 'op=addArticleCategoryAjax' + '&categoryName=' + encodeURIComponent(categoryName);
  72          var myAjax = new Ajax.Request(
  73                          url,
  74                          {method: 'get', parameters: params, onComplete: addArticleCategoryOption, onLoading: showArticleCategorySavingStatus }
  75                          );
  76      }
  77  }
  78  
  79  function addArticleCategoryOption(originalRequest)
  80  {
  81      //put returned XML in the textarea

  82      var xmldoc = originalRequest.responseXML;
  83      var success = xmldoc.getElementsByTagName('success')[0].firstChild.nodeValue;
  84      var message = xmldoc.getElementsByTagName('message')[0].firstChild.nodeValue;
  85      if (success=='0') {
  86          window.alert(message);
  87          $( 'newArticleCategory' ).value = '';
  88          $( 'addArticleCategory' ).disabled = 0;
  89      }
  90      else
  91      {
  92          var catId = xmldoc.getElementsByTagName('id')[0].firstChild.nodeValue;
  93          var catName = xmldoc.getElementsByTagName('name')[0].firstChild.nodeValue;
  94          for(i=$( 'postCategories' ).length; i>0; i--)
  95          {
  96              tmpText = $( 'postCategories' ).options[i-1].text;
  97              tmpValue = $( 'postCategories' ).options[i-1].value;
  98              tmpSelected = $( 'postCategories' ).options[i-1].selected;
  99              $( 'postCategories' ).options[i] = new Option( tmpText, tmpValue );
 100              $( 'postCategories' ).options[i].selected = tmpSelected;
 101          }
 102          $( 'postCategories' ).options[0] = new Option( catName, catId );
 103          $( 'postCategories' ).options[0].selected = true;
 104          $( 'newArticleCategory' ).value = '';
 105          $( 'addArticleCategory' ).disabled = 0;
 106      }
 107  }
 108  
 109  function showArticleCategorySavingStatus(originalRequest) {
 110      $( 'newArticleCategory' ).value = msgSaving;
 111      $( 'addArticleCategory' ).disabled = 1;
 112  }
 113  
 114  /**

 115   * this function is the one called when clicking the "add category" button

 116   */
 117  function submitPostsList(op)
 118  {
 119      if ( op == 'changePostsStatus' )
 120      {
 121          if ( document.getElementById("postsList").postStatus.value == -1 )
 122              window.alert(errorPostStatusMsg);
 123          else
 124          {
 125              document.getElementById("postsList").op.value = op;
 126              document.getElementById("postsList").submit();
 127          }
 128      }
 129      else
 130      {
 131          document.getElementById("postsList").op.value = op;
 132          document.getElementById("postsList").submit();
 133      }
 134  }
 135  
 136  function submitCommentsList(op)
 137  {
 138      if ( op == 'changeCommentsStatus' )
 139      {
 140          if ( document.getElementById("postCommentsList").commentStatus.value == -1 )
 141              window.alert(errorCommentStatusMsg);
 142          else
 143          {
 144              document.getElementById("postCommentsList").op.value = op;
 145              document.getElementById("postCommentsList").submit();
 146          }
 147      }
 148      else
 149      {
 150          document.getElementById("postCommentsList").op.value = op;
 151          document.getElementById("postCommentsList").submit();
 152      }
 153  }
 154  
 155  function submitTrackbacksList(op)
 156  {
 157      if ( op == 'changeTrackbacksStatus' )
 158      {
 159          if ( document.getElementById("postTrackbacksList").trackbackStatus.value == -1 )
 160              window.alert(errorTrackbackStatusMsg);
 161          else
 162          {
 163              document.getElementById("postTrackbacksList").op.value = op;
 164              document.getElementById("postTrackbacksList").submit();
 165          }
 166      }
 167      else
 168      {
 169          document.getElementById("postTrackbacksList").op.value = op;
 170          document.getElementById("postTrackbacksList").submit();
 171      }
 172  }
 173  
 174  function submitGalleryItemsList(op)
 175  {
 176      document.getElementById("Resources").op.value = op;
 177      document.getElementById("Resources").submit();
 178  }
 179  
 180  function submitLinksList(op)
 181  {
 182      document.getElementById("links").op.value = op;
 183      document.getElementById("links").submit();
 184  }
 185  
 186  function submitBlogsList(op)
 187  {
 188      if ( document.getElementById("blogStatus").value == -1 )
 189          window.alert(errorStatusMsg);
 190      else {
 191          document.getElementById("editBlogs").op.value = op;
 192          document.getElementById("editBlogs").submit();
 193      }
 194  }
 195  
 196  function submitUsersList(op)
 197  {
 198      if ( document.getElementById("userStatus").value == -1 )
 199          window.alert(errorStatusMsg);
 200      else {
 201          document.getElementById("siteUsers").op.value = op;
 202          document.getElementById("siteUsers").submit();
 203      }
 204  }
 205  
 206  function switchMassiveOption()
 207  {
 208      if ( $('massiveChangeOption').style.display == 'none' )
 209      {
 210          Element.show($('massiveChangeOption'));
 211          $('optionIconLink').innerHTML = hideMassiveChangeOption;
 212          $('optionIconLink').title = hideMassiveChangeOption;
 213      }
 214      else
 215      {
 216          Element.hide($('massiveChangeOption'));
 217          $('optionIconLink').innerHTML = showMassiveChangeOption;
 218          $('optionIconLink').title = showMassiveChangeOption;
 219      }
 220  }
 221  
 222  function showProgressBar( elementToHide )
 223  {
 224     button = document.getElementById( elementToHide );
 225     button.style.display = "none";     
 226     bar = document.getElementById("status_bar");
 227     bar.style.display = "block";
 228  }


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics