<commit_before>(function () {
    paper.install(window);

    /**
     * Convenience Method  that makes a text for an element
     * @param element The element to set the text
     * @param text The string text
     * @returns {PointText} The configured point text element
     */
    function makeText(element, text) {
        var center = element.getBounds().center;
        var pointText = new PointText({
            point: center,
            content: text,
            fillColor: "black",
            fontSize: 20
        });
        pointText.getBounds().center = center;

        return pointText;
    }

    /**
     * Convenience Method that makes a group with a element and text element draggable
     * @param element The rectangle or circle
     * @param textElement The text element
     * @returns {Group} The Group
     */
    function makeDraggableAsGroup(element, textElement) {
        var group = new Group([element, textElement]);

        group.onMouseDrag = function (event) {
            var x = group.position.x;
            var y = group.position.y;
            var dx = event.delta.x;
            var dy = event.delta.y;
            var newX = Math.min(Math.max(x + dx, 40), 460);
            var newY = Math.min(Math.max(y + dy, 40), 460);
            group.position.x = newX;
            group.position.y = newY;
        };
        return group;
    }

    /**
     * Init for rectangles
     */
    function initRectangles() {
        var rectLeft = new Path.Rectangle({
            x: 20,
            y: 10,
            width: 80,
            height: 80,
            fillColor: 'lightgray',
            strokeColor: "#000"
        });

        var rectRight = new Path.Rectangle({
            x: 400,
            y: 10,
            center: view.center,
            width: 80,
            height: 80,
            fillColor: 'lightgray',
            strokeColor: "#000",
            dashArray: [5]
        });

        //----------------------------------------------
        // TEXT SETUP
        //----------------------------------------------
        var rectLeftText = makeText(rectLeft, "Rect");
        var rectRightText = makeText(rectRight, "Rect");

        //----------------------------------------------
        // ADD TO GROUP
        //----------------------------------------------
        var rectLeftGroup = makeDraggableAsGroup(rectLeft, rectLeftText);
        var rectRightGroup = makeDraggableAsGroup(rectRight, rectRightText);
    }

    /**
     * Init for circles
     */
    function initCircles() {
        var circleLeft = new Path.Circle({
            x: 60,
            y: 440,
            radius: 40,
            fillColor: "#FFF",
            strokeColor: "#000"
        });

        var circleRight = new Path.Circle({
            //[440, 440], 40
            x: 440,
            y: 440,
            radius: 40,
            fillColor: "#FFF",
            strokeColor: "#000"
        });

        //----------------------------------------------
        // TEXT SETUP
        //----------------------------------------------
        var circleRightText = makeText(circleRight, "Circle");
        var circleLeftText = makeText(circleLeft, "Circle");

        //----------------------------------------------
        // ADD TO GROUP
        //----------------------------------------------
        var circleLeftGroup = makeDraggableAsGroup(circleLeft, circleLeftText);
        var circleRightGroup = makeDraggableAsGroup(circleRight, circleRightText);
    }

    /**
     * Main Method
     */
    function main() {
        paper.setup("paperjsCanvas");
        initRectangles();
        initCircles();
    }

    main();

})();
<commit_msg>Added lines<commit_after>(function () {
    paper.install(window);

    /**
     * Convenience Method  that makes a text for an element
     * @param element The element to set the text
     * @param text The string text
     * @returns {PointText} The configured point text element
     */
    function makeText(element, text) {
        var center = element.getBounds().center;
        var pointText = new PointText({
            point: center,
            content: text,
            fillColor: "black",
            fontSize: 20
        });
        pointText.getBounds().center = center;

        return pointText;
    }

    /**
     * Convenience Method that makes a group with a element and text element draggable
     * @param element The rectangle or circle
     * @param textElement The text element
     * @returns {Group} The Group
     */
    function makeDraggableAsGroup(element, textElement) {
        var group = new Group([element, textElement]);

        group.onMouseDrag = function (event) {
            var x = group.position.x;
            var y = group.position.y;
            var dx = event.delta.x;
            var dy = event.delta.y;
            var newX = Math.min(Math.max(x + dx, 40), 460);
            var newY = Math.min(Math.max(y + dy, 40), 460);
            group.position.x = newX;
            group.position.y = newY;
        };
        return group;
    }

    function makeLine(groupLeft, groupRight, dashArray) {
        var line = new Path.Line({
            from: groupLeft.getBounds().rightCenter,
            to: groupRight.getBounds().leftCenter,
            strokeColor: "#000",
            dashArray: dashArray || []
        });

    }

    /**
     * Init for rectangles
     */
    function initRectangles() {
        var rectLeft = new Path.Rectangle({
            x: 20,
            y: 10,
            width: 80,
            height: 80,
            fillColor: 'lightgray',
            strokeColor: "#000"
        });

        var rectRight = new Path.Rectangle({
            x: 400,
            y: 10,
            center: view.center,
            width: 80,
            height: 80,
            fillColor: 'lightgray',
            strokeColor: "#000",
            dashArray: [5]
        });

        //----------------------------------------------
        // TEXT SETUP
        //----------------------------------------------
        var rectLeftText = makeText(rectLeft, "Rect");
        var rectRightText = makeText(rectRight, "Rect");

        //----------------------------------------------
        // ADD TO GROUP
        //----------------------------------------------
        var rectLeftGroup = makeDraggableAsGroup(rectLeft, rectLeftText);
        var rectRightGroup = makeDraggableAsGroup(rectRight, rectRightText);

        //----------------------------------------------
        // ADD LINES
        //----------------------------------------------
        makeLine(rectLeftGroup, rectRightGroup);
    }

    /**
     * Init for circles
     */
    function initCircles() {
        var circleLeft = new Path.Circle({
            x: 60,
            y: 440,
            radius: 40,
            fillColor: "#FFF",
            strokeColor: "#000"
        });

        var circleRight = new Path.Circle({
            //[440, 440], 40
            x: 440,
            y: 440,
            radius: 40,
            fillColor: "#FFF",
            strokeColor: "#000"
        });

        //----------------------------------------------
        // TEXT SETUP
        //----------------------------------------------
        var circleRightText = makeText(circleRight, "Circle");
        var circleLeftText = makeText(circleLeft, "Circle");

        //----------------------------------------------
        // ADD TO GROUP
        //----------------------------------------------
        var circleLeftGroup = makeDraggableAsGroup(circleLeft, circleLeftText);
        var circleRightGroup = makeDraggableAsGroup(circleRight, circleRightText);

        //----------------------------------------------
        // ADD LINES
        //----------------------------------------------
        makeLine(circleLeftGroup, circleRightGroup, [5]);
    }

    /**
     * Main Method
     */
    function main() {
        paper.setup("paperjsCanvas");
        initRectangles();
        initCircles();
    }

    main();

})();
<|endoftext|>


