Source:part.component.js

(function () {
	'use strict';
	// Main content component
	angular
		.module('mohistory')
		.component('part', {
			templateUrl: 'app/components/part/part.component.html',
			controller: partCtrl,
			controllerAs: 'part',
			bindings: {
				data: '<',
				searchResults: '<',
				calendar: '<',
				setFooterHidden: '<',
				footerHidden: '<',
			}
		});
	partCtrl.$inject = ['$state', '$stateParams'];
	/**
	 * Displays the part array pulled from the WordPress API
	 * @memberof mohistory
     * @name part
     * @ngdoc component
	 */
	function partCtrl($state, $stateParams) {
		var vm = this;
		/* ----- Variables ----- */
		vm.params = {};
		vm.stateName = '';
		vm.slideNum = 0;
		vm.slideLength = 0;
		vm.isSlideshowOpen = false;
		vm.slideshowStartIdx = 0;
		vm.locationLookup = {
            'MHS': 'Society',
            'LRC': 'Library',
            'MHM': 'Museum',
            'SM': 'Memorial',
            'Off-Site': 'Off-Site',
		};
		// Mapping of custom formIO URLs to their
		// custom submission URLs. If their is no
		// custom URL, submissions will be posted
		// straight back to formIO.
		vm.formIOCustSub = {
			'https://mhs.form.io/donation': 'http://data.mohistory.org/mhs-services-staging/FormHandler/donation',
		}
		/* ----- Functions ----- */
		vm.$onInit = onInit;
		vm.openSlideshow = openSlideshow;
		vm.closeSlideshow = closeSlideshow;
		vm.isArray = isArray;
		/**
		 * Variable setup
		 * @function onInit
		 * @memberof part
		 */
		function onInit() {
			vm.params = $stateParams;
			vm.stateName = $state.current.name;
		}
		/**
		 * Initiate the slide show at a given index.
		 * @function slideOn
		 * @memberof part
		 * @param {number} idx The index on which to start the slideshow
		 */
		function openSlideshow(idx) {
			vm.isSlideshowOpen = true;
			vm.slideshowStartIdx = idx;
		}
		/** 
		 * Close the image slide show.
		 * @function closeSlideshow
		 * @memberof part
		*/
		function closeSlideshow() {
			vm.isSlideshowOpen = false;
			vm.slideshowStartIdx = 0;
		}
		/**
		 * Determine if value is an array.
		 * @function isArray
		 * @memberof part
		 * @param {*} value An item to test
		 */
		function isArray(value) {
			return Array.isArray(value);
		}
	};
})();