/[drupal]/contributions/modules/taxonomy_manager/js/termData.js
ViewVC logotype

Diff of /contributions/modules/taxonomy_manager/js/termData.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3.2.8.2.10, Fri Aug 7 08:20:22 2009 UTC revision 1.1.2.3.2.8.2.11, Mon Aug 10 13:47:45 2009 UTC
# Line 1  Line 1 
1  // $Id: termData.js,v 1.1.2.3.2.8.2.9 2009/08/04 13:46:28 mh86 Exp $  // $Id: termData.js,v 1.1.2.3.2.8.2.10 2009/08/07 08:20:22 mh86 Exp $
2    
3  /**  /**
4   * @file js support for term editing form for ajax saving and tree updating   * @file js support for term editing form for ajax saving and tree updating
# Line 7  Line 7 
7  //global var that holds the current term link object  //global var that holds the current term link object
8  var active_term = new Object();  var active_term = new Object();
9    
10    //holds tree objects, useful in double tree interface, when both trees needs to be updated
11    var trees = new Object();
12    
13    /**
14     * attaches term data form, used after 'Saves changes' ahah submit
15     */
16    Drupal.behaviors.TaxonomyManagerTermData = function(context) {
17      if (!$('#taxonomy-manager-toolbar' + '.tm-termData-processed').size()) {
18        var vid = $('#edit-term-data-vid').val();
19        for (var id in trees) {
20          var tree = trees[id];
21          if (tree.vocId == vid) {
22            Drupal.attachTermDataForm(tree);
23            break;
24          }
25        }
26      }
27    }
28    
29    /**
30     * attaches Term Data functionality, called by tree.js
31     */
32  Drupal.attachTermData = function(ul, tree) {  Drupal.attachTermData = function(ul, tree) {
33      trees[tree.treeId] = tree;
34    Drupal.attachTermDataLinks(ul, tree);    Drupal.attachTermDataLinks(ul, tree);
35    
36    var tid = $('#edit-term-data-tid').val();    if (!$('#taxonomy-manager-toolbar' + '.tm-termData-processed').size()) {
37    if (tid) {            Drupal.attachTermDataForm(tree);
     var termLink = $('#taxonomy-manager-tree').find(":input[value="+ tid +"]").parent().find("a.term-data-link");  
     Drupal.activeTermSwapHighlight(termLink);  
     var url = Drupal.settings.termData['term_url'] +'/'+ tid +'/true';  
     var termdata = new Drupal.TermData(tid, url, tree.getLi(tid), tree);  
     termdata.form();  
38    }    }
39  }  }
40    
# Line 59  Drupal.attachTermDataToSiblings = functi Line 76  Drupal.attachTermDataToSiblings = functi
76  }  }
77    
78  /**  /**
79     * adds click events to term data form, which is already open, when page gets loaded
80     */
81    Drupal.attachTermDataForm = function(tree) {
82      $('#taxonomy-manager-toolbar').addClass('tm-termData-processed');
83      var tid = $('#edit-term-data-tid').val();
84      if (tid) {
85        var li = tree.getLi(tid);
86        var termLink = $(li).children("div.term-line").find("a.term-data-link");
87        Drupal.activeTermSwapHighlight(termLink);
88        var url = Drupal.settings.termData['term_url'] +'/'+ tid +'/true';
89        var termdata = new Drupal.TermData(tid, url, li, tree);
90        termdata.form();
91      }
92    }
93    
94    /**
95   * TermData Object   * TermData Object
96   */   */
97  Drupal.TermData = function(tid, href, li, tree) {  Drupal.TermData = function(tid, href, li, tree) {
# Line 66  Drupal.TermData = function(tid, href, li Line 99  Drupal.TermData = function(tid, href, li
99    this.tid = tid;    this.tid = tid;
100    this.li = li;    this.li = li;
101    this.tree = tree    this.tree = tree
102    this.form_build_id = this.tree.form_build_id;    this.form_build_id = tree.form_build_id;
103    this.form_id = this.tree.form_id;    this.form_id = tree.form_id;
104      this.vid = tree.vocId;
105    this.div = $('#taxonomy-term-data');    this.div = $('#taxonomy-term-data');
106  }  }
107    
# Line 92  Drupal.TermData.prototype.load = functio Line 126  Drupal.TermData.prototype.load = functio
126   */   */
127  Drupal.TermData.prototype.insertForm = function(data) {  Drupal.TermData.prototype.insertForm = function(data) {
128    $(this.div).html(data);    $(this.div).html(data);
   this.vid = this.tree.vocId;  
129    this.form();    this.form();
130  }  }
131    
# Line 149  Drupal.TermData.prototype.form = functio Line 182  Drupal.TermData.prototype.form = functio
182    });    });
183    
184    $(this.div).find('#edit-term-data-save').click(function() {    $(this.div).find('#edit-term-data-save').click(function() {
185        $('#taxonomy-manager-toolbar').removeClass("tm-termData-processed");
186      termdata.param['value'] = $('#edit-term-data-name').attr('value');      termdata.param['value'] = $('#edit-term-data-name').attr('value');
187      termdata.updateTermName();      termdata.updateTermName();
188    });    });
# Line 220  Drupal.TermData.prototype.send = functio Line 254  Drupal.TermData.prototype.send = functio
254   * updates term data form and if necessary tree structure   * updates term data form and if necessary tree structure
255   */   */
256  Drupal.TermData.prototype.update = function() {  Drupal.TermData.prototype.update = function() {
257    var settings = Drupal.settings.taxonomytree || [];    for (var id in trees) {
258    if (settings['id']) {      var tree = trees[id];
259      if (!(settings['id'] instanceof Array)) {      if (tree.vocId == this.vid) {
260        this.updateTree(this.tree);         this.updateTree(tree);
     }  
     else {  
       for (var i = 0; i < settings['id'].length; i++) {  
         if (this.vid == settings['vid'][i]) {  
           this.updateTree(new Drupal.TaxonomyManagerTree(id, this.vid));  
         }  
       }  
261      }      }
262    }    }
263  }  }

Legend:
Removed from v.1.1.2.3.2.8.2.10  
changed lines
  Added in v.1.1.2.3.2.8.2.11

  ViewVC Help
Powered by ViewVC 1.1.2