<commit_before>(function () {
    "use strict";

    describe("Tests for ratings controller: ", function () {
        var controller, scope, root, data, httpBackend, SERVER_URL, windows;

        beforeEach(function () {
            module("mflAppConfig");
            module("mfl.rating");
            module("mfl.facilities.wrapper");
            module("mfl.rating.services");

            inject(["$rootScope", "$controller", "$httpBackend", "SERVER_URL",
                "facilitiesApi", "$window", "mfl.rating.services.rating",
                function ($rootScope, $controller, $httpBackend, url,
                    facilitiesApi, $window, ratingService) {
                    root = $rootScope;
                    scope = root.$new();
                    httpBackend = $httpBackend;
                    SERVER_URL = url;
                    windows = $window;
                    facilitiesApi = facilitiesApi;
                    ratingService = ratingService;
                    scope.fakeStateParams = {
                        fac_id : 1
                    };
                    data = {
                        $scope :scope,
                        facilitiesApi : facilitiesApi,
                        ratingService : ratingService,
                        SERVER_URL : url,
                        $stateParams : scope.fakeStateParams
                    };
                    controller = function (cntrl) {
                        return $controller(cntrl, data);
                    };
                }
            ]);
        });
        it("should test rating controller scope variable", function () {
            controller("mfl.rating.controllers.rating");
            var test = "Rating";
            expect(test).toEqual(scope.test);
        });
        it("should test if ratings are added to facilities services",
        inject(["$httpBackend", "mfl.rating.services.rating",
            function ($httpBackend, ratingService) {
                spyOn(ratingService, "getRating").andReturn(3);
                controller("mfl.rating.controllers.rating");
                var rating = 3;
                var id = 1;
                var service_obj = {
                    id: 1
                };
                scope.fac_rating = {
                    facility_service : id,
                    rating : rating
                };
                var data = {
                    facility_services: [
                        {
                            name: "owaga"
                        },
                        {
                            name: "knh"
                        },
                        {
                            name: "hostel"
                        }
                    ]
                };
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                var rate = [
                    {
                        current : 3,
                        max: 5
                    }
                ];
                $httpBackend.flush();
                expect(
                    scope.oneFacility.facility_services[0].ratings).toEqual(rate);

                scope.getSelectedRating(rating, id, service_obj);
                $httpBackend.expectPOST(
                    SERVER_URL +
                    "api/facilities/facility_service_ratings/").
                    respond(200, scope.fac_rating);
                //get one facility and redisplay all of its details
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                $httpBackend.flush();
                expect(service_obj.spinner).toBeFalsy();
            }
        ]));
        it("should test if no ratings in localstorage ",
            inject(["$httpBackend", "mfl.rating.services.rating",
            function ($httpBackend, ratingService) {
                spyOn(ratingService, "getRating").andReturn(null);
                controller("mfl.rating.controllers.rating");
                /*var rating = 3;
                var id = 1;
                scope.fac_rating = {
                    facility_service : id,
                    rating : rating
                };*/
                var data = {
                    facility_services: [
                        {
                            name: "owaga"
                        },
                        {
                            name: "knh"
                        },
                        {
                            name: "hostel"
                        }
                    ]
                };
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                var rate = [
                    {
                        current : 0,
                        max: 5
                    }
                ];
                $httpBackend.flush();
                expect(
                    scope.oneFacility.facility_services[0].ratings).toEqual(rate);
            }])
        );
        it("should fail on call to rate a facility service",
        inject(["$httpBackend", function ($httpBackend) {
            controller("mfl.rating.controllers.rating");
            $httpBackend.expectGET(
                SERVER_URL +
                "api/facilities/facilities/1/").respond(400, {name : ""});
            var rating = 3;
            var id = 1;
            var service_obj = {
                id: 1
            };
            scope.getSelectedRating(rating, id, service_obj);
            $httpBackend.expectPOST(
                    SERVER_URL +
                    "api/facilities/facility_service_ratings/").
                    respond(400, {name : ""});
            $httpBackend.flush();
            expect(service_obj.spinner).toBeFalsy();
        }]));
        it("should print facilities' detailed view",
        inject(["$window", function ($window) {
            spyOn($window, "print");
            controller("mfl.rating.controllers.rating");
            scope.printing();
            expect($window.print).toHaveBeenCalled();
        }]));
    });
})();
<commit_msg>Fixing tests<commit_after>(function () {
    "use strict";

    describe("Tests for ratings controller: ", function () {
        var controller, scope, root, data, httpBackend, SERVER_URL, windows;

        beforeEach(function () {
            module("mflAppConfig");
            module("mfl.rating");
            module("mfl.facilities.wrapper");
            module("mfl.rating.services");

            inject(["$rootScope", "$controller", "$httpBackend", "SERVER_URL",
                "facilitiesApi", "$window", "mfl.rating.services.rating",
                function ($rootScope, $controller, $httpBackend, url,
                    facilitiesApi, $window, ratingService) {
                    root = $rootScope;
                    scope = root.$new();
                    httpBackend = $httpBackend;
                    SERVER_URL = url;
                    windows = $window;
                    facilitiesApi = facilitiesApi;
                    ratingService = ratingService;
                    scope.fakeStateParams = {
                        fac_id : 1
                    };
                    data = {
                        $scope :scope,
                        facilitiesApi : facilitiesApi,
                        ratingService : ratingService,
                        SERVER_URL : url,
                        $stateParams : scope.fakeStateParams
                    };
                    controller = function (cntrl) {
                        return $controller(cntrl, data);
                    };
                }
            ]);
        });
        it("should test rating controller scope variable", function () {
            controller("mfl.rating.controllers.rating");
            var test = true;
            expect(test).toEqual(scope.spinneractive);
        });
        it("should test if ratings are added to facilities services",
        inject(["$httpBackend", "mfl.rating.services.rating",
            function ($httpBackend, ratingService) {
                spyOn(ratingService, "getRating").andReturn(3);
                controller("mfl.rating.controllers.rating");
                var rating = 3;
                var id = 1;
                var service_obj = {
                    id: 1
                };
                scope.fac_rating = {
                    facility_service : id,
                    rating : rating
                };
                var data = {
                    facility_services: [
                        {
                            name: "owaga"
                        },
                        {
                            name: "knh"
                        },
                        {
                            name: "hostel"
                        }
                    ]
                };
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                var rate = [
                    {
                        current : 3,
                        max: 5
                    }
                ];
                $httpBackend.flush();
                expect(
                    scope.oneFacility.facility_services[0].ratings).toEqual(rate);

                scope.getSelectedRating(rating, id, service_obj);
                $httpBackend.expectPOST(
                    SERVER_URL +
                    "api/facilities/facility_service_ratings/").
                    respond(200, scope.fac_rating);
                //get one facility and redisplay all of its details
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                $httpBackend.flush();
                expect(service_obj.spinner).toBeFalsy();
            }
        ]));
        it("should test if no ratings in localstorage ",
            inject(["$httpBackend", "mfl.rating.services.rating",
            function ($httpBackend, ratingService) {
                spyOn(ratingService, "getRating").andReturn(null);
                controller("mfl.rating.controllers.rating");
                /*var rating = 3;
                var id = 1;
                scope.fac_rating = {
                    facility_service : id,
                    rating : rating
                };*/
                var data = {
                    facility_services: [
                        {
                            name: "owaga"
                        },
                        {
                            name: "knh"
                        },
                        {
                            name: "hostel"
                        }
                    ]
                };
                $httpBackend.expectGET(SERVER_URL +
                    "api/facilities/facilities/1/").respond(200, data);
                var rate = [
                    {
                        current : 0,
                        max: 5
                    }
                ];
                $httpBackend.flush();
                expect(
                    scope.oneFacility.facility_services[0].ratings).toEqual(rate);
            }])
        );
        it("should fail on call to rate a facility service",
        inject(["$httpBackend", function ($httpBackend) {
            controller("mfl.rating.controllers.rating");
            $httpBackend.expectGET(
                SERVER_URL +
                "api/facilities/facilities/1/").respond(400, {name : ""});
            var rating = 3;
            var id = 1;
            var service_obj = {
                id: 1
            };
            scope.getSelectedRating(rating, id, service_obj);
            $httpBackend.expectPOST(
                    SERVER_URL +
                    "api/facilities/facility_service_ratings/").
                    respond(400, {name : ""});
            $httpBackend.flush();
            expect(service_obj.spinner).toBeFalsy();
        }]));
        it("should print facilities' detailed view",
        inject(["$window", function ($window) {
            spyOn($window, "print");
            controller("mfl.rating.controllers.rating");
            scope.printing();
            expect($window.print).toHaveBeenCalled();
        }]));
    });
})();
<|endoftext|>


<commit_before>import React from 'react';

import remark from 'remark';
import reactRenderer from 'remark-react';

import Editor from './editor';

const renderer = remark().use(reactRenderer);

export default class MarkdownCell extends React.Component {
  static propTypes = {
    cell: React.PropTypes.any,
    id: React.PropTypes.string,
  };

  static contextTypes = {
    dispatch: React.PropTypes.func,
  };

  constructor(props) {
    super(props);
    this.state = {
      view: true,
      // HACK: We'll need to handle props and state change better here
      source: this.props.cell.get('source'),
    };
    this.openEditor = this.openEditor.bind(this);
    this.keyDown = this.keyDown.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      source: nextProps.cell.get('source'),
    });
  }

  keyDown(e) {
    if (!e.shiftKey || e.key !== 'Enter') {
      return;
    }
    this.setState({ view: true });
  }

  openEditor() {
    this.setState({ view: false });
  }

  render() {
    return (
        (this.state && this.state.view) ?

            {renderer.process(
              this.state.source ?
                this.state.source :
                '*Empty markdown cell, double click me to add content.*')
            }

 :

            <Editor
              language="markdown"
              id={this.props.id}
              input={this.state.source}
            />

    );
  }
}
<commit_msg>clean up naming<commit_after>import React from 'react';

import remark from 'remark';
import reactRenderer from 'remark-react';

import Editor from './editor';

const markdownRenderer = remark().use(reactRenderer);

export default class MarkdownCell extends React.Component {
  static propTypes = {
    cell: React.PropTypes.any,
    id: React.PropTypes.string,
  };

  static contextTypes = {
    dispatch: React.PropTypes.func,
  };

  constructor(props) {
    super(props);
    this.state = {
      view: true,
      // HACK: We'll need to handle props and state change better here
      source: this.props.cell.get('source'),
    };
    this.openEditor = this.openEditor.bind(this);
    this.keyDown = this.keyDown.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      source: nextProps.cell.get('source'),
    });
  }

  keyDown(e) {
    if (!e.shiftKey || e.key !== 'Enter') {
      return;
    }
    this.setState({ view: true });
  }

  openEditor() {
    this.setState({ view: false });
  }

  render() {
    return (
        (this.state && this.state.view) ?

            {markdownRenderer.process(
              this.state.source ?
                this.state.source :
                '*Empty markdown cell, double click me to add content.*')
            }

 :

            <Editor
              language="markdown"
              id={this.props.id}
              input={this.state.source}
            />

    );
  }
}
<|endoftext|>


<commit_before>export const jsLibs = [
	{
		url: 'https://code.jquery.com/jquery-3.2.1.min.js',
		label: 'jQuery',
		type: 'js'
	},
	{
		url: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
		label: 'Bootstrap 3',
		type: 'js'
	},
	{
		url:
			'https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js',
		label: 'Bootstrap 4',
		type: 'js'
	},
	{
		url:
			'https://cdn.jsdelivr.net/npm/foundation-sites@6.5.0-rc.3/dist/js/foundation.min.js',
		label: 'Foundation',
		type: 'js'
	},
	{
		url: 'https://semantic-ui.com/dist/semantic.min.js',
		label: 'Semantic UI',
		type: 'js'
	},
	{
		url: 'https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js',
		label: 'Angular',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/umd/react.production.min.js',
		label: 'React',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.2.0/umd/react-dom.production.min.js',
		label: 'React DOM',
		type: 'js'
	},
	{
		url: 'https://unpkg.com/vue/dist/vue.min.js',
		label: 'Vue.js',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/89/three.min.js',
		label: 'Three.js',
		type: 'js'
	},
	{
		url: 'https://d3js.org/d3.v5.min.js',
		label: 'D3',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js',
		label: 'Underscore',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js',
		label: 'Greensock TweenMax',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/js/uikit.min.js',
		label: 'UIkit 2',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.16/js/uikit.min.js',
		label: 'UIkit 3',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.min.js',
		label: 'p5.js',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.min.js',
		label: 'p5.js DOM',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.sound.min.js',
		label: 'p5.js Sound',
		type: 'js'
	}
];
export const cssLibs = [
	{
		url:
			'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
		label: 'Bootstrap 3',
		type: 'css'
	},
	{
		url:
			'https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css',
		label: 'Bootstrap 4',
		type: 'css'
	},
	{
		url:
			'https://cdn.jsdelivr.net/npm/foundation-sites@6.5.0-rc.3/dist/css/foundation.min.css',
		label: 'Foundation',
		type: 'css'
	},
	{
		url: 'https://semantic-ui.com/dist/semantic.min.css',
		label: 'Semantic UI',
		type: 'css'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css',
		label: 'Bulma',
		type: 'css'
	},

	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.5.0/hint.min.css',
		label: 'Hint.css',
		type: 'css'
	},
	{
		url: 'https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css',
		label: 'Tailwind.css',
		type: 'css'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/css/uikit.min.css',
		label: 'UIkit 2',
		type: 'css'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.16/css/uikit.min.css',
		label: 'UIkit 3',
		type: 'css'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css',
		label: 'Animate.css',
		type: 'css'
	},
	{
		url:
			'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
		label: 'FontAwesome 4',
		type: 'css'
	},
	{
		url: 'https://use.fontawesome.com/releases/v5.3.1/css/all.css',
		label: 'FontAwesome 5',
		type: 'css'
	}
];
<commit_msg>Update libraryList.js<commit_after>export const jsLibs = [
	{
		url: 'https://code.jquery.com/jquery-3.2.1.min.js',
		label: 'jQuery',
		type: 'js'
	},
	{
		url: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
		label: 'Bootstrap 3',
		type: 'js'
	},
	{
		url:
			'https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js',
		label: 'Bootstrap 4',
		type: 'js'
	},
	{
		url:
			'https://cdn.jsdelivr.net/npm/foundation-sites@6.5.0-rc.3/dist/js/foundation.min.js',
		label: 'Foundation',
		type: 'js'
	},
	{
		url: 'https://semantic-ui.com/dist/semantic.min.js',
		label: 'Semantic UI',
		type: 'js'
	},
	{
		url: 'https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js',
		label: 'Angular',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/umd/react.production.min.js',
		label: 'React',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.2.0/umd/react-dom.production.min.js',
		label: 'React DOM',
		type: 'js'
	},
	{
		url: 'https://unpkg.com/vue/dist/vue.min.js',
		label: 'Vue.js',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/89/three.min.js',
		label: 'Three.js',
		type: 'js'
	},
	{
		url: 'https://d3js.org/d3.v5.min.js',
		label: 'D3',
		type: 'js'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js',
		label: 'Underscore',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js',
		label: 'Greensock TweenMax',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/js/uikit.min.js',
		label: 'UIkit 2',
		type: 'js'
	},
	{
		url:
			'https://getuikit.com/assets/uikit/dist/js/uikit.js',
		label: 'UIkit 3',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.min.js',
		label: 'p5.js',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.min.js',
		label: 'p5.js DOM',
		type: 'js'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.sound.min.js',
		label: 'p5.js Sound',
		type: 'js'
	}
];
export const cssLibs = [
	{
		url:
			'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
		label: 'Bootstrap 3',
		type: 'css'
	},
	{
		url:
			'https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css',
		label: 'Bootstrap 4',
		type: 'css'
	},
	{
		url:
			'https://cdn.jsdelivr.net/npm/foundation-sites@6.5.0-rc.3/dist/css/foundation.min.css',
		label: 'Foundation',
		type: 'css'
	},
	{
		url: 'https://semantic-ui.com/dist/semantic.min.css',
		label: 'Semantic UI',
		type: 'css'
	},
	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css',
		label: 'Bulma',
		type: 'css'
	},

	{
		url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.5.0/hint.min.css',
		label: 'Hint.css',
		type: 'css'
	},
	{
		url: 'https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css',
		label: 'Tailwind.css',
		type: 'css'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/css/uikit.min.css',
		label: 'UIkit 2',
		type: 'css'
	},
	{
		url:
			'https://getuikit.com/assets/uikit/dist/css/uikit.css',
		label: 'UIkit 3',
		type: 'css'
	},
	{
		url:
			'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css',
		label: 'Animate.css',
		type: 'css'
	},
	{
		url:
			'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
		label: 'FontAwesome 4',
		type: 'css'
	},
	{
		url: 'https://use.fontawesome.com/releases/v5.3.1/css/all.css',
		label: 'FontAwesome 5',
		type: 'css'
	}
];
<|endoftext|>


