-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjquery.sectionnavigator.js
More file actions
65 lines (53 loc) · 2.31 KB
/
jquery.sectionnavigator.js
File metadata and controls
65 lines (53 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* jQuery Multi-Step Section Plugin v1.0
* @author Michael Peacock
* @url www.michaelpeacock.co.uk
* @modified_by Zach Morek
* @m_url www.zachbeta.com
*/
(function($) {
$.fn.sectionnavigator = function( settings ) {
var config = {'nextclass' : 'next', 'prevclass' : 'prev', 'master_nav_heading' : 'h2' };
var masterReference = $(this).attr('id');
if (settings) $.extend(config, settings);
//put in top bar nav
$(this).parent().prepend('<div id="' + masterReference + '_navigator" style="display:none"></div>');
//create numbered links
$(this).children().each( function(index){
if($('#' + masterReference + '_navigator').html() != ""){
$('#' + masterReference + '_navigator').append(' | ');
}
$('#' + masterReference + '_navigator').append('<a stylehref="#" class="mnav_link" rel="sn_section_' + masterReference + '_' + index + '">' + (index+1) + '</a>');
});
//put in next and prev buttons
$(this).children().each( function(index){
$(this).attr('id','sn_section_' + masterReference + '_' + index );
$(this).prepend('<div class="' + masterReference + '_navigation" style="min-height:26px;"><input type="button" value="Previous" class="prev" />'+ $('#' + masterReference + '_navigator').html() +' <input type="button" value="Next" class="next" style="float:right;" /></div>');
});
$('.mnav_link').live( 'click', function(){
$('#' + masterReference ).children().hide();
$( '#' + $(this).attr('rel') ).show();
return false;
});
$('#' + masterReference + '_preview').live( 'click', function(){
$('#' + masterReference).children().show();
$('.' + masterReference + '_navigation').hide();
$('#' + masterReference + '_navigator').hide();
$(this).hide();
return false;
});
$(this).children().hide();
$(this).children().first().show();
$( ' .section:first .' + config.prevclass, this ).hide();
$( ' .section:last .' + config.nextclass , this ).hide();
$('.' + config.nextclass ).live( 'click', function(){
$(this).parent().parent().hide().next().show();
return false;
} );
$('.' + config.prevclass ).live( 'click', function(){
$(this).parent().parent().hide().prev().show();
return false;
} );
return this;
};
})(jQuery);