[5547] | 1 | function configureLabel(event, ui){ |
---|
| 2 | var idmarkernow = $(this).find('[name="labelItemId"]').val(); |
---|
| 3 | winElement.find('.edit-label').val(idmarkernow); |
---|
| 4 | winElement.find('.input-nome').val($(this).find("span").text()); |
---|
| 5 | |
---|
| 6 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
| 7 | colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor"))) |
---|
| 8 | .css("background-color", $(this).css("backgroundColor")).focus().end() |
---|
| 9 | .find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end() |
---|
| 10 | .find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end() |
---|
| 11 | .find('.preview-label-outer').css({ |
---|
| 12 | 'background-color':$(this).css("backgroundColor"), |
---|
| 13 | 'color':$(this).css("color"), |
---|
| 14 | 'border-color':$(this).css("border-left-color") |
---|
| 15 | }) |
---|
| 16 | winElement.find(".preview-label-inner").text($(this).text()); |
---|
| 17 | } |
---|
[5564] | 18 | |
---|
[5643] | 19 | function editLabel(data){ |
---|
[5537] | 20 | var conteudoSpan = $(this).parent().find(".text-list").text(); |
---|
| 21 | var span = $(this).parent().find(".text-list"); |
---|
| 22 | $(this).parent().trigger('click').unbind('click', configureLabel).find("span.text-list") |
---|
[5603] | 23 | .html('<input name="edit-value-list" class="edit-value-list" type="text" maxlength="18" value="'+conteudoSpan+'">').find("input[name='edit-value-list']").keydown(function(event){ |
---|
[5537] | 24 | event.stopPropagation(); |
---|
| 25 | $("input.edit-value-list").keyup(function () { |
---|
| 26 | var value = $(this).val(); |
---|
| 27 | winElement.find('.input-nome').val(value); |
---|
| 28 | }).keyup(); |
---|
| 29 | if(event.keyCode == 13){ |
---|
[5603] | 30 | event.preventDefault(); |
---|
| 31 | var nameLabel = $(".label-list").find(".edit-value-list").val(); |
---|
[5537] | 32 | $(span).html($(".label-list").find(".edit-value-list").val()) |
---|
[5713] | 33 | .parent().find('.edit').css("display","").parents("li").click(configureLabel).trigger("click"); |
---|
[5643] | 34 | save_editLabel(nameLabel, data.applyToSelectedMessages); |
---|
[5554] | 35 | |
---|
[5537] | 36 | }else if( event.keyCode == 27){ |
---|
| 37 | $(this).trigger("focusout"); |
---|
| 38 | } |
---|
| 39 | }).focusout(function(){ |
---|
| 40 | $(span).html(conteudoSpan) |
---|
[5713] | 41 | .parent().find('.edit').css("display","").parents("li").click(configureLabel); |
---|
[5537] | 42 | }).focus(); |
---|
[5713] | 43 | $(this).hide(); |
---|
[5537] | 44 | } |
---|
[5566] | 45 | |
---|
[5537] | 46 | function deleteLabel(event){ |
---|
| 47 | var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1]; |
---|
[5820] | 48 | var nameLabel = winElement.find(".input-nome").val(); |
---|
| 49 | confirmDelete(id, nameLabel); |
---|
[5537] | 50 | event.stopImmediatePropagation(); |
---|
| 51 | } |
---|
[5564] | 52 | |
---|
| 53 | function colors_suggestions(){ |
---|
| 54 | return [ |
---|
| 55 | {name:'Padrão', border:'#3366cc', font:'#ffffff', background:'#3366cc'}, |
---|
| 56 | {name:'Coala', border:'#123456', font:'#ffffff', background:'#385c80'}, |
---|
| 57 | {name:'Tomate', border:'#d5130b', font:'#111111', background:'#e36d76'}, |
---|
| 58 | {name:'Limão', border:'#32ed21', font:'#1f3f1c', background:'#b2f1ac'}, |
---|
| 59 | {name:'Alto contraste', border:'#000000', font:'#ffffff', background:'#222222'} |
---|
| 60 | ] |
---|
| 61 | } |
---|
[5566] | 62 | |
---|
[5690] | 63 | function rgb2hex(rgb){ |
---|
| 64 | if(!!(rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))){ |
---|
| 65 | return "#" + |
---|
| 66 | ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + |
---|
| 67 | ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + |
---|
| 68 | ("0" + parseInt(rgb[3],10).toString(16)).slice(-2); |
---|
| 69 | }else{ |
---|
| 70 | return rgb; |
---|
| 71 | } |
---|
[5564] | 72 | } |
---|
| 73 | |
---|
[5586] | 74 | function updateMessageLabels(idLabel){ |
---|
| 75 | var msgsReference = DataLayer.get('labeled', {filter: ['=', 'labelId', ''+idLabel]}, true); |
---|
| 76 | for(var i = 0; i < msgsReference.length; i++){ |
---|
| 77 | updateLabelsColumn({msg_number: msgsReference[i].messageNumber, boxname: msgsReference[i].folderName}); |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
[5820] | 81 | function confirmDelete(id,nameLabel){ |
---|
[5824] | 82 | $.Zebra_Dialog('Deseja excluir esse marcador <strong>'+nameLabel+'</strong> das conversas que está relacionado e excluí-lo sem remover as conversas?', { |
---|
[5564] | 83 | 'type': 'question', |
---|
[5713] | 84 | 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), |
---|
[5564] | 85 | 'title': 'Atenção', |
---|
[5713] | 86 | 'buttons': ['Sim','Não'], |
---|
[5586] | 87 | 'overlay_opacity': '0.5', |
---|
[5564] | 88 | 'onClose': function(caption) { |
---|
| 89 | if(caption == 'Sim'){ |
---|
| 90 | delete_label(id); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | }); |
---|
[5713] | 94 | if(is_ie) |
---|
| 95 | $(".ZebraDialogOverlay").css("z-index","1006"); |
---|
[5566] | 96 | } |
---|
| 97 | |
---|
[5625] | 98 | function save_editLabel(nameLabel, apply){ |
---|
[5606] | 99 | |
---|
| 100 | var lengthSpace = $.trim(nameLabel); |
---|
| 101 | |
---|
[5789] | 102 | if(lengthSpace.length >= 2){ |
---|
[5603] | 103 | var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length; |
---|
| 104 | // salvar marcador |
---|
| 105 | if(qtdLi > 0){ |
---|
| 106 | $(".save-label").button("disable"); |
---|
| 107 | var labelEdited = { |
---|
| 108 | id : winElement.find(".edit-label").val(), |
---|
| 109 | uid: User.me.id, |
---|
| 110 | name : winElement.find('.input-nome').val(), |
---|
| 111 | backgroundColor : winElement.find("input[name='backgroundColor']").val(), |
---|
| 112 | fontColor : winElement.find("input[name='fontColor']").val(), |
---|
| 113 | borderColor : winElement.find("input[name='borderColor']").val() |
---|
| 114 | } |
---|
| 115 | $(".label-list-container .label-list li").each(function(){ |
---|
| 116 | var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
| 117 | |
---|
| 118 | if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){ |
---|
| 119 | $(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({ |
---|
| 120 | "background" : labelEdited.backgroundColor, |
---|
| 121 | "color" : labelEdited.fontColor, |
---|
| 122 | "border-color" : labelEdited.borderColor |
---|
| 123 | }); |
---|
| 124 | } |
---|
| 125 | }); |
---|
[5554] | 126 | |
---|
[5603] | 127 | $("#MyMarckersList .label-list li").each(function(){ |
---|
| 128 | var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
[5554] | 129 | |
---|
[5603] | 130 | if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){ |
---|
| 131 | $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span>"+labelEdited.name+"</span>"); |
---|
| 132 | $(this).find(".square-color").css('background', labelEdited.backgroundColor); |
---|
| 133 | } |
---|
| 134 | }); |
---|
| 135 | DataLayer.put('label', labelEdited.id, labelEdited); |
---|
| 136 | DataLayer.commit(false, false, function(){ |
---|
| 137 | |
---|
| 138 | winElement.find(".insert-label").val(""); |
---|
| 139 | $.Watermark.ShowAll(); |
---|
| 140 | |
---|
| 141 | $(".label-list-container .label-list li").find('.button').button() |
---|
| 142 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
| 143 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
| 144 | |
---|
| 145 | winElement.find('.edit').unbind("click").click(editLabel); |
---|
| 146 | winElement.find('.close').click(deleteLabel); |
---|
| 147 | |
---|
| 148 | draw_tree_labels(); |
---|
| 149 | updateMessageLabels(labelEdited.id); |
---|
| 150 | |
---|
| 151 | /** |
---|
| 152 | * Atualiza menu remove o menu presente em cada mensagem listada em uma pasta |
---|
| 153 | * e carrega novamente para que os dados sejam atualizados |
---|
| 154 | */ |
---|
| 155 | $.contextMenu( 'destroy', ".table_box tbody tr"); |
---|
| 156 | loadMenu(); |
---|
| 157 | }); |
---|
| 158 | // criar marcador |
---|
| 159 | } else { |
---|
| 160 | var nameLabel = winElement.find(".input-nome").val(); |
---|
[5625] | 161 | new_label(nameLabel, false, apply); |
---|
[5566] | 162 | winElement.find(".insert-label").val(""); |
---|
[5677] | 163 | $.Watermark.ShowAll(); |
---|
| 164 | $(".save-label").button("disable"); |
---|
[5566] | 165 | } |
---|
[5603] | 166 | $(".label-list-container .label-list").find(".label-item-"+labelEdited.id).trigger("click"); |
---|
| 167 | } else { |
---|
[5789] | 168 | alert("Mínimo 2 caracteres"); |
---|
[5603] | 169 | } |
---|
[5554] | 170 | } |
---|
[5566] | 171 | |
---|
[5537] | 172 | function delete_label(id){ |
---|
| 173 | $(".label-list li").each(function () { |
---|
| 174 | var regex_match = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
| 175 | if (regex_match && regex_match[1] && regex_match[1] == id) { |
---|
| 176 | $(this).remove(); |
---|
| 177 | } |
---|
| 178 | }); |
---|
[5586] | 179 | |
---|
[5537] | 180 | DataLayer.remove('label', id); |
---|
[5586] | 181 | DataLayer.commit(false, false, function(data){ |
---|
| 182 | $.contextMenu( 'destroy', ".table_box tbody tr"); |
---|
| 183 | loadMenu(); |
---|
| 184 | updateMessageLabels(id); |
---|
| 185 | }); |
---|
[5537] | 186 | winElement.find(".label-list li:first").trigger("click"); |
---|
| 187 | |
---|
| 188 | if($(".label-list li").length == 0){ |
---|
[5675] | 189 | winElement.find(".label-list-container").html('<ul class="label-list"><li class="empty-item">'+get_lang("No labels found.")+'.</li></ul>'); |
---|
| 190 | $(".save-label").button("disable"); |
---|
| 191 | } |
---|
[5537] | 192 | var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length; |
---|
| 193 | if (qtdLi == 0){ |
---|
[5713] | 194 | $(".my-labels").hide(); |
---|
[5537] | 195 | $(".label-list-container ul").find(".empty-item").css("display",""); |
---|
| 196 | winElement.find(".buttons .save-label .ui-button-text").text('Criar'); |
---|
| 197 | $(".delete-label").button("disable"); |
---|
[5675] | 198 | $(".save-label").button("disable"); |
---|
[5537] | 199 | |
---|
| 200 | winElement.find('.input-nome').val(""); |
---|
| 201 | winElement.find(".preview-label-inner").text(""); |
---|
| 202 | |
---|
| 203 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
| 204 | colorpicker.find('input[name="backgroundColor"]').val("#ebebeb") |
---|
| 205 | .css("background-color", "#ebebeb").focus().end() |
---|
| 206 | .find('input[name="fontColor"]').val("#000000").css("background-color", "#000000").focus().end() |
---|
| 207 | .find('input[name="borderColor"]').val("#000000").css("background-color", "#000000").focus().end() |
---|
| 208 | .find('.preview-label-outer').css({ |
---|
| 209 | 'background-color':"#ebebeb", |
---|
| 210 | 'color':"#000000", |
---|
| 211 | 'border-color':"#000000" |
---|
| 212 | }); |
---|
| 213 | $(".input-nome").keyup(function () { |
---|
| 214 | var value = $(this).val(); |
---|
| 215 | winElement.find('.preview-label-inner').text(value); |
---|
| 216 | }).keyup(); |
---|
[5675] | 217 | } |
---|
[5537] | 218 | } |
---|
[5566] | 219 | |
---|
[5625] | 220 | function new_label(nameLabel, isNew, apply){ |
---|
[5537] | 221 | var labelCreated = { |
---|
| 222 | uid: User.me.id, |
---|
| 223 | name : nameLabel, |
---|
[5547] | 224 | backgroundColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(), |
---|
| 225 | fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(), |
---|
| 226 | borderColor :!!isNew ? '#000000' : winElement.find("input[name='borderColor']").val() |
---|
[5537] | 227 | } |
---|
| 228 | DataLayer.put('label', labelCreated); |
---|
| 229 | |
---|
| 230 | $(".add-label-button").removeClass("ui-icon ui-icon-plus") |
---|
| 231 | .html('<img alt="Carregando" title="Carregando" style="margin-left:10px;" src="../prototype/modules/mail/img/loader.gif" />'); |
---|
| 232 | |
---|
| 233 | DataLayer.commit(false, false, function(){ |
---|
[5533] | 234 | |
---|
[5537] | 235 | labels = DataLayer.get('label',{criteria:{order: 'id'}}, true); |
---|
| 236 | newLabel = { |
---|
| 237 | id: labels[labels.length - 1].id, |
---|
| 238 | name : labels[labels.length- 1].name, |
---|
| 239 | uid: User.me.id, |
---|
[5547] | 240 | bgColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(), |
---|
| 241 | fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(), |
---|
| 242 | borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val() |
---|
[5537] | 243 | }; |
---|
[5625] | 244 | |
---|
| 245 | /** Marca as mensagens selecionadas com o marcador criado*/ |
---|
| 246 | if(apply){ |
---|
| 247 | labeledMessages(newLabel.id) |
---|
| 248 | } |
---|
| 249 | |
---|
[5537] | 250 | $(".label-list-container ul").find(".empty-item").css("display","none"); |
---|
| 251 | $(".label-list-container ul") |
---|
| 252 | .prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel)) |
---|
| 253 | .find("li:first") |
---|
| 254 | .fadeIn("slow").click(configureLabel); |
---|
| 255 | |
---|
[5566] | 256 | draw_tree_labels(); |
---|
[5537] | 257 | |
---|
| 258 | $(".label-list-container .label-list li").not(".empty-item").click(function(){ |
---|
| 259 | $(".label-list-container .label-list li").find("img").remove(); |
---|
| 260 | $(".label-list-container .label-list li.label-item").removeClass("selected"); |
---|
| 261 | $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
| 262 | $(this).addClass("selected"); |
---|
| 263 | }); |
---|
| 264 | |
---|
| 265 | $(".label-list-container .label-list li").find('.button').button() |
---|
| 266 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
| 267 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
| 268 | |
---|
| 269 | //posiciona para edição o label inserido |
---|
| 270 | winElement.find("ul.label-list li:first").trigger("click"); |
---|
| 271 | winElement.find(".buttons .save-label .ui-button-text").text('Salvar'); |
---|
| 272 | $(".delete-label").button("enable"); |
---|
| 273 | |
---|
| 274 | winElement.find('.edit').unbind("click").click(editLabel); |
---|
| 275 | winElement.find('.close').click(deleteLabel); |
---|
| 276 | |
---|
[5713] | 277 | $(".my-labels").show(); |
---|
[5537] | 278 | |
---|
| 279 | $.contextMenu( 'destroy', ".table_box tbody tr"); |
---|
| 280 | loadMenu(); |
---|
| 281 | |
---|
| 282 | $(".add-label-button").empty() |
---|
| 283 | .addClass("ui-icon ui-icon-plus"); |
---|
| 284 | }); |
---|
| 285 | } |
---|
[5566] | 286 | |
---|
[5533] | 287 | function init_label(data){ |
---|
| 288 | |
---|
| 289 | winElement = data.window; |
---|
[5547] | 290 | |
---|
[5533] | 291 | //TODO Mudar quando API abstrair atualizações no cache |
---|
| 292 | DataLayer.remove('label',false); |
---|
| 293 | labels = DataLayer.get('label',{criteria:{order: 'name'}}); |
---|
| 294 | |
---|
| 295 | if(labels){ |
---|
| 296 | Label_List = winElement |
---|
| 297 | .find(".label-list-container").html(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels: labels})); |
---|
| 298 | |
---|
| 299 | }else{ |
---|
[5537] | 300 | //Exibe a mensagem informando o usuário de que não há nenhum marcador cadastrado. |
---|
[5533] | 301 | Label_List = winElement |
---|
[5586] | 302 | .find(".label-list-container").html('<ul class="label-list"><li class="empty-item">'+get_lang("No labels found.")+'.</li></ul>'); |
---|
[5533] | 303 | |
---|
| 304 | } |
---|
| 305 | Label_List.end() |
---|
| 306 | .find('.button').button() |
---|
| 307 | .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() |
---|
| 308 | .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); |
---|
| 309 | |
---|
| 310 | winElement.find('.edit').click(editLabel); |
---|
[5537] | 311 | winElement.find('.close').click(deleteLabel); |
---|
[5533] | 312 | |
---|
[5537] | 313 | //marca 'd agua |
---|
[5533] | 314 | winElement.find(".insert-label").Watermark(winElement.find(".insert-label").val()); |
---|
| 315 | |
---|
| 316 | $("input.insert-label").keyup(function () { |
---|
| 317 | $.Watermark.HideAll(); |
---|
| 318 | var value = $(this).val(); |
---|
| 319 | winElement.find('.input-nome').val(value); |
---|
| 320 | }).keyup(); |
---|
| 321 | |
---|
| 322 | if (!(labels)){ |
---|
| 323 | winElement.find(".buttons .save-label .ui-button-text").text('Criar'); |
---|
| 324 | $(".delete-label").button("disable"); |
---|
| 325 | }else{ |
---|
| 326 | winElement.find(".label-list li:first").addClass("selected").prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
| 327 | } |
---|
| 328 | $(".save-label").button("disable"); |
---|
| 329 | /** |
---|
| 330 | * seta a ação de click para os marcadores listados na tela |
---|
| 331 | */ |
---|
| 332 | winElement.find(".label-list li").not(".empty-item").click(configureLabel); |
---|
| 333 | |
---|
| 334 | if (data.selectedItem) |
---|
| 335 | winElement.find(".label-list li.label-item-"+data.selectedItem).trigger("click"); |
---|
| 336 | else |
---|
| 337 | winElement.find(".label-list li:first").trigger("click"); |
---|
| 338 | |
---|
| 339 | var dataColorPicker = { |
---|
| 340 | colorsSuggestions: colors_suggestions() |
---|
| 341 | }; |
---|
| 342 | |
---|
| 343 | winElement.find('select.color-suggestions').change(function() { |
---|
| 344 | $(".save-label").button("enable"); |
---|
| 345 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
| 346 | var colors; |
---|
| 347 | if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) { |
---|
| 348 | colorpicker |
---|
| 349 | .find('input[name="fontColor"]').val(colors.font).focus().end() |
---|
| 350 | .find('input[name="backgroundColor"]').val(colors.background).focus().end() |
---|
| 351 | .find('input[name="borderColor"]').val(colors.border).focus().end() |
---|
| 352 | |
---|
| 353 | .find('.preview-label-outer').css({ |
---|
| 354 | 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background, |
---|
| 355 | 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border, |
---|
| 356 | 'color':dataColorPicker.colorsSuggestions[$(this).val()].font |
---|
| 357 | }); |
---|
| 358 | } |
---|
| 359 | }); |
---|
| 360 | var colorpickerPreviewChange = function(color) { |
---|
| 361 | |
---|
| 362 | var pickedup = winElement.find('.colorwell-selected').val(color).css('background-color', color); |
---|
| 363 | |
---|
| 364 | $(".save-label").button("enable"); |
---|
| 365 | |
---|
| 366 | var colorpicker = winElement.find('.lebals-colorpicker'); |
---|
| 367 | |
---|
| 368 | if (pickedup.is('input[name="backgroundColor"]')) { |
---|
| 369 | colorpicker.find('.preview-label-outer').css('background-color',color); |
---|
| 370 | } else if (pickedup.is('input[name="fontColor"]')) { |
---|
| 371 | colorpicker.find('.preview-label-outer').css('color',color); |
---|
| 372 | } else if (pickedup.is('input[name="borderColor"]')) { |
---|
| 373 | colorpicker.find('.preview-label-outer').css('border-color',color); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | var f = $.farbtastic(winElement.find('.colorpicker'), colorpickerPreviewChange); |
---|
| 378 | var selected; |
---|
| 379 | |
---|
| 380 | winElement.find('.colorwell').each(function () { |
---|
| 381 | f.linkTo(this); |
---|
| 382 | }) |
---|
| 383 | .focus(function() { |
---|
| 384 | if (selected) { |
---|
| 385 | $(selected).removeClass('colorwell-selected'); |
---|
| 386 | } |
---|
| 387 | $(selected = this).addClass('colorwell-selected'); |
---|
| 388 | f.linkTo(this, colorpickerPreviewChange); |
---|
| 389 | f.linkTo(colorpickerPreviewChange); |
---|
| 390 | }); |
---|
| 391 | |
---|
| 392 | winElement.find(".add-label-button").click(function (event) { |
---|
| 393 | $.Watermark.HideAll(); |
---|
[5537] | 394 | var nameLabel = winElement.find(".insert-label").val(); |
---|
[5607] | 395 | |
---|
| 396 | var lengthSpace = $.trim(nameLabel); |
---|
| 397 | |
---|
[5789] | 398 | if(lengthSpace.length >= 2){ |
---|
[5625] | 399 | new_label(nameLabel, true, data.applyToSelectedMessages); |
---|
[5537] | 400 | $.Watermark.ShowAll(); |
---|
| 401 | winElement.find(".insert-label").val(""); |
---|
[5533] | 402 | } else { |
---|
[5789] | 403 | alert("Mínimo 2 caracteres"); |
---|
[5533] | 404 | } |
---|
| 405 | event.stopImmediatePropagation(); |
---|
| 406 | }); |
---|
| 407 | |
---|
| 408 | winElement.find('.insert-label').keydown(function(event, ui) { |
---|
| 409 | if (event.keyCode == 13) |
---|
| 410 | winElement.find(".add-label-button").trigger('click'); |
---|
| 411 | }); |
---|
[5537] | 412 | |
---|
[5533] | 413 | //excluir marcador {deve ser para o botão grande na janela de edição e nao o pequeno da lista} |
---|
| 414 | winElement.find(".buttons .delete-label").click(function(event){ |
---|
[5586] | 415 | var id = winElement.find(".edit-label").val(); |
---|
[5820] | 416 | var nameLabel = winElement.find(".input-nome").val(); |
---|
| 417 | confirmDelete(id, nameLabel); |
---|
[5533] | 418 | event.stopImmediatePropagation(); |
---|
| 419 | }); |
---|
[5537] | 420 | |
---|
[5533] | 421 | $(".label-list-container .label-list li").not(".empty-item").click(function(){ |
---|
| 422 | $(".label-list-container .label-list li").find("img").remove(); |
---|
| 423 | $(".label-list-container .label-list li.label-item").removeClass("selected"); |
---|
| 424 | $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); |
---|
| 425 | $(this).addClass("selected"); |
---|
| 426 | }); |
---|
| 427 | |
---|
| 428 | //salvar/criar marcador |
---|
[5564] | 429 | winElement.find(".buttons .save-label").click(function(){ |
---|
[5603] | 430 | var nameLabel = winElement.find(".input-nome").val(); |
---|
[5625] | 431 | save_editLabel(nameLabel, data.applyToSelectedMessages); |
---|
[5564] | 432 | }); |
---|
[5533] | 433 | //desfazer marcador |
---|
| 434 | winElement.find(".buttons .undo-label").click(function(event){ |
---|
| 435 | var edit = winElement.find(".edit-label").val(); |
---|
| 436 | $(".label-list-container .label-list li").each(function(){ |
---|
| 437 | var regex_match_3 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/); |
---|
| 438 | if(regex_match_3 && regex_match_3[1] && regex_match_3[1] == edit){ |
---|
| 439 | $(this).trigger("click"); |
---|
| 440 | } |
---|
| 441 | }); |
---|
| 442 | }); |
---|
| 443 | |
---|
| 444 | //fechar |
---|
| 445 | $(".button-close-window .close-window").click(function(){ |
---|
| 446 | $(".label-configure-win").dialog("close"); |
---|
[5643] | 447 | }); |
---|
[5533] | 448 | |
---|
[5643] | 449 | winElement.find(':input').change(function(event){ |
---|
[5673] | 450 | if (event.keyCode != '27' && event.keyCode != '13' && !$(event.target).is(".edit-value-list") && !$(event.target).is(".insert-label") ) |
---|
[5643] | 451 | winElement.find(".save-label").button("enable"); |
---|
| 452 | }).keydown(function(event){ |
---|
[5673] | 453 | if (event.keyCode != '27' && event.keyCode != '13' && !$(event.target).is(".edit-value-list") && !$(event.target).is(".insert-label")) |
---|
[5643] | 454 | winElement.find(".save-label").button("enable"); |
---|
| 455 | }); |
---|
| 456 | |
---|
[5533] | 457 | $(".input-nome").keyup(function () { |
---|
| 458 | var value = $(this).val(); |
---|
| 459 | winElement.find('.preview-label-inner').text(value); |
---|
[5537] | 460 | }).keyup(); |
---|
[5713] | 461 | } |
---|