Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.
HTML
<script type="text/javascript" src="">

TOTVS_Carousel.js

Índice:

...

...

HTML
<div id="divContainer"></div>
HTML
<script>

TOTVS_Carousel = {
	Id: "Carousel1",
	Container: "divContainer",
	Time: 0,
	SlideIndex: 0,
	Thumbs: false,
	Images: [],
	Auto: false,
	UseTotvsSkin: false, 
	HeaderText: '',
	AutoTimeOut: null,
	ArrowColor: 'white',
	Init: function(id, nameOfContainer, time, images, auto, thumbs, useTotvsSkin, headerText, arrowColor){
		this.Id = id;
		this.Time = time;
		this.Container = (typeof nameOfContainer === "string") ? document.getElementById(nameOfContainer) : nameOfContainer;
		this.Images = images;
		this.Auto = auto;
		this.Thumbs = thumbs;
		this.UseTotvsSkin = useTotvsSkin;
		this.HeaderText = headerText;
		this.ArrowColor = arrowColor;
		this.Build();
	},
	Build: function(){
		if(this.Container){


			if(this.UseTotvsSkin){
				this.Auto = false;
				var _divWrapperTotvsSkin = document.createElement('div');
				_divWrapperTotvsSkin.id = this.Id + "_Wrapper";
				_divWrapperTotvsSkin.className = 'totvs-skin-wrapper';


				var _divWrapperTotvsSkinHeader = document.createElement('div');
				_divWrapperTotvsSkinHeader.id = this.Id + "_WrapperHeader";
				_divWrapperTotvsSkinHeader.className = 'totvs-skin-wrapper-header';
				_divWrapperTotvsSkinHeader.innerHTML = this.HeaderText;


				var _divWrapperTotvsSkinHeaderImg = document.createElement('img');
				_divWrapperTotvsSkinHeaderImg .id = this.Id + "_WrapperHeaderImg";
				_divWrapperTotvsSkinHeaderImg .name = _divWrapperTotvsSkinHeaderImg .id;
				_divWrapperTotvsSkinHeaderImg .src = '/download/attachments/330843097/totvs_icon.png?version=3&modificationDate=1521732225403&api=v2'
				_divWrapperTotvsSkinHeader.appendChild(_divWrapperTotvsSkinHeaderImg);
		
				_divWrapperTotvsSkin.appendChild(_divWrapperTotvsSkinHeader);
			}
			var _divWrapper = document.createElement('div');
			_divWrapper.id = this.Id + "_Wrapper";
			_divWrapper.className = 'slideshow-container';


			if(this.Images != null && this.Images != undefined && this.Images.length > 0){
				for(var i = 0; i < this.Images.length; i++){
					var _divWrapperImages = document.createElement('div');
					_divWrapperImages.id = this.Id + "_WrapperImage_" + (i+1);
					_divWrapperImages.className = 'mySlides fade';					

					var _divWrapperImagesUpperText = document.createElement('div');
					_divWrapperImagesUpperText.id = this.Id + "_WrapperImage_" + (i+1) + "_UpperText";
					_divWrapperImagesUpperText.className = 'numbertext';
					_divWrapperImagesUpperText.innerHTML = (i+1) + " / " + this.Images.length;


					if(this.UseTotvsSkin){
						_divWrapperImagesUpperText.style.display = 'none';						
					}

					_divWrapperImages.appendChild(_divWrapperImagesUpperText);

					var _divWrapperImagesImg = document.createElement('img');
					_divWrapperImagesImg.id = this.Id + "_WrapperImage_" + (i+1) + "_Img";
					_divWrapperImagesImg.name = _divWrapperImagesImg.id;
					_divWrapperImagesImg.style.width = '100%';
					_divWrapperImagesImg.src = this.Images[i].Url;

					_divWrapperImages.appendChild(_divWrapperImagesImg);


					var _divWrapperImagesCaptionText = document.createElement('div');
					_divWrapperImagesCaptionText.id = this.Id + "_WrapperImage_" + (i+1) + "_CaptionText";
					_divWrapperImagesCaptionText.className = 'text';
					_divWrapperImagesCaptionText.innerHTML = this.Images[i].Caption;

					_divWrapperImages.appendChild(_divWrapperImagesCaptionText);


					_divWrapper.appendChild(_divWrapperImages);
				}


				if(!this.Auto || this.UseTotvsSkin){
					var _divWrapperNext = document.createElement('a');
					_divWrapperNext.id = this.Id + "_WrapperNext";
					_divWrapperNext.className = 'next';
					_divWrapperNext.innerHTML = '&#10095;'
					_divWrapperNext.style.setProperty( 'color', this.ArrowColor, 'important' );
					_divWrapperNext.onclick = function() { TOTVS_Carousel.PlusSlides(1); }
					_divWrapperNext.onmouseover = function(){
						this.style.setProperty('color', 'white', 'important');
					}


					_divWrapperNext.onmouseout = function(){
						this.style.setProperty('color', TOTVS_Carousel.ArrowColor , 'important');
					}
					
					_divWrapper.appendChild(_divWrapperNext);


					var _divWrapperPrev = document.createElement('a');
					_divWrapperPrev.id = this.Id + "_WrapperPrev";
					_divWrapperPrev.className = 'prev';
					_divWrapperPrev.innerHTML = '&#10094;'
					_divWrapperPrev.style.setProperty( 'color', this.ArrowColor, 'important' );
					_divWrapperPrev.onclick = function() { TOTVS_Carousel.PlusSlides(-1); }
					_divWrapperPrev.onmouseover = function(){
						this.style.setProperty('color', 'white', 'important');

					}


					_divWrapperPrev.onmouseout = function(){
						this.style.setProperty('color', TOTVS_Carousel.ArrowColor , 'important');
					}					
					_divWrapper.appendChild(_divWrapperPrev);
				}

				if(!this.Thumbs && !this.UseTotvsSkin){
					var _divWrapperDots = document.createElement('div');
					_divWrapperDots.id = this.Id + "_WrapperDotsWrapper";
					_divWrapperDots.style.textAlign = 'center';


					for(var i = 0; i < this.Images.length; i++){
						var _divWrapperDotsSpans = document.createElement('span');
						_divWrapperDotsSpans.id = this.Id + "_WrapperDotsWrapper_" + (i+1) + "_Span";
						_divWrapperDotsSpans.name = _divWrapperDotsSpans.id;
						_divWrapperDotsSpans.className = 'dot';


						if(!this.Auto){
							_divWrapperDotsSpans.onclick = function() { 
								var _index = 0;
								var _left = this.id.substring(this.id.indexOf('_WrapperDotsWrapper_') + '_WrapperDotsWrapper_'.length);
								if(_left.length > 0)
									_left = _left.replace('_Span', '');
								TOTVS_Carousel.CurrentSlide(_left);
							};
						}

						_divWrapperDots.appendChild(_divWrapperDotsSpans);
					}

					_divWrapperDots.style.marginTop = '15px';
					_divWrapper.appendChild(_divWrapperDots);
				}

				if(this.Thumbs){
					var _divWrapperThumbContainer = document.createElement('div');
					_divWrapperThumbContainer.id = this.Id + "_WrapperThumbContainer";
					_divWrapperThumbContainer.className = 'totvs-skin-wrapper-thumb-container';		

					var _divWrapperThumbContainerRow = document.createElement('div');
					_divWrapperThumbContainerRow .id = this.Id + "_WrapperThumbContainerRow";
					_divWrapperThumbContainerRow .className = 'row';		

					_divWrapperThumbContainer.appendChild(_divWrapperThumbContainerRow);


					for(var i = 0; i < this.Images.length; i++){
						var _divWrapperThumbContainerRowColumn = document.createElement('div');
						_divWrapperThumbContainerRowColumn.id = this.Id + "_WrapperThumbContainerRowColumn" + "_" + (i+1);
						_divWrapperThumbContainerRowColumn.className = 'column';


						_divWrapperThumbContainerRow.appendChild(_divWrapperThumbContainerRowColumn);
					}

					_divWrapper.appendChild(_divWrapperThumbContainer);
				}
			}
			
			if(this.UseTotvsSkin){
				var _divWrapperFooter = document.createElement('div');
					_divWrapperFooter .id = this.Id + "_WrapperFooter";
					_divWrapperFooter .className = 'totvs-skin-wrapper-footer';			


				_divWrapper.appendChild(_divWrapperFooter);		


				var _divWrapperFooterInput = document.createElement('input');
					_divWrapperFooterInput.id = this.Id + "_WrapperFooterInput";
					_divWrapperFooterInput.name = _divWrapperFooterInput.id;
					_divWrapperFooterInput.type = 'text';
					_divWrapperFooterInput.className = 'totvs-skin-wrapper-footer-input';		
					_divWrapperFooterInput.value = '1/3';
					_divWrapperFooterInput.readOnly = '';

					_divWrapperFooterInput.onblur = function(){
						var text = (this.value != null) ? this.value.replace(/\/\d/,'') : this.SlideIndex.toString();
						TOTVS_Carousel.SlideIndex = parseInt(text);
						TOTVS_Carousel.ShowSlides(TOTVS_Carousel.SlideIndex);
					}

				_divWrapperFooter.appendChild(_divWrapperFooterInput);


				var _divWrapperFooterPlayerContainer = document.createElement('div');
					_divWrapperFooterPlayerContainer.id = this.Id + "_WrapperFooterPlayerContainer";
					_divWrapperFooterPlayerContainer.className = 'totvs-skin-wrapper-footer-player-container';			


				_divWrapperFooter.appendChild(_divWrapperFooterPlayerContainer);


					var _divWrapperFooterPlayerContainerPlay = document.createElement('img');
					_divWrapperFooterPlayerContainerPlay.id = this.Id + "_WrapperFooterPlayerContainerPlayImg";
					_divWrapperFooterPlayerContainerPlay.name = _divWrapperFooterPlayerContainerPlay.id;
					_divWrapperFooterPlayerContainerPlay.className = 'totvs-skin-wrapper-footer-player-container-play';	
					_divWrapperFooterPlayerContainerPlay.src = '/download/thumbnails/330843097/play-button.png?version=1&modificationDate=1521735312000&api=v2';
					_divWrapperFooterPlayerContainerPlay.onclick = function(){
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPlayImg", "_WrapperNext")).style.display = 'none';
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPlayImg", "_WrapperPrev")).style.display = 'none';


						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPlayImg", "_WrapperFooterInput")).readOnly = 'readonly';
						TOTVS_Carousel.Auto = true;
						TOTVS_Carousel.SlideIndex -= 1;
						TOTVS_Carousel.SlideIndex = (TOTVS_Carousel.SlideIndex < 0) ? 0 : TOTVS_Carousel.SlideIndex;
						TOTVS_Carousel.ShowSlides();

						this.style.display = 'none';
						document.getElementById(this.id.replace("PlayImg", "PauseImg")).style.display = '';
						document.getElementById(this.id.replace("PlayImg", "PauseImg")).style.marginRight = '10px';
						document.getElementById(this.id.replace("PlayImg", "StopImg")).style.display = '';
					}

				_divWrapperFooterPlayerContainer.appendChild(_divWrapperFooterPlayerContainerPlay);
				
				var _divWrapperFooterPlayerContainerPause = document.createElement('img');
					_divWrapperFooterPlayerContainerPause.id = this.Id + "_WrapperFooterPlayerContainerPauseImg";
					_divWrapperFooterPlayerContainerPause.name = _divWrapperFooterPlayerContainerPause.id;
					_divWrapperFooterPlayerContainerPause.className = 'totvs-skin-wrapper-footer-player-container-pause';	
					_divWrapperFooterPlayerContainerPause.style.display = 'none';
					_divWrapperFooterPlayerContainerPause.src = '/download/thumbnails/330843097/pause-sign.png?version=1&modificationDate=1521735312000&api=v2';
					_divWrapperFooterPlayerContainerPause.onclick = function(){
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPauseImg", "_WrapperNext")).style.display = 'none';
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPauseImg", "_WrapperPrev")).style.display = 'none';


						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerPauseImg", "_WrapperFooterInput")).readOnly = 'readonly';


						TOTVS_Carousel.Auto = false;
						TOTVS_Carousel.ShowSlides(TOTVS_Carousel.SlideIndex);

						this.style.display = 'none';
						this.style.marginRight = '0px';
						document.getElementById(this.id.replace("PauseImg", "PlayImg")).style.display = '';
						document.getElementById(this.id.replace("PauseImg", "PlayImg")).style.marginRight = '10px';
						document.getElementById(this.id.replace("PauseImg", "StopImg")).style.display = '';
					}
				_divWrapperFooterPlayerContainer.appendChild(_divWrapperFooterPlayerContainerPause);
				
				var _divWrapperFooterPlayerContainerStop = document.createElement('img');
					_divWrapperFooterPlayerContainerStop.id = this.Id + "_WrapperFooterPlayerContainerStopImg";
					_divWrapperFooterPlayerContainerStop.name = _divWrapperFooterPlayerContainerStop.id;
					_divWrapperFooterPlayerContainerStop.className = 'totvs-skin-wrapper-footer-player-container-stop';	
					_divWrapperFooterPlayerContainerStop.style.display = 'none';
					_divWrapperFooterPlayerContainerStop.src = '/download/attachments/330843097/stop-button.png?version=2&modificationDate=1521738581119&api=v2';
					_divWrapperFooterPlayerContainerStop.onclick = function(){
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerStopImg", "_WrapperNext")).style.display = '';
						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerStopImg", "_WrapperPrev")).style.display = '';


						document.getElementById(this.id.replace("_WrapperFooterPlayerContainerStopImg", "_WrapperFooterInput")).readOnly = '';
						TOTVS_Carousel.Auto = false;
						TOTVS_Carousel.SlideIndex = 1;
						TOTVS_Carousel.ShowSlides(TOTVS_Carousel.SlideIndex);


						this.style.display = 'none';
						document.getElementById(this.id.replace("StopImg", "PauseImg")).style.display = 'none';
						document.getElementById(this.id.replace("StopImg", "PlayImg")).style.display = '';
						document.getElementById(this.id.replace("StopImg", "PlayImg")).style.marginRight = '0px';
					}
				_divWrapperFooterPlayerContainer.appendChild(_divWrapperFooterPlayerContainerStop);
				
				_divWrapperTotvsSkin.appendChild(_divWrapper);
				this.Container.appendChild(_divWrapperTotvsSkin);
			}
			else
				this.Container.appendChild(_divWrapper);
		}
	},
	PlusSlides(n) {
  		this.ShowSlides(this.SlideIndex += n);
	},
	CurrentSlide(n) {
  		this.ShowSlides(this.SlideIndex = n);
	},
	ShowSlides: function(n){
		var i;
    	var slides = document.getElementsByClassName("mySlides");
    	var dots = document.getElementsByClassName("dot");
					
		if(this.Auto){
			for (i = 0; i < slides.length; i++) {
       			slides[i].style.display = "none";  
    		}
   			this.SlideIndex++;
    		if (this.SlideIndex > slides.length) {this.SlideIndex = 1}    


			if(this.UseTotvsSkin){
				var currentSlideIndex = (this.SlideIndex <= 0 || this.SlideIndex > slides.length) ? 1 : this.SlideIndex;
				document.getElementById(this.Id + "_WrapperFooterInput").value = currentSlideIndex + "/" + slides.length;
			}
    		for (i = 0; i < dots.length; i++) {
        		dots[i].className = dots[i].className.replace(" active", "");
    		}
    		slides[this.SlideIndex-1].style.display = "block";  
			
			if(!this.UseTotvsSkin)
    			dots[this.SlideIndex-1].className += " active";
    		this.AutoTimeOut = setTimeout('TOTVS_Carousel.ShowSlides()', this.Time); // Change image every 2 seconds
		}
		else{
			if(this.AutoTimeOut != null)
					clearTimeout(this.AutoTimeOut);
			if(this.UseTotvsSkin){
				var currentSlideIndex = (this.SlideIndex <= 0 || this.SlideIndex > slides.length) ? 1 : this.SlideIndex;
				document.getElementById(this.Id + "_WrapperFooterInput").value = currentSlideIndex + "/" + slides.length;
			}
			if (n == undefined || n == null) {n = 1; this.SlideIndex = 1; }
  			if (n > slides.length) {this.SlideIndex = 1}    
  			if (n < 1) {this.SlideIndex = slides.length}
  			for (i = 0; i < slides.length; i++) {
      			slides[i].style.display = "none";  
  			}
  			for (i = 0; i < dots.length; i++) {
      			dots[i].className = dots[i].className.replace(" active", "");
  			}
  			slides[this.SlideIndex-1].style.display = "block";  


			if(!this.UseTotvsSkin)
  				dots[this.SlideIndex-1].className += " active";    	
		}
	}
}

