<commit_before>(function($)
{
	/**
	 * QuickField class
	 * Handles the buttons for creating new groups and fields inside a FieldLayoutDesigner
	 */
	var QuickField = Garnish.Base.extend({

		$container:   null,
		$groupButton: null,
		$fieldButton: null,
		$settings:    null,

		fld:          null,
		dialog:       null,
		modal:        null,

		/**
		 * The constructor.
		 *
		 * @param fld - An instance of Craft.FieldLayoutDesigner
		 */
		init: function(fld)
		{
			if(!(fld instanceof Craft.FieldLayoutDesigner))
			{
				// Fail silently - just means the quick field feature will not be initialised, no big deal
				return;
			}

			this.fld = fld;

			this.$container   = $('
').insertAfter(fld.$unusedFieldContainer);
			this.$groupButton = $('
').text(Craft.t('New Group')).appendTo(this.$container);
			this.$fieldButton = $('
').text(Craft.t('New Field')).appendTo(this.$container);

			this.initButtons();

			this.dialog = QuickField.GroupDialog.getInstance();
			this.modal  = QuickField.FieldModal.getInstance();

			this.addListener(this.$groupButton, 'activate', 'newGroup');
			this.addListener(this.$fieldButton, 'activate', 'newField');

			this.dialog.on('newGroup', $.proxy(function(e)
			{
				var group = e.group;
				this.addGroup(group.id, group.name);
			}, this));

			this.modal.on('newField', $.proxy(function(e)
			{
				var field = e.field;
				var group = field.group;
				this.addField(field.id, field.name, group.name);
			}, this));
		},

		/**
		 * Adds edit buttons to existing fields.
		 */
		initButtons: function()
		{
			var $tabs = this.fld.$unusedFieldContainer.find('.fld-tab .tab.sel');
			var $fields = this.fld.$unusedFieldContainer.find('.fld-field.unused');

			$tabs.each(function()
			{
				var $tab = $(this);
				var $button = $('');

				// Add the extra space in there for consistent padding
				$tab.append(' ').append($button);
			});

			$fields.each(function()
			{
				var $field = $(this);
				var $button = $('');

				$field.append($button);
			});
		},

		/**
		 * Event handler for the New Field button.
		 * Creates a modal window that contains new field settings.
		 */
		newField: function()
		{
			this.modal.show();
		},

		/**
		 * Adds a new unused (dashed border) field to the field layout designer.
		 *
		 * @param id
		 * @param name
		 * @param groupName
		 */
		addField: function(id, name, groupName)
		{
			var fld = this.fld;
			var grid = fld.unusedFieldGrid;
			var drag = fld.fieldDrag;
			var fields = fld.$allFields;
			var $group = this._getGroupByName(groupName);

			if($group)
			{
				var $groupContent = $group.children('.fld-tabcontent');
				var $field = $([
					'
',
						'', name, '',
						'',
					'
'
				].join('')).appendTo($groupContent);

				fld.$allFields = fields.add($field);

				$group.removeClass('hidden');
				drag.addItems($field);
				grid.refreshCols(true);
			}
			else
			{
				Craft.cp.displayError(Craft.t('Invalid field group:') + groupName);
			}
		},

		/**
		 *
		 */
		newGroup: function()
		{
			this.dialog.addNewGroup();
		},

		/**
		 * Adds a new unused (dashed border) group tab to the field layout designer.
		 *
		 * @param name
		 * @param id
		 */
		addGroup: function(id, name)
		{
			var fld = this.fld;
			var settings = fld.settings;
			var grid = fld.unusedFieldGrid;
			var drag = fld.tabDrag;

			var $container = fld.$unusedFieldContainer;
			var $tab = $([
				'
',
					'
',
						'
',
							'', name, '',
							' ',
						'
',
					'
',
					'

',
				'
'
			].join('')).appendTo($container);

			grid.addItems($tab);

			if(settings.customizableTabs)
			{
				drag.addItems($tab);
			}

			grid.refreshCols(true);
		},

		/**
		 * Finds the group tab element from it's name.
		 *
		 * @param name
		 * @returns {*}
		 * @private
		 */
		_getGroupByName: function(name)
		{
			var $container = this.fld.$unusedFieldContainer;
			var $groups = $container.children('.fld-tab');
			var $group = null;

			$groups.each(function()
			{
				var $this = $(this);
				var $tab = $this.children('.tabs').children('.tab.sel');
				var $span = $tab.children('span');

				if($span.text() === name)
				{
					$group = $this;
					return false;
				}
			});

			return $group;
		}
	});

	window.QuickField = QuickField;

})(jQuery);
<commit_msg>Docstrings<commit_after>(function($)
{
	/**
	 * QuickField class
	 * Handles the buttons for creating new groups and fields inside a FieldLayoutDesigner
	 */
	var QuickField = Garnish.Base.extend({

		$container:   null,
		$groupButton: null,
		$fieldButton: null,
		$settings:    null,

		fld:          null,
		dialog:       null,
		modal:        null,

		/**
		 * The constructor.
		 *
		 * @param fld - An instance of Craft.FieldLayoutDesigner
		 */
		init: function(fld)
		{
			if(!(fld instanceof Craft.FieldLayoutDesigner))
			{
				// Fail silently - just means the quick field feature will not be initialised, no big deal
				return;
			}

			this.fld = fld;

			this.$container   = $('
').insertAfter(fld.$unusedFieldContainer);
			this.$groupButton = $('
').text(Craft.t('New Group')).appendTo(this.$container);
			this.$fieldButton = $('
').text(Craft.t('New Field')).appendTo(this.$container);

			this.initButtons();

			this.dialog = QuickField.GroupDialog.getInstance();
			this.modal  = QuickField.FieldModal.getInstance();

			this.addListener(this.$groupButton, 'activate', 'newGroup');
			this.addListener(this.$fieldButton, 'activate', 'newField');

			this.dialog.on('newGroup', $.proxy(function(e)
			{
				var group = e.group;
				this.addGroup(group.id, group.name);
			}, this));

			this.modal.on('newField', $.proxy(function(e)
			{
				var field = e.field;
				var group = field.group;
				this.addField(field.id, field.name, group.name);
			}, this));
		},

		/**
		 * Adds edit buttons to existing fields.
		 */
		initButtons: function()
		{
			var $tabs = this.fld.$unusedFieldContainer.find('.fld-tab .tab.sel');
			var $fields = this.fld.$unusedFieldContainer.find('.fld-field.unused');

			$tabs.each(function()
			{
				var $tab = $(this);
				var $button = $('');

				// Add the extra space in there for consistent padding
				$tab.append(' ').append($button);
			});

			$fields.each(function()
			{
				var $field = $(this);
				var $button = $('');

				$field.append($button);
			});
		},

		/**
		 * Event handler for the New Field button.
		 * Creates a modal window that contains new field settings.
		 */
		newField: function()
		{
			this.modal.show();
		},

		/**
		 * Adds a new unused (dashed border) field to the field layout designer.
		 *
		 * @param id
		 * @param name
		 * @param groupName
		 */
		addField: function(id, name, groupName)
		{
			var fld = this.fld;
			var grid = fld.unusedFieldGrid;
			var drag = fld.fieldDrag;
			var fields = fld.$allFields;
			var $group = this._getGroupByName(groupName);

			if($group)
			{
				var $groupContent = $group.children('.fld-tabcontent');
				var $field = $([
					'
',
						'', name, '',
						'',
					'
'
				].join('')).appendTo($groupContent);

				fld.$allFields = fields.add($field);

				$group.removeClass('hidden');
				drag.addItems($field);
				grid.refreshCols(true);
			}
			else
			{
				Craft.cp.displayError(Craft.t('Invalid field group:') + groupName);
			}
		},

		/**
		 * Event listener for the new group button
		 */
		newGroup: function()
		{
			this.dialog.addNewGroup();
		},

		/**
		 * Adds a new unused (dashed border) group tab to the field layout designer.
		 *
		 * @param name
		 * @param id
		 */
		addGroup: function(id, name)
		{
			var fld = this.fld;
			var settings = fld.settings;
			var grid = fld.unusedFieldGrid;
			var drag = fld.tabDrag;

			var $container = fld.$unusedFieldContainer;
			var $tab = $([
				'
',
					'
',
						'
',
							'', name, '',
							' ',
						'
',
					'
',
					'

',
				'
'
			].join('')).appendTo($container);

			grid.addItems($tab);

			if(settings.customizableTabs)
			{
				drag.addItems($tab);
			}

			grid.refreshCols(true);
		},

		/**
		 * Finds the group tab element from it's name.
		 *
		 * @param name
		 * @returns {*}
		 * @private
		 */
		_getGroupByName: function(name)
		{
			var $container = this.fld.$unusedFieldContainer;
			var $groups = $container.children('.fld-tab');
			var $group = null;

			$groups.each(function()
			{
				var $this = $(this);
				var $tab = $this.children('.tabs').children('.tab.sel');
				var $span = $tab.children('span');

				if($span.text() === name)
				{
					$group = $this;
					return false;
				}
			});

			return $group;
		}
	});

	window.QuickField = QuickField;

})(jQuery);
<|endoftext|>


<commit_before>/*
 * scripts for loading and displaying github repos.
 */
(function ($) {
  /*
   * load and display github repos.
   */
  $(function() {
    var github_type = $('#repos').data('github-type')
      , github_login = $('#repos').data('github-login')
      , github_repos_url = 'https://api.github.com/' + github_type + 's/' + github_login + '/repos'
      , repos = [];

    $.getJSON(github_repos_url, 'sort=pushed', success_cb);

    /*
     * callback of successful ajax getting.
     */
    function success_cb(response, status, xhr) {
      if (status !== 'success') {
        return;
      }

      var links = page_links(xhr.getResponseHeader('Link'));

      repos = repos.concat(response);

      if (links && links['next']) {
        $.getJSON(links['next'], success_cb);

      } else {
        display_repos();
      }
    }

    /*
     * parse page link from ajax response header.
     */
    function page_links(link_header) {
      if (!link_header) {
        return;
      }

      var link_splits = link_header.split(',')
        , regex = /<(.+)>\s*\;\s*rel="(\w+)"/
        , obj = {}
        , temp
        , i;

      for (i = 0; i < link_splits.length; ++ i) {
        temp = regex.exec(link_splits[i]);
        obj[temp[2]] = temp[1];
      }

      return obj;
    }

    /*
     * display repositories.
     */
    function display_repos() {
      var repos_div = $('#repos')
        , temp
        , i
        , j;

      repos_div.empty();
      for (i = 0; i < repos.length; i += 4) {
        temp = $('

').addClass('row-fluid');

        for (j = i; j < ((repos.length > i + 4) ? (i + 4) : repos.length); ++ j) {
          temp.append(assemble_repo_node(repos[j]));
        }
        repos_div.append(temp);
      }
    }

    /*
     * assemble a repository node by the github repository object.
     */
    function assemble_repo_node(repo_obj) {
      return $('

')
        .addClass('span3')
        .addClass('well')
        .addClass('repo')
        .addClass(language_css_class(repo_obj.language))
        .append($('')
          .attr('href', repo_obj.html_url)
          .append($('

')
            .text(repo_obj.name)
            .append(assemble_repo_meta(repo_obj.language, 'repo-language'))
            .append(assemble_repo_meta(repo_obj.pushed_at, 'repo-update', date_styler)))
          .append(assemble_repo_meta(repo_obj.description)));
    }

    /*
     * assemble repository meta data node.
     */
    function assemble_repo_meta(meta_data, css_class, styler) {
      var obj;
      if (meta_data) {
        obj = $('

');

        if (styler) {
          obj.text(styler(meta_data));
        } else {
          obj.text(meta_data);
        }

        if (css_class) {
          obj.addClass(css_class);
        }
        return obj;
      }
    }

    /*
     * style the date retrieving from the ajax response.
     */
    function date_styler(date) {
      var d = new Date(date);
      return d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    }

    /*
     * retrieve the css class for the given language name.
     */
    function language_css_class(language) {
      if (!language) {
        return;
      }

      var lang_class = language.toLowerCase();

      switch (lang_class) {
        case 'c++':
          lang_class = 'cpp';
          break;

        case 'c#':
          lang_class = 'cs';
          break;

        default:
          break;
      }

      return lang_class;
    }
  });
})(window.jQuery);<commit_msg>Add some features to GitHub repositories page template<commit_after>/*
 * scripts for loading and displaying github repos.
 */
(function ($) {
  /*
   * load and display github repos.
   */
  $(function() {
    var github_type = $('#repos').data('github-type')
      , github_login = $('#repos').data('github-login')
      , github_repos_url = 'https://api.github.com/' + github_type + 's/' + github_login + '/repos'
      , repos = [];

    $.getJSON(github_repos_url, 'sort=pushed', success_cb);

    /*
     * callback of successful ajax getting.
     */
    function success_cb(response, status, xhr) {
      if (status !== 'success') {
        return;
      }

      var links = page_links(xhr.getResponseHeader('Link'));

      repos = repos.concat(response);

      if (links && links['next']) {
        $.getJSON(links['next'], success_cb);

      } else {
        display_repos();
      }
    }

    /*
     * parse page link from ajax response header.
     */
    function page_links(link_header) {
      if (!link_header) {
        return;
      }

      var link_splits = link_header.split(',')
        , regex = /<(.+)>\s*\;\s*rel="(\w+)"/
        , obj = {}
        , temp
        , i;

      for (i = 0; i < link_splits.length; ++ i) {
        temp = regex.exec(link_splits[i]);
        obj[temp[2]] = temp[1];
      }

      return obj;
    }

    /*
     * display repositories.
     */
    function display_repos() {
      var repos_div = $('#repos')
        , temp
        , i
        , j;

      repos_div.empty();
      for (i = 0; i < repos.length; i += 4) {
        temp = $('

').addClass('row-fluid');

        for (j = i; j < ((repos.length > i + 4) ? (i + 4) : repos.length); ++ j) {
          temp.append(assemble_repo_node(repos[j]));
        }
        repos_div.append(temp);
      }
    }

    /*
     * assemble a repository node by the github repository object.
     */
    function assemble_repo_node(repo_obj) {
      return $('

')
        .addClass('span3')
        .addClass('well')
        .addClass('repo')
        .addClass(language_css_class(repo_obj.language))
        .append($('')
          .attr('href', repo_obj.html_url)
          .attr('target', '_blank')
          .attr('rel', 'noreferrer')
          .append($('

')
            .text(repo_obj.name)
            .append(assemble_repo_meta(repo_obj.language, 'repo-language'))
            .append(assemble_repo_meta(repo_obj.pushed_at, 'repo-update', date_styler)))
          .append(assemble_repo_meta(repo_obj.description)));
    }

    /*
     * assemble repository meta data node.
     */
    function assemble_repo_meta(meta_data, css_class, styler) {
      var obj;
      if (meta_data) {
        obj = $('

');

        if (styler) {
          obj.text(styler(meta_data));
        } else {
          obj.text(meta_data);
        }

        if (css_class) {
          obj.addClass(css_class);
        }
        return obj;
      }
    }

    /*
     * style the date retrieving from the ajax response.
     */
    function date_styler(date) {
      var d = new Date(date);
      return d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    }

    /*
     * retrieve the css class for the given language name.
     */
    function language_css_class(language) {
      if (!language) {
        return;
      }

      var lang_class = language.toLowerCase();

      switch (lang_class) {
        case 'c++':
          lang_class = 'cpp';
          break;

        case 'c#':
          lang_class = 'cs';
          break;

        default:
          break;
      }

      return lang_class;
    }
  });
})(window.jQuery);<|endoftext|>


<commit_before>require('whatwg-fetch')
require('babel-polyfill')

//Here's how I've shown how to use promises before
fetch(
    '/ajax',
    {
        method: 'post',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({ param: 'You are a penguin' })
    })
    .then(response => response.json())
    .then(console.log)

//Here's how we handle the same async code with generators
const
    async = starFunc => {
        const
            iterator = starFunc(),
            handle = x => {
                const iteration = iterator.next(x)
                if(!iteration.done) {
                    iteration.value.then(handle)
                }
            }
        iterator.next().value.then(handle)
    }

async(function* () {
    const
        response = yield fetch(
            '/ajax',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Bananas are my friends' })
            }),
        json = yield response.json()
    console.log(json)
})

//I've not really bothered with handling errors in either of the above examples
//I could do, but it's mostly boring work that doesn't teach us much
//And there's already a library that does this for us with the generator approach
//https://github.com/tj/co
const
    co = require('co')

co(function* () {
    const
        response = yield fetch(
            '/ajax',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Your mom is a potato' })
            }),
        json = yield response.json()
    console.log(json)
})

//It's co even returns a promise from the end of the promise chain so you can catch errors
co(function* () {
    const
        response = yield fetch(
            '/banana',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Your mom is a potato' })
            }),
        json = yield response.json()
    console.log(json)
})
.catch(console.log)
<commit_msg>fixed comment<commit_after>require('whatwg-fetch')
require('babel-polyfill')

//Here's how I've shown how to use promises before
fetch(
    '/ajax',
    {
        method: 'post',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({ param: 'You are a penguin' })
    })
    .then(response => response.json())
    .then(console.log)

//Here's how we handle the same async code with generators
const
    async = starFunc => {
        const
            iterator = starFunc(),
            handle = x => {
                const iteration = iterator.next(x)
                if(!iteration.done) {
                    iteration.value.then(handle)
                }
            }
        iterator.next().value.then(handle)
    }

async(function* () {
    const
        response = yield fetch(
            '/ajax',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Bananas are my friends' })
            }),
        json = yield response.json()
    console.log(json)
})

//I've not really bothered with handling errors in either of the above examples
//I could do, but it's mostly boring work that doesn't teach us much
//And there's already a library that does this for us with the generator approach
//https://github.com/tj/co
const
    co = require('co')

co(function* () {
    const
        response = yield fetch(
            '/ajax',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Your mom is a potato' })
            }),
        json = yield response.json()
    console.log(json)
})

//co even returns a promise from the end of the promise chain so you can catch errors
co(function* () {
    const
        response = yield fetch(
            '/banana',
            {
                method: 'post',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ param: 'Your mom is a potato' })
            }),
        json = yield response.json()
    console.log(json)
})
.catch(console.log)
<|endoftext|>


<commit_before>var path = require('path');
var klaw = require('klaw');
var _ = require('maf/vendors/lodash');

module.exports = function (di) {

    di.program.command('render')
        .alias('r')
        .description('render all .md files in work dir')
        .action(function () {
            var options = {
                filter: function (filepath) {
                    if (di.api.fs.isIgnored(filepath)) {
                        return false;
                    }

                    if (filepath.search(di.config.get('wwwDir')) > -1) {
                        return false;
                    }

                    return true;
                }
            };

            var queue = [];

            klaw(di.config.get('markdownDir'), options)
                .on('data', function (item) {

                    if (path.extname(item.path) !== '.md') {
                        return false;
                    }

                    if (item.stats.isDirectory()) {
                        return false;
                    }

                    queue.push(item);

                })
                .on('error', function (error) {
                    throw error;
                })
                .on('end', function () {
                    di.logger.info(`render ${queue.length} files`);

                    var promises = [];

                    for (var raw of queue) {
                        promises.push(new Promise((resolve, reject) => {

                            var item = _.cloneDeep(raw);

                            var to = di.api.fs.getRenderPath(item.path);
                            di.api.markdown.renderFile(item.path, to)
                                .then(() => {
                                    di.logger.info(`render file: ${item.path} => ${to}`);
                                    resolve();
                                })
                                .catch((error) => {
                                    reject(error);
                                });
                        }));
                    }

                    Promise.all(promises)
                        .then(() => {
                            di.logger.info('done');
                        })
                        .catch((error) => {
                            di.logger.error(error);
                            process.exit(1);
                        });

                });
        });

};
<commit_msg>fix: render cmd render without header and footer<commit_after>var path = require('path');
var fs = require('fs-extra');
var klaw = require('klaw');
var _ = require('maf/vendors/lodash');

module.exports = function (di) {

    di.program.command('render')
        .alias('r')
        .description('render all .md files in work dir')
        .action(function () {
            var options = {
                filter: function (filepath) {
                    if (di.api.fs.isIgnored(filepath)) {
                        return false;
                    }

                    if (filepath.search(di.config.get('wwwDir')) > -1) {
                        return false;
                    }

                    return true;
                }
            };

            var queue = [];

            var header = fs.readFileSync(path.join(__dirname, '/../../templates/render', 'header.html')).toString();
            var footer = fs.readFileSync(path.join(__dirname, '/../../templates/render', 'footer.html')).toString();

            klaw(di.config.get('markdownDir'), options)
                .on('data', function (item) {

                    if (path.extname(item.path) !== '.md') {
                        return false;
                    }

                    if (item.stats.isDirectory()) {
                        return false;
                    }

                    queue.push(item);

                })
                .on('error', function (error) {
                    throw error;
                })
                .on('end', function () {
                    di.logger.info(`render ${queue.length} files`);

                    var promises = [];

                    for (var raw of queue) {
                        promises.push(new Promise((resolve, reject) => {

                            var item = _.cloneDeep(raw);

                            var to = di.api.fs.getRenderPath(item.path);
                            di.api.markdown.renderFile(item.path, to, {header: header, footer: footer})
                                .then(() => {
                                    di.logger.info(`render file: ${item.path} => ${to}`);
                                    resolve();
                                })
                                .catch((error) => {
                                    reject(error);
                                });
                        }));
                    }

                    Promise.all(promises)
                        .then(() => {
                            di.logger.info('done');
                        })
                        .catch((error) => {
                            di.logger.error(error);
                            process.exit(1);
                        });

                });
        });

};
<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.20',
        npm: {
          devDependencies: {
            'ember-source': '~3.20.5',
          },
        },
      },
      {
        name: 'ember-lts-3.24',
        npm: {
          devDependencies: {
            'ember-source': '~3.24.3',
          },
        },
      },
      {
        name: 'ember-lts-3.28',
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0',
          },
        },
      },
      // Comment out the release, beta and canary builds as they use Ember@4
      // which is not compatible atm
      // {
      //   name: 'ember-release',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('release'),
      //     },
      //   },
      // },
      // {
      //   name: 'ember-beta',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('beta'),
      //     },
      //   },
      // },
      // {
      //   name: 'ember-canary',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('canary'),
      //     },
      //   },
      // },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false,
          }),
        },
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0',
          },
          ember: {
            edition: 'classic',
          },
        },
      },
      embroiderSafe(),
      embroiderOptimized(),
    ],
  };
};
<commit_msg>Remove Embroider compatibility builds from Ember Try config<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.20',
        npm: {
          devDependencies: {
            'ember-source': '~3.20.5',
          },
        },
      },
      {
        name: 'ember-lts-3.24',
        npm: {
          devDependencies: {
            'ember-source': '~3.24.3',
          },
        },
      },
      {
        name: 'ember-lts-3.28',
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0',
          },
        },
      },
      // Comment out the release, beta and canary builds as they use Ember@4
      // which is not compatible atm
      // {
      //   name: 'ember-release',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('release'),
      //     },
      //   },
      // },
      // {
      //   name: 'ember-beta',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('beta'),
      //     },
      //   },
      // },
      // {
      //   name: 'ember-canary',
      //   npm: {
      //     devDependencies: {
      //       'ember-source': await getChannelURL('canary'),
      //     },
      //   },
      // },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false,
          }),
        },
        npm: {
          devDependencies: {
            'ember-source': '~3.28.0',
          },
          ember: {
            edition: 'classic',
          },
        },
      },
      // Remove Embroider builds for now as there are compat issues
      // embroiderSafe(),
      // embroiderOptimized(),
    ],
  };
};
<|endoftext|>


