<commit_before>/* ========================================================================
 * ZUI: ColorPicker.js
 * http://zui.sexy
 * ========================================================================
 * Copyright (c) 2016 cnezsoft.com; Licensed MIT
 * ======================================================================== */

(function($) {
    'use strict';

    var name = 'zui.colorPicker'; // modal name
    var TEAMPLATE = '
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown"></button>

';
    var LANG = {
        zh_cn: {
            errorTip: "不是有效的颜色值"
        },
        zh_tw: {
            errorTip: "不是有效的顏色值"
        },
        en: {
            errorTip: "Not a valid color value"
        }
    };

    // The ColorPicker modal class
    var ColorPicker = function(element, options) {
        this.name = name;
        this.$ = $(element);

        this.getOptions(options);
        this.init();

        // Initialize here
    };

    // default options
    ColorPicker.DEFAULTS = {
        colors: ['#00BCD4', '#388E3C', '#3280fc', '#3F51B5', '#9C27B0', '#795548', '#F57C00', '#F44336', '#E91E63'],
        pullMenuRight: true,
        wrapper: 'btn-wrapper',
        tileSize: 30,
        lineCount: 5,
        optional: true,
        tooltip: 'top',
        icon: 'caret-down',
        // btnTip: 'Tool tip in button'
    };

    ColorPicker.prototype.init = function() {
        var options = this.options,
            that = this;

        this.$picker = $(TEAMPLATE).addClass(options.wrapper);
        this.$picker.find('.cp-title').toggle(options.title !== undefined).text(options.title);
        this.$menu = this.$picker.find('.dropdown-menu').toggleClass('pull-right', options.pullMenuRight);
        this.$btn = this.$picker.find('.btn.dropdown-toggle');
        this.$btn.find('.icon').addClass('icon-' + options.icon);
        if(options.btnTip) {
            this.$picker.attr('data-toggle', 'tooltip').tooltip({title: options.btnTip, placement: options.tooltip, container: 'body'});
        }
        this.$.attr('data-provide', null).after(this.$picker);

        // init colors
        this.colors = {};
        $.each(this.options.colors, function(idx, rawColor) {
            if($.zui.Color.isColor(rawColor)) {
                var color = new $.zui.Color(rawColor);
                that.colors[color.toCssStr()] = color;
            }
        });

        this.updateColors();
        var that = this;
        this.$picker.on('click', '.cp-tile', function() {
            that.setValue($(this).data('color'));
        });
        var $input = this.$;
        var setInputColor = function() {
            var val = $input.val();
            var isColor = $.zui.Color.isColor(val);
            $input.parent().toggleClass('has-error', !isColor && !(options.optional && val === ''));
            if(isColor) {
                that.setValue(val, true);
            } else {
                if(options.optional && val === '') {
                    $input.tooltip('hide');
                } else {
                    $input.tooltip('show', options.errorTip);
                }
            }
        }
        if($input.is('input:not([type=hidden])')) {
            if(options.tooltip) {
                $input.attr('data-toggle', 'tooltip').tooltip({trigger: 'manual', placement: options.tooltip, tipClass: 'tooltip-danger'});
            }
            $input.on('keyup paste input', setInputColor);
        } else {
            $input.appendTo(this.$picker);
        }
        setInputColor();
    };

    ColorPicker.prototype.addColor = function(color) {
        var hex = color.toCssStr(),
            options = this.options;

        if(!this.colors[hex]) {
            this.colors[hex] = color;
        }

        var $a = $('', {
            titile: color
        }).data('color', color).css({
            'color': color.contrast().toCssStr(),
            'background': hex,
            'border-color': color.luma() > 0.43 ? '#ccc' : 'transparent'
        }).attr('data-color', hex);
        this.$menu.append($('
').css({width: options.tileSize, height: options.tileSize}).append($a));
        if(options.optional) {
            this.$menu.find('.cp-tile.empty').parent().detach().appendTo(this.$menu);
        }
    };

    ColorPicker.prototype.updateColors = function(colors) {
        var $picker = this.$picker,
            $menu = this.$menu.empty(),
            options = this.options,
            colors = colors || this.colors,
            that = this;
        var bestLineCount = 0;
        $.each(colors, function(idx, color) {
            that.addColor(color);
            bestLineCount++;
        });
        if(options.optional) {
            var $li = $('

').css({width: options.tileSize, height: options.tileSize});
            this.$menu.append($li);
            bestLineCount++;
        }
        $menu.css('width', Math.min(bestLineCount, options.lineCount) * options.tileSize + 6);
    };

    ColorPicker.prototype.setValue = function(color, notSetInput) {
        var options = this.options;
        this.$menu.find('.cp-tile.active').removeClass('active');
        var hex = null;
        if(color) {
            var c = new $.zui.Color(color);
            hex = c.toCssStr().toLowerCase();
            this.$btn.css({
                background: hex,
                color: c.contrast().toCssStr(),
                borderColor: c.luma() > 0.43 ? '#ccc' : hex
            });
            if(!this.colors[hex]) {
                this.addColor(c);
            }
            if(!notSetInput && this.$.val().toLowerCase() !== hex) {
                this.$.val(hex).trigger('change');
            }
            this.$menu.find('.cp-tile[data-color=' + hex + ']').addClass('active');
            this.$.tooltip('hide');
            this.$.trigger('colorchange', c);
        } else {
            this.$btn.attr('style', null);
            if(!notSetInput && this.$.val() !== '') {
                this.$.val(hex).trigger('change');
            }
            if(options.optional) {
                this.$.tooltip('hide');
            }
            this.$menu.find('.cp-tile.empty').addClass('active');
            this.$.trigger('colorchange', null);
        }

        if(options.updateBorder) {
            $(options.updateBorder).css('border-color', hex);
        }
        if(options.updateBackground) {
            $(options.updateBackground).css('background-color', hex);
        }
        if(options.updateText) {
            $(options.updateText).css('color', hex);
        }
    };

    // Get and init options
    ColorPicker.prototype.getOptions = function(options) {
        var thisOptions = $.extend({}, ColorPicker.DEFAULTS, this.$.data(), options);
        if(typeof thisOptions.colors === 'string') thisOptions.colors = thisOptions.colors.split(',');
        var lang = (thisOptions.lang || $.zui.clientLang()).toLowerCase();
        if(!thisOptions.errorTip) {
            thisOptions.errorTip = LANG[lang].errorTip;
        }
        this.options = thisOptions;
    };

    // Extense jquery element
    $.fn.colorPicker = function(option) {
        return this.each(function() {
            var $this = $(this);
            var data = $this.data(name);
            var options = typeof option == 'object' && option;

            if(!data) $this.data(name, (data = new ColorPicker(this, options)));

            if(typeof option == 'string') data[option]();
        });
    };

    $.fn.colorPicker.Constructor = ColorPicker;

    // Auto call colorPicker after document load complete
    $(function() {
        $('[data-provide="colorpicker"]').colorPicker();
    });
}(jQuery));

<commit_msg>* fix error in colorPicker on update color to other elements by set default value to empty string.<commit_after>/* ========================================================================
 * ZUI: ColorPicker.js
 * http://zui.sexy
 * ========================================================================
 * Copyright (c) 2016 cnezsoft.com; Licensed MIT
 * ======================================================================== */

(function($) {
    'use strict';

    var name = 'zui.colorPicker'; // modal name
    var TEAMPLATE = '
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown"></button>

';
    var LANG = {
        zh_cn: {
            errorTip: "不是有效的颜色值"
        },
        zh_tw: {
            errorTip: "不是有效的顏色值"
        },
        en: {
            errorTip: "Not a valid color value"
        }
    };

    // The ColorPicker modal class
    var ColorPicker = function(element, options) {
        this.name = name;
        this.$ = $(element);

        this.getOptions(options);
        this.init();

        // Initialize here
    };

    // default options
    ColorPicker.DEFAULTS = {
        colors: ['#00BCD4', '#388E3C', '#3280fc', '#3F51B5', '#9C27B0', '#795548', '#F57C00', '#F44336', '#E91E63'],
        pullMenuRight: true,
        wrapper: 'btn-wrapper',
        tileSize: 30,
        lineCount: 5,
        optional: true,
        tooltip: 'top',
        icon: 'caret-down',
        // btnTip: 'Tool tip in button'
    };

    ColorPicker.prototype.init = function() {
        var options = this.options,
            that = this;

        this.$picker = $(TEAMPLATE).addClass(options.wrapper);
        this.$picker.find('.cp-title').toggle(options.title !== undefined).text(options.title);
        this.$menu = this.$picker.find('.dropdown-menu').toggleClass('pull-right', options.pullMenuRight);
        this.$btn = this.$picker.find('.btn.dropdown-toggle');
        this.$btn.find('.icon').addClass('icon-' + options.icon);
        if(options.btnTip) {
            this.$picker.attr('data-toggle', 'tooltip').tooltip({title: options.btnTip, placement: options.tooltip, container: 'body'});
        }
        this.$.attr('data-provide', null).after(this.$picker);

        // init colors
        this.colors = {};
        $.each(this.options.colors, function(idx, rawColor) {
            if($.zui.Color.isColor(rawColor)) {
                var color = new $.zui.Color(rawColor);
                that.colors[color.toCssStr()] = color;
            }
        });

        this.updateColors();
        var that = this;
        this.$picker.on('click', '.cp-tile', function() {
            that.setValue($(this).data('color'));
        });
        var $input = this.$;
        var setInputColor = function() {
            var val = $input.val();
            var isColor = $.zui.Color.isColor(val);
            $input.parent().toggleClass('has-error', !isColor && !(options.optional && val === ''));
            if(isColor) {
                that.setValue(val, true);
            } else {
                if(options.optional && val === '') {
                    $input.tooltip('hide');
                } else {
                    $input.tooltip('show', options.errorTip);
                }
            }
        }
        if($input.is('input:not([type=hidden])')) {
            if(options.tooltip) {
                $input.attr('data-toggle', 'tooltip').tooltip({trigger: 'manual', placement: options.tooltip, tipClass: 'tooltip-danger'});
            }
            $input.on('keyup paste input', setInputColor);
        } else {
            $input.appendTo(this.$picker);
        }
        setInputColor();
    };

    ColorPicker.prototype.addColor = function(color) {
        var hex = color.toCssStr(),
            options = this.options;

        if(!this.colors[hex]) {
            this.colors[hex] = color;
        }

        var $a = $('', {
            titile: color
        }).data('color', color).css({
            'color': color.contrast().toCssStr(),
            'background': hex,
            'border-color': color.luma() > 0.43 ? '#ccc' : 'transparent'
        }).attr('data-color', hex);
        this.$menu.append($('
').css({width: options.tileSize, height: options.tileSize}).append($a));
        if(options.optional) {
            this.$menu.find('.cp-tile.empty').parent().detach().appendTo(this.$menu);
        }
    };

    ColorPicker.prototype.updateColors = function(colors) {
        var $picker = this.$picker,
            $menu = this.$menu.empty(),
            options = this.options,
            colors = colors || this.colors,
            that = this;
        var bestLineCount = 0;
        $.each(colors, function(idx, color) {
            that.addColor(color);
            bestLineCount++;
        });
        if(options.optional) {
            var $li = $('

').css({width: options.tileSize, height: options.tileSize});
            this.$menu.append($li);
            bestLineCount++;
        }
        $menu.css('width', Math.min(bestLineCount, options.lineCount) * options.tileSize + 6);
    };

    ColorPicker.prototype.setValue = function(color, notSetInput) {
        var options = this.options;
        this.$menu.find('.cp-tile.active').removeClass('active');
        var hex = '';
        if(color) {
            var c = new $.zui.Color(color);
            hex = c.toCssStr().toLowerCase();
            this.$btn.css({
                background: hex,
                color: c.contrast().toCssStr(),
                borderColor: c.luma() > 0.43 ? '#ccc' : hex
            });
            if(!this.colors[hex]) {
                this.addColor(c);
            }
            if(!notSetInput && this.$.val().toLowerCase() !== hex) {
                this.$.val(hex).trigger('change');
            }
            this.$menu.find('.cp-tile[data-color=' + hex + ']').addClass('active');
            this.$.tooltip('hide');
            this.$.trigger('colorchange', c);
        } else {
            this.$btn.attr('style', null);
            if(!notSetInput && this.$.val() !== '') {
                this.$.val(hex).trigger('change');
            }
            if(options.optional) {
                this.$.tooltip('hide');
            }
            this.$menu.find('.cp-tile.empty').addClass('active');
            this.$.trigger('colorchange', null);
        }

        if(options.updateBorder) {
            $(options.updateBorder).css('border-color', hex);
        }
        if(options.updateBackground) {
            $(options.updateBackground).css('background-color', hex);
        }
        if(options.updateText) {
            $(options.updateText).css('color', hex);
        }
    };

    // Get and init options
    ColorPicker.prototype.getOptions = function(options) {
        var thisOptions = $.extend({}, ColorPicker.DEFAULTS, this.$.data(), options);
        if(typeof thisOptions.colors === 'string') thisOptions.colors = thisOptions.colors.split(',');
        var lang = (thisOptions.lang || $.zui.clientLang()).toLowerCase();
        if(!thisOptions.errorTip) {
            thisOptions.errorTip = LANG[lang].errorTip;
        }
        this.options = thisOptions;
    };

    // Extense jquery element
    $.fn.colorPicker = function(option) {
        return this.each(function() {
            var $this = $(this);
            var data = $this.data(name);
            var options = typeof option == 'object' && option;

            if(!data) $this.data(name, (data = new ColorPicker(this, options)));

            if(typeof option == 'string') data[option]();
        });
    };

    $.fn.colorPicker.Constructor = ColorPicker;

    // Auto call colorPicker after document load complete
    $(function() {
        $('[data-provide="colorpicker"]').colorPicker();
    });
}(jQuery));

<|endoftext|>


<commit_before>/**
 * @fileoverview Crocodoc.Viewer definition
 * @author lakenen
 */

/**
 * The Crocodoc.Viewer namespace
 * @namespace
 */
(function () {
    'use strict';

    var CSS_CLASS_TEXT_DISABLED  = 'crocodoc-text-disabled',
        CSS_CLASS_LINKS_DISABLED = 'crocodoc-links-disabled';

    var viewerInstanceCount = 0,
        instances = {};

    /**
     * Crocodoc.Viewer constructor
     * @param {jQuery|string|Element} el The element to wrap
     * @param {Object} options           Configuration options
     * @constructor
     */
    Crocodoc.Viewer = function (el, options) {
        // call the EventTarget constructor to init handlers
        Crocodoc.EventTarget.call(this);

        var util = Crocodoc.getUtility('common');
        var layout,
            $el = $(el),
            config = util.extend(true, {}, Crocodoc.Viewer.defaults, options),
            scope = new Crocodoc.Scope(config),
            viewerBase = scope.createComponent('viewer-base');

        //Container exists?
        if ($el.length === 0) {
            throw new Error('Invalid container element');
        }

        this.id = config.id = ++viewerInstanceCount;
        config.api = this;
        config.$el = $el;
        // register this instance
        instances[this.id] = this;

        function init() {
            viewerBase.init();
        }

        //--------------------------------------------------------------------------
        // Public
        //--------------------------------------------------------------------------

        /**
         * Destroy the viewer instance
         * @returns {void}
         */
        this.destroy = function () {
            // unregister this instance
            delete instances[config.id];

            // broadcast a destroy message
            scope.broadcast('destroy');

            // destroy all components and plugins in this scope
            scope.destroy();
        };

        /**
         * Intiate loading of document assets
         * @returns {void}
         */
        this.load = function () {
            viewerBase.loadAssets();
        };

        /**
         * Set the layout to the given mode, destroying and cleaning up the current
         * layout if there is one
         * @param  {string} mode The layout mode
         * @returns {void}
         */
        this.setLayout = function (mode) {
            layout = viewerBase.setLayout(mode);
        };

        /**
         * Zoom to the given value
         * @param  {float|string} val Numeric zoom level to zoom to or one of:
         *                            Crocodoc.ZOOM_IN
         *                            Crocodoc.ZOOM_OUT
         *                            Crocodoc.ZOOM_AUTO
         *                            Crocodoc.ZOOM_FIT_WIDTH
         *                            Crocodoc.ZOOM_FIT_HEIGHT
         * @returns {void}
         */
        this.zoom = function (val) {
            // adjust for page scale if passed value is a number
            var valFloat = parseFloat(val);
            if (layout) {
                if (valFloat) {
                    val = valFloat / (config.pageScale || 1);
                }
                layout.setZoom(val);
            }
        };

        /**
         * Scroll to the given page
         * @param  {int|string} page Page number or one of:
         *                           Crocodoc.SCROLL_PREVIOUS
         *                           Crocodoc.SCROLL_NEXT
         * @returns {void}
         */
        this.scrollTo = function (page) {
            if (layout) {
                layout.scrollTo(page);
            }
        };

        /**
         * Scrolls by the given pixel amount from the current location
         * @param  {int} left Left offset to scroll to
         * @param  {int} top  Top offset to scroll to
         * @returns {void}
         */
        this.scrollBy = function (left, top) {
            if (layout) {
                layout.scrollBy(left, top);
            }
        };

        /**
         * Focuses the viewport so it can be natively scrolled with the keyboard
         * @returns {void}
         */
        this.focus = function () {
            if (layout) {
                layout.focus();
            }
        };

        /**
         * Enable text selection, loading text assets per page if necessary
         * @returns {void}
         */
        this.enableTextSelection = function () {
            if (!config.enableTextSelection) {
                $el.removeClass(CSS_CLASS_TEXT_DISABLED);
                config.enableTextSelection = true;
                scope.broadcast('textenabledchange', { enabled: true });
            }
        };

        /**
         * Disable text selection, hiding text layer on pages if it's already there
         * and disabling the loading of new text assets
         * @returns {void}
         */
        this.disableTextSelection = function () {
            if (config.enableTextSelection) {
                $el.addClass(CSS_CLASS_TEXT_DISABLED);
                config.enableTextSelection = false;
                scope.broadcast('textenabledchange', { enabled: false });
            }
        };

        /**
         * Enable links
         * @returns {void}
         */
        this.enableLinks = function () {
            if (!config.enableLinks) {
                $el.removeClass(CSS_CLASS_LINKS_DISABLED);
                config.enableLinks = true;
            }
        };

        /**
         * Disable links
         * @returns {void}
         */
        this.disableLinks = function () {
            if (config.enableLinks) {
                $el.addClass(CSS_CLASS_LINKS_DISABLED);
                config.enableLinks = false;
            }
        };

        /**
         * Force layout update
         * @returns {void}
         */
        this.updateLayout = function () {
            if (layout) {
                // force update layout (incl. calculating page paddings)
                layout.updatePageStates(true);
                layout.setZoom();
            }
        };

        init();
    };

    Crocodoc.Viewer.prototype = new Crocodoc.EventTarget();
    Crocodoc.Viewer.prototype.constructor = Crocodoc.Viewer;

    /**
     * Get a viewer instance by id
     * @param {number} id   The id
     * @returns {Object}    The viewer instance
     */
    Crocodoc.Viewer.get = function (id) {
        return instances[id];
    };

    // Global defaults
    Crocodoc.Viewer.defaults = {
        // the url to load the assets from (required)
        url: null,

        // document viewer layout
        layout: Crocodoc.LAYOUT_VERTICAL,

        // initial zoom level
        zoom: Crocodoc.ZOOM_AUTO,

        // page to start on
        page: 1,

        // enable/disable text layer
        enableTextSelection: true,

        // enable/disable links layer
        enableLinks: true,

        // enable/disable click-and-drag
        enableDragging: false,

        // query string parameters to append to all asset requests
        queryParams: null,

        // plugin configs
        plugins: {},

        // whether to use the browser window as the viewport into the document (this
        // is useful when the document should take up the entire browser window, e.g.,
        // on mobile devices)
        useWindowAsViewport: false,

        //--------------------------------------------------------------------------
        // The following are undocumented, internal, or experimental options,
        // which are very subject to change and likely to be broken.
        // --
        // USE AT YOUR OWN RISK!
        //--------------------------------------------------------------------------

        // whether or not the conversion is finished (eg., pages are ready to be loaded)
        conversionIsComplete: true,

        // template for loading assets... this should rarely (if ever) change
        template: {
            svg: 'page-{{page}}.svg',
            img: 'page-{{page}}.png',
            html: 'text-{{page}}.html',
            css: 'stylesheet.css',
            json: 'info.json'
        },

        // default data-providers
        dataProviders: {
            metadata: 'metadata',
            stylesheet: 'stylesheet',
            'page-svg': 'page-svg',
            'page-text': 'page-text',
            'page-img': 'page-img'
        },

        // page to start/end on (pages outside this range will not be shown)
        pageStart: null,
        pageEnd: null,

        // zoom levels are relative to the viewport size,
        // and the dynamic zoom levels (auto, fitwidth, etc) will be added into the mix
        zoomLevels: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0]
    };
})();

<commit_msg>Removing old layout reference when changing layout to avoid errors when handling the layoutchange event (fixes #118)<commit_after>/**
 * @fileoverview Crocodoc.Viewer definition
 * @author lakenen
 */

/**
 * The Crocodoc.Viewer namespace
 * @namespace
 */
(function () {
    'use strict';

    var CSS_CLASS_TEXT_DISABLED  = 'crocodoc-text-disabled',
        CSS_CLASS_LINKS_DISABLED = 'crocodoc-links-disabled';

    var viewerInstanceCount = 0,
        instances = {};

    /**
     * Crocodoc.Viewer constructor
     * @param {jQuery|string|Element} el The element to wrap
     * @param {Object} options           Configuration options
     * @constructor
     */
    Crocodoc.Viewer = function (el, options) {
        // call the EventTarget constructor to init handlers
        Crocodoc.EventTarget.call(this);

        var util = Crocodoc.getUtility('common');
        var layout,
            $el = $(el),
            config = util.extend(true, {}, Crocodoc.Viewer.defaults, options),
            scope = new Crocodoc.Scope(config),
            viewerBase = scope.createComponent('viewer-base');

        //Container exists?
        if ($el.length === 0) {
            throw new Error('Invalid container element');
        }

        this.id = config.id = ++viewerInstanceCount;
        config.api = this;
        config.$el = $el;
        // register this instance
        instances[this.id] = this;

        function init() {
            viewerBase.init();
        }

        //--------------------------------------------------------------------------
        // Public
        //--------------------------------------------------------------------------

        /**
         * Destroy the viewer instance
         * @returns {void}
         */
        this.destroy = function () {
            // unregister this instance
            delete instances[config.id];

            // broadcast a destroy message
            scope.broadcast('destroy');

            // destroy all components and plugins in this scope
            scope.destroy();
        };

        /**
         * Intiate loading of document assets
         * @returns {void}
         */
        this.load = function () {
            viewerBase.loadAssets();
        };

        /**
         * Set the layout to the given mode, destroying and cleaning up the current
         * layout if there is one
         * @param  {string} mode The layout mode
         * @returns {void}
         */
        this.setLayout = function (mode) {
            // removing old reference to prevent errors when handling layoutchange message
            layout = null;
            layout = viewerBase.setLayout(mode);
        };

        /**
         * Zoom to the given value
         * @param  {float|string} val Numeric zoom level to zoom to or one of:
         *                            Crocodoc.ZOOM_IN
         *                            Crocodoc.ZOOM_OUT
         *                            Crocodoc.ZOOM_AUTO
         *                            Crocodoc.ZOOM_FIT_WIDTH
         *                            Crocodoc.ZOOM_FIT_HEIGHT
         * @returns {void}
         */
        this.zoom = function (val) {
            // adjust for page scale if passed value is a number
            var valFloat = parseFloat(val);
            if (layout) {
                if (valFloat) {
                    val = valFloat / (config.pageScale || 1);
                }
                layout.setZoom(val);
            }
        };

        /**
         * Scroll to the given page
         * @param  {int|string} page Page number or one of:
         *                           Crocodoc.SCROLL_PREVIOUS
         *                           Crocodoc.SCROLL_NEXT
         * @returns {void}
         */
        this.scrollTo = function (page) {
            if (layout) {
                layout.scrollTo(page);
            }
        };

        /**
         * Scrolls by the given pixel amount from the current location
         * @param  {int} left Left offset to scroll to
         * @param  {int} top  Top offset to scroll to
         * @returns {void}
         */
        this.scrollBy = function (left, top) {
            if (layout) {
                layout.scrollBy(left, top);
            }
        };

        /**
         * Focuses the viewport so it can be natively scrolled with the keyboard
         * @returns {void}
         */
        this.focus = function () {
            if (layout) {
                layout.focus();
            }
        };

        /**
         * Enable text selection, loading text assets per page if necessary
         * @returns {void}
         */
        this.enableTextSelection = function () {
            if (!config.enableTextSelection) {
                $el.removeClass(CSS_CLASS_TEXT_DISABLED);
                config.enableTextSelection = true;
                scope.broadcast('textenabledchange', { enabled: true });
            }
        };

        /**
         * Disable text selection, hiding text layer on pages if it's already there
         * and disabling the loading of new text assets
         * @returns {void}
         */
        this.disableTextSelection = function () {
            if (config.enableTextSelection) {
                $el.addClass(CSS_CLASS_TEXT_DISABLED);
                config.enableTextSelection = false;
                scope.broadcast('textenabledchange', { enabled: false });
            }
        };

        /**
         * Enable links
         * @returns {void}
         */
        this.enableLinks = function () {
            if (!config.enableLinks) {
                $el.removeClass(CSS_CLASS_LINKS_DISABLED);
                config.enableLinks = true;
            }
        };

        /**
         * Disable links
         * @returns {void}
         */
        this.disableLinks = function () {
            if (config.enableLinks) {
                $el.addClass(CSS_CLASS_LINKS_DISABLED);
                config.enableLinks = false;
            }
        };

        /**
         * Force layout update
         * @returns {void}
         */
        this.updateLayout = function () {
            if (layout) {
                // force update layout (incl. calculating page paddings)
                layout.updatePageStates(true);
                layout.setZoom();
            }
        };

        init();
    };

    Crocodoc.Viewer.prototype = new Crocodoc.EventTarget();
    Crocodoc.Viewer.prototype.constructor = Crocodoc.Viewer;

    /**
     * Get a viewer instance by id
     * @param {number} id   The id
     * @returns {Object}    The viewer instance
     */
    Crocodoc.Viewer.get = function (id) {
        return instances[id];
    };

    // Global defaults
    Crocodoc.Viewer.defaults = {
        // the url to load the assets from (required)
        url: null,

        // document viewer layout
        layout: Crocodoc.LAYOUT_VERTICAL,

        // initial zoom level
        zoom: Crocodoc.ZOOM_AUTO,

        // page to start on
        page: 1,

        // enable/disable text layer
        enableTextSelection: true,

        // enable/disable links layer
        enableLinks: true,

        // enable/disable click-and-drag
        enableDragging: false,

        // query string parameters to append to all asset requests
        queryParams: null,

        // plugin configs
        plugins: {},

        // whether to use the browser window as the viewport into the document (this
        // is useful when the document should take up the entire browser window, e.g.,
        // on mobile devices)
        useWindowAsViewport: false,

        //--------------------------------------------------------------------------
        // The following are undocumented, internal, or experimental options,
        // which are very subject to change and likely to be broken.
        // --
        // USE AT YOUR OWN RISK!
        //--------------------------------------------------------------------------

        // whether or not the conversion is finished (eg., pages are ready to be loaded)
        conversionIsComplete: true,

        // template for loading assets... this should rarely (if ever) change
        template: {
            svg: 'page-{{page}}.svg',
            img: 'page-{{page}}.png',
            html: 'text-{{page}}.html',
            css: 'stylesheet.css',
            json: 'info.json'
        },

        // default data-providers
        dataProviders: {
            metadata: 'metadata',
            stylesheet: 'stylesheet',
            'page-svg': 'page-svg',
            'page-text': 'page-text',
            'page-img': 'page-img'
        },

        // page to start/end on (pages outside this range will not be shown)
        pageStart: null,
        pageEnd: null,

        // zoom levels are relative to the viewport size,
        // and the dynamic zoom levels (auto, fitwidth, etc) will be added into the mix
        zoomLevels: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0]
    };
})();

<|endoftext|>


<commit_before>(function() {

	var binding = 'calendar';

	var Model = function(params) {
		var self = this;

		self.strings = {
			months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
			days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
		};

		self.constants = {
			daysInWeek: 7,
			dayStringLength: 2
		};

		self.utils = {
			date: {
				normalize: function(d) {
					var normalized = new Date(d.getTime());
					normalized.setMinutes(0);
					normalized.setHours(0);
					normalized.setSeconds(0);
					return normalized;
				},

				isSame: function(d1, d2) {
					if(!d1 || !d2) { return false; }
					return (
						(d1.getMonth() == d2.getMonth()) &&
						(d1.getDate() == d2.getDate()) &&
						(d1.getFullYear() == d2.getFullYear())
					);
				},

				isWeekend: function(d) {
					if(!d) { return false; }
					return d.getDay() === 0 || (d.getDay() == self.constants.daysInWeek - 1);
				}
			}
		};

		// Date Alias Helpers
		self.current = ko.observable(new Date()); // The current Date
		self.selected = ko.observable(); // The selected Date

		// Selects a date
		self.select = function(data, e) { self.selected(data); };

		self.nextMonth = function() {
			self.current(
				new Date( self.current().setMonth(self.current().getMonth()+1) )
			);
		};

		self.prevMonth = function() {
			self.current(
				new Date( self.current().setMonth(self.current().getMonth()-1) )
			);
		};

		self.sheet = ko.computed(function() {

			// Current month set to the first day
			var normalized = self.utils.date.normalize(self.current());
			normalized.setDate(1);
			normalized.setDate(normalized.getDate() - normalized.getDay()); // Set our date to the first day of the week from the normalized month

			var weeks = [],
				week = 0,
				startedMonth = false,
				completedMonth = false,
				completedWeek = false;

			while(true) {
				if(!weeks[week]) { weeks[week] = []; }

				// If we haven't filled the current week up
				if(weeks[week].length !== self.constants.daysInWeek) {

					// Append to the week
					weeks[week].push(new Date(normalized.getTime()));

					// And increment the date
					normalized.setDate( normalized.getDate() + 1 );
				}

				// If we've began working within the current month
				if( normalized.getMonth() == self.current().getMonth() ) { startedMonth = true; }

				// If we've started our current month and we've changed months (and thus completed it)
				if( startedMonth && (normalized.getMonth() !== self.current().getMonth()) ) { completedMonth = true; }

				// If we've completed our month and we are at the end of the week
				if(completedMonth && weeks[week].length == self.constants.daysInWeek) { completedWeek = true; }

				// If we've completed the month and our week
				if(completedMonth && completedWeek) { break; }

				// Otherwise, if we're at the end of the week, increment the current week
				if(weeks[week].length == self.constants.daysInWeek) { week++; }
			}

			return weeks;
		});
	};

	var Template =
		'
\

\

\

\
						\
							«\
							\
						\
							\
							\
						\
							»\
							\

\

\
							\

\

\

\

\
						\
							\
							\

\

\

\

';

	// Component
	ko.components.register(binding, {
		viewModel: Model,
		template: Template
	});

}).call(this);
<commit_msg>relative to UTC<commit_after>(function() {

	var binding = 'calendar';

	var Model = function(params) {
		var self = this;

		self.strings = {
			months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
			days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
		};

		self.constants = {
			daysInWeek: 7,
			dayStringLength: 2
		};

		self.utils = {
			date: {
				normalize: function(d) {
					var normalized = new Date(d.getTime());
					normalized.setMinutes(0);
					normalized.setHours(0);
					normalized.setSeconds(0);
					return normalized;
				},

				isSame: function(d1, d2) {
					if(!d1 || !d2) { return false; }
					return (
						(d1.getUTCMonth() == d2.getUTCMonth()) &&
						(d1.getUTCDate() == d2.getUTCDate()) &&
						(d1.getFullYear() == d2.getFullYear())
					);
				},

				isWeekend: function(d) {
					if(!d) { return false; }
					return d.getUTCDay() === 0 || (d.getUTCDay() == self.constants.daysInWeek - 1);
				}
			}
		};

		// Date Alias Helpers
		self.current = ko.observable(new Date()); // The current Date
		self.selected = ko.observable(); // The selected Date

		// Selects a date
		self.select = function(data, e) { self.selected(data); };

		self.nextMonth = function() {
			self.current(
				new Date( self.current().setMonth(self.current().getUTCMonth()+1) )
			);
		};

		self.prevMonth = function() {
			self.current(
				new Date( self.current().setMonth(self.current().getUTCMonth()-1) )
			);
		};

		self.sheet = ko.computed(function() {

			// Current month set to the first day
			var normalized = self.utils.date.normalize(self.current());
			normalized.setDate(1);
			normalized.setDate(normalized.getUTCDate() - normalized.getUTCDay()); // Set our date to the first day of the week from the normalized month

			var weeks = [],
				week = 0,
				startedMonth = false,
				completedMonth = false,
				completedWeek = false;

			while(true) {
				if(!weeks[week]) { weeks[week] = []; }

				// If we haven't filled the current week up
				if(weeks[week].length !== self.constants.daysInWeek) {

					// Append to the week
					weeks[week].push(new Date(normalized.getTime()));

					// And increment the date
					normalized.setDate( normalized.getUTCDate() + 1 );
				}

				// If we've began working within the current month
				if( normalized.getUTCMonth() == self.current().getUTCMonth() ) { startedMonth = true; }

				// If we've started our current month and we've changed months (and thus completed it)
				if( startedMonth && (normalized.getUTCMonth() !== self.current().getUTCMonth()) ) { completedMonth = true; }

				// If we've completed our month and we are at the end of the week
				if(completedMonth && weeks[week].length == self.constants.daysInWeek) { completedWeek = true; }

				// If we've completed the month and our week
				if(completedMonth && completedWeek) { break; }

				// Otherwise, if we're at the end of the week, increment the current week
				if(weeks[week].length == self.constants.daysInWeek) { week++; }
			}

			return weeks;
		});
	};

	var Template =
		'
\

\

\

\
						\
							«\
							\
						\
							\
							\
						\
							»\
							\

\

\
							\

\

\

\

\
						\
							\
							\

\

\

\

';

	// Component
	ko.components.register(binding, {
		viewModel: Model,
		template: Template
	});

}).call(this);
<|endoftext|>


<commit_before>(function (clique, _, Backbone, $) {
    "use strict";

    clique.adapter = {};

    clique.Adapter = function (options) {
        var accessors;

        // Keep track of accessors.
        this.accessors = accessors = {};
        this.onNewAccessor = this.onNewAccessor || _.noop;
        this.addAccessor = function (blob) {
            var mut;

            if (!_.has(accessors, blob.key)) {
                accessors[blob.key] = new clique.util.Accessor(blob);
                this.onNewAccessor(mut);
            }

            mut = accessors[blob.key];

            return mut;
        };

        // Define class methods.
        this.getAccessor = _.propertyOf(accessors);

        this.findNodes = function (cfg) {
            var spec = cfg.spec || {},
                offset = cfg.offset || 0,
                limit = cfg.limit;

            return $.when(this.findNodesRaw(spec, offset, limit))
                .then(_.partial(_.map, _, this.addAccessor, this));
        };

        this.findNode = function (spec) {
            var req = this.findNodes({
                spec: spec,
                offset: 0,
                limit: 1
            });

            return $.when(req).then(_.bind(function (results) {
                return results && results[0];
            }, this));
        };

        this.findNodeByKey = function (key) {
            return this.findNode({
                key: key
            });
        };

        this.findLinks = function (cfg) {
            var spec = cfg.spec,
                source = cfg.source,
                target = cfg.target,
                directed = cfg.directed,
                offset = cfg.offset,
                limit = cfg.limit;

            return $.when(this.findLinksRaw(spec, source, target, directed, offset, limit))
                .then(_.partial(_.map, _, this.addAccessor, this));
        };

        this.findLink = function (_cfg) {
            var cfg = _.extend({}, _cfg, {
                offset: 0,
                limit: 1
            });

            return $.when(this.findLinks(cfg)).then(_.bind(function (results) {
                return results && results[0];
            }, this));
        };

        this.findLinkByKey = function (key) {
            return this.findLink({
                key: key
            });
        };

        this.neighborLinkCount = function (node, opts) {
            return this.neighborLinks(node, opts).then(_.size);
        };

        this.outgoingLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: false,
                undirected: false
            });
        };

        this.outflowingLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: false,
                undirected: true
            });
        };

        this.incomingLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: true,
                undirected: false
            });
        };

        this.inflowingLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: true,
                undirected: true
            });
        };

        this.undirectedLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: false,
                undirected: true
            });
        };

        this.directedLinkCount = function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: true,
                undirected: false
            });
        };

        this.neighborLinks = function (node, cfg) {
            var types,
                offset,
                limit;

            cfg = cfg || {};

            types = cfg.types || {};
            offset = cfg.offset;
            limit = cfg.limit;

            return this.neighborLinksRaw(node, types, offset, limit)
                .then(_.partial(_.map, _, this.addAccessor, this));
        };

        this.outgoingLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.outflowingLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.incomingLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.inflowingLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.undirectedLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.directedLinks = function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.neighborCount = function (node, opts) {
            return this.neighbors(node, opts).then(function (nbrs) {
                return _.size(nbrs.nodes);
            });
        };

        this.outgoingNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: false,
                undirected: false
            });
        };

        this.outflowingNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: false,
                undirected: true
            });
        };

        this.incomingNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: true,
                undirected: false
            });
        };

        this.inflowingNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: true,
                undirected: true
            });
        };

        this.undirectedNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: false,
                undirected: true
            });
        };

        this.directedNeighborCount = function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: true,
                undirected: false
            });
        };

        this.neighbors = function (node, opts) {
            var key = node.key(),
                links;

            return this.neighborLinks(node, opts).then(_.bind(function (links_) {
                var neighborKeys,
                    muts;

                links = links_;

                neighborKeys = _.map(links, function (link) {
                    return key === link.source() ? link.target() : link.source();
                });

                // Attempt to retrieve the accessors.  The ones we don't have
                // yet will show up as undefined in this array.
                muts = _.map(neighborKeys, this.getAccessor, this);

                _.each(muts, function (mut, i) {
                    if (_.isUndefined(mut)) {
                        muts[i] = this.findNodeByKey(neighborKeys[i]);
                    } else {
                        muts[i] = $.when(muts[i]);
                    }
                }, this);

                return $.when.apply($, muts);
            }, this)).then(function () {
                return {
                    nodes: _.toArray(arguments),
                    links: links
                };
            });
        };

        this.outgoingNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.outflowingNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.incomingNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.inflowingNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.undirectedNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        };

        this.directedNeighbors = function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        };

        this.createNode = function (data) {
            return $.when(this.createNodeRaw(data || {}))
                .then(_.bind(this.addAccessor, this));
        };

        this.createLink = function (source, target, _data, undirected) {
            var data;

            // If source/target is a accessor, call its key method to get the
            // key; otherwise, assume it is a string describing the key already.
            source = _.result(source, "key", source);
            target = _.result(target, "key", target);

            data = _data || {};
            undirected = _.isUndefined(undirected) ? false : undirected;

            return $.when(this.createLinkRaw(source, target, data, undirected))
                .then(_.bind(this.addAccessor, this));
        };

        this.destroyNode = function (node) {
            var key = node.key();
            return this.destroyNodeRaw(key).then(function (response) {
                return {
                    key: key,
                    response: response
                };
            });
        };

        this.destroyLink = function (link) {
            var key = link.key();
            return this.destroyLinkRaw(key).then(function (response) {
                return {
                    key: key,
                    response: response
                };
            });
        };

        // Default implementation methods.
        this.findNodesRaw = function () {
            throw new Error("To call findNodes(), findNode(), or findNodeByKey(), you must implement findNodesRaw()");
        };

        this.findNodesRaw = function () {
            throw new Error("To call findNodes(), findNode(), or findNodeByKey(), you must implement findNodesRaw()");
        };

        this.neighborLinksRaw = function (node, _types, offset, limit) {
            var reqs = [],
                types = {};

            _.each(["outgoing", "incoming", "undirected"], function (mode) {
                types[mode] = _.isUndefined(_types[mode]) ? true : _types[mode];
            });

            if (types.outgoing) {
                reqs.push(this.findLinksRaw(undefined, node.key(), undefined, true));
            }

            if (types.incoming) {
                reqs.push(this.findLinksRaw(undefined, undefined, node.key(), true));
            }

            if (types.undirected) {
                reqs.push(this.findLinksRaw(undefined, node.key(), undefined, false));
                reqs.push(this.findLinksRaw(undefined, undefined, node.key(), false));
            }

            return $.when.apply($, reqs).then(function () {
                // This pipeline zips together the list of results, then
                // flattens the resulting list-of-lists, removes all undefineds
                // (which may arise if some of the lists are shorter than
                // others), then finally slices the result to get the final list
                // of links.
                return _.filter(_.flatten(_.zip.apply(_, _.toArray(arguments))), _.negate(_.isUndefined))
                    .slice(offset || 0, (offset + limit) || undefined);
            });
        };

        this.createNodeRaw = function () {
            throw new Error("To call createNode() you must implement createNodeRaw()");
        };

        this.destroyNodeRaw = function () {
            throw new Error("To call destroyNode() you must implement destroyNodeRaw()");
        };

        this.createLinkRaw = function () {
            throw new Error("To call createLink() you must implement createLinkRaw()");
        };

        this.destroyLinkRaw = function () {
            throw new Error("To call destroyLink() you must implement destroyLinkRaw()");
        };

        options = options || {};
        this.initialize.apply(this, arguments);
    };

    clique.Adapter.extend = Backbone.Model.extend;

    clique.adapter.NodeLinkList = clique.Adapter.extend({
        initialize: function (options) {
            var table = {};

            this.nodes = clique.util.deepCopy(options.nodes);
            this.links = clique.util.deepCopy(options.links);

            _.each(this.nodes, function (node, i) {
                var tmpNs = "datax",
                    ns;

                // Promote the data elements into a dedicated namespace.
                //
                // First figure out a suitable temporary name to use for the
                // namespace.
                while (_.has(node, tmpNs)) {
                    tmpNs += "x";
                }

                // Create the namespace.
                ns = node[tmpNs] = {};

                // Move all top-level properties into the namespace.
                _.each(node, function (v, k) {
                    if (k !== tmpNs) {
                        ns[k] = v;
                        delete node[k];
                    }
                });

                // Rename the temporary namespace as "data".
                if (tmpNs !== "data") {
                    node.data = ns;
                    delete node[tmpNs];
                }

                table[i] = node;

                // Assign a unique key to this node.
                node.key = _.uniqueId("node_");
            });

            _.each(this.links, function (link) {
                link.key = _.uniqueId("link_");

                link.source = table[link.source];
                link.target = table[link.target];
            }, this);
        },

        findNodesRaw: function (_spec, offset, limit) {
            var spec = clique.util.deepCopy(_spec),
                searchspace = this.nodes,
                result;

            if (spec.key) {
                searchspace = _.filter(searchspace, function (node) {
                    return node.key === spec.key;
                });

                delete spec.key;
            }

            result = _.filter(searchspace, function (node) {
                return _.isMatch(node.data, spec);
            });

            return result.slice(offset || 0, (offset + limit) || undefined);
        },

        findLinksRaw: function (spec, source, target, directed, offset, limit) {
            return _.filter(this.links, function (link) {
                var directedMatch,
                    sourceMatch = _.isUndefined(source) || (link.source.key === source),
                    targetMatch = _.isUndefined(target) || (link.target.key === target),
                    dataMatch = _.isMatch(spec || {}, link.data);

                if (_.isUndefined(directed) || _.isNull(directed)) {
                    directedMatch = true;
                } else if (directed) {
                    directedMatch = !link.undirected;
                } else {
                    directedMatch = link.undirected;
                }

                return _.every([sourceMatch, targetMatch, dataMatch, directedMatch]);
            }).slice(offset || 0, (offset + limit) || undefined);
        }
    });
}(window.clique, window._, window.Backbone, window.jQuery));
<commit_msg>Change Adapter class declaration to follow internal Backbone style<commit_after>(function (clique, _, Backbone, $) {
    "use strict";

    clique.adapter = {};

    clique.Adapter = function () {
        // Keep track of accessors.
        this.accessors = {};
        this.onNewAccessor = this.onNewAccessor || _.noop;
        this.addAccessor = function (blob) {
            var mut,
                accessors = this.accessors;

            if (!_.has(accessors, blob.key)) {
                accessors[blob.key] = new clique.util.Accessor(blob);
                this.onNewAccessor(mut);
            }

            mut = accessors[blob.key];

            return mut;
        };

        this.getAccessor = _.propertyOf(this.accessors);

        this.initialize.apply(this, arguments);
    };

    _.extend(clique.Adapter.prototype, {
        // Define class methods.
        initialize: _.noop,

        findNodes: function (cfg) {
            var spec = cfg.spec || {},
                offset = cfg.offset || 0,
                limit = cfg.limit;

            return $.when(this.findNodesRaw(spec, offset, limit))
                .then(_.partial(_.map, _, this.addAccessor, this));
        },

        findNode: function (spec) {
            var req = this.findNodes({
                spec: spec,
                offset: 0,
                limit: 1
            });

            return $.when(req).then(_.bind(function (results) {
                return results && results[0];
            }, this));
        },

        findNodeByKey: function (key) {
            return this.findNode({
                key: key
            });
        },

        findLinks: function (cfg) {
            var spec = cfg.spec,
                source = cfg.source,
                target = cfg.target,
                directed = cfg.directed,
                offset = cfg.offset,
                limit = cfg.limit;

            return $.when(this.findLinksRaw(spec, source, target, directed, offset, limit))
                .then(_.partial(_.map, _, this.addAccessor, this));
        },

        findLink: function (_cfg) {
            var cfg = _.extend({}, _cfg, {
                offset: 0,
                limit: 1
            });

            return $.when(this.findLinks(cfg)).then(_.bind(function (results) {
                return results && results[0];
            }, this));
        },

        findLinkByKey: function (key) {
            return this.findLink({
                key: key
            });
        },

        neighborLinkCount: function (node, opts) {
            return this.neighborLinks(node, opts).then(_.size);
        },

        outgoingLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: false,
                undirected: false
            });
        },

        outflowingLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: false,
                undirected: true
            });
        },

        incomingLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: true,
                undirected: false
            });
        },

        inflowingLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: true,
                undirected: true
            });
        },

        undirectedLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: false,
                incoming: false,
                undirected: true
            });
        },

        directedLinkCount: function (node) {
            return this.neighborLinkCount(node, {
                outgoing: true,
                incoming: true,
                undirected: false
            });
        },

        neighborLinks: function (node, cfg) {
            var types,
                offset,
                limit;

            cfg = cfg || {};

            types = cfg.types || {};
            offset = cfg.offset;
            limit = cfg.limit;

            return this.neighborLinksRaw(node, types, offset, limit)
                .then(_.partial(_.map, _, this.addAccessor, this));
        },

        outgoingLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        outflowingLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        incomingLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        inflowingLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        undirectedLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: false,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        directedLinks: function (node, offset, limit) {
            return this.neighborLinks(node, {
                types: {
                    outgoing: true,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        neighborCount: function (node, opts) {
            return this.neighbors(node, opts).then(function (nbrs) {
                return _.size(nbrs.nodes);
            });
        },

        outgoingNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: false,
                undirected: false
            });
        },

        outflowingNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: false,
                undirected: true
            });
        },

        incomingNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: true,
                undirected: false
            });
        },

        inflowingNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: true,
                undirected: true
            });
        },

        undirectedNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: false,
                incoming: false,
                undirected: true
            });
        },

        directedNeighborCount: function (node) {
            return this.neighborCount(node, {
                outgoing: true,
                incoming: true,
                undirected: false
            });
        },

        neighbors: function (node, opts) {
            var key = node.key(),
                links;

            return this.neighborLinks(node, opts).then(_.bind(function (links_) {
                var neighborKeys,
                    muts;

                links = links_;

                neighborKeys = _.map(links, function (link) {
                    return key === link.source() ? link.target() : link.source();
                });

                // Attempt to retrieve the accessors.  The ones we don't have
                // yet will show up as undefined in this array.
                muts = _.map(neighborKeys, this.getAccessor, this);

                _.each(muts, function (mut, i) {
                    if (_.isUndefined(mut)) {
                        muts[i] = this.findNodeByKey(neighborKeys[i]);
                    } else {
                        muts[i] = $.when(muts[i]);
                    }
                }, this);

                return $.when.apply($, muts);
            }, this)).then(function () {
                return {
                    nodes: _.toArray(arguments),
                    links: links
                };
            });
        },

        outgoingNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        outflowingNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        incomingNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        inflowingNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: true,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        undirectedNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: false,
                    incoming: false,
                    undirected: true
                },
                offset: offset,
                limit: limit
            });
        },

        directedNeighbors: function (node, offset, limit) {
            return this.neighbors(node, {
                types: {
                    outgoing: true,
                    incoming: true,
                    undirected: false
                },
                offset: offset,
                limit: limit
            });
        },

        createNode: function (data) {
            return $.when(this.createNodeRaw(data || {}))
                .then(_.bind(this.addAccessor, this));
        },

        createLink: function (source, target, _data, undirected) {
            var data;

            // If source/target is a accessor, call its key method to get the
            // key; otherwise, assume it is a string describing the key already.
            source = _.result(source, "key", source);
            target = _.result(target, "key", target);

            data = _data || {};
            undirected = _.isUndefined(undirected) ? false : undirected;

            return $.when(this.createLinkRaw(source, target, data, undirected))
                .then(_.bind(this.addAccessor, this));
        },

        destroyNode: function (node) {
            var key = node.key();
            return this.destroyNodeRaw(key).then(function (response) {
                return {
                    key: key,
                    response: response
                };
            });
        },

        destroyLink: function (link) {
            var key = link.key();
            return this.destroyLinkRaw(key).then(function (response) {
                return {
                    key: key,
                    response: response
                };
            });
        },

        // Default implementation methods.
        findNodesRaw: function () {
            throw new Error("To call findNodes(), findNode(), or findNodeByKey(), you must implement findNodesRaw()");
        },

        findLinksRaw: function () {
            throw new Error("To call findLinks(), findLink(), or findLinkByKey(), you must implement findLinksRaw()");
        },

        neighborLinksRaw: function (node, _types, offset, limit) {
            var reqs = [],
                types = {};

            _.each(["outgoing", "incoming", "undirected"], function (mode) {
                types[mode] = _.isUndefined(_types[mode]) ? true : _types[mode];
            });

            if (types.outgoing) {
                reqs.push(this.findLinksRaw(undefined, node.key(), undefined, true));
            }

            if (types.incoming) {
                reqs.push(this.findLinksRaw(undefined, undefined, node.key(), true));
            }

            if (types.undirected) {
                reqs.push(this.findLinksRaw(undefined, node.key(), undefined, false));
                reqs.push(this.findLinksRaw(undefined, undefined, node.key(), false));
            }

            return $.when.apply($, reqs).then(function () {
                // This pipeline zips together the list of results, then
                // flattens the resulting list-of-lists, removes all undefineds
                // (which may arise if some of the lists are shorter than
                // others), then finally slices the result to get the final list
                // of links.
                return _.filter(_.flatten(_.zip.apply(_, _.toArray(arguments))), _.negate(_.isUndefined))
                    .slice(offset || 0, (offset + limit) || undefined);
            });
        },

        createNodeRaw: function () {
            throw new Error("To call createNode() you must implement createNodeRaw()");
        },

        destroyNodeRaw: function () {
            throw new Error("To call destroyNode() you must implement destroyNodeRaw()");
        },

        createLinkRaw: function () {
            throw new Error("To call createLink() you must implement createLinkRaw()");
        },

        destroyLinkRaw: function () {
            throw new Error("To call destroyLink() you must implement destroyLinkRaw()");
        }
    });

    clique.Adapter.extend = Backbone.Model.extend;

    clique.adapter.NodeLinkList = clique.Adapter.extend({
        initialize: function (options) {
            var table = {};

            this.nodes = clique.util.deepCopy(options.nodes);
            this.links = clique.util.deepCopy(options.links);

            _.each(this.nodes, function (node, i) {
                var tmpNs = "datax",
                    ns;

                // Promote the data elements into a dedicated namespace.
                //
                // First figure out a suitable temporary name to use for the
                // namespace.
                while (_.has(node, tmpNs)) {
                    tmpNs += "x";
                }

                // Create the namespace.
                ns = node[tmpNs] = {};

                // Move all top-level properties into the namespace.
                _.each(node, function (v, k) {
                    if (k !== tmpNs) {
                        ns[k] = v;
                        delete node[k];
                    }
                });

                // Rename the temporary namespace as "data".
                if (tmpNs !== "data") {
                    node.data = ns;
                    delete node[tmpNs];
                }

                table[i] = node;

                // Assign a unique key to this node.
                node.key = _.uniqueId("node_");
            });

            _.each(this.links, function (link) {
                link.key = _.uniqueId("link_");

                link.source = table[link.source];
                link.target = table[link.target];
            }, this);
        },

        findNodesRaw: function (_spec, offset, limit) {
            var spec = clique.util.deepCopy(_spec),
                searchspace = this.nodes,
                result;

            if (spec.key) {
                searchspace = _.filter(searchspace, function (node) {
                    return node.key === spec.key;
                });

                delete spec.key;
            }

            result = _.filter(searchspace, function (node) {
                return _.isMatch(node.data, spec);
            });

            return result.slice(offset || 0, (offset + limit) || undefined);
        },

        findLinksRaw: function (spec, source, target, directed, offset, limit) {
            return _.filter(this.links, function (link) {
                var directedMatch,
                    sourceMatch = _.isUndefined(source) || (link.source.key === source),
                    targetMatch = _.isUndefined(target) || (link.target.key === target),
                    dataMatch = _.isMatch(spec || {}, link.data);

                if (_.isUndefined(directed) || _.isNull(directed)) {
                    directedMatch = true;
                } else if (directed) {
                    directedMatch = !link.undirected;
                } else {
                    directedMatch = link.undirected;
                }

                return _.every([sourceMatch, targetMatch, dataMatch, directedMatch]);
            }).slice(offset || 0, (offset + limit) || undefined);
        }
    });
}(window.clique, window._, window.Backbone, window.jQuery));
<|endoftext|>


