1/* 2 requires 3 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 4 <script src="/bootstrap/js/bootstrap-modal.js"></script> 5 <script src="/bootstrap/js/bootstrap-modalmanager.js"></script> 6 */ 7var modalManager = { 8 hashChars: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 9 options: { 10 modalHeader: "ERROR", 11 modalBody: "An error has occurred", 12 modalFooter: " ", 13 modalClass: "fade", 14 modalID: null 15 16 }, 17 create: function (modalID) { 18 19 var d = $.Deferred(); 20 21 var data = { 22 cpProcess: "generateModal" 23 }; 24 25 if (typeof modalID !== "undefined" && modalID.length > 0) { 26 this.options["modalID"] = modalID; 27 } else { 28 this.options["modalID"] = this.generateModalID(); 29 } 30 31 var modalID = this.options["modalID"]; 32 33 for (x in this.options) { 34 data[x] = this.options[x]; 35 } 36 37 if (document.getElementById("cpModalTemplate")){ 38 39 d.resolve(modalManager.clone()); 40 41 } else { 42 $.ajax({ 43 url: window.location.pathname, 44 type: "POST", 45 datatype: "html", 46 data: data 47 }).done(function (response) { 48 $("body").append(response); 49 d.resolve(modalID); 50 }).fail(function (a, b, c) { 51 d.reject(b); 52 }); 53 } 54 55 56 return d.promise(); 57 58 }, 59 clone : function() { 60 61 var modalTemplate = $("#cpModalTemplate").html(); 62 if (typeof this.options["modalID"] === "undefined"){ 63 this.options["modalID"] = this.generateModalID(); 64 } 65 modalTemplate = '<div class="modal ' + this.options['modalClass'] + '" id="' + this.options["modalID"] + '" tabindex="-1" role="dialog" aria-hidden="true" aria-labelledby="modalHeader_' + this.options["modalID"] + '" data-generator="inline">' + modalTemplate + '</div>'; 66 $("body").append(modalTemplate); 67 $("#" + this.options['modalID'] + " .modal-header .modal-title").attr("id", 'modalHeader_' + this.options["modalID"]); 68 69 return this.options["modalID"]; 70 71 }, 72 hide: function (modalID) { 73 if (modalID.length > 0) { 74 $("#" + modalID).modal("hide"); 75 setTimeout(modalManager.remove, 2000, modalID); 76 } 77 }, 78 remove: function (modalID) { 79 if (modalID.length > 0) { 80 $("#" + modalID + " button").unbind("click"); 81 $("#" + modalID).remove(); 82 } 83 }, 84 getModalID: function () { 85 return modalManager.options["modalID"]; 86 }, 87 randomString: function (length) { 88 var result = ''; 89 for (var i = length; i > 0; --i) 90 result += this.hashChars[Math.round(Math.random() * (this.hashChars.length - 1))]; 91 return result; 92 }, 93 generateModalID: function () { 94 modalManager.options["modalID"] = "CPModal_" + this.randomString(25); 95 return modalManager.options["modalID"]; 96 } 97 98}; 99 100function initModal() { 101 var d = $.Deferred(); 102 modalManager.create().done(function (response) { 103 d.resolve(response); 104 }).fail(function (error) { 105 d.reject(error); 106 }); 107 108 return d.promise(); 109} 110function okBox(title, msg, okFunction, params) { 111 var modalIDGenerated = initModal().done(function (modalID) { 112 $("#" + modalID + " .modal-header h4").html(title); 113 $("#" + modalID + " .modal-body p").html(msg); 114 $("#" + modalID + " .modal-footer").html('<a href="#" id="okBoxOKButton_' + modalID + '" data-dismiss="modal" class="btn btn-primary">OK</a>'); 115 $("#" + modalID).modal({show: true}); 116 if (okFunction) { 117 $("#okBoxOKButton_" + modalID).click(function () { 118 okFunction(params); 119 setTimeout(modalManager.remove, 2000, modalID); 120 }); 121 } else { 122 $("#okBoxOKButton_" + modalID).click(function () { 123 setTimeout(modalManager.remove, 2000, modalID); 124 }); 125 } 126 return modalID; 127 }); 128 return modalIDGenerated; 129} 130 131 132 133function confirmBox(title, msg, okFunction, params, okLabelOverride, cancelLabelOverride) { 134 var d = $.Deferred(); 135 var okLabel="OK"; 136 var cancelLabel="Cancel"; 137 if(okLabelOverride){ 138 okLabel=okLabelOverride; 139 } 140 if(cancelLabelOverride){ 141 cancelLabel=cancelLabelOverride; 142 } 143 initModal().done(function (modalID) { 144 $("#" + modalID + " .modal-header h4").html(title); 145 $("#" + modalID + " .modal-body p").html(msg); 146 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">' + okLabel +'</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">' + cancelLabel +'</a>'); 147 $("#" + modalID).modal({ 148 show: true, 149 backdrop: 'static' 150 }).one('click', '#modalOK_' + modalID, function () { 151 setTimeout(modalManager.remove, 2000, modalID); 152 if (typeof okFunction !== "undefined") { 153 okFunction(params); 154 okFunction = null; 155 } 156 }).one('click', '#modalCancel_' + modalID, function () { 157 okFunction = null; 158 setTimeout(modalManager.remove, 2000, modalID); 159 }); 160 d.resolve(modalID); 161 162 }); 163 return d.promise(); 164} 165 166function emailEditBox(title, okFunction, params) { 167 var d = $.Deferred(); 168 initModal().done(function (modalID) { 169 170 var msg = '<div class="row"><div class="col-md-12"><form><fieldset><div class="form-group"><label class="control-label" for="emailPop">Email:</label></div><div class="form-group"><input class="form-control" type="text" name="emailPop" id="emailPop" value="' + params.email + '" /></div><div class="form-group"><label class="control-label" for="displayNamePop">Display Name:</label></div><div class="form-group"><input class="form-control" type="text" name="displayNamePop" id="displayNamePop" value="' + params.displayName + '" /></div><input type="hidden" name="emailIDPop" id="emailIDPop" value="' + params.emailID + '" /></fieldset></form></div></div>'; 171 172 $("#" + modalID + " .modal-header h4").html(title); 173 $("#" + modalID + " .modal-body p").html(msg); 174 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">Save</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 175 $("#" + modalID).modal({ 176 show: true, 177 backdrop: 'static' 178 }).one('click', '#modalOK_' + modalID, function () { 179 var changedParams = { 180 emailID: $("#" + modalID + " #emailIDPop").val(), 181 email: $("#" + modalID + " #emailPop").val(), 182 displayName: $("#" + modalID + " #displayNamePop").val() 183 }; 184 setTimeout(modalManager.remove, 2000, modalID); 185 if (typeof okFunction !== "undefined") {
186 okFunction(changedParams); 187 okFunction = null; 188 } 189 }).one('click', '#modalCancel_' + modalID, function () { 190 okFunction = null; 191 setTimeout(modalManager.remove, 2000, modalID); 192 }); 193 d.resolve(modalID); 194 195 }); 196 return d.promise(); 197} 198 199function emailListEditBox(title, okFunction, params) { 200 var d = $.Deferred(); 201 initModal().done(function (modalID) { 202 203 var msg = '<div class="row"><div class="col-md-12"><form><fieldset><div class="form-group"><label class="control-label" for="list">List Name:</label></div><div class="form-group"><input class="form-control" type="text" name="listNamePop" id="listNamePop" value="' + params.listName + '" /></div><input type="hidden" name="listIDPop" id="listIDPop" value="' + params.listID + '" /></fieldset></form></div></div>'; 204 205 $("#" + modalID + " .modal-header h4").html(title); 206 $("#" + modalID + " .modal-body p").html(msg); 207 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">Save</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 208 $("#" + modalID).modal({ 209 show: true, 210 backdrop: 'static' 211 }).one('click', '#modalOK_' + modalID, function () { 212 var changedParams = { 213 listID: $("#" + modalID + " #listIDPop").val(), 214 listName: $("#" + modalID + " #listNamePop").val() 215 }; 216 setTimeout(modalManager.remove, 2000, modalID); 217 if (typeof okFunction !== "undefined") { 218 okFunction(changedParams); 219 okFunction = null; 220 } 221 }).one('click', '#modalCancel_' + modalID, function () { 222 okFunction = null; 223 setTimeout(modalManager.remove, 2000, modalID); 224 }); 225 d.resolve(modalID); 226 227 }); 228 return d.promise(); 229} 230 231function addEmailToCustomListEditBox(title, okFunction, params) { 232 var d = $.Deferred(); 233 initModal().done(function (modalID) { 234 235 var msg = '<div class="row"><div class="col-md-12"><form><fieldset><div class="form-group"><label class="control-label" for="email">Email</label></div><div class="form-group"><input class="form-control" type="text" name="emailPop" id="emailPop" value="" /></div><div class="form-group"><label class="control-label" for="displayName">Display Name (optional)</label></div><div class="form-group"><input class="form-control" type="text" name="displayNamePop" id="displayNamePop" value="" /></div><input type="hidden" name="listIDPop" id="listIDPop" value="' + params.listID + '" /></fieldset></form></div></div>'; 236 237 $("#" + modalID + " .modal-header h4").html(title); 238 $("#" + modalID + " .modal-body p").html(msg); 239 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">Save Contact To List</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 240 $("#" + modalID).modal({ 241 show: true, 242 backdrop: 'static' 243 }).one('click', '#modalOK_' + modalID, function () { 244 var changedParams = { 245 listID: $("#" + modalID + " #listIDPop").val(), 246 email: $("#" + modalID + " #emailPop").val(), 247 displayName: $("#" + modalID + " #displayNamePop").val() 248 }; 249 setTimeout(modalManager.remove, 2000, modalID); 250 if (typeof okFunction !== "undefined") { 251 okFunction(changedParams); 252 okFunction = null; 253 } 254 }).one('click', '#modalCancel_' + modalID, function () { 255 okFunction = null; 256 setTimeout(modalManager.remove, 2000, modalID); 257 }); 258 d.resolve(modalID); 259 260 }); 261 return d.promise(); 262} 263 264function customStyleNameEditBox(title, okFunction, params) { 265 var d = $.Deferred(); 266 initModal().done(function (modalID) { 267 268 var msg = '<div class="row"><div class="col-md-12"><strong>Current Custom Style Name: </strong> ' + params.newStyleName + '</div><div class="col-md-12"><form><fieldset><div class="form-group"></div><div class="form-group"><label class="control-label" for="list">Change Style Name To:</label><input class="form-control" type="text" name="newStyleName" id="newStyleName" value="' + params.newStyleName + '" /></div><input type="hidden" name="newStyleID" id="newStyleID" value="' + params.styleID + '" /><input type="hidden" name="memberID" id="memberID" value="' + params.memberID + '" /></fieldset></form></div></div>'; 269 270 $("#" + modalID + " .modal-header h4").html(title); 271 $("#" + modalID + " .modal-body p").html(msg); 272 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">Save</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 273 $("#" + modalID).modal({ 274 show: true, 275 backdrop: 'static' 276 }).one('click', '#modalOK_' + modalID, function () { 277 var changedParams = { 278 memberID: $("#" + modalID + " #memberID").val(), 279 styleID: $("#" + modalID + " #newStyleID").val(), 280 newStyleName: $("#" + modalID + " #newStyleName").val() 281 }; 282 setTimeout(modalManager.remove, 2000, modalID); 283 if (typeof okFunction !== "undefined") {
284 okFunction(changedParams); 285 okFunction = null; 286 } 287 }).one('click', '#modalCancel_' + modalID, function () { 288 okFunction = null; 289 setTimeout(modalManager.remove, 2000, modalID); 290 }); 291 d.resolve(modalID); 292 293 }); 294 return d.promise(); 295} 296 297function approveOrderBox(title, okFunction, params) { 298 var d = $.Deferred(); 299 initModal().done(function (modalID) { 300 301 var msg = '<div class="row"><div class="col-md-12"><form><fieldset><div class="form-group"><label class="control-label" for="orderID">order ID</label></div><div class="form-group"><input class="form-control" type="text" name="orderIDPop" id="orderIDPop" value="' + params.orderID + '" readonly /></div><div class="form-group"><label class="control-label" for="commentsPop">Enter Your Comments</label><textarea id="commentsPop" class="form-control" rows="4" cols="50"></textarea></div></fieldset></form></div></div>'; 302 303 $("#" + modalID + " .modal-header h4").html(title); 304 $("#" + modalID + " .modal-body p").html(msg); 305 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">
305Approve Order</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 306 $("#" + modalID).modal({ 307 show: true, 308 backdrop: 'static' 309 }).one('click', '#modalOK_' + modalID, function () { 310 var changedParams = { 311 orderID: $("#" + modalID + " #orderIDPop").val(), 312 comments: $("#" + modalID + " #commentsPop").val() 313 }; 314 setTimeout(modalManager.remove, 2000, modalID); 315 if (typeof okFunction !== "undefined") { 316 okFunction(changedParams); 317 okFunction = null; 318 } 319 }).one('click', '#modalCancel_' + modalID, function () { 320 okFunction = null; 321 setTimeout(modalManager.remove, 2000, modalID); 322 }); 323 d.resolve(modalID); 324 325 }); 326 return d.promise(); 327} 328 329function preventEnterKey(e){ 330 if(e.keyCode == 13) 331 { 332 if(window.console && window.console.log){ 333 console.log('prevented enter key'); 334 } 335 return false; 336 } 337} 338 339function genericInputBox(title, introMessage, inputArray, endMessage, okFunction){ 340 var d = $.Deferred(); 341 initModal().done(function (modalID) { 342 //disable enter key - patch to prevent submitting some background form 343 $('html').on('keypress', null, preventEnterKey); 344 345 var htmlBody='<div>' + introMessage + '</div><form class="modal_inputs">'; 346 for(var i=0; i<inputArray.length; i++){ 347 var inputItem=inputArray[i]; 348 htmlBody+='<div class="modal_input"><label for="' + inputItem.id + '">' + inputItem.label + '</label>'; 349 if(inputItem.type=='text'){ 350 htmlBody+='<input type="text" id="' + inputItem.id + '" name="' + inputItem.name + '" value="' + inputItem.initialValue + '" required="' + inputItem.requiredField + '">'; 351 } 352 if(inputItem.type=='password'){ 353 htmlBody+='<input type="password" id="' + inputItem.id + '" value="' + inputItem.initialValue + '" required="' + inputItem.requiredField + '">'; 354 } 355 htmlBody+='</div>'; 356 357 } 358 htmlBody+='</form><div>' + endMessage +'</div>'; 359 360 361 $("#" + modalID + " .modal-header h4").html(title); 362 363 $("#" + modalID + " .modal-body p").html(htmlBody); 364 $("#" + modalID + " .modal-footer").html('<a id="modalOK_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-primary">OK</a> <a id="modalCancel_' + modalID + '" href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>'); 365 $("#" + modalID).modal({ 366 show: true, 367 backdrop: 'static' 368 }).one('click', '#modalOK_' + modalID, function () { 369 $('html').off('keypress', null, preventEnterKey); 370 setTimeout(modalManager.remove, 2000, modalID); 371 372 processInputBox( okFunction, $("#" + modalID + ' .modal_inputs') ); 373 374 }).one('click', '#modalCancel_' + modalID, function () { 375 $('html').off('keypress', null, preventEnterKey); 376 okFunction = null; 377 setTimeout(modalManager.remove, 500, modalID); 378 }); 379 d.resolve(modalID); 380 381 }); 382 return d.promise(); 383 384} 385 386function processInputBox(okFunction, $modal_inputs){ 387 var params=$modal_inputs.serializeArray(); 388 389 okFunction(params); 390} 391 392function CP_showProgressMessage(msg,icon,timer){ 393 394 if (icon){ 395 if (icon === "spacer"){ 396 var useIcon = ''; 397 } else if (icon === "error"){ 398 var useIcon = '<i class="fa fa-times-circle red"></i>'; 399 } else if (icon === "ok"){ 400 var useIcon = '<i class="fa fa-check-circle green"></i>'; 401 } else if (icon === "spinner"){ 402 var useIcon = '<i class="fa fa-spinner fa-spin"></i>'; 403 } else { 404 var useIcon = '<i class="fa fa-' + icon + '">' + '<' + '/i' + '>'; 405 } 406 } else { 407 var useIcon = '<i class="fa fa-spinner fa-spin"></i>'; 408 } 409 410 if (timer && timer>0){ 411 var thisTimer = timer; 412 } 413 414 if (msg){ 415 if (msg.length > 25){ 416 $(".meerkatMessage").css({"width":"750px"}); 417 } 418 $("#CP_ProgressMsg span").html(useIcon + ' ' + msg); 419 // jquery.meerkat.js is sometimes blocked by ad/tracker blockers (its filename alone is enough to 420 // trip some filter lists) - fall back to a plain show/hide so the rest of the calling code (which 421 // often runs after this call, e.g. an AJAX request) doesn't get aborted by an uncaught TypeError. 422 if (typeof $.fn.meerkat === "function"){ 423 if (thisTimer && thisTimer>0){ 424 $("#CP_ProgressMsg").meerkat({"position":"top",timer: thisTimer,animationOut: "fade"}); 425 var mto = setTimeout("CP_hideProgressMessage()",(thisTimer*1010)); 426 } else { 427 $("#CP_ProgressMsg").meerkat({"position":"top"}); 428 } 429 } else { 430 $("#CP_ProgressMsg").show(); 431 if (thisTimer && thisTimer>0){ 432 var mto = setTimeout("CP_hideProgressMessage()",(thisTimer*1010)); 433 } 434 } 435 $("#useIcon").attr("src",useIcon); 436 return true; 437 } 438 return false;
439 440} 441 442function CP_hideProgressMessage(){ 443 if (typeof $.fn.destroyMeerkat === "function"){ 444 $("#CP_ProgressMsg").destroyMeerkat(); 445 } else { 446 $("#CP_ProgressMsg").hide(); 447 } 448} 449 450function CP_updateProgressMessage(msg){ 451 $("#CP_ProgressMsg span").html(msg); 452} 453function inlineMessage(msg, type, noDismiss){ 454 if (!type){ 455 type = "danger"; 456 } 457 if (noDismiss){ 458 var messageOut = '<div id="inlineMessage" class="row"' + '>' + '<' + 'div class="col-md-12"' + '>' + '<' + 'div class="alert alert-' + type + '"' + '>' + msg + '<' + '/div' + '>' + '<' + '/div' + '>' + '<' + '/div' + '>'; 459 } else { 460 var messageOut = '<div id="inlineMessage" class="row"' + '>' + '<' + 'div class="col-md-12"' + '>' + '<' + 'div class="alert alert-' + type + ' alert-dismissable"' + '>' + '<' + 'button type="button" class="close" data-dismiss="alert" aria-hidden="true"' + '>' + '×' + '<' + '/button' + '>' + msg + '<' + '/div' + '>' + '<' + '/div' + '>' + '<' + '/div' + '>'; 461 } 462 if (document.getElementById("inlineMessage") && (!noDismiss || noDismiss !== "replace")){ 463 $("#inlineMessage .alert").append("<br/>" + msg); 464 } else if (noDismiss === "replace") { 465 $("#inlineMessage .alert").html(msg); 466 } else { 467 $("#page-wrapper").prepend(messageOut); 468 } 469}
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.