Explorar o código

Just some reformatting.

Frederic G. MARAND %!s(int64=9) %!d(string=hai) anos
pai
achega
9fc8811000
Modificáronse 3 ficheiros con 206 adicións e 238 borrados
  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": {
   "globals": {
     "$": true,
     "$": true,
     "jQuery": true,
     "jQuery": true,
-    "React": true,
+    "Handlebars": 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
   },
   },
 
 
   "plugins": ["react"],
   "plugins": ["react"],
@@ -190,7 +163,7 @@ module.exports = {
     "array-bracket-spacing": [2, "never"],
     "array-bracket-spacing": [2, "never"],
     "indent": [2, 2, { SwitchCase: 1 }], // this option sets a specific tab width for your code (off by default)
     "indent": [2, 2, { SwitchCase: 1 }], // this option sets a specific tab width for your code (off by default)
     "brace-style": [2, "stroustrup", {"allowSingleLine": true}],
     "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-spacing": [1, {"before": false, "after": true}], // enforce spacing before and after comma
     "comma-style": [1, "last"], // enforce one true comma style (off by default)
     "comma-style": [1, "last"], // enforce one true comma style (off by default)
     "computed-property-spacing": [2, "never"],
     "computed-property-spacing": [2, "never"],
@@ -239,7 +212,7 @@ module.exports = {
     //
     //
     // These rules are only relevant to ES6 environments and are off by default.
     // 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)
     "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
 // The photos contain an image src and some metadata
 
 
 var gallery = {
 var gallery = {
-	albums : [
+  albums: [
-		{
+    {
-			name : "Travels",
+      name: "Travels",
-			thumbnail : "images/img_1.jpg",
+      thumbnail: "images/img_1.jpg",
-			photos : [
+      photos: [
-				{	
+        {
-					src : "images/img_1.jpg",
+          src: "images/img_1.jpg",
-					title : "grafitti",
+          title: "grafitti",
-					description : "some derelict appartments with grafitti"
+          description: "some derelict appartments with grafitti"
-				},
+        },
-				{
+        {
-					src : "images/img_6.jpg",
+          src: "images/img_6.jpg",
-					title : "fountain", 
+          title: "fountain",
-					description : "a huge dragon fountain"
+          description: "a huge dragon fountain"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_7.jpg",
+          src: "images/img_7.jpg",
-					title : "tower", 
+          title: "tower",
-					description : "a colourful tower block"
+          description: "a colourful tower block"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_8.jpg",
+          src: "images/img_8.jpg",
-					title : "walkways", 
+          title: "walkways",
-					description : "an interesting interior"
+          description: "an interesting interior"
-				} 
+        }
-			]
+      ]
-		},
+    },
-		{
+    {
-			name : "Equipment", 
+      name: "Equipment",
-			thumbnail : "images/img_4.jpg",
+      thumbnail: "images/img_4.jpg",
-			photos : [
+      photos: [
-				{	
+        {
-					src : "images/img_4.jpg",
+          src: "images/img_4.jpg",
-					title : "syths", 
+          title: "syths",
-					description : "all workshops should aspire to being this tidy"
+          description: "all workshops should aspire to being this tidy"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_9.jpg",
+          src: "images/img_9.jpg",
-					title : "helmet", 
+          title: "helmet",
-					description : "a sci-fi helmet"
+          description: "a sci-fi helmet"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_12.jpg",
+          src: "images/img_12.jpg",
-					title : "drums", 
+          title: "drums",
-					description : "a rather nice drum kit"
+          description: "a rather nice drum kit"
-				}  
+        }
-			]
+      ]
-		},
+    },
-		{
+    {
-			name : "English Winter", 
+      name: "English Winter",
-			thumbnail : "images/img_17.jpg",
+      thumbnail: "images/img_17.jpg",
-			photos : [
+      photos: [
-				{	
+        {
-					src : "images/img_16.jpg",
+          src: "images/img_16.jpg",
-					title : "dog in the snow", 
+          title: "dog in the snow",
-					description : "looks like he needs that jacket"
+          description: "looks like he needs that jacket"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_17.jpg",
+          src: "images/img_17.jpg",
-					title : "winter", 
+          title: "winter",
-					description : "a snowy scene in a park"
+          description: "a snowy scene in a park"
-				}, 
+        },
-				{	
+        {
-					src : "images/img_18.jpg",
+          src: "images/img_18.jpg",
-					title : "frosty pond", 
+          title: "frosty pond",
-					description : "some ducks feeling cold"
+          description: "some ducks feeling cold"
-				} 
+        }
-			]
+      ]
-		}
+    }
 
 
-	]
+  ]
-};
+};

+ 132 - 137
js/gallery.js

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