<commit_before>var sys = require('sys');
var static = require('../lib/node-static');

//
// Create a node-static server to serve the current directory
//
var file = new(static.Server)('.', { cache: 7200, headers: {'X-Hello':'World!'} });

require('http').createServer(function (request, response) {
    request.addListener('end', function () {
        //
        // Serve files!
        //
        file.serve(request, response, function (err, res) {
            if (err) { // An error as occured
                sys.error("> Error serving " + request.url + " - " + err.message);
                response.writeHead(err.status, err.headers);
                response.end();
            } else { // The file was served successfully
                sys.puts("> " + request.url + " - " + res.message);
            }
        });
    });
}).listen(8080);

sys.puts("> node-static is listening on http://127.0.0.1:8080");
<commit_msg>Replacing sys.puts / error to console.log / error.<commit_after>var static = require('../lib/node-static');

//
// Create a node-static server to serve the current directory
//
var file = new(static.Server)('.', { cache: 7200, headers: {'X-Hello':'World!'} });

require('http').createServer(function (request, response) {
    request.addListener('end', function () {
        //
        // Serve files!
        //
        file.serve(request, response, function (err, res) {
            if (err) { // An error as occured
                console.error("> Error serving " + request.url + " - " + err.message);
                response.writeHead(err.status, err.headers);
                response.end();
            } else { // The file was served successfully
                console.log("> " + request.url + " - " + res.message);
            }
        });
    });
}).listen(8080);

console.log("> node-static is listening on http://127.0.0.1:8080");
<|endoftext|>


<commit_before>'use strict';

var validFunction      = require('es5-ext/function/valid-function')
  , assign             = require('es5-ext/object/assign')
  , eq                 = require('es5-ext/object/eq')
  , setPrototypeOf     = require('es5-ext/object/set-prototype-of')
  , d                  = require('d/d')
  , lazy               = require('d/lazy')
  , ee                 = require('event-emitter')
  , memoize            = require('memoizee/lib/regular')
  , validMap           = require('es6-map/valid-map')
  , toArray            = require('es6-iterator/to-array')
  , isObservableSymbol = require('observable-value/symbol-is-observable')

  , defineProperty = Object.defineProperty;

module.exports = memoize(function (Constructor) {
	var Observable, clear, del, set;

	validFunction(Constructor);
	validMap(Constructor.prototype);

	Observable = function (/* iterable, comparator */) {
		if (!(this instanceof Observable)) {
			return new Observable(arguments[0], arguments[1]);
		}
		Constructor.apply(this, arguments);
	};
	if (setPrototypeOf) setPrototypeOf(Observable, Constructor);

	clear = Constructor.prototype.clear;
	del = Constructor.prototype.delete;
	set = Constructor.prototype.set;

	Observable.prototype = ee(Object.create(Constructor.prototype, assign({
		constructor: d(Observable),
		clear: d(function () {
			if (!this.size) return;
			clear.call(this);
			if (this.__hold__) this.__set__ = this.__deleted__ = null;
			this.emit('change', { type: 'clear' });
		}),
		$clear: d(clear),
		delete: d(function (key) {
			var has = this.has(key), value;
			if (has) value = this.get(key);
			else return false;
			del.call(this, key);
			if (this.__hold__) {
				if (this.__set__ && this.__set__.has(key)) {
					this.__set__.delete(key);
				} else {
					if (!this.__deleted__) this.__deleted__ = new Constructor();
					this.__deleted__.set(key, value);
				}
				return true;
			}
			this.emit('change', { type: 'delete', key: key, value: value });
			return true;
		}),
		$delete: d(del),
		set: d(function (key, value) {
			var oldValue, has, event;
			if (this.has(key)) {
				has = true;
				oldValue = this.get(key);
				if (eq(oldValue, value)) return this;
			}
			set.call(this, key, value);
			if (this.__hold__) {
				if (has) {
					if (this.__set__ && this.__set__.has(key)) this.__set__.delete(key);
				}
				if (this.__deleted__ && this.__deleted__.has(key) &&
						eq(this.__deleted__.get(key), value)) {
					this.__deleted__.delete(key);
				} else {
					if (!this.__set__) this.__set__ = new Constructor();
					this.__set__.set(key, value);
					if (has) {
						if (!this.__deleted__) this.__deleted__ = new Constructor();
						this.__deleted__.set(key, oldValue);
					}
				}
				return this;
			}
			event = { type: 'set', key: key, value: value };
			if (has) event.oldValue = oldValue;
			this.emit('change', event);
			return this;
		}),
		$set: d(set),
		_hold_: d.gs(function () { return this.__hold__; }, function (hold) {
			var event, set, deleted, key, value;
			this.__hold__ = value;
			if (value) return;
			set = this.__set__;
			deleted = this.__deleted__;
			if (set && set.size) {
				if (deleted && deleted.size) {
					if ((set.size === 1) && (deleted.size === 1) &&
							eq(key = toArray(set.keys())[0], toArray(deleted.keys())[0])) {
						event = { type: 'set', key: key, value: set.get(key),
							oldValue: deleted.get(key) };
					} else {
						event = { type: 'batch', set: set, deleted: deleted };
					}
				} else if (set.size === 1) {
					set.forEach(function (v, k) {
						key = k;
						value = v;
					});
					event = { type: 'set', key: key, value: value };
				} else {
					event = { type: 'batch', set: set };
				}
			} else if (deleted && deleted.size) {
				if (deleted.size === 1) {
					deleted.forEach(function (v, k) {
						key = k;
						value = v;
					});
					event = { type: 'delete', key: key, value: value };
				} else {
					event = { type: 'batch', deleted: deleted };
				}
			}
			this.__set__ = this.__deleted__ = null;
			if (!event) return;
			this.emit('change', event);
		})
	}, lazy({
		__hold__: d('w', 0),
		__set__: d('w', null),
		__deleted__: d('w', null)
	}))));
	defineProperty(Observable.prototype, isObservableSymbol, d('', true));

	return Observable;
});
<commit_msg>No need for array coercion<commit_after>'use strict';

var validFunction      = require('es5-ext/function/valid-function')
  , assign             = require('es5-ext/object/assign')
  , eq                 = require('es5-ext/object/eq')
  , setPrototypeOf     = require('es5-ext/object/set-prototype-of')
  , d                  = require('d/d')
  , lazy               = require('d/lazy')
  , ee                 = require('event-emitter')
  , memoize            = require('memoizee/lib/regular')
  , validMap           = require('es6-map/valid-map')
  , isObservableSymbol = require('observable-value/symbol-is-observable')

  , defineProperty = Object.defineProperty;

