forked from olton/metroui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagecontrol.js
More file actions
41 lines (36 loc) · 1.17 KB
/
Copy pathpagecontrol.js
File metadata and controls
41 lines (36 loc) · 1.17 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
(function($){
$.fn.PageControl = function( options ){
var defaults = {
};
var $this = $(this)
, $ul = $this.children("ul")
, $selectors = $ul.find("li a")
, $selector = $ul.find(".active a")
, $frames = $this.find(".frames .frame")
, $frame = $frames.children(".frame.active")
;
var initSelectors = function(selectors){
selectors.on('click', function(e){
e.preventDefault();
var $a = $(this);
if ( $a.parent('li').hasClass('active') ) return false;
$frames.hide();
$ul.find("li").removeClass("active");
var target = $($a.attr("href"));
target.show();
$(this).parent("li").addClass("active");
});
}
return this.each(function(){
if ( options ) {
$.extend(defaults, options)
}
initSelectors($selectors);
});
}
$(function () {
$('[data-role="page-control"]').each(function () {
$(this).PageControl();
})
})
})(window.jQuery);