<commit_before>(function($) {

    /**
     * Style manager widget
     */
    $.widget('mapbender.featureStyleEditor', {
        options: {
            asPopup: true,
            data:    {
                'id':         null,
                'borderSize': 1
            }
        },

        /**
         * Generate StyleManagerForm
         */
        _create: function() {
            var widget = this;
            var element = $(widget.element);
            var options = widget.options;

            element.generateElements({
                type:     "tabs",
                children: [{
                    title:    "Allgemein",
                    type:     "form",
                    children: [{
                        type:      'input',
                        name:      'name',
                        title:     'Name',
                        infoText:  'Die Name erscheint in der Auswahlliste.',
                        mandatory: true
                    }]
                }, {
                    title:    "Füllung",
                    type:     "form",
                    children: [{
                        type:     'fieldSet',
                        children: [{
                            title:         "Farbe",
                            type:          "colorPicker",
                            name:          "fillColor",
                            value:         "#ff0000",
                            mandatory:     "/^#{1,1}[abcdefABCDEF0-9]{6,6}$/",
                            mandatoryText: "Bitte Farbwähler nutzen",
                            css:           {width: "50%"}

                        }, {
                            title: "Deckkraft",
                            name:  "fillOpacity",
                            type:  "slider",
                            range: "max",
                            min:   0.1,
                            max:   1,
                            value: 1,
                            step:  0.1,
                            css:   {width: "50%"}

                        }, {
                            title:   "Aktivieren",
                            type:    "checkbox",
                            checked: true,
                            name:    "fill",
                            value:   '1'
                        }]
                    }]
                }, {
                    title:    "Hintergrund",
                    type:     "form",
                    children: [{
                        type:     'fieldSet',
                        children: [{
                            title:         "Breite",
                            infoText:      "The width of the background width.  If not provided, the graphicWidth will be used.",
                            type:          "input",
                            name:          "backgroundWidth",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            css:           {width: '50%'}

                        }, {
                            title:         "Höhe",
                            infoText:      "The height of the background graphic.  If not provided, the graphicHeight will be used.",
                            type:          "input",
                            name:          "backgroundHeight",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            css:           {width: '50%'}
                        }]
                    }, {
                        type:     'fieldSet',
                        children: [{
                            title: "X-Offset", // infoText:  "The x offset (in pixels) for the background graphic.",
                            name:  "backgroundXOffset",
                            type:  "slider",
                            range: "max",
                            min:   0,
                            max:   100,
                            value: 0,
                            step:  1,
                            css:   {
                                width: '33%'
                            }
                        }, {
                            title: "Y-Offset",
                            type:  "slider",
                            name:  "backgroundYOffset",
                            range: "max",
                            min:   0,
                            max:   100,
                            value: 0,
                            step:  1,
                            css:   {
                                width: '33%'
                            }
                        }, {
                            title: "Z-Index",
                            type:  "slider",
                            name:  "backgroundGraphicZIndex", // infoText:  "The integer z-index value to use in rendering the background graphic.",
                            range: "max",
                            min:   0,
                            max:   100,
                            value: 0,
                            step:  1,
                            css:   {
                                width: '34%'
                            }
                        }]
                    }, {
                        title:       "Bild URL",
                        infoText:    "Url to a graphic to be used as the background under an externalGraphic.",
                        type:        "input",
                        name:        "backgroundGraphic",
                        value:       "",
                        placeholder: "URL"
                    }]
                }, {
                    title:    "Rand",
                    type:     "form",
                    children: [{
                        type:     'fieldSet',
                        children: [{
                            title:         "Farbe",
                            type:          "colorPicker",
                            name:          "strokeColor",
                            value:         "#ffffff",
                            horizontal:    true,
                            mandatory:     "/^\#[A-F0-9]{6}$/i",
                            mandatoryText: "Bitte Farbwähler nutzen",
                            css:           {width: "30%"}

                        }, {
                            title: "Deckkraft",
                            name:  "strokeOpacity",
                            type:  "slider",
                            range: "max",
                            min:   0.1,
                            max:   1,
                            value: 1,
                            step:  0.1,
                            css:   {width: "35%"}

                        }, {
                            title: "Breite",
                            type:  "slider",
                            name:  "strokeSize",
                            min:   0,
                            max:   10,
                            step:  0.1,
                            value: 1,
                            css:   {width: "35%"}
                        }]
                    }, {
                        type:     'fieldSet',
                        children: [{
                            title:   "Glättung",
                            name:    "strokeLineCap",
                            type:    "select",
                            options: {
                                round:  "round",
                                square: "square",
                                butt:   "butt"
                            },
                            value:   "round",
                            css:     {width: "50%"}
                        }, {
                            title:   "Style",
                            name:    "strokeDashStyle",
                            type:    "select",
                            options: {
                                Solid:           'Solid',
                                ShortDash:       'ShortDash',
                                ShortDot:        'ShortDot',
                                ShortDashDot:    'ShortDashDot',
                                ShortDashDotDot: 'ShortDashDotDot',
                                Dot:             'Dot',
                                Dash:            'Dash',
                                LongDash:        'LongDash',
                                DashDot:         'DashDot',
                                LongDashDot:     'LongDashDot',
                                LongDashDotDot:  'LongDashDotDot'
                            },
                            value:   "Solid",
                            css:     {width: "50%"}

                        }]
                    }, {
                        title:   "Aktivieren",
                        type:    "checkbox",
                        checked: true,
                        name:    "stroke",
                        value:   '1'
                    }]
                }, {
                    title:    "Bild",
                    type:     "form",
                    children: [{
                        title:    "Name",
                        type:     "input",
                        name:     "graphicName",
                        infoText: "Named graphic to use when rendering points.  Supported values include “circle” (default), “square”, “star”, “x”, “cross”, “triangle”."
                    }, {
                        type:     'fieldSet',
                        children: [{
                            title:         "Breite",
                            type:          "input",
                            name:          "graphicWidth",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            css:           {width: '50%'}
                        }, {
                            title:         "Höhe",
                            type:          "input",
                            name:          "graphicHeight",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            css:           {width: '50%'}
                        }]
                    }, {
                        type:     'fieldSet',
                        children: [{
                            title:         "X-Offset",
                            name:          "graphicXOffset",
                            type:          "slider",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            range:         "max",
                            min:           0,
                            max:           100,
                            value:         0,
                            step:          1,
                            css:           {
                                width: '33%'
                            }
                        }, {
                            title:         "Y-Offset",
                            type:          "slider",
                            name:          "graphicYOffset",
                            mandatoryText: "Bitte nur Zahlen verwenden",
                            range:         "max",
                            min:           0,
                            max:           100,
                            value:         0,
                            step:          1,
                            css:           {
                                width: '33%'
                            }
                        }, {
                            title: "Deckkraft",
                            name:  "graphicOpacity",
                            type:  "slider",
                            range: "max",
                            min:   0,
                            max:   1,
                            value: 1,
                            step:  0.01,
                            css:   {
                                width: '34%'
                            }
                        }]
                    }, {
                        title:       "URL",
                        type:        "input",
                        name:        "graphicUrl",
                        value:       "",
                        placeholder: "URL"
                    }]
                }, {

                    title:    'Beschriftung',
                    type:     'form',
                    children: [// labelAlign	{String} Label alignment.  This specifies the insertion point relative to the text.  It is a string composed of two characters.  The first character is for the horizontal alignment, the second for the vertical alignment.  Valid values for horizontal alignment: “l”=left, “c”=center, “r”=right.  Valid values for vertical alignment: “t”=top, “m”=middle, “b”=bottom.  Example values: “lt”, “cm”, “rb”.  Default is “cm”.
                        // labelXOffset	{Number} Pixel offset along the positive x axis for displacing the label.  Not supported by the canvas renderer.
                        // labelYOffset	{Number} Pixel offset along the positive y axis for displacing the label.  Not supported by the canvas renderer.
                        // labelOutlineColor	{String} The color of the label outline.  Default is ‘white’.  Only supported by the canvas & SVG renderers.
                        // labelOutlineWidth	{Number} The width of the label outline.  Default is 3, set to 0 or null to disable.  Only supported by the SVG renderers.
                        // labelOutlineOpacity	{Number} The opacity (0-1) of the label outline.  Default is fontOpacity.  Only supported by the canvas & SVG renderers.
                        {
                            type:     'textArea',
                            css:      {width: "100 %"},
                            name:     'label',
                            infoText: 'The text for an optional label.  For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available.'
                        }, {
                            type:     'fieldSet',
                            children: [{
                                title:    'Fontname',
                                type:     'select',
                                options:  {
                                    "Open Sans":    "Open Sans",
                                    "Calluna Sans": "Calluna Sans",
                                    "Gill Sans MT": "Gill Sans MT",
                                    'Calibri':      'Calibri',
                                    "Trebuchet MS": "Trebuchet MS",
                                    'sans-serif':   'sans-serif'
                                },
                                name:     'fontFamily',
                                infoText: 'The font family for the label, to be provided like in CSS.',
                                css:      {width: "50%"}

                            }, {
                                title:    'Grösse',
                                name:     'fontSize',
                                type:     'select',
                                options:  {
                                    "9":  9,
                                    "10": 10,
                                    "11": 11,
                                    "12": 12,
                                    "13": 13,
                                    "14": 14
                                },
                                css:      {width: "20%"},
                                infoText: 'The font size for the label, to be provided like in CSS'
                            }, //     {
                                //     title:    'Style',
                                //     type:     'input',
                                //     name:     'fontStyle',
                                //     infoText: 'The font style for the label, to be provided like in CSS'
                                // },

                                {
                                    title:    'Art',
                                    name:     'fontWeight',
                                    type:     'select',
                                    options:  {
                                        'regular': 'Normal',
                                        'bold':    'Fett',
                                        'italic':  'Kursive',
                                    },
                                    css:      {width: "30%"},
                                    infoText: 'The font weight for the label, to be provided like in CSS.'
                                }, {
                                    title:    'Farbe',
                                    type:     'colorPicker',
                                    name:     'fontColor',
                                    infoText: 'The font color for the label, to be provided like CSS.',
                                    css:      {width: "50%"}
                                }, {
                                    title: "Deckkraft",
                                    name:  "fontOpacity",
                                    type:  "slider",
                                    range: "max",
                                    min:   0,
                                    max:   1,
                                    value: 1,
                                    step:  0.01,
                                    css:   {
                                        width: '50%'
                                    }
                                }, {
                                    title:    "Selektierbar?",
                                    type:     "checkbox",
                                    checked:  false,
                                    name:     "labelEnabled",
                                    infoText: 'If set to true, labels will be selectable using SelectFeature or similar controls.  Default is false.',
                                    value:    '1',
                                    css:      {
                                        width: '30%'
                                    }
                                }]
                        }]

                }, {
                    title:    "Misc",
                    type:     "form",
                    children: [{
                        title:         "Punkt Radius",
                        name:          "pointRadius",
                        type:          "slider",
                        mandatory:     "/^\\d+$/",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        range:         "max",
                        min:           0,
                        max:           10,
                        value:         0
                    }, {
                        title:   "Zeiger",
                        name:    "cursor",
                        type:    "select",
                        options: {
                            auto:        'auto',
                            'default':   'default',
                            crosshair:   'crosshair',
                            pointer:     'pointer',
                            move:        'move',
                            'n-resize':  'n-resize',
                            'ne-resize': 'ne-resize',
                            'e-resize':  'e-resize',
                            'se-resize': 'se-resize',
                            's-resize':  's-resize',
                            'sw-resize': 'sw-resize',
                            'w-resize':  'w-resize',
                            'nw-resize': 'nw-resize',
                            text:        'text',
                            wait:        'wait',
                            help:        'help'
                        },
                        value:   "pointer"
                    }, {
                        title:     "Rotation (°)",
                        name:      "rotation",
                        type:      "slider",
                        mandatory: "/^\\d+$/",
                        range:     "max",
                        min:       0,
                        max:       360,
                        value:     0,
                        step:      1
                    }, {
                        title:   "Anzeige",
                        name:    "display",
                        type:    "select",
                        options: {
                            inline:         "inline",
                            "inline-block": "inline-block",
                            block:          "block",
                            none:           "none"
                        },
                        value:   "block"
                    }]
                }]
            });

            window.setTimeout(function() {
                element.formData(options.data);
            }, 1000);

            if(options.asPopup) {
                widget.popup();
            }

            return widget;
        },

        popup: function() {
            var widget = this;
            var element = $(widget.element);
            element.popupDialog({
                title:   "Stylemanager",
                modal:   true,
                width:   '500px',
                buttons: [{
                    text:  "Abbrechen",
                    click: function(e) {
                        widget.close();
                        return false;
                    }
                }, {
                    text:  "Speichern",
                    click: function(e) {
                        var form = $(e.currentTarget).closest(".ui-dialog");
                        widget._trigger('submit', null, {
                            form:   form,
                            widget: widget
                        });
                    }
                }]
            });
        },

        /**
         *
         * @private
         */
        close: function() {
            var widget = this;
            var element = $(widget.element);
            var options = widget.options;

            if(options.asPopup) {
                element.popupDialog("close");
            } else {
                widget.element.remove();
            }
        }
    });

})(jQuery);<commit_msg>Improve feature-style-editor<commit_after>(function($) {

    /**
     * Style manager widget
     */
    $.widget('mapbender.featureStyleEditor', {
        options: {
            asPopup:      true,
            data:         {
                'id':         null,
                'borderSize': 1
            },
            customColors: {
                '#777777': '#777777',
                '#337ab7': '#337ab7',
                '#5cb85c': '#5cb85c',
                '#5bc0de': '#5bc0de',
                '#f0ad4e': '#f0ad4e',
                '#d9534f': '#d9534f'
            },
            commonTab:    true
        },

        /**
         * Generate StyleManagerForm
         */
        _create: function() {
            var widget = this;
            var element = $(widget.element);
            var options = widget.options;
            var commonTab = {
                title:    "Allgemein",
                type:     "form",
                children: [{
                    type:      'input',
                    name:      'name',
                    title:     'Name',
                    infoText:  'Die Name erscheint in der Auswahlliste.',
                    mandatory: true
                }]
            };
            var customColors = options.customColors;
            var fillTab = {
                title:    "Füllung",
                type:     "form",
                children: [{
                    type:     'fieldSet',
                    children: [{
                        title:          "Farbe",
                        type:           "colorPicker",
                        name:           "fillColor",
                        value:          "#ff0000",
                        mandatory:      "/^#{1,1}[abcdefABCDEF0-9]{6,6}$/",
                        mandatoryText:  "Bitte Farbwähler nutzen",
                        colorSelectors: customColors,
                        css:            {width: "30%"}
                    }, {
                        title: "Deckkraft",
                        name:  "fillOpacity",
                        type:  "slider",
                        range: "max",
                        min:   0.1,
                        max:   1,
                        value: 1,
                        step:  0.1,
                        css:   {width: "35%"}

                    }, {
                        title:         "Punkt Radius",
                        name:          "pointRadius",
                        type:          "slider",
                        mandatory:     "/^\\d+$/",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        range:         "max",
                        min:           0,
                        max:           20,
                        value:         0,
                        css:   {width: "35%"}

                    },{
                        title:   "Aktivieren",
                        type:    "checkbox",
                        checked: true,
                        name:    "fill",
                        value:   '1'
                    }]
                }]
            };
            var backGroundTab = {
                title:    "Hintegrund",
                type:     "form",
                children: [{
                    type:     'fieldSet',
                    children: [{
                        title:         "Breite",
                        infoText:      "The width of the background width.  If not provided, the graphicWidth will be used.",
                        type:          "input",
                        name:          "backgroundWidth",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        css:           {width: '50%'}

                    }, {
                        title:         "Höhe",
                        infoText:      "The height of the background graphic.  If not provided, the graphicHeight will be used.",
                        type:          "input",
                        name:          "backgroundHeight",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        css:           {width: '50%'}
                    }]
                }, {
                    type:     'fieldSet',
                    children: [{
                        title: "X-Offset", // infoText:  "The x offset (in pixels) for the background graphic.",
                        name:  "backgroundXOffset",
                        type:  "slider",
                        range: "max",
                        min:   0,
                        max:   100,
                        value: 0,
                        step:  1,
                        css:   {
                            width: '33%'
                        }
                    }, {
                        title: "Y-Offset",
                        type:  "slider",
                        name:  "backgroundYOffset",
                        range: "max",
                        min:   0,
                        max:   100,
                        value: 0,
                        step:  1,
                        css:   {
                            width: '33%'
                        }
                    }, {
                        title: "Z-Index",
                        type:  "slider",
                        name:  "backgroundGraphicZIndex", // infoText:  "The integer z-index value to use in rendering the background graphic.",
                        range: "max",
                        min:   0,
                        max:   100,
                        value: 0,
                        step:  1,
                        css:   {
                            width: '34%'
                        }
                    }]
                }, {
                    title:       "Bild URL",
                    infoText:    "Url to a graphic to be used as the background under an externalGraphic.",
                    type:        "input",
                    name:        "backgroundGraphic",
                    value:       "",
                    placeholder: "URL"
                }]
            };
            var strokeTab = {
                title:    "Rand",
                type:     "form",
                children: [{
                    type:     'fieldSet',
                    children: [{
                        title:         "Farbe",
                        type:          "colorPicker",
                        name:          "strokeColor",
                        value:         "#ffffff",
                        horizontal:    true,
                        mandatory:     "/^\#[A-F0-9]{6}$/i",
                        mandatoryText: "Bitte Farbwähler nutzen",
                        css:           {width: "30%"}

                    }, {
                        title: "Deckkraft",
                        name:  "strokeOpacity",
                        type:  "slider",
                        range: "max",
                        min:   0.1,
                        max:   1,
                        value: 1,
                        step:  0.1,
                        css:   {width: "35%"}

                    }, {
                        title: "Breite",
                        type:  "slider",
                        name:  "strokeWidth",
                        min:   0,
                        max:   10,
                        step:  1,
                        value: 1,
                        css:   {width: "35%"}
                    }]
                }, {
                    type:     'fieldSet',
                    children: [{
                        title:   "Glättung",
                        name:    "strokeLineCap",
                        type:    "select",
                        options: {
                            round:  "round",
                            square: "square",
                            butt:   "butt"
                        },
                        value:   "round",
                        css:     {width: "50%"}
                    }, {
                        title:   "Style",
                        name:    "strokeDashStyle",
                        type:    "select",
                        options: {
                            Solid:           'Solid',
                            ShortDash:       'ShortDash',
                            ShortDot:        'ShortDot',
                            ShortDashDot:    'ShortDashDot',
                            ShortDashDotDot: 'ShortDashDotDot',
                            Dot:             'Dot',
                            Dash:            'Dash',
                            LongDash:        'LongDash',
                            DashDot:         'DashDot',
                            LongDashDot:     'LongDashDot',
                            LongDashDotDot:  'LongDashDotDot'
                        },
                        value:   "Solid",
                        css:     {width: "50%"}

                    }]
                }, {
                    title:   "Aktivieren",
                    type:    "checkbox",
                    checked: true,
                    name:    "stroke",
                    value:   '1'
                }]
            };
            var imageTab = {
                title:    "Bild",
                type:     "form",
                children: [{
                    title:    "Name",
                    type:     "input",
                    name:     "graphicName",
                    infoText: "Named graphic to use when rendering points.  Supported values include “circle” (default), “square”, “star”, “x”, “cross”, “triangle”."
                }, {
                    type:     'fieldSet',
                    children: [{
                        title:         "Breite",
                        type:          "input",
                        name:          "graphicWidth",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        css:           {width: '50%'}
                    }, {
                        title:         "Höhe",
                        type:          "input",
                        name:          "graphicHeight",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        css:           {width: '50%'}
                    }]
                }, {
                    type:     'fieldSet',
                    children: [{
                        title:         "X-Offset",
                        name:          "graphicXOffset",
                        type:          "slider",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        range:         "max",
                        min:           0,
                        max:           100,
                        value:         0,
                        step:          1,
                        css:           {
                            width: '33%'
                        }
                    }, {
                        title:         "Y-Offset",
                        type:          "slider",
                        name:          "graphicYOffset",
                        mandatoryText: "Bitte nur Zahlen verwenden",
                        range:         "max",
                        min:           0,
                        max:           100,
                        value:         0,
                        step:          1,
                        css:           {
                            width: '33%'
                        }
                    }, {
                        title: "Deckkraft",
                        name:  "graphicOpacity",
                        type:  "slider",
                        range: "max",
                        min:   0,
                        max:   1,
                        value: 1,
                        step:  0.01,
                        css:   {
                            width: '34%'
                        }
                    }]
                }, {
                    title:       "URL",
                    type:        "input",
                    name:        "graphicUrl",
                    value:       "",
                    placeholder: "URL"
                }]
            };
            var labelTab = {

                title:    'Beschriftung',
                type:     'form',
                children: [// labelAlign	{String} Label alignment.  This specifies the insertion point relative to the text.  It is a string composed of two characters.  The first character is for the horizontal alignment, the second for the vertical alignment.  Valid values for horizontal alignment: “l”=left, “c”=center, “r”=right.  Valid values for vertical alignment: “t”=top, “m”=middle, “b”=bottom.  Example values: “lt”, “cm”, “rb”.  Default is “cm”.
                    // labelXOffset	{Number} Pixel offset along the positive x axis for displacing the label.  Not supported by the canvas renderer.
                    // labelYOffset	{Number} Pixel offset along the positive y axis for displacing the label.  Not supported by the canvas renderer.
                    // labelOutlineColor	{String} The color of the label outline.  Default is ‘white’.  Only supported by the canvas & SVG renderers.
                    // labelOutlineWidth	{Number} The width of the label outline.  Default is 3, set to 0 or null to disable.  Only supported by the SVG renderers.
                    // labelOutlineOpacity	{Number} The opacity (0-1) of the label outline.  Default is fontOpacity.  Only supported by the canvas & SVG renderers.
                    {
                        type:     'textArea',
                        css:      {width: "100 %"},
                        name:     'label',
                        infoText: 'The text for an optional label.  For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available.'
                    }, {
                        type:     'fieldSet',
                        children: [{
                            title:    'Fontname',
                            type:     'select',
                            options:  {
                                "Open Sans":    "Open Sans",
                                "Calluna Sans": "Calluna Sans",
                                "Gill Sans MT": "Gill Sans MT",
                                'Calibri':      'Calibri',
                                "Trebuchet MS": "Trebuchet MS",
                                'sans-serif':   'sans-serif'
                            },
                            name:     'fontFamily',
                            infoText: 'The font family for the label, to be provided like in CSS.',
                            css:      {width: "50%"}

                        }, {
                            title:    'Grösse',
                            name:     'fontSize',
                            type:     'select',
                            options:  {
                                "9":  9,
                                "10": 10,
                                "11": 11,
                                "12": 12,
                                "13": 13,
                                "14": 14
                            },
                            css:      {width: "20%"},
                            infoText: 'The font size for the label, to be provided like in CSS'
                        }, //     {
                            //     title:    'Style',
                            //     type:     'input',
                            //     name:     'fontStyle',
                            //     infoText: 'The font style for the label, to be provided like in CSS'
                            // },

                            {
                                title:    'Art',
                                name:     'fontWeight',
                                type:     'select',
                                options:  {
                                    'regular': 'Normal',
                                    'bold':    'Fett',
                                    'italic':  'Kursive',
                                },
                                css:      {width: "30%"},
                                infoText: 'The font weight for the label, to be provided like in CSS.'
                            }, {
                                title:    'Farbe',
                                type:     'colorPicker',
                                name:     'fontColor',
                                infoText: 'The font color for the label, to be provided like CSS.',
                                css:      {width: "50%"}
                            }, {
                                title: "Deckkraft",
                                name:  "fontOpacity",
                                type:  "slider",
                                range: "max",
                                min:   0,
                                max:   1,
                                value: 1,
                                step:  0.01,
                                css:   {
                                    width: '50%'
                                }
                            }, {
                                title:    "Selektierbar?",
                                type:     "checkbox",
                                checked:  false,
                                name:     "labelEnabled",
                                infoText: 'If set to true, labels will be selectable using SelectFeature or similar controls.  Default is false.',
                                value:    '1',
                                css:      {
                                    width: '30%'
                                }
                            }]
                    }]

            };
            var miscTab = {
                title:    "Misc",
                type:     "form",
                children: [{
                    title:   "Zeiger",
                    name:    "cursor",
                    type:    "select",
                    options: {
                        auto:        'auto',
                        'default':   'default',
                        crosshair:   'crosshair',
                        pointer:     'pointer',
                        move:        'move',
                        'n-resize':  'n-resize',
                        'ne-resize': 'ne-resize',
                        'e-resize':  'e-resize',
                        'se-resize': 'se-resize',
                        's-resize':  's-resize',
                        'sw-resize': 'sw-resize',
                        'w-resize':  'w-resize',
                        'nw-resize': 'nw-resize',
                        text:        'text',
                        wait:        'wait',
                        help:        'help'
                    },
                    value:   "pointer"
                }, {
                    title:     "Rotation (°)",
                    name:      "rotation",
                    type:      "slider",
                    mandatory: "/^\\d+$/",
                    range:     "max",
                    min:       0,
                    max:       360,
                    value:     0,
                    step:      1
                }, {
                    title:   "Anzeige",
                    name:    "display",
                    type:    "select",
                    options: {
                        inline:         "inline",
                        "inline-block": "inline-block",
                        block:          "block",
                        none:           "none"
                    },
                    value:   "block"
                }]
            };

            var tabs = [];

            if(options.commonTab) {
                tabs.push(commonTab);
            }

            tabs.push(fillTab);
            tabs.push(strokeTab);
            tabs.push(labelTab);
            tabs.push(imageTab);
            tabs.push(backGroundTab);
            tabs.push(miscTab);

            element.generateElements({
                type:     "tabs",
                children: tabs
            });

            window.setTimeout(function() {
                element.formData(options.data);
            }, 100);

            if(options.asPopup) {
                widget.popup();
            }

            return widget;
        },

        popup: function() {
            var widget = this;
            var element = $(widget.element);
            element.popupDialog({
                title:   "Stylemanager",
                modal:   true,
                width:   '500px',
                buttons: [{
                    text:  "Abbrechen",
                    click: function(e) {
                        widget.close();
                        return false;
                    }
                }, {
                    text:  "Speichern",
                    click: function(e) {
                        var form = $(e.currentTarget).closest(".ui-dialog");
                        widget._trigger('submit', null, {
                            form:   form,
                            widget: widget
                        });
                    }
                }]
            });
        },

        /**
         *
         * @private
         */
        close: function() {
            var widget = this;
            var element = $(widget.element);
            var options = widget.options;

            if(options.asPopup) {
                element.popupDialog("close");
            } else {
                widget.element.remove();
            }
        }
    });

})(jQuery);<|endoftext|>


