1/* 2 * vcs - vioma content slider 3 * 4 */ 5if ( typeof vcs == 'undefined' ) { 6 if ( window.console && window.console.info ) { 7 console.info( 'vioma content slider' ); 8 console.info( 'Version 0.1 beta' ); 9 } 10 11 vcs = { 12 timer: false, 13 settings: {}, 14 counter: 0, 15 animate: function( identifier, backward ) { 16 if ( identifier === undefined || !vcs.settings[identifier] ) return false; 17 18 var left = vcs.settings[identifier].width, 19 left_current = Math.abs( parseInt( vcs.settings[identifier].container_inner.css( 'left' ), 10 ) ), 20 left_max = ( vcs.settings[identifier].children.size() - 1 ) * vcs.settings[identifier].width; 21 22 left_current = parseInt( left_current / vcs.settings[identifier].width ) * vcs.settings[identifier].width; 23 24 if (backward) { 25 left = left_current - left; 26 27 if (left < 0) { 28 left = left_max; 29 } 30 } 31 else { 32 if (left_current < left_max) { 33 left = left_current + left; 34 } 35 else { 36 left = 0; 37 } 38 } 39 40 jQuery( vcs.settings[identifier].pagina.container ) 41 .children() 42 .removeAttr( 'class' ) 43 .eq( parseInt( left / vcs.settings[identifier].width ) ) 44 .attr( 'class', 'active' ); 45 46 vcs.settings[identifier].container_inner.animate({ left: '-' + left }, { queue: false }); 47 }, 48 start: function( identifier ) { 49 if ( identifier === undefined || !vcs.settings[identifier] ) return false; 50 51 vcs.settings[identifier].timer = window.setInterval(function(){ 52 vcs.animate( identifier ); 53 }, vcs.settings[identifier].interval ); 54 }, 55 stop: function( identifier ) { 56 if ( identifier === undefined || !vcs.settings[identifier] ) return false; 57 58 window.clearInterval( vcs.settings[identifier].timer ); 59 }, 60 create: function( container, options ) { 61 identifier = vcs.counter++; 62 var container = jQuery( container ), 63 container_inner = container.children().eq( 0 ), 64 children = container_inner.children(), 65 width = children.eq( 0 ).outerWidth(); 66 67 vcs.settings[identifier] = jQuery.extend( 68 true, 69 { 70 container: container, 71 container_inner: container_inner, 72 children: children, 73 width: width, 74 pagina: { 75 container: false,// jQuery selector 76 path: false,// path to image 77 path_active: false// path to image 78 }, 79 links: { 80 prev: false,// jQuery selector 81 next: false// jQuery selector 82 }, 83 interval: 5000000 84 }, 85 options 86 ); 87 88 if ( !vcs.settings[identifier].container[0] ) return; 89 90 var container = vcs.settings[identifier].container, 91 container_inner = vcs.settings[identifier].container_inner, 92 children = container_inner.children(); 93 94 vcs.settings[identifier].container 95 .attr( 'vcs_element', identifier ) 96 .css({ 97 position: 'relative', 98 overflow: 'hidden' 99 }) 100 .bind( 'mouseenter', function( j ){ 101 vcs.stop( jQuery( this ).attr( 'vcs_element' ) ); 102 }) 103 .bind( 'mouseleave', function( j ){ 104 vcs.start( jQuery( this ).attr( 'vcs_element' ) ); 105 }); 106 107 container_inner 108 .css({ 109 position: 'absolute', 110 top: 0, 111 left: 0, 112 height: container.css( 'height' ), 113 width: children.size() * vcs.settings[identifier].width 114 }); 115 116 vcs.start( identifier ); 117 118 if ( vcs.settings[identifier].links ) { 119 if (vcs.settings[identifier].links.prev) { 120 jQuery(vcs.settings[identifier].links.prev) 121 .filter( ':not([vcs_element])' ) 122 .filter( ':first' ) 123 .attr('vcs_element', identifier) 124 .bind('click', function(){ 125 var identifier = jQuery( this ).attr( 'vcs_element' ); 126 vcs.stop(identifier); 127 vcs.animate(identifier, true); 128 vcs.start(identifier); 129 return false; 130 }); 131 } 132 133 if (vcs.settings[identifier].links.next) { 134 jQuery(vcs.settings[identifier].links.next) 135 .filter( ':not([vcs_element])' ) 136 .filter( ':first' ) 137 .attr('vcs_element', identifier) 138 .bind('click', function(){ 139 var identifier = jQuery( this ).attr( 'vcs_element' ); 140 vcs.stop(identifier); 141 vcs.animate(identifier); 142 vcs.start(identifier); 143 return false;
144 }); 145 } 146 } 147 148 if ( vcs.settings[identifier].pagina.container ) { 149 vcs.settings[identifier].children.each(function( i ){ 150 jQuery( document.createElement( 'a' ) ) 151 .attr( 'class', ( i == 0 ? 'active' : '' ) ) 152 .attr( 'href', '#' ) 153 .attr( 'vcs_element', identifier ) 154 .html( vcs.settings[identifier].pagina.path ? '<img src="' + vcs.settings[identifier].pagina.path + '">' + ( vcs.settings[identifier].pagina.path_active ? '<img src="' + vcs.settings[identifier].pagina.path_active + '">' : '' ) : ( i + 1 ) ) 155 .bind( 'click', function(){ 156 vcs.stop( jQuery( this ).attr( 'vcs_element' ) ); 157 vcs.animate( jQuery( this ).attr( 'vcs_element' ) ); 158 return false; 159 }) 160 .appendTo( vcs.settings[identifier].pagina.container ); 161 }); 162 } 163 } 164 }; 165 166 (function(jQuery) { 167 jQuery.fn.vcs = function( options ) { 168 this.each(function() { 169 vcs.create( this, options ); 170 }); 171 172 return this; 173 }; 174 })(jQuery); 175}
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.