<commit_before>import React from 'react';
import NavLink from './NavLink';
import Header from 'grommet/components/Header';
import Menu from 'grommet/components/Menu';
import Image from 'grommet/components/Image';
import Footer from 'grommet/components/Footer';

export default React.createClass({
  getInitialState: function() {
    return {
      userName: '',
      userEmail: '',
      userRole: ''
    };
  },
  componentDidMount: function() {
    this.serverRequest = $.get('https://datagovernance-dev.itcs.hpecorp.net:1337/WhoAmI', function (result) {
      var results=JSON.parse(result);
      this.setState({
        userName: results.name
      });
    }.bind(this));
  },

  render() {
    return (

			<Image src="img/Logo.jpg" size="small" />
				<Menu direction="row" size="medium">
					<NavLink to="/#">
						{this.state.userName}
					</NavLink>
					 <NavLink to="/D3_v4_er">
						Entity Relationship Diagram
					</NavLink>
				</Menu>

		<Image src="img/Banner_DataCenter6a.jpg" full="horizontal" />
		{this.props.children}

			Footer Informatin

	  );
  }
});

<commit_msg>Update App.js<commit_after>import React from 'react';
import NavLink from './NavLink';
import Header from 'grommet/components/Header';
import Menu from 'grommet/components/Menu';
import Image from 'grommet/components/Image';
import Footer from 'grommet/components/Footer';