<commit_before>angular.module('calendar', ['ngAnimate', 'ngSanitize', 'ngMessageFormat', 'uirouter',
              'calendar.menu', 'calendar.home', 'calendar.services', 'mwl.calendar', 'colorpicker.module'])
.config(['$locationProvider','$stateProvider',function($locationProvider,$stateProvider){
  $stateProvider
  .state('calendar', {
    url: '/',
    template: '<calendar></calendar>',
  });
  // use the HTML5 History API
  // $locationProvider.html5Mode(true);
}]);
<commit_msg>injection error ui routeur<commit_after>angular.module('calendar', ['ngAnimate', 'ngSanitize', 'ngMessageFormat', 'ui.router',
              'calendar.menu', 'calendar.home', 'calendar.services', 'mwl.calendar', 'colorpicker.module'])
.config(['$locationProvider','$stateProvider',function($locationProvider,$stateProvider){
  $stateProvider
  .state('calendar', {
    url: '/',
    template: '<calendar></calendar>',
  });
  // use the HTML5 History API
  // $locationProvider.html5Mode(true);
}]);
<|endoftext|>


<commit_before>/**
 * Show information about a version of a feed
 * This primarily consists of validation results
 */

var Backbone = require('backbone');
Backbone.Marionette = require('backbone.marionette');
var $ = require('jquery');
var _ = require('underscore');
var Handlebars = require('handlebars');
var app = require('application');
var NoteCollectionView = require('note-collection-view');
var FeedUploadView = require('feed-upload-view');
var FeedSource = require('feed-source');
var FeedVersion = require('feed-version');

