<commit_before>var angularFileUpload = angular.module('angularFileUpload', []);

(function loadFileAPI() {
    if (typeof jQuery === 'undefined') {
        var script = document.createElement('script');
        script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
        document.getElementsByTagName('head')[0].appendChild(script);
    }

    if (typeof FormData === 'undefined') {
        var script = document.createElement('script');
        var base = FileAPI.scriptBase || '';
        var allScripts = document.getElementsByTagName('script');
        for(var i = 0; i < allScripts.length; i++) {
            var index = allScripts[i].src.indexOf('angular-file-upload.js')
            if (index > -1) {
                base = allScripts[i].src.substring(0, index);
            }
        }

        script.setAttribute('src', base + 'FileAPI.min.js');
        document.getElementsByTagName('head')[0].appendChild(script);
    }
})()

angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', function($parse, $http) {
    if ($http.uploadFile === undefined) {
        $http.uploadFile = function(config) {
            if (typeof FormData === 'undefined') {
                var params = {
                    url: config.url,
                    complete: function (err, xhr) {
                        var JSON_START = /^\s*(\[|\{[^\{])/,
                              JSON_END = /[\}\]]\s*$/,
                              PROTECTION_PREFIX = /^\)\]\}',?\n/;
                        var data = xhr.responseText;
                        if (typeof data == 'string') {
                                // strip json vulnerability protection prefix
                                data = data.replace(PROTECTION_PREFIX, '');
                                if (JSON_START.test(data) && JSON_END.test(data))
                                  data = (typeof data == 'string')
                                               ? JSON.parse(data)
                                               : data;
                        }
                        if (params.promiseThen != null) params.promiseThen(data, xhr.status, null, config);
                        if (params.promiseError != null) params.promiseError(data, xhr.status, null, config);
                        if (params.promiseSuccess != null) params.promiseSuccess(data, xhr.status, null, config);
                    }
                }
                if (config.file != null) {
                    params.files = {
                        file: config.file
                    }
                }
                if (config.files != null) {
                    params.files = {
                        files: config.files
                    }
                }
                var xhr = FileAPI.upload(params);
                return {
                    then: function(func) {
                        params.promiseThen = func;
                    },
                    success: function(func) {
                        params.promiseSuccess = func;
                    },
                    error: function(func) {
                        params.promiseError = func;
                    }
                };
            } else {
                return $http({
                    method: 'POST',
                    url: config.url,
                    headers: { 'Content-Type': false },
                    transformRequest: function (data) {
                        var formData = new FormData();
                        if (config.files != null) {
                            for (var i = 0; i < config.files; i++) {
                                //add each file to the form data and iteratively name them
                                formData.append('file' + i, config.files[i]);
                            }
                        } else {
                            formData.append('file', config.file);
                        }
                        return formData;
                    }
                });
            }
        };
    }

    return function(scope, elem, attr) {
        if (typeof FormData === 'undefined') {
            elem.wrap('
');
        }
        var fn = $parse(attr['ngFileSelect']);
		elem.bind('change', function(evt) {
		    var files = [];
            if (typeof FormData !== 'undefined') {
                files = evt.target.files;
            } else {
                files = FileAPI.getFiles(evt);
            }
            scope.$apply(function() {
                fn(scope, {
                    $files: files,
                    $event : evt
                });
            });
		});
    };
} ]);<commit_msg>Update angular-file-upload.js<commit_after>/**!
 * AngularJS file upload directive and http post
 * @author  Danial  <danial.farid@gmail.com>
 */
var angularFileUpload = angular.module('angularFileUpload', []);

(function loadFileAPI() {
    if (typeof jQuery === 'undefined') {
        var script = document.createElement('script');
        script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
        document.getElementsByTagName('head')[0].appendChild(script);
    }

    if (typeof FormData === 'undefined') {
        var script = document.createElement('script');
        var base = FileAPI.scriptBase || '';
        var allScripts = document.getElementsByTagName('script');
        for(var i = 0; i < allScripts.length; i++) {
            var index = allScripts[i].src.indexOf('angular-file-upload.js')
            if (index > -1) {
                base = allScripts[i].src.substring(0, index);
            }
        }

        script.setAttribute('src', base + 'FileAPI.min.js');
        document.getElementsByTagName('head')[0].appendChild(script);
    }
})()

angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', function($parse, $http) {
    if ($http.uploadFile === undefined) {
        $http.uploadFile = function(config) {
            if (typeof FormData === 'undefined') {
                var params = {
                    url: config.url,
                    complete: function (err, xhr) {
                        var JSON_START = /^\s*(\[|\{[^\{])/,
                              JSON_END = /[\}\]]\s*$/,
                              PROTECTION_PREFIX = /^\)\]\}',?\n/;
                        var data = xhr.responseText;
                        if (typeof data == 'string') {
                                // strip json vulnerability protection prefix
                                data = data.replace(PROTECTION_PREFIX, '');
                                if (JSON_START.test(data) && JSON_END.test(data))
                                  data = (typeof data == 'string')
                                               ? JSON.parse(data)
                                               : data;
                        }
                        if (params.promiseThen != null) params.promiseThen(data, xhr.status, null, config);
                        if (params.promiseError != null) params.promiseError(data, xhr.status, null, config);
                        if (params.promiseSuccess != null) params.promiseSuccess(data, xhr.status, null, config);
                    }
                }
                if (config.file != null) {
                    params.files = {
                        file: config.file
                    }
                }
                if (config.files != null) {
                    params.files = {
                        files: config.files
                    }
                }
                var xhr = FileAPI.upload(params);
                return {
                    then: function(func) {
                        params.promiseThen = func;
                    },
                    success: function(func) {
                        params.promiseSuccess = func;
                    },
                    error: function(func) {
                        params.promiseError = func;
                    }
                };
            } else {
                return $http({
                    method: 'POST',
                    url: config.url,
                    headers: { 'Content-Type': false },
                    transformRequest: function (data) {
                        var formData = new FormData();
                        if (config.files != null) {
                            for (var i = 0; i < config.files; i++) {
                                //add each file to the form data and iteratively name them
                                formData.append('file' + i, config.files[i]);
                            }
                        } else {
                            formData.append('file', config.file);
                        }
                        return formData;
                    }
                });
            }
        };
    }

    return function(scope, elem, attr) {
        if (typeof FormData === 'undefined') {
            elem.wrap('
');
        }
        var fn = $parse(attr['ngFileSelect']);
		elem.bind('change', function(evt) {
		    var files = [];
            if (typeof FormData !== 'undefined') {
                files = evt.target.files;
            } else {
                files = FileAPI.getFiles(evt);
            }
            scope.$apply(function() {
                fn(scope, {
                    $files: files,
                    $event : evt
                });
            });
		});
    };
} ]);
<|endoftext|>


<commit_before>/**
 * @file 负责监控web中元素，将其改动更新至boost 被webMap中调用启动
 */

define(function (require, exports, module) {
    "use strict";

    var derive = require("base/derive");
    var $ = require("boost/$");
    var assert = require("base/assert");
    require("boost/webMap");
    var INTERVAL = 1000;

    var WebMonitor = derive(Object, {
        _setIntervalHandle: null,

        start: function () {
            assert(this._setIntervalHandle === null, "already been started");

            this._setIntervalHandle = setInterval(this.sync.bind(this), INTERVAL);
        },

        sync: function () {
            var self = this;
            var webMap = require("boost/webMap"); //因为有循环依赖，需在此使用时重新require
            webMap.getAllWebElements().forEach(function (webElement) {
                var tagName = webElement.tagName.toUpperCase();
                var boostElement = webMap.getBoostElement(webElement);

                if (tagName === "TEXT" || tagName === "TEXTINPUT") {
                    boostElement.value = webElement.innerHTML; //innerText can't get value~
                }

                boostElement.className = webElement.className; //FIXME: can't trigger style update

                var styleText = webElement.getAttribute("style");
                if (styleText) {
                    var styleList = styleText.split(";");
                    styleList = styleList.filter(function (styleItem) { return styleItem.trim().length > 0; });
                    styleList.forEach(function (styleItem) {
                        var tempArray = styleItem.split(":");
                        self._handleRule(boostElement,  tempArray[0].trim(), tempArray[1].trim());
                    });
                }
            });
        },

        _handleRule: function (boostElement, styleName, styleValue) {
            switch (styleName) {
                case "margin":
                case "padding":
                case "border-width":
                case "border-color":
                    //TODO
                    break;
                default :
                    if (/^[\d\.]+px$/.test(styleValue)) {
                        boostElement.style[styleName] = parseFloat(styleValue);
                    } else if (styleValue === "auto") {
                        boostElement.style[styleName] = null;
                    } else {
                        boostElement.style[styleName] = styleValue;
                    }
                    break;
            }
        }
    });

    module.exports = new WebMonitor();
});
<commit_msg>完善了对简写值的处理<commit_after>/**
 * @file 负责监控web中元素，将其改动更新至boost 被webMap中调用启动
 */

