Revision 823:73057b65abcb vendor/plugins/redmine_tags/assets/javascripts

View differences:

vendor/plugins/redmine_tags/assets/javascripts/projects_index.js
1
function toggleFieldsetWithState(this_field){
2
	id = Element.up(this_field, 'fieldset').id;	
3
	// is the fieldset collapsed?
4
	status = $(id).hasClassName("collapsed");
5
	change_session(id, status);
6
	
7
	toggleFieldset(this_field);
8

  
9
};
10

  
11
	function submitForm(){
12
		$('submitButton').click();		
13
	};
14

  
15
function change_session(id, nstatus) {
16
	var url = "projects/set_fieldset_status";
17
 	var request = new Ajax.Request(url, {
18
		method: 'post',
19
	 	parameters: {field_id: id, status: nstatus},
20
    	asynchronous: true
21
  	});
22
}
23

  
24
function keypressHandler (event){
25
  var key = event.which || event.keyCode;
26
  switch (key) {
27
      default:
28
      break;
29
      case Event.KEY_RETURN:
30
          $('submitButton').click(); return false;
31
      break;   
32
  };
33
};
34

  
35
document.observe("dom:loaded", function() {
36
	$('search-input').observe('keypress', keypressHandler);	
37
});
vendor/plugins/redmine_tags/assets/javascripts/tags_input.js
21 21
var Redmine = Redmine || {};
22 22

  
23 23
Redmine.TagsInput = Class.create({
24
  initialize: function(element) {
24
  initialize: function(element, update) {
25 25
    this.element  = $(element);
26 26
    this.input    = new Element('input', { 'type': 'text', 'autocomplete': 'off', 'size': 10 });
27 27
    this.button   = new Element('span', { 'class': 'tag-add icon icon-add' });
28 28
    this.tags     = new Hash();
29 29
    
30
		this.update = update;
31
		
32
		var uri_params = window.location.href.toQueryParams();
33
		if (uri_params["project[tag_list]"] != undefined){
34
			this.addTag(uri_params["project[tag_list]"].stripTags(), true);			
35
		};
36
		
30 37
    Event.observe(this.button, 'click', this.readTags.bind(this));
31 38
    Event.observe(this.input, 'keypress', this.onKeyPress.bindAsEventListener(this));
32 39

  
......
35 42
    this.addTagsList(this.element.value);
36 43
  },
37 44

  
38
  readTags: function() {
45
  readTags: function() {		
39 46
    this.addTagsList(this.input.value);
40 47
    this.input.value = '';
48
		if(this.update){
49
			submitForm();
50
		};
41 51
  },
42 52

  
43 53
  onKeyPress: function(event) {
44 54
    if (Event.KEY_RETURN == event.keyCode) {
45 55
      this.readTags(event);
46
      Event.stop(event);
56
      Event.stop(event);			
47 57
    }
48 58
  },
49 59

  
50
  addTag: function(tag) {
60
  addTag: function(tag, noSubmit) {
51 61
    if (tag.blank() || this.tags.get(tag)) return;
52 62

  
63
		if(noSubmit==undefined){noSubmit=false;}
64

  
53 65
    var button = new Element('span', { 'class': 'tag-delete icon icon-del' });
54 66
    var label  = new Element('span', { 'class': 'tag-label' }).insert(tag).insert(button);
55 67

  
......
57 69
    this.element.value = this.getTagsList();
58 70
    this.element.insert({ 'before': label });
59 71

  
72
		if(noSubmit==false){
73
			if(this.update){
74
				submitForm();
75
			};
76
		};
77

  
60 78
    Event.observe(button, 'click', function(){
61 79
      this.tags.unset(tag);
62 80
      this.element.value = this.getTagsList();
63 81
      label.remove();
82
		  if(this.update){submitForm();};
64 83
    }.bind(this));
65 84
  },
66 85

  
......
90 109

  
91 110

  
92 111
function observeIssueTagsField(url) {
93
  new Redmine.TagsInput('issue_tag_list').autocomplete('issue_tag_candidates', url);
112
  new Redmine.TagsInput('issue_tag_list', false).autocomplete('issue_tag_candidates', url);
94 113
}
95 114

  
96

  
97
function observeProjectTagsField(url) {
98
  new Redmine.TagsInput('project_tag_list').autocomplete('project_tag_candidates', url);
115
function observeProjectTagsField(url, update) {
116
	if(!update) { 
117
			var update = false;
118
		};
119
	
120
	new Redmine.TagsInput('project_tag_list', update).autocomplete('project_tag_candidates', url);
99 121
}

Also available in: Unified diff