var InvalidValuesList = Backbone.Marionette.ItemView.extend({
    // rather than having a ton of levels of nested views, since we're not editing, most of the
    // recursion occurs in the template
    template: Handlebars.compile(require('./invalid-values-list.html')),

    initialize: function (attr) {
        // group them by error type
        var invalidValues = attr.invalidValues;
        var errors = {};
        var invalidValuesLen = invalidValues.length;
        for (var i = 0; i < invalidValuesLen; i++) {
            var iv = invalidValues[i];

            if (typeof(errors[iv.problemType]) == 'undefined') {
                errors[iv.problemType] = [];
                errors[iv.problemType].name = iv.problemType;
            }

            errors[iv.problemType].push(iv);
        }

        // we use a bare Backbone.Model to pass the tree to the template
        this.model = new Backbone.Model({errors: errors});
    }
});

module.exports = Backbone.Marionette.LayoutView.extend({
    template: Handlebars.compile(require('./feed-version-view.html')),

    regions: {
        routesRegion: '#routes',
        tripsRegion: '#trips',
        stopsRegion: '#stops',
        shapesRegion: '#shapes',
        notesRegion: '.version-notes'
    },

    events: {
      'click .upload-feed': 'uploadFeed',
      'click .update-feed': 'updateFeed'
      },

    initialize: function () {
      _.bindAll(this, 'uploadFeed', 'updateFeed');
    },

    // show the feed upload dialog
    uploadFeed: function (e) {
        // model is so that it knows what feed source to upload to
        app.modalRegion.show(new FeedUploadView({model: new FeedSource(this.model.get('feedSource'))}));
    },

    // fetch the latest version of an autofetched/produced in house feed
    updateFeed: function (e) {
      // user feedback
      $(e.target).find('span').addClass('spinner');

      var instance = this;
      $.ajax({
        url: 'api/feedsources/' + this.model.get('feedSource').id + '/fetch',
        method: 'POST',
        success: function (data) {
          $(e.target).find('span').removeClass('spinner');
          var newVersion = new FeedVersion(data);
          window.location.hash = '#feed/' + newVersion.get('feedSource').id + '/' + newVersion.id;
        }
      });
    },

    onShow: function () {
        try {
            this.routesRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').routes.invalidValues}));
        } catch (e) {}
        try {
            this.stopsRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').stops.invalidValues}));
        } catch (e) {}
        try {
            this.tripsRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').trips.invalidValues}));
        } catch (e) {}
        try {
            this.shapesRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').shapes.invalidValues}));
        } catch (e) {}

        // set up nav
        app.nav.setLocation([
            {name: this.model.get('feedSource').feedCollection.name, href: '#overview/' + this.model.get('feedSource').feedCollection.id},
            {name: this.model.get('feedSource').name, href: '#feed/' + this.model.get('feedSource').id},
            {name: window.Messages('app.feed_version.version_number', this.model.get('version')),
             href: '#feed/' +this.model.get('feedSource').id + '/' + this.model.get('id')}
        ]);

        // set up notes
        this.notesRegion.show(new NoteCollectionView({objectId: this.model.get('id'), type: 'FEED_VERSION'}));
    }
});
<commit_msg>Let the user know when the feed has not changed and they try to update it.<commit_after>/**
 * Show information about a version of a feed
 * This primarily consists of validation results
 */