define(function (require, exports, module) {
    "use strict";

    var derive = require("base/derive");
    var $ = require("boost/$");
    var assert = require("base/assert");
    require("boost/webMap");
    var INTERVAL = 30;
    function toCamelCase(str) { //TODO: move to base/
        return str.replace(/-+(.)?/g, function (match, chr) {
            return chr ? chr.toUpperCase() : '';
        });
    }

    var WebMonitor = derive(Object, {
        _setIntervalHandle: null,

        start: function () {
            assert(this._setIntervalHandle === null, "already been started");

            this._setIntervalHandle = setInterval(this.sync.bind(this), INTERVAL);
        },

        sync: function () {
            var self = this;
            var webMap = require("boost/webMap"); //因为有循环依赖，需在此使用时重新require
            webMap.getAllWebElements().forEach(function (webElement) {
                var tagName = webElement.tagName.toUpperCase();
                var boostElement = webMap.getBoostElement(webElement);

                if (tagName === "TEXT" || tagName === "TEXTINPUT") {
                    boostElement.value = webElement.innerHTML; //innerText can't get value~
                }

                boostElement.className = webElement.className; //FIXME: can't trigger style update

                var styleText = webElement.getAttribute("style");
                if (styleText) {
                    var styleList = styleText.split(";");
                    styleList = styleList.filter(function (styleItem) { return styleItem.trim().length > 0; });
                    styleList.forEach(function (styleItem) {
                        var tempArray = styleItem.split(":");
                        self._handleRule(boostElement,  tempArray[0].trim(), tempArray[1].trim());
                    });
                }
            });
        },

        _handleRule: function (boostElement, styleName, styleValue) {
            var keyMap = {
                "margin": [
                    'margin-top',
                    'margin-right',
                    'margin-bottom',
                    'margin-left'
                ],
                "padding": [
                    'padding-top',
                    'padding-right',
                    'padding-bottom',
                    'padding-left'
                ],
                "border-width": [
                    'border-top-width',
                    'border-right-width',
                    'border-bottom-width',
                    'border-left-width'
                ],
                "border-color": [
                    'border-top-color',
                    'border-right-color',
                    'border-bottom-color',
                    'border-left-color'
                ]
            };
            switch (styleName) {
                case "margin":
                case "padding":
                case "border-width":
                case "border-color":
                    var subStyleValues = styleValue.split(/\s+/);
                    if (subStyleValues.length === 1) {
                        subStyleValues.push(subStyleValues[0]); //right
                        subStyleValues.push(subStyleValues[0]); //bottom
                        subStyleValues.push(subStyleValues[0]); //left
                    } else if (subStyleValues.length === 2) {
                        subStyleValues.push(subStyleValues[0]); //bottom
                        subStyleValues.push(subStyleValues[1]); //left
                    } else if (subStyleValues.length === 3) {
                        subStyleValues.push(subStyleValues[1]); //left
                    }
                    keyMap[styleName].forEach(function (subStyleKey, index) {
                        boostElement.style[webKeyToBoostKey(subStyleKey)] = webValueToBoostValue(subStyleValues[index]);
                    });
                    break;
                default :
                    boostElement.style[webKeyToBoostKey(styleName)] = webValueToBoostValue(styleValue);
                    break;
            }

            function webValueToBoostValue (webValue) {
                if (/^(?:\-)?[\d\.]+px$/.test(webValue)) {
                    return parseFloat(webValue);
                } else if (webValue === "auto") {
                    return null;
                } else {
                    return webValue;
                }
            }
            function webKeyToBoostKey (webKey) {
                return toCamelCase(webKey);
            }
        }
    });

    module.exports = new WebMonitor();
});
<|endoftext|>


