1jQuery(function ($) 2{ 3 //matriz box é baseado em pines notify 4 //documentação: http://pinesframework.org/pnotify 5 $.pnotify.defaults.closer_hover = false; 6 $.pnotify.defaults.hide = true; 7 $.pnotify.defaults.delay = 5000; 8 $.pnotify.defaults.history = false; 9 $.pnotify.defaults.sticker = false; 10 matriz.box = {}; 11 //configs auxiliares 12 matriz.box.config = {}; 13 matriz.box.config.confirm = function (selector, eventtype, message, callback) { 14 $(selector).each(function () { 15 element = $(this); 16 callback = matriz.box.callback(element, callback); 17 element.on(eventtype, function () { 18 matriz.box.obtrusive.confirm(message, callback); 19 return false; 20 }); 21 }); 22 }; 23 24 matriz.box.notifications = {}; 25 matriz.box.notifications.type = null; 26 matriz.box.notifications.mensagem = null; 27 matriz.box.notifications.caller = null; 28 matriz.box.notifications.exists = function (mensagem, type) { 29 var caller = arguments.callee.caller; 30 31 try { 32 var loop = 10; 33 while (caller.caller !== null && loop-- >= 0) { 34 caller = caller.caller; 35 } 36 } catch (e) {} 37 38 if ($("#notificacoes > div").length 39 && type === matriz.box.notifications.type 40 && mensagem === matriz.box.notifications.mensagem 41 && caller === matriz.box.notifications.caller) { 42 matriz.box.notifications.shake(); 43 return true; 44 } else { 45 matriz.box.notifications.type = type; 46 matriz.box.notifications.mensagem = mensagem; 47 matriz.box.notifications.caller = caller; 48 matriz.box.notifications.remove(); 49 return false; 50 } 51 }; 52 matriz.box.notifications.shake = function () { 53 $("#notificacoes").effect("shake", {times: 4}, 1000); 54 }; 55 matriz.box.notifications.remove = function () { 56 $("#notificacoes").empty(); 57 }; 58 matriz.box.notifications.append = function (pnotify) { 59 var $pnotify = $(pnotify[0]); 60 $pnotify.css("width", "100%"); 61 $pnotify.find(".ui-pnotify-icon").hide(); 62 $pnotify.find(".ui-pnotify-text").addClass("clearfix"); 63 $pnotify.appendTo("#notificacoes"); 64 }; 65 66 //box no estilo de notificação 67 matriz.box.notify = {}; 68 matriz.box.notify.default = function (mensagem, type) { 69 matriz.box.notifications.remove(); 70 $.pnotify({ 71 text: mensagem, 72 type: type, 73 before_open: function (pnotify) { 74 matriz.box.notifications.append(pnotify); 75 } 76 }); 77 }; 78 79 matriz.box.notify.danger = function (mensagem) { 80 matriz.box.notify.default(mensagem, 'error'); 81 }; 82 matriz.box.notify.info = function (mensagem) { 83 matriz.box.notify.default(mensagem, 'info'); 84 }; 85 matriz.box.notify.success = function (mensagem) { 86 matriz.box.notify.default(mensagem, 'success'); 87 }; 88 matriz.box.notify.warning = function (mensagem) { 89 matriz.box.notify.default(mensagem, 'info'); 90 }; 91 92 matriz.box.image = {}; 93 matriz.box.image.show = function (imagem, caption) { 94 var matrizBoxImage = '<div id="matrizBoxImage" class="modal fade"><div class="modal-dialog modal-lg"><div class="modal-content">'; 95 matrizBoxImage += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; 96 matrizBoxImage += '<h4 class="modal-title">' + caption + '</h4></div>'; 97 matrizBoxImage += '<div class="modal-body"><img class="img-thumbnail" src="' + imagem + '" alt="" />'; 98 matrizBoxImage += '</div></div></div></div>'; 99 $("body").append(matrizBoxImage); 100 $('#matrizBoxImage').modal({backdrop: true}); 101 $('#matrizBoxImage').on('shown.bs.modal', function () { 102 $('#matrizBoxImage').find("button.close").focus(); 103 }); 104 $('#matrizBoxImage').on('hidden.bs.modal', function () { 105 $(this).remove(); 106 }); 107 }; 108 109 //backdrop para box obstrutivos 110 matriz.box.backdrop = {}; 111 var modal_backdrop; 112 if (typeof info_box !== "undefined") { 113 info_box.pnotify_display(); 114 return; 115 } 116 matriz.box.backdrop.show = function (pnotify) { 117 // Make a modal screen overlay. 118 if (modal_backdrop) 119 modal_backdrop.fadeIn("fast"); 120 else 121 modal_backdrop = $("<div />", { 122 "class": "matriz-ui-alert-backdrop modal-backdrop fade in", 123 "css": { 124 "display": "none", 125 "position": "fixed", 126 "top": "0", 127 "bottom": "0", 128 "right": "0", 129 "left": "0" 130 } 131 }).appendTo("body").fadeIn("fast"); 132 }; 133 matriz.box.backdrop.hide = function () { 134 modal_backdrop.fadeOut("fast"); 135 }; 136 //botões para box obstrutivos 137 matriz.box.buttons = {}; 138 matriz.box.buttons.alert = '<div class="matriz-ui-alert-buttons">\ 139 <button data-matriz-action="confirm-close" type="button" class="btn btn-default btn-sm" style="background: none">\
140 <span class="fa fa-close"></span>\ 141 </button>\ 142 </div>'; 143 matriz.box.buttons.confirm = '<div class="matriz-ui-alert-buttons">\ 144 <button type="button" data-matriz-action="confirm-callback" class="btn btn-warning btn-sm">Continuar</button>\ 145 <button type="button" data-matriz-action="confirm-close" class="btn btn-default btn-sm">Cancelar</button>\ 146 </div>'; 147 148 //callback para box obstrutivos 149 matriz.box.callback = function (element, callback) { 150 //caso o callback seja nulo, verifica se é um link e então tenta recuperar o href para utilizar como location destino 151 if (callback === null) 152 { 153 if (element.is("a") && element.attr("href").length > 0) 154 { 155 callback = function () { 156 window.location.assign(element.attr("href")); 157 }; 158 } 159 } 160 else if (jQuery.type(callback) === "string") 161 { 162 //caso o callback seja um string considera este como um location destino 163 callback = function () { 164 window.location.assign(callback); 165 }; 166 } 167 return callback; 168 }; 169 170//alert obstrutivo 171 matriz.box.obtrusive = {}; 172 matriz.box.obtrusive.default = function (mensagem, callback, type) { 173 type = type || 'info'; 174 matriz.box.notifications.remove(); 175 $.pnotify({ 176 text: mensagem + matriz.box.buttons.alert, 177 type: type, 178 after_open: function (pnotify) { 179 $(pnotify[0]).find("button[data-matriz-action='confirm-close']").focus(); 180 }, 181 before_open: function (pnotify) { 182 matriz.box.backdrop.show(pnotify); 183 matriz.box.notifications.append(pnotify); 184 185 $(pnotify[0]).find(".ui-pnotify-closer").hide(); 186 $(pnotify[0]).find("button[data-matriz-action='confirm-close']").click(function () { 187 pnotify.pnotify_remove(); 188 $(pnotify).remove(); 189 if (callback) 190 callback(); 191 }); 192 }, 193 before_close: function () { 194 matriz.box.backdrop.hide(); 195 } 196 }); 197 }; 198 matriz.box.obtrusive.danger = function (mensagem, callback) { 199 matriz.box.obtrusive.default(mensagem, callback, "danger"); 200 }; 201 matriz.box.obtrusive.info = function (mensagem, callback) { 202 matriz.box.obtrusive.default(mensagem, callback, "info"); 203 }; 204 matriz.box.obtrusive.success = function (mensagem, callback) { 205 matriz.box.notify.success(mensagem); 206// matriz.box.obtrusive.default(mensagem, callback, "success"); 207 }; 208 matriz.box.obtrusive.warning = function (mensagem, callback) { 209 matriz.box.obtrusive.default(mensagem, callback, "warning"); 210 }; 211 //confirm 212 matriz.box.obtrusive.confirm = function (mensagem, confirm, reject) { 213 var type = 'warning'; 214 matriz.box.notifications.remove(); 215 $.pnotify({ 216 text: mensagem + matriz.box.buttons.confirm, 217 type: type, 218 hide: false, 219 after_open: function (pnotify) { 220 $(pnotify[0]).find("button[data-matriz-action='confirm-callback']").focus(); 221 }, 222 before_open: function (pnotify) { 223 matriz.box.backdrop.show(pnotify); 224 matriz.box.notifications.append(pnotify); 225 226 $(pnotify[0]).find(".ui-pnotify-closer").hide(); 227 $(pnotify[0]).find("button[data-matriz-action='confirm-close']").click(function () { 228 pnotify.pnotify_remove(); 229 $(pnotify).remove(); 230 if (typeof reject === "function") { 231 reject(); 232 } 233 }); 234 $(pnotify[0]).find("button[data-matriz-action='confirm-callback']").click(function () { 235 pnotify.pnotify_remove(); 236 if (typeof confirm === "function") { 237 confirm(); 238 } 239 }); 240 }, 241 before_close: function () { 242 matriz.box.backdrop.hide(); 243 } 244 }); 245 }; 246 //prompt 247 matriz.box.obtrusive.prompt = function (mensagem, callback) { 248 window.alert("Não implementado! Deve ser feito a partir da primeira necessidade."); 249 }; 250 251 matriz.box.uniquemodal = {}; 252 253 matriz.box.uniquemodal.create = function (options) { 254 $('#uniqueModal').remove(); 255 $('.modal-backdrop').remove(); 256 257 var modalUnique = '<div id="uniqueModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="uniqueModal" aria-hidden="true">\n\ 258 <div class="modal-dialog">\n\ 259 <div class="modal-content">\n\ 260 <div class="modal-header">\n\ 261 <button type="button" class="close" data-dismiss="modal">\n\
262 <span aria-hidden="true">×</span><span class="sr-only">' + matriz.utils.internationalization.translate("Fechar", "matriz.global.box") + '</span>\n\ 263 </button>\n\ 264 <h4 class="modal-title"></h4>\n\ 265 </div>\n\ 266 <div class="modal-body"></div>\n\ 267 <div class="modal-footer"></div>\n\ 268 </div>\n\ 269 </div>\n\ 270 </div>'; 271 $("body").append(modalUnique); 272 273 if (!options) { 274 options = matriz.box.uniquemodal.defaults; 275 } else { 276 if (options.titulo === undefined) 277 options.titulo = matriz.box.uniquemodal.defaults.titulo; 278 if (options.mensagem === undefined) 279 options.mensagem = matriz.box.uniquemodal.defaults.mensagem; 280 if (options.corContextual === undefined) 281 options.corContextual = matriz.box.uniquemodal.defaults.corContextual; 282 if (options.keyboard === undefined) 283 options.keyboard = matriz.box.uniquemodal.defaults.keyboard; 284 } 285 286 $('#uniqueModal').modal({backdrop: "static", show: false, keyboard: options.keyboard}); 287 288 if (options.customClass) { 289 $('#uniqueModal').addClass(options.customClass); 290 } 291 292 $('#uniqueModal .modal-header .modal-title').html(options.titulo); 293 $('#uniqueModal .modal-body').html(options.mensagem); 294 $('#uniqueModal .modal-header').addClass("bg-" + options.corContextual); 295 296 if (options.buttons && options.buttons instanceof Array) { 297 if (options.buttons.length) { 298 options.buttons.forEach(function (element) { 299 var $button = matriz.box.uniquemodal.createbutton(element); 300 $('#uniqueModal .modal-footer').append($button); 301 }); 302 } else { 303 $('#uniqueModal .modal-footer').remove(); 304 } 305 } else { 306 var $button = matriz.box.uniquemodal.createbutton({ 307 "attributes": {"class": "btn btn-default", "data-dismiss": "modal"}, 308 "value": matriz.utils.internationalization.translate("Fechar", "matriz.global.box") 309 }); 310 $('#uniqueModal .modal-footer').append($button); 311 } 312 $('#uniqueModal').modal("show"); 313 $('#uniqueModal').on('hidden.bs.modal', function (e) { 314 $('#uniqueModal').remove(); 315 }); 316 }; 317 318 matriz.box.uniquemodal.hide = function() { 319 $('#uniqueModal').modal("hide"); 320 }; 321 322 matriz.box.uniquemodal.createbutton = function (button) { 323 var $button = $('<button type="button">' + button.value + '</button>'); 324 for (var key in button.attributes) { 325 $button.attr(key, button.attributes[key]); 326 } 327 if (button.callback) { 328 if (typeof button.callback === "function") { 329 $button.click(function () { 330 button.callback(); 331 }); 332 } 333 } 334 return $button; 335 }; 336 337 matriz.box.uniquemodal.defaults = { 338 titulo: "Atenção", 339 mensagem: "", 340 corContextual: "primary", 341 callback: null, 342 keyboard: true 343 }; 344 345 //alias para as funções 346 matriz.alert = matriz.box.obtrusive.default; 347 matriz.confirm = matriz.box.obtrusive.confirm; 348 matriz.prompt = matriz.box.obtrusive.prompt; 349});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.