var Backbone = require('backbone');
Backbone.Marionette = require('backbone.marionette');
var $ = require('jquery');
var _ = require('underscore');
var Handlebars = require('handlebars');
var app = require('application');
var NoteCollectionView = require('note-collection-view');
var FeedUploadView = require('feed-upload-view');
var FeedSource = require('feed-source');
var FeedVersion = require('feed-version');

var InvalidValuesList = Backbone.Marionette.ItemView.extend({
    // rather than having a ton of levels of nested views, since we're not editing, most of the
    // recursion occurs in the template
    template: Handlebars.compile(require('./invalid-values-list.html')),

    initialize: function (attr) {
        // group them by error type
        var invalidValues = attr.invalidValues;
        var errors = {};
        var invalidValuesLen = invalidValues.length;
        for (var i = 0; i < invalidValuesLen; i++) {
            var iv = invalidValues[i];

            if (typeof(errors[iv.problemType]) == 'undefined') {
                errors[iv.problemType] = [];
                errors[iv.problemType].name = iv.problemType;
            }

            errors[iv.problemType].push(iv);
        }

        // we use a bare Backbone.Model to pass the tree to the template
        this.model = new Backbone.Model({errors: errors});
    }
});

module.exports = Backbone.Marionette.LayoutView.extend({
    template: Handlebars.compile(require('./feed-version-view.html')),

    regions: {
        routesRegion: '#routes',
        tripsRegion: '#trips',
        stopsRegion: '#stops',
        shapesRegion: '#shapes',
        notesRegion: '.version-notes'
    },

    events: {
      'click .upload-feed': 'uploadFeed',
      'click .update-feed': 'updateFeed'
      },

    initialize: function () {
      _.bindAll(this, 'uploadFeed', 'updateFeed');
    },

    // show the feed upload dialog
    uploadFeed: function (e) {
        // model is so that it knows what feed source to upload to
        app.modalRegion.show(new FeedUploadView({model: new FeedSource(this.model.get('feedSource'))}));
    },

    // fetch the latest version of an autofetched/produced in house feed
    updateFeed: function (e) {
      // user feedback
      $(e.target).find('span').addClass('spinner');

      var instance = this;
      $.ajax({
        url: 'api/feedsources/' + this.model.get('feedSource').id + '/fetch',
        method: 'POST',
        success: function (data) {
          $(e.target).find('span').removeClass('spinner');
          if (data === null) {
            alert('Feed has not changed');
          }
          else {
            var newVersion = new FeedVersion(data);
            window.location.hash = '#feed/' + newVersion.get('feedSource').id + '/' + newVersion.id;
          }
        }
      });
    },

    onShow: function () {
        try {
            this.routesRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').routes.invalidValues}));
        } catch (e) {}
        try {
            this.stopsRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').stops.invalidValues}));
        } catch (e) {}
        try {
            this.tripsRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').trips.invalidValues}));
        } catch (e) {}
        try {
            this.shapesRegion.show(new InvalidValuesList({invalidValues: this.model.get('validationResult').shapes.invalidValues}));
        } catch (e) {}

        // set up nav
        app.nav.setLocation([
            {name: this.model.get('feedSource').feedCollection.name, href: '#overview/' + this.model.get('feedSource').feedCollection.id},
            {name: this.model.get('feedSource').name, href: '#feed/' + this.model.get('feedSource').id},
            {name: window.Messages('app.feed_version.version_number', this.model.get('version')),
             href: '#feed/' +this.model.get('feedSource').id + '/' + this.model.get('id')}
        ]);

        // set up notes
        this.notesRegion.show(new NoteCollectionView({objectId: this.model.get('id'), type: 'FEED_VERSION'}));
    }
});
<|endoftext|>