<commit_before>(function() {
    'use strict';
    var self;
    var UB = UB || {};
    self = UB.DROPDOWN = {
        // initialize creatSubNav function and bind function
        init: function() {
            self.createSubNav();
            self.bind();
        },
        bind: function() {
            var links = document.querySelectorAll('.sub-nav');
            links.forEach(function(el) {
                var subNav = el.querySelectorAll('.subMenu');
                el.addEventListener('mouseover', function() {
                    el.classList.add('over');
                    subNav[0].setAttribute('style', 'height: ' + subNav[0].scrollHeight + 'px;');
                });
                el.addEventListener('mouseout', function() {
                    el.classList.remove('over');
                    subNav[0].setAttribute('style', 'height: 0;');
                });
            });
        },
        createSubNav: function() {
            // menus object contains information needed for the submenus
            var menus = {
                mDesign: {
                    mDesign1: {
                        text: 'Web Design',
                        href: '#'
                    },
                    mDesign2: {
                        text: 'Interactive Design',
                        href: '#'
                    },
                    mDesign3: {
                        text: 'Graphic Design',
                        href: '#'
                    }
                },
                mArt: {
                    mArt1: {
                        text: 'Photography',
                        href: '#'
                    },
                    mArt2: {
                        text: 'Ad Art',
                        href: '#'
                    },
                    mArt3: {
                        text: 'Web Art',
                        href: '#'
                    }
                }
            };

            // create elements that will be cloned later
            var newUl = self.createElem('ul', 'subMenu');
            var newLi = self.createElem('li');
            var newA = self.createElem('a');

            // getOwnPropertyNames returns an array that can be iterated over with forEach
            Object.getOwnPropertyNames(menus).forEach(function(e) {
                var u = newUl.cloneNode();                // clone ul
                var pli = document.getElementById(e);     // get parent li
                pli.classList.add('sub-nav');             // add sub-nav className indicating a submenu exists
                // cycle through sub-items
                Object.getOwnPropertyNames(menus[e]).forEach(function(el) {
                    var li = newLi.cloneNode();           // clone li
                    var a = newA.cloneNode();             // clone a
                    a.textContent = menus[e][el].text;    // apply a text
                    a.href = menus[e][el].href;           // apply href
                    li.appendChild(a);                    // append a to li
                    u.appendChild(li);                    // append li to u
                });
                pli.appendChild(u);                       // append u to sub-nav li
            });
        },
        // helper function to create new elements
        createElem : function(el, className, id) {
            var o = document.createElement(el);
            if(className) {
                o.className = className;
            }
            if(id) {
                o.id = id;
            }
            return o;
        }
    };
    UB.DROPDOWN.init();
})();
<commit_msg>js tweak<commit_after>(function() {
    'use strict';
    var self;
    var UB = UB || {};
    self = UB.DROPDOWN = {
        // initialize creatSubNav function and bind function
        init: function() {
            self.createSubNav();
            self.bind();
        },
        bind: function() {
            var links = document.querySelectorAll('.sub-nav');
            links.forEach(function(el) {
                var subNav = el.querySelectorAll('.subMenu');
                el.addEventListener('mouseover', function() {
                    el.classList.add('over');
                    subNav[0].style.height = subNav[0].scrollHeight + 'px';
                });
                el.addEventListener('mouseout', function() {
                    el.classList.remove('over');
                    subNav[0].style.height = '0';
                });
            });
        },
        createSubNav: function() {
            // menus object contains information needed for the submenus
            var menus = {
                mDesign: {
                    mDesign1: {
                        text: 'Web Design',
                        href: '#'
                    },
                    mDesign2: {
                        text: 'Interactive Design',
                        href: '#'
                    },
                    mDesign3: {
                        text: 'Graphic Design',
                        href: '#'
                    }
                },
                mArt: {
                    mArt1: {
                        text: 'Photography',
                        href: '#'
                    },
                    mArt2: {
                        text: 'Ad Art',
                        href: '#'
                    },
                    mArt3: {
                        text: 'Web Art',
                        href: '#'
                    }
                }
            };

            // create elements that will be cloned later
            var newUl = self.createElem('ul', 'subMenu');
            var newLi = self.createElem('li');
            var newA = self.createElem('a');

            // getOwnPropertyNames returns an array that can be iterated over with forEach
            Object.getOwnPropertyNames(menus).forEach(function(e) {
                var u = newUl.cloneNode();                // clone ul
                var pli = document.getElementById(e);     // get parent li
                pli.classList.add('sub-nav');             // add sub-nav className indicating a submenu exists
                // cycle through sub-items
                Object.getOwnPropertyNames(menus[e]).forEach(function(el) {
                    var li = newLi.cloneNode();           // clone li
                    var a = newA.cloneNode();             // clone a
                    a.textContent = menus[e][el].text;    // apply a text
                    a.href = menus[e][el].href;           // apply href
                    li.appendChild(a);                    // append a to li
                    u.appendChild(li);                    // append li to u
                });
                pli.appendChild(u);                       // append u to sub-nav li
            });
        },
        // helper function to create new elements
        createElem : function(el, className, id) {
            var o = document.createElement(el);
            if(className) {
                o.className = className;
            }
            if(id) {
                o.id = id;
            }
            return o;
        }
    };
    UB.DROPDOWN.init();
})();
<|endoftext|>