var _images = [];


var _imagesSettings1 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-1.png?version=1&modificationDate=1521744577627&api=v2',
	Caption: 'Página 1'
}


var _imagesSettings2 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-2.png?version=1&modificationDate=1521744583301&api=v2',
	Caption: 'Página 2'
}


var _imagesSettings3 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-3.png?version=1&modificationDate=1521744585793&api=v2',
	Caption: 'Página 3'
}


var _imagesSettings4 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-4.png?version=1&modificationDate=1521744587348&api=v2',
	Caption: 'Página 4'
}


var _imagesSettings5 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-5.png?version=1&modificationDate=1521744590331&api=v2',
	Caption: 'Página 5'
}


var _imagesSettings6 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-6.png?version=1&modificationDate=1521744593147&api=v2',
	Caption: 'Página 6'
}


var _imagesSettings7 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-7.png?version=1&modificationDate=1521744596596&api=v2',
	Caption: 'Página 7'
}


var _imagesSettings8 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-8.png?version=1&modificationDate=1521744598581&api=v2',
	Caption: 'Página 8'
}


var _imagesSettings9 = {
	Url: '/download/attachments/330843097/TOTVS%20RM%20-Configura%C3%A7%C3%A3o%20Servi%C3%A7o%20de%20Cache%20Centralizado-9.png?version=1&modificationDate=1521744575616&api=v2',
	Caption: 'Página 9'
}


_images.push(_imagesSettings1);
_images.push(_imagesSettings2);
_images.push(_imagesSettings3);
_images.push(_imagesSettings4);
_images.push(_imagesSettings5);
_images.push(_imagesSettings6);
_images.push(_imagesSettings7);
_images.push(_imagesSettings8);
_images.push(_imagesSettings9);
TOTVS_Carousel.Init('Carousel1', 'divContainer', 5000, _images, true, true, true, 'Cache Centralizado', 'black');
TOTVS_Carousel.ShowSlides();
</script>

...