PageSourceSearch

https://senjaya.co.id/wp-content/themes/salient/js/sticky.js?ver=1.0

js senjaya.co.id collected 2026-10-05 06:24:12 UTC 5,565 bytes, 179 lines download raw bytes

1(function($) {
2
3  var $headerHeight = $('#header-outer').outerHeight() + 34;	
4  var $extraHeight = ($('#wpadminbar').length > 0) ? 28 : 0; //admin bar
5  var secondaryHeader = ($('#header-outer').attr('data-using-secondary') == '1') ? 33 : 0 ;
6  
7  $(window).load(function(){
8   	 $headerHeight = $('#header-outer').outerHeight() + 34;	
9     $extraHeight = ($('#wpadminbar').length > 0) ? 28 : 0; //admin bar
10  });
11 
12  $.fn.extend({
13    stickyMojo: function(options) {
14
15      var settings = $.extend({
16        'footerID': '',
17        'contentID': '',
18        'orientation': $(this).css('float')
19      }, options);
20
21      var sticky = {
22        'el': $(this),  
23        'stickyLeft': $(settings.contentID).outerWidth() + $(settings.contentID).offset.left,
24        'stickyTop2': $(this).offset().top,
25        'stickyHeight': $(this).outerHeight(true),
26        'contentHeight': $(settings.contentID).outerHeight(true),
27        'win': $(window),
28        'breakPoint': $(this).outerWidth(true) + $(settings.contentID).outerWidth(true),
29        'marg': parseInt($(this).css('margin-top'), 10)
30      };
31
32      var errors = checkSettings();
33      cacheElements();
34
35      return this.each(function() {
36        buildSticky();
37      });
38
39      function buildSticky() { 
40        if (!errors.length) {
41          sticky.el.css('left', sticky.stickyLeft);
42
43          sticky.win.bind({
44            'scroll': stick,
45            'resize': function() {
46              sticky.el.css('left', sticky.stickyLeft);
47              sticky.contentHeight = $(settings.contentID).outerHeight(true);
48              sticky.stickyHeight =  sticky.el.outerHeight(true);
49
50              stick();
51              toLiveOrDie();
52            }
53          });
54          
55          $(window).load(toLiveOrDie);
56          
57        } else {
58          if (console && console.warn) {
59            console.warn(errors);
60          } else {
61            alert(errors);
62          }
63        }
64      }
65	  
66	  //destroy sticky sidebar if the sidebar is shorter than the content area
67	  function toLiveOrDie(){
68	  	if(parseInt($('#sidebar').height()) + 50 >= parseInt($('#post-area').height())) {
69      	 	sticky.win.unbind('scroll', stick);
70      	 	sticky.el.removeClass('fixed-sidebar');
71      	 	sticky.el.css({
72      	 		'position':'relative',
73      	 		'top' : 0,
74      	 		'margin-left' : 0,
75      	 		'bottom' : 0
76      	 	});
77      	 }
78      	 else {
79      	 	sticky.win.unbind('scroll', stick);
80      	 	sticky.win.bind('scroll', stick);
81      	 	sticky.el.addClass('fixed-sidebar');
82      	 }
83	  }
84	  
85      // Caches the footer and content elements into jquery objects
86      function cacheElements() {
87        settings.footerID = $(settings.footerID);
88        settings.contentID = $(settings.contentID);
89      }
90
91      //  Calcualtes the limits top and bottom limits for the sidebar
92      function calculateLimits() {
93        return {
94          limit: settings.footerID.offset().top - sticky.stickyHeight - $headerHeight - $extraHeight - secondaryHeader,
95          windowTop: sticky.win.scrollTop(),
96          stickyTop: sticky.stickyTop2 - sticky.marg - $headerHeight - $extraHeight - secondaryHeader
97        }
98      }
99
100      // Sets sidebar to fixed position
101      function setFixedSidebar() {
102        sticky.el.css({
103          position: 'fixed',
104          top: $headerHeight + $extraHeight + secondaryHeader,
105          bottom : 'auto'
106        });
107      }
108
109      // Determines the sidebar orientation and sets margins accordingly
110      function checkOrientation() {
111        if (settings.orientation === "left") {
112          settings.contentID.css('margin-left', sticky.el.outerWidth(true));
113        } else {
114          sticky.el.css('margin-left', settings.contentID.outerWidth(true));
115        }
116      }
117
118      // sets sidebar to a static positioned element
119      function setStaticSidebar() {
120        sticky.el.css({
121          'position': 'static',
122          'margin-left': '0px',
123          'bottom' : 'auto'
124        });
125        settings.contentID.css('margin-left', '0px');
126      }
127
128      // initiated to stop the sidebar from intersecting the footer
129      function setLimitedSidebar(diff) {
130
131        sticky.el.css({
132          position: 'absolute',
133          top: 'auto',
134          bottom  : -38
135        });
136      }
137
138      //determines whether sidebar should stick and applies appropriate settings to make it stick
139      function stick() {
140        var tops = calculateLimits();
141        var hitBreakPoint = tops.stickyTop < tops.windowTop && (sticky.win.width() >= sticky.breakPoint);
142		$headerHeight = $('#header-outer').outerHeight() + 34;	
143		
144        if (hitBreakPoint) {
145          setFixedSidebar();
146          checkOrientation();
147        } else {
148          setStaticSidebar();
149        }
150        if (tops.limit < tops.windowTop) {
151          var diff = tops.limit - tops.windowTop;
152          setLimitedSidebar(diff);
153        }
154
155      }
156
157      // verifies that all settings are correct
158      function checkSettings() {
159        var errors = [];
160        for (var key in settings) {
161          if (!settings[key]) {
162            errors.push(settings[key]);
163          }
164        }
165        ieVersion() && errors.push("NO IE 7");
166        return errors;
167      }
168
169      function ieVersion() {
170        if(document.querySelector) {
171          return false;
172        }
173        else {
174          return true;
175        }
176      }
177    }
178  });
179})(jQuery);

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.