Procházet zdrojové kódy

Just some reformatting.

Frederic G. MARAND před 8 roky
rodič
revize
9fc8811000
3 změnil soubory, kde provedl 206 přidání a 238 odebrání
  1. 3 30
      .eslintrc.js
  2. 71 71
      js/Albums.js
  3. 132 137
      js/gallery.js

+ 3 - 30
.eslintrc.js

@@ -9,34 +9,7 @@ module.exports = {
   "globals": {
     "$": true,
     "jQuery": true,
-    "React": true,
-    "ReactDOM": true,
-    "_": true,
-
-    "Accounts": true,
-    "HTTP": true,
-    "Log": true,
-    "Match": true,
-    "Meteor": true,
-    "Npm": true,
-    "Package": true,
-    "ServiceConfiguration": true,
-    "Session": true,
-    "Template": true,
-    "Tinytest": true,
-    "WebApp": true,
-    "check": true,
-
-    // The globals defined in this package.
-    "Drupal": true,
-    "DrupalBase": true,
-    "DrupalClient": true,
-    "DrupalConfiguration": true,
-    "DrupalServer": true,
-    "client": true,
-    "drupal": true,
-    "server": true,
-    "stream": true
+    "Handlebars": true
   },
 
   "plugins": ["react"],
@@ -190,7 +163,7 @@ module.exports = {
     "array-bracket-spacing": [2, "never"],
     "indent": [2, 2, { SwitchCase: 1 }], // this option sets a specific tab width for your code (off by default)
     "brace-style": [2, "stroustrup", {"allowSingleLine": true}],
-    "camelcase": 1, // require camel case names
+    "camelcase": 0, // require camel case names
     "comma-spacing": [1, {"before": false, "after": true}], // enforce spacing before and after comma
     "comma-style": [1, "last"], // enforce one true comma style (off by default)
     "computed-property-spacing": [2, "never"],
@@ -239,7 +212,7 @@ module.exports = {
     //
     // These rules are only relevant to ES6 environments and are off by default.
     //
-    "no-var": 2, // require let or const instead of var (off by default)
+    "no-var": 0, // require let or const instead of var (off by default)
     "generator-star-spacing": [2, "before"], // enforce the spacing around the * in generator functions (off by default)
 
     //

+ 71 - 71
js/Albums.js

@@ -5,75 +5,75 @@
 // The photos contain an image src and some metadata
 
 var gallery = {
-	albums : [
-		{
-			name : "Travels",
-			thumbnail : "images/img_1.jpg",
-			photos : [
-				{	
-					src : "images/img_1.jpg",
-					title : "grafitti",
-					description : "some derelict appartments with grafitti"
-				},
-				{
-					src : "images/img_6.jpg",
-					title : "fountain", 
-					description : "a huge dragon fountain"
-				}, 
-				{	
-					src : "images/img_7.jpg",
-					title : "tower", 
-					description : "a colourful tower block"
-				}, 
-				{	
-					src : "images/img_8.jpg",
-					title : "walkways", 
-					description : "an interesting interior"
-				} 
-			]
-		},
-		{
-			name : "Equipment", 
-			thumbnail : "images/img_4.jpg",
-			photos : [
-				{	
-					src : "images/img_4.jpg",
-					title : "syths", 
-					description : "all workshops should aspire to being this tidy"
-				}, 
-				{	
-					src : "images/img_9.jpg",
-					title : "helmet", 
-					description : "a sci-fi helmet"
-				}, 
-				{	
-					src : "images/img_12.jpg",
-					title : "drums", 
-					description : "a rather nice drum kit"
-				}  
-			]
-		},
-		{
-			name : "English Winter", 
-			thumbnail : "images/img_17.jpg",
-			photos : [
-				{	
-					src : "images/img_16.jpg",
-					title : "dog in the snow", 
-					description : "looks like he needs that jacket"
-				}, 
-				{	
-					src : "images/img_17.jpg",
-					title : "winter", 
-					description : "a snowy scene in a park"
-				}, 
-				{	
-					src : "images/img_18.jpg",
-					title : "frosty pond", 
-					description : "some ducks feeling cold"
-				} 
-			]
-		}
+  albums: [
+    {
+      name: "Travels",
+      thumbnail: "images/img_1.jpg",
+      photos: [
+        {
+          src: "images/img_1.jpg",
+          title: "grafitti",
+          description: "some derelict appartments with grafitti"
+        },
+        {
+          src: "images/img_6.jpg",
+          title: "fountain",
+          description: "a huge dragon fountain"
+        },
+        {
+          src: "images/img_7.jpg",
+          title: "tower",
+          description: "a colourful tower block"
+        },
+        {
+          src: "images/img_8.jpg",
+          title: "walkways",
+          description: "an interesting interior"
+        }
+      ]
+    },
+    {
+      name: "Equipment",
+      thumbnail: "images/img_4.jpg",
+      photos: [
+        {
+          src: "images/img_4.jpg",
+          title: "syths",
+          description: "all workshops should aspire to being this tidy"
+        },
+        {
+          src: "images/img_9.jpg",
+          title: "helmet",
+          description: "a sci-fi helmet"
+        },
+        {
+          src: "images/img_12.jpg",
+          title: "drums",
+          description: "a rather nice drum kit"
+        }
+      ]
+    },
+    {
+      name: "English Winter",
+      thumbnail: "images/img_17.jpg",
+      photos: [
+        {
+          src: "images/img_16.jpg",
+          title: "dog in the snow",
+          description: "looks like he needs that jacket"
+        },
+        {
+          src: "images/img_17.jpg",
+          title: "winter",
+          description: "a snowy scene in a park"
+        },
+        {
+          src: "images/img_18.jpg",
+          title: "frosty pond",
+          description: "some ducks feeling cold"
+        }
+      ]
+    }
 
-	]
-};
+  ]
+};

+ 132 - 137
js/gallery.js

@@ -1,10 +1,9 @@
-
 /*
  *		This file contains the javascript code for our gallery
  */
 
 // variables for all of the templates so we only have to compile
-// them once on page load and can then use the same compiled 
+// them once on page load and can then use the same compiled
 // templates many times
 var albums_template, photos_template, photo_template, slideshow_template;
 
@@ -14,143 +13,139 @@ var current_photo = current_album.photos[0];
 
 // a helper function that instantiates a template
 // and displays the results in the content div
-function showTemplate(template, data){
-	var html    = template(data);
-	$('#content').html(html);
+function showTemplate(template, data) {
+  var html = template(data);
+  $("#content").html(html);
 }
 
 // document read gets called when the whole document
 // is loaded, so we put most of the code that needs to run
 // in here
-$(document).ready(function(){
-
-	//
-	// compile all of our templates ready for use
-	//
-	var source   = $("#albums-template").html();
-	albums_template = Handlebars.compile(source);
-	
-	source   = $("#photos-template").html();
-	photos_template = Handlebars.compile(source);
-	
-	source   = $("#photo-template").html();
-	photo_template = Handlebars.compile(source);
-	
-	source   = $("#slideshow-template").html();
-	slideshow_template = Handlebars.compile(source);
-
-	// 
-	//  clicking on the albums tab shows the 
-	//  thumbnails of all the albums
-	//
-	$("#albums-tab").click(function () {
-
-		// displays the albums template
-		showTemplate(albums_template, gallery);
-
-		// make the albums tab the active one
-		// first make the currently active tab inactive
-		$(".nav-tabs .active").removeClass("active");
-		// then make albums tab active
-		$("#albums-tab").addClass("active");
-
-		// add a click callback to each album 
-		// thumbnail which displays the photos
-		// template on that album
-		// (I have written out the code for this 
-		// function for clarity but it is actually
-		// pretty much the same as the photos tab
-		// function so we could acutally just
-		// call $(".photo-thumbnail").click() ) 
-		$(".album-thumbnail").click(function (){
-			
-			// get the index (position in the array)
-			// of the album we clicked on
-			// "this" is the element that was clicked on
-			// data("id") gets the attribute data-id
-			// (which we set to the index of the album in
-			// the array - @index)
-			var index = $(this).data("id");
-
-			// set the current album to this album
-			current_album = gallery.albums[index];
-
-			// displays the photos template
-			showTemplate(photos_template, current_album);
-
-			// add an on click al all the photo thumbnails
-			// which displays the photo in a modal popup
-			$(".photo-thumbnail").click(function (){
-				// get the index (position in the array)
-				// of the photo we clicked on
-				// "this" is the element that was clicked on
-				// data("id") gets the attribute data-id
-				// (which we set to the index of the photo in
-				// the array - @index)
-				var index = $(this).data("id");
-
-				// set the current photo to this photo
-				current_photo = current_album.photos[index];
-				
-				// displays the single photo template
-				showTemplate(photo_template, current_photo);
-			});
-		});
-	});
-
-	// 
-	//  clicking on the photos tab shows all of the 
-	//  photos in the current album
-	//
-	$("#photos-tab").click(function () {
-		
-		// displays the photos template
-		showTemplate(photos_template, current_album);
-
-		// make the photos tab the active one
-		// first make the currently active tab inactive
-		$(".nav-tabs .active").removeClass("active");
-		// then make photos tab active
-		$("#photos-tab").addClass("active");
-
-		// add an on click al all the photo thumbnails
-		// which displays the photo in a modal popup
-		$(".photo-thumbnail").click(function (){
-			// get the index (position in the array)
-			// of the photo we clicked on
-			// "this" is the element that was clicked on
-			// data("id") gets the attribute data-id
-			// (which we set to the index of the photo in
-			// the array - @index)
-			var index = $(this).data("id");
-
-			// set the current photo to this photo
-			current_photo = current_album.photos[index];
-			
-			// displays the single photo template
-			showTemplate(photo_template, current_photo);
-		});
-	});
-
-	// 
-	//  clicking on the slideshow tab displays the
-	//  current album as a slide show
-	//
-	$("#slideshow-tab").click(function () {
-		// display the slideshow template using the 
-		// current album
-		showTemplate(slideshow_template, current_album);
-		
-		// make the slideshow tab the active one
-		// first make the currently active tab inactive
-		$(".nav-tabs .active").removeClass("active");
-		// then make slideshow tab active
-		$("#slideshow-tab").addClass("active");
-	});
-
-	// start the page by showing the albums view
-	// we do this by virtually clicking on the 
-	// albums tab
-	$("#albums-tab").click();
-
-});
+$(document).ready(function () {
+  //
+  // compile all of our templates ready for use
+  //
+  var source = $("#albums-template").html();
+  albums_template = Handlebars.compile(source);
+
+  source = $("#photos-template").html();
+  photos_template = Handlebars.compile(source);
+
+  source = $("#photo-template").html();
+  photo_template = Handlebars.compile(source);
+
+  source = $("#slideshow-template").html();
+  slideshow_template = Handlebars.compile(source);
+
+  //
+  //  clicking on the albums tab shows the
+  //  thumbnails of all the albums
+  //
+  $("#albums-tab").click(function () {
+    // displays the albums template
+    showTemplate(albums_template, gallery);
+
+    // make the albums tab the active one
+    // first make the currently active tab inactive
+    $(".nav-tabs .active").removeClass("active");
+    // then make albums tab active
+    $("#albums-tab").addClass("active");
+
+    // add a click callback to each album
+    // thumbnail which displays the photos
+    // template on that album
+    // (I have written out the code for this
+    // function for clarity but it is actually
+    // pretty much the same as the photos tab
+    // function so we could acutally just
+    // call $(".photo-thumbnail").click() )
+    $(".album-thumbnail").click(function () {
+
+      // get the index (position in the array)
+      // of the album we clicked on
+      // "this" is the element that was clicked on
+      // data("id") gets the attribute data-id
+      // (which we set to the index of the album in
+      // the array - @index)
+      var index = $(this).data("id");
+
+      // set the current album to this album
+      current_album = gallery.albums[index];
+
+      // displays the photos template
+      showTemplate(photos_template, current_album);
+
+      // add an on click al all the photo thumbnails
+      // which displays the photo in a modal popup
+      $(".photo-thumbnail").click(function () {
+        // get the index (position in the array)
+        // of the photo we clicked on
+        // "this" is the element that was clicked on
+        // data("id") gets the attribute data-id
+        // (which we set to the index of the photo in
+        // the array - @index)
+        var index = $(this).data("id");
+
+        // set the current photo to this photo
+        current_photo = current_album.photos[index];
+
+        // displays the single photo template
+        showTemplate(photo_template, current_photo);
+      });
+    });
+  });
+
+  //
+  //  clicking on the photos tab shows all of the
+  //  photos in the current album
+  //
+  $("#photos-tab").click(function () {
+    // displays the photos template
+    showTemplate(photos_template, current_album);
+
+    // make the photos tab the active one
+    // first make the currently active tab inactive
+    $(".nav-tabs .active").removeClass("active");
+    // then make photos tab active
+    $("#photos-tab").addClass("active");
+
+    // add an on click al all the photo thumbnails
+    // which displays the photo in a modal popup
+    $(".photo-thumbnail").click(function () {
+      // get the index (position in the array)
+      // of the photo we clicked on
+      // "this" is the element that was clicked on
+      // data("id") gets the attribute data-id
+      // (which we set to the index of the photo in
+      // the array - @index)
+      var index = $(this).data("id");
+
+      // set the current photo to this photo
+      current_photo = current_album.photos[index];
+
+      // displays the single photo template
+      showTemplate(photo_template, current_photo);
+    });
+  });
+
+  //
+  //  clicking on the slideshow tab displays the
+  //  current album as a slide show
+  //
+  $("#slideshow-tab").click(function () {
+    // display the slideshow template using the
+    // current album
+    showTemplate(slideshow_template, current_album);
+
+    // make the slideshow tab the active one
+    // first make the currently active tab inactive
+    $(".nav-tabs .active").removeClass("active");
+    // then make slideshow tab active
+    $("#slideshow-tab").addClass("active");
+  });
+
+  // start the page by showing the albums view
+  // we do this by virtually clicking on the
+  // albums tab
+  $("#albums-tab").click();
+});