1(function(root, factory) { 2 if (typeof define === 'function' && define.amd) { 3 define(['jquery'], factory); 4 } else { 5 factory(root.jQuery); 6 } 7}(this, function($) { 8 "use strict"; 9 10 /** 11 * Class constructor 12 * @param message String/Object - String of html or Object of states 13 * @param options Object - Options to set the prompt 14 * @return jQuery - container with overlay and prompt 15 */ 16 var imp = function(message, options) { 17 // only for backwards compat, to be removed in future version 18 if(options !== undefined && options.classes !== undefined && typeof options.classes === 'string'){ 19 options = { box: options.classes }; 20 } 21 22 imp.options = $.extend({},imp.defaults,options); 23 imp.currentPrefix = imp.options.prefix; 24 25 // Be sure any previous timeouts are destroyed 26 if(imp.timeout){ 27 clearTimeout(imp.timeout); 28 } 29 imp.timeout = false; 30 31 var opts = imp.options, 32 $body = $(document.body), 33 $window = $(window); 34 35 //build the box and fade 36 var msgbox = '<div class="'+ imp.options.prefix +'box '+ opts.classes.box +'">'; 37 if(opts.useiframe && ($('object, applet').length > 0)) { 38 msgbox += '<iframe src="javascript:false;" style="display:block;position:absolute;z-index:-1;" class="'+ opts.prefix +'fade '+ opts.classes.fade +'"></iframe>'; 39 } else { 40 msgbox +='<div class="'+ opts.prefix +'fade '+ opts.classes.fade +'"></div>'; 41 } 42 msgbox += '<div class="'+ opts.prefix +' '+ opts.classes.prompt +'">'+ 43 '<form action="javascript:false;" onsubmit="return false;" class="'+ opts.prefix +'form '+ opts.classes.form +'">'+ 44 '<div class="'+ opts.prefix +'close '+ opts.classes.close +'">'+ opts.closeText +'</div>'+ 45 '<div class="'+ opts.prefix +'states"></div>'+ 46 '</form>'+ 47 '</div>'+ 48 '</div>'; 49 50 imp.jqib = $(msgbox).appendTo($body); 51 imp.jqi = imp.jqib.children('.'+ opts.prefix);//.data('jqi',opts); 52 imp.jqif = imp.jqib.children('.'+ opts.prefix +'fade'); 53 54 //if a string was passed, convert to a single state 55 if(message.constructor === String){ 56 message = { 57 state0: { 58 title: opts.title, 59 html: message, 60 buttons: opts.buttons, 61 position: opts.position, 62 focus: opts.focus, 63 defaultButton: opts.defaultButton, 64 submit: opts.submit 65 } 66 }; 67 } 68 69 //build the states 70 imp.options.states = {}; 71 var k,v; 72 for(k in message){ 73 v = $.extend({},imp.defaults.state,{name:k},message[k]); 74 imp.addState(v.name, v); 75 76 if(imp.currentStateName === ''){ 77 imp.currentStateName = v.name; 78 } 79 } 80 81 //Events 82 imp.jqi.on('click', '.'+ opts.prefix +'buttons button', function(e){ 83 var $t = $(this), 84 $state = $t.parents('.'+ opts.prefix +'state'), 85 stateobj = imp.options.states[$state.data('jqi-name')], 86 msg = $state.children('.'+ opts.prefix +'message'), 87 clicked = stateobj.buttons[$t.text()] || stateobj.buttons[$t.html()], 88 forminputs = {}; 89 90 // if for some reason we couldn't get the value 91 if(clicked === undefined){ 92 for(var i in stateobj.buttons){ 93 if(stateobj.buttons[i].title === $t.text() || stateobj.buttons[i].title === $t.html()){ 94 clicked = stateobj.buttons[i].value; 95 } 96 } 97 } 98 99 //collect all form element values from all states. 100 $.each(imp.jqi.children('form').serializeArray(),function(i,obj){ 101 if (forminputs[obj.name] === undefined) { 102 forminputs[obj.name] = obj.value; 103 } else if (typeof forminputs[obj.name] === Array || typeof forminputs[obj.name] === 'object') { 104 forminputs[obj.name].push(obj.value); 105 } else { 106 forminputs[obj.name] = [forminputs[obj.name],obj.value]; 107 } 108 }); 109 110 // trigger an event 111 var promptsubmite = new $.Event('impromptu:submit'); 112 promptsubmite.stateName = stateobj.name; 113 promptsubmite.state = $state; 114 $state.trigger(promptsubmite, [clicked, msg, forminputs]); 115 116 if(!promptsubmite.isDefaultPrevented()){ 117 imp.close(true, clicked,msg,forminputs); 118 } 119 }); 120 121 // if the fade is clicked blink the prompt 122 var fadeClicked = function(){ 123 if(opts.persistent){ 124 var offset = (opts.top.toString().indexOf('%') >= 0? ($window.height()*(parseInt(opts.top,10)/100)) : parseInt(opts.top,10)), 125 top = parseInt(imp.jqi.css('top').replace('px',''),10) - offset; 126 127 //$window.scrollTop(top); 128 $('html,body').animate({ scrollTop: top }, 'fast', function(){ 129 var i = 0; 130 imp.jqib.addClass(opts.prefix +'warning'); 131 var intervalid = setInterval(function(){ 132 imp.jqib.toggleClass(opts.prefix +'warning'); 133 if(i++ > 1){ 134 clearInterval(intervalid); 135 imp.jqib.removeClass(opts.prefix +'warning'); 136 } 137 }, 100); 138 }); 139 } 140 else { 141 imp.close(true); 142 } 143 }; 144 145 // listen for esc or tab keys 146 var keyDownEventHandler = function(e){
147 var key = (window.event) ? event.keyCode : e.keyCode; 148 149 //escape key closes 150 if(key === 27) { 151 fadeClicked(); 152 } 153 154 //enter key pressed trigger the default button if its not on it, ignore if it is a textarea 155 if(key === 13){ 156 var $defBtn = imp.getCurrentState().find('.'+ opts.prefix +'defaultbutton'); 157 var $tgt = $(e.target); 158 159 if($tgt.is('textarea,.'+opts.prefix+'button') === false && $defBtn.length > 0){ 160 e.preventDefault(); 161 $defBtn.click(); 162 } 163 } 164 165 //constrain tabs, tabs should iterate through the state and not leave 166 if (key === 9){ 167 var $inputels = $('input,select,textarea,button',imp.getCurrentState()); 168 var fwd = !e.shiftKey && e.target === $inputels[$inputels.length-1]; 169 var back = e.shiftKey && e.target === $inputels[0]; 170 if (fwd || back) { 171 setTimeout(function(){ 172 if (!$inputels){ 173 return; 174 } 175 var el = $inputels[back===true ? $inputels.length-1 : 0]; 176 177 if (el){ 178 el.focus(); 179 } 180 },10); 181 return false; 182 } 183 } 184 }; 185 186 imp.position(); 187 imp.style(); 188 189 imp.jqif.click(fadeClicked); 190 $window.resize({animate:false}, imp.position); 191 imp.jqi.find('.'+ opts.prefix +'close').click(imp.close); 192 imp.jqib.on("keydown",keyDownEventHandler) 193 .on('impromptu:loaded', opts.loaded) 194 .on('impromptu:close', opts.close) 195 .on('impromptu:statechanging', opts.statechanging) 196 .on('impromptu:statechanged', opts.statechanged); 197 198 // Show it 199 imp.jqif[opts.show](opts.overlayspeed); 200 imp.jqi[opts.show](opts.promptspeed, function(){ 201 202 var $firstState = imp.jqi.find('.'+ opts.prefix +'states .'+ opts.prefix +'state').eq(0); 203 imp.goToState($firstState.data('jqi-name')); 204 205 imp.jqib.trigger('impromptu:loaded'); 206 }); 207 208 // Timeout 209 if(opts.timeout > 0){ 210 imp.timeout = setTimeout(function(){ imp.close(true); },opts.timeout); 211 } 212 213 return imp.jqib; 214 }; 215 216 imp.defaults = { 217 prefix:'jqi', 218 classes: { 219 box: '', 220 fade: '', 221 prompt: '', 222 form: '', 223 close: '', 224 title: '', 225 message: '', 226 buttons: '', 227 button: '', 228 defaultButton: '' 229 }, 230 title: '', 231 closeText: '×', 232 buttons: { 233 Ok: true 234 }, 235 loaded: function(e){}, 236 submit: function(e,v,m,f){}, 237 close: function(e,v,m,f){}, 238 statechanging: function(e, from, to){}, 239 statechanged: function(e, to){}, 240 opacity: 0.6, 241 zIndex: 999, 242 overlayspeed: 'slow', 243 promptspeed: 'fast', 244 instantShow: false, 245 show: 'fadeIn', 246 focus: 0, 247 defaultButton: 0, 248 useiframe: false, 249 top: '15%', 250 position: { 251 container: null, 252 x: null, 253 y: null, 254 arrow: null, 255 width: null 256 }, 257 persistent: true, 258 timeout: 0, 259 states: {}, 260 state: { 261 name: null, 262 title: '', 263 html: '', 264 buttons: { 265 Ok: true 266 }, 267 focus: 0, 268 defaultButton: 0, 269 position: { 270 container: null, 271 x: null, 272 y: null, 273 arrow: null, 274 width: null 275 }, 276 submit: function(e,v,m,f){ 277 return true; 278 } 279 } 280 }; 281 282 /** 283 * currentPrefix String - At any time this show be the prefix 284 * of the current prompt ex: "jqi" 285 */ 286 imp.currentPrefix = imp.defaults.prefix; 287 288 /** 289 * currentStateName String - At any time this is the current state 290 * of the current prompt ex: "state0" 291 */ 292 imp.currentStateName = ""; 293 294 /** 295 * setDefaults - Sets the default options 296 * @param o Object - Options to set as defaults 297 * @return void 298 */ 299 imp.setDefaults = function(o) { 300 imp.defaults = $.extend({}, imp.defaults, o); 301 }; 302 303 /** 304 * setStateDefaults - Sets the default options for a state 305 * @param o Object - Options to set as defaults 306 * @return void 307 */ 308 imp.setStateDefaults = function(o) { 309 imp.defaults.state = $.extend({}, imp.defaults.state, o); 310 }; 311 312 /** 313 * position - Repositions the prompt (Used internally) 314 * @return void 315 */ 316 imp.position = function(e){ 317 var restoreFx = $.fx.off, 318 $state = imp.getCurrentState(), 319 stateObj = imp.options.states[$state.data('jqi-name')], 320 pos = stateObj? stateObj.position : undefined, 321 $window = $(window), 322 bodyHeight = document.body.scrollHeight, //$(document.body).outerHeight(true), 323 windowHeight = $(window).height(), 324 documentHeight = $(document).height(), 325 height = bodyHeight > windowHeight ? bodyHeight : windowHeight, 326 top = parseInt($window.scrollTop(),10) + (imp.options.top.toString().indexOf('%') >= 0? 327 (windowHeight*(parseInt(imp.options.top,10)/100)) : parseInt(imp.options.top,10)); 328 329 // when resizing the window turn off animation 330 if(e !== undefined && e.data.animate === false){ 331 $.fx.off = true; 332 } 333 334 imp.jqib.css({ 335 position: "absolute",
336 height: height, 337 width: "100%", 338 top: 0, 339 left: 0, 340 right: 0, 341 bottom: 0 342 }); 343 imp.jqif.css({ 344 position: "fixed", 345 height: height, 346 width: "100%", 347 top: 0, 348 left: 0, 349 right: 0, 350 bottom: 0 351 }); 352 353 // tour positioning 354 if(pos && pos.container){ 355 var offset = $(pos.container).offset(); 356 357 if($.isPlainObject(offset) && offset.top !== undefined){ 358 imp.jqi.css({ 359 position: "absolute" 360 }); 361 imp.jqi.animate({ 362 top: offset.top + pos.y, 363 left: offset.left + pos.x, 364 marginLeft: 0, 365 width: (pos.width !== undefined)? pos.width : null 366 }); 367 top = (offset.top + pos.y) - (imp.options.top.toString().indexOf('%') >= 0? (windowHeight*(parseInt(imp.options.top,10)/100)) : parseInt(imp.options.top,10)); 368 $('html,body').animate({ scrollTop: top }, 'slow', 'swing', function(){}); 369 } 370 } 371 // custom state width animation 372 else if(pos && pos.width){ 373 imp.jqi.css({ 374 position: "absolute", 375 left: '50%' 376 }); 377 imp.jqi.animate({ 378 top: pos.y || top, 379 left: pos.x || '50%', 380 marginLeft: ((pos.width/2)*-1), 381 width: pos.width 382 }); 383 } 384 // standard prompt positioning 385 else{ 386 imp.jqi.css({ 387 position: "absolute", 388 top: top, 389 left: '50%',//$window.width()/2, 390 marginLeft: ((imp.jqi.outerWidth(false)/2)*-1) 391 }); 392 } 393 394 // restore fx settings 395 if(e !== undefined && e.data.animate === false){ 396 $.fx.off = restoreFx; 397 } 398 }; 399 400 /** 401 * style - Restyles the prompt (Used internally) 402 * @return void 403 */ 404 imp.style = function(){ 405 imp.jqif.css({ 406 zIndex: imp.options.zIndex, 407 display: "none", 408 opacity: imp.options.opacity 409 }); 410 imp.jqi.css({ 411 zIndex: imp.options.zIndex+1, 412 display: "none" 413 }); 414 imp.jqib.css({ 415 zIndex: imp.options.zIndex 416 }); 417 }; 418 419 /** 420 * get - Get the prompt 421 * @return jQuery - the prompt 422 */ 423 imp.get = function(state) { 424 return $('.'+ imp.currentPrefix); 425 }; 426 427 /** 428 * addState - Injects a state into the prompt 429 * @param statename String - Name of the state 430 * @param stateobj Object - options for the state 431 * @param afterState String - selector of the state to insert after 432 * @return jQuery - the newly created state 433 */ 434 imp.addState = function(statename, stateobj, afterState) { 435 var state = "", 436 $state = null, 437 arrow = "", 438 title = "", 439 opts = imp.options, 440 $jqistates = $('.'+ imp.currentPrefix +'states'), 441 buttons = [], 442 showHtml,defbtn,k,v,l,i=0; 443 444 stateobj = $.extend({},imp.defaults.state, {name:statename}, stateobj); 445 446 if(stateobj.position.arrow !== null){ 447 arrow = '<div class="'+ opts.prefix + 'arrow '+ opts.prefix + 'arrow'+ stateobj.position.arrow +'"></div>'; 448 } 449 if(stateobj.title && stateobj.title !== ''){ 450 title = '<div class="lead '+ opts.prefix + 'title '+ opts.classes.title +'">'+ stateobj.title +'</div>'; 451 } 452 453 showHtml = stateobj.html; 454 if (typeof stateobj.html === 'function') { 455 showHtml = 'Error: html function must return text'; 456 } 457 458 state += '<div id="'+ opts.prefix +'state_'+ statename +'" class="'+ opts.prefix + 'state" data-jqi-name="'+ statename +'" style="display:none;">'+ 459 arrow + title + 460 '<div class="'+ opts.prefix +'message '+ opts.classes.message +'">' + showHtml +'</div>'+ 461 '<div class="'+ opts.prefix +'buttons '+ opts.classes.buttons +'"'+ ($.isEmptyObject(stateobj.buttons)? 'style="display:none;"':'') +'>'; 462 463 // state buttons may be in object or array, lets convert objects to arrays 464 if($.isArray(stateobj.buttons)){ 465 buttons = stateobj.buttons; 466 } 467 else if($.isPlainObject(stateobj.buttons)){ 468 for(k in stateobj.buttons){ 469 if(stateobj.buttons.hasOwnProperty(k)){ 470 buttons.push({ title: k, value: stateobj.buttons[k] }); 471 } 472 } 473 } 474 475 // iterate over each button and create them 476 for(i=0, l=buttons.length; i<l; i++){ 477 v = buttons[i], 478 defbtn = stateobj.focus === i || (isNaN(stateobj.focus) && stateobj.defaultButton === i) ? (imp.currentPrefix + 'defaultbutton ' + opts.classes.defaultButton) : ''; 479 480 state += '<button class="'+ opts.classes.button +' '+ imp.currentPrefix + 'button '+ defbtn; 481 482 if(typeof v.classes !== "undefined"){ 483 state += ' '+ ($.isArray(v.classes)? v.classes.join(' ') : v.classes) + ' '; 484 } 485 486 state += '" name="' + opts.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" id="' + opts.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" value="' + v.value + '">' + v.title + '</button>'; 487 } 488 489 state += '</div></div>'; 490 491 $state = $(state); 492 493 $state.on('impromptu:submit', stateobj.submit); 494 495 if(afterState !== undefined){ 496 $jqistates.find('#'+ imp.currentPrefix +'state_'+ afterState).after($state); 497 } 498 else{ 499 $jqistates.append($state); 500 } 501 502 imp.options.states[statename] = stateobj; 503 504 return $state; 505 }; 506 507 /** 508 * removeState - Removes a state from the prompt 509 * @param state String - Name of the state 510 * @param newState String - Name of the state to transition to 511 * @return Boolean - returns true on success, false on failure 512 */ 513 imp.removeState = function(state, newState) { 514 var $state = imp.getState(state), 515 rm = function(){ $state.remove(); }; 516 517 if($state.length === 0){ 518 return false; 519 } 520 521 // transition away from it before deleting 522 if($state.css('display') !== 'none'){ 523 if(newState !== undefined && imp.getState(newState).length > 0){ 524 imp.goToState(newState, false, rm); 525 } 526 else if($state.next().length > 0){ 527 imp.nextState(rm); 528 } 529 else if($state.prev().length > 0){ 530 imp.prevState(rm); 531 } 532 else{ 533 imp.close(); 534 } 535 } 536 else{ 537 $state.slideUp('slow', rm); 538 } 539 540 return true; 541 }; 542 543 /** 544 * getState - Get the state by its name 545 * @param state String - Name of the state 546 * @return jQuery - the state 547 */ 548 imp.getState = function(state) { 549 return $('#'+ imp.currentPrefix +'state_'+ state); 550 }; 551 imp.getStateContent = function(state) { 552 return imp.getState(state); 553 }; 554 555 /** 556 * getCurrentState - Get the current visible state 557 * @return jQuery - the current visible state 558 */ 559 imp.getCurrentState = function() { 560 return imp.getState(imp.getCurrentStateName()); 561 }; 562 563 /** 564 * getCurrentStateName - Get the name of the current visible state
565 * @return String - the current visible state's name 566 */ 567 imp.getCurrentStateName = function() { 568 return imp.currentStateName; 569 }; 570 571 /** 572 * goToState - Goto the specified state 573 * @param state String - name of the state to transition to 574 * @param subState Boolean - true to be a sub state within the currently open state 575 * @param callback Function - called when the transition is complete 576 * @return jQuery - the newly active state 577 */ 578 imp.goToState = function(state, subState, callback) { 579 var $jqi = imp.get(), 580 jqiopts = imp.options, 581 $state = imp.getState(state), 582 stateobj = jqiopts.states[$state.data('jqi-name')], 583 promptstatechanginge = new $.Event('impromptu:statechanging'), 584 opts = imp.options; 585 586 if(stateobj !== undefined){ 587 588 589 if (typeof stateobj.html === 'function') { 590 var contentLaterFunc = stateobj.html; 591 $state.find('.' + opts.prefix +'message ').html(contentLaterFunc()); 592 } 593 594 // subState can be ommitted 595 if(typeof subState === 'function'){ 596 callback = subState; 597 subState = false; 598 } 599 600 imp.jqib.trigger(promptstatechanginge, [imp.getCurrentStateName(), state]); 601 602 if(!promptstatechanginge.isDefaultPrevented() && $state.length > 0){ 603 imp.jqi.find('.'+ imp.currentPrefix +'parentstate').removeClass(imp.currentPrefix +'parentstate'); 604 605 if(subState){ // hide any open substates 606 // get rid of any substates 607 imp.jqi.find('.'+ imp.currentPrefix +'substate').not($state) 608 .slideUp(jqiopts.promptspeed) 609 .removeClass('.'+ imp.currentPrefix +'substate') 610 .find('.'+ imp.currentPrefix +'arrow').hide(); 611 612 // add parent state class so it can be visible, but blocked 613 imp.jqi.find('.'+ imp.currentPrefix +'state:visible').addClass(imp.currentPrefix +'parentstate'); 614 615 // add substate class so we know it will be smaller 616 $state.addClass(imp.currentPrefix +'substate'); 617 } 618 else{ // hide any open states 619 imp.jqi.find('.'+ imp.currentPrefix +'state').not($state) 620 .slideUp(jqiopts.promptspeed) 621 .find('.'+ imp.currentPrefix +'arrow').hide(); 622 } 623 imp.currentStateName = stateobj.name; 624 625 $state.slideDown(jqiopts.promptspeed,function(){ 626 627 var $t = $(this); 628 629 // if focus is a selector, find it, else its button index 630 if(typeof(stateobj.focus) === 'string'){ 631 $t.find(stateobj.focus).eq(0).focus(); 632 } 633 else{ 634 $t.find('.'+ imp.currentPrefix +'defaultbutton').focus(); 635 } 636 637 $t.find('.'+ imp.currentPrefix +'arrow').show(jqiopts.promptspeed); 638 639 if (typeof callback === 'function'){ 640 imp.jqib.on('impromptu:statechanged', callback); 641 } 642 imp.jqib.trigger('impromptu:statechanged', [state]); 643 if (typeof callback === 'function'){ 644 imp.jqib.off('impromptu:statechanged', callback); 645 } 646 }); 647 648 if( jqiopts.instantShow ) { 649 $state.show(); 650 console.log("5"); 651 var $t = $state; 652 653 // if focus is a selector, find it, else its button index 654 if(typeof(stateobj.focus) === 'string'){ 655 $t.find(stateobj.focus).eq(0).focus(); 656 } 657 else{ 658 $t.find('.'+ imp.currentPrefix +'defaultbutton').focus(); 659 } 660 661 $t.find('.'+ imp.currentPrefix +'arrow').show(jqiopts.promptspeed); 662 663 if (typeof callback === 'function'){ 664 imp.jqib.on('impromptu:statechanged', callback); 665 } 666 imp.jqib.trigger('impromptu:statechanged', [state]); 667 if (typeof callback === 'function'){ 668 imp.jqib.off('impromptu:statechanged', callback); 669 } 670 671 $t.find('.background').css({ height: '220px' }); 672 673 } else { 674 675 $state.slideDown(jqiopts.promptspeed,function(){ 676 677 var $t = $(this); 678 679 // if focus is a selector, find it, else its button index 680 if(typeof(stateobj.focus) === 'string'){ 681 $t.find(stateobj.focus).eq(0).focus(); 682 } 683 else{ 684 $t.find('.'+ imp.currentPrefix +'defaultbutton').focus(); 685 } 686 687 $t.find('.'+ imp.currentPrefix +'arrow').show(jqiopts.promptspeed); 688 689 if (typeof callback === 'function'){ 690 imp.jqib.on('impromptu:statechanged', callback); 691 } 692 imp.jqib.trigger('impromptu:statechanged', [state]); 693 if (typeof callback === 'function'){ 694 imp.jqib.off('impromptu:statechanged', callback); 695 } 696 });
697 698 } 699 700 701 702 if(!subState){ 703 imp.position(); 704 } 705 } // end isDefaultPrevented() 706 }// end stateobj !== undefined 707 708 return $state; 709 }; 710 711 /** 712 * nextState - Transition to the next state 713 * @param callback Function - called when the transition is complete 714 * @return jQuery - the newly active state 715 */ 716 imp.nextState = function(callback) { 717 var $next = $('#'+ imp.currentPrefix +'state_'+ imp.getCurrentStateName()).next(); 718 if($next.length > 0){ 719 imp.goToState( $next.attr('id').replace(imp.currentPrefix +'state_',''), callback ); 720 } 721 return $next; 722 }; 723 724 /** 725 * prevState - Transition to the previous state 726 * @param callback Function - called when the transition is complete 727 * @return jQuery - the newly active state 728 */ 729 imp.prevState = function(callback) { 730 var $prev = $('#'+ imp.currentPrefix +'state_'+ imp.getCurrentStateName()).prev(); 731 if($prev.length > 0){ 732 imp.goToState( $prev.attr('id').replace(imp.currentPrefix +'state_',''), callback ); 733 } 734 return $prev; 735 }; 736 737 /** 738 * close - Closes the prompt 739 * @param callback Function - called when the transition is complete 740 * @param clicked String - value of the button clicked (only used internally) 741 * @param msg jQuery - The state message body (only used internally) 742 * @param forvals Object - key/value pairs of all form field names and values (only used internally) 743 * @return jQuery - the newly active state 744 */ 745 imp.close = function(callCallback, clicked, msg, formvals){ 746 if(imp.timeout){ 747 clearTimeout(imp.timeout); 748 imp.timeout = false; 749 } 750 751 if(imp.jqib){ 752 imp.jqib.fadeOut('fast',function(){ 753 754 imp.jqib.trigger('impromptu:close', [clicked,msg,formvals]); 755 756 imp.jqib.remove(); 757 758 $(window).off('resize',imp.position); 759 }); 760 } 761 imp.currentStateName = ""; 762 }; 763 764 /** 765 * Enable using $('.selector').prompt({}); 766 * This will grab the html within the prompt as the prompt message 767 */ 768 $.fn.prompt = function(options){ 769 if(options === undefined){ 770 options = {}; 771 } 772 if(options.withDataAndEvents === undefined){ 773 options.withDataAndEvents = false; 774 } 775 776 imp($(this).clone(options.withDataAndEvents).html(),options); 777 }; 778 779 $.prompt = imp; 780 window.Impromptu = imp; 781 782}));
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.