module.exports = memoize(function (Constructor) {
	var Observable, clear, del, set;

	validFunction(Constructor);
	validMap(Constructor.prototype);

	Observable = function (/* iterable, comparator */) {
		if (!(this instanceof Observable)) {
			return new Observable(arguments[0], arguments[1]);
		}
		Constructor.apply(this, arguments);
	};
	if (setPrototypeOf) setPrototypeOf(Observable, Constructor);

	clear = Constructor.prototype.clear;
	del = Constructor.prototype.delete;
	set = Constructor.prototype.set;

	Observable.prototype = ee(Object.create(Constructor.prototype, assign({
		constructor: d(Observable),
		clear: d(function () {
			if (!this.size) return;
			clear.call(this);
			if (this.__hold__) this.__set__ = this.__deleted__ = null;
			this.emit('change', { type: 'clear' });
		}),
		$clear: d(clear),
		delete: d(function (key) {
			var has = this.has(key), value;
			if (has) value = this.get(key);
			else return false;
			del.call(this, key);
			if (this.__hold__) {
				if (this.__set__ && this.__set__.has(key)) {
					this.__set__.delete(key);
				} else {
					if (!this.__deleted__) this.__deleted__ = new Constructor();
					this.__deleted__.set(key, value);
				}
				return true;
			}
			this.emit('change', { type: 'delete', key: key, value: value });
			return true;
		}),
		$delete: d(del),
		set: d(function (key, value) {
			var oldValue, has, event;
			if (this.has(key)) {
				has = true;
				oldValue = this.get(key);
				if (eq(oldValue, value)) return this;
			}
			set.call(this, key, value);
			if (this.__hold__) {
				if (has) {
					if (this.__set__ && this.__set__.has(key)) this.__set__.delete(key);
				}
				if (this.__deleted__ && this.__deleted__.has(key) &&
						eq(this.__deleted__.get(key), value)) {
					this.__deleted__.delete(key);
				} else {
					if (!this.__set__) this.__set__ = new Constructor();
					this.__set__.set(key, value);
					if (has) {
						if (!this.__deleted__) this.__deleted__ = new Constructor();
						this.__deleted__.set(key, oldValue);
					}
				}
				return this;
			}
			event = { type: 'set', key: key, value: value };
			if (has) event.oldValue = oldValue;
			this.emit('change', event);
			return this;
		}),
		$set: d(set),
		_hold_: d.gs(function () { return this.__hold__; }, function (hold) {
			var event, set, deleted, key, value;
			this.__hold__ = value;
			if (value) return;
			set = this.__set__;
			deleted = this.__deleted__;
			if (set && set.size) {
				if (deleted && deleted.size) {
					if ((set.size === 1) && (deleted.size === 1) &&
							eq(key = set.keys().next().value, deleted.keys().next().value)) {
						event = { type: 'set', key: key, value: set.get(key),
							oldValue: deleted.get(key) };
					} else {
						event = { type: 'batch', set: set, deleted: deleted };
					}
				} else if (set.size === 1) {
					set.forEach(function (v, k) {
						key = k;
						value = v;
					});
					event = { type: 'set', key: key, value: value };
				} else {
					event = { type: 'batch', set: set };
				}
			} else if (deleted && deleted.size) {
				if (deleted.size === 1) {
					deleted.forEach(function (v, k) {
						key = k;
						value = v;
					});
					event = { type: 'delete', key: key, value: value };
				} else {
					event = { type: 'batch', deleted: deleted };
				}
			}
			this.__set__ = this.__deleted__ = null;
			if (!event) return;
			this.emit('change', event);
		})
	}, lazy({
		__hold__: d('w', 0),
		__set__: d('w', null),
		__deleted__: d('w', null)
	}))));
	defineProperty(Observable.prototype, isObservableSymbol, d('', true));

	return Observable;
});
<|endoftext|>


<commit_before>
var windowCreater = {

    makeNewWindow: function(srcurl) {
        var frameType = this.getFrameType(srcurl);

        if (frameType != "") {
            var frameSrc = this.convertToFrameSrc(srcurl, frameType);
            this.createFrameWindow_(frameSrc);
        } else {
            this.createURLWindow_(srcurl);
        }

    },

    getFrameType: function(url) {
        for (var anItem in this.frameSrcPattern_) {
            var currentPattern = this.frameSrcPattern_[anItem];
            if (url.indexOf(currentPattern) != -1) {
                return anItem;
            }
        };

        return "";
    },

    convertToFrameSrc: function(url, frameType) {
        var frameSrc = "";

        if (frameType == "youtube") {
            var videoId = url.substr(url.indexOf("?v=")+3, 11);
            frameSrc = "http://www.youtube.com/embed/{video_id}?feature=player_detailpage";
            frameSrc = frameSrc.replace("{video_id}", videoId);
        } else if (frameType == "youku") {
            var videoId = url.substr(url.indexOf("id_")+3, 13);
            frameSrc = "http://player.youku.com/embed/{video_id}";
            frameSrc = frameSrc.replace("{video_id}", videoId);
        } else if (frameType == "flash") {
            frameSrc = url;
        }

        return frameSrc;
    },

    frameSrcPattern_: {"youtube": "www.youtube.com/watch?v=",
                        "youku": "v.youku.com/v_show/id_",
                        "flash": ".swf"},

    createFrameWindow_: function(src) {
        var createData = {
            url: "panel.html",
            type: "panel",
        };

        chrome.runtime.onMessage.addListener(
            function(request, sender, sendResponse) {

                if (request.get_frame_src == true) {
                    console.log("get request for get_frame_src, src=" + src);
                    sendResponse({frame_src: src});
                }
        });

        console.log("get_frame_src listener set");

        chrome.windows.create(createData, this.onFrameWindowCreated_);
    },

    onFrameWindowCreated_: function(window) {
        var isPanelEnabled = window.alwaysOnTop;
        if (isPanelEnabled) {
            $("#panel_enable_guide").css("display", "none");
        } else {
            $("#panel_enable_guide").css("display", "block");
        };
    },

    createURLWindow_: function(aurl) {
        var createData = {
            url: aurl,
            type: "panel",
        };

        console.log("New url is " + aurl);

        chrome.windows.create(createData, this.onURLWindowCreated_);
    },

    onURLWindowCreated_: function(window) {
        var isPanelEnabled = window.alwaysOnTop;
        if (isPanelEnabled) {
            $("#panel_enable_guide").css("display", "none");
        } else {
            $("#panel_enable_guide").css("display", "block");
        };
    },

};

document.addEventListener('DOMContentLoaded', function () {

    chrome.tabs.getSelected(null, function (tab) {
        $('input[name="src_URL"]').val(tab.url);

        // Create the window immediately or wait for the button event
        var srcurl = $('input[name="src_URL"]').val();
        if (srcurl.indexOf("chrome://newtab") == -1) {
            windowCreater.makeNewWindow(srcurl);
        } else {
            $('input[name="src_URL"]').val("http://")
        }

    });

    $("#new_panel_btn").click(function() {
        var srcurl = $('input[name="src_URL"]').val();

        if (srcurl.indexOf("chrome://newtab") == -1) {
            windowCreater.makeNewWindow(srcurl);
        };

        return false;
    });

});
<commit_msg>added panel flag tracking event, added link to open chrom://flags/ tab<commit_after>
var windowCreater = {

    makeNewWindow: function(srcurl) {
        var frameType = this.getFrameType(srcurl);

        if (frameType != "") {
            var frameSrc = this.convertToFrameSrc(srcurl, frameType);
            this.createFrameWindow_(frameSrc);
        } else {
            this.createURLWindow_(srcurl);
        }

    },

    getFrameType: function(url) {
        for (var anItem in this.frameSrcPattern_) {
            var currentPattern = this.frameSrcPattern_[anItem];
            if (url.indexOf(currentPattern) != -1) {
                return anItem;
            }
        };

        return "";
    },

    convertToFrameSrc: function(url, frameType) {
        var frameSrc = "";

        if (frameType == "youtube") {
            var videoId = url.substr(url.indexOf("?v=")+3, 11);
            frameSrc = "http://www.youtube.com/embed/{video_id}?feature=player_detailpage";
            frameSrc = frameSrc.replace("{video_id}", videoId);
        } else if (frameType == "youku") {
            var videoId = url.substr(url.indexOf("id_")+3, 13);
            frameSrc = "http://player.youku.com/embed/{video_id}";
            frameSrc = frameSrc.replace("{video_id}", videoId);
        } else if (frameType == "flash") {
            frameSrc = url;
        }

        return frameSrc;
    },

    frameSrcPattern_: {"youtube": "www.youtube.com/watch?v=",
                        "youku": "v.youku.com/v_show/id_",
                        "flash": ".swf"},

    createFrameWindow_: function(src) {
        var createData = {
            url: "panel.html",
            type: "panel",
        };

        chrome.runtime.onMessage.addListener(
            function(request, sender, sendResponse) {

                if (request.get_frame_src == true) {
                    console.log("get request for get_frame_src, src=" + src);
                    sendResponse({frame_src: src});
                }
        });

        console.log("get_frame_src listener set");

        chrome.windows.create(createData, this.onWindowCreated_);
    },

    createURLWindow_: function(aurl) {
        var createData = {
            url: aurl,
            type: "panel",
        };

        console.log("New url is " + aurl);

        chrome.windows.create(createData, this.onWindowCreated_);
    },

    onWindowCreated_: function(window) {
        var isPanelEnabled = window.alwaysOnTop;
        if (isPanelEnabled) {
            $("#panel_enable_guide").css("display", "none");
            _gaq.push(['_trackEvent', 'PanelFlag', 'Enabled']);
        } else {
            $("#panel_enable_guide").css("display", "block");
            _gaq.push(['_trackEvent', 'PanelFlag', 'Disabled']);
        };
    },

};

document.addEventListener('DOMContentLoaded', function () {

    chrome.tabs.getSelected(null, function (tab) {
        $('input[name="src_URL"]').val(tab.url);

        // Create the window immediately or wait for the button event
        var srcurl = $('input[name="src_URL"]').val();
        if (srcurl.indexOf("chrome://newtab") == -1) {
            windowCreater.makeNewWindow(srcurl);
        } else {
            $('input[name="src_URL"]').val("http://")
        }

    });

    $("#new_panel_btn").click(function() {
        var srcurl = $('input[name="src_URL"]').val();

        if (srcurl.indexOf("chrome://newtab") == -1) {
            windowCreater.makeNewWindow(srcurl);
        };

        return false;
    });

    $("#flags_tab_link").click(function() {
        chrome.tabs.create({url: "chrome://flags/"}, null);
    });

});
<|endoftext|>


<commit_before>function matchVote(vote) {
    return palindrome(vote.getServiceName());
}

// This is a very rough way to check if a word is a palindrome.
function palindrome(word) {
    var cleaned = word.toLowerCase().replace(/[^a-z0-9]/g, "");
    return cleaned.split("").reverse().join("") == cleaned;
}<commit_msg>Remove this, it's on the wiki now.<commit_after><|endoftext|>


<commit_before>import React from 'react';
import {arrayOf, shape, string} from 'prop-types';
import InternalLink from '../links/internal';

export default function ArchiveListItem({meeting}) {
  const meetingDetails = meeting.node.frontmatter;

  return (
    <>

<InternalLink to={meeting.node.fields.slug}>{meetingDetails.date}</InternalLink>

        {meetingDetails.talks.map(talk =>
{talk.talk.frontmatter.title}
)}

    </>
  );
}

ArchiveListItem.propTypes = {
  meeting: shape({
    node: shape({
      frontmatter: shape({
        date: string.isRequired,
        talks: arrayOf(shape({
          talk: shape({
            frontmatter: shape({
              title: string.isRequired
            }).isRequired
          }).isRequired
        })).isRequired
      }).isRequired,
      fields: shape({slug: string.isRequired}).isRequired
    }).isRequired
  }).isRequired
};
<commit_msg>fix(archive-list): removed the numbers from the list styling<commit_after>import React from 'react';
import {arrayOf, shape, string} from 'prop-types';
import InternalLink from '../links/internal';

export default function ArchiveListItem({meeting}) {
  const meetingDetails = meeting.node.frontmatter;

  return (
    <>

<InternalLink to={meeting.node.fields.slug}>{meetingDetails.date}</InternalLink>

        {meetingDetails.talks.map(talk =>
{talk.talk.frontmatter.title}
)}

    </>
  );
}

ArchiveListItem.propTypes = {
  meeting: shape({
    node: shape({
      frontmatter: shape({
        date: string.isRequired,
        talks: arrayOf(shape({
          talk: shape({
            frontmatter: shape({
              title: string.isRequired
            }).isRequired
          }).isRequired
        })).isRequired
      }).isRequired,
      fields: shape({slug: string.isRequired}).isRequired
    }).isRequired
  }).isRequired
};
<|endoftext|>


<commit_before>var style = {
    fillColor: '#000',
    fillOpacity: 0.1,
    strokeWidth: 0
}

var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
var vector = new OpenLayers.Layer.Vector('vector');
map.addLayers([layer, vector]);

map.setCenter(
    new OpenLayers.LonLat(-71.147, 42.472).transform(
        new OpenLayers.Projection("EPSG:4326"),
        map.getProjectionObject()
    ), 12
);

var pulsate = function(feature) {
    var point = feature.geometry.getCentroid(),
        bounds = feature.geometry.getBounds(),
        radius = Math.abs((bounds.right - bounds.left)/2),
        count = 0,
        grow = 'up';

    var resize = function(){
        if (count>16) clearInterval(window.resizeInterval);
        var interval = radius * 0.03;
        var ratio = interval/radius;
        switch(count) {
            case 4:
            case 12:
                grow = 'down'; break;
            case 8:
                grow = 'up'; break;
        }
        if (grow!=='up') {
            ratio = - Math.abs(ratio);
        }
        feature.geometry.resize(1+ratio, point);
        vector.drawFeature(feature);
        count++;
    }
    window.resizeInterval = window.setInterval(resize, 50, point, radius);
};

var geolocate = new OpenLayers.Control.Geolocate({
    geolocationOptions: {
        enableHighAccuracy: false,
        maximumAge: 0,
        timeout: 7000
    }
});
map.addControl(geolocate);
geolocate.events.register("locationupdated",this,function(e) {
    vector.removeAllFeatures();
    var circle = new OpenLayers.Feature.Vector(
        OpenLayers.Geometry.Polygon.createRegularPolygon(
            new OpenLayers.Geometry.Point(e.point.x, e.point.y),
            e.position.coords.accuracy/2,
            40,
            0
        ),
        {},
        style
    );
    vector.addFeatures([
        new OpenLayers.Feature.Vector(
            e.point,
            {},
            {
                graphicName: 'cross',
                strokeColor: '#f00',
                strokeWidth: 2,
                fillOpacity: 0,
                pointRadius: 10
            }
        ),
        circle
    ]);
    map.zoomToExtent(vector.getDataExtent());
    pulsate(circle);
});
geolocate.events.register("locationfailed",this,function() {
    OpenLayers.Console.log('Location detection failed');
});

$('locate').onclick = function() {
    vector.removeAllFeatures();
    geolocate.deactivate();
    $('track').checked = false;
    geolocate.watch = false;
    geolocate.activate();
};
$('track').onclick = function() {
    vector.removeAllFeatures();
    geolocate.deactivate();
    if (this.checked) {
        geolocate.watch = true;
        geolocate.activate();
    }
};
$('track').checked = false;
<commit_msg>Geolocation Examples: JSLINT + IE Fixes, p=cmoullet, r=me (closes #3150)<commit_after>var style = {
    fillColor: '#000',
    fillOpacity: 0.1,
    strokeWidth: 0
};

var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
var vector = new OpenLayers.Layer.Vector('vector');
map.addLayers([layer, vector]);

map.setCenter(
    new OpenLayers.LonLat(-71.147, 42.472).transform(
        new OpenLayers.Projection("EPSG:4326"),
        map.getProjectionObject()
    ), 12
);

var pulsate = function(feature) {
    var point = feature.geometry.getCentroid(),
        bounds = feature.geometry.getBounds(),
        radius = Math.abs((bounds.right - bounds.left)/2),
        count = 0,
        grow = 'up';

    var resize = function(){
        if (count>16) {
            clearInterval(window.resizeInterval);
        }
        var interval = radius * 0.03;
        var ratio = interval/radius;
        switch(count) {
            case 4:
            case 12:
                grow = 'down'; break;
            case 8:
                grow = 'up'; break;
        }
        if (grow!=='up') {
            ratio = - Math.abs(ratio);
        }
        feature.geometry.resize(1+ratio, point);
        vector.drawFeature(feature);
        count++;
    };
    window.resizeInterval = window.setInterval(resize, 50, point, radius);
};

var geolocate = new OpenLayers.Control.Geolocate({
    geolocationOptions: {
        enableHighAccuracy: false,
        maximumAge: 0,
        timeout: 7000
    }
});
map.addControl(geolocate);
geolocate.events.register("locationupdated",this,function(e) {
    vector.removeAllFeatures();
    var circle = new OpenLayers.Feature.Vector(
        OpenLayers.Geometry.Polygon.createRegularPolygon(
            new OpenLayers.Geometry.Point(e.point.x, e.point.y),
            e.position.coords.accuracy/2,
            40,
            0
        ),
        {},
        style
    );
    vector.addFeatures([
        new OpenLayers.Feature.Vector(
            e.point,
            {},
            {
                graphicName: 'cross',
                strokeColor: '#f00',
                strokeWidth: 2,
                fillOpacity: 0,
                pointRadius: 10
            }
        ),
        circle
    ]);
    map.zoomToExtent(vector.getDataExtent());
    pulsate(circle);
});
geolocate.events.register("locationfailed",this,function() {
    OpenLayers.Console.log('Location detection failed');
});

$('locate').onclick = function() {
    vector.removeAllFeatures();
    geolocate.deactivate();
    $('track').checked = false;
    geolocate.watch = false;
    geolocate.activate();
};
$('track').onclick = function() {
    vector.removeAllFeatures();
    geolocate.deactivate();
    if (this.checked) {
        geolocate.watch = true;
        geolocate.activate();
    }
};
$('track').checked = false;
<|endoftext|>


<commit_before>'use strict';

const path = require('path');
const fs = require('fs-extra');
const execa = require('execa');
const run = require('./run');
const utils = require('./utils');
const isDefaultBlueprint = require('./is-default-blueprint');
const emberInstallAddon = require('./ember-install-addon');
const overwriteBlueprintFiles = require('./overwrite-blueprint-files');

const nodeModulesIgnore = `

/node_modules/
`;

module.exports = function getStartAndEndCommands({
  packageJson: { name: projectName },
  baseBlueprint,
  startBlueprint,
  endBlueprint
}) {
  let isCustomBlueprint = !isDefaultBlueprint(endBlueprint);

  let startRange;
  let endRange;
  if (isCustomBlueprint) {
    startRange = endRange = '';
  } else {
    startRange = startBlueprint && startBlueprint.version;
    endRange = endBlueprint.version;
  }

  return {
    projectName,
    packageName: 'ember-cli',
    commandName: 'ember',
    createProjectFromCache,
    createProjectFromRemote,
    startOptions: {
      baseBlueprint,
      blueprint: startBlueprint,

      // for cache detection logic
      packageRange: startRange
    },
    endOptions: {
      baseBlueprint,
      blueprint: endBlueprint,

      // for cache detection logic
      packageRange: endRange
    }
  };
};

function isDefaultAddonBlueprint(blueprint) {
  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let isDefaultAddonBlueprint;

  if (isCustomBlueprint) {
    let { keywords } = utils.require(path.join(blueprint.path, 'package'));

    isDefaultAddonBlueprint = !(keywords && keywords.includes('ember-blueprint'));
  }

  return isDefaultAddonBlueprint;
}

function getArgs(projectName, blueprint) {
  let args = [];

  if (blueprint.isBaseBlueprint) {
    args.push('new');
    args.push(projectName);
    args.push('-sg');
  } else {
    args.push('init');
  }

  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let _blueprint;
  if (isCustomBlueprint) {
    _blueprint = blueprint.path;
  } else {
    // Can we use the above path all the time, even if it is default?
    _blueprint = blueprint.name;
  }

  return [
    ...args,
    '-sn',
    '-sb',
    '-b',
    _blueprint,
    ...blueprint.options
  ];
}

module.exports.spawn = async function spawn(command, args, options) {
  let ps = execa(command, args, {
    stdio: ['pipe', 'pipe', 'inherit'],
    ...options
  });

  overwriteBlueprintFiles(ps);

  await ps;
};

async function runEmberLocally({
  packageRoot,
  cwd,
  projectName,
  blueprint
}) {
  let args = getArgs(projectName, blueprint);

  if (!blueprint.isBaseBlueprint) {
    cwd = path.join(cwd, projectName);
  }

  await module.exports.spawn('node', [
    path.join(packageRoot, 'bin/ember'),
    ...args
  ], { cwd });
}

function createProjectFromCache({
  packageRoot,
  options
}) {
  return async function createProject(cwd) {
    if (!options.blueprint || !options.blueprint.isBaseBlueprint) {
      await runEmberLocally({
        packageRoot,
        cwd,
        projectName: options.projectName,
        blueprint: options.baseBlueprint
      });
    }

    if (options.blueprint) {
      await runEmberLocally({
        packageRoot,
        cwd,
        projectName: options.projectName,
        blueprint: options.blueprint
      });
    }

    return await postCreateProject({
      cwd,
      options
    });
  };
}

module.exports.npx = async function npx(args, options) {
  let ps = utils.npx(args.join(' '), options);

  overwriteBlueprintFiles(ps);

  await ps;
};

