<commit_before>(function ($) {
	$.fn.teddybar = function (options) {
		var config = {
			document : document, // if iframe use : document.getElementById('iframe').contentWindow.document
			menu : {
				'Bold': 'bold',
				'Italic': 'italic',
				'Underline': 'underline',
				'Strikethrough': 'strikethrough',
				'-1': null,
				'Font Name': ['fontname', {'-- Font Name --': '0','Fontin': 'fontin', 'Latin': 'latin modern'}],
				'Font Size': ['fontsize', {'-- Font Size --': '0','1 (8pt)': '1', '2 (10pt)': '2','3 (12pt)': '3','4 (14pt)': '4','5 (18pt)': '5','6 (24pt)': '6','7 (36pt)': '7'}],
				'Format': ['formatblock', {'-- Block Format --': '0','Heading 1': 'h1','Heading 2': 'h2','Heading 3': 'h3','Heading 4': 'h4','Heading 5': 'h5','Heading 6': 'h6','Paragraph': 'p','Preformatted': 'pre'}],
				'-2': null,
				'Numbered List': 'insertorderedlist',
				'Unnumbered List': 'insertunorderedlist',
				'-3': null,
				'Justify Left': 'justifyleft',
				'Justify Right': 'justifyright',
				'Center': 'justifycenter',
				'Justify Full': 'justifyfull',
				'-4': null,
				'Undo': 'undo',
				'Redo': 'redo',
				'-5': null,
				//'Save': 'save'
			},
			commands : {
				// Enter your own commands here e.g. : 'save': function(){ alert('TODO') }
			}
		};
	        if (options) {
			$.extend(config.commands, options);
	        }
		return this.each(function () {
			var $this=$(this);
			var block = $('<ul>').appendTo($this);
			$.each(config.menu, function (name, command) {
				if (command == null) {
					// make a separator
					block = $('<ul>').appendTo($this);
				} else if (typeof command == 'string') {
					// make a button
					$('<input>', {"title": name, "type": "button", "value": name, "class": command, "data-command": command}).appendTo(block).wrap('<li>');
				} else {
					// make a select
					$('<select>', {"title": name, "data-command": command[0]}).appendTo(block).wrap('<li>');
					$.each(command[1], function(label, value) {
						$('select[data-command='+command[0]+']').append($('<option>', {"value":value}).html(label));
					});
				}
			});

			// execCommand on select elements
			$('select').change(function() {
				var command = $(this).attr('data-command');
				var value = $(this).val();
				if (command in config.commands) {
					config.commands[command](value);
				} else {
					config.document.execCommand(command,false,value);
				}
			});

			// execCommand on input elements
			$('input[type=button]').on('click', function () {
				var command = $(this).attr('data-command');
				if (command in config.commands) {
					config.commands[command]();
				} else {
					config.document.execCommand(command,false,'');
				}
			});

			// function that always puts the toolbar above the body
			$(window).resize(function() {
				$('body').css('margin-top',$this.height());
			});
		});
	};
})(jQuery);
<commit_msg>Add AGPL license<commit_after>// Copyright (C) 2011 Kozea
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

(function ($) {
	$.fn.teddybar = function (options) {
		var config = {
			document : document, // if iframe use : document.getElementById('iframe').contentWindow.document
			menu : {
				'Bold': 'bold',
				'Italic': 'italic',
				'Underline': 'underline',
				'Strikethrough': 'strikethrough',
				'-1': null,
				'Font Name': ['fontname', {'-- Font Name --': '0','Fontin': 'fontin', 'Latin': 'latin modern'}],
				'Font Size': ['fontsize', {'-- Font Size --': '0','1 (8pt)': '1', '2 (10pt)': '2','3 (12pt)': '3','4 (14pt)': '4','5 (18pt)': '5','6 (24pt)': '6','7 (36pt)': '7'}],
				'Format': ['formatblock', {'-- Block Format --': '0','Heading 1': 'h1','Heading 2': 'h2','Heading 3': 'h3','Heading 4': 'h4','Heading 5': 'h5','Heading 6': 'h6','Paragraph': 'p','Preformatted': 'pre'}],
				'-2': null,
				'Numbered List': 'insertorderedlist',
				'Unnumbered List': 'insertunorderedlist',
				'-3': null,
				'Justify Left': 'justifyleft',
				'Justify Right': 'justifyright',
				'Center': 'justifycenter',
				'Justify Full': 'justifyfull',
				'-4': null,
				'Undo': 'undo',
				'Redo': 'redo',
				'-5': null,
				//'Save': 'save'
			},
			commands : {
				// Enter your own commands here e.g. : 'save': function(){ alert('TODO') }
			}
		};
	        if (options) {
			$.extend(config.commands, options);
	        }
		return this.each(function () {
			var $this=$(this);
			var block = $('<ul>').appendTo($this);
			$.each(config.menu, function (name, command) {
				if (command == null) {
					// make a separator
					block = $('<ul>').appendTo($this);
				} else if (typeof command == 'string') {
					// make a button
					$('<input>', {"title": name, "type": "button", "value": name, "class": command, "data-command": command}).appendTo(block).wrap('<li>');
				} else {
					// make a select
					$('<select>', {"title": name, "data-command": command[0]}).appendTo(block).wrap('<li>');
					$.each(command[1], function(label, value) {
						$('select[data-command='+command[0]+']').append($('<option>', {"value":value}).html(label));
					});
				}
			});

			// execCommand on select elements
			$('select').change(function() {
				var command = $(this).attr('data-command');
				var value = $(this).val();
				if (command in config.commands) {
					config.commands[command](value);
				} else {
					config.document.execCommand(command,false,value);
				}
			});

			// execCommand on input elements
			$('input[type=button]').on('click', function () {
				var command = $(this).attr('data-command');
				if (command in config.commands) {
					config.commands[command]();
				} else {
					config.document.execCommand(command,false,'');
				}
			});

			// function that always puts the toolbar above the body
			$(window).resize(function() {
				$('body').css('margin-top',$this.height());
			});
		});
	};
})(jQuery);
<|endoftext|>


<commit_before>/**
 * Created by gjr8050 on 2/24/2017.
 */

const browserify = {
    files: {
        'public/dist/bundle.js': 'src/ng/app.module.js',
    },
    options: {
        alias: {
            angular: './scripts/angular.min.proxy.js',
            'angular-ui-router': './node_modules/angular-ui-router/release/angular-ui-router.min.js',
            'event-types': './node_modules/pulsar-lib/dist/src/event-types',
            'game-params': './node_modules/pulsar-lib/dist/src/game-params',
        },
        browserifyOptions: {
            paths: ['./node_modules', './src/'],
        },
    },
};

module.exports = (grunt) => {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        browserify: {
            dev: {
                files: browserify.files,
                options: {
                    alias: browserify.options.alias,
                    browserifyOptions: {
                        debug: true,
                        paths: ['./node_modules', './src/'],
                    },
                },
            },
            dist: browserify,
        },
        // jshint: {
        //     options: {
        //         jshintrc: true,
        //         reporter: require('jshint-stylish')
        //     },
        //     all: ['src/ng/**/*.js']
        // },
        clean: {
            all: ['public/dist/*'],
            pulsarDist: ['public/dist/*'],
            tmp: ['.tmp/*'],
        },
        copy: {
            prod: {
                files: [{expand: true,
                    src: [
                    // Pulsar
                    'public/dist/**/*.js',
                    'public/index.html',
                    'public/assets/**',
                    'public/views/**',

                    'src/**/*.js',
                    // angular js included in dist bundle
                    '!src/ng/**/*.js',

                    'LICENSE',
                    'tsconfig.json',
                    'package.json',
                ],
                    dest: '.tmp'}],
            },
            pulsarAssets: {
                files: [
                    { expand: true, cwd: 'pulsar/assets/fonts', src: ['*'], dest: 'pulsar/dist/fonts/'},
                ],
            },
        },
        watch: {
            js: {
                files: ['src/ng/**/*.js'],
                tasks: ['browserify:dev'],
            },
        },
    });

    grunt.loadNpmTasks('grunt-browserify');
    // grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask('default', ['build-dev']);

    grunt.registerTask('build-dev', [
        // 'jshint:all',
        'clean:pulsarDist',
        'browserify:dev',
        //'copy:pulsarAssets'
    ]);

    grunt.registerTask('build-prod', [
        // 'jshint:all',
        'clean:pulsarDist',
        'browserify:dist',
        // 'copy:pulsarAssets',
        'copy:prod',
        //'clean:pulsarDist'
    ]);
};
<commit_msg>include other tsconfig<commit_after>/**
 * Created by gjr8050 on 2/24/2017.
 */

const browserify = {
    files: {
        'public/dist/bundle.js': 'src/ng/app.module.js',
    },
    options: {
        alias: {
            angular: './scripts/angular.min.proxy.js',
            'angular-ui-router': './node_modules/angular-ui-router/release/angular-ui-router.min.js',
            'event-types': './node_modules/pulsar-lib/dist/src/event-types',
            'game-params': './node_modules/pulsar-lib/dist/src/game-params',
        },
        browserifyOptions: {
            paths: ['./node_modules', './src/'],
        },
    },
};

module.exports = (grunt) => {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        browserify: {
            dev: {
                files: browserify.files,
                options: {
                    alias: browserify.options.alias,
                    browserifyOptions: {
                        debug: true,
                        paths: ['./node_modules', './src/'],
                    },
                },
            },
            dist: browserify,
        },
        // jshint: {
        //     options: {
        //         jshintrc: true,
        //         reporter: require('jshint-stylish')
        //     },
        //     all: ['src/ng/**/*.js']
        // },
        clean: {
            all: ['public/dist/*'],
            pulsarDist: ['public/dist/*'],
            tmp: ['.tmp/*'],
        },
        copy: {
            prod: {
                files: [{expand: true,
                    src: [
                    // Pulsar
                    'public/dist/**/*.js',
                    'public/index.html',
                    'public/assets/**',
                    'public/views/**',

                    'src/**/*.js',
                    'src/tsconfig.json',
                    // angular js included in dist bundle
                    '!src/ng/**/*.js',

                    'LICENSE',
                    'tsconfig.json',
                    'package.json',
                ],
                    dest: '.tmp'}],
            },
            pulsarAssets: {
                files: [
                    { expand: true, cwd: 'pulsar/assets/fonts', src: ['*'], dest: 'pulsar/dist/fonts/'},
                ],
            },
        },
        watch: {
            js: {
                files: ['src/ng/**/*.js'],
                tasks: ['browserify:dev'],
            },
        },
    });

    grunt.loadNpmTasks('grunt-browserify');
    // grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask('default', ['build-dev']);

    grunt.registerTask('build-dev', [
        // 'jshint:all',
        'clean:pulsarDist',
        'browserify:dev',
        //'copy:pulsarAssets'
    ]);

    grunt.registerTask('build-prod', [
        // 'jshint:all',
        'clean:pulsarDist',
        'browserify:dist',
        // 'copy:pulsarAssets',
        'copy:prod',
        //'clean:pulsarDist'
    ]);
};
<|endoftext|>


<commit_before>$(document).ready(function() {
  $(document).on('change', '.question-answered-box', function(){
    the_id = $(this).data('the-id')
    text_answer_field = $(this).closest('.text-answer').find('.text-answer-field')
    if($(this).prop('checked')) {
      $(text_answer_field).attr("readonly", true)
      $(text_answer_field).addClass("disabled")
      $("input[name='answers["+the_id+"]']:radio").attr("disabled", true)
      $("li.answer-option-"+the_id+" textarea").attr("disabled", true)
    }
    else {
      $(text_answer_field).attr("disabled", false)
      $(text_answer_field).attr("readonly", false)
      $(text_answer_field).removeClass("disabled")
      $("input[name='answers["+the_id+"]']:radio").attr("disabled", false)
      $("li.answer-option-"+the_id+" textarea").attr("disabled", false)
      $('.sticky_save_all').click();
    }
  });
});
<commit_msg>Disable dropdown when question marked as answered<commit_after>$(document).ready(function() {
  $(document).on('change', '.question-answered-box', function(){
    the_id = $(this).data('the-id')
    text_answer_field = $(this).closest('.text-answer').find('.text-answer-field')
    if($(this).prop('checked')) {
      $(text_answer_field).attr("readonly", true)
      $(text_answer_field).addClass("disabled")
      $("input[name='answers["+the_id+"]']:radio").attr("disabled", true)
      $("li.answer-option-"+the_id+" textarea").attr("disabled", true)
      $("select#answers_"+the_id).attr("disabled", true)
    }
    else {
      $(text_answer_field).attr("disabled", false)
      $(text_answer_field).attr("readonly", false)
      $(text_answer_field).removeClass("disabled")
      $("input[name='answers["+the_id+"]']:radio").attr("disabled", false)
      $("li.answer-option-"+the_id+" textarea").attr("disabled", false)
      $("select#answers_"+the_id).attr("disabled", false)
      $('.sticky_save_all').click();
    }
  });
});
<|endoftext|>


<commit_before>module.exports = function(grunt){
  grunt.initConfig({

    browserify: {
      dist: {
        src: 'src/**/*.js',
        dest: 'dist/landmine.js'
      }
    },

    uglify: {
      options: {
        banner: '//landmine.js\n'
      },
      dist: {
        files: {
          'dist/landmine.min.js': ['<%= browserify.dist.dest %>']
        }
      }
    },

    jshint: {
      files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          module: true,
          document: true,
          describe: true,
          it: true,
          beforeEach: true,
          require: true,
          setInterval: true,
          clearInterval: true,
          window: true,
          setTimeout: true
        },
        ignores: ['src/intro.js', 'src/outro.js'],
        curly: true,
        eqeqeq: true,
        forin: true,
        indent: 2,
        latedef: true,
        newcap: true,
        undef: true,
        unused: true,
        trailing: true
      }
    },
    mochaTest: {
      tdd: {
        options: {
          growl : true
        },
        src: ['test/**/*.js']
      },
      build: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/*.js'],
      tasks: ['jshint', 'mochaTest:tdd', 'browserify', 'uglify']
      },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
	commit: true,
	commitMessage: 'Release v%VERSION%',
	commitFiles: ['package.json', 'bower.json'],
	createTag: true,
	tagName: 'v%VERSION%',
	tagMessage: 'Version %VERSION%',
	push: false
      }
    }
    });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-bump');

  grunt.registerTask('default', ['jshint', 'mochaTest:build', 'browserify', 'uglify']);
  grunt.registerTask('test', ['jshint', 'mochaTest:build']);
  grunt.registerTask('release', ['default', 'bump']);
};
<commit_msg>Add dist folder to release commit<commit_after>module.exports = function(grunt){
  grunt.initConfig({

    browserify: {
      dist: {
        src: 'src/**/*.js',
        dest: 'dist/landmine.js'
      }
    },

    uglify: {
      options: {
        banner: '//landmine.js\n'
      },
      dist: {
        files: {
          'dist/landmine.min.js': ['<%= browserify.dist.dest %>']
        }
      }
    },

    jshint: {
      files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          module: true,
          document: true,
          describe: true,
          it: true,
          beforeEach: true,
          require: true,
          setInterval: true,
          clearInterval: true,
          window: true,
          setTimeout: true
        },
        ignores: ['src/intro.js', 'src/outro.js'],
        curly: true,
        eqeqeq: true,
        forin: true,
        indent: 2,
        latedef: true,
        newcap: true,
        undef: true,
        unused: true,
        trailing: true
      }
    },
    mochaTest: {
      tdd: {
        options: {
          growl : true
        },
        src: ['test/**/*.js']
      },
      build: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/*.js'],
      tasks: ['jshint', 'mochaTest:tdd', 'browserify', 'uglify']
      },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
	commit: true,
	commitMessage: 'Release v%VERSION%',
	commitFiles: ['package.json', 'bower.json', 'dist/*.js'],
	createTag: true,
	tagName: 'v%VERSION%',
	tagMessage: 'Version %VERSION%',
	push: false
      }
    }
    });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-bump');

  grunt.registerTask('default', ['jshint', 'mochaTest:build', 'browserify', 'uglify']);
  grunt.registerTask('test', ['jshint', 'mochaTest:build']);
  grunt.registerTask('release', ['default', 'bump']);
};
<|endoftext|>


<commit_before>// handles search filter toggle functionality
define(
	function() {
  'use strict';

  	// PRIVATE PROPERTIES
  	var _fieldsets = {}; // set of all fieldsets

  	// main module initialization
  	function init()
  	{
			// capture form submission
			var searchForm = document.getElementById("search-form");
			searchForm.addEventListener("submit",_formSubmitted,false);

			// initialize fieldsets
			var fieldsets = document.querySelectorAll('#search-box fieldset');
			var numFieldsets = fieldsets.length;
			var fs; // individual fieldset

			// instantiate new fieldset objects and place in set of fieldsets
			for (var f = 0; f < numFieldsets; f++)
			{
	      fs = new Fieldset();
	      fs.init(fieldsets[f]);
	      _fieldsets[fs.getId()] = fs;
	    }
  	}

  	// Handle form submission
  	function _formSubmitted(evt)
		{
			var form = evt.target;
			var input;

			for (var f in _fieldsets)
			{
				input = _fieldsets[f].getInput();
				if (input && input.value != "")
				{
					_fieldsets[f].getHidden().value = input.getAddInput().value;
					input.disabled = true;
				}
			}

			var count = 0;
			while(form[count] != undefined)
			{
				input = form[count++];
				if (input.value == "" || (input.type == "radio" || input.type == "checkbox"))
					input.disabled = true;
			}

			form.submit();

			evt.preventDefault();
			return false;
		}

		// New ToggleGroup instance constructor
  	var ToggleGroup = function()
  	{
  		var _group; // the group around a toggle
			var _toggle; // the actual toggle input element (radio or checkbox)
			var _label; // the toggle's label element

			var _isCurrentToggle = false;
			var _isAddToggle = false; // the add toggle (if present)
			var _addInput; // the add input text field
			var _addInputLabel; // the add input label
			var _addInputShowing = false; // whether or not the add input field is showing

			function init(tGroup)
			{
				_group = tGroup;
				_toggle = _group.querySelector(".toggle input");
				_label = _group.querySelector("div+label");

				_addInput = _label.querySelector("input");
				_isAddToggle = (_addInput) ? true : false;

				if (_isAddToggle)
					_addInputLabel = _label.querySelector("span");
				else
					_isCurrentToggle = (_group.parentNode.classList.contains("current-option"));
			}

			// Show the add input text field.
			function showAddInput()
			{
				if (_isAddToggle && !_addInputShowing)
				{
					_addInputLabel.classList.add('hide'); // hide "Add..." text
					_addInput.classList.remove('hide'); // show input field
					_addInputShowing = true;
					setTimeout(function() { _addInput.focus(); }, 0);
				}
			}

			// Hide the add input text field.
			function hideAddInput()
			{
				if (_isAddToggle && _addInputShowing)
				{
					_addInput.value = ""; // clear input field value
					_addInput.classList.add('hide'); // hide input field
					_addInputLabel.classList.remove('hide'); // show "Add..." text
					_addInputShowing = false;
				}
			}

			// Set the label's text value.
			function setLabel(value)
			{
				if (_isAddToggle)
					_addInputLabel.innerHTML = value;
				else
					_label.innerHTML = value;
			}

			// GETTERS
			function getToggle()
			{
				return _toggle;
			}

			function getAddInput()
			{
				return _addInput;
			}

			function isAddToggle()
			{
				return _isAddToggle;
			}

			function addInputShowing()
			{
				return _addInputShowing;
			}

			return {
				init:init,
				isAddToggle:isAddToggle,
				showAddInput:showAddInput,
				hideAddInput:hideAddInput,
				setLabel:setLabel,
				getToggle:getToggle,
				getAddInput:getAddInput,
				addInputShowing:addInputShowing
			};
  	}

		// New Fieldset instance constructor
  	var Fieldset = function() {

  		// fieldset components
  		var _fieldset; // the fieldset element
  		var _id; // the fieldset element's id
  		var _legend; // the fieldset's legend
  		var _toggleGroupContainers; // the container for all toggles
  		var _toggleGroups = {}; // array of toggles radio-groups

  		var _highlightToggle; // the currently show toggle when fieldset is closed
  		var _allToggle; // the "All" toggle
  		var _selectedToggle; // the currently selected toggle
  		var _addInputToggle; // add input toggle

  		var _hidden; // the fieldset's hidden input that's used for form submission

			function init(fieldset)
			{
				_fieldset = fieldset;
				_id = _fieldset.id;

				_legend = _fieldset.querySelector("legend");

				_toggleGroupContainers 		= _fieldset.querySelectorAll(".options");
				_hidden 									= _fieldset.querySelector("input[type=hidden]");

				var container;
				var groups;
				var group;
				var toggle;

				for (var c = 0; c < _toggleGroupContainers.length; c++)
				{
					groups = _toggleGroupContainers[c].querySelectorAll(".toggle-group");
					for (var g = 0; g < groups.length; g++)
					{
						group = groups[g];
						toggle = new ToggleGroup();
						toggle.init(group);
						_toggleGroups[group.id] = toggle;
						if (toggle.getToggle().checked && c>0)
							_selectedToggle = toggle;
						group.addEventListener("mousedown",_toggleClicked,false);
					}
					_highlightToggle = _highlightToggle || _toggleGroups[groups[0].id];
					if (c > 0)
						_allToggle = _allToggle || _toggleGroups[groups[0].id];
				}
				var addInputToggle = _toggleGroups[groups[groups.length-1].id];
				_addInputToggle = addInputToggle.isAddToggle() ? addInputToggle : null;

				// setup event listeners
				_legend.addEventListener('mousedown',_legendClicked,false);
			}

			// EVENT HANDLERS
			// The legend was clicked.
			function _legendClicked(evt)
			{
				_toggleFilter();
			}

			// Toggle clicked event handler.
			function _toggleClicked(evt)
			{
				var current = evt.target; // the current clicked target
				var toggleGroup = _toggleGroups[evt.currentTarget.id]; // the current toggle group

				var toggle = toggleGroup.getToggle(); // the current toggle input

				// Whether the toggle input or associated label was clicked or not.
				var toggleClicked = (toggle == current || current.getAttribute("for") == toggle.id);

				// If the toggle was not directly clicked, then some other element
				// (such as a div) was clicked in the toggle group, so we need
				// to manually switch the checked state of the toggle.
				// Logic to handle radio buttons and checkboxes differs slightly
				// as clicking a radio button will always set checked to true
				// whereas clicking a check box will toggle its value.
				if (!toggleClicked)
				{
					if (toggle.type == "radio")
						toggle.checked = true;
					else if (toggle.type == "checkbox")
						toggle.checked = !toggle.checked;
				}

				// Toggle filters.
				if (toggleGroup == _highlightToggle)
				{
					_toggleFilter();
				}
				else if (toggleGroup == _addInputToggle)
				{
					_toggleAddInputFilter(current);
				}
				else if (toggleGroup == _selectedToggle)
				{
					_toggleFilter();
				}
				else
				{
					_selectedToggle = toggleGroup;

					// hide add input if selected toggle is not the add input toggle
					if (_selectedToggle != _addInputToggle)
						_addInputToggle.hideAddInput();
				}

			}

			// Toggle visible toggle group container. Which means either the
			// currently selected toggle or list of toggles will be visible.
			function _toggleFilter()
			{
				if (_legend.className == 'open')
				{
					// Check if add input value has a value.
					// If it doesn't and the add input toggle is selected
					// uncheck the selected toggle and check the "All"
					// toggle and set the selected toggle to "All".
					var inputVal = _addInputToggle.getAddInput().value;
					if (_selectedToggle == _addInputToggle && inputVal == "")
					{
						_selectedToggle.getToggle().checked = false;
						_selectedToggle.hideAddInput();
						_selectedToggle = _allToggle;
						_allToggle.getToggle().checked = true;
					}

					var toggle = _selectedToggle.getToggle();
					_highlightToggle.setLabel(
						toggle.getAttribute("data-display-value") ||
						inputVal ||
						toggle.value ||
						"All");

					_toggleGroupContainers[1].classList.add('hide');
					_toggleGroupContainers[0].classList.remove('hide');
					_legend.className = 'closed';
				}
				else
				{
					_toggleGroupContainers[1].classList.remove('hide');
					_toggleGroupContainers[0].classList.add('hide');
					_legend.className = 'open';
				}
			}

			function _toggleAddInputFilter(clicked)
			{
				if (_selectedToggle == _addInputToggle)
				{
					if (clicked.type != "search")
						_toggleFilter();
				}
				else
				{
					_selectedToggle = _addInputToggle;
					_selectedToggle.showAddInput();
				}
			}

			// GETTERS
			// Publically exposed getters for properties
			function getId()
			{
				return _id;
			}

			function getInput()
			{
				return _addInputToggle;
			}

			function getHidden()
			{
				return _hidden;
			}

    return {
      init:init,
      getId:getId,
      getInput:getInput,
      getHidden:getHidden
    };

  };

	return {
		init:init
	};
});<commit_msg>Fixes bug where error was thrown when filters didn't have an add button<commit_after>// handles search filter toggle functionality
define(
	function() {
  'use strict';

  	// PRIVATE PROPERTIES
  	var _fieldsets = {}; // set of all fieldsets

  	// main module initialization
  	function init()
  	{
			// capture form submission
			var searchForm = document.getElementById("search-form");
			searchForm.addEventListener("submit",_formSubmitted,false);

			// initialize fieldsets
			var fieldsets = document.querySelectorAll('#search-box fieldset');
			var numFieldsets = fieldsets.length;
			var fs; // individual fieldset

			// instantiate new fieldset objects and place in set of fieldsets
			for (var f = 0; f < numFieldsets; f++)
			{
	      fs = new Fieldset();
	      fs.init(fieldsets[f]);
	      _fieldsets[fs.getId()] = fs;
	    }
  	}

  	// Handle form submission
  	function _formSubmitted(evt)
		{
			var form = evt.target;
			var input;

			for (var f in _fieldsets)
			{
				input = _fieldsets[f].getInput();
				if (input && input.value != "")
				{
					_fieldsets[f].getHidden().value = input.getAddInput().value;
					input.disabled = true;
				}
			}

			var count = 0;
			while(form[count] != undefined)
			{
				input = form[count++];
				if (input.value == "" || (input.type == "radio" || input.type == "checkbox"))
					input.disabled = true;
			}

			form.submit();

			evt.preventDefault();
			return false;
		}

		// New ToggleGroup instance constructor
  	var ToggleGroup = function()
  	{
  		var _group; // the group around a toggle
			var _toggle; // the actual toggle input element (radio or checkbox)
			var _label; // the toggle's label element

			var _isCurrentToggle = false;
			var _isAddToggle = false; // the add toggle (if present)
			var _addInput; // the add input text field
			var _addInputLabel; // the add input label
			var _addInputShowing = false; // whether or not the add input field is showing

			function init(tGroup)
			{
				_group = tGroup;
				_toggle = _group.querySelector(".toggle input");
				_label = _group.querySelector("div+label");

				_addInput = _label.querySelector("input");
				_isAddToggle = (_addInput) ? true : false;

				if (_isAddToggle)
					_addInputLabel = _label.querySelector("span");
				else
					_isCurrentToggle = (_group.parentNode.classList.contains("current-option"));
			}

			// Show the add input text field.
			function showAddInput()
			{
				if (_isAddToggle && !_addInputShowing)
				{
					_addInputLabel.classList.add('hide'); // hide "Add..." text
					_addInput.classList.remove('hide'); // show input field
					_addInputShowing = true;
					setTimeout(function() { _addInput.focus(); }, 0);
				}
			}

			// Hide the add input text field.
			function hideAddInput()
			{
				if (_isAddToggle && _addInputShowing)
				{
					_addInput.value = ""; // clear input field value
					_addInput.classList.add('hide'); // hide input field
					_addInputLabel.classList.remove('hide'); // show "Add..." text
					_addInputShowing = false;
				}
			}

			// Set the label's text value.
			function setLabel(value)
			{
				if (_isAddToggle)
					_addInputLabel.innerHTML = value;
				else
					_label.innerHTML = value;
			}

			// GETTERS
			function getToggle()
			{
				return _toggle;
			}

			function getAddInput()
			{
				return _addInput;
			}

			function isAddToggle()
			{
				return _isAddToggle;
			}

			function addInputShowing()
			{
				return _addInputShowing;
			}

			return {
				init:init,
				isAddToggle:isAddToggle,
				showAddInput:showAddInput,
				hideAddInput:hideAddInput,
				setLabel:setLabel,
				getToggle:getToggle,
				getAddInput:getAddInput,
				addInputShowing:addInputShowing
			};
  	}

		// New Fieldset instance constructor
  	var Fieldset = function() {

  		// fieldset components
  		var _fieldset; // the fieldset element
  		var _id; // the fieldset element's id
  		var _legend; // the fieldset's legend
  		var _toggleGroupContainers; // the container for all toggles
  		var _toggleGroups = {}; // array of toggles radio-groups

  		var _highlightToggle; // the currently show toggle when fieldset is closed
  		var _allToggle; // the "All" toggle
  		var _selectedToggle; // the currently selected toggle
  		var _addInputToggle; // add input toggle

  		var _hidden; // the fieldset's hidden input that's used for form submission

			function init(fieldset)
			{
				_fieldset = fieldset;
				_id = _fieldset.id;

				_legend = _fieldset.querySelector("legend");

				_toggleGroupContainers 		= _fieldset.querySelectorAll(".options");
				_hidden 									= _fieldset.querySelector("input[type=hidden]");

				var container;
				var groups;
				var group;
				var toggle;

				for (var c = 0; c < _toggleGroupContainers.length; c++)
				{
					groups = _toggleGroupContainers[c].querySelectorAll(".toggle-group");
					for (var g = 0; g < groups.length; g++)
					{
						group = groups[g];
						toggle = new ToggleGroup();
						toggle.init(group);
						_toggleGroups[group.id] = toggle;
						if (toggle.getToggle().checked && c>0)
							_selectedToggle = toggle;
						group.addEventListener("mousedown",_toggleClicked,false);
					}
					_highlightToggle = _highlightToggle || _toggleGroups[groups[0].id];
					if (c > 0)
						_allToggle = _allToggle || _toggleGroups[groups[0].id];
				}
				var addInputToggle = _toggleGroups[groups[groups.length-1].id];
				_addInputToggle = addInputToggle.isAddToggle() ? addInputToggle : null;

				// setup event listeners
				_legend.addEventListener('mousedown',_legendClicked,false);
			}

			// EVENT HANDLERS
			// The legend was clicked.
			function _legendClicked(evt)
			{
				_toggleFilter();
			}

			// Toggle clicked event handler.
			function _toggleClicked(evt)
			{
				var current = evt.target; // the current clicked target
				var toggleGroup = _toggleGroups[evt.currentTarget.id]; // the current toggle group

				var toggle = toggleGroup.getToggle(); // the current toggle input

				// Whether the toggle input or associated label was clicked or not.
				var toggleClicked = (toggle == current || current.getAttribute("for") == toggle.id);

				// If the toggle was not directly clicked, then some other element
				// (such as a div) was clicked in the toggle group, so we need
				// to manually switch the checked state of the toggle.
				// Logic to handle radio buttons and checkboxes differs slightly
				// as clicking a radio button will always set checked to true
				// whereas clicking a check box will toggle its value.
				if (!toggleClicked)
				{
					if (toggle.type == "radio")
						toggle.checked = true;
					else if (toggle.type == "checkbox")
						toggle.checked = !toggle.checked;
				}

				// Toggle filters.
				if (toggleGroup == _highlightToggle)
				{
					_toggleFilter();
				}
				else if (toggleGroup == _addInputToggle)
				{
					_toggleAddInputFilter(current);
				}
				else if (toggleGroup == _selectedToggle)
				{
					_toggleFilter();
				}
				else
				{
					_selectedToggle = toggleGroup;

					// hide add input if selected toggle is not the add input toggle
					if (_addInputToggle && _selectedToggle != _addInputToggle)
						_addInputToggle.hideAddInput();
				}

			}

			// Toggle visible toggle group container. Which means either the
			// currently selected toggle or list of toggles will be visible.
			function _toggleFilter()
			{
				if (_legend.className == 'open')
				{
					// Check if add input value has a value.
					// If it doesn't and the add input toggle is selected
					// uncheck the selected toggle and check the "All"
					// toggle and set the selected toggle to "All".
					var inputVal = _addInputToggle.getAddInput().value;
					if (_selectedToggle == _addInputToggle && inputVal == "")
					{
						_selectedToggle.getToggle().checked = false;
						_selectedToggle.hideAddInput();
						_selectedToggle = _allToggle;
						_allToggle.getToggle().checked = true;
					}

					var toggle = _selectedToggle.getToggle();
					_highlightToggle.setLabel(
						toggle.getAttribute("data-display-value") ||
						inputVal ||
						toggle.value ||
						"All");

					_toggleGroupContainers[1].classList.add('hide');
					_toggleGroupContainers[0].classList.remove('hide');
					_legend.className = 'closed';
				}
				else
				{
					_toggleGroupContainers[1].classList.remove('hide');
					_toggleGroupContainers[0].classList.add('hide');
					_legend.className = 'open';
				}
			}

			function _toggleAddInputFilter(clicked)
			{
				if (_selectedToggle == _addInputToggle)
				{
					if (clicked.type != "search")
						_toggleFilter();
				}
				else
				{
					_selectedToggle = _addInputToggle;
					_selectedToggle.showAddInput();
				}
			}

			// GETTERS
			// Publically exposed getters for properties
			function getId()
			{
				return _id;
			}

			function getInput()
			{
				return _addInputToggle;
			}

			function getHidden()
			{
				return _hidden;
			}

    return {
      init:init,
      getId:getId,
      getInput:getInput,
      getHidden:getHidden
    };

  };

	return {
		init:init
	};
});<|endoftext|>


<commit_before>// Generated on 2014-09-19 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: []
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all', 'newer:jscs:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jscs: {
            options: {
                config: '.jscsrc'
            },
            all: {
                src: '<%= yeoman.app %>/scripts/{,*/}*.js'
            },
            test: {
                src: '<%= yeoman.app %>/scripts/{,*/}*.js'
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/{,*/}*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: ['*.js', '!oldieshim.js'],
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/{,*/}*.html',
                        'images/{,*/}*.{webp}',
                        'fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'bower_components/bootstrap/dist',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }
        if (target === 'dist-light') {
            return grunt.task.run(['build-light', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
//      'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
//    'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
//    'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('build-light', [
        'clean:dist',
//    'wiredep',
//    'useminPrepare',
        'concurrent:dist',
//    'autoprefixer',
//    'concat',
        'ngAnnotate',
        'copy:dist',
//    'cdnify',
//    'cssmin',
//    'uglify',
//    'filerev',
//    'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'newer:jscs',
        'test',
        'build'
    ]);
};
<commit_msg>Enabled access from outside<commit_after>// Generated on 2014-09-19 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: []
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all', 'newer:jscs:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: '0.0.0.0',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jscs: {
            options: {
                config: '.jscsrc'
            },
            all: {
                src: '<%= yeoman.app %>/scripts/{,*/}*.js'
            },
            test: {
                src: '<%= yeoman.app %>/scripts/{,*/}*.js'
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/{,*/}*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: ['*.js', '!oldieshim.js'],
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/{,*/}*.html',
                        'images/{,*/}*.{webp}',
                        'fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'bower_components/bootstrap/dist',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }
        if (target === 'dist-light') {
            return grunt.task.run(['build-light', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
//      'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
//    'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
//    'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('build-light', [
        'clean:dist',
//    'wiredep',
//    'useminPrepare',
        'concurrent:dist',
//    'autoprefixer',
//    'concat',
        'ngAnnotate',
        'copy:dist',
//    'cdnify',
//    'cssmin',
//    'uglify',
//    'filerev',
//    'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'newer:jscs',
        'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>/*
 * client.js: Client object responsible for managing Producers attached to a TCP or UDP client.
 *
 * (C) 2012, Nodejitsu Inc.
 *
 */

var dgram = require('dgram'),
    net = require('net'),
    utile = require('utile'),
    ip = require('ip'),
    clone = utile.clone,
    back = require('back'),
    EventEmitter = require('events').EventEmitter,
    noop = function () {};

//
// ### function Server (options)
// #### @options {Object} Options for this server
// ####   @options.type      {udp|tcp} Networking protocol of this server.
// ####   @options.producers {Array}   Set of producers to get data from.
// ####   @options.host      {string}  Host to send producer data to.
// ####   @options.port      {Number}  Port to send producer data to.
// Constructor function for the Client object responsible for managing
// Producers attached to a TCP or UDP client.
//
var Client = module.exports = function Client(options) {
  EventEmitter.call(this);

  if (!options || !options.type
      || !~['tcp', 'udp', 'unix'].indexOf(options.type)) {
    throw new Error('Cannot create client without type: udp, tcp, unix');
  }

  if(typeof options.reconnect !== 'undefined'
     && typeof options.reconnect!== 'object') {
    throw new Error('Reconnect must be a defined object if used')
  }

  var self = this;

  this.type      = options.type;
  this.host      = options.host;
  this.port      = options.port;
  this.path      = options.path;
  this.reconnect = options.reconnect;
  this.attempt = null;
  this.producers = {};
  this.handlers  = {
    data: {},
    end:  {}
  };
  this.defaults = {
    host: ip.address(),
    state: 'ok',
    description: 'No Description',
    tags: [],
    metric: 1,
    ttl: 15000
  };

  if (Array.isArray(options.producers)) {
    options.producers.forEach(function (producer) {
      self.add(producer);
    });
  }
};

//
// Inherit from EventEmitter
//
utile.inherits(Client, EventEmitter);

//
// ### function add (producer)
// #### @producer {Producer} Producer to add to this server
// Adds the specified `producer` to this client. All data
// from the producer will be sent over the underlying
// network connection.
//
Client.prototype.add = function (producer) {
  var self = this,
      id = producer.id;

  this.producers[producer.id] = producer;

  producer.on('end', this.handlers.end[producer.id] = function () {
    self.remove(producer, id);
  });

  producer.on('data', this.handlers.data[producer.id] = function (data) {
    //
    // Ignore data until we have a socket
    //
    if (self.socket) {
      self.write(data);
    }
  });
};

//
// ### function remove (reactor)
// #### @producer {producer} Producer to remove from this client.
// Removes the specified `producer` from this client. All data
// from the producer will no longer be sent over the underlying
// network connection.
//
Client.prototype.remove = function (producer, id) {
  id = id || producer.id;

  producer.removeListener('data', this.handlers.data[id]);
  producer.removeListener('end',  this.handlers.end[id]);
  delete this.producers[id];
  delete this.handlers.data[id];
  delete this.handlers.end[id];
};

//
// ### function write (data)
// #### @data {Object} Data to write.
// Writes the specified `data` to the underlying network
// connection associated with this client.
//
Client.prototype.write = function (data) {
  var message = !Array.isArray(data)
    ? JSON.stringify(data) + '\n'
    : data.map(JSON.stringify).join('\n') + '\n'

  if (this.type === 'tcp' || this.type === 'unix') {
    this.socket.write(message);
  }
  else if (this.type === 'udp') {
    message = new Buffer(message);
    this.socket.send(message, 0, message.length, this.port, this.host);
  }
};

//
// ### function produce (data)
// #### @data {Object|Array} Data to write to socket with some extras
// Writes to a socket with some default values attached.
// This is purely a convenience method
//
Client.prototype.produce = function (data) {
  var self = this;
  //
  // Add defaults to each object where a value does not already exist
  //
  function defaultify (obj) {
    return Object.keys(self.defaults).reduce(function (acc, key) {
      if (!acc[key]) { acc[key] = self.defaults[key] }
      return acc;
    }, obj);
  }

  //
  // TODO: we may want to be monotonic here
  //
  this.defaults['time'] = Date.now();
  data = !Array.isArray(data)
    ? defaultify(data)
    : data.map(defaultify);

  return this.write(data);
};

//
// ### function connect (callback)
// #### @port {Number} **Optional** Port number to connect on.
// #### @host {String} **Optional** Host to connect to.
// #### @callback {function} **Optional** Continuation to respond to.
// Opens the underlying network connection for this client.
//
Client.prototype.connect = function (port, host, callback) {
  var self = this;

  //
  // Do some fancy arguments parsing to support everything
  // being optional.
  //
  if (!callback && typeof host === 'function') {
    callback = host;
    host = null;
  }

  Array.prototype.slice.call(arguments).forEach(function (arg) {
    switch (typeof arg) {
      case 'number':   port = arg; break;
      case 'string':   host = arg; break;
      case 'function': callback = arg; break;
    }
  });

  function error (arg) {
    var err = new Error(arg + ' required to connect');
    return callback
      ? callback(err)
      : self.emit('error', err) ;
  }

  function reconnect(err) {
    self.attempt = self.attempt || clone(self.reconnect);
    //
    // Remark: Terminate the backoff when we have hit our fail condition with
    // a noop to avoid an if statement
    //
    // TODO: Make this less coupled (I feel like i want this contained in
    // `back` but eh)
    //
    return self.terminate
      ? noop()
      : back(function (fail, backoff) {
        //
        // Remark: We are done here, emit error and set termination
        //
        if (fail) {
          self.terminate = true;
          self.attempt = null;
          return self.emit('error', err);
        }
        //
        // So we can listen on when reconnect events are about to fire
        //
        self.emit('reconnect', backoff);
        //
        // Attempt a CONNECT!
        //
        return connect();
      }, self.attempt);
  }

  function onError(err) {
    return self.reconnect
      ? reconnect(err)
      : self.emit('error', err);
  }

  function connect() {
    if (self.type === 'tcp') {
      self.socket = net.connect({ port: self.port, host: self.host }, callback);
    }
    else if (self.type === 'udp') {
      self.socket = dgram.createSocket('udp4');
      if (callback) {
        process.nextTick(callback);
      }
    }
    else if (self.type === 'unix') {
      self.socket = net.connect({ path: self.path }, callback);
    }

    self.socket.on('error', onError);
    self.socket.on('connect', function () {
      //
      // Remark: We have successfully connected so reset the terminate variable
      //
      self.terminate = false;
      self.emit('connect');
    });
  }

  // Split cases due to unix using `this.path`
  if (this.type === 'tcp' || this.type === 'udp') {
    this.port = port || this.port;
    this.host = host || this.host || '0.0.0.0';

    if (!this.host || !this.port) {
      error('host and port are');
    }
  }
  else if (this.type === 'unix') {
    this.path = host || this.path;

    if (!this.path) {
      error('path is');
    }
  }

  connect();
};

//
// ### function close ()
// Closes the underlying network connection for this client.
//
Client.prototype.close = function () {
  var self = this;

  if (this.type === 'tcp' || this.type === 'unix') {
    this.socket.destroy();
  }
  else if (this.type === 'udp') {
    this.socket.close();
  }

  Object.keys(this.producers).forEach(function (id) {
    self.remove(self.producers[id]);
  });

  this.socket.on('close', function () {
    self.emit('close');
  });
};
<commit_msg>[fix] properly handle a single callback as an argument to the connect function<commit_after>/*
 * client.js: Client object responsible for managing Producers attached to a TCP or UDP client.
 *
 * (C) 2012, Nodejitsu Inc.
 *
 */

var dgram = require('dgram'),
    net = require('net'),
    utile = require('utile'),
    ip = require('ip'),
    clone = utile.clone,
    back = require('back'),
    EventEmitter = require('events').EventEmitter,
    noop = function () {};

//
// ### function Server (options)
// #### @options {Object} Options for this server
// ####   @options.type      {udp|tcp} Networking protocol of this server.
// ####   @options.producers {Array}   Set of producers to get data from.
// ####   @options.host      {string}  Host to send producer data to.
// ####   @options.port      {Number}  Port to send producer data to.
// Constructor function for the Client object responsible for managing
// Producers attached to a TCP or UDP client.
//
var Client = module.exports = function Client(options) {
  EventEmitter.call(this);

  if (!options || !options.type
      || !~['tcp', 'udp', 'unix'].indexOf(options.type)) {
    throw new Error('Cannot create client without type: udp, tcp, unix');
  }

  if(typeof options.reconnect !== 'undefined'
     && typeof options.reconnect!== 'object') {
    throw new Error('Reconnect must be a defined object if used')
  }

  var self = this;

  this.type      = options.type;
  this.host      = options.host;
  this.port      = options.port;
  this.path      = options.path;
  this.reconnect = options.reconnect;
  this.attempt = null;
  this.producers = {};
  this.handlers  = {
    data: {},
    end:  {}
  };
  this.defaults = {
    host: ip.address(),
    state: 'ok',
    description: 'No Description',
    tags: [],
    metric: 1,
    ttl: 15000
  };

  if (Array.isArray(options.producers)) {
    options.producers.forEach(function (producer) {
      self.add(producer);
    });
  }
};

//
// Inherit from EventEmitter
//
utile.inherits(Client, EventEmitter);

//
// ### function add (producer)
// #### @producer {Producer} Producer to add to this server
// Adds the specified `producer` to this client. All data
// from the producer will be sent over the underlying
// network connection.
//
Client.prototype.add = function (producer) {
  var self = this,
      id = producer.id;

  this.producers[producer.id] = producer;

  producer.on('end', this.handlers.end[producer.id] = function () {
    self.remove(producer, id);
  });

  producer.on('data', this.handlers.data[producer.id] = function (data) {
    //
    // Ignore data until we have a socket
    //
    if (self.socket) {
      self.write(data);
    }
  });
};

//
// ### function remove (reactor)
// #### @producer {producer} Producer to remove from this client.
// Removes the specified `producer` from this client. All data
// from the producer will no longer be sent over the underlying
// network connection.
//
Client.prototype.remove = function (producer, id) {
  id = id || producer.id;

  producer.removeListener('data', this.handlers.data[id]);
  producer.removeListener('end',  this.handlers.end[id]);
  delete this.producers[id];
  delete this.handlers.data[id];
  delete this.handlers.end[id];
};

//
// ### function write (data)
// #### @data {Object} Data to write.
// Writes the specified `data` to the underlying network
// connection associated with this client.
//
Client.prototype.write = function (data) {
  var message = !Array.isArray(data)
    ? JSON.stringify(data) + '\n'
    : data.map(JSON.stringify).join('\n') + '\n'

  if (this.type === 'tcp' || this.type === 'unix') {
    this.socket.write(message);
  }
  else if (this.type === 'udp') {
    message = new Buffer(message);
    this.socket.send(message, 0, message.length, this.port, this.host);
  }
};

//
// ### function produce (data)
// #### @data {Object|Array} Data to write to socket with some extras
// Writes to a socket with some default values attached.
// This is purely a convenience method
//
Client.prototype.produce = function (data) {
  var self = this;

  //
  // Add defaults to each object where a value does not already exist
  //
  function defaultify (obj) {
    return Object.keys(self.defaults).reduce(function (acc, key) {
      if (!acc[key]) { acc[key] = self.defaults[key] }
      return acc;
    }, obj);
  }

  //
  // TODO: we may want to be monotonic here
  //
  this.defaults['time'] = Date.now();
  data = !Array.isArray(data)
    ? defaultify(data)
    : data.map(defaultify);

  return this.write(data);
};

//
// ### function connect (callback)
// #### @port {Number} **Optional** Port number to connect on.
// #### @host {String} **Optional** Host to connect to.
// #### @callback {function} **Optional** Continuation to respond to.
// Opens the underlying network connection for this client.
//
Client.prototype.connect = function (port, host, callback) {
  var self = this;

  //
  // Do some fancy arguments parsing to support everything
  // being optional.
  //
  if (!callback && typeof host === 'function') {
    callback = host;
    host = null;
  }

  if (!callback && typeof port === 'function') {
    callback = port;
    port = null
  }

  Array.prototype.slice.call(arguments).forEach(function (arg) {
    switch (typeof arg) {
      case 'number':   port = arg; break;
      case 'string':   host = arg; break;
      case 'function': callback = arg; break;
    }
  });

  function error (arg) {
    var err = new Error(arg + ' required to connect');
    return callback
      ? callback(err)
      : self.emit('error', err) ;
  }

  function reconnect(err) {
    self.attempt = self.attempt || clone(self.reconnect);
    //
    // Remark: Terminate the backoff when we have hit our fail condition with
    // a noop to avoid an if statement
    //
    // TODO: Make this less coupled (I feel like i want this contained in
    // `back` but eh)
    //
    return self.terminate
      ? noop()
      : back(function (fail, backoff) {
        //
        // Remark: We are done here, emit error and set termination
        //
        if (fail) {
          self.terminate = true;
          self.attempt = null;
          return self.emit('error', err);
        }
        //
        // So we can listen on when reconnect events are about to fire
        //
        self.emit('reconnect', backoff);
        //
        // Attempt a CONNECT!
        //
        return connect();
      }, self.attempt);
  }

  function onError(err) {
    return self.reconnect
      ? reconnect(err)
      : self.emit('error', err);
  }

  function connect() {
    if (self.type === 'tcp') {
      self.socket = net.connect({ port: self.port, host: self.host }, callback);
    }
    else if (self.type === 'udp') {
      self.socket = dgram.createSocket('udp4');
      if (callback) {
        process.nextTick(callback);
      }
    }
    else if (self.type === 'unix') {
      self.socket = net.connect({ path: self.path }, callback);
    }

    self.socket.on('error', onError);
    self.socket.on('connect', function () {
      //
      // Remark: We have successfully connected so reset the terminate variable
      //
      self.terminate = false;
      self.emit('connect');
    });
  }

  // Split cases due to unix using `this.path`
  if (this.type === 'tcp' || this.type === 'udp') {
    this.port = port || this.port;
    this.host = host || this.host || '0.0.0.0';

    if (!this.host || !this.port) {
      error('host and port are');
    }
  }
  else if (this.type === 'unix') {
    this.path = host || this.path;

    if (!this.path) {
      error('path is');
    }
  }

  connect();
};

//
// ### function close ()
// Closes the underlying network connection for this client.
//
Client.prototype.close = function () {
  var self = this;

  if (this.type === 'tcp' || this.type === 'unix') {
    this.socket.destroy();
  }
  else if (this.type === 'udp') {
    this.socket.close();
  }

  Object.keys(this.producers).forEach(function (id) {
    self.remove(self.producers[id]);
  });

  this.socket.on('close', function () {
    self.emit('close');
  });
};
<|endoftext|>


<commit_before>//= require spree/backend/spree_backend
<commit_msg>Update spree_magnific.js<commit_after>//= require spree/backend
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function (grunt) {

    // Project configuration.
    grunt.initConfig({
        // Metadata.
        pkg: grunt.file.readJSON('package.json'),
        banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
        // Task configuration.
        concat: {
            options: {
                banner: '<%= banner %>',
                stripBanners: true
            },
            dist: {
                src: ['web/js/rss*.js'],
                dest: 'web/build/<%= pkg.name %>.js'
            }
        },
        uglify: {
            options: {
                banner: '<%= banner %>'
            },
            dist: {
                src: '<%= concat.dist.dest %>',
                dest: 'web/dist/<%= pkg.name %>.min.js'
            }
        },
        jshint: {
            options: {
                curly: true,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                undef: true,
                unused: true,
                boss: true,
                eqnull: true,
                browser: true,
                globals: {
                    jQuery: true
                }
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            lib_test: {
                src: ['web/js/rss*.js', 'test/**/*.js']
            }
        },
        qunit: {
            files: ['test/**/*.html']
        },
        watch: {
            gruntfile: {
                files: '<%= jshint.gruntfile.src %>',
                tasks: ['jshint:gruntfile']
            },
            lib_test: {
                files: '<%= jshint.lib_test.src %>',
                tasks: ['jshint:lib_test', 'qunit']
            }
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task.
    //grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
    grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};
<commit_msg>Update Gruntfile to ignore jquery check<commit_after>/*global module:false*/
module.exports = function (grunt) {

    // Project configuration.
    grunt.initConfig({
        // Metadata.
        pkg: grunt.file.readJSON('package.json'),
        banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
        // Task configuration.
        concat: {
            options: {
                banner: '<%= banner %>',
                stripBanners: true
            },
            dist: {
                src: ['web/js/rss*.js'],
                dest: 'web/build/<%= pkg.name %>.js'
            }
        },
        uglify: {
            options: {
                banner: '<%= banner %>'
            },
            dist: {
                src: '<%= concat.dist.dest %>',
                dest: 'web/dist/<%= pkg.name %>.min.js'
            }
        },
        jshint: {
            options: {
                curly: true,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                undef: true,
                unused: true,
                boss: true,
                eqnull: true,
                browser: true,
                jquery: true,
                globals: {
                    angular: false,
                    $: false,
                    console: false
                }
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            lib_test: {
                src: ['web/js/rss*.js', 'test/**/*.js']
            }
        },
        qunit: {
            files: ['test/**/*.html']
        },
        watch: {
            gruntfile: {
                files: '<%= jshint.gruntfile.src %>',
                tasks: ['jshint:gruntfile']
            },
            lib_test: {
                files: '<%= jshint.lib_test.src %>',
                tasks: ['jshint:lib_test', 'qunit']
            }
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task.
    //grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
    grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};
<|endoftext|>


<commit_before>module.exports = Register;

function Register(pluginPath) {

    electron = require('electron')
    const app = electron.app

    const isWindows = process.platform === 'win32';

    var ppapiPath = '';
    if (isWindows)
        ppapiPath = __dirname + '\\..\\bin\\Win32\\PepperPlugin.dll';
    if (pluginPath)
        ppapiPath = pluginPath + '\\PepperPlugin.dll';
    //console.log('PPAPI path ' + ppapiPath + ';application/electron-dotnet');
    app.commandLine.appendSwitch('register-pepper-plugins', ppapiPath + ';application/electron-dotnet');

}<commit_msg>Add support for 64 bit architectures to the register node.js module<commit_after>module.exports = Register;

function Register(pluginPath) {

    electron = require('electron')
    const app = electron.app

    const isWindows = process.platform === 'win32';

    var ppapiPath = '';
    if (isWindows) {
        if (process.arch = 'x64')
            ppapiPath = __dirname + '\\..\\bin\\x64\\PepperPlugin.dll';
        else
            ppapiPath = __dirname + '\\..\\bin\\Win32\\PepperPlugin.dll';
    }
    if (pluginPath)
        ppapiPath = pluginPath + '\\PepperPlugin.dll';
    //console.log('PPAPI path ' + ppapiPath + ';application/electron-dotnet');
    app.commandLine.appendSwitch('register-pepper-plugins', ppapiPath + ';application/electron-dotnet');

}<|endoftext|>


<commit_before>module.exports = function(grunt) {

	grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

		jshint: {
			options: {
			},
			files: [
			  'lib/**/*.js'
			]
		},

		clean: ['tmp', 'dist'],
	});

  grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-jshint');

	grunt.registerTask('default', 'jshint');
};<commit_msg>indentation<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    jshint: {
      options: {
      },
      files: [
        'lib/**/*.js'
      ]
    },

    clean: ['tmp', 'dist'],
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('default', 'jshint');
};<|endoftext|>


<commit_before>/*
 * grunt-css-sprite
 * https://github.com/laoshu133
 *
 * Licensed under the MIT license.
 */

module.exports = function(grunt) {
	grunt.initConfig({
		//Auto sprite
		sprite: {
			options: {
				// sprite背景图源文件夹，只有匹配此路径才会处理，默认 images/slice/
				imagepath: 'test/slice/',
				// 映射CSS中背景路径，支持函数和数组，默认为 null
				imagepath_map: null,
				// 雪碧图输出目录，注意，会覆盖之前文件！默认 images/
				spritedest: 'test/publish/images/',
				// 替换后的背景路径，默认 ../images/
				spritepath: '../images/',
				// 各图片间间距，如果设置为奇数，会强制+1以保证生成的2x图片为偶数宽高，默认 0
				padding: 2,
				// 是否使用 image-set 作为2x图片实现，默认不使用
				useimageset: false,
				// 是否以时间戳为文件名生成新的雪碧图文件，如果启用请注意清理之前生成的文件，默认不生成新文件
				newsprite: false,
				// 给雪碧图追加时间戳，默认不追加
				spritestamp: true,
				// 在CSS文件末尾追加时间戳，默认不追加
				cssstamp: true,
				// 默认使用二叉树最优排列算法
				algorithm: 'binary-tree',
				// 默认使用`pngsmith`图像处理引擎
				engine: 'pngsmith'
			},
			autoSprite: {
				files: [{
					// 启用动态扩展
					expand: true,
					// css文件源的文件夹
					cwd: 'test/css/',
					// 匹配规则
					src: '*.css',
					// 导出css和sprite的路径地址
					dest: 'test/publish/css/',
					// 导出的css名
					ext: '.sprite.css'
				}]
			},
			// image-set 示例
			imageSetSprite: {
				options: {
					useimageset: true,
					imagepath_map: ['/w/grunt-css-sprite/test/', '../'],
					/*
					imagepath_map: function(uri) {
						return String(uri).replace('/w/grunt-css-sprite/test/', '../');
					},
					*/
					spritedest: 'test/publish/images/imageset/',
					spritepath: '../../images/imageset/'
					//,spritepath: '/w/grunt-css-sprite/test/publish/images/imageset/'
				},
				files: [{
					// 启用动态扩展
					expand: true,
					// css文件源的文件夹
					cwd: 'test/css/',
					// 匹配规则
					src: '*.css',
					// 导出css和sprite的路径地址
					dest: 'test/publish/css/imageset/',
					// 导出的css名
					ext: '.imageset.css'
				}]
			}
		},
		jshint: {
			all: [ 'Gruntfile.js', 'lib/*.js', 'tasks/*.js' ]
		}
	});

	// 载入任务
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadTasks('tasks');

	// 声明别名
	grunt.registerTask('default', ['sprite']);
	grunt.registerTask('test', ['sprite']);
};<commit_msg>修改测试默认图像处理引擎至 pixelsmith<commit_after>/*
 * grunt-css-sprite
 * https://github.com/laoshu133
 *
 * Licensed under the MIT license.
 */

module.exports = function(grunt) {
	grunt.initConfig({
		//Auto sprite
		sprite: {
			options: {
				// sprite背景图源文件夹，只有匹配此路径才会处理，默认 images/slice/
				imagepath: 'test/slice/',
				// 映射CSS中背景路径，支持函数和数组，默认为 null
				imagepath_map: null,
				// 雪碧图输出目录，注意，会覆盖之前文件！默认 images/
				spritedest: 'test/publish/images/',
				// 替换后的背景路径，默认 ../images/
				spritepath: '../images/',
				// 各图片间间距，如果设置为奇数，会强制+1以保证生成的2x图片为偶数宽高，默认 0
				padding: 2,
				// 是否使用 image-set 作为2x图片实现，默认不使用
				useimageset: false,
				// 是否以时间戳为文件名生成新的雪碧图文件，如果启用请注意清理之前生成的文件，默认不生成新文件
				newsprite: false,
				// 给雪碧图追加时间戳，默认不追加
				spritestamp: true,
				// 在CSS文件末尾追加时间戳，默认不追加
				cssstamp: true,
				// 默认使用二叉树最优排列算法
				algorithm: 'binary-tree',
				// 默认使用`pixelsmith`图像处理引擎
				engine: 'pixelsmith'
			},
			autoSprite: {
				files: [{
					// 启用动态扩展
					expand: true,
					// css文件源的文件夹
					cwd: 'test/css/',
					// 匹配规则
					src: '*.css',
					// 导出css和sprite的路径地址
					dest: 'test/publish/css/',
					// 导出的css名
					ext: '.sprite.css'
				}]
			},
			// image-set 示例
			imageSetSprite: {
				options: {
					useimageset: true,
					imagepath_map: ['/w/grunt-css-sprite/test/', '../'],
					/*
					imagepath_map: function(uri) {
						return String(uri).replace('/w/grunt-css-sprite/test/', '../');
					},
					*/
					spritedest: 'test/publish/images/imageset/',
					spritepath: '../../images/imageset/'
					//,spritepath: '/w/grunt-css-sprite/test/publish/images/imageset/'
				},
				files: [{
					// 启用动态扩展
					expand: true,
					// css文件源的文件夹
					cwd: 'test/css/',
					// 匹配规则
					src: '*.css',
					// 导出css和sprite的路径地址
					dest: 'test/publish/css/imageset/',
					// 导出的css名
					ext: '.imageset.css'
				}]
			}
		},
		jshint: {
			all: [ 'Gruntfile.js', 'lib/*.js', 'tasks/*.js' ]
		}
	});

	// 载入任务
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadTasks('tasks');

	// 声明别名
	grunt.registerTask('default', ['sprite']);
	grunt.registerTask('test', ['sprite']);
};<|endoftext|>


<commit_before>module.exports = function(grunt) {
	require("time-grunt")(grunt);
	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		eslint: {
			options: {
				configFile: ".eslintrc.json"
			},
			target: [
				"js/*.js",
				"modules/default/*.js",
				"modules/default/*/*.js",
				"serveronly/*.js",
				"clientonly/*.js",
				"*.js",
				"tests/**/*.js",
				"!modules/default/alert/notificationFx.js",
				"!modules/default/alert/modernizr.custom.js",
				"!modules/default/alert/classie.js",
				"config/*",
				"translations/translations.js",
				"vendor/vendor.js",
				"modules/node_modules/node_helper/index.js"
			]
		},
		stylelint: {
			simple: {
				options: {
					configFile: ".stylelintrc.json"
				},
				src: [
					"css/main.css",
					"modules/default/calendar/calendar.css",
					"modules/default/clock/clock_styles.css",
					"modules/default/currentweather/currentweather.css",
					"modules/default/weatherforcast/weatherforcast.css"
				]
			}
		},
		jsonlint: {
			main: {
				src: [
					"package.json",
					".eslintrc.json",
					".stylelintrc.json",
					"installers/pm2_MagicMirror.json",
					"translations/*.json",
					"modules/default/*/translations/*.json",
					"vendor/package.json"
				],
				options: {
					reporter: "jshint"
				}
			}
		},
		markdownlint: {
			all: {
				options: {
					config: {
						"default": true,
						"line-length": false,
						"blanks-around-headers": false,
						"no-duplicate-header": false,
						"no-inline-html": false,
						"MD010": false,
						"MD001": false,
						"MD031": false,
						"MD040": false,
						"MD002": false,
						"MD029": false,
						"MD041": false,
						"MD032": false,
						"MD036": false,
						"MD037": false,
						"MD009": false,
						"MD018": false,
						"MD012": false,
						"MD026": false,
						"MD038": false
					}
				},
				src: [
					"README.md",
					"CHANGELOG.md",
					"LICENSE.md",
					"modules/README.md",
					"modules/default/**/*.md",
					"!modules/default/calendar/vendor/ical.js/readme.md"
				]
			}
		},
		yamllint: {
			all: [
				".travis.yml"
			]
		}
	});
	grunt.loadNpmTasks("grunt-eslint");
	grunt.loadNpmTasks("grunt-stylelint");
	grunt.loadNpmTasks("grunt-jsonlint");
	grunt.loadNpmTasks("grunt-yamllint");
	grunt.loadNpmTasks("grunt-markdownlint");
	grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]);
};
<commit_msg>Pass fix options to eslint<commit_after>module.exports = function(grunt) {
	require("time-grunt")(grunt);
	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		eslint: {
			options: {
				fix: "true",
				configFile: ".eslintrc.json"
			},
			target: [
				"js/*.js",
				"modules/default/*.js",
				"modules/default/*/*.js",
				"serveronly/*.js",
				"clientonly/*.js",
				"*.js",
				"tests/**/*.js",
				"!modules/default/alert/notificationFx.js",
				"!modules/default/alert/modernizr.custom.js",
				"!modules/default/alert/classie.js",
				"config/*",
				"translations/translations.js",
				"vendor/vendor.js",
				"modules/node_modules/node_helper/index.js"
			]
		},
		stylelint: {
			simple: {
				options: {
					configFile: ".stylelintrc.json"
				},
				src: [
					"css/main.css",
					"modules/default/calendar/calendar.css",
					"modules/default/clock/clock_styles.css",
					"modules/default/currentweather/currentweather.css",
					"modules/default/weatherforcast/weatherforcast.css"
				]
			}
		},
		jsonlint: {
			main: {
				src: [
					"package.json",
					".eslintrc.json",
					".stylelintrc.json",
					"installers/pm2_MagicMirror.json",
					"translations/*.json",
					"modules/default/*/translations/*.json",
					"vendor/package.json"
				],
				options: {
					reporter: "jshint"
				}
			}
		},
		markdownlint: {
			all: {
				options: {
					config: {
						"default": true,
						"line-length": false,
						"blanks-around-headers": false,
						"no-duplicate-header": false,
						"no-inline-html": false,
						"MD010": false,
						"MD001": false,
						"MD031": false,
						"MD040": false,
						"MD002": false,
						"MD029": false,
						"MD041": false,
						"MD032": false,
						"MD036": false,
						"MD037": false,
						"MD009": false,
						"MD018": false,
						"MD012": false,
						"MD026": false,
						"MD038": false
					}
				},
				src: [
					"README.md",
					"CHANGELOG.md",
					"LICENSE.md",
					"modules/README.md",
					"modules/default/**/*.md",
					"!modules/default/calendar/vendor/ical.js/readme.md"
				]
			}
		},
		yamllint: {
			all: [
				".travis.yml"
			]
		}
	});
	grunt.loadNpmTasks("grunt-eslint");
	grunt.loadNpmTasks("grunt-stylelint");
	grunt.loadNpmTasks("grunt-jsonlint");
	grunt.loadNpmTasks("grunt-yamllint");
	grunt.loadNpmTasks("grunt-markdownlint");
	grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]);
};
<|endoftext|>