<commit_before>/**
 * The examples provided by Facebook are for non-commercial testing and
 * evaluation purposes only.
 *
 * Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * @flow
 */
'use strict';

var React = require('react-native');
var {
  Image,
  StyleSheet,
  Text,
  View,
  ActivityIndicatorIOS
} = React;

var ImageCapInsetsExample = require('./ImageCapInsetsExample');

var NetworkImageExample = React.createClass({
  watchID: (null: ?number),

  getInitialState: function() {
    return {
      error: false,
      loading: false,
      progress: 0
    };
  },
  render: function() {
    var loader = this.state.loading ?
      <View style={styles.progress}>
        <Text>{this.state.progress}%</Text>
        <ActivityIndicatorIOS style={{marginLeft:5}}/>
      </View> : null;
    return this.state.error ?
      <Text>{this.state.error}</Text> :
      <Image
        source={this.props.source}
        style={[styles.base, {overflow: 'visible'}]}
        onLoadStart={(e) => this.setState({loading: true})}
        onError={(e) => this.setState({error: e.nativeEvent.error, loading: false})}
        onProgress={(e) => this.setState({progress: Math.round(100 * e.nativeEvent.loaded / e.nativeEvent.total)})}
        onLoad={() => this.setState({loading: false, error: false})}>
        {loader}
      </Image>;
  }
});

exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<Image>';
exports.description = 'Base component for displaying different types of images.';

exports.examples = [
  {
    title: 'Plain Network Image',
    description: 'If the `source` prop `uri` property is prefixed with ' +
    '"http", then it will be downloaded from the network.',
    render: function() {
      return (
        <Image
          source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
          style={styles.base}
        />
      );
    },
  },
  {
    title: 'Plain Static Image',
    description: 'Static assets should be required by prefixing with `image!` ' +
      'and are located in the app bundle.',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image source={require('image!uie_thumb_normal')} style={styles.icon} />
          <Image source={require('image!uie_thumb_selected')} style={styles.icon} />
          <Image source={require('image!uie_comment_normal')} style={styles.icon} />
          <Image source={require('image!uie_comment_highlighted')} style={styles.icon} />
        </View>
      );
    },
  },
  {
    title: 'Error Handler',
    render: function() {
      return (
        <NetworkImageExample source={{uri: 'http://TYPO_ERROR_facebook.github.io/react/img/logo_og.png'}} />
      );
    },
  },
  {
    title: 'Image Download Progress',
    render: function() {
      return (
        <NetworkImageExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}}/>
      );
    },
  },
  {
    title: 'Border Color',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            source={smallImage}
            style={[
              styles.base,
              styles.background,
              {borderWidth: 3, borderColor: '#f099f0'}
            ]}
          />
        </View>
      );
    },
  },
  {
    title: 'Border Width',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            source={smallImage}
            style={[
              styles.base,
              styles.background,
              {borderWidth: 5, borderColor: '#f099f0'}
            ]}
          />
        </View>
      );
    },
  },
  {
    title: 'Border Radius',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            style={[styles.base, styles.background, {borderRadius: 5}]}
            source={smallImage}
          />
          <Image
            style={[
              styles.base,
              styles.background,
              styles.leftMargin,
              {borderRadius: 19}
            ]}
            source={smallImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Background Color',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image source={smallImage} style={styles.base} />
          <Image
            style={[
              styles.base,
              styles.leftMargin,
              {backgroundColor: 'rgba(0, 0, 100, 0.25)'}
            ]}
            source={smallImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {backgroundColor: 'red'}]}
            source={smallImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {backgroundColor: 'black'}]}
            source={smallImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Opacity',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            style={[styles.base, {opacity: 1}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.8}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.6}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.4}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.2}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0}]}
            source={fullImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Nesting',
    render: function() {
      return (
        <Image
          style={{width: 60, height: 60, backgroundColor: 'transparent'}}
          source={fullImage}>
          <Text style={styles.nestedText}>
            React
          </Text>
        </Image>
      );
    },
  },
  {
    title: 'Tint Color',
    description: 'The `tintColor` style prop changes all the non-alpha ' +
      'pixels to the tint color.',
    render: function() {
      return (
        <View>
          <View style={styles.horizontal}>
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, {tintColor: '#5ac8fa' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#4cd964' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#ff2d55' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#8e8e93' }]}
            />
          </View>
          <Text style={styles.sectionText}>
            It also works with downloaded images:
          </Text>
          <View style={styles.horizontal}>
            <Image
              source={smallImage}
              style={[styles.base, {tintColor: '#5ac8fa' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#4cd964' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#ff2d55' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#8e8e93' }]}
            />
          </View>
        </View>
      );
    },
  },
  {
    title: 'Resize Mode',
    description: 'The `resizeMode` style prop controls how the image is ' +
      'rendered within the frame.',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <View>
            <Text style={[styles.resizeModeText]}>
              Contain
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.contain}
              source={fullImage}
            />
          </View>
          <View style={styles.leftMargin}>
            <Text style={[styles.resizeModeText]}>
              Cover
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.cover}
              source={fullImage}
            />
          </View>
          <View style={styles.leftMargin}>
            <Text style={[styles.resizeModeText]}>
              Stretch
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.stretch}
              source={fullImage}
            />
          </View>
        </View>
      );
    },
  },
  {
    title: 'Cap Insets',
    description:
      'When the image is resized, the corners of the size specified ' +
      'by capInsets will stay a fixed size, but the center content and ' +
      'borders of the image will be stretched. This is useful for creating ' +
      'resizable rounded buttons, shadows, and other resizable assets.',
    render: function() {
      return <ImageCapInsetsExample />;
    },
  },
];

var fullImage = {uri: 'http://facebook.github.io/react/img/logo_og.png'};
var smallImage = {uri: 'http://facebook.github.io/react/img/logo_small.png'};

var styles = StyleSheet.create({
  base: {
    width: 38,
    height: 38,
  },
  progress: {
    flex: 1,
    alignItems: 'center',
    flexDirection: 'row',
    width: 100
  },
  leftMargin: {
    marginLeft: 10,
  },
  background: {
    backgroundColor: '#222222'
  },
  sectionText: {
    marginVertical: 6,
  },
  nestedText: {
    marginLeft: 12,
    marginTop: 20,
    backgroundColor: 'transparent',
    color: 'white'
  },
  resizeMode: {
    width: 90,
    height: 60,
    borderWidth: 0.5,
    borderColor: 'black'
  },
  resizeModeText: {
    fontSize: 11,
    marginBottom: 3,
  },
  icon: {
    width: 15,
    height: 15,
  },
  horizontal: {
    flexDirection: 'row',
  }
});
<commit_msg>Fix fuzziness images in UIExplorer <Image> sample.<commit_after>/**
 * The examples provided by Facebook are for non-commercial testing and
 * evaluation purposes only.
 *
 * Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * @flow
 */
'use strict';

var React = require('react-native');
var {
  Image,
  StyleSheet,
  Text,
  View,
  ActivityIndicatorIOS
} = React;

var ImageCapInsetsExample = require('./ImageCapInsetsExample');

var NetworkImageExample = React.createClass({
  watchID: (null: ?number),

  getInitialState: function() {
    return {
      error: false,
      loading: false,
      progress: 0
    };
  },
  render: function() {
    var loader = this.state.loading ?
      <View style={styles.progress}>
        <Text>{this.state.progress}%</Text>
        <ActivityIndicatorIOS style={{marginLeft:5}}/>
      </View> : null;
    return this.state.error ?
      <Text>{this.state.error}</Text> :
      <Image
        source={this.props.source}
        style={[styles.base, {overflow: 'visible'}]}
        onLoadStart={(e) => this.setState({loading: true})}
        onError={(e) => this.setState({error: e.nativeEvent.error, loading: false})}
        onProgress={(e) => this.setState({progress: Math.round(100 * e.nativeEvent.loaded / e.nativeEvent.total)})}
        onLoad={() => this.setState({loading: false, error: false})}>
        {loader}
      </Image>;
  }
});

exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<Image>';
exports.description = 'Base component for displaying different types of images.';

