[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/templates/javascript/ -> folders.js (source)

   1  /**
   2   * IMP Folders Javascript
   3   *
   4   * Provides the javascript to help the folders.php script.
   5   *
   6   * See the enclosed file COPYING for license information (GPL). If you did not
   7   * receive this file, see http://www.fsf.org/copyleft/gpl.html.
   8   *
   9   * $Horde: imp/templates/javascript/folders.js,v 1.1.2.2 2006/01/11 05:48:23 slusarz Exp $
  10   */
  11  
  12  var tooMany = '<?php echo addslashes(_("Please select only one folder for this operation.")) ?>';
  13  var downloadConfirm = '<?php echo addslashes(_("All messages in the following folder(s) will be downloaded into one MBOX file:")) ?>';
  14  var downloadSure = '<?php echo addslashes(_("This may take some time. Are you sure you want to continue?")) ?>';
  15  var displayNames;
  16  
  17  function buttonCount()
  18  {
  19      numSel = 0;
  20      for (var i = 0; i < document.fmanager.elements.length; i++) {
  21          if (document.fmanager.elements[i].checked) {
  22              numSel++;
  23          }
  24      }
  25      return numSel;
  26  }
  27  
  28  function getSelectedFolders()
  29  {
  30      var sel = "";
  31      var folder = 0;
  32      for (var a = 0; a < document.fmanager.elements.length; a++) {
  33          if (document.fmanager.elements[a].name == 'folder_list[]') {
  34              if (document.fmanager.elements[a].checked == 1) {
  35                  sel = sel + displayNames[folder] + "\n";
  36              }
  37              folder++;
  38          }
  39      }
  40  
  41      if (sel.charAt(sel.length - 1) == "\n") {
  42          sel = sel.substring(0, sel.length - 1);
  43      }
  44  
  45      return sel;
  46  }
  47  
  48  function chooseAction(i)
  49  {
  50      var action;
  51  
  52      if (i == 0) {
  53          action = document.fmanager.action_choose0.options[document.fmanager.action_choose0.selectedIndex].value;
  54      } else {
  55          action = document.fmanager.action_choose1.options[document.fmanager.action_choose1.selectedIndex].value;
  56      }
  57  
  58      if (action == 'create_folder') {
  59          createMailbox();
  60      } else if (action == 'rebuild_tree') {
  61          submitAction(action);
  62      } else if (buttonCount() == 0) {
  63          alert('<?php echo addslashes(_("Please select a folder before you perform this action.")) ?>');
  64      } else if (action == 'rename_folder') {
  65          renameMailbox();
  66      } else if (action == 'subscribe_folder' ||
  67                 action == 'unsubscribe_folder' ||
  68                 action == 'poll_folder' ||
  69                 action == 'expunge_folder' ||
  70                 action == 'nopoll_folder' ||
  71                 action == 'mark_folder_seen' ||
  72                 action == 'mark_folder_unseen' ||
  73                 action == 'delete_folder_confirm' ||
  74                 action == 'folders_empty_mailbox_confirm') {
  75          submitAction(action);
  76      } else if (action == 'download_folder' ||
  77                 action == 'download_folder_zip') {
  78          downloadMailbox(action);
  79      } else if (action == 'import_mbox') {
  80          if (buttonCount() > 1) {
  81              alert('<?php echo addslashes(_("Only one folder should be selected for this action.")) ?>');
  82          } else {
  83              submitAction(action);
  84          }
  85      }
  86  }
  87  
  88  function submitAction(a)
  89  {
  90      document.fmanager.actionID.value = a;
  91      document.fmanager.submit();
  92  }
  93  
  94  function createMailbox()
  95  {
  96      var count = buttonCount();
  97      if (count > 1) {
  98          window.alert(tooMany);
  99          return;
 100      }
 101  
 102      var mbox;
 103      if (count == 1) {
 104          mbox = window.prompt('<?php echo addslashes(_("You are creating a sub-folder to ")) ?>' + getSelectedFolders() + '.\n<?php echo addslashes(_("Please enter the name of the new folder:")) ?>\n', '');
 105      } else {
 106          mbox = window.prompt('<?php echo addslashes(_("You are creating a top-level folder.")) . '\n' . addslashes(_("Please enter the name of the new folder:")) ?>\n', '');
 107      }
 108  
 109      if (mbox != null && mbox != '') {
 110          document.fmanager.new_mailbox.value = mbox;
 111          document.fmanager.actionID.value = 'create_folder';
 112          document.fmanager.submit();
 113      }
 114  }
 115  
 116  function downloadMailbox(actionid)
 117  {
 118      var count = buttonCount();
 119      if (window.confirm(downloadConfirm + "\n" + getSelectedFolders() + "\n" + downloadSure)) {
 120          document.fmanager.actionID.value = actionid;
 121          document.fmanager.submit();
 122      }
 123  }
 124  
 125  function renameMailbox()
 126  {
 127      newnames = '';
 128      oldnames = '';
 129  
 130      var j = 0;
 131      while (document.fmanager.elements[j].name != "folder_list[]") {
 132          j++;
 133      }
 134  
 135      for (var i = j; i < document.fmanager.elements.length; i++) {
 136          if (document.fmanager.elements[i].type == "checkbox" && document.fmanager.elements[i].checked) {
 137              tmp = window.prompt('<?php echo addslashes(_("You are renaming the folder: ")) ?>' +
 138                                  displayNames[i - j] + "\n" +
 139                                  '<?php echo addslashes(_("Please enter the new name:")) ?>', displayNames[i - j]);
 140              if (tmp == null || tmp == '') {
 141                  return false;
 142              }
 143              newnames = newnames + tmp + "\n";
 144              oldnames = oldnames + document.fmanager.elements[i].value + "\n";
 145          }
 146      }
 147      if (newnames.charAt(newnames.length - 1) == "\n") {
 148          newnames = newnames.substring(0, newnames.length - 1);
 149      }
 150      if (oldnames.charAt(oldnames.length - 1) == "\n") {
 151          oldnames = oldnames.substring(0, oldnames.length - 1);
 152      }
 153      document.fmanager.new_names.value = newnames;
 154      document.fmanager.old_names.value = oldnames;
 155      document.fmanager.actionID.value = 'rename_folder';
 156      document.fmanager.submit();
 157      return true;
 158  }
 159  
 160  function toggleSelection()
 161  {
 162      var total = 0;
 163      var checked = 0;
 164      for (var i = 0; i < document.fmanager.elements.length; i++) {
 165          if (document.fmanager.elements[i].name == "folder_list[]") {
 166              total++;
 167              if (document.fmanager.elements[i].checked) {
 168                  checked++;
 169              }
 170          }
 171      }  
 172      
 173      var new_value = (total != checked);
 174      for (var i = 0; i < document.fmanager.elements.length; i++) {
 175          if (document.fmanager.elements[i].name == "folder_list[]") {
 176              document.fmanager.elements[i].checked = new_value;
 177          }
 178      }  
 179  }


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics