
﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.chart.ts"/>
/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.chart.interaction.ts"/>
/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.chart.analytics.ts"/>
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (chart) {
        /**
        * The @see:FlexChart control extends from @see:wijmo.chart.FlexChart.
        */
        var FlexChart = (function (_super) {
            __extends(FlexChart, _super);
            function FlexChart() {
                _super.apply(this, arguments);
            }
            return FlexChart;
        })(wijmo.chart.FlexChart);
        chart.FlexChart = FlexChart;

        /**
        * The customized wijmo @see:FlexPie control extends from @see:wijmo.chart.FlexPie.
        */
        var FlexPie = (function (_super) {
            __extends(FlexPie, _super);
            function FlexPie() {
                _super.apply(this, arguments);
            }
            return FlexPie;
        })(wijmo.chart.FlexPie);
        chart.FlexPie = FlexPie;
    })(c1.chart || (c1.chart = {}));
    var chart = c1.chart;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.chart.interaction.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (chart) {
        (function (interaction) {
            /**
            * The @see:RangeSelector control extends from @see:wijmo.chart.interaction.RangeSelector.
            */
            var RangeSelector = (function (_super) {
                __extends(RangeSelector, _super);
                function RangeSelector() {
                    _super.apply(this, arguments);
                }
                RangeSelector.prototype.initialize = function (options) {
                    wijmo.copy(this, options);
                };

                RangeSelector.prototype._copy = function (key, value) {
                    if (key === "rangeChanged") {
                        if (typeof value === "function") {
                            this.rangeChanged.addHandler(value);
                        }
                        return true;
                    }
                    return false;
                };
                return RangeSelector;
            })(wijmo.chart.interaction.RangeSelector);
            interaction.RangeSelector = RangeSelector;
        })(chart.interaction || (chart.interaction = {}));
        var interaction = chart.interaction;
    })(c1.chart || (c1.chart = {}));
    var chart = c1.chart;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.Interaction.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.chart.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (chart) {
        /**
        * The @see:LineMarker control extends from @see:wijmo.chart.LineMarker.
        */
        var LineMarker = (function (_super) {
            __extends(LineMarker, _super);
            function LineMarker() {
                _super.apply(this, arguments);
            }
            LineMarker.prototype.initialize = function (options) {
                var content = options.content;
                if (typeof window[content] === "function") {
                    options.content = window[content];
                }
                wijmo.copy(this, options);
            };

            LineMarker.prototype._copy = function (key, value) {
                if (key === "positionChanged") {
                    if (typeof value === "function") {
                        this.positionChanged.addHandler(value);
                    }
                    return true;
                }
                return false;
            };
            return LineMarker;
        })(wijmo.chart.LineMarker);
        chart.LineMarker = LineMarker;
    })(c1.chart || (c1.chart = {}));
    var chart = c1.chart;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.LineMarker.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.gauge.ts"/>
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (gauge) {
        /**
        * The @see:BulletGraph control extends from @see:wijmo.gauge.BulletGraph.
        */
        var BulletGraph = (function (_super) {
            __extends(BulletGraph, _super);
            function BulletGraph() {
                _super.apply(this, arguments);
            }
            return BulletGraph;
        })(wijmo.gauge.BulletGraph);
        gauge.BulletGraph = BulletGraph;

        /**
        * The @see:LinearGauge control extends from @see:wijmo.gauge.LinearGauge.
        */
        var LinearGauge = (function (_super) {
            __extends(LinearGauge, _super);
            function LinearGauge() {
                _super.apply(this, arguments);
            }
            return LinearGauge;
        })(wijmo.gauge.LinearGauge);
        gauge.LinearGauge = LinearGauge;

        /**
        * The @see:RadialGauge control extends from @see:wijmo.gauge.RadialGauge.
        */
        var RadialGauge = (function (_super) {
            __extends(RadialGauge, _super);
            function RadialGauge() {
                _super.apply(this, arguments);
            }
            return RadialGauge;
        })(wijmo.gauge.RadialGauge);
        gauge.RadialGauge = RadialGauge;
    })(c1.gauge || (c1.gauge = {}));
    var gauge = c1.gauge;
})(c1 || (c1 = {}));
//# sourceMappingURL=Gauge.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.grid.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (grid) {
        /**
        * The @see:FlexGrid control extends from @see:wijmo.grid.FlexGrid.
        */
        var FlexGrid = (function (_super) {
            __extends(FlexGrid, _super);
            function FlexGrid() {
                _super.apply(this, arguments);
            }
            return FlexGrid;
        })(wijmo.grid.FlexGrid);
        grid.FlexGrid = FlexGrid;
    })(c1.grid || (c1.grid = {}));
    var grid = c1.grid;
})(c1 || (c1 = {}));
//# sourceMappingURL=Grid.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.input.ts"/>
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (input) {
        /**
        * The @see:c1.input.AutoComplete control extends from @see:wijmo.input.AutoComplete.
        */
        var AutoComplete = (function (_super) {
            __extends(AutoComplete, _super);
            function AutoComplete() {
                _super.apply(this, arguments);
            }
            return AutoComplete;
        })(wijmo.input.AutoComplete);
        input.AutoComplete = AutoComplete;

        /**
        * The @see:c1.input.Calendar control extends from @see:wijmo.input.Calendar.
        */
        var Calendar = (function (_super) {
            __extends(Calendar, _super);
            function Calendar() {
                _super.apply(this, arguments);
            }
            return Calendar;
        })(wijmo.input.Calendar);
        input.Calendar = Calendar;

        /**
        * The @see:c1.input.ColorPicker control extends from @see:wijmo.input.ColorPicker.
        */
        var ColorPicker = (function (_super) {
            __extends(ColorPicker, _super);
            function ColorPicker() {
                _super.apply(this, arguments);
            }
            return ColorPicker;
        })(wijmo.input.ColorPicker);
        input.ColorPicker = ColorPicker;

        /**
        * The @see:c1.input.ComboBox control extends from @see:wijmo.input.ComboBox.
        */
        var ComboBox = (function (_super) {
            __extends(ComboBox, _super);
            function ComboBox() {
                _super.apply(this, arguments);
            }
            /**
            * Gets the string displayed for the item at a given index (as plain text).
            *
            * @param index The index of the item to retrieve the text for.
            */
            ComboBox.prototype.getDisplayText = function (index) {
                // trim space caused by HTML content
                return _super.prototype.getDisplayText.call(this, index).trim();
            };
            return ComboBox;
        })(wijmo.input.ComboBox);
        input.ComboBox = ComboBox;

        /**
        * The @see:c1.input.InputColor control extends from @see:wijmo.input.InputColor.
        */
        var InputColor = (function (_super) {
            __extends(InputColor, _super);
            function InputColor() {
                _super.apply(this, arguments);
            }
            return InputColor;
        })(wijmo.input.InputColor);
        input.InputColor = InputColor;

        /**
        * The @see:c1.input.InputDate control extends from @see:wijmo.input.InputDate.
        */
        var InputDate = (function (_super) {
            __extends(InputDate, _super);
            function InputDate(element, options) {
                _super.call(this, element);

                //I don't hope the mousedown event is triggerred on the elements below the
                //dropdown calendar when press mouse down on the calendar.
                this._dropDown && this._dropDown.addEventListener('mousedown', function (e) {
                    e.stopPropagation();
                });
            }
            return InputDate;
        })(wijmo.input.InputDate);
        input.InputDate = InputDate;

        /**
        * The @see:c1.input.InputMask control extends from @see:wijmo.input.InputMask.
        */
        var InputMask = (function (_super) {
            __extends(InputMask, _super);
            function InputMask() {
                _super.apply(this, arguments);
            }
            return InputMask;
        })(wijmo.input.InputMask);
        input.InputMask = InputMask;

        /**
        * The @see:c1.input.InputNumber control extends from @see:wijmo.input.InputNumber.
        */
        var InputNumber = (function (_super) {
            __extends(InputNumber, _super);
            function InputNumber() {
                _super.apply(this, arguments);
            }
            return InputNumber;
        })(wijmo.input.InputNumber);
        input.InputNumber = InputNumber;

        /**
        * The @see:c1.input.InputTime control extends from @see:wijmo.input.InputTime.
        */
        var InputTime = (function (_super) {
            __extends(InputTime, _super);
            function InputTime() {
                _super.apply(this, arguments);
            }
            return InputTime;
        })(wijmo.input.InputTime);
        input.InputTime = InputTime;

        /**
        * The @see:c1.input.ListBox control extends from @see:wijmo.input.ListBox.
        */
        var ListBox = (function (_super) {
            __extends(ListBox, _super);
            function ListBox() {
                _super.apply(this, arguments);
            }
            return ListBox;
        })(wijmo.input.ListBox);
        input.ListBox = ListBox;

        /**
        * The @see:c1.input.Menu control extends from @see:wijmo.input.Menu.
        */
        var Menu = (function (_super) {
            __extends(Menu, _super);
            function Menu() {
                _super.apply(this, arguments);
            }
            return Menu;
        })(wijmo.input.Menu);
        input.Menu = Menu;

        /**
        * The @see:c1.input.Popup control extends from @see:wijmo.input.Popup.
        */
        var Popup = (function (_super) {
            __extends(Popup, _super);
            function Popup() {
                _super.apply(this, arguments);
            }
            return Popup;
        })(wijmo.input.Popup);
        input.Popup = Popup;

        /**
        * The @see:c1.input.MultiSelect control extends from @see:wijmo.input.MultiSelect.
        */
        var MultiSelect = (function (_super) {
            __extends(MultiSelect, _super);
            function MultiSelect() {
                _super.apply(this, arguments);
            }
            return MultiSelect;
        })(wijmo.input.MultiSelect);
        input.MultiSelect = MultiSelect;
    })(c1.input || (c1.input = {}));
    var input = c1.input;
})(c1 || (c1 = {}));
//# sourceMappingURL=Input.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.ts"/>
var c1;
(function (c1) {
    /**
    * Gets the extender with specified owner and id.
    *
    * @param owner The @see:wijmo.Control who has the extender.
    * @param id The extender's id.
    */
    function getExtender(owner, id) {
        if (!owner || id == null) {
            return null;
        }

        var extendable = c1.wrapper.Wrapper.getWrapper(owner), extenders;
        if (!extendable) {
            return null;
        }

        extenders = extendable.extenders;
        return extenders ? extenders[id] : null;
    }
    c1.getExtender = getExtender;

    /**
    * Gets the extenders with specified owner and type.
    * When type is not passed, this returns all extenders under the owner.
    *
    * @param owner The @see:wijmo.Control who has the extender.
    * @param type The extender's type. It is optional.
    */
    function getExtenders(owner, type) {
        var extendable, extenders, results = [], extender;
        if (!owner) {
            return results;
        }

        extendable = c1.wrapper.Wrapper.getWrapper(owner);
        if (!extendable) {
            return results;
        }

        extenders = extendable.extenders;
        if (!extenders) {
            return results;
        }

        for (var id in extenders) {
            extender = extenders[id];
            if (!type || extender instanceof type) {
                results.push(extender);
            }
        }

        return results;
    }
    c1.getExtenders = getExtenders;

    function addExtender(owner, id, extender) {
        if (!owner || id == null || !extender) {
            return;
        }

        var extendable = c1.wrapper.Wrapper.getWrapper(owner), extenders;
        if (!extendable) {
            return;
        }

        extenders = extendable.extenders;
        if (extenders) {
            extenders[id] = extender;
        }
    }
    c1.addExtender = addExtender;
})(c1 || (c1 = {}));

var c1;
(function (c1) {
    (function (wrapper) {
        // The base control wrapper which contains a wijmo control.
        var Wrapper = (function () {
            function Wrapper(element) {
                this._extenders = {};
                var self = this, wjCtor = self.getWjCtor();
                self.extendWjControl(wjCtor);
                self._wjControl = new wjCtor(element);
                self._wjControl.hostElement[Wrapper.dataKey] = self;
            }
            Wrapper.prototype.extendWjControl = function (wjCtor) {
                // Customize wijmo 5 control's copy for custimizing the initializing
                var wjControlCopy = wjCtor.prototype["_copy"];
                if (wjCtor["_isCopyOverrided"])
                    return;
                wjCtor.prototype["_copy"] = function (key, value) {
                    var prop = this[key];
                    if (prop instanceof wijmo.Event && wijmo.isFunction(value)) {
                        //Add the function as event handler to wijmo.Event
                        prop.addHandler(value);
                        return true;
                    }
                    return wjControlCopy ? wjControlCopy.call(this, key, value) : false;
                };
                wjCtor["_isCopyOverrided"] = true;
            };

            // Gets the wrapper that is hosted in a given DOM element or wijmo.Control.
            Wrapper.getWrapper = function (element) {
                var wjControl = element instanceof wijmo.Control ? element : wijmo.Control.getControl(element);
                return wjControl ? wjControl.hostElement[Wrapper.dataKey] : null;
            };

            // Get the wijmo control's constructor.
            Wrapper.prototype.getWjCtor = function () {
                throw "Should implement this method in the leaf control.";
            };

            Object.defineProperty(Wrapper.prototype, "wjControl", {
                // Get the wijmo control instance.
                get: function () {
                    return this._wjControl;
                },
                enumerable: true,
                configurable: true
            });

            // Initialize the control with the specified options.
            Wrapper.prototype.initialize = function (options) {
                this._wjControl.initialize(options);
            };

            Object.defineProperty(Wrapper.prototype, "extenders", {
                get: function () {
                    return this._extenders;
                },
                enumerable: true,
                configurable: true
            });
            Wrapper.dataKey = 'c1-Control';
            return Wrapper;
        })();
        wrapper.Wrapper = Wrapper;
    })(c1.wrapper || (c1.wrapper = {}));
    var wrapper = c1.wrapper;
})(c1 || (c1 = {}));
//# sourceMappingURL=Control.js.map

﻿/*
* ComponentOne LightSwitch JavaScript Library v5.0.20173.37
* Util.js
*/

var c1;
(function (c1) {
    (function (cba) {
        var $ = jQuery;

        

        

        

        

        /**
        * Utility functions.
        */
        var Utils = (function () {
            function Utils() {
            }
            /**
            * Get a value indicating whether a property is nullable.
            *
            * @param propertyType A value of defined from the LightSwitch value model.
            */
            Utils.isNullableType = function (propertyType) {
                var n = propertyType.__isNullableType;
                return n === undefined ? false : n !== 0;
            };

            // Set the isDroppedDown property for drop down controls.
            Utils.setIsDroppedDown = function (wijControl, isDroppedDown) {
                var setDroppedDown = function () {
                    // set isDroppedDown after 200ms make sure the layout is fixed.
                    setTimeout(function () {
                        wijControl["isDroppedDown"] = isDroppedDown;
                        msls.unsubscribe("LayoutUpdated", setDroppedDown);
                    }, 200);
                };
                if (msls.subscribe && $.isFunction(msls.subscribe)) {
                    //should set the isDroppedDown property after the layout is updated, or the position popup div will be incorrect.
                    msls.subscribe("LayoutUpdated", setDroppedDown);
                }
            };

            /**
            * Get a value indicating whether a property is image type.
            *
            * @param propertyType A value of defined from the LightSwitch value model.
            */
            Utils.isImageType = function (propertyType) {
                var pt = Utils.isNullableType(propertyType) ? propertyType.underlyingType : propertyType;
                return pt.id === ':Binary' || pt.id === 'Microsoft.LightSwitch.Extensions:Image';
            };

            /**
            * Get a value indicating whether a property is primitive type.
            *
            * @param propertyType A value of defined from the LightSwitch value model.
            */
            Utils.isPrimitiveType = function (propertyType) {
                var p = propertyType.__isPrimitiveType;
                return p === undefined ? false : p !== 0;
            };

            /**
            * Get a @see:TypeDesc value of a property.
            *
            * @param propertyType A value of defined from the LightSwitch value model.
            */
            Utils.getTypeDesc = function (propertyType) {
                var pt = propertyType, format;

                while (!Utils.isPrimitiveType(pt)) {
                    pt = pt.underlyingType;
                }

                var type = (pt.name === 'Decimal') ? 'Number' : pt.jSType;

                if (pt.name === 'Int16' || pt.name === 'Int32' || pt.name === 'Int64') {
                    format = 'n0';
                    type = 'Number';
                }

                return {
                    type: type,
                    format: format,
                    underlying: pt.name
                };
            };

            /**
            * Return a @see:ColumnModel Array from contentItem.
            *
            * @param contentItem A object of defined from the LightSwitch content item.
            */
            Utils.buildColumnsModel = function (contentItem) {
                var columnsModel = [];

                if (contentItem.children.length > 0) {
                    var first = contentItem.children[0];

                    var createColumn = function (col) {
                        if (col.kind === 'Details') {
                            var context = this.slice(0);
                            context.push(col.valueModel.name);
                            if (col.children.length > 1) {
                                col.children.forEach(createColumn, context);
                            } else {
                                var summary = col.valueModel.elementType[':@SummaryProperty'].property.name;
                                columnsModel.push({
                                    header: col.displayName,
                                    binding: col.name + "-" + summary,
                                    innerBinding: summary,
                                    visible: col.isVisible,
                                    dataType: 'Summary',
                                    columnName: col.name,
                                    properties: col.properties,
                                    required: !Utils.isNullableType(col.valueModel.propertyType),
                                    context: context
                                });
                            }
                        } else if (col.kind === 'Value') {
                            if (Utils.isImageType(col.valueModel.propertyType)) {
                                columnsModel.push({
                                    header: col.displayName,
                                    binding: col.valueModel.name + "-Image",
                                    innerBinding: col.valueModel.name,
                                    visible: col.isVisible,
                                    dataType: 'Image',
                                    columnName: col.valueModel.name,
                                    properties: col.properties,
                                    required: !Utils.isNullableType(col.valueModel.propertyType)
                                });
                            } else {
                                var typeDesc = Utils.getTypeDesc(col.valueModel.propertyType);
                                if (typeDesc.type !== 'Array') {
                                    columnsModel.push({
                                        header: col.displayName,
                                        binding: col.valueModel.name,
                                        visible: col.isVisible,
                                        dataType: typeDesc.type,
                                        columnName: col.valueModel.name,
                                        properties: col.properties,
                                        required: !Utils.isNullableType(col.valueModel.propertyType),
                                        supportedValues: col.valueModel[':@SupportedValue'],
                                        context: this
                                    });
                                }
                            }
                        }
                    };

                    first.children.forEach(createColumn, []);
                }

                return columnsModel;
            };

            /**
            * Bind a set of pager button state to a @see:LightSwitchCollectionView.
            *
            * @param screen LightSwitch screen object.
            * @param lightSwitchCollectionView LightSwitch collection view object.
            * @param PagerOptions Object that contains previous page and next page command name.
            */
            Utils.bindPagerState = function (screen, lightSwitchCollectionView, pagerOptions) {
                var prevCmd, nextCmd;
                lightSwitchCollectionView.pageChanged.addHandler(function () {
                    if (pagerOptions) {
                        if (typeof pagerOptions.previous === 'string') {
                            prevCmd = screen.findContentItem(pagerOptions.previous);

                            if (prevCmd) {
                                prevCmd.isEnabled = lightSwitchCollectionView.pageIndex > 0;
                                prevCmd.isVisible = lightSwitchCollectionView.enablePaging;
                            }
                        }

                        if (typeof pagerOptions.next === 'string') {
                            nextCmd = screen.findContentItem(pagerOptions.next);

                            if (nextCmd) {
                                nextCmd.isEnabled = lightSwitchCollectionView.pageIndex < lightSwitchCollectionView.pageCount - 1;
                                nextCmd.isVisible = lightSwitchCollectionView.enablePaging;
                            }
                        }
                    }
                });
            };

            /**
            * Bind a custom event handler to a callback property of object.
            *
            * @param object Object with custom event handler to bind.
            * @param eventName String of callback property name.
            * @param handler Custom event handler.
            */
            Utils.bindCustomEventHandler = function (object, eventName, handler) {
                var customEventHandlers = '_' + eventName + 'CustomHandlers';

                if (!object[customEventHandlers]) {
                    object[customEventHandlers] = [];
                }
                object[customEventHandlers].push(handler);

                object[eventName] = function () {
                    var self = this, args = arguments, customHandlers = object[customEventHandlers];
                    if (customHandlers) {
                        customHandlers.forEach(function (val) {
                            val.apply(self, args);
                        });
                    }
                };
            };

            /**
            * Set a property value by jsonString.
            *
            * @param object Object with property value to set.
            * @param propertyName String of property name.
            * @param jsonString Json string.
            */
            Utils.setPropertyValueFromJson = function (object, propertyName, jsonString, bypassNullValues) {
                if (typeof bypassNullValues === "undefined") { bypassNullValues = true; }
                if (!object[propertyName]) {
                    object[propertyName] = {};
                }
                Utils.restoreFromJson(object[propertyName], jsonString, bypassNullValues);
            };

            /**
            * Restore property values by jsonString.
            *
            * @param object Object with property value to set.
            * @param jsonString Json string.
            */
            Utils.restoreFromJson = function (obj, jsonString, bypassNullValues) {
                if (typeof bypassNullValues === "undefined") { bypassNullValues = true; }
                var jsonObj = $.parseJSON(jsonString);

                $.each(jsonObj, function (key, val) {
                    if (!bypassNullValues || val !== null && val !== undefined && val !== "") {
                        obj[key] = val;
                    }
                });
            };
            return Utils;
        })();
        cba.Utils = Utils;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Util.js.map

﻿/// <reference path="../../../../Shared/WijmoNxt/HTML5/Controls/dist/controls/wijmo.ts" />
/// <reference path="../Util/Util.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * LightSwitchCollectionView.js
    */
    (function (cba) {
        var $ = jQuery;

        

        

        /**
        * Extends @see:CollectionView to support LightSwitch.
        *
        * You can use the result objects from the LightSwitch data service as data sources for any Wijmo controls,
        * and in addition to full CRUD support and real-time updates you automatically get
        * CollectionView features including sorting, filtering, paging, grouping, and editing.
        */
        var LightSwitchCollectionView = (function (_super) {
            __extends(LightSwitchCollectionView, _super);
            /**
            * Initializes a new instance of a @see:LightSwitchCollectionView.
            *
            * @param contentItem A value of defined from the LightSwitch content item.
            * @param pagerOptions @see:PagerOptions that contains the page commands.
            */
            function LightSwitchCollectionView(contentItem) {
                _super.call(this);
                this._enableVirtualScrolling = false;
                this._initialItemsCount = 100;
                this._skip = 0;
                this._top = 0;
                this._dataLength = 0;
                var self = this;
                self._contentItem = contentItem;

                self._initialize(contentItem);
                self._bindSelection(contentItem);

                self.sortDescriptions.collectionChanged.removeAllHandlers();
                self.sortDescriptions.collectionChanged.addHandler(self._sortDescriptionsChangedHandler.bind(self));

                cba.Utils.bindCustomEventHandler(contentItem.value, 'oncollectionchange', self._contentItemCollectionChangeHandler.bind(self));
                cba.Utils.bindCustomEventHandler(contentItem.screen.details.dataWorkspace.details, 'onchange', self._dataWorkspaceChangeHandler.bind(self));
            }
            LightSwitchCollectionView.prototype._initialize = function (contentItem) {
                var self = this, value = contentItem.value;
                self.pageSize = contentItem.valueModel.pageSize;
                self._columnsModel = cba.Utils.buildColumnsModel(contentItem);
                self._setGroupDescriptions(contentItem);
                self._enableVirtualScrolling = contentItem.properties.enableVirtualScrolling && contentItem.properties.isReadOnly;
                self._initialItemsCount = contentItem.properties.initialItemsCount;

                if (value.isLoaded) {
                    self._updateData(value);
                }
            };

            LightSwitchCollectionView.prototype._bindSelection = function (contentItem) {
                var self = this;

                self.currentChanged.addHandler(function () {
                    if (self._contentItem.value.selectedItem !== self.currentItem) {
                        self._contentItem.value.selectedItem = self.currentItem;
                    }
                });

                cba.Utils.bindCustomEventHandler(contentItem.value, 'onchange', function (args) {
                    switch (args.detail) {
                        case 'selectedItem':
                            if (self._contentItem.value.selectedItem !== self.currentItem) {
                                self.moveCurrentTo(self._contentItem.value.selectedItem);
                            }
                            break;
                    }
                });
            };

            LightSwitchCollectionView.prototype._sortDescriptionsChangedHandler = function () {
                var self = this, arr = self.sortDescriptions;
                for (var i = 0; i < arr.length; i++) {
                    var sd = wijmo.tryCast(arr[i], wijmo.collections.SortDescription);
                    if (!sd) {
                        throw 'sortDescriptions array must contain SortDescription objects.';
                    }
                }
                if (self.canSort) {
                    self.sourceCollection.length = 0;
                    self._skip = 0;
                    self._top = self._initialItemsCount;
                    window["msls"].application.applyChanges().then(function success() {
                        self._reloadData(function (data) {
                            self._totalItemCount = data.totalCount;
                            self._contentItem.value._data = data.results;

                            if (self._enableVirtualScrolling) {
                                self._updateSourceCollection(data.results, self._skip, self._top);

                                // selection is invalid now, clear it.
                                self.moveCurrentToPosition(-1);
                            } else {
                                self.sourceCollection = data.results;
                            }

                            self.onPageChanged();
                            self.refresh();
                        });
                    });
                }
            };

            LightSwitchCollectionView.prototype._setGroupDescriptions = function (contentItem) {
                var self = this, p = contentItem.properties;
                if (p.groupDescriptions) {
                    $.each(p.groupDescriptions.split(','), function (index, val) {
                        if (val && val.trim() !== '')
                            self.groupDescriptions.push(self._createPropertyGroupDescription(val.trim()));
                    });
                }
            };

            LightSwitchCollectionView.prototype._createPropertyGroupDescription = function (propName) {
                var self = this, displayName = self._getDisplayNameByPropertyName(propName);
                return new wijmo.collections.PropertyGroupDescription(displayName, function (item, name) {
                    return item[self._getBindingNameByDisplayName(name)];
                });
            };

            LightSwitchCollectionView.prototype._getDisplayNameByPropertyName = function (propertyName) {
                var displayName = propertyName;
                $.each(this._columnsModel, function (index, col) {
                    if (col.innerBinding === propertyName || col.binding === propertyName) {
                        displayName = col.header;
                    }
                });
                return displayName;
            };

            LightSwitchCollectionView.prototype._getBindingNameByDisplayName = function (displayName) {
                var bindingName = displayName;
                $.each(this._columnsModel, function (index, col) {
                    if (col.header === displayName) {
                        bindingName = col.binding;
                    }
                });
                return bindingName;
            };

            LightSwitchCollectionView.prototype._getColumnNameByBinding = function (binding) {
                var self = this, columnName = binding;
                $.each(self._columnsModel, function (index, col) {
                    if (col.columnName && col.binding === binding) {
                        columnName = col.columnName;
                    }
                });
                return columnName;
            };

            LightSwitchCollectionView.prototype._contentItemCollectionChangeHandler = function (args) {
                var self = this;
                self._updateData(self._contentItem.value, args);
            };

            LightSwitchCollectionView.prototype._updateData = function (value, args) {
                var self = this;
                self._processContentItemData(value.data);
                self.sourceCollection = value.data;
                self.onPageChanged();

                if (args && args.detail.action !== msls.CollectionChangeAction.refresh) {
                    self.onCollectionChanged();
                    return;
                }

                if (self._enableVirtualScrolling && value.data.length < self._initialItemsCount) {
                    self._skip = 0;
                    self._dataLength = value.data.length;
                    self.requestItems(0, self._initialItemsCount);
                } else {
                    self._updateTotalItemCount();
                }
            };

            LightSwitchCollectionView.prototype._dataWorkspaceChangeHandler = function () {
                var e = new wijmo.collections.NotifyCollectionChangedEventArgs(2 /* Change */);
                this.onCollectionChanged(e);
            };

            LightSwitchCollectionView.prototype._processContentItemData = function (data) {
                var self = this, dataItem, columnContext, oldType, converterProperty, protoVal;
                $.each(data, function (index, val) {
                    $.each(self._columnsModel, function (index, column) {
                        switch (column.dataType) {
                            case "Summary":
                                dataItem = val;
                                if (dataItem && column.context !== undefined) {
                                    columnContext = column.context.slice(0);
                                    while (columnContext.length > 0) {
                                        dataItem = dataItem[columnContext.shift()];
                                    }

                                    if (dataItem && dataItem[column.innerBinding] !== undefined) {
                                        val[column.binding] = dataItem[column.innerBinding];
                                    }
                                }
                                break;
                            case "Image":
                                val[column.binding] = '<img src="data:image;base64,' + val[column.innerBinding] + '"/>';
                                break;
                            case "Number":
                                converterProperty = {};
                                converterProperty[column.binding] = {
                                    set: function (value) {
                                        protoVal = Object.getPrototypeOf(val);
                                        protoVal.details = val.details;
                                        switch (value) {
                                            case null:
                                            case undefined:
                                            case "":
                                                protoVal[column.binding] = null;
                                                break;
                                            default:
                                                if (!isNaN(parseFloat(value))) {
                                                    oldType = typeof protoVal[column.binding];
                                                    protoVal[column.binding] = (oldType === "string" ? String(value) : value);
                                                }
                                                break;
                                        }
                                    },
                                    get: function () {
                                        protoVal = Object.getPrototypeOf(val);
                                        protoVal.details = val.details;
                                        var value = parseFloat(protoVal[column.binding]);
                                        return isNaN(value) ? null : value;
                                    },
                                    enumerable: true,
                                    configurable: true
                                };
                                Object.defineProperties(val, converterProperty);
                                break;
                        }
                    });
                });
            };

            /**
            * Override _getPageView to get the list that corresponds to the current page
            */
            LightSwitchCollectionView.prototype._getPageView = function () {
                return this._view;
            };

            Object.defineProperty(LightSwitchCollectionView.prototype, "totalItemCount", {
                /**
                * Gets the total number of items in the view before paging is applied.
                */
                get: function () {
                    return this._totalItemCount;
                },
                enumerable: true,
                configurable: true
            });

            Object.defineProperty(LightSwitchCollectionView.prototype, "pageCount", {
                /**
                * Override pageCount to get the total number pages.
                */
                get: function () {
                    var self = this;
                    return self.pageSize ? Math.ceil(self.totalItemCount / self.pageSize) : 1;
                },
                enumerable: true,
                configurable: true
            });

            Object.defineProperty(LightSwitchCollectionView.prototype, "enablePaging", {
                /**
                * @Ignore
                * Get a value indicating whether paging is enabled. For internal use.
                */
                get: function () {
                    var self = this;
                    return !self._contentItem.valueModel.disablePaging;
                },
                enumerable: true,
                configurable: true
            });

            /**
            * Override moveToPage to Moves the page at the specified index.
            *
            * @param index Index of the page to move to.
            * @return True if the page index was changed successfully.
            */
            LightSwitchCollectionView.prototype.moveToPage = function (index) {
                var self = this, newIndex = wijmo.clamp(index, 0, self.pageCount - 1);
                if (newIndex != self._pgIdx) {
                    // honor canChangePage
                    if (!self._canChangePage) {
                        wijmo.assert(false, 'Changing pages not supported.');
                    }

                    // raise pageChanging
                    var e = new wijmo.collections.PageChangingEventArgs(newIndex);
                    if (self.onPageChanging(e)) {
                        // change the page
                        self._pgIdx = newIndex;
                        self._idx = 0;

                        self._reloadData(function (data) {
                            self._totalItemCount = data.totalCount;
                            self.sourceCollection = self._contentItem.value._data = data.results;
                            self.onPageChanged();
                            self.onCollectionChanged();
                        });
                    }
                }
                return this._pgIdx == index;
            };

            LightSwitchCollectionView.prototype._reloadData = function (callback, showProgress) {
                if (typeof showProgress === "undefined") { showProgress = true; }
                var self = this, sortDescs = self.sortDescriptions, query = self._contentItem.value._loader._baseQuery, sortBy;

                if (query) {
                    if (sortDescs) {
                        $.each(sortDescs, function (index, val) {
                            sortBy = self._getColumnNameByBinding(val.property);
                            if (val.ascending) {
                                query = query.orderBy(sortBy);
                            } else {
                                query = query.orderByDescending(sortBy);
                            }
                        });
                    }

                    if (self._enableVirtualScrolling) {
                        query = query.skip(self._skip);
                        query = query.top(self._top);
                    } else if (self.enablePaging) {
                        query = query.skip(self.pageIndex * self.pageSize);
                        query = query.top(self.pageSize);
                    }

                    query = query.includeTotalCount();

                    self._doQuery(query, function (data) {
                        self._processContentItemData(data.results);
                        if ($.isFunction(callback)) {
                            callback(data);
                        }
                    }, showProgress);
                }
            };

            LightSwitchCollectionView.prototype._updateTotalItemCount = function () {
                var self = this, query = self._contentItem.value._loader._baseQuery;

                if (query) {
                    query = query.skip(0);
                    query = query.top(1);
                    query = query.includeTotalCount();
                    self._doQuery(query, function (data) {
                        self._totalItemCount = data.totalCount;
                        if (self._enableVirtualScrolling) {
                            self.sourceCollection.length = self._totalItemCount;
                            self.onCollectionChanged();
                        } else {
                            self._pgIdx = 0;
                            self.onPageChanged();
                        }
                    }, false);
                }
            };

            LightSwitchCollectionView.prototype._doQuery = function (query, callback, showProgress) {
                if (typeof showProgress === "undefined") { showProgress = true; }
                var self = this;
                if (showProgress) {
                    msls.showProgress(msls.promiseOperation(function (op) {
                        query.execute().then(function (result) {
                            op.complete(result);
                        }, function (error) {
                            op.error(error);
                        });
                    }).then(function success(data) {
                        if ($.isFunction(callback)) {
                            callback(data);
                        }
                    }, function failure(error) {
                    }));
                } else {
                    query.execute().then(function success(data) {
                        if ($.isFunction(callback)) {
                            callback(data);
                        }
                    }, function failure(error) {
                    });
                }
            };

            /**
            * Prepare the items from startRow to endRow.
            */
            LightSwitchCollectionView.prototype.requestItems = function (startRow, endRow) {
                var self = this, count, rowRange, end, skip, top;
                if (!self._enableVirtualScrolling) {
                    return;
                }

                // judge whether caches include startRow or EndRow
                // only three times of current view range are used to judge whether the items are queried from server side.
                count = Math.max(0, endRow - startRow + 1);
                rowRange = self._caculateRangeRow(startRow, endRow, count);
                end = self._skip + self._dataLength - 1;
                if (self._skip <= rowRange.start && end >= rowRange.end) {
                    return;
                }

                // Add two times more for querying if the requested items are not in cache.
                rowRange = self._caculateRangeRow(rowRange.start, rowRange.end, count);
                self._skip = skip = rowRange.start;
                self._top = top = Math.max(0, rowRange.end - rowRange.start + 1);

                self._reloadData(function (data) {
                    self._totalItemCount = data.totalCount;
                    self._contentItem.value._data = data.results;
                    self._updateSourceCollection(data.results, skip, top);
                }, false);
            };

            LightSwitchCollectionView.prototype._updateSourceCollection = function (data, skip, top) {
                var self = this;
                self._skip = skip;
                self._dataLength = data.length;
                self.sourceCollection.length = self._totalItemCount;
                data.forEach(function (item, index) {
                    var si = index + skip;
                    if (si >= self._totalItemCount || si < 0) {
                        throw 'The index of item is out of range.';
                    }

                    //override the item with the specified index.
                    self.sourceCollection[si] = item;
                    self.items[si] = item;
                });
                self.onCollectionChanged();
            };

            LightSwitchCollectionView.prototype._caculateRangeRow = function (startRow, endRow, count) {
                startRow = Math.max(0, startRow - count);
                endRow = endRow + count;
                return { start: startRow, end: endRow };
            };
            return LightSwitchCollectionView;
        })(wijmo.collections.CollectionView);
        cba.LightSwitchCollectionView = LightSwitchCollectionView;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=LightSwitchCollectionView.js.map

﻿/// <reference path="../Shared/Control.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (cba) {
        /*
        * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
        * Control.js
        */
        (function (wrapper) {
            var $ = jQuery;

            /**
            * Base class for all Wijmo control wrappers.
            */
            var Wrapper = (function (_super) {
                __extends(Wrapper, _super);
                function Wrapper(element) {
                    _super.call(this, element);

                    var self = this;
                    if (msls.subscribe && $.isFunction(msls.subscribe)) {
                        msls.subscribe("CommandProgressComplete", function () {
                            self.wjControl.refresh();
                        });

                        msls.subscribe("mslsnavigationcomplete", function () {
                            self.wjControl.refresh();
                        });
                    }
                }
                return Wrapper;
            })(c1.wrapper.Wrapper);
            wrapper.Wrapper = Wrapper;
        })(cba.wrapper || (cba.wrapper = {}));
        var wrapper = cba.wrapper;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Control.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Grid.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * Grid.js
    */
    (function (cba) {
        var $ = jQuery;

        /**
        * Extends @see:Control which contains a @see:FlexGrid control to support LightSwitch.
        *
        * The @see:FlexGrid control is a full-featured grid, providing all the
        * features you are used to including several selection modes, sorting,
        * column reordering, grouping, filtering, editing, custom cells,
        * XAML-style star-sizing columns, row and column virtualization, etc.
        */
        var FlexGrid = (function (_super) {
            __extends(FlexGrid, _super);
            /**
            * Initializes a new instance of a @see:FlexGrid control.
            *
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function FlexGrid(element, contentItem, options) {
                _super.call(this, element);
                var self = this;
                if (options)
                    self.initialize(options);

                self._contentItem = contentItem;
                self._setGridProperties(contentItem.properties);

                self.initialize({
                    autoGenerateColumns: false,
                    columns: self._buildGridColumns(contentItem)
                });

                // fix the FlexGrid scroll bar style errors in IE10/11.
                $(self.grid.hostElement).css('-ms-overflow-style', 'auto');

                // remove msls-vscroll and msls-hscroll, use flexgrid scroll bar.
                $(self.grid.hostElement).parent().removeClass('msls-vscroll').removeClass('msls-hscroll');

                // fix when press "Esc" key in cell editing mode, it navigates to the other screen.
                $(self.grid.hostElement).on("keydown", function (e) {
                    if (e.keyCode === 27) {
                        e.stopPropagation();
                    }
                });

                self.grid.formatItem.addHandler(function (sender, args) {
                    self._updateGridRowHeader(args);
                });

                self.grid.cellEditEnding.addHandler(function (sender, args) {
                    sender.beginUpdate();
                });

                self.grid.cellEditEnded.addHandler(function (sender, args) {
                    sender.endUpdate();
                });

                self.grid.sortedColumn.addHandler(function (sender, args) {
                    if (contentItem.properties.enableVirtualScrolling) {
                        self.grid.scrollPosition = new wijmo.Point(self.grid.scrollPosition.x, 0);
                    }
                });

                if (contentItem.properties.enableVirtualScrolling && contentItem.properties.isReadOnly) {
                    self.grid.scrollPositionChanged.addHandler(self._scrolling, self);
                }
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            FlexGrid.prototype.getWjCtor = function () {
                return c1.grid.FlexGrid;
            };

            Object.defineProperty(FlexGrid.prototype, "grid", {
                get: function () {
                    return this.wjControl;
                },
                enumerable: true,
                configurable: true
            });

            FlexGrid.prototype._buildGridColumns = function (contentItem) {
                var self = this, columnsModel = cba.Utils.buildColumnsModel(contentItem), col;
                return $.map(columnsModel, function (columnModel) {
                    if (columnModel.visible) {
                        switch (columnModel.dataType) {
                            case 'Summary':
                                col = {
                                    header: columnModel.header,
                                    binding: columnModel.binding,
                                    allowMerging: false,
                                    allowSorting: false,
                                    isReadOnly: true
                                };
                                self._setColumnWidth(col, columnModel.properties);
                                return col;
                            case 'Image':
                                col = self._createDefaultColumn(columnModel);
                                col.allowMerging = false;
                                col.allowSorting = false;
                                col.isContentHtml = true;
                                col.isReadOnly = true;
                                return col;
                            default:
                                col = self._createDefaultColumn(columnModel);
                                col.dataType = columnModel.dataType;
                                col.isReadOnly = (columnModel.context && columnModel.context.length > 0) || columnModel.properties.isReadOnly;
                                col.aggregate = columnModel.properties.aggregate;
                                col.required = columnModel.required;

                                if (columnModel.supportedValues && columnModel.supportedValues.length > 0) {
                                    $.each(columnModel.supportedValues, function (index, val) {
                                        if (!val.displayName) {
                                            val.displayName = String(val.value);
                                        }
                                    });
                                    col.dataMap = new wijmo.grid.DataMap(columnModel.supportedValues, "value", "displayName");
                                }
                                return col;
                        }
                    }
                });
            };

            FlexGrid.prototype._createDefaultColumn = function (columnModel) {
                var self = this, p = columnModel.properties, col = {
                    header: columnModel.header,
                    binding: columnModel.binding,
                    visible: columnModel.visible,
                    allowDragging: p.allowDragging,
                    allowMerging: p.allowMerging,
                    allowResizing: p.allowResizing,
                    allowSorting: p.allowSorting,
                    isContentHtml: p.isContentHtml,
                    align: p.align,
                    cssClass: p.cssClass,
                    format: p.format,
                    wordWrap: p.wordWrap
                };

                self._setColumnWidth(col, p);
                return col;
            };

            FlexGrid.prototype._setColumnWidth = function (col, properties) {
                if (properties.columnWidth) {
                    col.width = isNaN(Number(properties.columnWidth)) ? properties.columnWidth : Number(properties.columnWidth);
                }
                if (properties.columnMinWidth && !isNaN(Number(properties.columnMinWidth))) {
                    col.minWidth = Number(properties.columnMinWidth);
                }
                if (properties.columnMaxWidth && !isNaN(Number(properties.columnMaxWidth))) {
                    col.maxWidth = Number(properties.columnMaxWidth);
                }
            };

            FlexGrid.prototype._setGridProperties = function (properties) {
                var self = this, grid = self.grid;
                grid.autoGenerateColumns = false;
                grid.isReadOnly = properties.isReadOnly;
                grid.allowDragging = properties.allowDragging;
                grid.allowMerging = properties.allowMerging;
                grid.allowResizing = properties.allowResizing;
                grid.headersVisibility = properties.headersVisibility;
                grid.selectionMode = properties.selectionMode;
                grid.groupHeaderFormat = properties.groupHeaderFormat;
                grid.allowSorting = properties.allowSorting;
                grid.showGroups = properties.showGroups;
                grid.showSort = properties.showSort;
                grid.autoClipboard = properties.autoClipboard;
                grid.frozenRows = properties.frozenRows;
                grid.frozenColumns = properties.frozenColumns;
                grid.treeIndent = properties.treeIndent;
            };

            FlexGrid.prototype._updateGridRowHeader = function (args) {
                var self = this, grid = self.grid, dataItem;

                if (args.panel === grid.rowHeaders) {
                    dataItem = grid.rows[args.row].dataItem;

                    if (dataItem && dataItem.details) {
                        switch (dataItem.details.entityState) {
                            case msls.EntityState.added:
                                $(args.cell).text('+');
                                break;
                            case msls.EntityState.modified:
                                $(args.cell).text('\u270E');
                                break;
                            case msls.EntityState.deleted:
                                $(args.cell).text('x');
                                break;
                        }
                    }
                }
            };

            FlexGrid.prototype._scrolling = function () {
                var self = this, viewRange = self.grid.viewRange;
                self._prepareRequest(viewRange.row, viewRange.row2);
            };

            FlexGrid.prototype._prepareRequest = function (startRow, endRow) {
                var self = this, currentViewRange, cv = self.grid.collectionView;

                window.setTimeout(function () {
                    currentViewRange = self.grid.viewRange;
                    if (currentViewRange.row == startRow && currentViewRange.row2 == endRow) {
                        cv.requestItems(startRow, endRow);
                    } else {
                        self._prepareRequest(currentViewRange.row, currentViewRange.row2);
                    }
                }, 100);
            };
            return FlexGrid;
        })(cba.wrapper.Wrapper);
        cba.FlexGrid = FlexGrid;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Grid.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Chart.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * FlexChart.js
    */
    (function (cba) {
        var $ = jQuery;

        var FlexChartBase = (function (_super) {
            __extends(FlexChartBase, _super);
            function FlexChartBase() {
                _super.apply(this, arguments);
            }
            return FlexChartBase;
        })(cba.wrapper.Wrapper);
        cba.FlexChartBase = FlexChartBase;

        var FlexPie = (function (_super) {
            __extends(FlexPie, _super);
            /**
            * Initializes a new instance of a @see:FlexPie control.
            *
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function FlexPie(element, contentItem, options) {
                _super.call(this, element);

                var self = this;

                self._contentItem = contentItem;
                self._setProperties(contentItem.properties);
                if (options)
                    self.initialize(options);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            FlexPie.prototype.getWjCtor = function () {
                return c1.chart.FlexPie;
            };

            Object.defineProperty(FlexPie.prototype, "pie", {
                get: function () {
                    return this.wjControl;
                },
                enumerable: true,
                configurable: true
            });

            FlexPie.prototype._setProperties = function (properties) {
                var self = this, p = properties, pieProperties = [
                    "binding",
                    "bindingName",
                    "dataLabel",
                    "disabled",
                    "footer",
                    "footerStyle",
                    "header",
                    "headerStyle",
                    "innerRadius",
                    "isAnimated",
                    "legendPosition",
                    "offset",
                    "palette",
                    "plotMargin",
                    "reversed",
                    "selectedItemOffset",
                    "selectedItemPosition",
                    "selectionMode",
                    "startAngle",
                    "tooltip"
                ], val, selectedIndex;

                $.each(pieProperties, function (index, propertyName) {
                    val = p[propertyName];
                    if (val !== null && val !== undefined && val !== "") {
                        switch (propertyName) {
                            case "dataLabel":
                            case "footerStyle":
                            case "headerStyle":
                                cba.Utils.setPropertyValueFromJson(self.pie, propertyName, val);
                                break;
                            case "tooltip":
                                cba.Utils.setPropertyValueFromJson(self.pie, propertyName, val, false);
                                break;
                            case "legendPosition":
                                self.pie.legend.position = val;
                                break;
                            case "palette":
                                self.pie.palette = wijmo.chart.Palettes[val];
                                break;
                            default:
                                self.pie[propertyName] = val;
                        }
                    }
                });
            };
            return FlexPie;
        })(FlexChartBase);
        cba.FlexPie = FlexPie;

        var FlexChart = (function (_super) {
            __extends(FlexChart, _super);
            /**
            * Initializes a new instance of a @see:FlexChart control.
            *
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function FlexChart(element, contentItem, options) {
                _super.call(this, element);

                var self = this, series = [], trendLines = [];

                self._contentItem = contentItem;
                self._buildChartSeries(contentItem, series, trendLines);

                self.initialize({
                    "series": series
                });

                self._setChartProperties(contentItem.properties);

                // Before add trendLine series, need to ensure the data is loaded.
                if (contentItem.value.isLoaded) {
                    self._processTrendLines(trendLines);
                } else {
                    cba.Utils.bindCustomEventHandler(contentItem.value, 'oncollectionchange', function () {
                        self._processTrendLines(trendLines);
                    });
                }

                if (options)
                    self.initialize(options);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            FlexChart.prototype.getWjCtor = function () {
                return c1.chart.FlexChart;
            };

            Object.defineProperty(FlexChart.prototype, "chart", {
                get: function () {
                    return this.wjControl;
                },
                enumerable: true,
                configurable: true
            });

            FlexChart.prototype._processTrendLines = function (trendLines) {
                var _this = this;
                if (trendLines.length > 0) {
                    setTimeout(function () {
                        while (trendLines.length > 0) {
                            _this.chart.series.push(trendLines.shift());
                        }
                    }, 100);
                }
            };

            FlexChart.prototype._buildChartSeries = function (contentItem, series, trendLines) {
                var self = this, columnsModel = cba.Utils.buildColumnsModel(contentItem), p, tl;
                $.each(columnsModel, function (index, columnModel) {
                    if (columnModel.dataType !== "Summary" && columnModel.dataType !== "Image") {
                        p = columnModel.properties;
                        if (p["chartType"] === "TrendLine") {
                            trendLines.push(self._createSeries(columnModel));
                        } else {
                            series.push(self._createSeries(columnModel));
                        }
                    }
                });
            };

            FlexChart.prototype._createSeries = function (columnModel) {
                var self = this, p = columnModel.properties, series = p["chartType"] === "TrendLine" ? new wijmo.chart.analytics.TrendLine() : {}, seriesProperties = [
                    "axisX",
                    "axisY",
                    "binding",
                    "chartType",
                    "cssClass",
                    "style",
                    "symbolMarker",
                    "symbolSize",
                    "symbolStyle",
                    "visibility"
                ], val;

                series["name"] = columnModel.header;
                series["binding"] = columnModel.binding;

                $.each(seriesProperties, function (index, propertyName) {
                    val = p[propertyName];
                    if (val !== null && val !== undefined && val !== "") {
                        switch (propertyName) {
                            case "axisX":
                            case "axisY":
                                self._setSeriesAxis(series, propertyName, val);
                                break;
                            case "style":
                            case "symbolStyle":
                                cba.Utils.setPropertyValueFromJson(series, propertyName, val);
                                break;
                            case "chartType":
                                if (val === "TrendLine") {
                                    break;
                                }
                            default:
                                series[propertyName] = val;
                        }
                    }
                });

                if (p["chartType"] === "TrendLine") {
                    series["bindingX"] = self._contentItem.properties["bindingX"];
                    if (p["trendLineSettings"]) {
                        cba.Utils.restoreFromJson(series, p["trendLineSettings"]);
                    }
                }

                return series;
            };

            FlexChart.prototype._setSeriesAxis = function (series, propertyName, jsonString) {
                var self = this, jsonObj = $.parseJSON(jsonString), axis = new wijmo.chart.Axis();
                switch (propertyName) {
                    case "axisX":
                        axis.axisType = 0 /* X */;
                        break;
                    case "axisY":
                        axis.axisType = 1 /* Y */;
                        break;
                }

                $.each(jsonObj, function (key, val) {
                    if (val !== undefined && val !== null && val !== "") {
                        axis[key] = val;
                    }
                });

                series[propertyName] = axis;
            };

            FlexChart.prototype._setChartProperties = function (properties) {
                var self = this, chart = self.chart, p = properties, chartProperties = [
                    "axisX",
                    "axisY",
                    "bindingX",
                    "chartType",
                    "dataLabel",
                    "disabled",
                    "footer",
                    "footerStyle",
                    "header",
                    "headerStyle",
                    "interpolateNulls",
                    "legendPosition",
                    "legendToggle",
                    "options",
                    "palette",
                    "plotMargin",
                    "rotated",
                    "selection",
                    "selectionMode",
                    "stacking",
                    "symbolSize",
                    "tooltip"
                ], val, selectedIndex;

                $.each(chartProperties, function (index, propertyName) {
                    val = p[propertyName];
                    if (val !== null && val !== undefined && val !== "") {
                        switch (propertyName) {
                            case "axisX":
                            case "axisY":
                            case "dataLabel":
                            case "footerStyle":
                            case "headerStyle":
                                cba.Utils.setPropertyValueFromJson(chart, propertyName, val);
                                break;
                            case "tooltip":
                                cba.Utils.setPropertyValueFromJson(chart, propertyName, val, false);
                                break;
                            case "options":
                                self._setChartOptions(val);
                                break;
                            case "legendPosition":
                                chart.legend.position = val;
                                break;
                            case "palette":
                                chart.palette = wijmo.chart.Palettes[val];
                                break;
                            case "selection":
                                if (p["selectionMode"] === "Series") {
                                    selectedIndex = $.inArray(val, $.map(chart.series, function (val) {
                                        return val.binding;
                                    }));
                                    if (selectedIndex !== -1) {
                                        chart.selection = chart.series[selectedIndex];
                                    }
                                }
                                break;
                            default:
                                chart[propertyName] = val;
                        }
                    }
                });

                if (p["lineMarkers"]) {
                    self._setLineMarkers(p["lineMarkers"]);
                }

                if (p["rangeSelectors"]) {
                    self._setRangeSelectors(p["rangeSelectors"]);
                }
            };

            FlexChart.prototype._setChartOptions = function (jsonString) {
                var self = this, chart = self.chart, opt = $.parseJSON(jsonString), bubbleMinSize = opt.bubbleMinSize, bubbleMaxSize = opt.bubbleMaxSize, groupWidth = opt.groupWidth;

                chart.options = {};
                chart.options.bubble = {};

                if (bubbleMinSize && bubbleMinSize !== undefined && bubbleMinSize !== null) {
                    chart.options.bubble.minSize = bubbleMinSize;
                }

                if (bubbleMaxSize && bubbleMaxSize !== undefined && bubbleMaxSize !== null) {
                    chart.options.bubble.maxSize = bubbleMaxSize;
                }

                if (groupWidth && groupWidth !== undefined && groupWidth !== null && groupWidth !== "") {
                    chart.options.groupWidth = groupWidth;
                }
                chart.refresh();
            };

            FlexChart.prototype._setLineMarkers = function (jsonString) {
                var self = this, jsonObj = $.parseJSON(jsonString), lineMarker, content, alignment;

                // the HTMLElement does not contain the dataset property in LS, LineMarker will run error.
                if (!self.chart.hostElement.dataset)
                    self.chart.hostElement.dataset = {};
                if (!self.chart["extenders"])
                    self.chart["extenders"] = [];

                if (jsonObj && $.isArray(jsonObj)) {
                    $.each(jsonObj, function (index, val) {
                        content = val.content;
                        alignment = val.alignment;

                        if (content && typeof window[content] === "function") {
                            val.content = window[content];
                        }

                        switch (alignment) {
                            case "Auto":
                                val.alignment = 2;
                                break;
                            case "Left":
                                val.alignment = 1;
                                break;
                            case "Top":
                                val.alignment = 6;
                                break;
                            case "Right":
                                val.alignment = 0;
                                break;
                            case "Bottom":
                                val.alignment = 4;
                                break;
                            default:
                                break;
                        }

                        lineMarker = new c1.chart.LineMarker(self.chart, val);
                        c1.addExtender(self.chart, "lineMarker" + index, lineMarker);
                        self.chart["extenders"].push(lineMarker);
                    });
                }
            };

            FlexChart.prototype._setRangeSelectors = function (jsonString) {
                var self = this, jsonObj = $.parseJSON(jsonString), rangeSelector;
                if (!self.chart["extenders"])
                    self.chart["extenders"] = [];

                if (jsonObj && $.isArray(jsonObj)) {
                    $.each(jsonObj, function (index, val) {
                        rangeSelector = new c1.chart.interaction.RangeSelector(self.chart, val);
                        c1.addExtender(self.chart, "rangeSelector" + index, rangeSelector);
                        self.chart["extenders"].push(rangeSelector);
                    });
                }
            };
            return FlexChart;
        })(FlexChartBase);
        cba.FlexChart = FlexChart;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.js.map

﻿/// <reference path="../Shared/Chart.Interaction.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (cba) {
        /**
        * The @see:RangeSelector control extends from @see:c1.chart.interaction.RangeSelector.
        */
        var RangeSelector = (function (_super) {
            __extends(RangeSelector, _super);
            function RangeSelector() {
                _super.apply(this, arguments);
            }
            return RangeSelector;
        })(c1.chart.interaction.RangeSelector);
        cba.RangeSelector = RangeSelector;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.Interaction.js.map

﻿/// <reference path="../Shared/Chart.LineMarker.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    (function (cba) {
        /**
        * The @see:LineMarker control extends from @see:c1.chart.LineMarker.
        */
        var LineMarker = (function (_super) {
            __extends(LineMarker, _super);
            function LineMarker() {
                _super.apply(this, arguments);
            }
            return LineMarker;
        })(c1.chart.LineMarker);
        cba.LineMarker = LineMarker;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Chart.LineMarker.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Gauge.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * Gauge.js
    */
    (function (cba) {
        var $ = jQuery;

        var Gauge = (function (_super) {
            __extends(Gauge, _super);
            /**
            * Initializes a new instance of a @see:Gauge control.
            *
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function Gauge(element, contentItem, options) {
                _super.call(this, element);

                var self = this;
                self.contentItem = contentItem;
                self._initializeGauge(self.gauge);
                if (options)
                    self.initialize(options);
            }
            Object.defineProperty(Gauge.prototype, "gauge", {
                get: function () {
                    return this.wjControl;
                },
                enumerable: true,
                configurable: true
            });

            /**
            * get a porperty list to initialize the Gauge control.
            */
            Gauge.prototype.getPorpertyList = function () {
                return [
                    "disabled",
                    "face",
                    "format",
                    "hasShadow",
                    "isAnimated",
                    "isReadOnly",
                    "max",
                    "min",
                    "origin",
                    "pointer",
                    "ranges",
                    "showRanges",
                    "showText",
                    "step",
                    "thickness"
                ];
            };

            /**
            * Initialize the gauge control.
            */
            Gauge.prototype._initializeGauge = function (gauge) {
                var self = this, p = self.contentItem.properties, val;

                $.each(self.getPorpertyList(), function (index, propertyName) {
                    val = p[propertyName];
                    if (val !== null && val !== undefined && val !== "") {
                        switch (propertyName) {
                            case "face":
                            case "pointer":
                                cba.Utils.setPropertyValueFromJson(gauge, propertyName, val);
                                break;
                            case "ranges":
                                self._setRanges(gauge, val);
                                break;
                            case "origin":
                                val = parseFloat(val);
                                if (!isNaN(val)) {
                                    gauge[propertyName] = val;
                                }
                                break;
                            default:
                                gauge[propertyName] = val;
                        }
                    }
                });

                gauge.valueChanged.addHandler(function () {
                    if (Number(self.contentItem.value) !== Number(gauge.value)) {
                        self.contentItem.value = gauge.value;
                    }
                });

                self.contentItem.dataBind("stringValue", function (newValue) {
                    var val = parseFloat(newValue);
                    if (!isNaN(val) && val !== Number(gauge.value)) {
                        gauge.value = val;
                    }
                });

                //Fix gauge render error on animated LS screen.
                $(window).on("resize", function () {
                    self._deferredRefresh(gauge);
                });
                $(function () {
                    self._deferredRefresh(gauge);
                });
            };

            Gauge.prototype._setRanges = function (gauge, jsonString) {
                var self = this, ranges = $.parseJSON(jsonString), range;
                $.each(ranges, function (index, val) {
                    range = new wijmo.gauge.Range();
                    range.color = val.color;
                    range.max = val.max;
                    range.min = val.min;
                    range.name = val.name;
                    range.thickness = val.thickness;
                    gauge.ranges.push(range);
                });
            };

            Gauge.prototype._deferredRefresh = function (gauge) {
                setTimeout(function () {
                    gauge.refresh();
                }, 500);
            };
            return Gauge;
        })(cba.wrapper.Wrapper);
        cba.Gauge = Gauge;

        var LinearGauge = (function (_super) {
            __extends(LinearGauge, _super);
            function LinearGauge() {
                _super.apply(this, arguments);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            LinearGauge.prototype.getWjCtor = function () {
                return c1.gauge.LinearGauge;
            };

            /**
            * Override getPorpertyList to initialize the LinearGauge control.
            */
            LinearGauge.prototype.getPorpertyList = function () {
                var list = _super.prototype.getPorpertyList.call(this);
                list.push("direction");
                return list;
            };
            return LinearGauge;
        })(Gauge);
        cba.LinearGauge = LinearGauge;

        var BulletGraph = (function (_super) {
            __extends(BulletGraph, _super);
            function BulletGraph() {
                _super.apply(this, arguments);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            BulletGraph.prototype.getWjCtor = function () {
                return c1.gauge.BulletGraph;
            };

            /**
            * Override getPorpertyList to initialize the BulletGraph control.
            */
            BulletGraph.prototype.getPorpertyList = function () {
                var list = _super.prototype.getPorpertyList.call(this);
                list.push("bad", "good", "target");
                return list;
            };
            return BulletGraph;
        })(LinearGauge);
        cba.BulletGraph = BulletGraph;

        var RadialGauge = (function (_super) {
            __extends(RadialGauge, _super);
            function RadialGauge() {
                _super.apply(this, arguments);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            RadialGauge.prototype.getWjCtor = function () {
                return c1.gauge.RadialGauge;
            };

            /**
            * Override getPorpertyList to initialize the RadialGauge control.
            */
            RadialGauge.prototype.getPorpertyList = function () {
                var list = _super.prototype.getPorpertyList.call(this);
                list.push("autoScale", "startAngle", "sweepAngle");
                return list;
            };
            return RadialGauge;
        })(Gauge);
        cba.RadialGauge = RadialGauge;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Gauge.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Input.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * Input.js
    */
    (function (cba) {
        var $ = jQuery;
        var Input = (function (_super) {
            __extends(Input, _super);
            /**
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function Input(element, contentItem, options) {
                var self = this, control = $("<div></div>").appendTo($(element)), settings = contentItem.properties.inputControlSettings;
                self.contentItem = contentItem;
                if (settings === null || settings === undefined) {
                    self.inputControlSettings = null;
                    self.inputControl = self._getInputControlByBoundField();
                } else {
                    self.inputControlSettings = $.parseJSON(settings);
                    self.inputControl = self.inputControlSettings["inputControl"];
                }
                _super.call(this, control);
                self._initializeInput(self.wjControl);
                if (options)
                    self.initialize(options);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            Input.prototype.getWjCtor = function () {
                return c1.input[this.inputControl];
            };

            Input.prototype._getInputControlByBoundField = function () {
                var fieldType = this.contentItem.valueModel.propertyType.name;
                switch (fieldType) {
                    case "SByte":
                    case "SByte?":
                    case "Byte":
                    case "Byte?":
                    case "Int16":
                    case "Int16?":
                    case "Int32":
                    case "Int32?":
                    case "Int64":
                    case "Int64?":
                    case "Decimal":
                    case "Decimal?":
                    case "Double":
                    case "Double?":
                    case "Single":
                    case "Single?":
                        return "InputNumber";
                    case "Date":
                    case "Date?":
                    case "DateTime":
                    case "DateTime?":
                        return "InputDate";
                    default:
                        return "InputMask";
                }
            };

            /**
            * Initialize the input control.
            */
            Input.prototype._initializeInput = function (wijInput) {
                var self = this, p = self.inputControlSettings, val, input = new c1.cba[self.inputControl], propertyList = input.getPropertyList();

                if (self.inputControlSettings && propertyList) {
                    $.each(propertyList, function (index, propertyName) {
                        val = p[propertyName];
                        if (val !== null && val !== undefined && val !== "") {
                            input.assignValue(wijInput, propertyName, val);
                        }
                    });
                }
                self._resolveNullableProperty(wijInput);

                wijInput.valueChanged.addHandler(function () {
                    if (!input.equals(self.contentItem.value, wijInput.value)) {
                        self.contentItem.value = wijInput.value;
                    }
                });

                self.contentItem.dataBind("stringValue", function (newValue) {
                    var required;
                    if (wijInput['required'] === undefined) {
                        required = true;
                    } else {
                        required = wijInput['required'];
                    }
                    if (!newValue && !required) {
                        wijInput.value = null;
                        return;
                    }
                    var val = self._parseValue(newValue);
                    if (val !== null && !input.equals(newValue, wijInput.value)) {
                        wijInput.value = val;
                    } else if (val === null && !required) {
                        wijInput.value = null;
                    }
                });
            };

            Input.prototype._resolveNullableProperty = function (wijInput) {
                var self = this, isNullableType = self.contentItem.valueModel.propertyType['__isNullableType'];
                if (isNullableType === 1 && wijInput['required']) {
                    wijInput['required'] = false;
                }
            };

            Input.prototype._parseValue = function (value) {
                var self = this, fieldType = self.contentItem.valueModel.propertyType.name, result, date;
                if (value === null || value === undefined) {
                    return null;
                }
                switch (fieldType) {
                    case "SByte":
                    case "SByte?":
                    case "Byte":
                    case "Byte?":
                    case "Int16":
                    case "Int16?":
                    case "Int32":
                    case "Int32?":
                    case "Int64":
                    case "Int64?":
                        value = value.replace(",", "");
                        result = parseInt(value);
                        if (isNaN(result)) {
                            return null;
                        }
                        break;
                    case "Decimal":
                    case "Decimal?":
                    case "Double":
                    case "Double?":
                    case "Single":
                    case "Single?":
                        value = value.replace(",", "");
                        result = parseFloat(value);
                        if (isNaN(result)) {
                            return null;
                        }
                        break;
                    case "Date":
                    case "Date?":
                    case "DateTime":
                    case "DateTime?":
                        date = new Date(value);
                        result = isNaN(date.getTime()) ? null : date;
                        break;
                    default:
                        result = value;
                        break;
                }
                return result;
            };
            return Input;
        })(cba.wrapper.Wrapper);
        cba.Input = Input;

        var InputBase = (function () {
            function InputBase() {
            }
            /**
            * set value to wijControl's property.
            */
            InputBase.prototype.assignValue = function (input, key, value) {
                input[key] = value;
            };

            /**
            * get a porperty list to initialize the input control, should over-write it in child control.
            */
            InputBase.prototype.getPropertyList = function () {
                return ["disabled"];
            };

            /**
            * check if two values are equal.
            */
            InputBase.prototype.equals = function (value1, value2) {
                return value1 === value2;
            };

            InputBase.convertDate = function (date) {
                date = date.replace(/[^0-9 +]/g, '');
                return new Date(parseInt(date));
            };
            return InputBase;
        })();
        cba.InputBase = InputBase;

        var InputNumber = (function (_super) {
            __extends(InputNumber, _super);
            function InputNumber() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the InputNumber control.
            */
            InputNumber.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("inputType", "min", "max", "step", "format", "placeholder", "required", "showSpinner");
                return list;
            };

            /**
            * Override equals to compare two number values.
            */
            InputNumber.prototype.equals = function (value1, value2) {
                return Number(value1) === Number(value2);
            };
            return InputNumber;
        })(InputBase);
        cba.InputNumber = InputNumber;

        var InputMask = (function (_super) {
            __extends(InputMask, _super);
            function InputMask() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the InputMask control.
            */
            InputMask.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("mask", "promptChar", "placeholder");
                return list;
            };
            return InputMask;
        })(InputBase);
        cba.InputMask = InputMask;

        var InputDate = (function (_super) {
            __extends(InputDate, _super);
            function InputDate() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the InputDate control.
            */
            InputDate.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("placeholder", "showDropDownButton", "min", "max", "required", "format", "mask", "isDroppedDown");
                return list;
            };

            /**
            * Override assignValue to set value.
            */
            InputDate.prototype.assignValue = function (input, key, value) {
                switch (key) {
                    case "min":
                    case "max":
                        input[key] = InputBase.convertDate(value);
                        break;
                    case "isDroppedDown":
                        cba.Utils.setIsDroppedDown(input, value);
                        break;
                    default:
                        _super.prototype.assignValue.call(this, input, key, value);
                }
            };

            /**
            * Override equals to compare two Date values.
            */
            InputDate.prototype.equals = function (value1, value2) {
                return new Date(value1) === new Date(value2);
            };
            return InputDate;
        })(InputBase);
        cba.InputDate = InputDate;

        var InputTime = (function (_super) {
            __extends(InputTime, _super);
            function InputTime() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the InputTime control.
            */
            InputTime.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("placeholder", "showDropDownButton", "min", "max", "format", "mask", "isContentHtml", "itemFormatter", "step", "selectedIndex", "isEditable", "maxDropDownHeight", "maxDropDownWidth", "isDroppedDown");
                return list;
            };

            /**
            * Override assignValue to set value.
            */
            InputTime.prototype.assignValue = function (input, key, value) {
                switch (key) {
                    case "min":
                    case "max":
                        input[key] = InputBase.convertDate(value);
                        break;
                    case "itemFormatter":
                        input[key] = wijmo.asFunction(window[value]);
                        break;
                    case "isDroppedDown":
                        cba.Utils.setIsDroppedDown(input, value);
                        break;
                    default:
                        _super.prototype.assignValue.call(this, input, key, value);
                }
            };

            /**
            * Override equals to compare two Date values.
            */
            InputTime.prototype.equals = function (value1, value2) {
                return new Date(value1) === new Date(value2);
            };
            return InputTime;
        })(InputBase);
        cba.InputTime = InputTime;

        var Calendar = (function (_super) {
            __extends(Calendar, _super);
            function Calendar() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the Calendar control.
            */
            Calendar.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("min", "max", "firstDayOfWeek", "displayMonth", "showHeader", "monthView", "itemFormatter");
                return list;
            };

            /**
            * Override assignValue to set value.
            */
            Calendar.prototype.assignValue = function (input, key, value) {
                switch (key) {
                    case "min":
                    case "max":
                    case "displayMonth":
                        input[key] = InputBase.convertDate(value);
                        break;
                    case "itemFormatter":
                        input[key] = wijmo.asFunction(window[value]);
                        break;
                    default:
                        _super.prototype.assignValue.call(this, input, key, value);
                }
            };

            /**
            * Override equals to compare two Date values.
            */
            Calendar.prototype.equals = function (value1, value2) {
                return new Date(value1) === new Date(value2);
            };
            return Calendar;
        })(InputBase);
        cba.Calendar = Calendar;

        var InputColor = (function (_super) {
            __extends(InputColor, _super);
            function InputColor() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the InputColor control.
            */
            InputColor.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("placeholder", "isDroppedDown", "showDropDownButton", "showAlphaChannel");
                return list;
            };

            /**
            * Override assignValue to set value.
            */
            InputColor.prototype.assignValue = function (input, key, value) {
                switch (key) {
                    case "isDroppedDown":
                        cba.Utils.setIsDroppedDown(input, value);
                        break;
                    default:
                        _super.prototype.assignValue.call(this, input, key, value);
                }
            };
            return InputColor;
        })(InputBase);
        cba.InputColor = InputColor;

        var ColorPicker = (function (_super) {
            __extends(ColorPicker, _super);
            function ColorPicker() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the ColorPicker control.
            */
            ColorPicker.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("palette", "showAlphaChannel", "showColorString");
                return list;
            };

            /**
            * Override assignValue to set value.
            */
            ColorPicker.prototype.assignValue = function (input, key, value) {
                switch (key) {
                    case "palette":
                        input[key] = value.split(',');
                        break;
                    default:
                        _super.prototype.assignValue.call(this, input, key, value);
                }
            };
            return ColorPicker;
        })(InputBase);
        cba.ColorPicker = ColorPicker;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Input.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Input.ts" />
/// <reference path="../Util/Util.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * Select.js
    */
    (function (cba) {
        var $ = jQuery;
        var Select = (function (_super) {
            __extends(Select, _super);
            /**
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function Select(element, contentItem, options) {
                var self = this, control = $("<div></div>").appendTo($(element)), settings = contentItem.properties.selectControlSettings;
                self.contentItem = contentItem;
                if (settings === null || settings === undefined) {
                    self.selectControlSettings = null;
                    self.selectControl = "AutoComplete";
                } else {
                    self.selectControlSettings = $.parseJSON(settings);
                    self.selectControl = self.selectControlSettings["selectControl"] || "AutoComplete";
                }
                _super.call(this, control);
                self._initializeSelect(self.wjControl);
                if (options)
                    self.initialize(options);
            }
            /**
            * Override getWjCtor to get the constructor of wijmo control.
            */
            Select.prototype.getWjCtor = function () {
                return c1.input[this.selectControl];
            };

            /**
            * Initialize the select control.
            */
            Select.prototype._initializeSelect = function (wijSelect) {
                var self = this, p = self.selectControlSettings, val, select = new c1.cba[self.selectControl], isNullableType = self.contentItem.valueModel.propertyType['__isNullableType'], propertyList = select.getPropertyList();

                if (self.selectControlSettings && propertyList) {
                    $.each(propertyList, function (index, propertyName) {
                        val = p[propertyName];
                        if (val !== null && val !== undefined && val !== "") {
                            select.assignValue(wijSelect, propertyName, val, self);
                        }
                    });
                }
                if (isNullableType === 1 && wijSelect['required']) {
                    wijSelect['required'] = false;
                }
                select.bindValue(wijSelect, self);
            };
            return Select;
        })(cba.wrapper.Wrapper);
        cba.Select = Select;

        var ComboBox = (function () {
            function ComboBox() {
                this._dataInitialized = false;
            }
            /**
            * get a porperty list to initialize the select control, should over-write it in child control.
            */
            ComboBox.prototype.getPropertyList = function () {
                return [
                    "placeholder",
                    "isDroppedDown",
                    "showDropDownButton",
                    "dataSourceTable",
                    "displayMemberPath",
                    "selectedValuePath",
                    "isContentHtml",
                    "isEditable",
                    "required",
                    "maxDropDownHeight",
                    "maxDropDownWidth",
                    "disabled"
                ];
            };

            /**
            * Process data after data is loaded.
            */
            ComboBox.prototype.processData = function (wijSelect) {
            };

            /**
            * set value to wijControl's property.
            */
            ComboBox.prototype.assignValue = function (wijSelect, key, value, select) {
                var self = this, dataSource, dataTable, dataInfo, isEditable;
                switch (key) {
                    case "dataSourceTable":
                        if (value !== "<Not Set>") {
                            dataInfo = value.split('/');
                            dataSource = dataInfo[0];
                            dataTable = dataInfo[1];
                            var loader = select.contentItem.application.activeDataWorkspace[dataSource][dataTable].load();
                            loader.done(function (data) {
                                wijSelect.itemsSource = data.results;
                                isEditable = wijSelect.isEditable;
                                wijSelect.isEditable = true;
                                wijSelect.text = select.contentItem.value || "";
                                wijSelect.isEditable = isEditable;
                                self.processData(wijSelect);
                                cba.Utils.setIsDroppedDown(wijSelect, select.selectControlSettings["isDroppedDown"]);
                                self._dataInitialized = true;
                            });
                        }
                        break;
                    case "maxDropDownHeight":
                    case "maxDropDownWidth":
                        if (parseFloat(value) > 0) {
                            wijSelect[key] = value;
                        }
                        break;
                    case "isDroppedDown":
                        break;
                    default:
                        wijSelect[key] = value;
                }
            };

            /**
            * bind the value of ComboBox control.
            */
            ComboBox.prototype.bindValue = function (wijComboBox, select) {
                var self = this;
                wijComboBox.selectedIndexChanged.addHandler(function () {
                    if (self._dataInitialized && select.contentItem.value !== wijComboBox.selectedValue) {
                        select.contentItem.value = wijComboBox.selectedValue;
                    }
                });

                wijComboBox.textChanged.addHandler(function () {
                    if (self._dataInitialized && select.contentItem.value !== wijComboBox.selectedValue) {
                        select.contentItem.value = wijComboBox.text;
                    }
                });

                select.contentItem.dataBind("stringValue", function (newValue) {
                    if (newValue && newValue !== wijComboBox.selectedValue) {
                        wijComboBox.selectedValue = newValue;
                    }
                });
            };
            return ComboBox;
        })();
        cba.ComboBox = ComboBox;

        var AutoComplete = (function (_super) {
            __extends(AutoComplete, _super);
            function AutoComplete() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the AutoComplete control.
            */
            AutoComplete.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("cssMatch", "delay", "maxItems", "minLength");
                return list;
            };

            /**
            * bind the value of AutoComplete control.
            */
            AutoComplete.prototype.bindValue = function (wijAutoComplete, select) {
                var self = this;

                wijAutoComplete.textChanged.addHandler(function () {
                    if (self._dataInitialized && select.contentItem.value !== wijAutoComplete.text) {
                        select.contentItem.value = wijAutoComplete.text;
                    }
                });

                select.contentItem.dataBind("stringValue", function (newValue) {
                    if (newValue != null && newValue != undefined && newValue !== wijAutoComplete.text) {
                        wijAutoComplete.text = newValue;
                    }
                });
            };
            return AutoComplete;
        })(ComboBox);
        cba.AutoComplete = AutoComplete;

        var MultiSelect = (function (_super) {
            __extends(MultiSelect, _super);
            function MultiSelect() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the AutoComplete control.
            */
            MultiSelect.prototype.getPropertyList = function () {
                var list = _super.prototype.getPropertyList.call(this);
                list.push("checkedIndexes", "checkedMemberPath", "headerFormat", "maxHeaderItems");
                return list;
            };

            /**
            * Override assignValue to set value to wijControl's property.
            */
            MultiSelect.prototype.assignValue = function (wijSelect, key, value, select) {
                var self = this;
                switch (key) {
                    case "checkedIndexes":
                        self.checkedIndexes = value;
                        break;
                    default:
                        _super.prototype.assignValue.call(this, wijSelect, key, value, select);
                }
            };

            /**
            * Process data after data is loaded.
            */
            MultiSelect.prototype.processData = function (wijSelect) {
                var self = this, checkedItems;
                if (!self.checkedIndexes)
                    return;
                checkedItems = self._getCheckedItemsByIndex(self.checkedIndexes, wijSelect);
                if (checkedItems && wijSelect.itemsSource) {
                    wijSelect["checkedItems"] = checkedItems;
                }
            };

            MultiSelect.prototype._getCheckedItemsByIndex = function (value, wijSelect) {
                var self = this, indexes = value.split(','), i, result = [], index;
                for (i = 0; i < indexes.length; i++) {
                    index = parseInt(indexes[i]);
                    if (!isNaN(index) && index >= 0 && index < wijSelect.itemsSource.length) {
                        result.push(wijSelect.itemsSource[index]);
                    }
                }
                return result;
            };

            MultiSelect.prototype._getCheckedItemsByValue = function (value, wijSelect) {
                var self = this, valueArray = self._removeReduplicativeItems(value.split(',')), i, j, result = [];
                if (wijSelect.selectedValuePath) {
                    for (i = 0; i < valueArray.length; i++) {
                        for (j = 0; j < wijSelect.checkedItems.length; j++) {
                            if (valueArray[i] === wijSelect.checkedItems[j][wijSelect.selectedValuePath]) {
                                result.push(wijSelect.itemsSource[j]);
                                break;
                            }
                        }
                    }
                }
                return result;
            };

            MultiSelect.prototype._removeReduplicativeItems = function (arr) {
                var result = [], hash = {};
                for (var i = 0, elem; (elem = arr[i]) != null; i++) {
                    if (!hash[elem]) {
                        result.push(elem);
                        hash[elem] = true;
                    }
                }
                return result;
            };

            MultiSelect.prototype._getValue = function (wijMultiSelect) {
                var self = this, value = '', checkedItems = wijMultiSelect.checkedItems, selectedValuePath = wijMultiSelect.selectedValuePath, i;
                if (selectedValuePath) {
                    for (i = 0; i < checkedItems.length; i++) {
                        value += checkedItems[i][selectedValuePath];
                        if (i < checkedItems.length - 1) {
                            value += ',';
                        }
                    }
                }
                return value;
            };

            /**
            * Override bindValue to bind value of MultiSelect.
            */
            MultiSelect.prototype.bindValue = function (wijMultiSelect, select) {
                var self = this, value;
                wijMultiSelect.checkedItemsChanged.addHandler(function () {
                    value = self._getValue(wijMultiSelect);
                    if (select.contentItem.value !== value) {
                        select.contentItem.value = value;
                    }
                });

                select.contentItem.dataBind("stringValue", function (newValue) {
                    value = self._getValue(wijMultiSelect);
                    if (newValue && newValue !== value) {
                        wijMultiSelect.checkedItems = self._getCheckedItemsByValue(newValue, wijMultiSelect);
                    }
                });
            };
            return MultiSelect;
        })(ComboBox);
        cba.MultiSelect = MultiSelect;

        var ListBox = (function (_super) {
            __extends(ListBox, _super);
            function ListBox() {
                _super.apply(this, arguments);
            }
            /**
            * Override getPropertyList to initialize the ListBox control.
            */
            ListBox.prototype.getPropertyList = function () {
                return [
                    "disabled",
                    "dataSourceTable",
                    "displayMemberPath",
                    "selectedValuePath",
                    "checkedMemberPath",
                    "isContentHtml",
                    "maxHeight",
                    "checkedIndexes",
                    "isMultipleSelect"
                ];
            };

            /**
            * Override assignValue to set value to wijControl's property.
            */
            ListBox.prototype.assignValue = function (wijSelect, key, value, select) {
                var self = this, checkedIndexes, isMultipleSelect, p = select.selectControlSettings, checkedItems, dataInfo, dataSource, dataTable;
                switch (key) {
                    case "dataSourceTable":
                        if (value !== "<Not Set>") {
                            dataInfo = value.split('/');
                            dataSource = dataInfo[0];
                            dataTable = dataInfo[1];
                            var loader = select.contentItem.application.activeDataWorkspace[dataSource][dataTable].load();
                            loader.done(function (data) {
                                wijSelect.itemsSource = data.results;
                                checkedIndexes = p["checkedIndexes"];
                                isMultipleSelect = p["isMultipleSelect"];
                                if (isMultipleSelect) {
                                    //set a value to checkedMemberPath property to add checkboxes to item.
                                    wijSelect["checkedMemberPath"] = "_itemschecked";
                                    wijSelect["checkedItems"] = [];
                                }
                                if (checkedIndexes) {
                                    checkedItems = self._getCheckedItemsByIndex(checkedIndexes, wijSelect);
                                    if (checkedItems) {
                                        wijSelect["checkedItems"] = checkedItems;
                                    }
                                }
                            });
                        }
                        break;
                    case "maxHeight":
                        if (parseFloat(value) > 0) {
                            wijSelect[key] = value;
                        }
                        break;
                    case "isMultipleSelect":
                        break;
                    default:
                        _super.prototype.assignValue.call(this, wijSelect, key, value, select);
                }
            };

            /**
            * Override bindValue to bind value of ListBox.
            */
            ListBox.prototype.bindValue = function (wijListBox, select) {
                var self = this, checkedIndexes, isMultipleSelect, p = select.selectControlSettings, checkedItems, value;
                if (p["isMultipleSelect"]) {
                    wijListBox.checkedItemsChanged.addHandler(function () {
                        value = self._getValue(wijListBox);
                        if (select.contentItem.value !== value) {
                            select.contentItem.value = value;
                        }
                    });

                    select.contentItem.dataBind("stringValue", function (newValue) {
                        value = self._getValue(wijListBox);
                        if (newValue && newValue !== value) {
                            wijListBox.checkedItems = self._getCheckedItemsByValue(newValue, wijListBox);
                        }
                    });
                } else {
                    wijListBox.selectedIndexChanged.addHandler(function () {
                        if (select.contentItem.value !== wijListBox.selectedValue) {
                            select.contentItem.value = wijListBox.selectedValue;
                        }
                    });

                    select.contentItem.dataBind("stringValue", function (newValue) {
                        if (newValue && newValue !== wijListBox.selectedValue) {
                            wijListBox.selectedValue = newValue;
                        }
                    });
                }
            };
            return ListBox;
        })(MultiSelect);
        cba.ListBox = ListBox;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Select.js.map

﻿/// <reference path="Control.ts" />
/// <reference path="../Shared/Input.ts" />
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var c1;
(function (c1) {
    /*
    * ComponentOne LightSwitch JavaScript Library v5.0.20173.37
    * Menu.js
    */
    (function (cba) {
        var $ = jQuery;

        var Menu = (function (_super) {
            __extends(Menu, _super);
            /**
            * Initializes a new instance of a @see:Menu control.
            *
            * @param element The DOM element that will host the control, or a selector for the host element (e.g. '#theCtrl').
            * @param contentItem A object of defined from the LightSwitch content item.
            * @param options JavaScript object containing initialization data for the control.
            */
            function Menu(element, contentItem, options) {
                var control = $("<div></div>").appendTo($(element));
                _super.call(this, control);
                this._contentItem = contentItem;
                this._initializeMenu(contentItem.properties);
                if (options)
                    this.initialize(options);
            }
            Menu.prototype._initializeMenu = function (properties) {
                var self = this, menu = self.Menu, p = properties, menuProperties = self.getPorpertyList(), val, selectedIndex;
                if (!menu["command"]) {
                    menu["command"] = {};
                }

                $.each(menuProperties, function (index, propertyName) {
                    val = p[propertyName];
                    if (val !== null && val !== undefined && val !== "") {
                        switch (propertyName) {
                            case "maxDropDownHeight":
                            case "maxDropDownWidth":
                                if (parseFloat(val) > 0) {
                                    menu[propertyName] = val;
                                }
                                break;
                            case "menuItems":
                                self._setMenuItems(val);
                                break;
                            case "isDroppedDown":
                                cba.Utils.setIsDroppedDown(menu, val);
                                break;
                            default:
                                menu[propertyName] = val;
                        }
                    }
                });
            };

            /**
            * Get the constructor of wijmo control.
            */
            Menu.prototype.getWjCtor = function () {
                return c1.input.Menu;
            };

            Object.defineProperty(Menu.prototype, "Menu", {
                get: function () {
                    return this.wjControl;
                },
                enumerable: true,
                configurable: true
            });

            /**
            * get a porperty list to initialize the Menu control.
            */
            Menu.prototype.getPorpertyList = function () {
                return [
                    "showDropDownButton",
                    "isContentHtml",
                    "isButton",
                    "maxDropDownHeight",
                    "maxDropDownWidth",
                    "header",
                    "menuItems",
                    "isDroppedDown"
                ];
            };

            Menu.prototype._setMenuItems = function (val) {
                var self = this, menuItems = $.parseJSON(val), menu = self.Menu, menuDataSource = [];

                $.each(menuItems, function (index, menuItem) {
                    menuDataSource.push({
                        "header": menuItem.header,
                        "commandParameter": menuItem.commandParameter,
                        "command": {
                            canExecuteCommand: wijmo.asFunction(window[menuItem.canExecuteCommand]),
                            executeCommand: wijmo.asFunction(window[menuItem.executeCommand])
                        }
                    });
                });

                menu.itemsSource = menuDataSource;
                menu.displayMemberPath = "header";
                menu.commandParameterPath = "commandParameter";
                menu.commandPath = "command";
            };
            return Menu;
        })(cba.wrapper.Wrapper);
        cba.Menu = Menu;
    })(c1.cba || (c1.cba = {}));
    var cba = c1.cba;
})(c1 || (c1 = {}));
//# sourceMappingURL=Menu.js.map