exports.examples = [
  {
    title: 'Plain Network Image',
    description: 'If the `source` prop `uri` property is prefixed with ' +
    '"http", then it will be downloaded from the network.',
    render: function() {
      return (
        <Image
          source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
          style={styles.base}
        />
      );
    },
  },
  {
    title: 'Plain Static Image',
    description: 'Static assets should be required by prefixing with `image!` ' +
      'and are located in the app bundle.',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image source={require('image!uie_thumb_normal')} style={styles.icon} />
          <Image source={require('image!uie_thumb_selected')} style={styles.icon} />
          <Image source={require('image!uie_comment_normal')} style={styles.icon} />
          <Image source={require('image!uie_comment_highlighted')} style={styles.icon} />
        </View>
      );
    },
  },
  {
    title: 'Error Handler',
    render: function() {
      return (
        <NetworkImageExample source={{uri: 'http://TYPO_ERROR_facebook.github.io/react/img/logo_og.png'}} />
      );
    },
  },
  {
    title: 'Image Download Progress',
    render: function() {
      return (
        <NetworkImageExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}}/>
      );
    },
  },
  {
    title: 'Border Color',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            source={smallImage}
            style={[
              styles.base,
              styles.background,
              {borderWidth: 3, borderColor: '#f099f0'}
            ]}
          />
        </View>
      );
    },
  },
  {
    title: 'Border Width',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            source={smallImage}
            style={[
              styles.base,
              styles.background,
              {borderWidth: 5, borderColor: '#f099f0'}
            ]}
          />
        </View>
      );
    },
  },
  {
    title: 'Border Radius',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            style={[styles.base, styles.background, {borderRadius: 5}]}
            source={smallImage}
          />
          <Image
            style={[
              styles.base,
              styles.background,
              styles.leftMargin,
              {borderRadius: 19}
            ]}
            source={smallImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Background Color',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image source={smallImage} style={styles.base} />
          <Image
            style={[
              styles.base,
              styles.leftMargin,
              {backgroundColor: 'rgba(0, 0, 100, 0.25)'}
            ]}
            source={smallImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {backgroundColor: 'red'}]}
            source={smallImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {backgroundColor: 'black'}]}
            source={smallImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Opacity',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <Image
            style={[styles.base, {opacity: 1}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.8}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.6}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.4}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0.2}]}
            source={fullImage}
          />
          <Image
            style={[styles.base, styles.leftMargin, {opacity: 0}]}
            source={fullImage}
          />
        </View>
      );
    },
  },
  {
    title: 'Nesting',
    render: function() {
      return (
        <Image
          style={{width: 60, height: 60, backgroundColor: 'transparent'}}
          source={fullImage}>
          <Text style={styles.nestedText}>
            React
          </Text>
        </Image>
      );
    },
  },
  {
    title: 'Tint Color',
    description: 'The `tintColor` style prop changes all the non-alpha ' +
      'pixels to the tint color.',
    render: function() {
      return (
        <View>
          <View style={styles.horizontal}>
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, {tintColor: '#5ac8fa' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#4cd964' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#ff2d55' }]}
            />
            <Image
              source={require('image!uie_thumb_normal')}
              style={[styles.icon, styles.leftMargin, {tintColor: '#8e8e93' }]}
            />
          </View>
          <Text style={styles.sectionText}>
            It also works with downloaded images:
          </Text>
          <View style={styles.horizontal}>
            <Image
              source={smallImage}
              style={[styles.base, {tintColor: '#5ac8fa' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#4cd964' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#ff2d55' }]}
            />
            <Image
              source={smallImage}
              style={[styles.base, styles.leftMargin, {tintColor: '#8e8e93' }]}
            />
          </View>
        </View>
      );
    },
  },
  {
    title: 'Resize Mode',
    description: 'The `resizeMode` style prop controls how the image is ' +
      'rendered within the frame.',
    render: function() {
      return (
        <View style={styles.horizontal}>
          <View>
            <Text style={[styles.resizeModeText]}>
              Contain
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.contain}
              source={fullImage}
            />
          </View>
          <View style={styles.leftMargin}>
            <Text style={[styles.resizeModeText]}>
              Cover
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.cover}
              source={fullImage}
            />
          </View>
          <View style={styles.leftMargin}>
            <Text style={[styles.resizeModeText]}>
              Stretch
            </Text>
            <Image
              style={styles.resizeMode}
              resizeMode={Image.resizeMode.stretch}
              source={fullImage}
            />
          </View>
        </View>
      );
    },
  },
  {
    title: 'Cap Insets',
    description:
      'When the image is resized, the corners of the size specified ' +
      'by capInsets will stay a fixed size, but the center content and ' +
      'borders of the image will be stretched. This is useful for creating ' +
      'resizable rounded buttons, shadows, and other resizable assets.',
    render: function() {
      return <ImageCapInsetsExample />;
    },
  },
];

var fullImage = {uri: 'http://facebook.github.io/react/img/logo_og.png'};
var smallImage = {uri: 'http://facebook.github.io/react/img/logo_small_2x.png'};

var styles = StyleSheet.create({
  base: {
    width: 38,
    height: 38,
  },
  progress: {
    flex: 1,
    alignItems: 'center',
    flexDirection: 'row',
    width: 100
  },
  leftMargin: {
    marginLeft: 10,
  },
  background: {
    backgroundColor: '#222222'
  },
  sectionText: {
    marginVertical: 6,
  },
  nestedText: {
    marginLeft: 12,
    marginTop: 20,
    backgroundColor: 'transparent',
    color: 'white'
  },
  resizeMode: {
    width: 90,
    height: 60,
    borderWidth: 0.5,
    borderColor: 'black'
  },
  resizeModeText: {
    fontSize: 11,
    marginBottom: 3,
  },
  icon: {
    width: 15,
    height: 15,
  },
  horizontal: {
    flexDirection: 'row',
  }
});
<|endoftext|>


<commit_before>'use strict'

// === WATERMILL ===
const {
  task,
  join,
  junction,
  fork
} = require('../../..')

const task0 = task({name: 'task0'}, () => `echo "something0"`)

const task1 = task({name: 'task1'}, () => `echo "something1"`)

const task2 = task({name: 'task2'}, () => `echo "something2"`)

const task3 = task({name: 'task3'}, () => `echo "something3"`)

const task4 = task({name: 'task4'}, () => `echo "something4"`)

const task5 = task({name: 'task5'}, () => `echo "something5"`)

const task6 = task({name: 'task6'}, () => `echo "something6"`)

const task7 = task({name: 'task7'}, () => `echo "something7"`)

// alternative with manual handling of task5 (the last leave of each branch)
const pipeline = join(
  task0,
  fork(
    join(task2,task5),
    join(task4,
      fork(
        join(task1,task5),
        join(task3,task5)
      )
    )
  )
)

const pipeline2 = join(
  task0,
  fork(
    join(
      task4,
        fork(
          task1,
          task3
        ),
      task6
    ),
    task2
  ),
  task5
)

const pipeline3 = join(
  task0,
  fork(
      fork(
        task1,
        task3
      ),
      task6
  ),
  task5
)

const pipeline4 = join(
  task0,
  fork(
    join(
      task4,
      fork(
        join(
          task7,
          fork(
            task1,
            task3
          )
        ),
        task6
      )
    ),
    task2
  ),
  task5
)

pipeline4()<commit_msg>added a new pipeline for tests<commit_after>'use strict'

// === WATERMILL ===
const {
  task,
  join,
  junction,
  fork
} = require('../../..')

const task0 = task({name: 'task0'}, () => `echo "something0"`)

const task1 = task({name: 'task1'}, () => `echo "something1"`)

const task2 = task({name: 'task2'}, () => `echo "something2"`)

const task3 = task({name: 'task3'}, () => `echo "something3"`)

const task4 = task({name: 'task4'}, () => `echo "something4"`)

const task5 = task({name: 'task5'}, () => `echo "something5"`)

const task6 = task({name: 'task6'}, () => `echo "something6"`)

const task7 = task({name: 'task7'}, () => `echo "something7"`)

// alternative with manual handling of task5 (the last leave of each branch)
const pipeline = join(
  task0,
  fork(
    join(task2,task5),
    join(task4,
      fork(
        join(task1,task5),
        join(task3,task5)
      )
    )
  )
)

const pipeline2 = join(
  task0,
  fork(
    join(
      task4,
        fork(
          task1,
          task3
        ),
      task6
    ),
    task2
  ),
  task5
)

const pipeline3 = join(
  task0,
  fork(
      fork(
        task1,
        task3
      ),
      task6
  ),
  task5
)

const pipeline4 = join(
  task0,
  fork(
    join(
      task4,
      fork(
        join(
          task7,
          fork(
            task1,
            task3
          )
        ),
        task6
      )
    ),
    task2
  ),
  task5
)

const pipeline5 = join(
  task0,
  fork(
    join(
      task4,
      fork(
        join(
          task7,
          junction(
            task1,
            task3
          ),
          task6
        ),
        task6
      )
    ),
    task2
  ),
  task5
)

pipeline5()<|endoftext|>


<commit_before>var p = Ent.Project.create('robin', 'js');
p.setVersion(3, 2, 0);
p.setBolt('library', '**/*.js');
p.setBoltTest();

<commit_msg>TBIO-1766-b: version<commit_after>var p = Ent.Project.create('robin', 'js');
p.setVersion(3, 3, 0);
p.setBolt('library', '**/*.js');
p.setBoltTest();

<|endoftext|>


<commit_before>(function(window) {
  function findValueWithName(array, name) {
    var value;

    array.forEach(function(object) {
      if (object.name === name) {
        value = object.value;
      }
    });

    return value;
  }

  function trackNewcomerSignupDone() {
    if ($('.js-newcomer-register-submit-thanks').length > 0) {
      analytics.track('Newcomer finished Wintrgarden signup', {
        locale: CURRENT_LOCALE
      });
    }
  }

  function trackNewcomerSignupStart() {
    var trackNewcomer = function(selector, regType) {
     $(document).on('click', selector, function() {
       analytics.track('Newcomer start Wintrgarden signup', {
         reg_type: regType,
         signup_url: location.href,
         locale: CURRENT_LOCALE
       });
     });
    };

    trackNewcomer('.js-wintrgarden-signup-no-reg', 'No reg.');
    trackNewcomer('.js-wintrgarden-signup-reg', 'Reg.');
  }

  function trackCompanySignup() {
    $('.js-company-signup-form').submit(function() {
      var formData = $(this).serializeArray();

      var email = findValueWithName(formData, 'email');
      var phone = findValueWithName(formData, 'phone');
      var name = findValueWithName(formData, 'last_name');
      var company = findValueWithName(formData, 'company');
      var city = findValueWithName(formData, '00N580000088gDR');

      analytics.track('Company Interest Sign Up', {
        name: name,
        email: email,
        phone: phone,
        company: company,
        city: city,
        signup_url: location.href,
        locale: CURRENT_LOCALE
      });
    });
  }

  function trackNewcomerRegPopupOpen() {
    $('.cd-popup-trigger-newcomer-signup').on('click', function() {
      analytics.track('Newcomer reg popup open', {
        locale: CURRENT_LOCALE
      });
    });
  }

  function trackCompanyRegPopupOpen() {
    $('.cd-popup-trigger-signin').on('click', function() {
      analytics.track('Company reg popup open', {
        locale: CURRENT_LOCALE
      });
    });
  }

  function initTrackOfDOMElements() {
    $('[data-track]').each(function() {
      var $element = $(this);
      var eventName = $element.attr('data-track') || 'click';
      var label = $element.attr('data-track-label');

      if (label) {
        // Add event listener to element
        $(document).on(eventName, function() {
          analytics.track(label, {
            locale: CURRENT_LOCALE
          });
        });
      } else {
        console.error('[just-track] data-track-label can *not* be blank!')
      }
    });
  }

  function trackJobCardClick() {
    $(document).on('click', '.job-card', function() {
      analytics.track('Job card click', {
        locale: CURRENT_LOCALE
      });
    });
  }

  var JustTrack = {
    init: function() {
      trackCompanySignup();
      trackNewcomerSignupStart();
      trackNewcomerSignupDone();
      trackNewcomerRegPopupOpen();
      trackCompanyRegPopupOpen();
      initTrackOfDOMElements();
      trackJobCardClick();
    }
  };

  window.JustTrack = JustTrack;
})(window);
<commit_msg>Update just-track in order to switch from segment to google analytics vanilla<commit_after>---
---

(function(window) {

  /* Google Analytics Categories */
  var registrationCategory = '{{site.analytics.categories.registration}}';
  var companyCategory = '{{site.analytics.categories.company}}';

  /**
  * Convenience function for tracking using Google Analytics
  * Since we only post events this function can be used for all tracking at this point.
  *
  @ param category    The category to post the event under
  @ param action      Action (type of click) that was performed
  @ param label       The label you want to use to describe the event
  */
  function gaTracking(category, action, label) {

    console.log('Category: ' + category +'\n');
    console.log('Action: ' + action +'\n');
    console.log('Label: ' + label +'\n');
    // ga('send', {
    //   hitType: 'event',
    //   eventCategory: category,
    //   eventAction: action,
    //   eventLabel: label
    // });
  }

  function findValueWithName(array, name) {
    var value;

    array.forEach(function(object) {
      if (object.name === name) {
        value = object.value;
      }
    });

    return value;
  }

  function trackNewcomerSignupDone() {
    if ($('.js-newcomer-register-submit-thanks').length > 0) {
      gaTracking(registrationCategory,
                'finished registration',
                'Newcomer finished Wintrgarden signup');
    }
  }

  function trackNewcomerSignupStart() {
    var trackNewcomer = function(selector, eventLabel) {
      $(document).on('click', selector, function() {
        gaTracking(registrationCategory,
                   'started',
                   eventLabel);
      });
    }

    var newcomerStart = 'Newcomer start Wintrgarden signup';
    trackNewcomer('.js-wintrgarden-signup-no-reg', newcomerStart + ' - No reg.');
    trackNewcomer('.js-wintrgarden-signup-reg', newcomerStart + ' - Reg.');
  }

  function trackCompanySignup() {
    $('.js-company-signup-form').submit(function() {
      gaTracking(companyCategory, 'submit', 'Company Interest Sign Up');
    });
  }

  function trackNewcomerRegPopupOpen() {
    $('.cd-popup-trigger-newcomer-signup').on('click', function() {
      gaTracking(
        registrationCategory,
        'click',
        'Newcomer reg popup open');
    });
  }

  function trackCompanyRegPopupOpen() {
    $('.cd-popup-trigger-signin').on('click', function() {
      gaTracking(
        registrationCategory,
        'click',
        'Company reg popup open');
    });
  }

  function initTrackOfDOMElements() {
    $('[data-track]').each(function() {
      var $element = $(this);
      var category =  $element.attr('category');
      var action = $element.attr('data-track') || 'click';
      var label = $element.attr('data-track-label');

      if (!category) {
        console.error('[just-track] category can *not* be blank!');
      } else if (label) {
        // Add event listener to element
        $element.on(action, function() {
          gaTracking(
            category,
            action,
            label
          );
        });
      } else {
        console.error('[just-track] data-track-label can *not* be blank!')
      }
    });
  }

  function trackJobCardClick() {
    $(document).on('click', '.job-card', function() {
      gaTracking(registrationCategory, 'click', 'Click job card from start page');
    });
  }

  var JustTrack = {
    init: function() {
      trackCompanySignup();
      trackNewcomerSignupStart();
      trackNewcomerSignupDone();
      trackNewcomerRegPopupOpen();
      trackCompanyRegPopupOpen();
      initTrackOfDOMElements();
      trackJobCardClick();
    }
  };

  window.JustTrack = JustTrack;
})(window);
<|endoftext|>


<commit_before>'use strict';

angular.module('pumprApp')
  .controller('AdminCtrl', function ($scope, $http, Auth, User) {

    // Use the User $resource to fetch all users
    $scope.users = User.query();

    $scope.delete = function(user) {
      User.remove({ id: user._id });
      angular.forEach($scope.users, function(u, i) {
        if (u === user) {
          $scope.users.splice(i, 1);
        }
      });
    };

    $scope.roles = [{role: 'admin'}, {role:'superuser'}, {role:'user'}];
    // $scope.selectedRole;

    $scope.changeRole = function(user, role){
      var targ;
      if (!e) var e = window.event;
      if (e.target) targ = e.target;
      else if (e.srcElement) targ = e.srcElement;
      // defeat Safari bug
      if (targ.nodeType == 3){
        targ = targ.parentNode;
      }

      user.newRole = role;
      console.log(user);
      Auth.changeRole(user)
        .then( function() {
          angular.element(targ).addClass('role-success');
        })
        .catch( function() {
          angular.element(targ).addClass('role-failure');
        });
    };

  });
<commit_msg>Removed bloat code<commit_after>'use strict';

angular.module('pumprApp')
  .controller('AdminCtrl', function ($scope, $http, Auth, User) {

    // Use the User $resource to fetch all users
    $scope.users = User.query();

    $scope.delete = function(user) {
      User.remove({ id: user._id });
      angular.forEach($scope.users, function(u, i) {
        if (u === user) {
          $scope.users.splice(i, 1);
        }
      });
    };

    $scope.roles = [{role: 'admin'}, {role:'superuser'}, {role:'user'}];
    // $scope.selectedRole;

    $scope.changeRole = function(user, role){
      var targ;
      if (!e) var e = window.event;
      if (e.target) targ = e.target;
      else if (e.srcElement) targ = e.srcElement;
      // defeat Safari bug
      if (targ.nodeType == 3){
        targ = targ.parentNode;
      }

      user.newRole = role;

      Auth.changeRole(user)
        .then( function() {
          angular.element(targ).addClass('role-success');
        })
        .catch( function() {
          angular.element(targ).addClass('role-failure');
        });
    };

  });
<|endoftext|>


<commit_before>import {KEYCODES} from '../utils/fef-keycodes';

const HOOK_CLASS        = '.js-genex';
const TOGGLE_CLASS      = '.js-genex-toggle';
const ANIMATION_DEFAULT_EASING = 'easeInOutCubic';

let ANIMATION_DEFAULT_DURATION = 400;

if (window.matchMedia('(prefers-reduced-motion)').matches) {
    ANIMATION_DEFAULT_DURATION = 0;
}

export function init() {
    $(HOOK_CLASS).each((index, element) => {
        new FefGenericExpander(element);
    });
}
export class FefGenericExpander {
    constructor(element) {
        this.$element = $(element);
        this.openToggleClass = this.$element.attr('data-genex-open-toggle-class') || 'js-genex-toggle-open';
        this.openPanelClass  = this.$element.attr('data-genex-open-panel-class')  || 'js-genex-panel-open';

        this.eventSource = this.$element.attr('data-event-source');
        this.eventValue = this.$element.attr('data-event-value');

        this.initA11Y();
        this.bindEvents();

        this.$lastToggle = undefined;
    }

    initA11Y() {
        // set aria-expand attribute
        $(TOGGLE_CLASS).attr('aria-expanded', false);

        // set aria-controls attribute
        $('[data-genex-target-id]').each((index, element) => {
            $(element).attr('aria-controls', $(element).attr('data-genex-target-id'));
        });
    }

    bindEvents() {
        let clickHandler = (event) => {
            event.preventDefault();
            this.togglePanels(event);
        };

        let keyboardHandler = (event) => {
            if (event.keyCode === KEYCODES.enter || event.keyCode === KEYCODES.space) {
                event.preventDefault();
                this.togglePanels(event);
            }
        };

        this.$element.on('click', TOGGLE_CLASS, clickHandler);
        this.$element.on('keydown', TOGGLE_CLASS, keyboardHandler);
    }

    togglePanels(event) {
        let $lastToggle = $('.' + this.openToggleClass);

        if($lastToggle.length > 0) {
            this.closeOpenPanels(event);
        } else {
            this.openCurrentPanel(event);
        }
    }

    closeOpenPanels(event) {
        this.setA11YState($(TOGGLE_CLASS), false);
        this.doTracking(event, false);
        const self = this;
        $('.' + this.openPanelClass)
            .removeClass(this.openPanelClass)
            .slideUp(ANIMATION_DEFAULT_DURATION, ANIMATION_DEFAULT_EASING, () => {
                self.openCurrentPanel(event);
                $('.' + this.openToggleClass).removeClass(this.openToggleClass);
            });
    }

    openCurrentPanel(event) {
        let $currentToggle = $(event.currentTarget);
        let $currentPanel  = $('#' + $currentToggle.attr('data-genex-target-id'));

        if(this.$lastToggle === undefined || this.$lastToggle.get(0) !== $currentToggle.get(0) || !$currentToggle.hasClass(this.openToggleClass)) {
            this.doTracking(event, true);
            this.setA11YState($currentToggle, true);
            $currentPanel.slideDown(
                ANIMATION_DEFAULT_DURATION,
                ANIMATION_DEFAULT_EASING,
                () => {
                    $currentToggle.addClass(this.openToggleClass);
                    $currentPanel.addClass(this.openPanelClass);
                }
            );
        }

        this.$lastToggle = $currentToggle;
    }

    setA11YState($element, isActive) {
        if(isActive) {
            $element.attr('aria-expanded', 'true');
        } else {
            $element.attr('aria-expanded', 'false');
        }
    }

    doTracking(event, panelWillBeOpen) {
        if(this.eventSource && this.eventValue) {
            let trackingData = {
                event_type: event.type === 'keydown' ? 'keypress' : 'click',
                event_source: this.eventSource,
                event_name:  panelWillBeOpen ? 'Open': 'Close',
                event_value: this.eventValue
            };

            $(window).trigger('fef.track.interaction', trackingData);
            $(window).trigger('fef.expandable.interaction', trackingData);
        }
    }
}<commit_msg>Fixed a bug of expander<commit_after>import {KEYCODES} from '../utils/fef-keycodes';

const HOOK_CLASS        = '.js-genex';
const TOGGLE_CLASS      = '.js-genex-toggle';
const ANIMATION_DEFAULT_EASING = 'easeInOutCubic';

let ANIMATION_DEFAULT_DURATION = 400;

if (window.matchMedia('(prefers-reduced-motion)').matches) {
    ANIMATION_DEFAULT_DURATION = 0;
}

export function init() {
    $(HOOK_CLASS).each((index, element) => {
        new FefGenericExpander(element);
    });
}
export class FefGenericExpander {
    constructor(element) {
        this.$element = $(element);
        this.openToggleClass = this.$element.attr('data-genex-open-toggle-class') || 'js-genex-toggle-open';
        this.openPanelClass  = this.$element.attr('data-genex-open-panel-class')  || 'js-genex-panel-open';

        this.eventSource = this.$element.attr('data-event-source');
        this.eventValue = this.$element.attr('data-event-value');

        this.initA11Y();
        this.bindEvents();

        this.isTogglingAllowed = true;
        this.isSwitching = false;
    }

    initA11Y() {
        // set aria-expand attribute
        $(TOGGLE_CLASS).attr('aria-expanded', false);

        // set aria-controls attribute
        $('[data-genex-target-id]').each((index, element) => {
            $(element).attr('aria-controls', $(element).attr('data-genex-target-id'));
        });
    }

    bindEvents() {
        let clickHandler = (event) => {
            event.preventDefault();
            if (this.isTogglingAllowed) {
                this.togglePanels(event);
                this.isTogglingAllowed = false;
                setTimeout(() => {this.isTogglingAllowed = true}, !this.isSwitching ? ANIMATION_DEFAULT_DURATION : ANIMATION_DEFAULT_DURATION * 2);
            }
        };

        let keyboardHandler = (event) => {
            if (event.keyCode === KEYCODES.enter || event.keyCode === KEYCODES.space) {
                event.preventDefault();
                this.togglePanels(event);
            }
        };

        this.$element.on('click', TOGGLE_CLASS, clickHandler);
        this.$element.on('keydown', TOGGLE_CLASS, keyboardHandler);
    }

    togglePanels(event) {
        let $lastToggle = $('.' + this.openToggleClass);

        if($lastToggle.length > 0) {
            this.closeOpenPanels(event);
        } else {
            this.openCurrentPanel(event);
        }
    }

    closeOpenPanels(event) {
        this.setA11YState($(TOGGLE_CLASS), false);
        this.doTracking(event, false);
        const self = this;

        let $currentToggle = $(event.currentTarget);
        let $lastToggle = $('.' + this.openToggleClass);
        if ($lastToggle.get(0) !== $currentToggle.get(0)) {
            this.isSwitching = true;
        }

        $('.' + this.openPanelClass)
            .removeClass(this.openPanelClass)
            .slideUp(ANIMATION_DEFAULT_DURATION, ANIMATION_DEFAULT_EASING, () => {
                self.openCurrentPanel(event);
                $('.' + this.openToggleClass).removeClass(this.openToggleClass);
            });
    }

    openCurrentPanel(event) {
        let $currentToggle = $(event.currentTarget);
        let $currentPanel  = $('#' + $currentToggle.attr('data-genex-target-id'));
        let $lastToggle = $('.' + this.openToggleClass);

        if($lastToggle === undefined || $lastToggle.get(0) !== $currentToggle.get(0)) {
            this.doTracking(event, true);
            this.setA11YState($currentToggle, true);
            $currentPanel.slideDown(
                ANIMATION_DEFAULT_DURATION,
                ANIMATION_DEFAULT_EASING,
                () => {
                    $currentToggle.addClass(this.openToggleClass);
                    $currentPanel.addClass(this.openPanelClass);
                    $currentToggle.focus();
                }
            );
        }
    }

    setA11YState($element, isActive) {
        if(isActive) {
            $element.attr('aria-expanded', 'true');
        } else {
            $element.attr('aria-expanded', 'false');
        }
    }

    doTracking(event, panelWillBeOpen) {
        if(this.eventSource && this.eventValue) {
            let trackingData = {
                event_type: event.type === 'keydown' ? 'keypress' : 'click',
                event_source: this.eventSource,
                event_name:  panelWillBeOpen ? 'Open': 'Close',
                event_value: this.eventValue
            };

            $(window).trigger('fef.track.interaction', trackingData);
            $(window).trigger('fef.expandable.interaction', trackingData);
        }
    }
}<|endoftext|>


<commit_before>/*jshint strict: false */
/*global require */

////////////////////////////////////////////////////////////////////////////////
/// @brief foxx administration actions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var actions = require("org/arangodb/actions");
var foxxManager = require("org/arangodb/foxx/manager");

var easyPostCallback = actions.easyPostCallback;

// -----------------------------------------------------------------------------
// --SECTION--                                                  public functions
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief sets up a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/setup",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.setup(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief tears down a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/teardown",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.teardown(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief installs a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/install",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;

      return foxxManager.install(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief uninstalls a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/uninstall",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.uninstall(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief replaces a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/replace",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;

      return foxxManager.replace(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief upgrades a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/upgrade",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;

      return foxxManager.upgrade(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief configures a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/configure",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;
      var options = body.options;

      return foxxManager.configure(mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief Gets the configuration of a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/configuration",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.configuration(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief Toggles the development mode of a foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/development",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;
      var activate = body.activate;
      if (activate) {
        return foxxManager.development(mount);
      } else {
        return foxxManager.production(mount);
      }
    }
  })
});

// -----------------------------------------------------------------------------
// --SECTION--                                                       END-OF-FILE
// -----------------------------------------------------------------------------

// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|/// @startDocuBlock\\|// --SECTION--\\|/// @\\}"
// End:
<commit_msg>The http install procedure will try to update the appstore before installing apps<commit_after>/*jshint strict: false */
/*global require */

////////////////////////////////////////////////////////////////////////////////
/// @brief foxx administration actions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var actions = require("org/arangodb/actions");
var foxxManager = require("org/arangodb/foxx/manager");

var easyPostCallback = actions.easyPostCallback;

// -----------------------------------------------------------------------------
// --SECTION--                                                  public functions
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief sets up a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/setup",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.setup(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief tears down a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/teardown",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.teardown(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief installs a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/install",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;
      foxxManager.update();
      return foxxManager.install(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief uninstalls a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/uninstall",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.uninstall(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief replaces a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/replace",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;

      return foxxManager.replace(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief upgrades a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/upgrade",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var appInfo = body.appInfo;
      var mount = body.mount;
      var options = body.options;

      return foxxManager.upgrade(appInfo, mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief configures a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/configure",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;
      var options = body.options;

      return foxxManager.configure(mount, options);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief Gets the configuration of a Foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/configuration",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;

      return foxxManager.configuration(mount);
    }
  })
});

