fengjuan 4 yıl önce
ebeveyn
işleme
86ed718d90
1 değiştirilmiş dosya ile 100 ekleme ve 2 silme
  1. 100 2
      index.html

+ 100 - 2
index.html

@@ -18,9 +18,11 @@
 		
 		<script src="/skin/js/commonHttp.js"></script>
 		<script src="/skin/js/flexible-bootstrap-carousel.js"></script>
-		<script src="/skin/js/jquery.tmpl.js"></script> 
+
 		
-		<script src="/skin/js/scripta.js"></script>
+		<!--<script src="/skin/js/scripta.js"></script>-->
+		<script src="/skin/js/jquery.tmpl.js"></script> 
+		 
 		<!--<script src="/skin/js/bootstrap.js"></script>-->
 		
 
@@ -347,7 +349,103 @@
 					$("#NewsTemplate").tmpl(result.data.c.introduce_model).appendTo("#NewsContent");
 					$("#ExpeTemplate").tmpl(result.data.d.introduce_model).appendTo("#ExpeContent");
 					
+					/* global $ */
+
+$(window).load(function() {
+	preloadImagesForCarousel();
+	
+	$(".carousel").on("aCarouselHasBeenAdjusted", function() {
+		sizeChoosing();
+		chooseColor();
+		adjustIndexesOfCarousel();
+	});
+	
+	adjustAllCarousels();
+});
+
+function sizeChoosing() {
+	$(".size .options").hide();
+	
+	$(".carousel").off("click").on("click", ".size", function() {
+		$(this).clearQueue();
+		
+		if ($(this).hasClass("shown"))
+		{
+			$(this).clearQueue().removeClass("shown").find(".options").slideUp(800);
+		}
+		else
+		{
+			$(this).clearQueue().addClass("shown").find(".options").slideDown(800);
+		}
+	});
+	
+	$(".carousel").on("click", ".option", function() {
+		$(this).closest(".size").find(".header .number").html($(this).text());
+	});
+}
+
+function chooseColor() {
+	$(".carousel").on("click", ".choose-color div", function() {
+		var img_path = findPathToDirectory($(this).closest(".flex-item").find(".good-image img").attr("src")) + $(this).attr("class") + ".png";
+		
+		$(this).closest(".flex-item").find(".good-image img").stop().fadeTo("slow", 0, function() {
+			$(this).attr("src", img_path);
+		}).fadeTo("slow", 1);
+	});
+}
 
+function findPathToDirectory(path_to_file) {
+	return path_to_file.slice(0, path_to_file.lastIndexOf("/") + 1);
+}
+
+function adjustIndexesOfCarousel() {
+	$(".carousel").each(function() {
+		setupIndexesOfCarousel($(this));
+	});
+	$(".carousel").on("slid.bs.carousel", function() {
+		setupIndexesOfCarousel($(this));
+	});
+}
+
+function setupIndexesOfCarousel(carousel) {
+	var total_number = $(carousel).find(".item").length;
+	var current_number = $(carousel).find(".item.active").index() + 1;
+	
+	$(carousel).find(".index").text(String(current_number) + " / " + String(total_number));
+}
+
+function preloadImages(images) { 
+  for (var i = 0; i < images.length; i++) {
+    $("<img />").attr("src", images[i]);
+  }
+}
+
+function collectImagesForPreloading() {
+	var images = [];
+	
+	$(".carousel .choose-color").each(function() {
+		var files = [];
+		
+		$(this).find("div").each(function() {
+			files.push($(this).attr("class"));
+		});
+		
+		var directory = findPathToDirectory($(this).closest(".flex-item").find(".good-image img").attr("src"));
+		
+		for (var i = 0; i < files.length; i++)
+		{
+			images.push(directory + files[i] + ".png");
+		}
+	});
+	
+	return images;
+}
+
+function preloadImagesForCarousel() {
+	var images = collectImagesForPreloading();
+	
+	preloadImages(images);
+}
 				}, "json");
 			}
 			function About(){