PageSourceSearch

https://www.munturkey.com/wp-content/plugins/buddypress-media/app/assets/admin/js/vendors/tabs.js

js munturkey.com collected 2026-10-02 00:19:54 UTC 3,195 bytes, 129 lines download raw bytes

1// Written by S@G@R
2
3/* Utility : Object.create dosen't work all browsers. */
4if ( typeof Object.create !== 'function' ) {
5	Object.create = function ( obj ) {
6		function F() {
7		}
8		;
9		F.prototype = obj;
10		return new F();
11	};
12}
13
14( function ( $, window, document, undefined ) {
15
16	var Tab = {
17		init: function ( options, elem ) {
18			var self = this;
19			self.elem = elem;
20			self.$elem = $( elem );
21
22			/* Extend Options */
23			self.options = $.extend( { }, $.fn.rtTab.options, options );
24
25			self.rtTabs();
26		},
27		rtTabs: function () {
28			var self = this,
29					showTab = self.options.activeTab;
30
31			/* Tab Active */
32			self.$elem.find( 'li:nth-child(' + showTab + ')' ).addClass( 'active' );
33			self.rtTabContent( activeTabContent = 'yes' );
34			self.rtClick();
35
36			// Datahash Variable
37			var datahash = ( self.$elem.attr( 'data-hash' ) === 'false' ) ? false : true;
38
39			/* This will keep on same tab as in hashtag */
40			if ( datahash === true ) {
41				var hashTag = window.location.hash;
42
43				if ( hashTag ) {
44					self.$elem.find( 'li' ).find( 'a[href="' + hashTag + '"]' ).trigger( 'click' );
45				}
46
47				// Detect change in hash value of URL
48				$( window ).on( 'hashchange', function () {
49					var hashTag = window.location.hash;
50					// Iterate over all nav links, setting the "selected" class as-appropriate.
51					self.$elem.find( 'li' ).find( 'a[href="' + hashTag + '"]' ).trigger( 'click' );
52				} );
53			}
54
55		},
56		rtClick: function () {
57			var self = this,
58					eachTab = self.$elem.find( 'li' ),
59					tabLink = eachTab.find( 'a' );
60
61			tabLink.on( 'click', function ( e ) {
62				/* Prevent */
63				e.preventDefault();
64
65				/* Remove Active Class From All Tabs */
66				eachTab.removeClass( 'active' );
67
68				/* Hide All Tab Contents */
69				self.rtTabContent();
70
71				/* Add Active Class to Current Tab */
72				$( this ).parent().addClass( 'active' );
73
74				/* Show Active Tab Content */
75				var activeTab = $( this ).attr( 'href' );
76				$( activeTab ).removeClass( 'hide' );
77
78				// Datahash Variable
79				var datahash = ( self.$elem.attr( 'data-hash' ) === 'false' ) ? false : true;
80
81				/* Hash tag in URL */
82				if ( datahash === true ) {
83					var pos = $( window ).scrollTop();
84					location.hash = $( this ).attr( 'href' );
85					$( window ).scrollTop( pos );
86				}
87
88				/* On complete function */
89				if ( typeof self.options.onComplete === 'function' ) {
90					self.options.onComplete.apply( self.elem, arguments );
91				}
92
93			} );
94		},
95		rtTabContent: function ( activeTabContent ) {
96			var self = this,
97					eachTab = self.$elem.find( 'li' ),
98					tabLink = eachTab.find( 'a' );
99
100			tabLink.each( function () {
101				var link = $( this ),
102						tabContent = link.attr( 'href' );
103				if ( activeTabContent === 'yes' ) {
104					if ( ! link.parent().hasClass( 'active' ) ) {
105						$( tabContent ).addClass( 'hide' );
106					}
107				} else {
108					$( tabContent ).addClass( 'hide' );
109				}
110			} );
111		}
112	};
113
114	$.fn.rtTab = function ( options ) {
115		return this.each( function () {
116			var tab = Object.create( Tab );
117			tab.init( options, this );
118
119			/* Store Data */
120			$.data( this, 'rtTab', tab );
121		} );
122	};
123
124	$.fn.rtTab.options = {
125		activeTab: 1,
126		onComplete: null
127	};
128
129} )( jQuery, window, document );

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.