<commit_before>angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse', '$cookieStore', '$window', '$log', function ($parse, $cookieStore, $window, $log) {
	/**
	 * Global Vars
	 */
	var storage = (typeof $window.localStorage === 'undefined') ? undefined : $window.localStorage;
	var supported = !(typeof storage === 'undefined');

	var privateMethods = {
		/**
		 * Pass any type of a string from the localStorage to be parsed so it returns a usable version (like an Object)
		 * @param res - a string that will be parsed for type
		 * @returns {*} - whatever the real type of stored value was
		 */
		parseValue: function (res) {
			var val;
			try {
				val = angular.fromJson(res);
				if (typeof val === 'undefined') {
					val = res;
				}
				if (val === 'true') {
					val = true;
				}
				if (val === 'false') {
					val = false;
				}
				if ($window.parseFloat(val) === val && !angular.isObject(val)) {
					val = $window.parseFloat(val);
				}
			} catch (e) {
				val = res;
			}
			return val;
		}
	};

	var publicMethods = {
		/**
		 * Set - let's you set a new localStorage key pair set
		 * @param key - a string that will be used as the accessor for the pair
		 * @param value - the value of the localStorage item
		 * @returns {*} - will return whatever it is you've stored in the local storage
		 */
		set: function (key, value) {
			if (!supported) {
				try {
					$cookieStore.put(key, value);
					return value;
				} catch(e) {
					$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
				}
			}
			var saver = angular.toJson(value);
			storage.setItem(key, saver);
			return privateMethods.parseValue(saver);
		},

		/**
		 * Get - let's you get the value of any pair you've stored
		 * @param key - the string that you set as accessor for the pair
		 * @returns {*} - Object,String,Float,Boolean depending on what you stored
		 */
		get: function (key) {
			if (!supported) {
				try {
					return privateMethods.parseValue($.cookie(key));
				} catch (e) {
					return null;
				}
			}
			var item = storage.getItem(key);
			return privateMethods.parseValue(item);
		},

		/**
		 * Remove - let's you nuke a value from localStorage
		 * @param key - the accessor value
		 * @returns {boolean} - if everything went as planned
		 */
		remove: function (key) {
			if (!supported) {
				try {
					$cookieStore.remove(key);
					return true;
				} catch (e) {
					return false;
				}
			}
			storage.removeItem(key);
			return true;
		},

		/**
		 * Bind - let's you directly bind a localStorage value to a $scope variable
		 * @param {Angular $scope} $scope - the current scope you want the variable available in
		 * @param {String} key - the name of the variable you are binding
		 * @param {Object} opts - (optional) custom options like default value or unique store name
         * Here are the available options you can set:
         * * defaultValue: the default value
         * * storeName: add a custom store key value instead of using the scope variable name
		 * @returns {*} - returns whatever the stored value is
		 */
		bind: function ($scope, key, opts) {
            var defaultOpts = {
                defaultValue: '',
                storeName: ''
            };
            // Backwards compatibility with old defaultValue string
            if (angular.isString(opts)) {
                opts = angular.extend({},defaultOpts,{defaultValue:opts});
            } else {
                // If no defined options we use defaults otherwise extend defaults
                opts = (angular.isUndefined(opts)) ? defaultOpts : angular.extend(defaultOpts,opts);
            }

			// Set the storeName key for the localStorage entry
			// use user defined in specified
			var storeName = opts.storeName || key;

			// If a value doesn't already exist store it as is
			if (!publicMethods.get(storeName)) {
				publicMethods.set(storeName, opts.defaultValue);
			}

			// If it does exist assign it to the $scope value
			$parse(key).assign($scope, publicMethods.get(storeName));

			// Register a listener for changes on the $scope value
			// to update the localStorage value
			$scope.$watch(key, function (val) {
				if (angular.isDefined(val)) {
					publicMethods.set(storeName, val);
				}
			}, true);

			return publicMethods.get(storeName);
		},
		/**
		 * Unbind - let's you unbind a variable from localStorage while removing the value from both
		 * the localStorage and the local variable and sets it to null
		 * @param $scope - the scope the variable was initially set in
		 * @param key - the name of the variable you are unbinding
		 * @param storeName - (optional) if you used a custom storeName you will have to specify it here as well
		 */
		unbind: function($scope,key,storeName) {
			storeName = storeName || key;
			$parse(key).assign($scope, null);
			$scope.$watch(key, function () { });
			publicMethods.remove(storeName);
		},
		/**
		 * Clear All - let's you clear out ALL localStorage variables, use this carefully!
		 */
		clearAll: function() {
			storage.clear();
		}
	};
	return publicMethods;
}]);
<commit_msg>Fixed confusing use of invert boolean<commit_after>angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse', '$cookieStore', '$window', '$log', function ($parse, $cookieStore, $window, $log) {
	/**
	 * Global Vars
	 */
	var storage = (typeof $window.localStorage === 'undefined') ? undefined : $window.localStorage;
	var supported = typeof storage !== 'undefined';

	var privateMethods = {
		/**
		 * Pass any type of a string from the localStorage to be parsed so it returns a usable version (like an Object)
		 * @param res - a string that will be parsed for type
		 * @returns {*} - whatever the real type of stored value was
		 */
		parseValue: function (res) {
			var val;
			try {
				val = angular.fromJson(res);
				if (typeof val === 'undefined') {
					val = res;
				}
				if (val === 'true') {
					val = true;
				}
				if (val === 'false') {
					val = false;
				}
				if ($window.parseFloat(val) === val && !angular.isObject(val)) {
					val = $window.parseFloat(val);
				}
			} catch (e) {
				val = res;
			}
			return val;
		}
	};

	var publicMethods = {
		/**
		 * Set - let's you set a new localStorage key pair set
		 * @param key - a string that will be used as the accessor for the pair
		 * @param value - the value of the localStorage item
		 * @returns {*} - will return whatever it is you've stored in the local storage
		 */
		set: function (key, value) {
			if (!supported) {
				try {
					$cookieStore.put(key, value);
					return value;
				} catch(e) {
					$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
				}
			}
			var saver = angular.toJson(value);
			storage.setItem(key, saver);
			return privateMethods.parseValue(saver);
		},

		/**
		 * Get - let's you get the value of any pair you've stored
		 * @param key - the string that you set as accessor for the pair
		 * @returns {*} - Object,String,Float,Boolean depending on what you stored
		 */
		get: function (key) {
			if (!supported) {
				try {
					return privateMethods.parseValue($.cookie(key));
				} catch (e) {
					return null;
				}
			}
			var item = storage.getItem(key);
			return privateMethods.parseValue(item);
		},

		/**
		 * Remove - let's you nuke a value from localStorage
		 * @param key - the accessor value
		 * @returns {boolean} - if everything went as planned
		 */
		remove: function (key) {
			if (!supported) {
				try {
					$cookieStore.remove(key);
					return true;
				} catch (e) {
					return false;
				}
			}
			storage.removeItem(key);
			return true;
		},

		/**
		 * Bind - let's you directly bind a localStorage value to a $scope variable
		 * @param {Angular $scope} $scope - the current scope you want the variable available in
		 * @param {String} key - the name of the variable you are binding
		 * @param {Object} opts - (optional) custom options like default value or unique store name
         * Here are the available options you can set:
         * * defaultValue: the default value
         * * storeName: add a custom store key value instead of using the scope variable name
		 * @returns {*} - returns whatever the stored value is
		 */
		bind: function ($scope, key, opts) {
            var defaultOpts = {
                defaultValue: '',
                storeName: ''
            };
            // Backwards compatibility with old defaultValue string
            if (angular.isString(opts)) {
                opts = angular.extend({},defaultOpts,{defaultValue:opts});
            } else {
                // If no defined options we use defaults otherwise extend defaults
                opts = (angular.isUndefined(opts)) ? defaultOpts : angular.extend(defaultOpts,opts);
            }

			// Set the storeName key for the localStorage entry
			// use user defined in specified
			var storeName = opts.storeName || key;

			// If a value doesn't already exist store it as is
			if (!publicMethods.get(storeName)) {
				publicMethods.set(storeName, opts.defaultValue);
			}

			// If it does exist assign it to the $scope value
			$parse(key).assign($scope, publicMethods.get(storeName));

			// Register a listener for changes on the $scope value
			// to update the localStorage value
			$scope.$watch(key, function (val) {
				if (angular.isDefined(val)) {
					publicMethods.set(storeName, val);
				}
			}, true);

			return publicMethods.get(storeName);
		},
		/**
		 * Unbind - let's you unbind a variable from localStorage while removing the value from both
		 * the localStorage and the local variable and sets it to null
		 * @param $scope - the scope the variable was initially set in
		 * @param key - the name of the variable you are unbinding
		 * @param storeName - (optional) if you used a custom storeName you will have to specify it here as well
		 */
		unbind: function($scope,key,storeName) {
			storeName = storeName || key;
			$parse(key).assign($scope, null);
			$scope.$watch(key, function () { });
			publicMethods.remove(storeName);
		},
		/**
		 * Clear All - let's you clear out ALL localStorage variables, use this carefully!
		 */
		clearAll: function() {
			storage.clear();
		}
	};
	return publicMethods;
}]);
<|endoftext|>


<commit_before>var $ = require('jquery');
var _ = require('underscore');
var cdb = require('cartodb-deep-insights.js');
var Polyglot = require('node-polyglot');
var ConfigModel = require('./data/config-model');
var EditorMapView = require('./editor/map/map-view');
var LayerDefinitionsCollection = require('./data/layer-definitions-collection');
var WidgetDefinitionsCollection = require('./data/widget-definitions-collection');
var VisDefinitionModel = require('./data/vis-definition-model');
var createEditorMenuTabPane = require('./components/tab-pane/create-editor-menu-tab-pane');
var EditorPaneTemplate = require('./editor-pane.tpl');
var EditorPaneIconItemTemplate = require('./editor-pane-icon.tpl');
var ModalsServiceModel = require('./components/modals/modals-service-model');
var viewFactory = require('./components/view-factory');

// JSON data passed from entry point (editor/visualizations/show.html):
var vizJSON = window.vizJSON;
var userData = window.userData;
var frontendConfig = window.frontendConfig;
var visualizationData = window.visualizationData;
var layersData = window.layersData;

// Setup root and top-level models and objects
var ACTIVE_LOCALE = 'en';
var Locale = require('../../locale/index');
var polyglot = new Polyglot({
  locale: ACTIVE_LOCALE, // Needed for pluralize behaviour
  phrases: Locale[ACTIVE_LOCALE]
});

window._t = polyglot.t.bind(polyglot);

// Setup and create the vis (map, layers etc.) + dashboard (widgets) from the given vizJSON
// Remove old zoom template in order to start using new component
// TODO: decide how to manage this problem
delete vizJSON.overlays[2].template; // Zoom template
var dashboard = cdb.deepInsights.createDashboard('#dashboard', vizJSON, {
  no_cdn: false,
  cartodb_logo: false,
  renderMenu: false
});

var mapId = visualizationData.map_id;
var layersCollection = dashboard.vis.map.layers;
var configModel = new ConfigModel(
  _.defaults(
    {
      base_url: userData.base_url
    },
    frontendConfig
  )
);

