| 1 |
jQuery(document).ready( function($) { |
| 2 |
function createPointer(id,pointer){ |
| 3 |
var $point, |
| 4 |
content=pointer[0], arrow=pointer[1], |
| 5 |
valign=pointer[2],selector=pointer[3]; |
| 6 |
switch(id){ |
| 7 |
case 'update_forms_pointer': |
| 8 |
$point = $('tbody#the-list tr .cf7-form-key[data-update="cf7sg-update"]'); |
| 9 |
if($point){ |
| 10 |
$point = $point.first().closest('tr').find('a.row-title'); |
| 11 |
}else return null; |
| 12 |
break; |
| 13 |
case 'cf7sg_shortcodes': |
| 14 |
$point = $('tbody#the-list tr .cf7-2-post-shortcode').first(); |
| 15 |
break; |
| 16 |
default: |
| 17 |
$point = $(selector); |
| 18 |
break; |
| 19 |
} |
| 20 |
var pointer = $point.pointer({ |
| 21 |
content: content, |
| 22 |
position:{edge: arrow, align: valign}, |
| 23 |
pointerWidth: 350, |
| 24 |
close:function() {$.post( ajaxurl, {pointer: id, action: 'dismiss-wp-pointer'});} |
| 25 |
}).pointer('open'); |
| 26 |
$('.wp-pointer-content .cf7sg-pointer').parent().find('a.close').after('<a href="#" data-id="'+id+'" class="button-primary cf7sg-next">'+cf7sg_pointers.next+'</a>'); |
| 27 |
return pointer; |
| 28 |
} |
| 29 |
var pobj, pids, id, pidx, pointers = cf7sg_pointers.pointers; |
| 30 |
pids = Object.keys(pointers); |
| 31 |
if(pids.length>0){ |
| 32 |
pidx=0; |
| 33 |
id = pids[pidx]; |
| 34 |
pobj=createPointer(id, pointers[id]); |
| 35 |
if(!pobj && pidx<pids.length){ //try the next one. |
| 36 |
pidx++; |
| 37 |
id = pids[pidx]; |
| 38 |
pobj=createPointer(id, pointers[id]); |
| 39 |
} |
| 40 |
$('body').on('click', 'a.cf7sg-next', function(e){ |
| 41 |
// var $pointer = $(e.target); |
| 42 |
pobj.pointer('close'); |
| 43 |
if(pidx<pids.length){ |
| 44 |
pidx++; |
| 45 |
id = pids[pidx]; |
| 46 |
pobj=createPointer( id, pointers[id]); |
| 47 |
pobj.pointer('open'); |
| 48 |
} |
| 49 |
}); |
| 50 |
} |
| 51 |
|
| 52 |
}); |
| 53 |
|