1 | function colors_suggestions(){ |
---|
2 | return [ |
---|
3 | {name:'Padrão', border:'#3366cc', font:'#ffffff', background:'#3366cc'}, |
---|
4 | {name:'Coala', border:'#123456', font:'#ffffff', background:'#385c80'}, |
---|
5 | {name:'Tomate', border:'#d5130b', font:'#111111', background:'#e36d76'}, |
---|
6 | {name:'Limão', border:'#32ed21', font:'#1f3f1c', background:'#b2f1ac'}, |
---|
7 | {name:'Alto contraste', border:'#000000', font:'#ffffff', background:'#222222'} |
---|
8 | ] |
---|
9 | } |
---|
10 | function rgb2hex(rgb){ |
---|
11 | rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); |
---|
12 | return "#" + |
---|
13 | ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + |
---|
14 | ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + |
---|
15 | ("0" + parseInt(rgb[3],10).toString(16)).slice(-2); |
---|
16 | } |
---|
17 | |
---|
18 | function init_label(data){ |
---|
19 | |
---|
20 | winElement = data.window; |
---|
21 | |
---|
22 | var configureLabel = function(event, ui){ |
---|
23 | var idmarkernow = $(this).find('[name="labelItemId"]').val(); |
---|
24 | winElement.find('.edit-label').val(idmarkernow); |
---|
25 | winElement.find('.input-nome').val($(this).find("span").text()); |
---|
26 | |
---|
27 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
28 | colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor"))) |
---|
29 | .css("background-color", $(this).css("backgroundColor")).focus().end() |
---|
30 | .find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end() |
---|
31 | .find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end() |
---|
32 | .find('.preview-label-outer').css({ |
---|
33 | 'background-color':$(this).css("backgroundColor"), |
---|
34 | 'color':$(this).css("color"), |
---|
35 | 'border-color':$(this).css("border-left-color") |
---|
36 | }) |
---|
37 | winElement.find(".preview-label-inner").text($(this).text()); |
---|
38 | } |
---|
39 | //TODO Mudar quando API abstrair atualizações no cache |
---|
40 | DataLayer.remove('label',false); |
---|
41 | labels = DataLayer.get('label',{criteria:{order: 'name'}}); |
---|
42 | |
---|
43 | if(labels){ |
---|
44 | Label_List = winElement |
---|
45 | .find(".label-list-container").html(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels: labels})); |
---|
46 | |
---|
47 | }else{ |
---|
48 | /** |
---|
49 | * Quando não existir marcadores cadastrados |
---|
50 | * exibe a mensagem informando o usuário de que não há |
---|
51 | * nenhum marcador cadastrado. |
---|
52 | */ |
---|
53 | Label_List = winElement |
---|
54 | .find(".label-list-container").html('<ul class="label-list"><li class="empty-item">Nenhum Marcador Cadastrado.</li></ul>'); |
---|
55 | |
---|
56 | } |
---|
57 | Label_List.end() |
---|
58 | .find('.button').button() |
---|
59 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
60 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
61 | |
---|
62 | var editLabel = function(){ |
---|
63 | var conteudoSpan = $(this).parent().find(".text-list").text(); |
---|
64 | var span = $(this).parent().find(".text-list"); |
---|
65 | $(this).parent().trigger('click').unbind('click', configureLabel).find("span.text-list") |
---|
66 | .html('<input name="edit-value-list" class="edit-value-list" type="text" value="'+conteudoSpan+'">').find("input[name='edit-value-list']").keydown(function(event){ |
---|
67 | event.stopPropagation(); |
---|
68 | $("input.edit-value-list").keyup(function () { |
---|
69 | var value = $(this).val(); |
---|
70 | winElement.find('.input-nome').val(value); |
---|
71 | }).keyup(); |
---|
72 | if(event.keyCode == 13){ |
---|
73 | $(span).html($(".label-list").find(".edit-value-list").val()) |
---|
74 | .parent().find('.edit').removeClass("hidden").parents("li").click(configureLabel).trigger("click"); |
---|
75 | winElement.find(".buttons .save-label").trigger("click"); |
---|
76 | }else if( event.keyCode == 27){ |
---|
77 | $(this).trigger("focusout"); |
---|
78 | } |
---|
79 | }).focusout(function(){ |
---|
80 | $(span).html(conteudoSpan) |
---|
81 | .parent().find('.edit').removeClass("hidden").parents("li").click(configureLabel); |
---|
82 | }).focus(); |
---|
83 | $(this).addClass("hidden"); |
---|
84 | } |
---|
85 | |
---|
86 | winElement.find('.edit').click(editLabel); |
---|
87 | winElement.find('.close').click(function(event){ |
---|
88 | var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1]; |
---|
89 | confirmDelete(id); |
---|
90 | event.stopImmediatePropagation(); |
---|
91 | }); |
---|
92 | /** |
---|
93 | * Testa novamente se existem marcadores cadastrados, |
---|
94 | * pois nesse momento os botões Excluir, Desfazer e Salvar já existem |
---|
95 | * e os marcadores já estão listados na tela, |
---|
96 | * então é possível alterar o text do Salvar para Criar, |
---|
97 | * caso não exista nenhum marcador cadastrado e listado na tela de configuração dos marcadores, |
---|
98 | * ou "marcar" o primeiro marcador listado com o "triangulo", caracterizando que o mesmo está selecionado. |
---|
99 | */ |
---|
100 | |
---|
101 | //marca 'd agua e adicionar label na lista. |
---|
102 | winElement.find(".insert-label").Watermark(winElement.find(".insert-label").val()); |
---|
103 | |
---|
104 | $("input.insert-label").keyup(function () { |
---|
105 | $.Watermark.HideAll(); |
---|
106 | var value = $(this).val(); |
---|
107 | winElement.find('.input-nome').val(value); |
---|
108 | }).keyup(); |
---|
109 | |
---|
110 | if (!(labels)){ |
---|
111 | winElement.find(".buttons .save-label .ui-button-text").text('Criar'); |
---|
112 | $(".delete-label").button("disable"); |
---|
113 | }else{ |
---|
114 | winElement.find(".label-list li:first").addClass("selected").prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
115 | } |
---|
116 | $(".save-label").button("disable"); |
---|
117 | /** |
---|
118 | * seta a ação de click para os marcadores listados na tela |
---|
119 | */ |
---|
120 | winElement.find(".label-list li").not(".empty-item").click(configureLabel); |
---|
121 | |
---|
122 | if (data.selectedItem) |
---|
123 | winElement.find(".label-list li.label-item-"+data.selectedItem).trigger("click"); |
---|
124 | else |
---|
125 | winElement.find(".label-list li:first").trigger("click"); |
---|
126 | |
---|
127 | var dataColorPicker = { |
---|
128 | colorsSuggestions: colors_suggestions() |
---|
129 | }; |
---|
130 | |
---|
131 | winElement.find('select.color-suggestions').change(function() { |
---|
132 | $(".save-label").button("enable"); |
---|
133 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
134 | var colors; |
---|
135 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
136 | colorpicker |
---|
137 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
138 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
139 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
140 | |
---|
141 | .find('.preview-label-outer').css({ |
---|
142 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
143 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
144 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
145 | }); |
---|
146 | } |
---|
147 | }); |
---|
148 | var colorpickerPreviewChange = function(color) { |
---|
149 | |
---|
150 | var pickedup = winElement.find('.colorwell-selected').val(color).css('background-color', color); |
---|
151 | |
---|
152 | $(".save-label").button("enable"); |
---|
153 | |
---|
154 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
155 | |
---|
156 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
157 | colorpicker.find('.preview-label-outer').css('background-color',color); |
---|
158 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
159 | colorpicker.find('.preview-label-outer').css('color',color); |
---|
160 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
161 | colorpicker.find('.preview-label-outer').css('border-color',color); |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|
165 | var f = $.farbtastic(winElement.find('.colorpicker'), colorpickerPreviewChange); |
---|
166 | var selected; |
---|
167 | |
---|
168 | winElement.find('.colorwell').each(function () { |
---|
169 | f.linkTo(this); |
---|
170 | }) |
---|
171 | .focus(function() { |
---|
172 | if (selected) { |
---|
173 | $(selected).removeClass('colorwell-selected'); |
---|
174 | } |
---|
175 | $(selected = this).addClass('colorwell-selected'); |
---|
176 | f.linkTo(this, colorpickerPreviewChange); |
---|
177 | f.linkTo(colorpickerPreviewChange); |
---|
178 | }); |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | winElement.find(".add-label-button").click(function (event) { |
---|
183 | $.Watermark.HideAll(); |
---|
184 | var name = winElement.find(".insert-label").val(); |
---|
185 | if(name.length >= 2){ |
---|
186 | DataLayer.put('label', {name: name, uid: User.me.id}); |
---|
187 | |
---|
188 | $(".add-label-button").removeClass("ui-icon ui-icon-plus") |
---|
189 | .html('<img alt="Carregando" title="Carregando" style="margin-left:10px;" src="../prototype/modules/mail/img/loader.gif" />'); |
---|
190 | |
---|
191 | DataLayer.commit(false, false, function(){ |
---|
192 | |
---|
193 | labels = DataLayer.get('label',{criteria:{order: 'id'}}, true); |
---|
194 | newLabel = { |
---|
195 | id: labels[labels.length -1 ].id, |
---|
196 | name : labels[labels.length -1].name, |
---|
197 | uid: User.me.id |
---|
198 | }; |
---|
199 | |
---|
200 | $(".label-list-container ul").find(".empty-item").css("display","none"); |
---|
201 | |
---|
202 | $(".label-list-container ul, .list-label ul") |
---|
203 | .prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel)) |
---|
204 | .find("li:first") |
---|
205 | .fadeIn("slow").click(configureLabel); |
---|
206 | |
---|
207 | $(".label-list-container .label-list li").not(".empty-item").click(function(){ |
---|
208 | $(".save-label").button("disable"); |
---|
209 | $(".label-list-container .label-list li").find("img").remove(); |
---|
210 | $(".label-list-container .label-list li.label-item").removeClass("selected"); |
---|
211 | $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
212 | $(this).addClass("selected"); |
---|
213 | }); |
---|
214 | |
---|
215 | $(".label-list-container .label-list li").find('.button').button() |
---|
216 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
217 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
218 | |
---|
219 | winElement.find('.edit').unbind("click").click(editLabel); |
---|
220 | |
---|
221 | winElement.find('.close').click(function(event){ |
---|
222 | var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1]; |
---|
223 | confirmDelete(id); |
---|
224 | event.stopImmediatePropagation(); |
---|
225 | }); |
---|
226 | |
---|
227 | $.Watermark.ShowAll(); |
---|
228 | winElement.find(".insert-label").val(""); |
---|
229 | |
---|
230 | //posiciona para edição o label inserido |
---|
231 | winElement.find("ul.label-list li:first").trigger("click"); |
---|
232 | winElement.find(".buttons .save-label .ui-button-text").text('Salvar'); |
---|
233 | $(".delete-label").button("enable"); |
---|
234 | |
---|
235 | //Remove o título da lista de Marcadores da tela principal do módulo |
---|
236 | $(".my-labels").removeClass("hidden"); |
---|
237 | /** |
---|
238 | * atualiza menu |
---|
239 | * Remove o menu presente em cada mensagem listada em uma pasta |
---|
240 | * e carrega novamente para que os dados sejam atualizados |
---|
241 | */ |
---|
242 | $.contextMenu( 'destroy', ".table_box tbody tr"); |
---|
243 | loadMenu(); |
---|
244 | $(".add-label-button").empty() |
---|
245 | .addClass("ui-icon ui-icon-plus"); |
---|
246 | }); |
---|
247 | } else { |
---|
248 | alert("Mínimo 2 caracteres"); |
---|
249 | } |
---|
250 | |
---|
251 | event.stopImmediatePropagation(); |
---|
252 | }); |
---|
253 | |
---|
254 | winElement.find('.insert-label').keydown(function(event, ui) { |
---|
255 | if (event.keyCode == 13) |
---|
256 | winElement.find(".add-label-button").trigger('click'); |
---|
257 | }); |
---|
258 | |
---|
259 | function confirmDelete(id){ |
---|
260 | |
---|
261 | $.Zebra_Dialog('<strong>Deseja excluir esse marcador?</strong>', { |
---|
262 | 'type': 'question', |
---|
263 | 'title': 'Atenção', |
---|
264 | 'buttons': ['Sim','Não'], |
---|
265 | 'onClose': function(caption) { |
---|
266 | if(caption == 'Sim'){ |
---|
267 | deleteLabel(id); |
---|
268 | } |
---|
269 | } |
---|
270 | }); |
---|
271 | } |
---|
272 | |
---|
273 | function deleteLabel(id){ |
---|
274 | $(".label-list li").each(function () { |
---|
275 | var regex_match = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
276 | if (regex_match && regex_match[1] && regex_match[1] == id) { |
---|
277 | $(this).remove(); |
---|
278 | } |
---|
279 | }); |
---|
280 | DataLayer.remove('label', id); |
---|
281 | DataLayer.commit(); |
---|
282 | winElement.find(".label-list li:first").trigger("click"); |
---|
283 | |
---|
284 | if($(".label-list li").length == 0){ |
---|
285 | winElement.find(".label-list-container").html('<ul class="label-list"><li class="empty-item">Nenhum Marcador Cadastrado.</li></ul>'); |
---|
286 | } |
---|
287 | var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length; |
---|
288 | if (qtdLi == 0){ |
---|
289 | $(".my-labels").addClass("hidden"); |
---|
290 | $(".label-list-container ul").find(".empty-item").css("display",""); |
---|
291 | winElement.find(".buttons .save-label .ui-button-text").text('Criar'); |
---|
292 | $(".delete-label").button("disable"); |
---|
293 | |
---|
294 | winElement.find('.input-nome').val(""); |
---|
295 | winElement.find(".preview-label-inner").text(""); |
---|
296 | |
---|
297 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
298 | colorpicker.find('input[name="backgroundColor"]').val("#ffffff") |
---|
299 | .css("background-color", "#ffffff").focus().end() |
---|
300 | .find('input[name="fontColor"]').val("#444444").css("background-color", "#000000").focus().end() |
---|
301 | .find('input[name="borderColor"]').val("#cccccc").css("background-color", "#000000").focus().end() |
---|
302 | .find('.preview-label-outer').css({ |
---|
303 | 'background-color':"#ffffff", |
---|
304 | 'color':"#444444", |
---|
305 | 'border-color':"#cccccc" |
---|
306 | }); |
---|
307 | $(".input-nome").keyup(function () { |
---|
308 | var value = $(this).val(); |
---|
309 | winElement.find('.preview-label-inner').text(value); |
---|
310 | }).keyup(); |
---|
311 | } |
---|
312 | } |
---|
313 | //excluir marcador {deve ser para o botão grande na janela de edição e nao o pequeno da lista} |
---|
314 | winElement.find(".buttons .delete-label").click(function(event){ |
---|
315 | var id = winElement.find(".edit-label").val(); |
---|
316 | confirmDelete(id); |
---|
317 | event.stopImmediatePropagation(); |
---|
318 | }); |
---|
319 | $(".label-list-container .label-list li").not(".empty-item").click(function(){ |
---|
320 | $(".label-list-container .label-list li").find("img").remove(); |
---|
321 | $(".label-list-container .label-list li.label-item").removeClass("selected"); |
---|
322 | $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
323 | $(this).addClass("selected"); |
---|
324 | }); |
---|
325 | |
---|
326 | //salvar/criar marcador |
---|
327 | winElement.find(".buttons .save-label").click(function(){ |
---|
328 | $(".save-label").button("disable"); |
---|
329 | var labelEdited = { |
---|
330 | id : winElement.find(".edit-label").val(), |
---|
331 | uid: User.me.id, |
---|
332 | name : winElement.find('.input-nome').val(), |
---|
333 | backgroundColor : winElement.find("input[name='backgroundColor']").val(), |
---|
334 | fontColor : winElement.find("input[name='fontColor']").val(), |
---|
335 | borderColor : winElement.find("input[name='borderColor']").val() |
---|
336 | } |
---|
337 | var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length; |
---|
338 | // salvar marcador |
---|
339 | if(qtdLi > 0){ |
---|
340 | $(".label-list-container .label-list li").each(function(){ |
---|
341 | var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
342 | |
---|
343 | if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){ |
---|
344 | $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span class='text-list'>"+labelEdited.name+"</span><div class='button close tiny' style='float: right'></div><div class='button edit tiny' style='float: right'></div>").css({ |
---|
345 | "background" : labelEdited.backgroundColor, |
---|
346 | "color" : labelEdited.fontColor, |
---|
347 | "border-color" : labelEdited.borderColor |
---|
348 | }); |
---|
349 | } |
---|
350 | }); |
---|
351 | |
---|
352 | $("#MyMarckersList .label-list li").each(function(){ |
---|
353 | var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
354 | |
---|
355 | if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){ |
---|
356 | $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span>"+labelEdited.name+"</span>"); |
---|
357 | $(this).find(".square-color").css('background', labelEdited.backgroundColor); |
---|
358 | } |
---|
359 | }); |
---|
360 | DataLayer.put('label', labelEdited.id, labelEdited); |
---|
361 | DataLayer.commit(false, false, function(){ |
---|
362 | $("#MyMarckersList") |
---|
363 | .html( |
---|
364 | "<div class='my-labels'>" + |
---|
365 | "<img src='../prototype/modules/mail/img/tag.png'/>" + |
---|
366 | "<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='Meus marcadores'>Meus marcadores</a>" + |
---|
367 | |
---|
368 | "<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" + |
---|
369 | "</div>" |
---|
370 | ) |
---|
371 | .append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} )) |
---|
372 | .find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"}) |
---|
373 | .find(".square-color").css("display","").click(function(){ |
---|
374 | $(this).parent(".label-item").each(function(){ |
---|
375 | configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]}); |
---|
376 | }); |
---|
377 | }); |
---|
378 | |
---|
379 | $("#MyMarckersList a.title-my-labels").click(function() { |
---|
380 | $("#MyMarckersList ul.label-list").toggleClass("hidden") |
---|
381 | $('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s"); |
---|
382 | $('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n"); |
---|
383 | }); |
---|
384 | |
---|
385 | $.Watermark.ShowAll(); |
---|
386 | winElement.find(".insert-label").val(""); |
---|
387 | $(".label-list-container .label-list li").find('.button').button() |
---|
388 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
389 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
390 | winElement.find('.edit').unbind("click").click(editLabel); |
---|
391 | |
---|
392 | winElement.find('.close').click(function(event){ |
---|
393 | var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1]; |
---|
394 | confirmDelete(id); |
---|
395 | event.stopImmediatePropagation(); |
---|
396 | }); |
---|
397 | }); |
---|
398 | // criar marcador |
---|
399 | } else{ |
---|
400 | var nameLabel = winElement.find(".input-nome").val(); |
---|
401 | var labelCreated = { |
---|
402 | uid: User.me.id, |
---|
403 | name : nameLabel, |
---|
404 | backgroundColor : winElement.find("input[name='backgroundColor']").val(), |
---|
405 | fontColor : winElement.find("input[name='fontColor']").val(), |
---|
406 | borderColor : winElement.find("input[name='borderColor']").val() |
---|
407 | } |
---|
408 | |
---|
409 | if(nameLabel.length >= 2){ |
---|
410 | DataLayer.put('label', labelCreated); |
---|
411 | DataLayer.commit(false, false, function(){ |
---|
412 | |
---|
413 | labels = DataLayer.get('label',{criteria:{order: 'id'}}, true); |
---|
414 | newLabel = { |
---|
415 | id: labels[labels.length - 1].id, |
---|
416 | name : labels[labels.length- 1].name, |
---|
417 | uid: User.me.id, |
---|
418 | bgColor : winElement.find("input[name='backgroundColor']").val(), |
---|
419 | fontColor : winElement.find("input[name='fontColor']").val(), |
---|
420 | borderColor : winElement.find("input[name='borderColor']").val() |
---|
421 | }; |
---|
422 | |
---|
423 | $(".label-list-container ul").find(".empty-item").css("display","none"); |
---|
424 | $(".label-list-container ul") |
---|
425 | .prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel)) |
---|
426 | .find("li:first") |
---|
427 | .fadeIn("slow").click(configureLabel); |
---|
428 | |
---|
429 | $("#MyMarckersList") |
---|
430 | .html( |
---|
431 | "<div class='my-labels'>" + |
---|
432 | "<img src='../prototype/modules/mail/img/tag.png'/>" + |
---|
433 | "<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='Meus marcadores'>Meus marcadores</a>" + |
---|
434 | |
---|
435 | "<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" + |
---|
436 | "</div>" |
---|
437 | ) |
---|
438 | |
---|
439 | .append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} )) |
---|
440 | .find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"}) |
---|
441 | .find(".square-color").css("display","").click(function(){ |
---|
442 | $(this).parent(".label-item").each(function(){ |
---|
443 | configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]}); |
---|
444 | }); |
---|
445 | }); |
---|
446 | $("#MyMarckersList a.title-my-labels").click(function() { |
---|
447 | $("#MyMarckersList ul.label-list").toggleClass("hidden") |
---|
448 | $('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s"); |
---|
449 | $('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n"); |
---|
450 | }); |
---|
451 | |
---|
452 | $(".label-list-container .label-list li").not(".empty-item").click(function(){ |
---|
453 | $(".label-list-container .label-list li").find("img").remove(); |
---|
454 | $(".label-list-container .label-list li.label-item").removeClass("selected"); |
---|
455 | $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
456 | $(this).addClass("selected"); |
---|
457 | }); |
---|
458 | |
---|
459 | $(".label-list-container .label-list li").find('.button').button() |
---|
460 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
461 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
462 | $.Watermark.ShowAll(); |
---|
463 | winElement.find(".insert-label").val(""); |
---|
464 | |
---|
465 | //posiciona para edição o label inserido |
---|
466 | winElement.find("ul.label-list li:first").trigger("click"); |
---|
467 | winElement.find(".buttons .save-label .ui-button-text").text('Salvar'); |
---|
468 | $(".delete-label").button("enable"); |
---|
469 | |
---|
470 | winElement.find('.edit').unbind("click").click(editLabel); |
---|
471 | |
---|
472 | winElement.find('.close').click(function(event){ |
---|
473 | var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1]; |
---|
474 | confirmDelete(id); |
---|
475 | event.stopImmediatePropagation(); |
---|
476 | }); |
---|
477 | |
---|
478 | $(".my-labels").removeClass("hidden"); |
---|
479 | }); |
---|
480 | } else { |
---|
481 | alert("Mínimo 2 caracteres"); |
---|
482 | } |
---|
483 | } |
---|
484 | /** |
---|
485 | * atualiza menu |
---|
486 | * Remove o menu presente em cada mensagem listada em uma pasta |
---|
487 | * e carrega novamente para que os dados sejam atualizados |
---|
488 | */ |
---|
489 | $.contextMenu( 'destroy', ".table_box tbody tr"); |
---|
490 | loadMenu(); |
---|
491 | |
---|
492 | $(".label-list-container .label-list").find(".label-item-"+labelEdited.id).trigger("click"); |
---|
493 | }); |
---|
494 | //desfazer marcador |
---|
495 | winElement.find(".buttons .undo-label").click(function(event){ |
---|
496 | var edit = winElement.find(".edit-label").val(); |
---|
497 | $(".label-list-container .label-list li").each(function(){ |
---|
498 | var regex_match_3 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
499 | if(regex_match_3 && regex_match_3[1] && regex_match_3[1] == edit){ |
---|
500 | $(this).trigger("click"); |
---|
501 | } |
---|
502 | }); |
---|
503 | }); |
---|
504 | |
---|
505 | //fechar |
---|
506 | $(".button-close-window .close-window").click(function(){ |
---|
507 | $(".label-configure-win").dialog("close"); |
---|
508 | }); |
---|
509 | |
---|
510 | $(".configure-label-content").find("input[type='text']").focus(function () { |
---|
511 | $(this).keyup(function(){ |
---|
512 | var value = $(this).val(); |
---|
513 | if(value){ |
---|
514 | $(".save-label").button("enable"); |
---|
515 | }else{ |
---|
516 | $(".save-label").button("disable"); |
---|
517 | } |
---|
518 | }); |
---|
519 | |
---|
520 | }); |
---|
521 | |
---|
522 | $(".input-nome").keyup(function () { |
---|
523 | var value = $(this).val(); |
---|
524 | winElement.find('.preview-label-inner').text(value); |
---|
525 | }).keyup(); |
---|
526 | |
---|
527 | } |
---|
528 | |
---|
529 | /** |
---|
530 | * TODO: |
---|
531 | * * Qunado excluir um marcador deve ser removido das mensagens sem que seja necessario atualizar o Expresso. |
---|
532 | * * Fazer abrir a configuração do Marcador pela lista do modulo principal apenas quando criado um marcador sem clicar no botão "salvar". |
---|
533 | */ |
---|