var visDefinitionModel = new VisDefinitionModel(visualizationData, {
  configModel: configModel
});
var layerDefinitionsCollection = new LayerDefinitionsCollection(layersData, {
  configModel: configModel,
  mapId: mapId,
  layersCollection: layersCollection
});
var widgetDefinitionsCollection = new WidgetDefinitionsCollection([], {
  configModel: configModel,
  layersCollection: layersCollection,
  dashboardWidgets: dashboard.widgets,
  mapId: mapId
});

// TODO should we provide a dashboard.done of some sort?
dashboard.vis.done(function () {
  vizJSON.widgets.forEach(function (d) {
    widgetDefinitionsCollection.add(d);
  });

  widgetDefinitionsCollection.bind('add remove reset', function () {
    dashboard.vis.mapView.invalidateSize();
  });

  dashboard.vis.centerMapToOrigin();
})
.error(function (err) {
  console.error(err);
});

var modals = new ModalsServiceModel();
var editorTabPaneView = createEditorMenuTabPane([
  {
    icon: 'edition',
    selected: true,
    createContentView: function () {
      return new EditorMapView({
        modals: modals,
        visDefinitionModel: visDefinitionModel,
        layerDefinitionsCollection: layerDefinitionsCollection,
        widgetDefinitionsCollection: widgetDefinitionsCollection
      });
    }
  }, {
    icon: 'view',
    createContentView: function () {
      return viewFactory.createByHTML('View');
    }
  }, {
    icon: 'odyssey',
    createContentView: function () {
      return viewFactory.createByHTML('Odyssey');
    }
  }, {
    icon: 'settings',
    createContentView: function () {
      return viewFactory.createByHTML('Settings');
    }
  }], {
    tabPaneOptions: {
      className: 'Editor-wrapper',
      template: EditorPaneTemplate,
      url: userData.base_url,
      avatar_url: userData.avatar_url,
      tabPaneItemOptions: {
        tagName: 'li',
        className: 'EditorMenu-navigationItem'
      }
    },
    tabPaneItemIconOptions: {
      tagName: 'button',
      template: EditorPaneIconItemTemplate,
      className: 'EditorMenu-navigationLink'
    }
  });

$('.js-editor').prepend(editorTabPaneView.render().$el);

document.title = dashboard.vis.map.get('title') + ' | CartoDB';

// Expose the root stuff to be able to inspect and modify state from developer console
window.configModel = configModel;
window.dashboard = dashboard;
window.layerDefinitionsCollection = layerDefinitionsCollection;
window.modals = modals;
window.viewFactory = viewFactory;
window.vis = dashboard.vis;
window.visDefinitionModel = visDefinitionModel;
window.widgetDefinitionsCollection = widgetDefinitionsCollection;
<commit_msg>Add missing API key to the frontend config<commit_after>var $ = require('jquery');
var _ = require('underscore');
var cdb = require('cartodb-deep-insights.js');
var Polyglot = require('node-polyglot');
var ConfigModel = require('./data/config-model');
var EditorMapView = require('./editor/map/map-view');
var LayerDefinitionsCollection = require('./data/layer-definitions-collection');
var WidgetDefinitionsCollection = require('./data/widget-definitions-collection');
var VisDefinitionModel = require('./data/vis-definition-model');
var createEditorMenuTabPane = require('./components/tab-pane/create-editor-menu-tab-pane');
var EditorPaneTemplate = require('./editor-pane.tpl');
var EditorPaneIconItemTemplate = require('./editor-pane-icon.tpl');
var ModalsServiceModel = require('./components/modals/modals-service-model');
var viewFactory = require('./components/view-factory');

// JSON data passed from entry point (editor/visualizations/show.html):
var vizJSON = window.vizJSON;
var userData = window.userData;
var frontendConfig = window.frontendConfig;
var visualizationData = window.visualizationData;
var layersData = window.layersData;

// Setup root and top-level models and objects
var ACTIVE_LOCALE = 'en';
var Locale = require('../../locale/index');
var polyglot = new Polyglot({
  locale: ACTIVE_LOCALE, // Needed for pluralize behaviour
  phrases: Locale[ACTIVE_LOCALE]
});

window._t = polyglot.t.bind(polyglot);

// Setup and create the vis (map, layers etc.) + dashboard (widgets) from the given vizJSON
// Remove old zoom template in order to start using new component
// TODO: decide how to manage this problem
delete vizJSON.overlays[2].template; // Zoom template
var dashboard = cdb.deepInsights.createDashboard('#dashboard', vizJSON, {
  no_cdn: false,
  cartodb_logo: false,
  renderMenu: false
});

var mapId = visualizationData.map_id;
var layersCollection = dashboard.vis.map.layers;
var configModel = new ConfigModel(
  _.defaults(
    {
      base_url: userData.base_url,
      api_key: userData.api_key
    },
    frontendConfig
  )
);

var visDefinitionModel = new VisDefinitionModel(visualizationData, {
  configModel: configModel
});
var layerDefinitionsCollection = new LayerDefinitionsCollection(layersData, {
  configModel: configModel,
  mapId: mapId,
  layersCollection: layersCollection
});
var widgetDefinitionsCollection = new WidgetDefinitionsCollection([], {
  configModel: configModel,
  layersCollection: layersCollection,
  dashboardWidgets: dashboard.widgets,
  mapId: mapId
});

// TODO should we provide a dashboard.done of some sort?
dashboard.vis.done(function () {
  vizJSON.widgets.forEach(function (d) {
    widgetDefinitionsCollection.add(d);
  });

  widgetDefinitionsCollection.bind('add remove reset', function () {
    dashboard.vis.mapView.invalidateSize();
  });

  dashboard.vis.centerMapToOrigin();
})
.error(function (err) {
  console.error(err);
});

var modals = new ModalsServiceModel();
var editorTabPaneView = createEditorMenuTabPane([
  {
    icon: 'edition',
    selected: true,
    createContentView: function () {
      return new EditorMapView({
        modals: modals,
        visDefinitionModel: visDefinitionModel,
        layerDefinitionsCollection: layerDefinitionsCollection,
        widgetDefinitionsCollection: widgetDefinitionsCollection
      });
    }
  }, {
    icon: 'view',
    createContentView: function () {
      return viewFactory.createByHTML('View');
    }
  }, {
    icon: 'odyssey',
    createContentView: function () {
      return viewFactory.createByHTML('Odyssey');
    }
  }, {
    icon: 'settings',
    createContentView: function () {
      return viewFactory.createByHTML('Settings');
    }
  }], {
    tabPaneOptions: {
      className: 'Editor-wrapper',
      template: EditorPaneTemplate,
      url: userData.base_url,
      avatar_url: userData.avatar_url,
      tabPaneItemOptions: {
        tagName: 'li',
        className: 'EditorMenu-navigationItem'
      }
    },
    tabPaneItemIconOptions: {
      tagName: 'button',
      template: EditorPaneIconItemTemplate,
      className: 'EditorMenu-navigationLink'
    }
  });

$('.js-editor').prepend(editorTabPaneView.render().$el);

document.title = dashboard.vis.map.get('title') + ' | CartoDB';

// Expose the root stuff to be able to inspect and modify state from developer console
window.configModel = configModel;
window.dashboard = dashboard;
window.layerDefinitionsCollection = layerDefinitionsCollection;
window.modals = modals;
window.viewFactory = viewFactory;
window.vis = dashboard.vis;
window.visDefinitionModel = visDefinitionModel;
window.widgetDefinitionsCollection = widgetDefinitionsCollection;
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2016-present, Nicolas Gallagher.
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @providesModule AppState
 * @flow
 */

import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import findIndex from 'array-find-index';
import invariant from 'fbjs/lib/invariant';

const EVENT_TYPES = ['change'];
const VISIBILITY_CHANGE_EVENT = 'visibilitychange';

const AppStates = {
  BACKGROUND: 'background',
  ACTIVE: 'active'
};

const listeners = [];

export default class AppState {
  static isAvailable = ExecutionEnvironment.canUseDOM && document.visibilityState;