async function runEmberRemotely({
  cwd,
  projectName,
  blueprint
}) {
  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let args = getArgs(projectName, blueprint);

  if (!blueprint.isBaseBlueprint) {
    cwd = path.join(cwd, projectName);
  }

  if (isCustomBlueprint) {
    args = ['ember-cli', ...args];
    // args = ['-p', 'github:ember-cli/ember-cli#cfb9780', 'ember', 'new', projectName, '-sn', '-sg', '-b', `${blueprint.packageName}@${blueprint.version}`];
  } else {
    args = ['-p', `ember-cli@${blueprint.version}`, 'ember', ...args];
  }

  await module.exports.npx(args, { cwd });
}

function createProjectFromRemote({
  options
}) {
  return async function createProject(cwd) {
    if (!options.blueprint || !options.blueprint.isBaseBlueprint) {
      await runEmberRemotely({
        cwd,
        projectName: options.projectName,
        blueprint: options.baseBlueprint
      });
    }

    if (options.blueprint) {
      await runEmberRemotely({
        cwd,
        projectName: options.projectName,
        blueprint: options.blueprint
      });
    }

    return await postCreateProject({
      cwd,
      options
    });
  };
}

async function postCreateProject({
  cwd,
  options: {
    projectName,
    blueprint
  }
}) {
  if (blueprint && isDefaultAddonBlueprint(blueprint)) {
    await module.exports.installAddonBlueprint({
      cwd,
      projectName,
      blueprint
    });
  }

  if (!(blueprint && isDefaultBlueprint(blueprint))) {
    // This might not be needed anymore.
    await module.exports.appendNodeModulesIgnore({
      cwd,
      projectName
    });
  }

  return path.join(cwd, projectName);
}

module.exports.installAddonBlueprint = async function installAddonBlueprint({
  cwd,
  projectName,
  blueprint
}) {
  let projectRoot = path.join(cwd, projectName);

  // `not found: ember` without this
  await run('npm install', { cwd: projectRoot });

  let { ps } = await emberInstallAddon({
    cwd: projectRoot,
    addonName: blueprint.path,
    blueprintPackageName: blueprint.packageName,
    stdin: 'pipe'
  });

  overwriteBlueprintFiles(ps);

  await ps;

  let packageJson = await fs.readJson(path.join(projectRoot, 'package.json'));
  packageJson.devDependencies[blueprint.packageName] = blueprint.version;
  await fs.writeJson(path.join(projectRoot, 'package.json'), packageJson);

  await fs.remove(path.join(projectRoot, 'package-lock.json'));
};

async function appendNodeModulesIgnore({
  cwd,
  projectName
}) {
  if (!await fs.pathExists(path.join(cwd, projectName, 'node_modules'))) {
    return;
  }

  let isIgnoringNodeModules;
  let gitignore = '';
  try {
    gitignore = await fs.readFile(path.join(cwd, projectName, '.gitignore'), 'utf8');

    isIgnoringNodeModules = /^\/?node_modules\/?$/m.test(gitignore);
  } catch (err) {}
  if (!isIgnoringNodeModules) {
    await fs.writeFile(path.join(cwd, projectName, '.gitignore'), `${gitignore}${nodeModulesIgnore}`);
  }
}

module.exports.appendNodeModulesIgnore = appendNodeModulesIgnore;
module.exports.getArgs = getArgs;
<commit_msg>add spawn logging<commit_after>'use strict';

const path = require('path');
const fs = require('fs-extra');
const execa = require('execa');
const run = require('./run');
const utils = require('./utils');
const isDefaultBlueprint = require('./is-default-blueprint');
const emberInstallAddon = require('./ember-install-addon');
const overwriteBlueprintFiles = require('./overwrite-blueprint-files');
const debug = require('debug')('ember-cli-update');

const nodeModulesIgnore = `

/node_modules/
`;

module.exports = function getStartAndEndCommands({
  packageJson: { name: projectName },
  baseBlueprint,
  startBlueprint,
  endBlueprint
}) {
  let isCustomBlueprint = !isDefaultBlueprint(endBlueprint);

  let startRange;
  let endRange;
  if (isCustomBlueprint) {
    startRange = endRange = '';
  } else {
    startRange = startBlueprint && startBlueprint.version;
    endRange = endBlueprint.version;
  }

  return {
    projectName,
    packageName: 'ember-cli',
    commandName: 'ember',
    createProjectFromCache,
    createProjectFromRemote,
    startOptions: {
      baseBlueprint,
      blueprint: startBlueprint,

      // for cache detection logic
      packageRange: startRange
    },
    endOptions: {
      baseBlueprint,
      blueprint: endBlueprint,

      // for cache detection logic
      packageRange: endRange
    }
  };
};

function isDefaultAddonBlueprint(blueprint) {
  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let isDefaultAddonBlueprint;

  if (isCustomBlueprint) {
    let { keywords } = utils.require(path.join(blueprint.path, 'package'));

    isDefaultAddonBlueprint = !(keywords && keywords.includes('ember-blueprint'));
  }

  return isDefaultAddonBlueprint;
}

function getArgs(projectName, blueprint) {
  let args = [];

  if (blueprint.isBaseBlueprint) {
    args.push('new');
    args.push(projectName);
    args.push('-sg');
  } else {
    args.push('init');
  }

  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let _blueprint;
  if (isCustomBlueprint) {
    _blueprint = blueprint.path;
  } else {
    // Can we use the above path all the time, even if it is default?
    _blueprint = blueprint.name;
  }

  return [
    ...args,
    '-sn',
    '-sb',
    '-b',
    _blueprint,
    ...blueprint.options
  ];
}

module.exports.spawn = async function spawn(command, args, options) {
  debug(`${command} ${args.join(' ')}`);

  let ps = execa(command, args, {
    stdio: ['pipe', 'pipe', 'inherit'],
    ...options
  });

  overwriteBlueprintFiles(ps);

  await ps;
};

async function runEmberLocally({
  packageRoot,
  cwd,
  projectName,
  blueprint
}) {
  let args = getArgs(projectName, blueprint);

  if (!blueprint.isBaseBlueprint) {
    cwd = path.join(cwd, projectName);
  }

  await module.exports.spawn('node', [
    path.join(packageRoot, 'bin/ember'),
    ...args
  ], { cwd });
}

function createProjectFromCache({
  packageRoot,
  options
}) {
  return async function createProject(cwd) {
    if (!options.blueprint || !options.blueprint.isBaseBlueprint) {
      await runEmberLocally({
        packageRoot,
        cwd,
        projectName: options.projectName,
        blueprint: options.baseBlueprint
      });
    }

    if (options.blueprint) {
      await runEmberLocally({
        packageRoot,
        cwd,
        projectName: options.projectName,
        blueprint: options.blueprint
      });
    }

    return await postCreateProject({
      cwd,
      options
    });
  };
}

module.exports.npx = async function npx(args, options) {
  let ps = utils.npx(args.join(' '), options);

  overwriteBlueprintFiles(ps);

  await ps;
};

async function runEmberRemotely({
  cwd,
  projectName,
  blueprint
}) {
  let isCustomBlueprint = !isDefaultBlueprint(blueprint);

  let args = getArgs(projectName, blueprint);

  if (!blueprint.isBaseBlueprint) {
    cwd = path.join(cwd, projectName);
  }

  if (isCustomBlueprint) {
    args = ['ember-cli', ...args];
    // args = ['-p', 'github:ember-cli/ember-cli#cfb9780', 'ember', 'new', projectName, '-sn', '-sg', '-b', `${blueprint.packageName}@${blueprint.version}`];
  } else {
    args = ['-p', `ember-cli@${blueprint.version}`, 'ember', ...args];
  }

  await module.exports.npx(args, { cwd });
}

function createProjectFromRemote({
  options
}) {
  return async function createProject(cwd) {
    if (!options.blueprint || !options.blueprint.isBaseBlueprint) {
      await runEmberRemotely({
        cwd,
        projectName: options.projectName,
        blueprint: options.baseBlueprint
      });
    }

    if (options.blueprint) {
      await runEmberRemotely({
        cwd,
        projectName: options.projectName,
        blueprint: options.blueprint
      });
    }

    return await postCreateProject({
      cwd,
      options
    });
  };
}

async function postCreateProject({
  cwd,
  options: {
    projectName,
    blueprint
  }
}) {
  if (blueprint && isDefaultAddonBlueprint(blueprint)) {
    await module.exports.installAddonBlueprint({
      cwd,
      projectName,
      blueprint
    });
  }

  if (!(blueprint && isDefaultBlueprint(blueprint))) {
    // This might not be needed anymore.
    await module.exports.appendNodeModulesIgnore({
      cwd,
      projectName
    });
  }

  return path.join(cwd, projectName);
}

module.exports.installAddonBlueprint = async function installAddonBlueprint({
  cwd,
  projectName,
  blueprint
}) {
  let projectRoot = path.join(cwd, projectName);

  // `not found: ember` without this
  await run('npm install', { cwd: projectRoot });

  let { ps } = await emberInstallAddon({
    cwd: projectRoot,
    addonName: blueprint.path,
    blueprintPackageName: blueprint.packageName,
    stdin: 'pipe'
  });

  overwriteBlueprintFiles(ps);

  await ps;

  let packageJson = await fs.readJson(path.join(projectRoot, 'package.json'));
  packageJson.devDependencies[blueprint.packageName] = blueprint.version;
  await fs.writeJson(path.join(projectRoot, 'package.json'), packageJson);

  await fs.remove(path.join(projectRoot, 'package-lock.json'));
};

async function appendNodeModulesIgnore({
  cwd,
  projectName
}) {
  if (!await fs.pathExists(path.join(cwd, projectName, 'node_modules'))) {
    return;
  }

  let isIgnoringNodeModules;
  let gitignore = '';
  try {
    gitignore = await fs.readFile(path.join(cwd, projectName, '.gitignore'), 'utf8');

    isIgnoringNodeModules = /^\/?node_modules\/?$/m.test(gitignore);
  } catch (err) {}
  if (!isIgnoringNodeModules) {
    await fs.writeFile(path.join(cwd, projectName, '.gitignore'), `${gitignore}${nodeModulesIgnore}`);
  }
}

module.exports.appendNodeModulesIgnore = appendNodeModulesIgnore;
module.exports.getArgs = getArgs;
<|endoftext|>


<commit_before>goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.dom.Input');
goog.require('ol.layer.LayerGroup');
goog.require('ol.layer.TileLayer');
goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.TileJSON');