export default React.createClass({
  render() {
    return (

			<Image src="img/Logo.jpg" size="small" />
				<Menu direction="row" size="medium">
					 <NavLink to="/D3_v4_er">
						Entity Relationship Diagram
					</NavLink>
				</Menu>

		<Image src="img/Banner_DataCenter6a.jpg" full="horizontal" />
		{this.props.children}

			Footer Informatin

	  );
  }
});

<|endoftext|>


<commit_before>var sjcl    = require('../../../build/sjcl');
var utils   = require('./utils');
var jsbn    = require('./jsbn');
var extend  = require('extend');

var BigInteger = jsbn.BigInteger;
var nbi        = jsbn.nbi;

var Base = {};

var alphabets = Base.alphabets = {
  ripple  :  "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",
  tipple  :  "RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",
  bitcoin :  "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
};

extend(Base, {
  VER_NONE              : 1,
  VER_NODE_PUBLIC       : 28,
  VER_NODE_PRIVATE      : 32,
  VER_ACCOUNT_ID        : 0,
  VER_ACCOUNT_PUBLIC    : 35,
  VER_ACCOUNT_PRIVATE   : 34,
  VER_FAMILY_GENERATOR  : 41,
  VER_FAMILY_SEED       : 33
});

function sha256(bytes) {
  return sjcl.codec.bytes.fromBits(sjcl.hash.sha256.hash(sjcl.codec.bytes.toBits(bytes)));
};

function sha256hash(bytes) {
  return sha256(sha256(bytes));
};

// --> input: big-endian array of bytes.
// <-- string at least as long as input.
Base.encode = function (input, alpha) {
  var alphabet = alphabets[alpha || 'ripple'];
  var bi_base  = new BigInteger(String(alphabet.length));
  var bi_q     = nbi();
  var bi_r     = nbi();
  var bi_value = new BigInteger(input);
  var buffer   = [];

  while (bi_value.compareTo(BigInteger.ZERO) > 0) {
    bi_value.divRemTo(bi_base, bi_q, bi_r);
    bi_q.copyTo(bi_value);
    buffer.push(alphabet[bi_r.intValue()]);
  }

  for (var i=0; i !== input.length && !input[i]; i += 1) {
    buffer.push(alphabet[0]);
  }

  return buffer.reverse().join('');
};

// --> input: String
// <-- array of bytes or undefined.
Base.decode = function (input, alpha) {
  if (typeof input !== 'string') {
    return void(0);
  }

  var alphabet = alphabets[alpha || 'ripple'];
  var bi_base  = new BigInteger(String(alphabet.length));
  var bi_value = nbi();
  var i;

  for (i = 0; i != input.length && input[i] === alphabet[0]; i += 1)
  ;

  for (; i !== input.length; i += 1) {
    var v = alphabet.indexOf(input[i]);

    if (v < 0) {
      return void(0);
    }

    var r = nbi();
    r.fromInt(v);
    bi_value  = bi_value.multiply(bi_base).add(r);
  }

  // toByteArray:
  // - Returns leading zeros!
  // - Returns signed bytes!
  var bytes =  bi_value.toByteArray().map(function (b) { return b ? b < 0 ? 256+b : b : 0; });
  var extra = 0;

  while (extra != bytes.length && !bytes[extra]) {
    extra += 1;
  }

  if (extra) {
    bytes = bytes.slice(extra);
  }

  var zeros = 0;

  while (zeros !== input.length && input[zeros] === alphabet[0]) {
    zeros += 1;
  }

  return [].concat(utils.arraySet(zeros, 0), bytes);
};

Base.verify_checksum = function (bytes) {
  var computed = sha256hash(bytes.slice(0, -4)).slice(0, 4);
  var checksum = bytes.slice(-4);
  var result = true;

  for (var i=0; i<4; i++) {
    if (computed[i] !== checksum[i]) {
      result = false;
      break;
    }
  }

  return result;
};

// --> input: Array
// <-- String
Base.encode_check = function (version, input, alphabet) {
  var buffer = [].concat(version, input);
  var check  = sha256(sha256(buffer)).slice(0, 4);

  return Base.encode([].concat(buffer, check), alphabet);
};

// --> input : String
// <-- NaN || BigInteger
Base.decode_check = function (version, input, alphabet) {
  var buffer = Base.decode(input, alphabet);

  if (!buffer || buffer.length < 5) {
    return NaN;
  }

  // Single valid version
  if (typeof version && buffer[0] !== version === 'number') {
    return NaN;
  }

  // Multiple allowed versions
  if (typeof version && Array.isArray(version) === 'object') {
    var match = false;

    for (var i=0, l=version.length; i<l; i++) {
      match |= version[i] === buffer[0];
    }

    if (!match) {
      return NaN;
    }
  }

  if (!Base.verify_checksum(buffer)) {
    return NaN;
  }

  // We'll use the version byte to add a leading zero, this ensures JSBN doesn't
  // intrepret the value as a negative number
  buffer[0] = 0;

  return new BigInteger(buffer.slice(0, -4), 256);
}:

exports.Base = Base;
<commit_msg>Remove colon<commit_after>var sjcl    = require('../../../build/sjcl');
var utils   = require('./utils');
var jsbn    = require('./jsbn');
var extend  = require('extend');

var BigInteger = jsbn.BigInteger;
var nbi        = jsbn.nbi;

var Base = {};

var alphabets = Base.alphabets = {
  ripple  :  "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",
  tipple  :  "RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",
  bitcoin :  "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
};

extend(Base, {
  VER_NONE              : 1,
  VER_NODE_PUBLIC       : 28,
  VER_NODE_PRIVATE      : 32,
  VER_ACCOUNT_ID        : 0,
  VER_ACCOUNT_PUBLIC    : 35,
  VER_ACCOUNT_PRIVATE   : 34,
  VER_FAMILY_GENERATOR  : 41,
  VER_FAMILY_SEED       : 33
});

function sha256(bytes) {
  return sjcl.codec.bytes.fromBits(sjcl.hash.sha256.hash(sjcl.codec.bytes.toBits(bytes)));
};

function sha256hash(bytes) {
  return sha256(sha256(bytes));
};

// --> input: big-endian array of bytes.
// <-- string at least as long as input.
Base.encode = function (input, alpha) {
  var alphabet = alphabets[alpha || 'ripple'];
  var bi_base  = new BigInteger(String(alphabet.length));
  var bi_q     = nbi();
  var bi_r     = nbi();
  var bi_value = new BigInteger(input);
  var buffer   = [];

  while (bi_value.compareTo(BigInteger.ZERO) > 0) {
    bi_value.divRemTo(bi_base, bi_q, bi_r);
    bi_q.copyTo(bi_value);
    buffer.push(alphabet[bi_r.intValue()]);
  }

  for (var i=0; i !== input.length && !input[i]; i += 1) {
    buffer.push(alphabet[0]);
  }

  return buffer.reverse().join('');
};