  static get currentState() {
    if (!AppState.isAvailable) {
      return AppStates.ACTIVE;
    }

    switch (document.visibilityState) {
      case 'hidden':
      case 'prerender':
      case 'unloaded':
        return AppStates.BACKGROUND;
      default:
        return AppStates.ACTIVE;
    }
  }

  static addEventListener(type: string, handler: Function) {
    if (AppState.isAvailable) {
      invariant(
        EVENT_TYPES.indexOf(type) !== -1,
        'Trying to subscribe to unknown event: "%s"',
        type
      );
      const callback = () => handler(AppState.currentState);
      listeners.push([handler, callback]);
      document.addEventListener(VISIBILITY_CHANGE_EVENT, callback, false);
    }
  }

  static removeEventListener(type: string, handler: Function) {
    if (AppState.isAvailable) {
      invariant(
        EVENT_TYPES.indexOf(type) !== -1,
        'Trying to remove listener for unknown event: "%s"',
        type
      );
      const listenerIndex = findIndex(listeners, pair => pair[0] === handler);
      invariant(
        listenerIndex !== -1,
        'Trying to remove AppState listener for unregistered handler'
      );
      const callback = listeners[listenerIndex][1];
      document.removeEventListener(VISIBILITY_CHANGE_EVENT, callback, false);
      listeners.splice(listenerIndex, 1);
    }
  }
}
<commit_msg>[fix] AppState support for Android browser 4.4<commit_after>/**
 * Copyright (c) 2016-present, Nicolas Gallagher.
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @providesModule AppState
 * @noflow
 */

import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import findIndex from 'array-find-index';
import invariant from 'fbjs/lib/invariant';

// Android 4.4 browser
const isPrefixed = !document.hasOwnProperty('hidden') && document.hasOwnProperty('webkitHidden');

const EVENT_TYPES = ['change'];
const VISIBILITY_CHANGE_EVENT = isPrefixed ? 'webkitvisibilitychange' : 'visibilitychange';
const VISIBILITY_STATE_PROPERTY = isPrefixed ? 'webkitVisibilityState' : 'visibilityState';

const AppStates = {
  BACKGROUND: 'background',
  ACTIVE: 'active'
};

const listeners = [];

export default class AppState {
  static isAvailable = ExecutionEnvironment.canUseDOM && document[VISIBILITY_STATE_PROPERTY];

  static get currentState() {
    if (!AppState.isAvailable) {
      return AppStates.ACTIVE;
    }

    switch (document[VISIBILITY_STATE_PROPERTY]) {
      case 'hidden':
      case 'prerender':
      case 'unloaded':
        return AppStates.BACKGROUND;
      default:
        return AppStates.ACTIVE;
    }
  }

  static addEventListener(type: string, handler: Function) {
    if (AppState.isAvailable) {
      invariant(
        EVENT_TYPES.indexOf(type) !== -1,
        'Trying to subscribe to unknown event: "%s"',
        type
      );
      const callback = () => handler(AppState.currentState);
      listeners.push([handler, callback]);
      document.addEventListener(VISIBILITY_CHANGE_EVENT, callback, false);
    }
  }

  static removeEventListener(type: string, handler: Function) {
    if (AppState.isAvailable) {
      invariant(
        EVENT_TYPES.indexOf(type) !== -1,
        'Trying to remove listener for unknown event: "%s"',
        type
      );
      const listenerIndex = findIndex(listeners, pair => pair[0] === handler);
      invariant(
        listenerIndex !== -1,
        'Trying to remove AppState listener for unregistered handler'
      );
      const callback = listeners[listenerIndex][1];
      document.removeEventListener(VISIBILITY_CHANGE_EVENT, callback, false);
      listeners.splice(listenerIndex, 1);
    }
  }
}
<|endoftext|>


<commit_before>'use strict';

class ChartMogulError extends Error {
  constructor (message, httpStatus, response) {
    super(message);
    this.name = this.constructor.name;
    this.message = message;
    this.response = response;
    this.httpStatus = httpStatus;
    Error.captureStackTrace(this, this.constructor.name);
  }
}

module.exports = ChartMogulError;
<commit_msg>The response from API should get included by default<commit_after>'use strict';

class ChartMogulError extends Error {
  constructor (message, httpStatus, response) {
    super(message + ' ' + JSON.stringify(response));
    this.name = this.constructor.name;
    this.response = response;
    this.httpStatus = httpStatus;
    Error.captureStackTrace(this, this.constructor.name);
  }
}

module.exports = ChartMogulError;
<|endoftext|>


<commit_before>#!/usr/bin/env node

var optionator = require("optionator"),
    glob = require("glob"),
    shell = require("shelljs"),
    fs = require('fs'),
    parser = require('../src/parse'),
    chalk = require('chalk');

var exitCode = 0,
    options = optionator({
        prepend: "docs-cli [options] file.js [file.js] [dir]",
        concatRepeatedArrays: true,
        mergeRepeatedObjects: true,
        options: [
            {
                heading: "Basic configuration"
            },
            {
                option: "ext",
                type: "[String]",
                default: ".js",
                description: "Specify JavaScript file extensions"
            }
        ]
    });