////////////////////////////////////////////////////////////////////////////////
/// @brief Toggles the development mode of a foxx application
////////////////////////////////////////////////////////////////////////////////

actions.defineHttp({
  url : "_admin/foxx/development",
  prefix : false,

  callback: easyPostCallback({
    body: true,
    callback: function (body) {
      var mount = body.mount;
      var activate = body.activate;
      if (activate) {
        return foxxManager.development(mount);
      } else {
        return foxxManager.production(mount);
      }
    }
  })
});

// -----------------------------------------------------------------------------
// --SECTION--                                                       END-OF-FILE
// -----------------------------------------------------------------------------

// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|/// @startDocuBlock\\|// --SECTION--\\|/// @\\}"
// End:
<|endoftext|>


<commit_before>/*
 * FuzzSource: a Readable stream that emits "size" bytes of random data.
 * It also makes the raw buffer of the entire data stream available.  (It's
 * therefore not streaming, and requires buffering everything in memory.)
 */

var mod_util = require('util');
var mod_stream = require('stream');
if (!mod_stream.Transform)
	/* 0.8 shim */
	mod_stream = require('readable-stream');

module.exports = FuzzSource;

function FuzzSource(size, options)
{
	var buf, i;

	buf = new Buffer(size);
	for (i = 0; i < size; i++)
		buf[i] = 65 + Math.floor(Math.random() * 26);

	this.ds_emitted = 0;
	this.ds_buf = buf;

	mod_stream.Readable.call(this, options);
}