<commit_before>/* eslint-env mocha */
// Above line makes it work with Mocha

// NOTE:Run these tests assuming running on a GMT server
// For mocha, use switch env TZ='etc/GMT'

const addremindersupplementarytextprocessor = require('./addreminder.supplementarytextprocessor')
const should = require('chai').should()
const sinon = require('sinon')
const errors = require('./../errors')

describe('add reminder supplementary text processor', () => {
  let timezone, clock, now

  afterEach(() => {
    if (clock) {
      clock.restore()
    }
  })

  const shouldMatch = (text, expected) => {
    var data = {timezone: timezone, supplementaryText: text}
    clock = sinon.useFakeTimers(now.getTime())
    addremindersupplementarytextprocessor.retrieveDateAndTitleFromSupplementaryText(data)
    var expectedDataAppended = expected.dateGMT + ' GMT+0000 (GMT)'
    data.reminderWhenGMT.toString().should.equal(expectedDataAppended)
    data.reminderUserDateText.should.equal(expected.dateText)
    data.reminderTitle.should.equal(expected.title)
  }

  const shouldError = (text, expectedError) => {
    var data = {timezone: timezone, supplementaryText: text}
    clock = sinon.useFakeTimers(now.getTime())
    try {
      addremindersupplementarytextprocessor.retrieveDateAndTitleFromSupplementaryText(data)
      should.fail('should fail')
    } catch (result) {
      result.errorMessage.should.equal(expectedError)
    }
  }

  describe('GMT Timezone Midnight', () => {
    beforeEach(() => {
      timezone = 'GMT'
      now = new Date('01/01/2017 GMT+0000')
    })
    it('✅ tomorrow go shopping', () => { shouldMatch('tomorrow go shopping', {dateGMT: 'Mon Jan 02 2017 00:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 00:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ today 2pm go shopping', () => { shouldMatch('2pm go shopping', {dateGMT: 'Sun Jan 01 2017 14:00:00', dateText: 'Sunday 2pm, Jan 1st', title: 'go shopping'}) })
    it('✅ next week go shopping', () => { shouldMatch('next week go shopping', {dateGMT: 'Sun Jan 08 2017 00:00:00', dateText: 'Sunday, Jan 8th', title: 'go shopping'}) })
    it('✅ thursday noon go shopping', () => { shouldMatch('thursday noon go shopping', {dateGMT: 'Thu Jan 05 2017 12:00:00', dateText: 'Thursday 12pm, Jan 5th', title: 'go shopping'}) })
    it('✅ yesterday reminder', () => { shouldMatch('yesterday reminder', {dateGMT: 'Sat Dec 31 2016 00:00:00', dateText: 'Saturday, Dec 31st, 2016', title: 'reminder'}) })
    it('✅ next month 1:36:44am eclipse', () => { shouldMatch('next month 1:36am eclipse', {dateGMT: 'Wed Feb 01 2017 01:36:00', dateText: 'Wednesday 1:36am, Feb 1st', title: 'eclipse'}) })
    it('✅ fri go shopping', () => { shouldMatch('fri go shopping', {dateGMT: 'Fri Jan 06 2017 00:00:00', dateText: 'Friday, Jan 6th', title: 'go shopping'}) })
    it('✅ go shopping tonight', () => { shouldMatch('go shopping tonight', {dateGMT: 'Sun Jan 01 2017 21:00:00', dateText: 'Sunday 9pm, Jan 1st', title: 'go shopping'}) })
    it('✅ go party 12/31/2017 evening', () => { shouldMatch('go party 12/31/2017 evening', {dateGMT: 'Sun Dec 31 2017 19:00:00', dateText: 'Sunday 7pm, Dec 31st', title: 'go party'}) })
    it('❌ go shopping', () => { shouldError('go shopping', errors.errorTypes.noDateTime) })
    it('❌ tomorrow', () => { shouldError('tomorrow', errors.errorTypes.noTitle) })
    it('❌ empty', () => { shouldError('', errors.errorTypes.noDateTime) })
  })

  describe('New York Timezone 8pm', () => {
    beforeEach(() => {
      timezone = 'America/New_York'
      now = new Date('01/01/2017 22:00:00 GMT-0500')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 05:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Mon Jan 02 2017 05:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping tomorrow night', () => { shouldMatch('go shopping tomorrow night', {dateGMT: 'Tue Jan 03 2017 02:00:00', dateText: 'Monday 9pm, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping yesterday', () => { shouldMatch('go shopping yesterday', {dateGMT: 'Sat Dec 31 2016 05:00:00', dateText: 'Saturday, Dec 31st, 2016', title: 'go shopping'}) })
    it('✅ Jan 1 2018 morning write new years intentions', () => { shouldMatch('Jan 1 2018 morning write new years intentions', {dateGMT: 'Mon Jan 01 2018 13:00:00', dateText: 'Monday 8am, Jan 1st, 2018', title: 'write new years intentions'}) })
    it('✅ next month pay bills', () => { shouldMatch('next month pay bills', {dateGMT: 'Wed Feb 01 2017 05:00:00', dateText: 'Wednesday, Feb 1st', title: 'pay bills'}) })
  })

  describe('New York Timezone 3am', () => {
    beforeEach(() => {
      timezone = 'America/New_York'
      now = new Date('01/01/2017 03:00:00 GMT-0500')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 05:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Mon Jan 02 2017 05:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping afternoon', () => { shouldMatch('go shopping afternoon', {dateGMT: 'Sun Jan 01 2017 19:00:00', dateText: 'Sunday 2pm, Jan 1st', title: 'go shopping'}) })
    it('✅ date-night Feb 1st, 8pm', () => { shouldMatch('date-night Feb 1st, 8pm', {dateGMT: 'Thu Feb 02 2017 01:00:00', dateText: 'Wednesday 8pm, Feb 1st', title: 'date-night'}) })
  })

  describe('Russia Timezone 3am', () => {
    beforeEach(() => {
      timezone = 'Europe/Moscow'
      now = new Date('01/01/2017 03:00:00 GMT+0300')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sat Dec 31 2016 21:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Sun Jan 01 2017 21:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
  })
})
<commit_msg>test deploy2<commit_after>/* eslint-env mocha */
// Above line makes it work with Mocha

// NOTE:Run these tests assuming running on a GMT server
// For mocha, use switch env TZ='etc/GMT'.

const addremindersupplementarytextprocessor = require('./addreminder.supplementarytextprocessor')
const should = require('chai').should()
const sinon = require('sinon')
const errors = require('./../errors')

describe('add reminder supplementary text processor', () => {
  let timezone, clock, now

  afterEach(() => {
    if (clock) {
      clock.restore()
    }
  })

  const shouldMatch = (text, expected) => {
    var data = {timezone: timezone, supplementaryText: text}
    clock = sinon.useFakeTimers(now.getTime())
    addremindersupplementarytextprocessor.retrieveDateAndTitleFromSupplementaryText(data)
    var expectedDataAppended = expected.dateGMT + ' GMT+0000 (GMT)'
    data.reminderWhenGMT.toString().should.equal(expectedDataAppended)
    data.reminderUserDateText.should.equal(expected.dateText)
    data.reminderTitle.should.equal(expected.title)
  }

  const shouldError = (text, expectedError) => {
    var data = {timezone: timezone, supplementaryText: text}
    clock = sinon.useFakeTimers(now.getTime())
    try {
      addremindersupplementarytextprocessor.retrieveDateAndTitleFromSupplementaryText(data)
      should.fail('should fail')
    } catch (result) {
      result.errorMessage.should.equal(expectedError)
    }
  }

  describe('GMT Timezone Midnight', () => {
    beforeEach(() => {
      timezone = 'GMT'
      now = new Date('01/01/2017 GMT+0000')
    })
    it('✅ tomorrow go shopping', () => { shouldMatch('tomorrow go shopping', {dateGMT: 'Mon Jan 02 2017 00:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 00:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ today 2pm go shopping', () => { shouldMatch('2pm go shopping', {dateGMT: 'Sun Jan 01 2017 14:00:00', dateText: 'Sunday 2pm, Jan 1st', title: 'go shopping'}) })
    it('✅ next week go shopping', () => { shouldMatch('next week go shopping', {dateGMT: 'Sun Jan 08 2017 00:00:00', dateText: 'Sunday, Jan 8th', title: 'go shopping'}) })
    it('✅ thursday noon go shopping', () => { shouldMatch('thursday noon go shopping', {dateGMT: 'Thu Jan 05 2017 12:00:00', dateText: 'Thursday 12pm, Jan 5th', title: 'go shopping'}) })
    it('✅ yesterday reminder', () => { shouldMatch('yesterday reminder', {dateGMT: 'Sat Dec 31 2016 00:00:00', dateText: 'Saturday, Dec 31st, 2016', title: 'reminder'}) })
    it('✅ next month 1:36:44am eclipse', () => { shouldMatch('next month 1:36am eclipse', {dateGMT: 'Wed Feb 01 2017 01:36:00', dateText: 'Wednesday 1:36am, Feb 1st', title: 'eclipse'}) })
    it('✅ fri go shopping', () => { shouldMatch('fri go shopping', {dateGMT: 'Fri Jan 06 2017 00:00:00', dateText: 'Friday, Jan 6th', title: 'go shopping'}) })
    it('✅ go shopping tonight', () => { shouldMatch('go shopping tonight', {dateGMT: 'Sun Jan 01 2017 21:00:00', dateText: 'Sunday 9pm, Jan 1st', title: 'go shopping'}) })
    it('✅ go party 12/31/2017 evening', () => { shouldMatch('go party 12/31/2017 evening', {dateGMT: 'Sun Dec 31 2017 19:00:00', dateText: 'Sunday 7pm, Dec 31st', title: 'go party'}) })
    it('❌ go shopping', () => { shouldError('go shopping', errors.errorTypes.noDateTime) })
    it('❌ tomorrow', () => { shouldError('tomorrow', errors.errorTypes.noTitle) })
    it('❌ empty', () => { shouldError('', errors.errorTypes.noDateTime) })
  })

  describe('New York Timezone 8pm', () => {
    beforeEach(() => {
      timezone = 'America/New_York'
      now = new Date('01/01/2017 22:00:00 GMT-0500')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 05:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Mon Jan 02 2017 05:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping tomorrow night', () => { shouldMatch('go shopping tomorrow night', {dateGMT: 'Tue Jan 03 2017 02:00:00', dateText: 'Monday 9pm, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping yesterday', () => { shouldMatch('go shopping yesterday', {dateGMT: 'Sat Dec 31 2016 05:00:00', dateText: 'Saturday, Dec 31st, 2016', title: 'go shopping'}) })
    it('✅ Jan 1 2018 morning write new years intentions', () => { shouldMatch('Jan 1 2018 morning write new years intentions', {dateGMT: 'Mon Jan 01 2018 13:00:00', dateText: 'Monday 8am, Jan 1st, 2018', title: 'write new years intentions'}) })
    it('✅ next month pay bills', () => { shouldMatch('next month pay bills', {dateGMT: 'Wed Feb 01 2017 05:00:00', dateText: 'Wednesday, Feb 1st', title: 'pay bills'}) })
  })

  describe('New York Timezone 3am', () => {
    beforeEach(() => {
      timezone = 'America/New_York'
      now = new Date('01/01/2017 03:00:00 GMT-0500')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sun Jan 01 2017 05:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Mon Jan 02 2017 05:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
    it('✅ go shopping afternoon', () => { shouldMatch('go shopping afternoon', {dateGMT: 'Sun Jan 01 2017 19:00:00', dateText: 'Sunday 2pm, Jan 1st', title: 'go shopping'}) })
    it('✅ date-night Feb 1st, 8pm', () => { shouldMatch('date-night Feb 1st, 8pm', {dateGMT: 'Thu Feb 02 2017 01:00:00', dateText: 'Wednesday 8pm, Feb 1st', title: 'date-night'}) })
  })

  describe('Russia Timezone 3am', () => {
    beforeEach(() => {
      timezone = 'Europe/Moscow'
      now = new Date('01/01/2017 03:00:00 GMT+0300')
    })
    it('✅ today go shopping', () => { shouldMatch('today go shopping', {dateGMT: 'Sat Dec 31 2016 21:00:00', dateText: 'Sunday, Jan 1st', title: 'go shopping'}) })
    it('✅ go shopping tomorrow', () => { shouldMatch('go shopping tomorrow', {dateGMT: 'Sun Jan 01 2017 21:00:00', dateText: 'Monday, Jan 2nd', title: 'go shopping'}) })
  })
})
<|endoftext|>


<commit_before>var express      = require('express');
var config       = require('./config');
var path         = require('path');
var favicon      = require('serve-favicon');
var logger       = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser   = require('body-parser');
var session      = require('express-session');
var flash        = require('connect-flash');
var mongoose     = require('mongoose');
var passport     = require('passport');
var Strategy     = require('passport-local').Strategy;
var hbs          = require('hbs');
var stylus       = require('express-stylus');
var User         = require('./models/user');

//Pages
var homepage     = require('./routes/homepage');
var signUp       = require('./routes/signup');
var login        = require('./routes/login');
var logout       = require('./routes/logout');
var user         = require('./routes/user');

var app = express();

//set port to use environment variables for heroku
app.set('port',(process.env.PORT || 3000));

var public = path.join(__dirname, 'public');

//Express
app.use(favicon(path.join(public, 'favicon.ico')));
app.use(express.static(public));
app.use(logger('dev'));

//Handlebars
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
hbs.registerPartials(path.join(__dirname, 'views', 'partials'));
hbs.registerHelper('config',function(variable) {
  return config[variable];
});

//BodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: false
}));

//CookieParser
app.use(cookieParser());

//Passport
app.use(session({
  secret: config.passportSecret,
  resave: false,
  saveUninitialized: false,
  }
));

//Flash
app.use(flash());

app.use(passport.initialize());
app.use(passport.session());

passport.use(new Strategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());

//enables case sensitive routing so /user/bob is same as /uSeR/bOB
app.enable('case sensitive routing');

//disables the header field x-powered-by: Express being sent through the headers
app.disable('x-powered-by');

//Routes
app.use('/', homepage);
app.use('/signup', signUp);
app.use('/login', login);
app.use('/logout', logout);
app.use('/user', user);

//logs out what environment mode you are currently working on
console.log("process.env.NODE_ENV="+app.get('env'));

//MongoDB
if(app.get('env')==='production'){
  console.log("Connecting to: "+ process.env.MONGODB_URI);
  console.log("Port="+process.env.PORT );
  //NOTE: You have to run heroku config first to set this environment variable
  //otherwise it defaults to the config file in config.mongooseUri
  mongoose.connect(process.env.MONGODB_URI);
  console.log("Connection successful");
}
else{
  mongoose.connect(config.mongooseUri);
}

//Stylus
app.use(stylus({
  src: path.join(public, "stylesheets")
}));

//404 error handler
app.use(function(req, res, next) {
  res.status(404);
  res.render('404', {
    title: 'wasdWithMe - Page not found!',
    layout: 'primary',
    file: '404',
    user : req.user,
    message: "Page not found!"
  });
});

//Development error handler
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

//Production error handler
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;
<commit_msg>bug hunting<commit_after>var express      = require('express');
var config       = require('./config');
var path         = require('path');
var favicon      = require('serve-favicon');
var logger       = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser   = require('body-parser');
var session      = require('express-session');
var flash        = require('connect-flash');
var mongoose     = require('mongoose');
var passport     = require('passport');
var Strategy     = require('passport-local').Strategy;
var hbs          = require('hbs');
var stylus       = require('express-stylus');
var User         = require('./models/user');

//Pages
var homepage     = require('./routes/homepage');
var signUp       = require('./routes/signup');
var login        = require('./routes/login');
var logout       = require('./routes/logout');
var user         = require('./routes/user');

var app = express();

//set port to use environment variables for heroku
app.set('port',(process.env.PORT || 3000));

var public = path.join(__dirname, 'public');

//Express
app.use(favicon(path.join(public, 'favicon.ico')));
app.use(express.static(public));
app.use(logger('dev'));

//Handlebars
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
hbs.registerPartials(path.join(__dirname, 'views', 'partials'));
hbs.registerHelper('config',function(variable) {
  return config[variable];
});

//BodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: false
}));

//CookieParser
app.use(cookieParser());

//Passport
app.use(session({
  secret: config.passportSecret,
  resave: false,
  saveUninitialized: false,
  }
));

//Flash
app.use(flash());

app.use(passport.initialize());
app.use(passport.session());

passport.use(new Strategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());

//enables case sensitive routing so /user/bob is same as /uSeR/bOB
app.enable('case sensitive routing');

//disables the header field x-powered-by: Express being sent through the headers
app.disable('x-powered-by');

//Routes
app.use('/', homepage);
app.use('/signup', signUp);
app.use('/login', login);
app.use('/logout', logout);
app.use('/user', user);

//logs out what environment mode you are currently working on
console.log("process.env.NODE_ENV="+app.get('env'));

//MongoDB
if(app.get('env')==='production'){
  console.log("Connecting to: "+ process.env.MONGODB_URI);
  console.log("env.PORT="+process.env.PORT +" current port="+app.get('port'));
  //NOTE: You have to run heroku config first to set this environment variable
  //otherwise it defaults to the config file in config.mongooseUri
  mongoose.connect(process.env.MONGODB_URI);
  console.log("Connection successful");
}
else{
  mongoose.connect(config.mongooseUri);
}

//Stylus
app.use(stylus({
  src: path.join(public, "stylesheets")
}));

//404 error handler
app.use(function(req, res, next) {
  res.status(404);
  res.render('404', {
    title: 'wasdWithMe - Page not found!',
    layout: 'primary',
    file: '404',
    user : req.user,
    message: "Page not found!"
  });
});

//Development error handler
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

//Production error handler
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;
<|endoftext|>


<commit_before>'use strict';

//Menu service used for managing  menus
angular.module('core').service('Menus', [

	function() {
		// Define a set of default roles
		this.defaultRoles = ['*'];

		// Define the menus object
		this.menus = {};

		// A private function for rendering decision
		var shouldRender = function() {
      var user = window.user;
			if (user) {
				if (!!~this.roles.indexOf('*')) {
					return true;
				} else {
					for (var userRoleIndex in user.roles) {
						for (var roleIndex in this.roles) {
							if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
								return true;
							}
						}
					}
				}
			} else {
				return this.isPublic;
			}

			return false;
		};

		// Validate menu existance
		this.validateMenuExistance = function(menuId) {
			if (menuId && menuId.length) {
				if (this.menus[menuId]) {
					return true;
				} else {
					throw new Error('Menu does not exists');
				}
			} else {
				throw new Error('MenuId was not provided');
			}

			return false;
		};

		// Get the menu object by menu id
		this.getMenu = function(menuId) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Return the menu object
			return this.menus[menuId];
		};

		// Add new menu object by menu id
		this.addMenu = function(menuId, isPublic, roles) {
			// Create the new menu
			this.menus[menuId] = {
				isPublic: isPublic || false,
				roles: roles || this.defaultRoles,
				items: [],
				shouldRender: shouldRender
			};

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeMenu = function(menuId) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Return the menu object
			delete this.menus[menuId];
		};

		// Add menu item object
		this.addMenuItem = function(menuId, menuItemTitle, menuItemURL, menuItemType, menuItemUIRoute, isPublic, roles, position) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Push new menu item
			this.menus[menuId].items.push({
				title: menuItemTitle,
				link: menuItemURL,
				menuItemType: menuItemType || 'item',
				menuItemClass: menuItemType,
				uiRoute: menuItemUIRoute || ('/' + menuItemURL),
				isPublic: ((isPublic === null || typeof isPublic === 'undefined') ? this.menus[menuId].isPublic : isPublic),
				roles: ((roles === null || typeof roles === 'undefined') ? this.menus[menuId].roles : roles),
				position: position || 0,
				items: [],
				shouldRender: shouldRender
			});

			// Return the menu object
			return this.menus[menuId];
		};

		// Add submenu item object
		this.addSubMenuItem = function(menuId, rootMenuItemURL, menuItemTitle, menuItemURL, menuItemUIRoute, isPublic, roles, position) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item
			for (var itemIndex in this.menus[menuId].items) {
				if (this.menus[menuId].items[itemIndex].link === rootMenuItemURL) {
					// Push new submenu item
					this.menus[menuId].items[itemIndex].items.push({
						title: menuItemTitle,
						link: menuItemURL,
						uiRoute: menuItemUIRoute || ('/' + menuItemURL),
						isPublic: ((isPublic === null || typeof isPublic === 'undefined') ? this.menus[menuId].items[itemIndex].isPublic : isPublic),
						roles: ((roles === null || typeof roles === 'undefined') ? this.menus[menuId].items[itemIndex].roles : roles),
						position: position || 0,
						shouldRender: shouldRender
					});
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeMenuItem = function(menuId, menuItemURL) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item to remove
			for (var itemIndex in this.menus[menuId].items) {
				if (this.menus[menuId].items[itemIndex].link === menuItemURL) {
					this.menus[menuId].items.splice(itemIndex, 1);
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeSubMenuItem = function(menuId, submenuItemURL) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item to remove
			for (var itemIndex in this.menus[menuId].items) {
				for (var subitemIndex in this.menus[menuId].items[itemIndex].items) {
					if (this.menus[menuId].items[itemIndex].items[subitemIndex].link === submenuItemURL) {
						this.menus[menuId].items[itemIndex].items.splice(subitemIndex, 1);
					}
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		//Adding the topbar menu
		this.addMenu('topbar');
	}
]);<commit_msg>Menu bugfix<commit_after>'use strict';

//Menu service used for managing  menus
angular.module('core').service('Menus', [

	function() {
		// Define a set of default roles
		this.defaultRoles = ['*'];

		// Define the menus object
		this.menus = {};

		// A private function for rendering decision
		var shouldRender = function() {
			if (window.user) {
				if (!!~this.roles.indexOf('*')) {
					return true;
				} else {
					for (var userRoleIndex in window.user.roles) {
						for (var roleIndex in this.roles) {
							if (this.roles[roleIndex] === window.user.roles[userRoleIndex]) {
								return true;
							}
						}
					}
				}
			} else {
				return this.isPublic;
			}

			return false;
		};

		// Validate menu existance
		this.validateMenuExistance = function(menuId) {
			if (menuId && menuId.length) {
				if (this.menus[menuId]) {
					return true;
				} else {
					throw new Error('Menu does not exists');
				}
			} else {
				throw new Error('MenuId was not provided');
			}

			return false;
		};

		// Get the menu object by menu id
		this.getMenu = function(menuId) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Return the menu object
			return this.menus[menuId];
		};

		// Add new menu object by menu id
		this.addMenu = function(menuId, isPublic, roles) {
			// Create the new menu
			this.menus[menuId] = {
				isPublic: isPublic || false,
				roles: roles || this.defaultRoles,
				items: [],
				shouldRender: shouldRender
			};

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeMenu = function(menuId) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Return the menu object
			delete this.menus[menuId];
		};

		// Add menu item object
		this.addMenuItem = function(menuId, menuItemTitle, menuItemURL, menuItemType, menuItemUIRoute, isPublic, roles, position) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Push new menu item
			this.menus[menuId].items.push({
				title: menuItemTitle,
				link: menuItemURL,
				menuItemType: menuItemType || 'item',
				menuItemClass: menuItemType,
				uiRoute: menuItemUIRoute || ('/' + menuItemURL),
				isPublic: ((isPublic === null || typeof isPublic === 'undefined') ? this.menus[menuId].isPublic : isPublic),
				roles: ((roles === null || typeof roles === 'undefined') ? this.menus[menuId].roles : roles),
				position: position || 0,
				items: [],
				shouldRender: shouldRender
			});

			// Return the menu object
			return this.menus[menuId];
		};

		// Add submenu item object
		this.addSubMenuItem = function(menuId, rootMenuItemURL, menuItemTitle, menuItemURL, menuItemUIRoute, isPublic, roles, position) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item
			for (var itemIndex in this.menus[menuId].items) {
				if (this.menus[menuId].items[itemIndex].link === rootMenuItemURL) {
					// Push new submenu item
					this.menus[menuId].items[itemIndex].items.push({
						title: menuItemTitle,
						link: menuItemURL,
						uiRoute: menuItemUIRoute || ('/' + menuItemURL),
						isPublic: ((isPublic === null || typeof isPublic === 'undefined') ? this.menus[menuId].items[itemIndex].isPublic : isPublic),
						roles: ((roles === null || typeof roles === 'undefined') ? this.menus[menuId].items[itemIndex].roles : roles),
						position: position || 0,
						shouldRender: shouldRender
					});
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeMenuItem = function(menuId, menuItemURL) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item to remove
			for (var itemIndex in this.menus[menuId].items) {
				if (this.menus[menuId].items[itemIndex].link === menuItemURL) {
					this.menus[menuId].items.splice(itemIndex, 1);
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		// Remove existing menu object by menu id
		this.removeSubMenuItem = function(menuId, submenuItemURL) {
			// Validate that the menu exists
			this.validateMenuExistance(menuId);

			// Search for menu item to remove
			for (var itemIndex in this.menus[menuId].items) {
				for (var subitemIndex in this.menus[menuId].items[itemIndex].items) {
					if (this.menus[menuId].items[itemIndex].items[subitemIndex].link === submenuItemURL) {
						this.menus[menuId].items[itemIndex].items.splice(subitemIndex, 1);
					}
				}
			}

			// Return the menu object
			return this.menus[menuId];
		};

		//Adding the topbar menu
		this.addMenu('topbar');
	}
]);<|endoftext|>


<commit_before>'use strict';

// Declare app level module which depends on filters, and services
angular.module('my.app', [
    'my.config',
    'my.user.factory',
    'my.user.controller',
    'my.chat.controller',
    'my.home.controller',
    'my.login.controller',
    'my.menu.controller',
    'my.decorators',
    'my.directives',
    'my.filters',
    'ngRoute'
])

        .config(["$routeProvider", function ($routeProvider) {
                $routeProvider.when("/home", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "homeController",
                    templateUrl: "home/home.html",
                    resolve: {
                        // controller will not be loaded until $waitForAuth resolves
                        // Auth refers to our $firebaseAuth wrapper in the example above
                        "currentAuth": ['userFactory', function (userFactory) {
                                // $waitForAuth returns a promise so the resolve waits for it to complete
                                return userFactory.firebaseAuth().$waitForAuth();
                            }]
                    }
                }).when("/login", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "loginController",
                    templateUrl: "components/login/login.html"
                }).when("/chat", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "chatController",
                    templateUrl: "chat/chat.html"
                }).when("/user", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "userController",
                    templateUrl: "components/user/user.html",
                    resolve: {
                        // controller will not be loaded until $requireAuth resolves
                        // Auth refers to our $firebaseAuth wrapper in the example above
                        "currentAuth": ['userFactory', function (userFactory) {
                                // $requireAuth returns a promise so the resolve waits for it to complete
                                // If the promise is rejected, it will throw a $stateChangeError (see above)
                                return userFactory.firebaseAuth().$requireAuth();
                            }]
                    }
                }).otherwise({
                    redirectTo: '/home'});
            }])

        .run(["$rootScope", "$location", 'userFactory', function ($rootScope, $location, userFactory) {
                $rootScope.$on("$routeChangeError", function (event, next, previous, error) {
                    // We can catch the error thrown when the $requireAuth promise is rejected
                    // and redirect the user back to the home page
                    if (error === "AUTH_REQUIRED") {
                        $location.path("/login");
                    }
                });
                userFactory.firebaseAuth().$onAuth(function (auth) {
                    $rootScope.auth = auth;
                });
                $rootScope.$on('$destroy', function () {
                    userFactory.getAuth().$offAuth();
                });
            }]);
<commit_msg>remove dependency on userFactory<commit_after>'use strict';

// Declare app level module which depends on filters, and services
angular.module('my.app', [
    'my.config',
    'my.user.controller',
    'my.chat.controller',
    'my.home.controller',
    'my.login.controller',
    'my.menu.controller',
    'my.decorators',
    'my.directives',
    'my.filters',
    'ngRoute'
])

        .config(["$routeProvider", function ($routeProvider) {
                $routeProvider.when("/home", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "homeController",
                    templateUrl: "home/home.html",
                    resolve: {
                        // controller will not be loaded until $waitForAuth resolves
                        // Auth refers to our $firebaseAuth wrapper in the example above
                        "currentAuth": ['firebaseFactory', function (firebaseFactory) {
                                // $waitForAuth returns a promise so the resolve waits for it to complete
                                return firebaseFactory.auth().$waitForAuth();
                            }]
                    }
                }).when("/login", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "loginController",
                    templateUrl: "components/login/login.html"
                }).when("/chat", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "chatController",
                    templateUrl: "chat/chat.html"
                }).when("/user", {
                    // the rest is the same for ui-router and ngRoute...
                    controller: "userController",
                    templateUrl: "components/user/user.html",
                    resolve: {
                        // controller will not be loaded until $requireAuth resolves
                        // Auth refers to our $firebaseAuth wrapper in the example above
                        "currentAuth": ['firebaseFactory', function (firebaseFactory) {
                                // $requireAuth returns a promise so the resolve waits for it to complete
                                // If the promise is rejected, it will throw a $stateChangeError (see above)
                                return firebaseFactory.auth().$requireAuth();
                            }]
                    }
                }).otherwise({
                    redirectTo: '/home'});
            }])

        .run(["$rootScope", "$location", 'firebaseFactory', function ($rootScope, $location, firebaseFactory) {
                $rootScope.$on("$routeChangeError", function (event, next, previous, error) {
                    // We can catch the error thrown when the $requireAuth promise is rejected
                    // and redirect the user back to the home page
                    if (error === "AUTH_REQUIRED") {
                        $location.path("/login");
                    }
                });
                firebaseFactory.auth().$onAuth(function (auth) {
                    $rootScope.auth = auth;
                });
                $rootScope.$on('$destroy', function () {
                    firebaseFactory.auth().$offAuth();
                });
            }]);
<|endoftext|>


<commit_before>import Resolver from 'ember/resolver';
import session from 'emberconf-2014-demo/controllers/session';
import analyticsHandler from 'emberconf-2014-demo/utils/analyticsHandler';

ic.ajax.defineFixture('/session', {
  response: {
    /* Successfully identified username and password. */
    isIdentified: true,

    /* Related to one-time-passcode. */
    willSetupOTP: false,
    isAuthenticated: false,

    hasElectronicConsent: true,
    hasTermsOfServiceConsent: false,
    showTour: false
  },
  textStatus: 'success'
});

ic.ajax.defineFixture('/one-time-password-methods', {
  // response: [
  //   { id: 1, type: 'phone', value: '5555555555' },
  //   { id: 2, type: 'email', value: 'example@example.com' }
  // ],
  response: [
   { id: 1, type: 'phone', value: '5555555555' }
  ],
  // response: [],
  textStatus: 'success'
});

ic.ajax.defineFixture('/one-time-password-authenticate', {
  response: {
    isAuthenticated: true
  },
  textStatus: 'success'
});

Ember.Application.initializer({
  name: 'session',
  initialize: function(container, app) {
    container.register('session:main', session);
    app.inject('route', 'session', 'session:main');
  }
});

var App = Ember.Application.extend({
  // LOG_ACTIVE_GENERATION: true,
  // LOG_MODULE_RESOLVER: true,
  // LOG_TRANSITIONS: true,
  // LOG_TRANSITIONS_INTERNAL: true,
  // LOG_VIEW_LOOKUPS: true,
  modulePrefix: 'emberconf-2014-demo', // TODO: loaded via config
  Resolver: Resolver['default']
});

/* Reopen ActionHandler and perform processing on the send() function */
Ember.ActionHandler.reopen({
  send: function(actionName) {
    analyticsHandler.apply(this, arguments);
  }
});

export default App;
<commit_msg>Improve the demo example.<commit_after>import Resolver from 'ember/resolver';
import session from 'emberconf-2014-demo/controllers/session';
import analyticsHandler from 'emberconf-2014-demo/utils/analyticsHandler';

ic.ajax.defineFixture('/session', {
  response: {
    /* Successfully identified username and password. */
    isIdentified: true,

    /* Related to one-time-passcode. */
    willSetupOTP: false,
    isAuthenticated: false,

    hasElectronicConsent: true,
    hasTermsOfServiceConsent: false,
    showTour: false
  },
  textStatus: 'success'
});

ic.ajax.defineFixture('/one-time-password-methods', {
  response: [
    { id: 1, type: 'phone', value: '5555555555' },
    { id: 2, type: 'email', value: 'example@example.com' }
  ],
  // response: [
  //  { id: 1, type: 'phone', value: '5555555555' }
  // ],
  // response: [],
  textStatus: 'success'
});

ic.ajax.defineFixture('/one-time-password-authenticate', {
  response: {
    isAuthenticated: true
  },
  textStatus: 'success'
});

Ember.Application.initializer({
  name: 'session',
  initialize: function(container, app) {
    container.register('session:main', session);
    app.inject('route', 'session', 'session:main');
  }
});

var App = Ember.Application.extend({
  // LOG_ACTIVE_GENERATION: true,
  // LOG_MODULE_RESOLVER: true,
  // LOG_TRANSITIONS: true,
  // LOG_TRANSITIONS_INTERNAL: true,
  // LOG_VIEW_LOOKUPS: true,
  modulePrefix: 'emberconf-2014-demo', // TODO: loaded via config
  Resolver: Resolver['default']
});

/* Reopen ActionHandler and perform processing on the send() function */
Ember.ActionHandler.reopen({
  send: function(actionName) {
    analyticsHandler.apply(this, arguments);
  }
});

export default App;
<|endoftext|>