1"use strict"; 2 3i3.use({ 4 "object": "" 5}); 6 7i3.object.extend({ 8 __name__: "i3-widget-scroll-navigation", 9 10 __constructor__: function (self, params) 11 { 12 var component = this; 13 14 params = i3.extend(true, { 15 offsets: {}, 16 17 "class": { 18 up: "", 19 down: "" 20 }, 21 22 __scrollTop__: i3(window).scrollTop() 23 }, params); 24 25 // if any of the offsets are defined as being 'auto' then we will 26 // need to go around and figure out what the offsets should be; for 27 // the interests of simplicity we will declare that anything that is 28 // 'auto' is the position of the element, relative to the top of the 29 // document. 30 for(var i in params.offsets) 31 { 32 var matches = undefined; 33 34 if(typeof params.offsets[i] == "string") 35 { 36 if((matches = params.offsets[i].match(/^top(?:\s*([+-])\s*(\d+))?$/))) 37 { 38 params.offsets[i] = this.node().position().top; 39 40 if(matches[1] !== undefined && matches[2] !== undefined) 41 { 42 if(matches[1] == "+") 43 params.offsets[i] += parseInt(matches[2]); 44 else if(matches[1] == "-") 45 params.offsets[i] -= parseInt(matches[2]); 46 } 47 } 48 else if((matches = params.offsets[i].match(/^bottom(?:\s*([+-])\s*(\d+))?$/))) 49 { 50 params.offsets[i] = this.node().position().top + this.node().outerHeight(); 51 52 if(matches[1] !== undefined && matches[2] !== undefined) 53 { 54 if(matches[1] == "+") 55 params.offsets[i] += parseInt(matches[2]); 56 else if(matches[1] == "-") 57 params.offsets[i] -= parseInt(matches[2]); 58 } 59 } 60 } 61 } 62 63 this.params(params); 64 }, 65 66 __init__: function() 67 { 68 var component = this; 69 70 i3(window).on('scroll', function(){ 71 component.__event__() 72 }).trigger('scroll'); 73 }, 74 75 __event__: function(event) 76 { 77 var params = this.params(); 78 var node = this.node(); 79 80 if (params['class'].up != params['class'].down) 81 { 82 if (params.__scrollTop__ > i3(window).scrollTop()) 83 i3(node).addClass(params['class'].up).removeClass(params['class'].down); 84 else 85 i3(node).addClass(params['class'].down).removeClass(params['class'].up); 86 } 87 88 params.__scrollTop__ = i3(window).scrollTop(); 89 90 for (var i in params.offsets) 91 { 92 if (i3(window).scrollTop() > parseInt(params.offsets[i])) 93 i3(node).addClass(i); 94 else 95 i3(node).removeClass(i); 96 } 97 } 98});
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.