mod_util.inherits(FuzzSource, mod_stream.Readable);

FuzzSource.prototype._read = function (sz)
{
	var count, b, i;

	count = Math.min(this.ds_buf.length - this.ds_emitted, sz);
	if (count === 0) {
		this.push(null);
		return;
	}

	b = new Buffer(count);
	for (i = 0; i < count; i++)
		b[i] = this.ds_buf[this.ds_emitted + i];
	this.ds_emitted += count;
	this.push(b);
};

FuzzSource.prototype.rawbuf = function ()
{
	return (this.ds_buf);
};
<commit_msg>fuzz test should not limit itself to ASCII<commit_after>/*
 * FuzzSource: a Readable stream that emits "size" bytes of random data.
 * It also makes the raw buffer of the entire data stream available.  (It's
 * therefore not streaming, and requires buffering everything in memory.)
 */

var mod_util = require('util');
var mod_stream = require('stream');
if (!mod_stream.Transform)
	/* 0.8 shim */
	mod_stream = require('readable-stream');

module.exports = FuzzSource;

function FuzzSource(size, options)
{
	var buf, i;

	buf = new Buffer(size);
	for (i = 0; i < size; i++)
		buf[i] = Math.floor(Math.random() * 256);

	this.ds_emitted = 0;
	this.ds_buf = buf;

	mod_stream.Readable.call(this, options);
}

mod_util.inherits(FuzzSource, mod_stream.Readable);

FuzzSource.prototype._read = function (sz)
{
	var count, b, i;

	count = Math.min(this.ds_buf.length - this.ds_emitted, sz);
	if (count === 0) {
		this.push(null);
		return;
	}

	b = new Buffer(count);
	for (i = 0; i < count; i++)
		b[i] = this.ds_buf[this.ds_emitted + i];
	this.ds_emitted += count;
	this.push(b);
};

FuzzSource.prototype.rawbuf = function ()
{
	return (this.ds_buf);
};
<|endoftext|>