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