function processPath(extensions) {
    var suffix = "/**";

    if (extensions) {
        if (extensions.length === 1) {
            suffix += "/*." + extensions[0];
        } else {
            suffix += "/*.{" + extensions.join(",") + "}";
        }
    }

    return function(pathname) {
        var newPath = pathname;

        if (shell.test("-d", pathname)) {
            newPath = pathname.replace(/[\/\\]$/, "") + suffix;
        }

        return newPath.replace(/\\/g, "/").replace(/^\.\//, "");
    };
}

function patternToFile(globPatterns) {
    var files = [],
        added = {};

    function addFile(filename) {
        filename = fs.realpathSync(filename);
        if (added[filename]) {
            return;
        }
        files.push(filename);
        added[filename] = true;
    }

    globPatterns.forEach(function(pattern) {
        if (shell.test("-f", pattern)) {
            addFile(pattern);
        } else {
            glob.sync(pattern, { nodir: true }).forEach(addFile);
        }
    });

    return files;
}

function printError(e) {
    console.log(chalk.bold.red('Error in ') + e.file);
    console.log(chalk.red(e.message));
}

function run() {
    try {
        currentOptions = options.parse(process.argv);
    } catch (error) {
        console.log(error.message);
        return 1;
    }

    files = currentOptions._;

    if (currentOptions.help || !files.length) {
        console.log(options.generateHelp());
        return 0;
    }

    var extensions = (currentOptions.ext || [".js"])
            .map(function(ext) {
                return ext.charAt(0) === "." ? ext.substr(1) : ext;
            }),
        docs = [],
        errors = [];

    patternToFile(files.map(processPath(extensions)))
        .map(function(file) {
            try {
                parser('' + fs.readFileSync(file)).forEach(function(doc) {
                    doc.file = file;
                    docs.push(doc);
                });
            } catch (e) {
                throw e;
                errors.push({
                    file: file,
                    message: e.message
                });
            }
        });

    if (errors.length) {
        errors.forEach(printError);
        return 1;
    }

    return 0;
}

exitCode = run();

process.on("exit", function() {
    process.exit(exitCode);
});
<commit_msg>adding back cli functionality<commit_after>#!/usr/bin/env node

var optionator = require("optionator"),
    glob = require("glob"),
    shell = require("shelljs"),
    fs = require('fs'),
    parser = require('../src/parse'),
    chalk = require('chalk');

var exitCode = 0,
    options = optionator({
        prepend: "docs-cli [options] file.js [file.js] [dir]",
        concatRepeatedArrays: true,
        mergeRepeatedObjects: true,
        options: [
            {
                heading: "Basic configuration"
            },
            {
                option: "ext",
                type: "[String]",
                default: ".js",
                description: "Specify JavaScript file extensions"
            }
        ]
    });

function processPath(extensions) {
    var suffix = "/**";

    if (extensions) {
        if (extensions.length === 1) {
            suffix += "/*." + extensions[0];
        } else {
            suffix += "/*.{" + extensions.join(",") + "}";
        }
    }

    return function(pathname) {
        var newPath = pathname;

        if (shell.test("-d", pathname)) {
            newPath = pathname.replace(/[\/\\]$/, "") + suffix;
        }

        return newPath.replace(/\\/g, "/").replace(/^\.\//, "");
    };
}

function patternToFile(globPatterns) {
    var files = [],
        added = {};

    function addFile(filename) {
        filename = fs.realpathSync(filename);
        if (added[filename]) {
            return;
        }
        files.push(filename);
        added[filename] = true;
    }

    globPatterns.forEach(function(pattern) {
        if (shell.test("-f", pattern)) {
            addFile(pattern);
        } else {
            glob.sync(pattern, { nodir: true }).forEach(addFile);
        }
    });

    return files;
}

function printError(e) {
    console.log(chalk.bold.red('Error in ') + e.file);
    console.log(chalk.red(e.message));
}

function run() {
    try {
        currentOptions = options.parse(process.argv);
    } catch (error) {
        console.log(error.message);
        return 1;
    }

    files = currentOptions._;

    if (currentOptions.help || !files.length) {
        console.log(options.generateHelp());
        return 0;
    }

    var extensions = (currentOptions.ext || [".js"])
            .map(function(ext) {
                return ext.charAt(0) === "." ? ext.substr(1) : ext;
            }),
        docs = [],
        errors = [];

    patternToFile(files.map(processPath(extensions)))
        .map(function(file) {
            try {
                parser('' + fs.readFileSync(file)).forEach(function(doc) {
                    doc.file = file;
                    docs.push(doc);
                });
            } catch (e) {
                errors.push({
                    file: file,
                    message: e.message
                });
            }
        });

    if (errors.length) {
        errors.forEach(printError);
        return 1;
    }

    return 0;
}

exitCode = run();

process.on("exit", function() {
    process.exit(exitCode);
});
<|endoftext|>


<commit_before>import React from 'react'
import Helmet from 'react-helmet'

import BpkLink from 'bpk-component-link'
import BpkHeading from 'bpk-component-heading'
import BpkParagraph from 'bpk-component-paragraph'
import { BpkList, BpkListItem } from 'bpk-component-list'
import BpkContentContainer from 'bpk-component-content-container'
import PresentationBlock from './../../components/PresentationBlock'

const anchors = {
  headings: 'content-page-headings',
  paragraphs: 'content-page-paragraphs',
  links: 'content-page-links',
  lists: 'content-page-lists'
}

const TypographyPage = () => (

    <Helmet title='Typography' />
    <BpkContentContainer>
      <BpkHeading level='h1'>Typography</BpkHeading>
      <BpkParagraph>
        Headings, paragraphs, links, lists and more.
        <BpkLink href='/sassdoc/#typography' blank>View the Sass documentation.</BpkLink>
      </BpkParagraph>
      <BpkList>
        <BpkListItem>
          <BpkLink href={`#${anchors.headings}`}>Headings</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.paragraphs}`}>Paragaphs</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.links}`}>Links</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.lists}`}>Lists</BpkLink>
        </BpkListItem>
      </BpkList>
      <BpkHeading id={anchors.headings} level='h2'>Headings</BpkHeading>
      <PresentationBlock>
        <BpkHeading level='h1'>Heading 1</BpkHeading>
        <BpkHeading level='h2'>Heading 2</BpkHeading>
        <BpkHeading level='h3'>Heading 3</BpkHeading>
        <BpkHeading level='h4'>Heading 4</BpkHeading>
        <BpkHeading level='h5'>Heading 5</BpkHeading>
        <BpkHeading level='h6'>Heading 6</BpkHeading>
      </PresentationBlock>
      <BpkHeading id={anchors.paragraphs} level='h2'>Paragraphs</BpkHeading>
      <PresentationBlock>
        <BpkParagraph>
          Rizzle ipsizzle dolizzle ass cool, crazy adipiscing elizzle. Nullam phat velizzle, i'm in the shizzle
          volutpizzle, check out this quizzle, cool vizzle, arcu. Pellentesque sheezy tortor.
        </BpkParagraph>
        <BpkParagraph>
          Owned erizzle. Black izzle dolor dapibizzle turpis tempizzle ghetto. Dope pellentesque nibh et turpis. Sure in
          tortizzle. Pellentesque eleifend rhoncizzle crackalackin. In hac habitasse platea dictumst.
        </BpkParagraph>
        <BpkParagraph>
          Fo shizzle my nizzle dapibizzle. Curabitizzle tellus izzle, pretizzle nizzle, da bomb sheezy, eleifend its fo
          rizzle, check out this. Nizzle suscipizzle. Shizznit semper crackalackin phat boofron.
        </BpkParagraph>
      </PresentationBlock>
      <BpkHeading id={anchors.links} level='h2'>Links</BpkHeading>
      <PresentationBlock>
        <BpkLink href='#'>Link 1</BpkLink>{'\n'}
        <BpkLink href='#'>Link 2</BpkLink>{'\n'}
        <BpkLink href='#'>Link 3</BpkLink>
      </PresentationBlock>
      <BpkHeading id={anchors.lists} level='h2'>Lists</BpkHeading>
      <PresentationBlock>
        <BpkList>
          <BpkListItem>Apples</BpkListItem>
          <BpkListItem>Oranges
            <BpkList>
              <BpkListItem>Tangerines</BpkListItem>
              <BpkListItem>Mandarins</BpkListItem>
              <BpkListItem>Satsumas</BpkListItem>
            </BpkList>
          </BpkListItem>
          <BpkListItem>Pears</BpkListItem>
        </BpkList>
        <BpkList ordered>
          <BpkListItem>First</BpkListItem>
          <BpkListItem>Second</BpkListItem>
          <BpkListItem>First</BpkListItem>
        </BpkList>
      </PresentationBlock>
    </BpkContentContainer>

)

export default TypographyPage
<commit_msg>BPK-127: Formatting Typography page<commit_after>import React from 'react'
import Helmet from 'react-helmet'

import BpkLink from 'bpk-component-link'
import BpkHeading from 'bpk-component-heading'
import BpkParagraph from 'bpk-component-paragraph'
import { BpkList, BpkListItem } from 'bpk-component-list'
import BpkContentContainer from 'bpk-component-content-container'
import PresentationBlock from './../../components/PresentationBlock'

const anchors = {
  headings: 'content-page-headings',
  paragraphs: 'content-page-paragraphs',
  links: 'content-page-links',
  lists: 'content-page-lists'
}

const TypographyPage = () => (

    <Helmet title='Typography' />
    <BpkContentContainer>
      <BpkHeading level='h1'>Typography</BpkHeading>
      <BpkParagraph>
        Headings, paragraphs, links, lists and more.
        <BpkLink href='/sassdoc/#typography' blank>View the Sass documentation.</BpkLink>
      </BpkParagraph>
      <BpkHeading level='h2'>Examples</BpkHeading>
      <BpkList>
        <BpkListItem>
          <BpkLink href={`#${anchors.headings}`}>Headings</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.paragraphs}`}>Paragaphs</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.links}`}>Links</BpkLink>
        </BpkListItem>
        <BpkListItem>
          <BpkLink href={`#${anchors.lists}`}>Lists</BpkLink>
        </BpkListItem>
      </BpkList>
      <BpkHeading id={anchors.headings} level='h3'>Headings</BpkHeading>
      <PresentationBlock>
        <BpkHeading level='h1'>Heading 1</BpkHeading>
        <BpkHeading level='h2'>Heading 2</BpkHeading>
        <BpkHeading level='h3'>Heading 3</BpkHeading>
        <BpkHeading level='h4'>Heading 4</BpkHeading>
        <BpkHeading level='h5'>Heading 5</BpkHeading>
        <BpkHeading level='h6'>Heading 6</BpkHeading>
      </PresentationBlock>
      <BpkHeading id={anchors.paragraphs} level='h3'>Paragraphs</BpkHeading>
      <PresentationBlock>
        <BpkParagraph>
          Rizzle ipsizzle dolizzle ass cool, crazy adipiscing elizzle. Nullam phat velizzle, i'm in the shizzle
          volutpizzle, check out this quizzle, cool vizzle, arcu. Pellentesque sheezy tortor.
        </BpkParagraph>
        <BpkParagraph>
          Owned erizzle. Black izzle dolor dapibizzle turpis tempizzle ghetto. Dope pellentesque nibh et turpis. Sure in
          tortizzle. Pellentesque eleifend rhoncizzle crackalackin. In hac habitasse platea dictumst.
        </BpkParagraph>
        <BpkParagraph>
          Fo shizzle my nizzle dapibizzle. Curabitizzle tellus izzle, pretizzle nizzle, da bomb sheezy, eleifend its fo
          rizzle, check out this. Nizzle suscipizzle. Shizznit semper crackalackin phat boofron.
        </BpkParagraph>
      </PresentationBlock>
      <BpkHeading id={anchors.links} level='h3'>Links</BpkHeading>
      <PresentationBlock>
        <BpkLink href='#'>Link 1</BpkLink>{'\n'}
        <BpkLink href='#'>Link 2</BpkLink>{'\n'}
        <BpkLink href='#'>Link 3</BpkLink>
      </PresentationBlock>
      <BpkHeading id={anchors.lists} level='h2'>Lists</BpkHeading>
      <PresentationBlock>
        <BpkList>
          <BpkListItem>Apples</BpkListItem>
          <BpkListItem>Oranges
            <BpkList>
              <BpkListItem>Tangerines</BpkListItem>
              <BpkListItem>Mandarins</BpkListItem>
              <BpkListItem>Satsumas</BpkListItem>
            </BpkList>
          </BpkListItem>
          <BpkListItem>Pears</BpkListItem>
        </BpkList>
        <BpkList ordered>
          <BpkListItem>First</BpkListItem>
          <BpkListItem>Second</BpkListItem>
          <BpkListItem>First</BpkListItem>
        </BpkList>
      </PresentationBlock>
      <BpkHeading level='h2'>Usage</BpkHeading>
      <BpkParagraph>Matt to write</BpkParagraph>
    </BpkContentContainer>

)

