<commit_before>/**
 * Created by AlexanderC on 5/27/15.
 */

'use strict';

/**
 * Available AWS regions
 */
export class Region {
  /**
   * @returns {String}
   */
  static get ANY() {
    return '*';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_TOKYO() {
    return 'ap-northeast-1';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_SINGAPORE() {
    return 'ap-southeast-1';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_SYDNEY() {
    return 'ap-southeast-2';
  }

  /**
   * @returns {String}
   */
  static get EU_FRANKFURT() {
    return 'eu-central-1';
  }

  /**
   * @returns {String}
   */
  static get EU_IRELAND() {
    return 'eu-west-1';
  }

  /**
   * @returns {String}
   */
  static get SOUTH_AMERICA_SAO_PAULO() {
    return 'sa-east-1';
  }

  /**
   * @returns {String}
   */
  static get US_EAST_N_VIRGINIA() {
    return 'us-east-1';
  }

  /**
   * @returns {String}
   */
  static get US_WEST_N_CALIFORNIA() {
    return 'us-west-1';
  }

  /**
   * @returns {String}
   */
  static get US_WEST_OREGON() {
    return 'us-west-2';
  }

  /**
   * @param {String} name
   * @returns {Boolean}
   */
  static exists(name) {
    return name === '' || -1 !== Region.list().indexOf(name);
  }

  /**
   * @returns {String[]}
   */
  static list() {
    return [
      Region.ANY,
      Region.ASIA_PACIFIC_TOKYO,
      Region.ASIA_PACIFIC_SYDNEY,
      Region.ASIA_PACIFIC_SINGAPORE,
      Region.EU_FRANKFURT,
      Region.EU_IRELAND,
      Region.SOUTH_AMERICA_SAO_PAULO,
      Region.US_EAST_N_VIRGINIA,
      Region.US_WEST_N_CALIFORNIA,
      Region.US_WEST_OREGON,
    ];
  }

  /**
   * List method alias
   *
   * @returns {String[]}
   */
  static all() {
    return Region.list();
  }

  /**
   * @param {string} defaultRegion
   * @param {array} availableRegions
   * @returns {string}
   */
  static getAppropriateAwsRegion(defaultRegion, availableRegions) {
    if (availableRegions.indexOf(defaultRegion) !== -1) {
      return defaultRegion;
    }

    let regionContinent = defaultRegion.split('-')[0];

    for (let regionKey in availableRegions) {
      if (!availableRegions.hasOwnProperty(regionKey)) {
        continue;
      }

      let region = availableRegions[regionKey];

      if (region === Region.ANY) {
        return defaultRegion;
      }

      if (region.split('-')[0] === regionContinent) {
        return region;
      }
    }

    return availableRegions[0]; // fallback to first available region
  }
}
<commit_msg>#186 - Add ASIA_PACIFIC_SEOUL aws region<commit_after>/**
 * Created by AlexanderC on 5/27/15.
 */

'use strict';

/**
 * Available AWS regions
 */
export class Region {
  /**
   * @returns {String}
   */
  static get ANY() {
    return '*';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_TOKYO() {
    return 'ap-northeast-1';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_SEOUL() {
    return 'ap-northeast-2';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_SINGAPORE() {
    return 'ap-southeast-1';
  }

  /**
   * @returns {String}
   */
  static get ASIA_PACIFIC_SYDNEY() {
    return 'ap-southeast-2';
  }

  /**
   * @returns {String}
   */
  static get EU_FRANKFURT() {
    return 'eu-central-1';
  }

  /**
   * @returns {String}
   */
  static get EU_IRELAND() {
    return 'eu-west-1';
  }

  /**
   * @returns {String}
   */
  static get SOUTH_AMERICA_SAO_PAULO() {
    return 'sa-east-1';
  }

  /**
   * @returns {String}
   */
  static get US_EAST_N_VIRGINIA() {
    return 'us-east-1';
  }

  /**
   * @returns {String}
   */
  static get US_WEST_N_CALIFORNIA() {
    return 'us-west-1';
  }

  /**
   * @returns {String}
   */
  static get US_WEST_OREGON() {
    return 'us-west-2';
  }

  /**
   * @param {String} name
   * @returns {Boolean}
   */
  static exists(name) {
    return name === '' || -1 !== Region.list().indexOf(name);
  }

  /**
   * @returns {String[]}
   */
  static list() {
    return [
      Region.ANY,
      Region.ASIA_PACIFIC_TOKYO,
      Region.ASIA_PACIFIC_SEOUL,
      Region.ASIA_PACIFIC_SYDNEY,
      Region.ASIA_PACIFIC_SINGAPORE,
      Region.EU_FRANKFURT,
      Region.EU_IRELAND,
      Region.SOUTH_AMERICA_SAO_PAULO,
      Region.US_EAST_N_VIRGINIA,
      Region.US_WEST_N_CALIFORNIA,
      Region.US_WEST_OREGON,
    ];
  }

  /**
   * List method alias
   *
   * @returns {String[]}
   */
  static all() {
    return Region.list();
  }

  /**
   * @param {string} defaultRegion
   * @param {array} availableRegions
   * @returns {string}
   */
  static getAppropriateAwsRegion(defaultRegion, availableRegions) {
    if (availableRegions.indexOf(defaultRegion) !== -1) {
      return defaultRegion;
    }

    let regionContinent = defaultRegion.split('-')[0];

    for (let regionKey in availableRegions) {
      if (!availableRegions.hasOwnProperty(regionKey)) {
        continue;
      }

      let region = availableRegions[regionKey];

      if (region === Region.ANY) {
        return defaultRegion;
      }

      if (region.split('-')[0] === regionContinent) {
        return region;
      }
    }

    return availableRegions[0]; // fallback to first available region
  }
}
<|endoftext|>


<commit_before>var LOAD_INDICATOR = 'https://did-finish-load/';

chrome.devtools.network.onRequestFinished.addListener(function (request) {
  if (request.request.url === LOAD_INDICATOR) {
    chrome.devtools.network.getHAR(function (har) {
      har.entries = har.entries.filter(function (e) {
        return e.request.url !== LOAD_INDICATOR;
      });
      chrome.devtools.inspectedWindow.eval(
        'require("electron").ipcRenderer.send("har-generation-succeeded", ' + JSON.stringify(har) + ');');
    });
  }
});

chrome.devtools.inspectedWindow.eval('require("electron").ipcRenderer.send("devtools-loaded");');
<commit_msg>Made sure root starts with a "log" (per spec)<commit_after>var LOAD_INDICATOR = 'https://did-finish-load/';

chrome.devtools.network.onRequestFinished.addListener(function (request) {
  if (request.request.url === LOAD_INDICATOR) {
    chrome.devtools.network.getHAR(function (har) {
      har.entries = har.entries.filter(function (e) {
        return e.request.url !== LOAD_INDICATOR;
      });
      chrome.devtools.inspectedWindow.eval(
        'require("electron").ipcRenderer.send("har-generation-succeeded", ' + JSON.stringify({log: har}) + ');');
    });
  }
});

chrome.devtools.inspectedWindow.eval('require("electron").ipcRenderer.send("devtools-loaded");');
<|endoftext|>


<commit_before>;(function(angular) {

    'use strict';

    angular.module('k15t.auiNg').
        factory('anDialog',
            function($animate, $compile, $rootScope, $controller, $q, $http, $templateCache, anDialogUtils) {
                var stack = [];
                var startZindex = 3000;
                var focusableElements = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]';
                var $body = angular.element('body');
                var orgOverflow = $body.css('overflow');

                var defaultTemplate = [
                    '
',
                    '
',
                    '
',
                    '
',
                    '

',
                    '
',
                    '
',
                    '
',
                    '
'
                ].join('\n');

                var getBlanket = function() {
                    return $body.find('.an-dialog-blanket');
                };

                var onKeyDown = function(ev) {
                    if (stack.length && stack[stack.length - 1].options.closeOnEscape && ev.keyCode === 27) {
                        stack[stack.length - 1].scope.$close();
                    }
                };

                var onBlanketClick = function(ev) {
                    if (stack.length && stack[stack.length - 1].options.closeOnBlanketClick &&
                        angular.element(ev.target).hasClass('an-dialog-wrapper-inner')) {
                        stack[stack.length - 1].scope.$close();
                    }
                };

                var onFocusIn = function (ev) {
                    var modalElement = $body.find('.an-dialog-wrapper')[0];

                    if (stack.length && !modalElement.contains(ev.target)) {
                        angular.element(modalElement).find(focusableElements)[0].focus();
                    }
                };

                var addDialogToStack = function(dialog) {
                    if (!stack.length) {
                        $body.append('

');
                        $body.css('overflow', 'hidden');
                        $body.on('click', onBlanketClick);
                        $body.on('focusin', onFocusIn);
                        document.addEventListener('keydown', onKeyDown);
                    }
                    stack.push(dialog);
                    getBlanket().css('z-index', startZindex + ((stack.length * 2) - 1));
                };

                var popDialogFromStack = function() {
                    if (!stack.length) {
                        return;
                    }

                    stack.pop();
                    getBlanket().css('z-index', startZindex + ((stack.length * 2) - 1));

                    if (!stack.length) {
                        $body.off('click', onBlanketClick);
                        $body.off('focusin', onFocusIn);
                        getBlanket().remove();
                        $body.css('overflow', orgOverflow);
                        document.removeEventListener('keydown', onKeyDown);
                    }
                };

                var getTemplate = function(template) {
                    if (typeof template === 'function') {
                        return template();
                    }
                    return $http.get(template, {
                        cache: $templateCache
                    }).then(function(response) {
                        return response.data;
                    });
                };

                // this code is highly inspired by https://github.com/btford/angular-modal
                var create = function(opts) {
                    var defaults = {
                        width: 640,
                        height: 480,
                        template: function() {
                            return $q.when(defaultTemplate);
                        },
                        contentTemplate: null,
                        controller: null,
                        controllerAs: 'dialogCtrl',
                        closeOnEscape: true,
                        closeOnBlanketClick: false,
                        onOpen: angular.noop,
                        onClose: angular.noop,
                        promises: [],
                        locals: {}
                    };

                    var options = anDialogUtils.extendOptions(defaults, opts);
                    var scope;
                    var element;

                    var open = function() {
                        return getTemplate(options.template).then(function(wrapperContent) {
                            if (!options.contentTemplate) {
                                return wrapperContent;
                            }
                            return getTemplate(options.contentTemplate).then(function(content) {
                                var wrapperEl = angular.element(wrapperContent);
                                wrapperEl.find('[ng-bind-html="content"]').removeAttr('ng-bind-html').html(content);
                                return wrapperEl.get(0).outerHTML;
                            });
                        }).then(attach);
                    };

                    var attach = function(html) {
                        element = angular.element(html);
                        if (element.length === 0) {
                            throw new Error('The template contains no elements; you need to wrap text nodes');
                        }
                        scope = options.scope ? options.scope.$new() : $rootScope.$new();
                        dialog.scope = scope;

                        angular.extend(scope, options.locals, {
                            $close: close,
                            $submit: close,
                            $disableSubmit: angular.noop,
                            $isLoading: true,
                            dialog: dialog
                        });

                        if (options.controller) {
                            var deps = {
                                dialog: dialog,
                                $scope: scope
                            };
                            var ctrl = $controller(options.controller, deps);
                            if (options.controllerAs) {
                                scope[options.controllerAs] = ctrl;
                            }
                        }

                        return $q.all(options.promises).then(function() {
                            addDialogToStack(dialog);

                            $compile(element)(scope);

                            element.css('z-index', startZindex + stack.length * 2);
                            return $animate.enter(element, $body).then(function() {
                                scope.$isLoading = false;
                                element.focus();
                            });
                        });
                    };

                    var close = function() {
                        var args = arguments;
                        if (!element) {
                            return $q.when();
                        }
                        return $animate.leave(element).then(function() {
                            scope.$emit('$close', args);
                            scope.$destroy();
                            scope = null;
                            element.remove();
                            element = null;
                            popDialogFromStack();
                            options.onClose.apply(null, args);
                        });
                    };

                    var waitFor = function(promise) {
                        options.promises.push(promise);
                    };

                    var dialog = {
                        close: close,
                        options: options,
                        waitFor: waitFor,
                        openPromise: null
                    };

                    dialog.openPromise = open().then(function() {
                        options.onOpen(dialog);
                        return dialog;
                    });

                    return dialog;
                };

                return {
                    create: create
                };
            }
    );
})(angular);
<commit_msg>Add check on visibility of focusable elements<commit_after>;(function(angular) {

    'use strict';

    angular.module('k15t.auiNg').
        factory('anDialog',
            function($animate, $compile, $rootScope, $controller, $q, $http, $templateCache, anDialogUtils) {
                var stack = [];
                var startZindex = 3000;
                var focusableElements = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]';
                var $body = angular.element('body');
                var orgOverflow = $body.css('overflow');

                var defaultTemplate = [
                    '
',
                    '
',
                    '
',
                    '
',
                    '

',
                    '
',
                    '
',
                    '
',
                    '
'
                ].join('\n');

                var getBlanket = function() {
                    return $body.find('.an-dialog-blanket');
                };

                var onKeyDown = function(ev) {
                    if (stack.length && stack[stack.length - 1].options.closeOnEscape && ev.keyCode === 27) {
                        stack[stack.length - 1].scope.$close();
                    }
                };

                var onBlanketClick = function(ev) {
                    if (stack.length && stack[stack.length - 1].options.closeOnBlanketClick &&
                        angular.element(ev.target).hasClass('an-dialog-wrapper-inner')) {
                        stack[stack.length - 1].scope.$close();
                    }
                };

                var onFocusIn = function (ev) {
                    var modalElement = $body.find('.an-dialog-wrapper')[0];

                    if (stack.length && !modalElement.contains(ev.target)) {
                        angular.element(modalElement).find(focusableElements).filter(':visible')[0].focus();
                    }
                };

                var addDialogToStack = function(dialog) {
                    if (!stack.length) {
                        $body.append('

');
                        $body.css('overflow', 'hidden');
                        $body.on('click', onBlanketClick);
                        $body.on('focusin', onFocusIn);
                        document.addEventListener('keydown', onKeyDown);
                    }
                    stack.push(dialog);
                    getBlanket().css('z-index', startZindex + ((stack.length * 2) - 1));
                };

                var popDialogFromStack = function() {
                    if (!stack.length) {
                        return;
                    }

                    stack.pop();
                    getBlanket().css('z-index', startZindex + ((stack.length * 2) - 1));

                    if (!stack.length) {
                        $body.off('click', onBlanketClick);
                        $body.off('focusin', onFocusIn);
                        getBlanket().remove();
                        $body.css('overflow', orgOverflow);
                        document.removeEventListener('keydown', onKeyDown);
                    }
                };

                var getTemplate = function(template) {
                    if (typeof template === 'function') {
                        return template();
                    }
                    return $http.get(template, {
                        cache: $templateCache
                    }).then(function(response) {
                        return response.data;
                    });
                };

                // this code is highly inspired by https://github.com/btford/angular-modal
                var create = function(opts) {
                    var defaults = {
                        width: 640,
                        height: 480,
                        template: function() {
                            return $q.when(defaultTemplate);
                        },
                        contentTemplate: null,
                        controller: null,
                        controllerAs: 'dialogCtrl',
                        closeOnEscape: true,
                        closeOnBlanketClick: false,
                        onOpen: angular.noop,
                        onClose: angular.noop,
                        promises: [],
                        locals: {}
                    };

                    var options = anDialogUtils.extendOptions(defaults, opts);
                    var scope;
                    var element;

                    var open = function() {
                        return getTemplate(options.template).then(function(wrapperContent) {
                            if (!options.contentTemplate) {
                                return wrapperContent;
                            }
                            return getTemplate(options.contentTemplate).then(function(content) {
                                var wrapperEl = angular.element(wrapperContent);
                                wrapperEl.find('[ng-bind-html="content"]').removeAttr('ng-bind-html').html(content);
                                return wrapperEl.get(0).outerHTML;
                            });
                        }).then(attach);
                    };

                    var attach = function(html) {
                        element = angular.element(html);
                        if (element.length === 0) {
                            throw new Error('The template contains no elements; you need to wrap text nodes');
                        }
                        scope = options.scope ? options.scope.$new() : $rootScope.$new();
                        dialog.scope = scope;

                        angular.extend(scope, options.locals, {
                            $close: close,
                            $submit: close,
                            $disableSubmit: angular.noop,
                            $isLoading: true,
                            dialog: dialog
                        });

                        if (options.controller) {
                            var deps = {
                                dialog: dialog,
                                $scope: scope
                            };
                            var ctrl = $controller(options.controller, deps);
                            if (options.controllerAs) {
                                scope[options.controllerAs] = ctrl;
                            }
                        }

                        return $q.all(options.promises).then(function() {
                            addDialogToStack(dialog);

                            $compile(element)(scope);

                            element.css('z-index', startZindex + stack.length * 2);
                            return $animate.enter(element, $body).then(function() {
                                scope.$isLoading = false;
                                element.focus();
                            });
                        });
                    };

                    var close = function() {
                        var args = arguments;
                        if (!element) {
                            return $q.when();
                        }
                        return $animate.leave(element).then(function() {
                            scope.$emit('$close', args);
                            scope.$destroy();
                            scope = null;
                            element.remove();
                            element = null;
                            popDialogFromStack();
                            options.onClose.apply(null, args);
                        });
                    };

                    var waitFor = function(promise) {
                        options.promises.push(promise);
                    };

                    var dialog = {
                        close: close,
                        options: options,
                        waitFor: waitFor,
                        openPromise: null
                    };

                    dialog.openPromise = open().then(function() {
                        options.onOpen(dialog);
                        return dialog;
                    });

                    return dialog;
                };

                return {
                    create: create
                };
            }
    );
})(angular);
<|endoftext|>


<commit_before>/*jslint indent:2, maxlen:80, node:true*/
'use strict';

// exports

module.exports = {
  urls: [
    'http://127.0.0.1:9999/test/unminified.html',
    'http://127.0.0.1:9999/test/minified.html'
  ],
  tunnelTimeout: 5,
  build: process.env.TRAVIS_JOB_ID,
  concurrency: 3,
  browsers: [
    {
      browserName: "internet explorer",
      platform: "WIN8",
      version: "10"
    }
  ],
  testname: 'requirejs-promise',
  tags: ['master']
};
<commit_msg>travis-ci: configure saucelabs to test with more browsers<commit_after>/*jslint indent:2, maxlen:80, node:true*/
'use strict';

// exports

module.exports = {
  urls: [
    'http://127.0.0.1:9999/test/unminified.html',
    'http://127.0.0.1:9999/test/minified.html'
  ],
  tunnelTimeout: 5,
  build: process.env.TRAVIS_JOB_ID,
  concurrency: 3,
  browsers: [
    {
      browserName: "internet explorer",
      version: "11",
      platform: "Windows 8.1"
    },
    {
      browserName: "internet explorer",
      version: "10",
      platform: "Windows 8"
    },
    {
      browserName: "firefox",
      version: "26",
      platform: "Windows 7"
    },
    {
      browserName: "googlechrome",
      version: "31",
      platform: "OS X 10.9"
    },
    {
      browserName: "android",
      version: "4.0",
      platform: "Linux",
      "device-orientation": "portrait"
    },
    {
      browserName: "iphone",
      version: "7",
      platform: "OS X 10.9",
      "device-orientation": "portrait"
    },
    {
      browserName: "iphone",
      version: "6.1",
      platform: "OS X 10.8",
      "device-orientation": "portrait"
    }
  ],
  testname: 'requirejs-promise',
  tags: ['master']
};
<|endoftext|>


<commit_before>/*
==================================================================================================
  Jasy - JavaScript Tooling Framework
  Copyright 2010-2011 Sebastian Werner
--------------------------------------------------------------------------------------------------
  Inspired by: https://github.com/inexorabletash/raf-shim/blob/master/raf.js
==================================================================================================
*/

/**
 * @require {fix.ObjectKeys}
 * @require {fix.DateParse}
 */
(function(global)
{
	if(global.requestAnimationFrame) {
		return;
	}

	// requestAnimationFrame polyfill
	// http://webstuff.nfshost.com/anim-timing/Overview.html

	var postfix = "RequestAnimationFrame";
	var prefix = (function()
	{
		var all = "webkit,moz,o,ms".split(",");
		for (var i=0; i<4; i++) {
			if (global[all[i]+postfix] != null) {
				return all[i];
			}
		}
	})();

	// Vendor specific implementation
	if (prefix)
	{
		global.requestAnimationFrame = global[prefix+postfix];
		global.cancelRequestAnimationFrame = global[prefix+"Cancel"+postfix];
		return;
	}

	// Custom implementation
	var TARGET_FPS = 60;
	var requests = {};
	var rafHandle = 1;
	var timeoutHandle = null;

	global.requestAnimationFrame = function(callback, root)
	{
		var callbackHandle = rafHandle++;

		// Store callback
		requests[callbackHandle] = callback;

		// Create timeout at first request
		if (timeoutHandle === null)
		{
			timeoutHandle = setTimeout(function()
			{
				var time = Date.now();
				var currentRequests = requests;
				var keys = Object.keys(currentRequests);

				// Reset data structure before executing callbacks
				requests = {};
				timeoutHandle = null;

				// Process all callbacks
				for (var i=0, l=keys.length; i<l; i++) {
					currentRequests[keys[i]](time);
				}
			}, 1000 / TARGET_FPS);
		}

		return callbackHandle;
	};

	global.cancelRequestAnimationFrame = function cancelRequestAnimationFrame(handle)
	{
		delete requests[handle];

		// Stop timeout if all where removed
		if (Object.empty(requests))
		{
			clearTimeout(timeoutHandle);
			timeoutHandle = null;
		}
	};

})(this);<commit_msg>Minor cleanup<commit_after>/*
==================================================================================================
  Jasy - JavaScript Tooling Framework
  Copyright 2010-2011 Sebastian Werner
--------------------------------------------------------------------------------------------------
  Inspired by: https://github.com/inexorabletash/raf-shim/blob/master/raf.js
==================================================================================================
*/

(function(global)
{
	if(global.requestAnimationFrame) {
		return;
	}

	// requestAnimationFrame polyfill
	// http://webstuff.nfshost.com/anim-timing/Overview.html

	var postfix = "RequestAnimationFrame";
	var prefix = (function()
	{
		var all = "webkit,moz,o,ms".split(",");
		for (var i=0; i<4; i++) {
			if (global[all[i]+postfix] != null) {
				return all[i];
			}
		}
	})();

	// Vendor specific implementation
	if (prefix)
	{
		global.requestAnimationFrame = global[prefix+postfix];
		global.cancelRequestAnimationFrame = global[prefix+"Cancel"+postfix];
		return;
	}

	// Custom implementation
	var TARGET_FPS = 60;
	var requests = {};
	var rafHandle = 1;
	var timeoutHandle = null;

	global.requestAnimationFrame = function(callback, root)
	{
		var callbackHandle = rafHandle++;

		// Store callback
		requests[callbackHandle] = callback;

		// Create timeout at first request
		if (timeoutHandle === null)
		{
			timeoutHandle = setTimeout(function()
			{
				var time = Date.now();
				var currentRequests = requests;
				var keys = Object.keys(currentRequests);

				// Reset data structure before executing callbacks
				requests = {};
				timeoutHandle = null;

				// Process all callbacks
				for (var i=0, l=keys.length; i<l; i++) {
					currentRequests[keys[i]](time);
				}
			}, 1000 / TARGET_FPS);
		}

		return callbackHandle;
	};

	global.cancelRequestAnimationFrame = function(handle)
	{
		delete requests[handle];

		// Stop timeout if all where removed
		if (Object.empty(requests))
		{
			clearTimeout(timeoutHandle);
			timeoutHandle = null;
		}
	};

})(this);<|endoftext|>


<commit_before>/* eslint-disable react/no-multi-comp */
import React from 'react';
import { mount } from 'enzyme';
import dayjs from 'dayjs';
import preParsePostFormat from 'dayjs/plugin/preParsePostFormat';
import MockDate from 'mockdate';
import mountTest from '../../../tests/shared/mountTest';
import {
  Pagination,
  DatePicker,
  TimePicker,
  Calendar,
  Popconfirm,
  Table,
  Modal,
  Select,
  Transfer,
} from '../..';
import LocaleProvider from '..';
import arEG from '../ar_EG';
import 'dayjs/locale/ar';
import azAZ from '../az_AZ';
import 'dayjs/locale/az';
import bgBG from '../bg_BG';
import 'dayjs/locale/bg';
import bnBD from '../bn_BD';
// import 'dayjs/locale/bn-bd';
import byBY from '../by_BY';
import 'dayjs/locale/be';
import caES from '../ca_ES';
import 'dayjs/locale/ca';
import csCZ from '../cs_CZ';
import 'dayjs/locale/cs';
import deDE from '../de_DE';
import 'dayjs/locale/de';
import daDK from '../da_DK';
import 'dayjs/locale/da';
import elGR from '../el_GR';
import 'dayjs/locale/el';
import enGB from '../en_GB';
import 'dayjs/locale/en-gb';
import enUS from '../en_US';
import 'dayjs/locale/en';
import esES from '../es_ES';
import 'dayjs/locale/es';
import etEE from '../et_EE';
import 'dayjs/locale/et';
import faIR from '../fa_IR';
import 'dayjs/locale/fa';
import fiFI from '../fi_FI';
import 'dayjs/locale/fi';
import frBE from '../fr_BE';
import frCA from '../fr_CA';
import 'dayjs/locale/fr-ca';
import frFR from '../fr_FR';
import 'dayjs/locale/fr';
import gaIE from '../ga_IE';
import 'dayjs/locale/ga';
import glES from '../gl_ES';
import 'dayjs/locale/gl';
import heIL from '../he_IL';
import 'dayjs/locale/he';
import hiIN from '../hi_IN';
import 'dayjs/locale/hi';
import hrHR from '../hr_HR';
import 'dayjs/locale/hr';
import huHU from '../hu_HU';
import 'dayjs/locale/hu';
import hyAM from '../hy_AM';
import 'dayjs/locale/hy-am';
import idID from '../id_ID';
import 'dayjs/locale/id';
import isIS from '../is_IS';
import 'dayjs/locale/is';
import itIT from '../it_IT';
import 'dayjs/locale/it';
import jaJP from '../ja_JP';
import 'dayjs/locale/ja';
import kaGE from '../ka_GE';
import 'dayjs/locale/ka';
import kkKZ from '../kk_KZ';
import 'dayjs/locale/kk';
import knIN from '../kn_IN';
import 'dayjs/locale/kn';
import koKR from '../ko_KR';
import 'dayjs/locale/ko';
import kmKH from '../km_KH';
import 'dayjs/locale/km';
import kmrIQ from '../kmr_IQ';
import kuIQ from '../ku_IQ';
import 'dayjs/locale/ku';
import lvLV from '../lv_LV';
import 'dayjs/locale/lv';
import ltLT from '../lt_LT';
import 'dayjs/locale/lt';
import mkMK from '../mk_MK';
import 'dayjs/locale/mk';
import mlIN from '../ml_IN';
import 'dayjs/locale/ml';
import mnMN from '../mn_MN';
import 'dayjs/locale/mn';
import msMY from '../ms_MY';
import 'dayjs/locale/ms';
import nbNO from '../nb_NO';
import 'dayjs/locale/nb';
import neNP from '../ne_NP';
import 'dayjs/locale/ne';
import nlBE from '../nl_BE';
import 'dayjs/locale/nl-be';
import nlNL from '../nl_NL';
import 'dayjs/locale/nl';
import plPL from '../pl_PL';
import 'dayjs/locale/pl';
import ptBR from '../pt_BR';
import 'dayjs/locale/pt-br';
import ptPT from '../pt_PT';
import 'dayjs/locale/pt';
import roRO from '../ro_RO';
import 'dayjs/locale/ro';
import ruRU from '../ru_RU';
import 'dayjs/locale/ru';
import skSK from '../sk_SK';
import 'dayjs/locale/sk';
import slSI from '../sl_SI';
import 'dayjs/locale/sl';
import srRS from '../sr_RS';
import 'dayjs/locale/sr';
import svSE from '../sv_SE';
import 'dayjs/locale/sv';
import taIN from '../ta_IN';
import 'dayjs/locale/ta';
import thTH from '../th_TH';
import 'dayjs/locale/th';
import trTR from '../tr_TR';
import 'dayjs/locale/tr';
import ukUA from '../uk_UA';
import 'dayjs/locale/uk';
import viVN from '../vi_VN';
import 'dayjs/locale/vi';
import zhCN from '../zh_CN';
import 'dayjs/locale/zh-cn';
import zhHK from '../zh_HK';
import 'dayjs/locale/zh-hk';
import zhTW from '../zh_TW';
import 'dayjs/locale/zh-tw';
import urPK from '../ur_PK';
import 'dayjs/locale/ur';
dayjs.extend(preParsePostFormat);

const locales = [
  azAZ,
  arEG,
  // bgBG,
  // bnBD,
  // byBY,
  // caES,
  // csCZ,
  // daDK,
  // deDE,
  // elGR,
  // enGB,
  // enUS,
  // esES,
  // etEE,
  // faIR,
  // fiFI,
  // frBE,
  // frCA,
  // frFR,
  // gaIE,
  // glES,
  // heIL,
  // hiIN,
  // hrHR,
  // huHU,
  // hyAM,
  // isIS,
  // itIT,
  // jaJP,
  // kaGE,
  // kkKZ,
  // knIN,
  // koKR,
  // kmKH,
  // kmrIQ,
  // kuIQ,
  // ltLT,
  // mkMK,
  // mlIN,
  // msMY,
  // mnMN,
  // nbNO,
  // neNP,
  // nlBE,
  // nlNL,
  // plPL,
  // ptBR,
  // ptPT,
  // roRO,
  // ruRU,
  // skSK,
  // slSI,
  // srRS,
  // svSE,
  // taIN,
  // thTH,
  // trTR,
  // ukUA,
  // viVN,
  // idID,
  // lvLV,
  // zhCN,
  // zhHK,
  // zhTW,
  // urPK,
];

const { Option } = Select;
const { RangePicker } = DatePicker;

const columns = [
  {
    title: 'Name',
    dataIndex: 'name',
    filters: [
      {
        text: 'filter1',
        value: 'filter1',
      },
    ],
  },
  {
    title: 'Age',
    dataIndex: 'age',
  },
];

const App = () => (

    <Pagination defaultCurrent={1} total={50} showSizeChanger />
    <Select showSearch style={{ width: 200 }}>
      <Option value="jack">jack</Option>
      <Option value="lucy">lucy</Option>
    </Select>
    <DatePicker open />
    <TimePicker open defaultOpenValue={dayjs()} />
    <RangePicker open style={{ width: 200 }} />
    <Popconfirm title="Question?" visible>
      Click to confirm
    </Popconfirm>
    <Transfer dataSource={[]} showSearch targetKeys={[]} render={item => item.title} />
    <Calendar fullscreen={false} value={dayjs()} />

    <Modal title="Locale Modal" visible getContainer={false}>

Locale Modal

    </Modal>

);

describe('Locale Provider', () => {
  mountTest(() => (
    <LocaleProvider>

    </LocaleProvider>
  ));

  beforeAll(() => {
    MockDate.set(dayjs('2017-09-18T03:30:07.795').valueOf());
  });

  afterAll(() => {
    MockDate.reset();
  });

  locales.forEach(locale => {
    it(`should display the text as ${locale.locale}`, () => {
      const wrapper = mount(
        <LocaleProvider locale={locale}>
          <App />
        </LocaleProvider>,
      );
      expect(wrapper.render()).toMatchSnapshot();
    });
  });

  it('should change locale of Modal.xxx', () => {
    class ModalDemo extends React.Component {
      componentDidMount() {
        jest.useFakeTimers();
        Modal.confirm({
          title: 'Hello World!',
        });
        jest.runAllTimers();
        jest.useRealTimers();
      }

      render() {
        return null;
      }
    }
    locales.forEach(locale => {
      mount(
        <LocaleProvider locale={locale}>
          <ModalDemo />
        </LocaleProvider>,
      );
      const currentConfirmNode =
        document.querySelectorAll('.ant-modal-confirm')[
          document.querySelectorAll('.ant-modal-confirm').length - 1
        ];
      let cancelButtonText = currentConfirmNode.querySelectorAll(
        '.ant-btn:not(.ant-btn-primary) span',
      )[0].innerHTML;
      let okButtonText = currentConfirmNode.querySelectorAll('.ant-btn-primary span')[0].innerHTML;
      if (locale.locale.indexOf('zh-') === 0) {
        cancelButtonText = cancelButtonText.replace(' ', '');
        okButtonText = okButtonText.replace(' ', '');
      }
      expect(cancelButtonText).toBe(locale.Modal.cancelText);
      expect(okButtonText).toBe(locale.Modal.okText);
    });
  });

  it('set moment locale when locale changes', () => {
    class Test extends React.Component {
      state = {
        locale: zhCN,
      };

      render() {
        const { locale } = this.state;
        return (
          <LocaleProvider locale={locale}>

              <DatePicker defaultValue={dayjs()} open />

          </LocaleProvider>
        );
      }
    }
    const wrapper = mount(<Test />);
    expect(wrapper.render()).toMatchSnapshot();
    wrapper.setState({ locale: frFR });
    expect(wrapper.render()).toMatchSnapshot();
    wrapper.setState({ locale: null });
    expect(wrapper.render()).toMatchSnapshot();
  });
});
<commit_msg>update test<commit_after>/* eslint-disable react/no-multi-comp */
import React from 'react';
import { mount } from 'enzyme';
import dayjs from 'dayjs';
import preParsePostFormat from 'dayjs/plugin/preParsePostFormat';
import MockDate from 'mockdate';
import mountTest from '../../../tests/shared/mountTest';
import {
  Pagination,
  DatePicker,
  TimePicker,
  Calendar,
  Popconfirm,
  Table,
  Modal,
  Select,
  Transfer,
} from '../..';
import LocaleProvider from '..';
import arEG from '../ar_EG';
import 'dayjs/locale/ar';
import azAZ from '../az_AZ';
import 'dayjs/locale/az';
import bgBG from '../bg_BG';
import 'dayjs/locale/bg';
import bnBD from '../bn_BD';
// import 'dayjs/locale/bn-bd';
import byBY from '../by_BY';
import 'dayjs/locale/be';
import caES from '../ca_ES';
import 'dayjs/locale/ca';
import csCZ from '../cs_CZ';
import 'dayjs/locale/cs';
import deDE from '../de_DE';
import 'dayjs/locale/de';
import daDK from '../da_DK';
import 'dayjs/locale/da';
import elGR from '../el_GR';
import 'dayjs/locale/el';
import enGB from '../en_GB';
import 'dayjs/locale/en-gb';
import enUS from '../en_US';
import 'dayjs/locale/en';
import esES from '../es_ES';
import 'dayjs/locale/es';
import etEE from '../et_EE';
import 'dayjs/locale/et';
import faIR from '../fa_IR';
import 'dayjs/locale/fa';
import fiFI from '../fi_FI';
import 'dayjs/locale/fi';
import frBE from '../fr_BE';
import frCA from '../fr_CA';
import 'dayjs/locale/fr-ca';
import frFR from '../fr_FR';
import 'dayjs/locale/fr';
import gaIE from '../ga_IE';
import 'dayjs/locale/ga';
import glES from '../gl_ES';
import 'dayjs/locale/gl';
import heIL from '../he_IL';
import 'dayjs/locale/he';
import hiIN from '../hi_IN';
import 'dayjs/locale/hi';
import hrHR from '../hr_HR';
import 'dayjs/locale/hr';
import huHU from '../hu_HU';
import 'dayjs/locale/hu';
import hyAM from '../hy_AM';
import 'dayjs/locale/hy-am';
import idID from '../id_ID';
import 'dayjs/locale/id';
import isIS from '../is_IS';
import 'dayjs/locale/is';
import itIT from '../it_IT';
import 'dayjs/locale/it';
import jaJP from '../ja_JP';
import 'dayjs/locale/ja';
import kaGE from '../ka_GE';
import 'dayjs/locale/ka';
import kkKZ from '../kk_KZ';
import 'dayjs/locale/kk';
import knIN from '../kn_IN';
import 'dayjs/locale/kn';
import koKR from '../ko_KR';
import 'dayjs/locale/ko';
import kmKH from '../km_KH';
import 'dayjs/locale/km';
import kmrIQ from '../kmr_IQ';
import kuIQ from '../ku_IQ';
import 'dayjs/locale/ku';
import lvLV from '../lv_LV';
import 'dayjs/locale/lv';
import ltLT from '../lt_LT';
import 'dayjs/locale/lt';
import mkMK from '../mk_MK';
import 'dayjs/locale/mk';
import mlIN from '../ml_IN';
import 'dayjs/locale/ml';
import mnMN from '../mn_MN';
import 'dayjs/locale/mn';
import msMY from '../ms_MY';
import 'dayjs/locale/ms';
import nbNO from '../nb_NO';
import 'dayjs/locale/nb';
import neNP from '../ne_NP';
import 'dayjs/locale/ne';
import nlBE from '../nl_BE';
import 'dayjs/locale/nl-be';
import nlNL from '../nl_NL';
import 'dayjs/locale/nl';
import plPL from '../pl_PL';
import 'dayjs/locale/pl';
import ptBR from '../pt_BR';
import 'dayjs/locale/pt-br';
import ptPT from '../pt_PT';
import 'dayjs/locale/pt';
import roRO from '../ro_RO';
import 'dayjs/locale/ro';
import ruRU from '../ru_RU';
import 'dayjs/locale/ru';
import skSK from '../sk_SK';
import 'dayjs/locale/sk';
import slSI from '../sl_SI';
import 'dayjs/locale/sl';
import srRS from '../sr_RS';
import 'dayjs/locale/sr';
import svSE from '../sv_SE';
import 'dayjs/locale/sv';
import taIN from '../ta_IN';
import 'dayjs/locale/ta';
import thTH from '../th_TH';
import 'dayjs/locale/th';
import trTR from '../tr_TR';
import 'dayjs/locale/tr';
import ukUA from '../uk_UA';
import 'dayjs/locale/uk';
import viVN from '../vi_VN';
import 'dayjs/locale/vi';
import zhCN from '../zh_CN';
import 'dayjs/locale/zh-cn';
import zhHK from '../zh_HK';
import 'dayjs/locale/zh-hk';
import zhTW from '../zh_TW';
import 'dayjs/locale/zh-tw';
import urPK from '../ur_PK';
import 'dayjs/locale/ur';
dayjs.extend(preParsePostFormat);

const locales = [
  azAZ,
  arEG,
  bgBG,
  // bnBD,
  // byBY,
  // caES,
  // csCZ,
  // daDK,
  // deDE,
  // elGR,
  // enGB,
  // enUS,
  // esES,
  // etEE,
  // faIR,
  // fiFI,
  // frBE,
  // frCA,
  // frFR,
  // gaIE,
  // glES,
  // heIL,
  // hiIN,
  // hrHR,
  // huHU,
  // hyAM,
  // isIS,
  // itIT,
  // jaJP,
  // kaGE,
  // kkKZ,
  // knIN,
  // koKR,
  // kmKH,
  // kmrIQ,
  // kuIQ,
  // ltLT,
  // mkMK,
  // mlIN,
  // msMY,
  // mnMN,
  // nbNO,
  // neNP,
  // nlBE,
  // nlNL,
  // plPL,
  // ptBR,
  // ptPT,
  // roRO,
  // ruRU,
  // skSK,
  // slSI,
  // srRS,
  // svSE,
  // taIN,
  // thTH,
  // trTR,
  // ukUA,
  // viVN,
  // idID,
  // lvLV,
  // zhCN,
  // zhHK,
  // zhTW,
  // urPK,
];

const { Option } = Select;
const { RangePicker } = DatePicker;

const columns = [
  {
    title: 'Name',
    dataIndex: 'name',
    filters: [
      {
        text: 'filter1',
        value: 'filter1',
      },
    ],
  },
  {
    title: 'Age',
    dataIndex: 'age',
  },
];

const App = () => (

    <Pagination defaultCurrent={1} total={50} showSizeChanger />
    <Select showSearch style={{ width: 200 }}>
      <Option value="jack">jack</Option>
      <Option value="lucy">lucy</Option>
    </Select>
    <DatePicker open />
    <TimePicker open defaultOpenValue={dayjs()} />
    <RangePicker open style={{ width: 200 }} />
    <Popconfirm title="Question?" visible>
      Click to confirm
    </Popconfirm>
    <Transfer dataSource={[]} showSearch targetKeys={[]} render={item => item.title} />
    <Calendar fullscreen={false} value={dayjs()} />

    <Modal title="Locale Modal" visible getContainer={false}>

Locale Modal

    </Modal>

);

describe('Locale Provider', () => {
  mountTest(() => (
    <LocaleProvider>

    </LocaleProvider>
  ));

  beforeAll(() => {
    MockDate.set(dayjs('2017-09-18T03:30:07.795').valueOf());
  });

  afterAll(() => {
    MockDate.reset();
  });

  locales.forEach(locale => {
    it(`should display the text as ${locale.locale}`, () => {
      const wrapper = mount(
        <LocaleProvider locale={locale}>
          <App />
        </LocaleProvider>,
      );
      expect(wrapper.render()).toMatchSnapshot();
    });
  });

  it('should change locale of Modal.xxx', () => {
    class ModalDemo extends React.Component {
      componentDidMount() {
        jest.useFakeTimers();
        Modal.confirm({
          title: 'Hello World!',
        });
        jest.runAllTimers();
        jest.useRealTimers();
      }

      render() {
        return null;
      }
    }
    locales.forEach(locale => {
      mount(
        <LocaleProvider locale={locale}>
          <ModalDemo />
        </LocaleProvider>,
      );
      const currentConfirmNode =
        document.querySelectorAll('.ant-modal-confirm')[
          document.querySelectorAll('.ant-modal-confirm').length - 1
        ];
      let cancelButtonText = currentConfirmNode.querySelectorAll(
        '.ant-btn:not(.ant-btn-primary) span',
      )[0].innerHTML;
      let okButtonText = currentConfirmNode.querySelectorAll('.ant-btn-primary span')[0].innerHTML;
      if (locale.locale.indexOf('zh-') === 0) {
        cancelButtonText = cancelButtonText.replace(' ', '');
        okButtonText = okButtonText.replace(' ', '');
      }
      expect(cancelButtonText).toBe(locale.Modal.cancelText);
      expect(okButtonText).toBe(locale.Modal.okText);
    });
  });

  it('set moment locale when locale changes', () => {
    class Test extends React.Component {
      state = {
        locale: zhCN,
      };

      render() {
        const { locale } = this.state;
        return (
          <LocaleProvider locale={locale}>

              <DatePicker defaultValue={dayjs()} open />

          </LocaleProvider>
        );
      }
    }
    const wrapper = mount(<Test />);
    expect(wrapper.render()).toMatchSnapshot();
    wrapper.setState({ locale: frFR });
    expect(wrapper.render()).toMatchSnapshot();
    wrapper.setState({ locale: null });
    expect(wrapper.render()).toMatchSnapshot();
  });
});
<|endoftext|>


<commit_before>import angular from 'angular';
import { ColumnTotalWidth } from 'utils/math';
import { Sortable } from 'utils/sortable';
import { ColumnsByPin } from 'utils/utils';

export class HeaderController {

  /**
   * Creates an instance of the HeaderController
   * @param  {object} $scope angular js scope
   */
  constructor($scope){
    $scope.$watch('options.columns', (newVal) => {
      this.columnsByPin = ColumnsByPin(newVal);
    }, true);
  }

  /**
   * Returns the styles for the header directive.
   * @param  {scope}
   * @return {styles object}
   */
  styles(scope) {
    return {
      width: scope.options.internal.innerWidth + 'px',
      height: scope.options.headerHeight + 'px'
    }
  }

  /**
   * Returns the inner styles for the header directive
   * @param  {scope}
   * @return {styles object}
   */
  innerStyles(scope){
    return {
      width: ColumnTotalWidth(scope.options.columns) + 'px'

    };
  }

  /**
   * Invoked when a column sort direction has changed
   * @param  {scope}
   * @param  {column}
   */
  onSort(scope, column){
    scope.onSort({
      column: column
    })
  }

  /**
   * Returns the styles by group for the headers.
   * @param  {scope}
   * @param  {group}
   * @return {styles object}
   */
  stylesByGroup(scope, group){
    var cols = scope.options.columns.filter((c) => {
      if(group === 'left' && c.frozenLeft){
        return c;
      } else if(group === 'right' && c.frozenRight){
        return c;
      } else if(group === 'center') {
        return c;
      }
    });

    var styles = {
      width: ColumnTotalWidth(cols) + 'px'
    };

    if(group === 'center'){
      styles['transform'] = `translate3d(-${scope.options.internal.offsetX}px, 0, 0)`
    }

    return styles;
  }

  /**
   * Invoked when the header cell directive's checkbox has changed.
   * @param  {scope}
   */
  onCheckboxChange(scope){
    scope.onCheckboxChange();
  }

};

export function HeaderDirective($timeout){

  return {
    restrict: 'E',
    controller: 'HeaderController',
    controllerAs: 'header',
    scope: {
      options: '=',
      onSort: '&',
      onCheckboxChange: '&'
    },
    template: `

`,
    replace:true,
    link: function($scope, $elm, $attrs){

      $scope.columnsResorted = function(event, childScope){
        var col = childScope.column,
            idx = $scope.options.columns.indexOf(col),
            parent = angular.element(event.currentTarget),
            newIdx = -1;

        angular.forEach(parent.children(), (c, i) => {
          if(childScope === angular.element(c).scope()){
            newIdx = i;
          }
        });

        $timeout(() => {
          $scope.options.columns.splice(idx, 1);
          $scope.options.columns.splice(newIdx, 0, col);
        });
      }

    }
  };
};
<commit_msg>removed watch for header<commit_after>import angular from 'angular';
import { ColumnTotalWidth } from 'utils/math';
import { Sortable } from 'utils/sortable';
import { ColumnsByPin } from 'utils/utils';

export class HeaderController {

  /**
   * Creates an instance of the HeaderController
   * @param  {object} $scope angular js scope
   */
  constructor($scope){
    this.columnsByPin = ColumnsByPin($scope.options.columns);
  }

  /**
   * Returns the styles for the header directive.
   * @param  {scope}
   * @return {styles object}
   */
  styles(scope) {
    return {
      width: scope.options.internal.innerWidth + 'px',
      height: scope.options.headerHeight + 'px'
    }
  }

  /**
   * Returns the inner styles for the header directive
   * @param  {scope}
   * @return {styles object}
   */
  innerStyles(scope){
    return {
      width: ColumnTotalWidth(scope.options.columns) + 'px'

    };
  }

  /**
   * Invoked when a column sort direction has changed
   * @param  {scope}
   * @param  {column}
   */
  onSort(scope, column){
    scope.onSort({
      column: column
    })
  }

  /**
   * Returns the styles by group for the headers.
   * @param  {scope}
   * @param  {group}
   * @return {styles object}
   */
  stylesByGroup(scope, group){
    var cols = scope.options.columns.filter((c) => {
      if(group === 'left' && c.frozenLeft){
        return c;
      } else if(group === 'right' && c.frozenRight){
        return c;
      } else if(group === 'center') {
        return c;
      }
    });

    var styles = {
      width: ColumnTotalWidth(cols) + 'px'
    };

    if(group === 'center'){
      styles['transform'] = `translate3d(-${scope.options.internal.offsetX}px, 0, 0)`
    }

    return styles;
  }

  /**
   * Invoked when the header cell directive's checkbox has changed.
   * @param  {scope}
   */
  onCheckboxChange(scope){
    scope.onCheckboxChange();
  }

};

export function HeaderDirective($timeout){

  return {
    restrict: 'E',
    controller: 'HeaderController',
    controllerAs: 'header',
    scope: {
      options: '=',
      onSort: '&',
      onCheckboxChange: '&'
    },
    template: `

`,
    replace:true,
    link: function($scope, $elm, $attrs, ctrl){

      $scope.columnsResorted = function(event, childScope){
        var col = childScope.column,
            idx = $scope.options.columns.indexOf(col),
            parent = angular.element(event.currentTarget),
            newIdx = -1;

        angular.forEach(parent.children(), (c, i) => {
          if(childScope === angular.element(c).scope()){
            newIdx = i;
          }
        });

        $timeout(() => {
          $scope.options.columns.splice(idx, 1);
          $scope.options.columns.splice(newIdx, 0, col);
        });

        ctrl.columnsByPin = ColumnsByPin($scope.options.columns);
      }

    }
  };
};
<|endoftext|>


<commit_before>export const initialCraftingState = {
    "recipes": [
        {
            "name": "Premium Kaolin Refiner",
            "profession": "Merry Potter",
            "cost": 432,
            "quantity": 5,
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/gather_cheongia_bottle_3_1.png",
            "ingredients": [
                {"name": "Soulstone", "quantity": 8},
                {"name": "Kaolin Refiner", "quantity": 5},
                {"name": "Silverfrost Quartz", "quantity": 5},
                {"name": "Squio Sap", "quantity": 1},
                {"name": "Thight Meat", "quantity": 2}
            ]
        },
        {
            "name": "Silverfrost Transformation Stone",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_element_steel2_4_1.png",
            "cost": 432,
            "quantity": 10,
            "ingredients": [
                {"name": "Soulstone", "quantity": 250},
                {"name": "Silverfrost Quartz", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5},
                {"name": "Silverfrost Mountains Dew", "quantity": 10},
                {"name": "Moonstone", "quantity": 10}
            ]
        },
        {
            "name": "Crafted Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Crafted Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Crafted Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Artisanal Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Artisanal Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Artisanal Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Violet Honey Cookie",
            "profession": "Acquired Tase",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/food_dumpling_grade_10_5_1.png",
            "cost": 100000,
            "quantity": 1,
            "ingredients": [
                {"name": "Sweet Potato", "quantity": 1},
                {"name": "Soulstone", "quantity": 3},
                {"name": "Sacred Orb", "quantity": 3}
            ]
        },
        {
            "name": "Royal Dye",
            "profession": "The Silver Cauldron",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/gather_sap_ginkgo_refine_5_1.png",
            "cost": 100000,
            "quantity": 1,
            "ingredients": [
                {"name": "Rainbowfish Oil", "quantity": 1},
                {"name": "Soulstone", "quantity": 5},
                {"name": "Sacred Orb", "quantity": 5},
                {"name": "Violet Honey Cookie", "quantity": 5}
            ]
        },
        {
            "name": "Empyrean Spirit Charm",
            "profession": "Earthseers",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/talisman_13phase_unseal_7_1.png",
            "cost": 300000,
            "quantity": 1,
            "ingredients": [
                {"name": "Jade Magnolia", "quantity": 1},
                {"name": "Soulstone", "quantity": 100},
                {"name": "Sacred Orb", "quantity": 100},
                {"name": "Royal Dye", "quantity": 1}
            ]
        },
        {
            "name": "Silverfrost Premium Transformation Stone",
            "profession": "Transmute",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_element_steel3_4_1.png",
            "cost": 150000,
            "quantity": 1,
            "ingredients": [
                {"name": "Moonstone", "quantity": 8},
                {"name": "Soulstone", "quantity": 30},
                {"name": "Sacred Orb", "quantity": 30},
                {"name": "Elysian Orb", "quantity": 8},
                {"name": "Silverfrost Transformation Stone", "quantity": 4}
            ]
        },
        {
            "name": "Sealed Sacred Oil",
            "profession": "Transmute",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_liquor_bottle_5_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Demon Spirit Stone", "quantity": 1},
                {"name": "Evolved Stone", "quantity": 25},
                {"name": "Elysian Orb", "quantity": 10},
                {"name": "Silverfrost Transformation Stone", "quantity": 5}
            ]
        }
    ]
};
<commit_msg> - corrected typo in ingredients<commit_after>export const initialCraftingState = {
    "recipes": [
        {
            "name": "Premium Kaolin Refiner",
            "profession": "Merry Potter",
            "cost": 432,
            "quantity": 5,
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/gather_cheongia_bottle_3_1.png",
            "ingredients": [
                {"name": "Soulstone", "quantity": 8},
                {"name": "Kaolin Refiner", "quantity": 5},
                {"name": "Silverfrost Quartz", "quantity": 5},
                {"name": "Squio Sap", "quantity": 1},
                {"name": "Thigh Meat", "quantity": 2}
            ]
        },
        {
            "name": "Silverfrost Transformation Stone",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_element_steel2_4_1.png",
            "cost": 432,
            "quantity": 10,
            "ingredients": [
                {"name": "Soulstone", "quantity": 250},
                {"name": "Silverfrost Quartz", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5},
                {"name": "Silverfrost Mountains Dew", "quantity": 10},
                {"name": "Moonstone", "quantity": 10}
            ]
        },
        {
            "name": "Crafted Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Crafted Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Crafted Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master_pos8_3_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Sequoia Log", "quantity": 10},
                {"name": "Soulstone", "quantity": 8},
                {"name": "Skypetal Feather", "quantity": 2}
            ]
        },
        {
            "name": "Artisanal Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Artisanal Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Artisanal Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_master2_pos8_4_1.png",
            "cost": 473,
            "quantity": 5,
            "ingredients": [
                {"name": "Crafted Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 60},
                {"name": "Mamosu Bone", "quantity": 5},
                {"name": "Premium Kaolin Refiner", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Masterwork Silverfrost Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/gem/equipgem_master2_pos8_5_1.png",
            "cost": 473,
            "quantity": 1,
            "ingredients": [
                {"name": "Artisanal Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Soulstone", "quantity": 50},
                {"name": "Masterwork Soul Shield Primer Design", "quantity": 5}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Critical Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Critical Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Piercing Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Piercing Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Silverfrost Soul Warden Reflex Soul Shield Primer",
            "profession": "Soul Wardens",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/equipgem_honcheonfight5_pos8_7_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Masterwork Silverfrost Reflex Soul Shield Primer", "quantity": 1},
                {"name": "Premium Kaolin Refiner", "quantity": 8},
                {"name": "Soul Warden's Emblem", "quantity": 3}
            ]
        },
        {
            "name": "Violet Honey Cookie",
            "profession": "Acquired Tase",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/food_dumpling_grade_10_5_1.png",
            "cost": 100000,
            "quantity": 1,
            "ingredients": [
                {"name": "Sweet Potato", "quantity": 1},
                {"name": "Soulstone", "quantity": 3},
                {"name": "Sacred Orb", "quantity": 3}
            ]
        },
        {
            "name": "Royal Dye",
            "profession": "The Silver Cauldron",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/gather_sap_ginkgo_refine_5_1.png",
            "cost": 100000,
            "quantity": 1,
            "ingredients": [
                {"name": "Rainbowfish Oil", "quantity": 1},
                {"name": "Soulstone", "quantity": 5},
                {"name": "Sacred Orb", "quantity": 5},
                {"name": "Violet Honey Cookie", "quantity": 5}
            ]
        },
        {
            "name": "Empyrean Spirit Charm",
            "profession": "Earthseers",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/talisman_13phase_unseal_7_1.png",
            "cost": 300000,
            "quantity": 1,
            "ingredients": [
                {"name": "Jade Magnolia", "quantity": 1},
                {"name": "Soulstone", "quantity": 100},
                {"name": "Sacred Orb", "quantity": 100},
                {"name": "Royal Dye", "quantity": 1}
            ]
        },
        {
            "name": "Silverfrost Premium Transformation Stone",
            "profession": "Transmute",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_element_steel3_4_1.png",
            "cost": 150000,
            "quantity": 1,
            "ingredients": [
                {"name": "Moonstone", "quantity": 8},
                {"name": "Soulstone", "quantity": 30},
                {"name": "Sacred Orb", "quantity": 30},
                {"name": "Elysian Orb", "quantity": 8},
                {"name": "Silverfrost Transformation Stone", "quantity": 4}
            ]
        },
        {
            "name": "Sealed Sacred Oil",
            "profession": "Transmute",
            "image": "http://static.ncsoft.com/bns_resource/ui_resource/grocery/grocery_liquor_bottle_5_1.png",
            "cost": 50000,
            "quantity": 1,
            "ingredients": [
                {"name": "Demon Spirit Stone", "quantity": 1},
                {"name": "Evolved Stone", "quantity": 25},
                {"name": "Elysian Orb", "quantity": 10},
                {"name": "Silverfrost Transformation Stone", "quantity": 5}
            ]
        }
    ]
};
<|endoftext|>


<commit_before>var _ = require('underscore');
var backbone = require('backbone');
var backboneBase = require('backbone-base');

var BaseView = backbone.BaseView.extend({
  // Activate overlay along with dialog box
  activate: function(state) {
    window.APP.$('#overlay').prop('hidden', !(_.isUndefined(state) || state));
    backbone.BaseView.prototype.activate.call(this, state);
    return this;
  },

  // Update internal object of callbacks called during Yes/No click
  setCallbacks: function(callbacks) {
    this.callbacks = _.extend(this.callbacks || {}, callbacks);
    return this;
  },

  setMessage: function(text) { this.$('[data-id=message]').html(text || ''); return this; }
});

module.exports = {
  NotificationView: BaseView.extend({
    events: {
      'click [data-id=ok]': function () {
        // Just close dialog as default No-action
        this.deactivate();

        return false;
      }}
  }),

  ConfirmationView: BaseView.extend({
    events: {
      'click [data-id=yes]': function() {
        this.deactivate();

        // Error should be thrown if no callback defined — there is no default action
        return this.callbacks.yes();
      },

      'click [data-id=no]': function() {
        if(_.isFunction((this.callbacks || {}).no))
          return this.callbacks.no();

        // Just close dialog as default No-action
        this.deactivate();

        return false;
      }
    }
  })
};
<commit_msg>Scroll to error message om activaton (#130)<commit_after>var _ = require('underscore');
var backbone = require('backbone');
var backboneBase = require('backbone-base');

var BaseView = backbone.BaseView.extend({
  // Activate overlay along with dialog box
  activate: function(state) {
    window.APP.$('#overlay').prop('hidden', !(_.isUndefined(state) || state));
    backbone.BaseView.prototype.activate.call(this, state);
    return this;
  },

  // Update internal object of callbacks called during Yes/No click
  setCallbacks: function(callbacks) {
    this.callbacks = _.extend(this.callbacks || {}, callbacks);
    return this;
  },

  setMessage: function(text) { this.$('[data-id=message]').html(text || ''); return this; }
});

module.exports = {
  NotificationView: BaseView.extend({
    activate: function(state) {
      BaseView.prototype.activate.call(this, state);

      // Scroll to the top, where notification is show
      if(state)
        $(document).scrollTop(0);
    },

    events: {
      'click [data-id=ok]': function () {
        // Just close dialog as default No-action
        this.deactivate();

        return false;
      }}
  }),

  ConfirmationView: BaseView.extend({
    events: {
      'click [data-id=yes]': function() {
        this.deactivate();

        // Error should be thrown if no callback defined — there is no default action
        return this.callbacks.yes();
      },

      'click [data-id=no]': function() {
        if(_.isFunction((this.callbacks || {}).no))
          return this.callbacks.no();

        // Just close dialog as default No-action
        this.deactivate();

        return false;
      }
    }
  })
};
<|endoftext|>


<commit_before>module.exports = {
  'create-dp/data-file-editor.hbs'      : require('./create-dp/data-file-editor.hbs'),
  'create-dp/data-file-editor-item.hbs' : require('./create-dp/data-file-editor-item.hbs'),
  'datapackage.hbs'                     : require('./datapackage.hbs'),
  'create-dp/form.hbs'                  : require('./create-dp/form.hbs'),
  'create-dp/header.hbs'                : require('./create-dp/header.hbs'),
  'create-dp/name-editor.hbs'           : require('./create-dp/name-editor.hbs'),
  'create-dp/validation-report.hbs'     : require('./create-dp/validation-report.hbs'),
  'create-dp/validation-report-item.hbs': require('./create-dp/validation-report-item.hbs'),
  'create-dp/upload.hbs'                : require('./create-dp/upload.hbs')
};
<commit_msg>/templates/index.js formatted<commit_after>module.exports = {
  'create-dp/data-file-editor.hbs': require('./create-dp/data-file-editor.hbs'),

  'create-dp/data-file-editor-item.hbs': require(
    './create-dp/data-file-editor-item.hbs'
  ),

  'datapackage.hbs'          : require('./datapackage.hbs'),
  'create-dp/form.hbs'       : require('./create-dp/form.hbs'),
  'create-dp/header.hbs'     : require('./create-dp/header.hbs'),
  'create-dp/name-editor.hbs': require('./create-dp/name-editor.hbs'),

  'create-dp/validation-report.hbs': require(
    './create-dp/validation-report.hbs'
  ),

  'create-dp/validation-report-item.hbs': require(
    './create-dp/validation-report-item.hbs'
  ),

  'create-dp/upload.hbs': require('./create-dp/upload.hbs')
};
<|endoftext|>


<commit_before>if (document.location.hostname == "localhost") {
    var baseurl = "";
} else {
    var baseurl = "https://representme.co.za";
}
document.write('

');
document.write('');

document.write("");
<commit_msg>Embed secretballot using noconfidencevote instance<commit_after>if (document.location.hostname == "localhost") {
    var baseurl = "";
} else {
    var baseurl = "https://noconfidencevote.openup.org.za";
}
document.write('

');
document.write('');

document.write("");
<|endoftext|>


<commit_before>(function (angular) {
    'use strict';

    var module = angular.module('djangularRestFramework', [
        'angularExtQ',
        'jmdobry.angular-cache'
    ]);

    module.factory('drf', [
        '$http',
        '$angularCacheFactory',
        'extQ',
        function ($http, $angularCacheFactory, extQ) {
            var cacheOptions = {
                maxAge: 86400000,
                storageMode: 'localStorage'
            };

            var defaultOptions = {
                cache: true
            };

            var api = {
                optionsCache: $angularCacheFactory('optionsCache', cacheOptions),
                urlCache: $angularCacheFactory('urlCache', cacheOptions),
                objectCache: $angularCacheFactory('objectCache', cacheOptions),

                getPage: function (url, options, deferred, items) {
                    $http({
                        method: 'GET',
                        url: url,
                        params: options.params
                    }).then(function (response) {
                        // If the response has pages it will be structured
                        // differently.
                        var data;
                        if (angular.isDefined(response.data.results)) {
                            data = response.data.results;
                        } else {
                            data = response.data;
                        }

                        if (angular.isDefined(response.data.count) && angular.isUndefined(options.limit)) {
                            options.limit = response.data.count;
                        }

                        deferred.update(data);
                        items = items.concat(data);

                        if (angular.isDefined(response.data.next) && response.data.next !== null && items.length < options.limit) {
                            api.getPage(response.data.next, options, deferred, items);
                        } else {
                            if (angular.isDefined(options.limit)) {
                                items = items.splice(0, options.limit);
                            }
                            deferred.resolve(items);
                        }

                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });
                },

                stream: function (url, options) {
                    var deferred = extQ.defer(['update']);
                    var items = [];

                    api.getPage(url, options, deferred, items);

                    return deferred.promise;
                },

                load: function (url, options) {
                    var deferred = extQ.defer();

                    $http({
                        method: 'GET',
                        url: url,
                        params: options.params
                    }).then(function (response) {
                        deferred.resolve(response);
                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });

                    return deferred.promise;
                },

                loadList: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer(['add', 'update', 'remove']);

                    if (options.cache) {
                        // Load list of item URLs from urlCache.
                        var cached = api.urlCache.get(url);
                        if (angular.isDefined(options.limit) && isDefined(cached)) {
                            cached = cached.splice(0, options.limit);
                        }
                        angular.forEach(cached, function (url) {
                            var obj = api.objectCache.get(url);
                            if (angular.isDefined(obj)) {
                                deferred.add(obj);
                            }
                        });
                    }

                    var seen = {};
                    api.stream(url, options).update(function (list) {
                        // Stream the list
                        angular.forEach(list, function (item) {
                            seen[item.url] = item;
                            if (options.cache) {
                                var cached = api.objectCache.get(item.url);
                                if (angular.isUndefined(cached)) {
                                    api.objectCache.put(item.url, item);
                                    deferred.add(item);
                                } else if (!angular.equals(cached, item)) {
                                    api.objectCache.put(item.url, item);
                                    deferred.update(item);
                                }
                            } else {
                                deferred.add(item);
                            }
                        });
                    }).then(function (list) {
                        if (options.cache) {
                            // Remove items from the cache if they were not returned
                            // in the list.
                            if (cached) {
                                angular.forEach(cached, function (url) {
                                    if (angular.isUndefined(seen[url])) {
                                        deferred.remove(url);
                                        api.objectCache.remove(url);
                                    }
                                });
                            }

                            // Update the urlCache with a list of URLs.
                            var urls = [];
                            angular.forEach(list, function (item) {
                                if (angular.isDefined(item.url)) {
                                    urls.push(item.url);
                                }
                            });
                            api.urlCache.put(url, urls);
                        }

                        deferred.resolve(list);
                    });

                    return deferred.promise;
                },

                loadItem: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer(['add', 'update', 'remove']);

                    if (options.cache) {
                        // Load the item from the cache.
                        var cached = api.objectCache.get(url);
                        if (angular.isDefined(cached)) {
                            deferred.add(cached);
                        }
                    }

                    api.load(url, options).then(function (response) {
                        var item = response.data;
                        if (options.cache) {
                            if (angular.isUndefined(cached)) {
                                api.objectCache.put(url, item);
                                deferred.add(item);
                            } else if (!angular.equals(cached, item)) {
                                api.objectCache.put(url, item);
                                deferred.update(item);
                            }
                        }

                        deferred.resolve(item);
                    });

                    return deferred.promise;
                },

                loadOptions: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer();

                    if (options.cache) {
                        // Load the options from the cache.
                        var cached = api.optionsCache.get(url);
                        if (angular.isDefined(cached)) {
                            deferred.resolve({data: cached, url: url});
                        }
                    }

                    $http({
                        method: 'OPTIONS',
                        url: url
                    }).then(function (response) {
                        if (options.cache) {
                            if (!angular.equals(cached, response.data)) {
                                api.optionsCache.put(url, response.data);
                            }
                        }

                        deferred.resolve({data: response.data, url: url});
                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });

                    return deferred.promise;
                }
            };

            return api;
        }
    ]);
}(window.angular));
<commit_msg>Ensure we update all promises asynchronously.<commit_after>(function (angular) {
    'use strict';

    var module = angular.module('djangularRestFramework', [
        'angularExtQ',
        'jmdobry.angular-cache'
    ]);

    module.factory('drf', [
        '$http',
        '$timeout',
        '$angularCacheFactory',
        'extQ',
        function ($http, $timeout, $angularCacheFactory, extQ) {
            var cacheOptions = {
                maxAge: 86400000,
                storageMode: 'localStorage'
            };

            var defaultOptions = {
                cache: true
            };

            var api = {
                optionsCache: $angularCacheFactory('optionsCache', cacheOptions),
                urlCache: $angularCacheFactory('urlCache', cacheOptions),
                objectCache: $angularCacheFactory('objectCache', cacheOptions),

                getPage: function (url, options, deferred, items) {
                    $http({
                        method: 'GET',
                        url: url,
                        params: options.params
                    }).then(function (response) {
                        // If the response has pages it will be structured
                        // differently.
                        var data;
                        if (angular.isDefined(response.data.results)) {
                            data = response.data.results;
                        } else {
                            data = response.data;
                        }

                        if (angular.isDefined(response.data.count) && angular.isUndefined(options.limit)) {
                            options.limit = response.data.count;
                        }

                        deferred.update(data);
                        items = items.concat(data);

                        if (angular.isDefined(response.data.next) && response.data.next !== null && items.length < options.limit) {
                            api.getPage(response.data.next, options, deferred, items);
                        } else {
                            if (angular.isDefined(options.limit)) {
                                items = items.splice(0, options.limit);
                            }
                            deferred.resolve(items);
                        }

                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });
                },

                stream: function (url, options) {
                    var deferred = extQ.defer(['update']);
                    var items = [];

                    api.getPage(url, options, deferred, items);

                    return deferred.promise;
                },

                load: function (url, options) {
                    var deferred = extQ.defer();

                    $http({
                        method: 'GET',
                        url: url,
                        params: options.params
                    }).then(function (response) {
                        deferred.resolve(response);
                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });

                    return deferred.promise;
                },

                loadList: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer(['add', 'update', 'remove']);

                    if (options.cache) {
                        $timeout(function () {
                            // Load list of item URLs from urlCache.
                            var cached = api.urlCache.get(url);
                            if (angular.isDefined(options.limit) && isDefined(cached)) {
                                cached = cached.splice(0, options.limit);
                            }
                            angular.forEach(cached, function (url) {
                                var obj = api.objectCache.get(url);
                                if (angular.isDefined(obj)) {
                                    deferred.add(obj);
                                }
                            });
                        }, 0);
                    }

                    var seen = {};
                    api.stream(url, options).update(function (list) {
                        // Stream the list
                        angular.forEach(list, function (item) {
                            seen[item.url] = item;
                            if (options.cache) {
                                var cached = api.objectCache.get(item.url);
                                if (angular.isUndefined(cached)) {
                                    api.objectCache.put(item.url, item);
                                    deferred.add(item);
                                } else if (!angular.equals(cached, item)) {
                                    api.objectCache.put(item.url, item);
                                    deferred.update(item);
                                }
                            } else {
                                deferred.add(item);
                            }
                        });
                    }).then(function (list) {
                        if (options.cache) {
                            // Remove items from the cache if they were not returned
                            // in the list.
                            if (cached) {
                                angular.forEach(cached, function (url) {
                                    if (angular.isUndefined(seen[url])) {
                                        deferred.remove(url);
                                        api.objectCache.remove(url);
                                    }
                                });
                            }

                            // Update the urlCache with a list of URLs.
                            var urls = [];
                            angular.forEach(list, function (item) {
                                if (angular.isDefined(item.url)) {
                                    urls.push(item.url);
                                }
                            });
                            api.urlCache.put(url, urls);
                        }

                        deferred.resolve(list);
                    });

                    return deferred.promise;
                },

                loadItem: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer(['add', 'update', 'remove']);

                    if (options.cache) {
                        $timeout(function () {
                            // Load the item from the cache.
                            var cached = api.objectCache.get(url);
                            if (angular.isDefined(cached)) {
                                deferred.add(cached);
                            }
                        }, 0);
                    }

                    api.load(url, options).then(function (response) {
                        var item = response.data;
                        if (options.cache) {
                            if (angular.isUndefined(cached)) {
                                api.objectCache.put(url, item);
                                deferred.add(item);
                            } else if (!angular.equals(cached, item)) {
                                api.objectCache.put(url, item);
                                deferred.update(item);
                            }
                        }

                        deferred.resolve(item);
                    });

                    return deferred.promise;
                },

                loadOptions: function (url, options, deferred) {
                    options = angular.extend({}, defaultOptions, options);
                    deferred = deferred || extQ.defer();

                    if (options.cache) {
                        $timeout(function () {
                            // Load the options from the cache.
                            var cached = api.optionsCache.get(url);
                            if (angular.isDefined(cached)) {
                                deferred.resolve({data: cached, url: url});
                            }
                        }, 0);
                    }

                    $http({
                        method: 'OPTIONS',
                        url: url
                    }).then(function (response) {
                        if (options.cache) {
                            if (!angular.equals(cached, response.data)) {
                                api.optionsCache.put(url, response.data);
                            }
                        }

                        deferred.resolve({data: response.data, url: url});
                    }, function (response, status) {
                        deferred.reject({response: response, status: status});
                    });

                    return deferred.promise;
                }
            };

            return api;
        }
    ]);
}(window.angular));
<|endoftext|>