Streber PM PHP Cross Reference Groupware Applications

Source: /js/misc.js - 306 lines - 8403 bytes - Summary - Text - Print

Description: all jquery-functions, no special relation is been called on load

   1  /**
   2   * all jquery-functions, no special relation
   3   *
   4   * is been called on load
   5   *
   6   * included by:
   7   *
   8   * @author     Tino Beirau
   9   * @uses:
  10   * @usedby:
  11   */
  12  
  13  /**
  14  * global variables
  15  */
  16  var onLoadFunctions= new Array();
  17  var ajax_edits= new Array();
  18  
  19  /**
  20  * called after loading
  21  */
  22  function misc()
  23  {
  24  
  25  
  26  
  27      /*******************************************************
  28      * Form - visual effects
  29      *
  30      */
  31  
  32      /**
  33      * chose between current or next project in notes on person dialog
  34      * show and hide project list / project input field
  35      */
  36      $('body.taskNoteOnPersonEdit #new_project').click
  37      (
  38          function(e)
  39          {
  40              if(this.checked)
  41              {
  42                  $('div.form #proj_list').slideUp('300');
  43                  $('div.form #proj_new_input').slideDown('300');
  44              }
  45              else
  46              {
  47                     $('div.form #proj_new_input').slideUp('300');
  48                  $('div.form #proj_list').slideDown('300');
  49              }
  50          }
  51      );
  52  
  53  
  54      /**
  55      * toggle between different tabgroups
  56      */
  57      TabGroup = {
  58        init: function() {
  59          $('div.tabgroup').each(function(){
  60            var f = TabGroup.click;
  61            var group = this;
  62            $('.tab_header', group).each(function(){
  63              this.group = group;
  64              $(this).click(f);
  65              $('#'+this.id+'-body').addClass('Hidden');
  66            }).filter(':first').trigger('click');
  67          });
  68          $('.tabgroup ul li:first').addClass('Active');
  69          $('.tabgroup div:first').removeClass('Hidden');
  70        },
  71  
  72        click: function(e) {
  73          var tab = $('#'+this.id+'-body').get(0);
  74  
  75          $('.tab_header', this.group).each(function(){
  76            $(this).removeClass('Active');
  77            $('#'+this.id+'-body').addClass('Hidden');
  78          });
  79          $(this).addClass('Active');
  80  
  81          $(tab).removeClass('Hidden');
  82          e.preventDefault();
  83        }
  84      };
  85      TabGroup.init();
  86  
  87  
  88      /**
  89      * in taskEdit hide and show tabs depending on task category
  90      */
  91      TaskEditTabs = {
  92          init:function() {
  93              $('select#task_category').change(function(e) {
  94                  switch(this.value) {
  95  
  96                      //--- task ---
  97                      case '0':
  98                          $('div.tabgroup li#task').show();
  99                          $('div.tabgroup li#bug').hide();
 100                          $('div.tabgroup li#timing').show();
 101                          $('div.tabgroup li#task').trigger('click');
 102                          break;
 103  
 104                      //--- bug ---
 105                      case '1':
 106                          $('div.tabgroup li#task').show();
 107                          $('div.tabgroup li#bug').show();
 108                          $('div.tabgroup li#timing').show();
 109                          $('div.tabgroup li#task').trigger('click');
 110                          break;
 111  
 112                      //--- documentation ---
 113                      case '2':
 114                          $('div.tabgroup li#task').hide();
 115                          $('div.tabgroup li#bug').hide();
 116                          $('div.tabgroup li#timing').hide();
 117                          $('div.tabgroup li#description').trigger('click');
 118                          break;
 119  
 120                      //--- folder ---
 121                      case '3':
 122                          $('div.tabgroup li#task').show();
 123                          $('div.tabgroup li#bug').hide();
 124                          $('div.tabgroup li#timing').show();
 125                          $('div.tabgroup li#description').trigger('click');
 126                          break;
 127  
 128                     //--- event ---
 129                      case '4':
 130                          $('div.tabgroup li#task').show();
 131                          $('div.tabgroup li#bug').hide();
 132                          $('div.tabgroup li#timing').show();
 133                          $('div.tabgroup li#description').trigger('click');
 134                          break;
 135  
 136                     //--- milestone ---
 137                      case '10':
 138                          $('div.tabgroup li#task').show();
 139                          $('div.tabgroup li#bug').hide();
 140                          $('div.tabgroup li#timing').show();
 141                          $('div.tabgroup li#description').trigger('click');
 142                          break;
 143  
 144                    //--- version ---
 145                      case '11':
 146                          $('div.tabgroup li#task').show();
 147                          $('div.tabgroup li#bug').hide();
 148                          $('div.tabgroup li#timing').show();
 149                          $('div.tabgroup li#description').trigger('click');
 150                          break;
 151                  }
 152              });
 153          }
 154      }
 155      TaskEditTabs.init();
 156      $('select#task_category').trigger('change');
 157  
 158      /**
 159      * project selector
 160      */
 161      $('span#projectselector').click(function() {
 162          $('span#projectselectorlist').toggle();
 163      });
 164  
 165      /**
 166      * home selector
 167      */
 168      $('span#homeselector').click(function() {
 169          $('span#homeselectorlist').toggle();
 170      });
 171  
 172      /**
 173      * call onload functions
 174      */
 175      for(i=0; i < onLoadFunctions.length; i++) {
 176          onLoadFunctions[i]();
 177      }
 178  
 179      /**
 180      * init ajaxEdits
 181      */
 182      $('div.wiki.editable').each(function() {
 183          aj= new AjaxEdit(this);
 184          ajax_edits.push(aj);
 185          this.ajax_edit= aj;
 186      });    
 187  }
 188  
 189  /**
 190  * load additional changes for dashboard
 191  *
 192  * - called directly from home.inc.php -> home() javascript in ahref
 193  */
 194  
 195  function getMoreChanges(project, start, count)
 196  {
 197      var element= $('ul#changesOnProject_' + project);
 198  
 199      // initialize or update static variables
 200      if(!this.starts) {
 201          this.starts = Array();
 202      }       
 203          
 204      if(this.starts[project]) {
 205          start= this.starts[project] + count;
 206      }
 207      this.starts[project] = start;
 208              
 209      $.get("index.php",
 210          { go:'ajaxMoreChanges', start: start, count: count, prj:project },
 211          function(data) {
 212              $(element).append(data);
 213          }
 214      );
 215      return;
 216  }
 217  
 218  
 219  /**
 220  * add inline edit functions for wiki chapters
 221  * 
 222  * read more documentation at http://www.streber-pm.org/3695
 223  */
 224  function AjaxEdit(dom_element, item_id, field)
 225  {
 226      this.dom_element    = dom_element;
 227      this.item_id        = item_id || 0;
 228      this.field          = field || 0;
 229  
 230      if(!dom_element)
 231          return;
 232  
 233      if($(dom_element).attr('item_id')) {
 234          item_id= $(dom_element).attr('item_id');
 235      }
 236      else {
 237          alert("Warning: no item id for ajax editing!");
 238          return;
 239      }
 240  
 241      if(dom_element.attributes['field_name']) {
 242          field_name= dom_element.attributes['field_name'].value;
 243      }
 244      else {
 245          field_name= "description";
 246      }
 247  
 248      this.initEditChapters = function()
 249      {
 250          if(!dom_element) {
 251              alert("no dom element");
 252              return;
 253          }
 254  
 255          var chapter_count= 0;
 256          $(dom_element).find('div.chapter').each(function() {
 257              var chapter= this;
 258  
 259              var children= $(this).children();
 260  
 261              var chapter_name= chapter_count++;
 262  
 263  
 264              $(this).addClass('edit_chapter');
 265              $(this).attr('title', 'Doubleclick to edit chapter');
 266  
 267              $(this).editable('index.php?go=itemSaveField&item=' + item_id + '&field=' + field_name + '&chapter=' + chapter_name, {
 268                  loadurl:'index.php?go=itemLoadField&item=' + item_id + '&field=' + field_name + '&chapter=' + chapter_name,
 269                  type:'textarea',
 270                  submit:'Save',
 271                  cancel:'Cancel',
 272                  chapter:true,
 273                  obj:dom_element,
 274                  placeholder:'',
 275                  onblur:'ignore',
 276                  event:'dblclick',
 277                  callback:function(value, settings){
 278                    keepParentNode = this.parentNode
 279                    $(this.parentNode).html( value );
 280                    keepParentNode.ajax_edit.initEditChapters();
 281                  }
 282              });
 283          });
 284      }
 285      this.initEditChapters();
 286  }
 287  
 288  /**
 289  * initialize handlers for autocompletion input fields on startup
 290  * 
 291  * Calledby render_page js-code if page->use_autocomplete enabled
 292  */
 293  function initAutocompleteFields() {
 294      $("input.autocomplete").each(function() {
 295          if($(this).attr('autocomplete_list')) {
 296              var autocomplete_list= $(this).attr('autocomplete_list');
 297              $(this).autocomplete(autocomplete_list.split(','), {
 298                  delay: 150,
 299                  selectFirst: false,
 300                  multiple: true,
 301                  //mustMatch: true,
 302                  autoFill: true
 303                });
 304          }
 305      });
 306  }

title

Description

title

Description

title

Description

title

title

Body