// --> input: String
// <-- array of bytes or undefined.
Base.decode = function (input, alpha) {
  if (typeof input !== 'string') {
    return void(0);
  }

  var alphabet = alphabets[alpha || 'ripple'];
  var bi_base  = new BigInteger(String(alphabet.length));
  var bi_value = nbi();
  var i;

  for (i = 0; i != input.length && input[i] === alphabet[0]; i += 1)
  ;

  for (; i !== input.length; i += 1) {
    var v = alphabet.indexOf(input[i]);

    if (v < 0) {
      return void(0);
    }

    var r = nbi();
    r.fromInt(v);
    bi_value  = bi_value.multiply(bi_base).add(r);
  }

  // toByteArray:
  // - Returns leading zeros!
  // - Returns signed bytes!
  var bytes =  bi_value.toByteArray().map(function (b) { return b ? b < 0 ? 256+b : b : 0; });
  var extra = 0;

  while (extra != bytes.length && !bytes[extra]) {
    extra += 1;
  }

  if (extra) {
    bytes = bytes.slice(extra);
  }

  var zeros = 0;

  while (zeros !== input.length && input[zeros] === alphabet[0]) {
    zeros += 1;
  }

  return [].concat(utils.arraySet(zeros, 0), bytes);
};

Base.verify_checksum = function (bytes) {
  var computed = sha256hash(bytes.slice(0, -4)).slice(0, 4);
  var checksum = bytes.slice(-4);
  var result = true;

  for (var i=0; i<4; i++) {
    if (computed[i] !== checksum[i]) {
      result = false;
      break;
    }
  }

  return result;
};

