1/** 2 * smartPopup 3 * -------- 4 * 5 * author: Andrei Dinca & Alexandra Ipate 6 * _ _ _____ _ 7 * /\ | | (_) | __ \(_) 8 * / \ _ __ __| |_ __ ___ _ | | | |_ _ __ ___ __ _ 9 * / /\ \ | '_ \ / _` | '__/ _ \ | | | | | | '_ \ / __/ _` | 10 * / ____ \| | | | (_| | | | __/ | | |__| | | | | | (_| (_| | 11 * /_/ \_\_| |_|\__,_|_| \___|_| |_____/|_|_| |_|\___\__,_| 12 * 13 * email: [email protected] 14 * 15 * version 1.0 release date: 05 01 2011 16 * 17**/ 18 19 //pass the options variable to the function 20var smartPopup = function(options) { 21 //Set the default values 22 var defaults = { 23 'fadeBox' : 'div#smartPopupfade', 24 'fadeOpacity' : 0.7, 25 'fadeBackground' : 'wp-content/plugins/feedback/frontpage/images/bg-transparent.png', 26 'fadeOutTime' : 200, 27 'fadeInTime' : 300, 28 'closeBtn' : 'a.smartPopup-close', 29 'boxWidth' : '800', 30 'boxHeight' : '600', 31 'showOn' : 'open' 32 }; 33 34 // extends options object 35 options = jQuery.extend(defaults, options); 36 37 // self define parent class 38 var self = this; 39 40 // prevent collisions 41 var running = false; 42 43 jQuery("div.smartPopup").each(function() { 44 var opts = options; 45 46 // cache jQuery(this) object 47 var $this = jQuery(this); 48 49 if( !$this.hasClass('smartPopupSlide') ) { 50 // event close 51 jQuery('body').on('click', options.closeBtn, function(){ 52 closeFeedback(); 53 return false; 54 }); 55 } 56 57 58 if(options.showOn == 'open'){ 59 // open feedback box 60 openFeedback(); 61 }else{ 62 jQuery(window).bind("beforeunload", function(){ 63 // open feedback box 64 openFeedback(); 65 return false; 66 }); 67 } 68 // open feedback box 69 function openFeedback(){ 70 71 if( !$this.hasClass('smartPopupSlide') ) { 72 // count down 73 jQuery("body").append('<div id="pietimerholder">Auto Close<br /></div>'); 74 canvasPieTimer.init(50, "canvaspietimer", "pietimerholder"); 75 } 76 77 // till close 78 jQuery(options.fadeBox).css('display', 'none'); 79 80 // extra width and height + 30 (padding) 81 if( $this.hasClass('smartPopupSlide') ) { 82 83 $this.css({ 84 width: options.boxWidth + 'px', 85 height: options.boxHeight + 'px', 86 display: 'none' 87 }); 88 89 }else{ 90 91 $this.css({ 92 width: options.boxWidth + 'px', 93 height: options.boxHeight + 'px', 94 display: 'none', 95 // align to center 96 marginTop: "-" + (parseInt(options.boxHeight) + 30) / 2 + "px", 97 marginLeft: "-" + (parseInt(options.boxWidth) + 30) / 2 + "px" 98 }); 99 100 } 101 102 // set fade opacity 103 jQuery(options.fadeBox).css({ 104 opacity : options.fadeOpacity, 105 background: 'url(' + options.fadeBackground + ')' 106 }); 107 108 // open it 109 jQuery(options.fadeBox).fadeIn(options.fadeInTime); 110 $this.fadeIn(options.fadeInTime); 111 } 112 113 // close feedback box 114 function closeFeedback(){ 115 jQuery(options.fadeBox).fadeOut(options.fadeOutTime); 116 $this.fadeOut(options.fadeOutTime); 117 jQuery("div#pietimerholder").fadeOut(options.fadeOutTime); 118 } 119 120 var $ = jQuery; 121 122 if( $this.hasClass('smartPopupSlide') ) { 123 124 $('body').on('click', options.closeBtn, function(e){ 125 e.preventDefault(); 126 127 $this.css("margin-left", "-425px"); 128 $('#smartPopupPlus').css("margin-left", "10px"); 129 130 return false; 131 }); 132 133 $(document).scroll(function() { 134 var scroll = $(this).scrollTop(); 135 if (scroll >= 150) { 136 $this.css("margin-left", "-425px"); 137 $('#smartPopupPlus').css("margin-left", "10px"); 138 } 139 }); 140 141 $('body').on('click', '#smartPopupPlus', function() { 142 $this.css("margin-left", "30px"); 143 $('#smartPopupPlus').css("margin-left", "-425px"); 144 }); 145 146 $this.on('click', ".smartPopup-close", function() { 147 $this.css("margin-left", "-425px"); 148 $('#smartPopupPlus').css("margin-left", "10px"); 149 }); 150 151 } 152 153 }); 154}
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.