export default TypographyPage
<|endoftext|>


<commit_before>const babel = require('rollup-plugin-babel');
const multiEntry = require('rollup-plugin-multi-entry');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('@lhorie/rollup-plugin-commonjs');
const replace = require('rollup-plugin-replace');
const browserConfig = require('./browser-config.js');

const template = ({env}) => `${env}.js`;

module.exports = (userBabelConfig) => ({
  formats: ['iife'],
  template,
  plugins: [
    multiEntry({exports: false}),
    resolve({browser: true}),
    commonjs({include: 'node_modules/**'}),
    babel(Object.assign({}, browserConfig(userBabelConfig), {exclude: 'node_modules/**'})),
    replace({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    }),
  ],
});
<commit_msg>Fix rollup plugin import<commit_after>const babel = require('rollup-plugin-babel');
const multiEntry = require('rollup-plugin-multi-entry');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const replace = require('rollup-plugin-replace');
const browserConfig = require('./browser-config.js');

const template = ({env}) => `${env}.js`;

module.exports = (userBabelConfig) => ({
  formats: ['iife'],
  template,
  plugins: [
    multiEntry({exports: false}),
    resolve({browser: true}),
    commonjs({include: 'node_modules/**'}),
    babel(Object.assign({}, browserConfig(userBabelConfig), {exclude: 'node_modules/**'})),
    replace({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    }),
  ],
});
<|endoftext|>


<commit_before>'use strict';

angular.module('mean.icu.ui.tasklist', [])
.controller('TaskListController', function ($scope, $state, tasks, TasksService, context) {
    $scope.tasks = tasks;
    $scope.autocomplete = context.entityName === 'discussion';

    $scope.showStarred = false;

    $scope.isCurrentState = function(id) {
        return $state.current.name.indexOf('main.tasks.byentity') === 0 &&
            $state.current.name.indexOf('details') === -1;
    };

    $scope.changeOrder = function () {
        $scope.sorting.isReverse = !$scope.sorting.isReverse;
    };

    $scope.sorting = {
        field: 'created',
        isReverse: false
    };

    $scope.sortingList = [
        {
            title: 'Due',
            value: 'due'
        }, {
            title: 'Project',
            value: 'project._id'
        }, {
            title: 'Title',
            value: 'title'
        }, {
            title: 'Status',
            value: 'status'
        }, {
            title: 'Created',
            value: 'created'
        }
    ];

    function navigateToDetails(task) {
        $scope.detailsState = context.entityName === 'all' ? 'main.tasks.all.details' : 'main.tasks.byentity.details';

        $state.go($scope.detailsState, {
            id: task._id,
            entity: $scope.currentContext.entityName,
            entityId: $scope.currentContext.entityId
        });
    }

    $scope.starredOnly = function () {
        $scope.showStarred = !$scope.showStarred;
        if ($scope.showStarred) {
            TasksService.getStarred().then(function(starred) {
                $scope.tasks = _(tasks).reduce(function(list, item) {
                    var contains = _(starred).any(function(s) {
                        return s._id === item._id;
                    });

                    if (contains) {
                        list.push(item);
                    }

                    return list;
                }, []);

                navigateToDetails($scope.tasks[0]);
            });
        } else {
            $scope.tasks = tasks;
            navigateToDetails($scope.tasks[0]);
        }
    };

    if ($scope.tasks.length) {
        if ($state.current.name === 'main.tasks.all' ||
            $state.current.name === 'main.tasks.byentity') {
                navigateToDetails($scope.tasks[0]);
        }
    } else if (
            $state.current.name !== 'main.tasks.byentity.activities' &&
            $state.current.name !== 'main.tasks.byentity.tasks') {
        $state.go('.activities');
    }
});
<commit_msg>Sort by title<commit_after>'use strict';

angular.module('mean.icu.ui.tasklist', [])
.controller('TaskListController', function ($scope, $state, tasks, TasksService, context) {
    $scope.tasks = tasks;
    $scope.autocomplete = context.entityName === 'discussion';

    $scope.showStarred = false;

    $scope.isCurrentState = function(id) {
        return $state.current.name.indexOf('main.tasks.byentity') === 0 &&
            $state.current.name.indexOf('details') === -1;
    };

    $scope.changeOrder = function () {
        $scope.sorting.isReverse = !$scope.sorting.isReverse;
    };

    $scope.sorting = {
        field: 'created',
        isReverse: false
    };

    $scope.sortingList = [
        {
            title: 'Due',
            value: 'due'
        }, {
            title: 'Project',
            value: 'project.title'
        }, {
            title: 'Title',
            value: 'title'
        }, {
            title: 'Status',
            value: 'status'
        }, {
            title: 'Created',
            value: 'created'
        }
    ];

    function navigateToDetails(task) {
        $scope.detailsState = context.entityName === 'all' ? 'main.tasks.all.details' : 'main.tasks.byentity.details';

        $state.go($scope.detailsState, {
            id: task._id,
            entity: $scope.currentContext.entityName,
            entityId: $scope.currentContext.entityId
        });
    }

    $scope.starredOnly = function () {
        $scope.showStarred = !$scope.showStarred;
        if ($scope.showStarred) {
            TasksService.getStarred().then(function(starred) {
                $scope.tasks = _(tasks).reduce(function(list, item) {
                    var contains = _(starred).any(function(s) {
                        return s._id === item._id;
                    });

                    if (contains) {
                        list.push(item);
                    }

                    return list;
                }, []);

                navigateToDetails($scope.tasks[0]);
            });
        } else {
            $scope.tasks = tasks;
            navigateToDetails($scope.tasks[0]);
        }
    };

    if ($scope.tasks.length) {
        if ($state.current.name === 'main.tasks.all' ||
            $state.current.name === 'main.tasks.byentity') {
                navigateToDetails($scope.tasks[0]);
        }
    } else if (
            $state.current.name !== 'main.tasks.byentity.activities' &&
            $state.current.name !== 'main.tasks.byentity.tasks') {
        $state.go('.activities');
    }
});
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(FILL_ME_IN);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe(FILL_ME_IN);
    expect(overrideMessage()).toBe(FILL_ME_IN);
    expect(message).toBe(FILL_ME_IN);
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe(FILL_ME_IN);
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>Finished<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe("first");

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe();

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe("first,second,third");
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe("John rules!");

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe("Mary totally rules!");

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(3);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe("function (a, b) {
      //An internal comment
      return a * b;
    }");
  });
});
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>Corrected the values for the 5th test, extra function arguments<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe("first");

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(undefined);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe("first,second,third");
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
      var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe("first");

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(undefined);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe("first,second,third");
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>It passes functions as values<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
      var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe("first");

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(undefined);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe("first,second,third");
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe("John rules!");

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe("Mary totally rules!");

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<|endoftext|>