var map = new ol.Map({
  layers: [
    new ol.layer.TileLayer({
      source: new ol.source.MapQuestOpenAerial()
    }), new ol.layer.LayerGroup({
      layers: [
        new ol.layer.TileLayer({
          source: new ol.source.TileJSON({
            url: 'http://api.tiles.mapbox.com/v3/' +
                'mapbox.20110804-hoa-foodinsecurity-3month.jsonp',
            crossOrigin: 'anonymous'
          })
        }),
        new ol.layer.TileLayer({
          source: new ol.source.TileJSON({
            url: 'http://api.tiles.mapbox.com/v3/' +
                'mapbox.world-borders-light.jsonp',
            crossOrigin: 'anonymous'
          })
        })
      ]
    })
  ],
  renderers: ol.RendererHints.createFromQueryData(),
  target: 'map',
  view: new ol.View2D({
    center: ol.proj.transform([37.40570, 8.81566], 'EPSG:4326', 'EPSG:3857'),
    zoom: 4
  })
});

function bindInputs(layerid, layer) {
  new ol.dom.Input($(layerid + ' .visible')[0])
      .bindTo('checked', layer, 'visible');
  $.each(['opacity', 'hue', 'saturation', 'contrast', 'brightness'],
      function(i, v) {
        new ol.dom.Input($(layerid + ' .' + v)[0]).bindTo('value', layer, v);
      }
  );
}
map.getLayers().forEach(function(layer, i) {
  bindInputs('#layer' + i, layer);
  if (layer instanceof ol.layer.LayerGroup) {
    layer.getLayers().forEach(function(sublayer, j) {
      bindInputs('#layer' + i + j, sublayer);
    });
  }
});

$('#layertree li > span').click(function() {
  $(this).siblings('fieldset').toggle();
}).siblings('fieldset').hide();
<commit_msg>Bindto valueAsNumber in layer-group example<commit_after>goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.dom.Input');
goog.require('ol.layer.LayerGroup');
goog.require('ol.layer.TileLayer');
goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.TileJSON');

var map = new ol.Map({
  layers: [
    new ol.layer.TileLayer({
      source: new ol.source.MapQuestOpenAerial()
    }), new ol.layer.LayerGroup({
      layers: [
        new ol.layer.TileLayer({
          source: new ol.source.TileJSON({
            url: 'http://api.tiles.mapbox.com/v3/' +
                'mapbox.20110804-hoa-foodinsecurity-3month.jsonp',
            crossOrigin: 'anonymous'
          })
        }),
        new ol.layer.TileLayer({
          source: new ol.source.TileJSON({
            url: 'http://api.tiles.mapbox.com/v3/' +
                'mapbox.world-borders-light.jsonp',
            crossOrigin: 'anonymous'
          })
        })
      ]
    })
  ],
  renderers: ol.RendererHints.createFromQueryData(),
  target: 'map',
  view: new ol.View2D({
    center: ol.proj.transform([37.40570, 8.81566], 'EPSG:4326', 'EPSG:3857'),
    zoom: 4
  })
});

function bindInputs(layerid, layer) {
  new ol.dom.Input($(layerid + ' .visible')[0])
      .bindTo('checked', layer, 'visible');
  $.each(['opacity', 'hue', 'saturation', 'contrast', 'brightness'],
      function(i, v) {
        new ol.dom.Input($(layerid + ' .' + v)[0])
            .bindTo('valueAsNumber', layer, v);
      }
  );
}
map.getLayers().forEach(function(layer, i) {
  bindInputs('#layer' + i, layer);
  if (layer instanceof ol.layer.LayerGroup) {
    layer.getLayers().forEach(function(sublayer, j) {
      bindInputs('#layer' + i + j, sublayer);
    });
  }
});

$('#layertree li > span').click(function() {
  $(this).siblings('fieldset').toggle();
}).siblings('fieldset').hide();
<|endoftext|>


<commit_before>(function (root, factory) {
    // Using the Universal Module Definition pattern from
    // https://github.com/umdjs/umd/blob/master/returnExports.js
    if (typeof define === 'function' && define.amd) {
        define(['iscroll'], factory);
    } else if (typeof exports === 'object') {
        module.exports = factory(require('iscroll'));
    } else {
        // Browser globals (root is window)
        root.angularIscroll = factory(root.IScroll);
    }
}(this, function (IScroll) {
    'use strict';

    var signals = {
        disabled: 'iscroll:disabled',
        enabled: 'iscroll:enabled',
        refresh: 'iscroll:refresh'
    };

    var classes = {
        on: 'iscroll-on',
        off: 'iscroll-off'
    };

    function iScrollServiceProvider() {
        var defaultOptions = {
            iScroll: {
                /**
                 * The different options for iScroll are explained in
                 * detail at http://iscrolljs.com/#configuring
                 **/
                momentum: true,
                mouseWheel: true
            },
            directive: {
                /**
                 * Delay, in ms, before we asynchronously perform an
                 * iScroll.refresh().  If false, then no async refresh is
                 * performed.
                 **/
                asyncRefreshDelay: 0,
                /**
                 * Delay, in ms, between each iScroll.refresh().  If false,
                 * then no periodic refresh is performed.
                 **/
                refreshInterval: false
            }
        };

        function _configureDefaults(options) {
            angular.extend(defaultOptions, options);
        }

        this.configureDefaults = _configureDefaults;
        function _getDefaults() {
            return defaultOptions;
        }

        this.getDefaults = _getDefaults;

        /* @ngInject */
        function iScrollService($rootScope, $log, iScrollSignals) {
            var _state = {
                useIScroll: true
            };

            function _disable(signalOnly) {
                if (!signalOnly) {
                    _state.useIScroll = false;
                }
                //$log.debug('emit(iScrollSignals.disabled)', iScrollSignals.disabled);
                $rootScope.$emit(iScrollSignals.disabled);
            }

            function _enable(signalOnly) {
                if (!signalOnly) {
                    _state.useIScroll = true;
                }
                //$log.debug('emit(iScrollSignals.enabled)', iScrollSignals.enabled);
                $rootScope.$emit(iScrollSignals.enabled);
            }

            function _toggle(signalOnly) {
                (_state.useIScroll ^ signalOnly) ?  // XOR
                    _disable(signalOnly) : _enable(signalOnly);
            }

            function _refresh(name) {
                // The name parameter is not really used for now.
                $rootScope.$emit(iScrollSignals.refresh, name);
            }

            return {
                defaults: defaultOptions,
                state: _state,
                enable: _enable,
                disable: _disable,
                toggle: _toggle,
                refresh: _refresh
            };
        }

        this.$get = iScrollService;
    }

    function _call(functor) {
        functor();
    }

    /* @ngInject */
    function iscroll($rootScope, $timeout, $interval, $log, iScrollSignals,
                     iScrollService) {
        function asyncRefresh(instance, options) {
            $timeout(function _refreshAfterInitialRender() {
                instance.refresh();
            }, options.directive.asyncRefreshDelay);
        }

        function _createInstance(scope, element, attrs, options) {
            var instance = new IScroll(element[0], options.iScroll),
                refreshEnabled = true,
                refreshInterval = null;

            element.removeClass(classes.off).addClass(classes.on);

            if (angular.isDefined(attrs.iscrollInstance)) {
                scope.iscrollInstance = instance;
            }

            if (options.directive.asyncRefreshDelay !== false) {
                asyncRefresh(instance, options);
            }

            function _destroyInstance() {
                if (refreshInterval !== null) {
                    $interval.cancel(refreshInterval);
                }

                if (angular.isDefined(scope.iscrollInstance)) {
                    delete scope.iscrollInstance;
                }
                instance.destroy();

                element.removeClass(classes.on).addClass(classes.off);
                // Remove element's CSS transition values:
                element.children('.iscroll-scroller').attr('style', null);

                angular.forEach(deregistrators, _call);
                //$log.debug('angular-iscroll: destroyInstance');
            }

            function _refreshInstance() {
                if (refreshEnabled) {
                    refreshEnabled = false;
                    asyncRefresh(instance, options);
                    refreshEnabled = true;
                }
            }

            function _disableRefresh() {
                refreshEnabled = false;
            }

            function _enableRefresh() {
                refreshEnabled = true;
            }

            instance.on('scrollStart', _disableRefresh);
            instance.on('scrollEnd', _enableRefresh);

            if (options.directive.refreshInterval !== false) {
                refreshInterval = $interval(_refreshInstance,
                    options.directive.refreshInterval);
            }

            var deregistrators = [
                $rootScope.$on(iScrollSignals.disabled, _destroyInstance),
                $rootScope.$on(iScrollSignals.refresh, _refreshInstance),
                scope.$on('$destroy', _destroyInstance)
            ];

            return instance;
        }

        function _link(scope, element, attrs) {
            var options = {
                iScroll: angular.extend({}, scope.iscroll || {},
                    iScrollService.defaults.iScroll),
                directive: angular.extend({}, iScrollService.defaults.directive)
            };

            angular.forEach(options.iScroll,
                function _extractOptions(value, key) {
                    if (iScrollService.defaults.directive.hasOwnProperty(key)) {
                        options.directive[key] = value;
                        delete options.iScroll[key];
                    }
                }
            );

            function _init() {
                if (!element.hasClass(classes.on)) {
                    _createInstance(scope, element, attrs, options);
                }
            }

            var enableHandlers = [$rootScope.$on(iScrollSignals.enabled, _init)];

            function _removeEnableHandlers() {
                angular.forEach(enableHandlers, _call);
            }

            if (iScrollService.state.useIScroll) {
                _init();
            } else {
                element.removeClass(classes.on).addClass(classes.off);
            }

            scope.$on('$destroy', _removeEnableHandlers);
        }

        return {
            restrict: 'A',
            link: _link,
            scope: {
                iscroll: '=',
                iscrollInstance: '='
            }
        }
    }

    return angular.module('angular-iscroll', [])
        .directive('iscroll', iscroll)
        .provider('iScrollService', iScrollServiceProvider)
        .constant('iScrollSignals', signals);
}));

