|
@@ -35,7 +35,7 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
|
35
|
35
|
{
|
36
|
36
|
if (!tag_id)
|
37
|
37
|
{
|
38
|
|
- this.openTagSubmission(tag_name);
|
|
38
|
+ openTagSubmission(tag_name);
|
39
|
39
|
}
|
40
|
40
|
else
|
41
|
41
|
{
|
|
@@ -44,6 +44,112 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
|
44
|
44
|
}
|
45
|
45
|
}
|
46
|
46
|
|
|
47
|
+ var openTagSubmission = function (tag_name)
|
|
48
|
+ {
|
|
49
|
+ // TODO : Cette partie du code n'est pas encore refactorisé
|
|
50
|
+
|
|
51
|
+ // Effet fade-in du fond opaque
|
|
52
|
+ $('body').append($('<div>').attr('id', 'fade'));
|
|
53
|
+ //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
|
|
54
|
+ $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
|
|
55
|
+
|
|
56
|
+ // En premier lieux on fait apparaître la fenêtre de confirmation
|
|
57
|
+ var popup = $('<div>')
|
|
58
|
+ .attr('id', 'add_tag')
|
|
59
|
+ .addClass('popin_block')
|
|
60
|
+ .css('width', '400px')
|
|
61
|
+ //.append($('<h2>').append(string_tag_add_title))
|
|
62
|
+ .append($('<form>')
|
|
63
|
+ .attr('action', url_add_tag)
|
|
64
|
+ .attr('method', 'post')
|
|
65
|
+ .attr('name', 'add_tag')
|
|
66
|
+ .ajaxForm(function(response) {
|
|
67
|
+ /*
|
|
68
|
+ *
|
|
69
|
+ */
|
|
70
|
+
|
|
71
|
+ if (response.status == 'mustbeconnected')
|
|
72
|
+ {
|
|
73
|
+ $(location).attr('href', url_index);
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ if (response.status == 'success')
|
|
77
|
+ {
|
|
78
|
+ var tag = new Tag(response.tag_id, response.tag_name);
|
|
79
|
+ addTagToProposedTags(tag);
|
|
80
|
+ addTagToSelectedTags(tag);
|
|
81
|
+ _tag_prompt_connector.updateOutput(tags_selected);
|
|
82
|
+
|
|
83
|
+ $('#fade').fadeOut(400, function(){$('#fade').remove();});
|
|
84
|
+ $('#add_tag').remove();
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ if (response.status == 'error')
|
|
88
|
+ {
|
|
89
|
+ $('form[name="add_tag"]').find('ul.error_list').remove();
|
|
90
|
+ var ul_errors = $('<ul>').addClass('error_list');
|
|
91
|
+
|
|
92
|
+ for (i in response.errors)
|
|
93
|
+ {
|
|
94
|
+ ul_errors.append($('<li>').append(response.errors[i]));
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ $('form[name="add_tag"]').prepend(ul_errors);
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ return false;
|
|
101
|
+ })
|
|
102
|
+
|
|
103
|
+ .append($('<div>').addClass('tag')
|
|
104
|
+ .append($('<ul>')
|
|
105
|
+ .append($('<li>').addClass('button')
|
|
106
|
+ .append(tag_name))))
|
|
107
|
+ .append($('<p>').append(string_tag_add_text))
|
|
108
|
+ .append($('<p>').append(string_tag_add_argument))
|
|
109
|
+ .append($('<textarea>').attr('name', 'argument'))
|
|
110
|
+ .append($('<div>').addClass('inputs')
|
|
111
|
+ .append($('<input>')
|
|
112
|
+ .attr('type', 'button')
|
|
113
|
+ .attr('value', string_tag_add_inputs_cancel)
|
|
114
|
+ .addClass('button')
|
|
115
|
+ .click(function(){
|
|
116
|
+ $('#fade').fadeOut(1000, function(){$('#fade').remove();});
|
|
117
|
+ $('#add_tag').remove();
|
|
118
|
+
|
|
119
|
+ return false;
|
|
120
|
+ })
|
|
121
|
+ )
|
|
122
|
+ .append($('<input>')
|
|
123
|
+ .attr('type', 'submit')
|
|
124
|
+ .attr('value', string_tag_add_inputs_submit)
|
|
125
|
+ .addClass('button')
|
|
126
|
+ .click(function(){
|
|
127
|
+
|
|
128
|
+ // TODO: loader gif
|
|
129
|
+
|
|
130
|
+ })
|
|
131
|
+ )
|
|
132
|
+ .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val(tag_name))
|
|
133
|
+ ))
|
|
134
|
+ ;
|
|
135
|
+
|
|
136
|
+ // Il faut ajouter le popup au dom avant de le positionner en css
|
|
137
|
+ // Sinon la valeur height n'est pas encore calculable
|
|
138
|
+ $('body').prepend(popup);
|
|
139
|
+
|
|
140
|
+ //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
|
|
141
|
+ var popMargTop = (popup.height() + 50) / 2;
|
|
142
|
+ var popMargLeft = (popup.width() + 50) / 2;
|
|
143
|
+
|
|
144
|
+ //On affecte le margin
|
|
145
|
+ $(popup).css({
|
|
146
|
+ 'margin-top' : -popMargTop,
|
|
147
|
+ 'margin-left' : -popMargLeft
|
|
148
|
+ });
|
|
149
|
+
|
|
150
|
+ return false;
|
|
151
|
+ }
|
|
152
|
+
|
47
|
153
|
this.openTagSubmission = function (tag_name)
|
48
|
154
|
{
|
49
|
155
|
// TODO : Cette partie du code n'est pas encore refactorisé
|
|
@@ -245,7 +351,16 @@ function TagPromptConnector(input, output, proposition_list, tag_box, prompt_loa
|
245
|
351
|
|
246
|
352
|
var cleanInput = function()
|
247
|
353
|
{
|
248
|
|
- _input.val('');
|
|
354
|
+ // hack pour ie < 10 ne supportant pas le placeholder
|
|
355
|
+ if ($.browser.version < 10 && $.browser.msie)
|
|
356
|
+ {
|
|
357
|
+ _input.addClass('placeholder');
|
|
358
|
+ _input.val(_input.attr('placeholder'));
|
|
359
|
+ }
|
|
360
|
+ else
|
|
361
|
+ {
|
|
362
|
+ _input.val('');
|
|
363
|
+ }
|
249
|
364
|
}
|
250
|
365
|
|
251
|
366
|
var showPromptLoader = function()
|