<commit_before>'use strict';

import React, { Component } from 'react';
import Swiper from 'react-native-swiper';

import {
  Text,
  View,
  StyleSheet,
  Image,
} from 'react-native';

class DetailImages extends Component {

  showImages() {
    console.log(this.props.photos)
    var components = this.props.photos.map((photo,index)=>{
    var photo = photo.replace(/^http:\/\//i, 'https://');
      console.log(photo)
      return (
        <View key={index} style={styles.slide2}>
         <Image style={styles.image} source={{uri: photo}} />
        </View>
      )
    })
    return components
  }

  render(){
    var images = this.showImages()
    if(images.length == 1){
      return(
      <Image style={styles.image} source={{uri: this.props.photos[0]}} />
      )
    } else {
    return (
      <Swiper style={styles.wrapper} height={360} showsButtons={true}>
        {images}
         {/*<View style={styles.slide1}>
           <Image style={styles.image} source={{uri: this.props.photos[0]}} />
         </View>
         <View style={styles.slide2}>
          <Image style={styles.image} source={{uri: this.props.photos[1]}} />
         </View>
         <View style={styles.slide3}>
          <Image style={styles.image} source={{uri: this.props.photos[2]}} />
         </View>*/}
      </Swiper>
    )
    }
  }
}
  const styles = StyleSheet.create({
    wrapper: {
     },
     slide: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#9DD6EB',
     },
     slide2: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#97CAE5',
     },
     slide3: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#92BBD9',
     },
     text: {
       color: '#fff',
       fontSize: 30,
       fontWeight: 'bold',
    },
    image:{
      height:360,
      width:375,
    },
});

export default DetailImages;
<commit_msg>pushing<commit_after>'use strict';

import React, { Component } from 'react';
import Swiper from 'react-native-swiper';

import {
  Text,
  View,
  StyleSheet,
  Image,
} from 'react-native';

class DetailImages extends Component {

  showImages() {
    console.log(this.props.photos)
    var components = this.props.photos.map((photo,index)=>{
    var photo = photo.replace(/^http:\/\//i, 'https://');
      console.log(photo)
      return (
        <View key={index} style={styles.slide2}>
         <Image style={styles.image} source={{uri: photo}} />
        </View>
      )
    })
    return components
  }

  render(){
    var images = this.showImages()
    if(images.length == 1){
      return(
      <Image style={styles.image} source={{uri: this.props.photos[0]}} />
      )
    } else {
    return (
      <Swiper style={styles.wrapper} height={360} showsButtons={true}>
        {images}
         {/*<View style={styles.slide1}>
           <Image style={styles.image} source={{uri: this.props.photos[0]}} />
         </View>
         <View style={styles.slide2}>
          <Image style={styles.image} source={{uri: this.props.photos[1]}} />
         </View>
         <View style={styles.slide3}>
          <Image style={styles.image} source={{uri: this.props.photos[2]}} />
         </View>*/}
      </Swiper>
    )

    }
  }
}
  const styles = StyleSheet.create({
    wrapper: {
     },
     slide: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#9DD6EB',
     },
     slide2: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#97CAE5',
     },
     slide3: {
       justifyContent: 'center',
       alignItems: 'center',
       backgroundColor: '#92BBD9',
     },
     text: {
       color: '#fff',
       fontSize: 30,
       fontWeight: 'bold',
    },
    image:{
      height:360,
      width:375,
    },
});

export default DetailImages;
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(FILL_ME_IN);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe(FILL_ME_IN);
    expect(overrideMessage()).toBe(FILL_ME_IN);
    expect(message).toBe(FILL_ME_IN);
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe(FILL_ME_IN);
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>AboutFunctions - can't get the last expect() to go through<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe("first");

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(undefined);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe("first,second,third");
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe("John rules!");

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe("Mary totally rules!");

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(3);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe('function (a, b) {
      //An internal comment
      return a * b;
      }');
  });
});
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe(FILL_ME_IN);
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>"Fixed: AboutFunctions.js - Problem (3) : it('should have lexical ..'"<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe("Outer");
    expect(overrideMessage()).toBe("Inner");
    expect(message).toBe("Outer");
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe("local");
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<|endoftext|>


<commit_before>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe('Outer');
    expect(overrideMessage()).toBe('Inner');
    expect(message).toBe('Outer');
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe('local');
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe('first');

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe();

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe('first,second,third');
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<commit_msg>fill in correct values for passing functions as strings<commit_after>describe("About Functions", function() {

  it("should declare functions", function() {

    function add(a, b) {
      return a + b;
    }

    expect(add(1, 2)).toBe(3);
  });

  it("should know internal variables override outer variables", function () {
    var message = "Outer";

    function getMessage() {
      return message;
    }

    function overrideMessage() {
      var message = "Inner";
      return message;
    }

    expect(getMessage()).toBe('Outer');
    expect(overrideMessage()).toBe('Inner');
    expect(message).toBe('Outer');
  });

  it("should have lexical scoping", function () {
    var variable = "top-level";
    function parentfunction() {
        var variable = "local";
      function childfunction() {
          return variable;
      }
      return childfunction();
    }
    expect(parentfunction()).toBe('local');
  });

  it("should use lexical scoping to synthesise functions", function () {

    function makeIncreaseByFunction(increaseByAmount) {
      return function (numberToIncrease) {
        return numberToIncrease + increaseByAmount;
      };
    }

    var increaseBy3 = makeIncreaseByFunction(3);
    var increaseBy5 = makeIncreaseByFunction(5);

    expect(increaseBy3(10) + increaseBy5(10)).toBe(28);
  });

  it("should allow extra function arguments", function () {

    function returnFirstArg(firstArg) {
      return firstArg;
    }

    expect(returnFirstArg("first", "second", "third")).toBe('first');

    function returnSecondArg(firstArg, secondArg) {
      return secondArg;
    }

    expect(returnSecondArg("only give first arg")).toBe();

    function returnAllArgs() {
      var argsArray = [];
      for (var i = 0; i < arguments.length; i += 1) {
        argsArray.push(arguments[i]);
      }
      return argsArray.join(",");
    }

    expect(returnAllArgs("first", "second", "third")).toBe('first,second,third');
  });

  it("should pass functions as values", function () {

    var appendRules = function (name) {
      return name + " rules!";
    };

    var appendDoubleRules = function (name) {
      return name + " totally rules!";
    };

    var praiseSinger = { givePraise: appendRules };
    expect(praiseSinger.givePraise("John")).toBe('John rules!');

    praiseSinger.givePraise = appendDoubleRules;
    expect(praiseSinger.givePraise("Mary")).toBe('Mary totally rules!');

  });

  it("should use function body as a string", function () {
    var add = new Function("a", "b", "return a + b;");
    expect(add(1, 2)).toBe(FILL_ME_IN);

    var multiply = function (a, b) {
      //An internal comment
      return a * b;
    };
    expect(multiply.toString()).toBe(FILL_ME_IN);
  });
});
<|endoftext|>