<commit_msg>#10: Create simple configuration interface for defining event handlers.<commit_after>(function (root, factory) {
    // Using the Universal Module Definition pattern from
    // https://github.com/umdjs/umd/blob/master/returnExports.js
    if (typeof define === 'function' && define.amd) {
        define(['iscroll'], factory);
    } else if (typeof exports === 'object') {
        module.exports = factory(require('iscroll'));
    } else {
        // Browser globals (root is window)
        root.angularIscroll = factory(root.IScroll);
    }
}(this, function (IScroll) {
    'use strict';

    var signals = {
            disabled: 'iscroll:disabled',
            enabled: 'iscroll:enabled',
            refresh: 'iscroll:refresh'
        },
        classes = {
            on: 'iscroll-on',
            off: 'iscroll-off'
        },
        iScrollEvents = [
            'beforeScrollStart',
            'scrollCancel',
            'scrollStart',
            'scroll',
            'scrollEnd',
            'flick',
            'zoomStart',
            'zoomEnd'
        ],
        /**
         * Add handler name to event name mapping.
         *
         * Please note that the 'scroll' event is only available when using
         * iscroll-probe.js (for example, through angular-iscroll-probe).
         *
         * For example, the handler for the 'scrollEnd' event can be configured
         * by supplying the onScrollEnd option.
         **/
        iScrollEventHandlerMap =
            _.reduce(iScrollEvents, function _addPair(result, event) {
                result['on' + _capitalizeFirst(event)] = event;
            }, {});

    function _capitalizeFirst(str) {
        return str.substring(0,1).toLocaleUpperCase() + str.substring(1);
    }

    function iScrollServiceProvider() {
        var defaultOptions = {
                iScroll: {
                    /**
                     * The different options for iScroll are explained in
                     * detail at http://iscrolljs.com/#configuring
                     **/
                    momentum: true,
                    mouseWheel: true
                },
                directive: {
                    /**
                     * Delay, in ms, before we asynchronously perform an
                     * iScroll.refresh().  If false, then no async refresh is
                     * performed.
                     **/
                    asyncRefreshDelay: 0,
                    /**
                     * Delay, in ms, between each iScroll.refresh().  If false,
                     * then no periodic refresh is performed.
                     **/
                    refreshInterval: false
                    /**
                     * Event handler options are added below.
                     **/
                }
            };

        _.each(iScrollEventHandlerMap, function _provideDefault(event, handler) {
            defaultOptions.directive[handler] = undefined;
        });

        function _configureDefaults(options) {
            angular.extend(defaultOptions, options);
        }

        this.configureDefaults = _configureDefaults;
        function _getDefaults() {
            return defaultOptions;
        }

        this.getDefaults = _getDefaults;

        /* @ngInject */
        function iScrollService($rootScope, $log, iScrollSignals) {
            var _state = {
                useIScroll: true
            };

            function _disable(signalOnly) {
                if (!signalOnly) {
                    _state.useIScroll = false;
                }
                //$log.debug('emit(iScrollSignals.disabled)',
                //    iScrollSignals.disabled);
                $rootScope.$emit(iScrollSignals.disabled);
            }

            function _enable(signalOnly) {
                if (!signalOnly) {
                    _state.useIScroll = true;
                }
                //$log.debug('emit(iScrollSignals.enabled)',
                //    iScrollSignals.enabled);
                $rootScope.$emit(iScrollSignals.enabled);
            }

            function _toggle(signalOnly) {
                (_state.useIScroll ^ signalOnly) ?  // XOR
                    _disable(signalOnly) : _enable(signalOnly);
            }

            function _refresh(name) {
                // The name parameter is not really used for now.
                $rootScope.$emit(iScrollSignals.refresh, name);
            }

            return {
                defaults: defaultOptions,
                state: _state,
                enable: _enable,
                disable: _disable,
                toggle: _toggle,
                refresh: _refresh
            };
        }

        this.$get = iScrollService;
    }

    function _call(functor) {
        functor();
    }

    /* @ngInject */
    function iscroll($rootScope, $timeout, $interval, $log, iScrollSignals,
                     iScrollService) {
        function asyncRefresh(instance, options) {
            $timeout(function _refreshAfterInitialRender() {
                instance.refresh();
            }, options.directive.asyncRefreshDelay);
        }

        function _createInstance(scope, element, attrs, options) {
            var instance = new IScroll(element[0], options.iScroll),
                refreshEnabled = true,
                refreshInterval = null;

            _.each(iScrollEventHandlerMap, function _addHandler(event, option) {
                if (_.has(options.directive, option)) {
                    instance.on(event, options.directive[option]);
                }
            });

            element.removeClass(classes.off).addClass(classes.on);

            if (angular.isDefined(attrs.iscrollInstance)) {
                scope.iscrollInstance = instance;
            }

            if (options.directive.asyncRefreshDelay !== false) {
                asyncRefresh(instance, options);
            }

            function _destroyInstance() {
                if (refreshInterval !== null) {
                    $interval.cancel(refreshInterval);
                }

                if (angular.isDefined(scope.iscrollInstance)) {
                    delete scope.iscrollInstance;
                }
                instance.destroy();

                element.removeClass(classes.on).addClass(classes.off);
                // Remove element's CSS transition values:
                element.children('.iscroll-scroller').attr('style', null);

                angular.forEach(deregistrators, _call);
                //$log.debug('angular-iscroll: destroyInstance');
            }

            function _refreshInstance() {
                if (refreshEnabled) {
                    refreshEnabled = false;
                    asyncRefresh(instance, options);
                    refreshEnabled = true;
                }
            }

            function _disableRefresh() {
                refreshEnabled = false;
            }

            function _enableRefresh() {
                refreshEnabled = true;
            }

            instance.on('scrollStart', _disableRefresh);
            instance.on('scrollEnd', _enableRefresh);

            if (options.directive.refreshInterval !== false) {
                refreshInterval = $interval(_refreshInstance,
                    options.directive.refreshInterval);
            }

            var deregistrators = [
                $rootScope.$on(iScrollSignals.disabled, _destroyInstance),
                $rootScope.$on(iScrollSignals.refresh, _refreshInstance),
                scope.$on('$destroy', _destroyInstance)
            ];

            return instance;
        }

        function _link(scope, element, attrs) {
            var options = {
                iScroll: angular.extend({}, scope.iscroll || {},
                    iScrollService.defaults.iScroll),
                directive: angular.extend({}, iScrollService.defaults.directive)
            };

            angular.forEach(options.iScroll,
                function _extractOptions(value, key) {
                    if (iScrollService.defaults.directive.hasOwnProperty(key)) {
                        options.directive[key] = value;
                        delete options.iScroll[key];
                    }
                }
            );

            function _init() {
                if (!element.hasClass(classes.on)) {
                    _createInstance(scope, element, attrs, options);
                }
            }

            var enableHandlers = [$rootScope.$on(iScrollSignals.enabled, _init)];

            function _removeEnableHandlers() {
                angular.forEach(enableHandlers, _call);
            }

            if (iScrollService.state.useIScroll) {
                _init();
            } else {
                element.removeClass(classes.on).addClass(classes.off);
            }

            scope.$on('$destroy', _removeEnableHandlers);
        }

        return {
            restrict: 'A',
            link: _link,
            scope: {
                iscroll: '=',
                iscrollInstance: '='
            }
        }
    }

    return angular.module('angular-iscroll', [])
        .directive('iscroll', iscroll)
        .provider('iScrollService', iScrollServiceProvider)
        .constant('iScrollSignals', signals);
}));

<|endoftext|>


<commit_before><commit_msg>[ux] added example how to list all tickets<commit_after><|endoftext|>


<commit_before>'use strict';

var myDemoApp = angular.module('myDemoApp', ['formsAngular']);

myDemoApp.config(['formRoutesProvider', function (formRoutes) {
        formRoutes.setRoutes([
            {route:'/index', options:{templateUrl: 'partials/landing-page.html'}},
            {route:'/get-started', options:{templateUrl: 'partials/get-started.html'}},
            {route:'/forms', options:{templateUrl: 'partials/forms.html'}},
            {route:'/schemas', options:{templateUrl: 'partials/schemas.html'}},
            {route:'/reporting', options:{templateUrl: 'partials/reporting.html'}},
            {route:'/more', options:{templateUrl: 'partials/more.html'}},
            {route:'/in-the-wild', options:{templateUrl: 'partials/in-the-wild.html'}},
            {route:'/examples', options:{templateUrl: 'partials/examples.html'}},
            {route:'/api-docs', options:{templateUrl: 'partials/api-docs.html'}},
            {route:'/404', options:{templateUrl: 'partials/404.html'}},
            {route:'/z_custom_form/new', options:{templateUrl: 'partials/custom-new.html'}},            // example view override
            {route:'/z_custom_form/:id/edit', options:{templateUrl: 'partials/custom-edit.html'}},      // example view override
            {route:'/z_custom_form/:form/new', options:{templateUrl: 'partials/custom-new.html'}},      // example view override with specified form content
            {route:'/z_custom_form/:form/:id/edit', options:{templateUrl: 'partials/custom-edit.html'}} // example view override with specified form content
        ], '/index');
}]);

formsAngular.config(['urlServiceProvider',function(urlService) {
    urlService.setOptions({html5Mode: false, hashPrefix: '!'});
}]);
<commit_msg>Select css framework<commit_after>'use strict';

var myDemoApp = angular.module('myDemoApp', ['formsAngular']);

myDemoApp.config(['formRoutesProvider', function (formRoutes) {
        formRoutes.setRoutes([
            {route:'/index', options:{templateUrl: 'partials/landing-page.html'}},
            {route:'/get-started', options:{templateUrl: 'partials/get-started.html'}},
            {route:'/forms', options:{templateUrl: 'partials/forms.html'}},
            {route:'/schemas', options:{templateUrl: 'partials/schemas.html'}},
            {route:'/reporting', options:{templateUrl: 'partials/reporting.html'}},
            {route:'/more', options:{templateUrl: 'partials/more.html'}},
            {route:'/in-the-wild', options:{templateUrl: 'partials/in-the-wild.html'}},
            {route:'/examples', options:{templateUrl: 'partials/examples.html'}},
            {route:'/api-docs', options:{templateUrl: 'partials/api-docs.html'}},
            {route:'/404', options:{templateUrl: 'partials/404.html'}},
            {route:'/z_custom_form/new', options:{templateUrl: 'partials/custom-new.html'}},            // example view override
            {route:'/z_custom_form/:id/edit', options:{templateUrl: 'partials/custom-edit.html'}},      // example view override
            {route:'/z_custom_form/:form/new', options:{templateUrl: 'partials/custom-new.html'}},      // example view override with specified form content
            {route:'/z_custom_form/:form/:id/edit', options:{templateUrl: 'partials/custom-edit.html'}} // example view override with specified form content
        ], '/index');
}]);

formsAngular.config(['urlServiceProvider','cssFrameworkServiceProvider',function(urlService, cssFrameworkService) {
    urlService.setOptions({html5Mode: false, hashPrefix: '!'});
    cssFrameworkService.setOptions({framework:'bs2'});
}]);
<|endoftext|>