// --> input: Array
// <-- String
Base.encode_check = function (version, input, alphabet) {
  var buffer = [].concat(version, input);
  var check  = sha256(sha256(buffer)).slice(0, 4);

  return Base.encode([].concat(buffer, check), alphabet);
};

// --> input : String
// <-- NaN || BigInteger
Base.decode_check = function (version, input, alphabet) {
  var buffer = Base.decode(input, alphabet);

  if (!buffer || buffer.length < 5) {
    return NaN;
  }

  // Single valid version
  if (typeof version && buffer[0] !== version === 'number') {
    return NaN;
  }

  // Multiple allowed versions
  if (typeof version && Array.isArray(version) === 'object') {
    var match = false;

    for (var i=0, l=version.length; i<l; i++) {
      match |= version[i] === buffer[0];
    }

    if (!match) {
      return NaN;
    }
  }

  if (!Base.verify_checksum(buffer)) {
    return NaN;
  }

  // We'll use the version byte to add a leading zero, this ensures JSBN doesn't
  // intrepret the value as a negative number
  buffer[0] = 0;

  return new BigInteger(buffer.slice(0, -4), 256);
};

exports.Base = Base;
<|endoftext|>


<commit_before>import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import { routeState } from '../components/routing';
import { repos } from '../components/github';
import { authors } from '../components/library';
import { resourceFetchStatus } from '../resource-manager';

const rootReducer = combineReducers({
  routeState,
  repos,
  authors,
  resourceFetchStatus
});

const configureStore = () => {
  const middlewares = [thunk];

  if (process.env.NODE_ENV && process.env.NODE_ENV !== 'production') {
    middlewares.push(createLogger());
  }

  return createStore(
    rootReducer,
    applyMiddleware(...middlewares)
  );
}

const store = configureStore();

export default store;
<commit_msg>Fix usage of redux-logger<commit_after>import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { createLogger } from 'redux-logger';
import { routeState } from '../components/routing';
import { repos } from '../components/github';
import { authors } from '../components/library';
import { resourceFetchStatus } from '../resource-manager';

const rootReducer = combineReducers({
  routeState,
  repos,
  authors,
  resourceFetchStatus
});

const configureStore = () => {
  const middlewares = [thunk];

  if (process.env.NODE_ENV && process.env.NODE_ENV !== 'production') {
    middlewares.push(createLogger());
  }

  return createStore(
    rootReducer,
    applyMiddleware(...middlewares)
  );
}

const store = configureStore();

export default store;
<|endoftext|>