<commit_before>(function($) {
    $.isScrollToFixed = function(el) {
        return $(el).data('ScrollToFixed') !== undefined;
    };

    $.ScrollToFixed = function(el, options) {
        // To avoid scope issues, use 'base' instead of 'this' to reference this
        // class from internal events and functions.
        var base = this;

        // Access to jQuery and DOM versions of element.
        base.$el = $(el);
        base.el = el;

        // Add a reverse reference to the DOM object.
        base.$el.data('ScrollToFixed', base);

        // A flag so we know if the scroll has been reset.
        var isReset = false;

        // The element that was given to us to fix if scrolled above the top of
        // the page.
        var target = base.$el;

        var position;
        var originalPosition;

        var originalOffset;

        // The offset top of the element when resetScroll was called. This is
        // used to determine if we have scrolled past the top of the element.
        var offsetTop = 0;

        // The offset left of the element when resetScroll was called. This is
        // used to move the element left or right relative to the horizontal
        // scroll.
        var offsetLeft = 0;
        var originalOffsetLeft = -1;

        // This last offset used to move the element horizontally. This is used
        // to determine if we need to move the element because we would not want
        // to do that for no reason.
        var lastOffsetLeft = -1;

        // This is the element used to fill the void left by the target element
        // when it goes fixed; otherwise, everything below it moves up the page.
        var spacer = null;

        var spacerClass;

        var className;

        // Capture the original offsets for the target element. This needs to be
        // called whenever the page size changes or when the page is first
        // scrolled. For some reason, calling this before the page is first
        // scrolled causes the element to become fixed too late.
        function resetScroll() {
            // Set the element to it original positioning.
            target.trigger('preUnfixed.ScrollToFixed');
            setUnfixed();
            target.trigger('unfixed.ScrollToFixed');

            // Reset the last offset used to determine if the page has moved
            // horizontally.
            lastOffsetLeft = -1;

            // Capture the offset top of the target element.
            offsetTop = target.offset().top;

            // Capture the offset left of the target element.
            offsetLeft = target.offset().left;

            // If the offsets option is on, alter the left offset.
            if (base.options.offsets) {
                offsetLeft += (target.offset().left - target.position().left);
            }

            if (originalOffsetLeft == -1) {
                originalOffsetLeft = offsetLeft;
            }

            position = target.css('position');

            // Set that this has been called at least once.
            isReset = true;

            if (base.options.bottom != -1) {
                target.trigger('preFixed.ScrollToFixed');
                setFixed();
                target.trigger('fixed.ScrollToFixed');
            }
        }

        function getLimit() {
            var limit = base.options.limit;
            if (!limit) return 0;

            if (typeof(limit) === 'function') {
                return limit.apply(target);
            }
            return limit;
        }

        // Returns whether the target element is fixed or not.
        function isFixed() {
            return position === 'fixed';
        }

        // Returns whether the target element is absolute or not.
        function isAbsolute() {
            return position === 'absolute';
        }

        function isUnfixed() {
            return !(isFixed() || isAbsolute());
        }

        // Sets the target element to fixed. Also, sets the spacer to fill the
        // void left by the target element.
        function setFixed() {
            // Only fix the target element and the spacer if we need to.
            if (!isFixed()) {
                // Set the spacer to fill the height and width of the target
                // element, then display it.
                spacer.css({
                    'display' : target.css('display'),
                    'width' : target.outerWidth(true),
                    'height' : target.outerHeight(true),
                    'float' : target.css('float')
                });

                // Set the target element to fixed and set its width so it does
                // not fill the rest of the page horizontally. Also, set its top
                // to the margin top specified in the options.

                cssOptions={
                    'position' : 'fixed',
                    'top' : base.options.bottom == -1?getMarginTop():'',
                    'bottom' : base.options.bottom == -1?'':base.options.bottom,
                    'margin-left' : '0px'
                }
                if (!base.options.dontSetWidth){ cssOptions['width']=target.width(); };

                target.css(cssOptions);

                target.addClass('scroll-to-fixed-fixed');

                if (base.options.className) {
                    target.addClass(base.options.className);
                }

                position = 'fixed';
            }
        }

        function setAbsolute() {

            var top = getLimit();
            var left = offsetLeft;

            if (base.options.removeOffsets) {
                left = 0;
                top = top - offsetTop;
            }

            cssOptions={
              'position' : 'absolute',
              'top' : top,
              'left' : left,
              'margin-left' : '0px',
              'bottom' : ''
            }
            if (!base.options.dontSetWidth){ cssOptions['width']=target.width(); };

            target.css(cssOptions);

            position = 'absolute';
        }

        // Sets the target element back to unfixed. Also, hides the spacer.
        function setUnfixed() {
            // Only unfix the target element and the spacer if we need to.
            if (!isUnfixed()) {
                lastOffsetLeft = -1;

                // Hide the spacer now that the target element will fill the
                // space.
                spacer.css('display', 'none');

                // Remove the style attributes that were added to the target.
                // This will reverse the target back to the its original style.
                target.css({
                    'width' : '',
                    'position' : originalPosition,
                    'left' : '',
                    'top' : originalOffset.top,
                    'margin-left' : ''
                });

                target.removeClass('scroll-to-fixed-fixed');

                if (base.options.className) {
                    target.removeClass(base.options.className);
                }

                position = null;
            }
        }

        // Moves the target element left or right relative to the horizontal
        // scroll position.
        function setLeft(x) {
            // Only if the scroll is not what it was last time we did this.
            if (x != lastOffsetLeft) {
                // Move the target element horizontally relative to its original
                // horizontal position.
                target.css('left', offsetLeft - x);

                // Hold the last horizontal position set.
                lastOffsetLeft = x;
            }
        }

        function getMarginTop() {
            var marginTop = base.options.marginTop;
            if (!marginTop) return 0;

            if (typeof(marginTop) === 'function') {
                return marginTop.apply(target);
            }
            return marginTop;
        }

        // Checks to see if we need to do something based on new scroll position
        // of the page.
        function checkScroll() {
            if (!$.isScrollToFixed(target)) return;
            var wasReset = isReset;

            // If resetScroll has not yet been called, call it. This only
            // happens once.
            if (!isReset) {
                resetScroll();
            }

            // Grab the current horizontal scroll position.
            var x = $(window).scrollLeft();

            // Grab the current vertical scroll position.
            var y = $(window).scrollTop();

            // Get the limit, if there is one.
            var limit = getLimit();

            // If the vertical scroll position, plus the optional margin, would
            // put the target element at the specified limit, set the target
            // element to absolute.
            if (base.options.minWidth && $(window).width() < base.options.minWidth) {
                if (!isUnfixed() || !wasReset) {
                    postPosition();
                    target.trigger('preUnfixed.ScrollToFixed');
                    setUnfixed();
                    target.trigger('unfixed.ScrollToFixed');
                }
            } else if (base.options.bottom == -1) {
                // If the vertical scroll position, plus the optional margin, would
                // put the target element at the specified limit, set the target
                // element to absolute.
                if (limit > 0 && y >= limit - getMarginTop()) {
                    if (!isAbsolute() || !wasReset) {
                        postPosition();
                        target.trigger('preAbsolute.ScrollToFixed');
                        setAbsolute();
                        target.trigger('unfixed.ScrollToFixed');
                    }
                // If the vertical scroll position, plus the optional margin, would
                // put the target element above the top of the page, set the target
                // element to fixed.
                } else if (y >= offsetTop - getMarginTop()) {
                    if (!isFixed() || !wasReset) {
                        postPosition();
                        target.trigger('preFixed.ScrollToFixed');

                        // Set the target element to fixed.
                        setFixed();

                        // Reset the last offset left because we just went fixed.
                        lastOffsetLeft = -1;

                        target.trigger('fixed.ScrollToFixed');
                    }
                    // If the page has been scrolled horizontally as well, move the
                    // target element accordingly.
                    setLeft(x);
                } else {
                    // Set the target element to unfixed, placing it where it was
                    // before.
                    if (!isUnfixed() || !wasReset) {
                        postPosition();
                        target.trigger('preUnfixed.ScrollToFixed');
                        setUnfixed();
                        target.trigger('unfixed.ScrollToFixed');
                    }
                }
            } else {
                if (limit > 0) {
                    if (y + $(window).height() - target.outerHeight(true) >= limit - (getMarginTop() || -getBottom())) {
                        if (isFixed()) {
                            postPosition();
                            target.trigger('preUnfixed.ScrollToFixed');

                            if (originalPosition === 'absolute') {
                                setAbsolute();
                            } else {
                                setUnfixed();
                            }

                            target.trigger('unfixed.ScrollToFixed');
                        }
                    } else {
                        if (!isFixed()) {
                            postPosition();
                            target.trigger('preFixed.ScrollToFixed');
                            setFixed();
                        }
                        setLeft(x);
                        target.trigger('fixed.ScrollToFixed');
                    }
                } else {
                    setLeft(x);
                }
            }
        }

        function getBottom() {
            if (!base.options.bottom) return 0;
            return base.options.bottom;
        }

        function postPosition() {
            var position = target.css('position');

            if (position == 'absolute') {
                target.trigger('postAbsolute.ScrollToFixed');
            } else if (position == 'fixed') {
                target.trigger('postFixed.ScrollToFixed');
            } else {
                target.trigger('postUnfixed.ScrollToFixed');
            }
        }

        var windowResize = function(event) {
            // Check if the element is visible before updating it's position, which
            // improves behavior with responsive designs where this element is hidden.
            if(target.is(':visible')) {
                isReset = false;
                checkScroll();
			}
        }

        var windowScroll = function(event) {
            checkScroll();
        }

        // From: http://kangax.github.com/cft/#IS_POSITION_FIXED_SUPPORTED
        var isPositionFixedSupported = function() {
            var container = document.body;

            if (document.createElement && container && container.appendChild && container.removeChild) {
                var el = document.createElement('div');

                if (!el.getBoundingClientRect) return null;

                el.innerHTML = 'x';
                el.style.cssText = 'position:fixed;top:100px;';
                container.appendChild(el);

                var originalHeight = container.style.height,
                originalScrollTop = container.scrollTop;

                container.style.height = '3000px';
                container.scrollTop = 500;

                var elementTop = el.getBoundingClientRect().top;
                container.style.height = originalHeight;

                var isSupported = (elementTop === 100);
                container.removeChild(el);
                container.scrollTop = originalScrollTop;

                return isSupported;
            }

            return null;
        }

        var preventDefault = function(e) {
            e = e || window.event;
            if (e.preventDefault) {
                e.preventDefault();
            }
            e.returnValue = false;
        }

        // Initializes this plugin. Captures the options passed in, turns this
        // off for devices that do not support fixed position, adds the spacer,
        // and binds to the window scroll and resize events.
        base.init = function() {
            // Capture the options for this plugin.
            base.options = $
                    .extend({}, $.ScrollToFixed.defaultOptions, options);

            // Turn off this functionality for devices that do not support it.
            // if (!(base.options && base.options.dontCheckForPositionFixedSupport)) {
            //     var fixedSupported = isPositionFixedSupported();
            //     if (!fixedSupported) return;
            // }

            // Put the target element on top of everything that could be below
            // it. This reduces flicker when the target element is transitioning
            // to fixed.
            base.$el.css('z-index', base.options.zIndex);

            // Create a spacer element to fill the void left by the target
            // element when it goes fixed.
            spacer = $('<div />');

            position = target.css('position');
            originalPosition = target.css('position');

            originalOffset = $.extend({}, target.offset());

            // Place the spacer right after the target element.
            if (isUnfixed()) base.$el.after(spacer);

            // Reset the target element offsets when the window is resized, then
            // check to see if we need to fix or unfix the target element.
            $(window).bind('resize.ScrollToFixed', windowResize);

            // When the window scrolls, check to see if we need to fix or unfix
            // the target element.
            $(window).bind('scroll.ScrollToFixed', windowScroll);

            if (base.options.preFixed) {
                target.bind('preFixed.ScrollToFixed', base.options.preFixed);
            }
            if (base.options.postFixed) {
                target.bind('postFixed.ScrollToFixed', base.options.postFixed);
            }
            if (base.options.preUnfixed) {
                target.bind('preUnfixed.ScrollToFixed', base.options.preUnfixed);
            }
            if (base.options.postUnfixed) {
                target.bind('postUnfixed.ScrollToFixed', base.options.postUnfixed);
            }
            if (base.options.preAbsolute) {
                target.bind('preAbsolute.ScrollToFixed', base.options.preAbsolute);
            }
            if (base.options.postAbsolute) {
                target.bind('postAbsolute.ScrollToFixed', base.options.postAbsolute);
            }
            if (base.options.fixed) {
                target.bind('fixed.ScrollToFixed', base.options.fixed);
            }
            if (base.options.unfixed) {
                target.bind('unfixed.ScrollToFixed', base.options.unfixed);
            }

            if (base.options.spacerClass) {
                spacer.addClass(base.options.spacerClass);
            }

            target.bind('resize.ScrollToFixed', function() {
                spacer.height(target.height());
            });

            target.bind('scroll.ScrollToFixed', function() {
                target.trigger('preUnfixed.ScrollToFixed');
                setUnfixed();
                target.trigger('unfixed.ScrollToFixed');
                checkScroll();
            });

            target.bind('detach.ScrollToFixed', function(ev) {
                preventDefault(ev);

                target.trigger('preUnfixed.ScrollToFixed');
                setUnfixed();
                target.trigger('unfixed.ScrollToFixed');

                $(window).unbind('resize.ScrollToFixed', windowResize);
                $(window).unbind('scroll.ScrollToFixed', windowScroll);

                target.unbind('.ScrollToFixed');
                base.$el.removeData('ScrollToFixed');
            });

            // Reset everything.
            windowResize();
        };

        // Initialize the plugin.
        base.init();
    };

    // Sets the option defaults.
    $.ScrollToFixed.defaultOptions = {
        marginTop : 0,
        limit : 0,
        bottom : -1,
        zIndex : 1000
    };

    // Returns enhanced elements that will fix to the top of the page when the
    // page is scrolled.
    $.fn.scrollToFixed = function(options) {
        return this.each(function() {
            (new $.ScrollToFixed(this, options));
        });
    };
})(jQuery);
<commit_msg>Update jquery-scrolltofixed.js<commit_after>(function($) {
    $.isScrollToFixed = function(el) {
        return !!$(el).data('ScrollToFixed');
    };

    $.ScrollToFixed = function(el, options) {
        // To avoid scope issues, use 'base' instead of 'this' to reference this
        // class from internal events and functions.
        var base = this;

        // Access to jQuery and DOM versions of element.
        base.$el = $(el);
        base.el = el;

        // Add a reverse reference to the DOM object.
        base.$el.data('ScrollToFixed', base);

        // A flag so we know if the scroll has been reset.
        var isReset = false;

        // The element that was given to us to fix if scrolled above the top of
        // the page.
        var target = base.$el;

        var position;
        var originalPosition;

        var originalOffset;

        // The offset top of the element when resetScroll was called. This is
        // used to determine if we have scrolled past the top of the element.
        var offsetTop = 0;

        // The offset left of the element when resetScroll was called. This is
        // used to move the element left or right relative to the horizontal
        // scroll.
        var offsetLeft = 0;
        var originalOffsetLeft = -1;

        // This last offset used to move the element horizontally. This is used
        // to determine if we need to move the element because we would not want
        // to do that for no reason.
        var lastOffsetLeft = -1;

        // This is the element used to fill the void left by the target element
        // when it goes fixed; otherwise, everything below it moves up the page.
        var spacer = null;

        var spacerClass;

        var className;

        // Capture the original offsets for the target element. This needs to be
        // called whenever the page size changes or when the page is first
        // scrolled. For some reason, calling this before the page is first
        // scrolled causes the element to become fixed too late.
        function resetScroll() {
            // Set the element to it original positioning.
            target.trigger('preUnfixed.ScrollToFixed');
            setUnfixed();
            target.trigger('unfixed.ScrollToFixed');

            // Reset the last offset used to determine if the page has moved
            // horizontally.
            lastOffsetLeft = -1;

            // Capture the offset top of the target element.
            offsetTop = target.offset().top;

            // Capture the offset left of the target element.
            offsetLeft = target.offset().left;

            // If the offsets option is on, alter the left offset.
            if (base.options.offsets) {
                offsetLeft += (target.offset().left - target.position().left);
            }

            if (originalOffsetLeft == -1) {
                originalOffsetLeft = offsetLeft;
            }

            position = target.css('position');

            // Set that this has been called at least once.
            isReset = true;

            if (base.options.bottom != -1) {
                target.trigger('preFixed.ScrollToFixed');
                setFixed();
                target.trigger('fixed.ScrollToFixed');
            }
        }

        function getLimit() {
            var limit = base.options.limit;
            if (!limit) return 0;

            if (typeof(limit) === 'function') {
                return limit.apply(target);
            }
            return limit;
        }

        // Returns whether the target element is fixed or not.
        function isFixed() {
            return position === 'fixed';
        }

        // Returns whether the target element is absolute or not.
        function isAbsolute() {
            return position === 'absolute';
        }

        function isUnfixed() {
            return !(isFixed() || isAbsolute());
        }

        // Sets the target element to fixed. Also, sets the spacer to fill the
        // void left by the target element.
        function setFixed() {
            // Only fix the target element and the spacer if we need to.
            if (!isFixed()) {
                // Set the spacer to fill the height and width of the target
                // element, then display it.
                spacer.css({
                    'display' : target.css('display'),
                    'width' : target.outerWidth(true),
                    'height' : target.outerHeight(true),
                    'float' : target.css('float')
                });

                // Set the target element to fixed and set its width so it does
                // not fill the rest of the page horizontally. Also, set its top
                // to the margin top specified in the options.

                cssOptions={
                    'position' : 'fixed',
                    'top' : base.options.bottom == -1?getMarginTop():'',
                    'bottom' : base.options.bottom == -1?'':base.options.bottom,
                    'margin-left' : '0px'
                }
                if (!base.options.dontSetWidth){ cssOptions['width']=target.width(); };

                target.css(cssOptions);

                target.addClass('scroll-to-fixed-fixed');

                if (base.options.className) {
                    target.addClass(base.options.className);
                }

                position = 'fixed';
            }
        }

        function setAbsolute() {

            var top = getLimit();
            var left = offsetLeft;

            if (base.options.removeOffsets) {
                left = 0;
                top = top - offsetTop;
            }

            cssOptions={
              'position' : 'absolute',
              'top' : top,
              'left' : left,
              'margin-left' : '0px',
              'bottom' : ''
            }
            if (!base.options.dontSetWidth){ cssOptions['width']=target.width(); };

            target.css(cssOptions);

            position = 'absolute';
        }

        // Sets the target element back to unfixed. Also, hides the spacer.
        function setUnfixed() {
            // Only unfix the target element and the spacer if we need to.
            if (!isUnfixed()) {
                lastOffsetLeft = -1;

                // Hide the spacer now that the target element will fill the
                // space.
                spacer.css('display', 'none');

                // Remove the style attributes that were added to the target.
                // This will reverse the target back to the its original style.
                target.css({
                    'width' : '',
                    'position' : originalPosition,
                    'left' : '',
                    'top' : originalOffset.top,
                    'margin-left' : ''
                });

                target.removeClass('scroll-to-fixed-fixed');

                if (base.options.className) {
                    target.removeClass(base.options.className);
                }

                position = null;
            }
        }

        // Moves the target element left or right relative to the horizontal
        // scroll position.
        function setLeft(x) {
            // Only if the scroll is not what it was last time we did this.
            if (x != lastOffsetLeft) {
                // Move the target element horizontally relative to its original
                // horizontal position.
                target.css('left', offsetLeft - x);

                // Hold the last horizontal position set.
                lastOffsetLeft = x;
            }
        }

        function getMarginTop() {
            var marginTop = base.options.marginTop;
            if (!marginTop) return 0;

            if (typeof(marginTop) === 'function') {
                return marginTop.apply(target);
            }
            return marginTop;
        }

        // Checks to see if we need to do something based on new scroll position
        // of the page.
        function checkScroll() {
            if (!$.isScrollToFixed(target)) return;
            var wasReset = isReset;

            // If resetScroll has not yet been called, call it. This only
            // happens once.
            if (!isReset) {
                resetScroll();
            }

            // Grab the current horizontal scroll position.
            var x = $(window).scrollLeft();

            // Grab the current vertical scroll position.
            var y = $(window).scrollTop();

            // Get the limit, if there is one.
            var limit = getLimit();

            // If the vertical scroll position, plus the optional margin, would
            // put the target element at the specified limit, set the target
            // element to absolute.
            if (base.options.minWidth && $(window).width() < base.options.minWidth) {
                if (!isUnfixed() || !wasReset) {
                    postPosition();
                    target.trigger('preUnfixed.ScrollToFixed');
                    setUnfixed();
                    target.trigger('unfixed.ScrollToFixed');
                }
            } else if (base.options.bottom == -1) {
                // If the vertical scroll position, plus the optional margin, would
                // put the target element at the specified limit, set the target
                // element to absolute.
                if (limit > 0 && y >= limit - getMarginTop()) {
                    if (!isAbsolute() || !wasReset) {
                        postPosition();
                        target.trigger('preAbsolute.ScrollToFixed');
                        setAbsolute();
                        target.trigger('unfixed.ScrollToFixed');
                    }
                // If the vertical scroll position, plus the optional margin, would
                // put the target element above the top of the page, set the target
                // element to fixed.
                } else if (y >= offsetTop - getMarginTop()) {
                    if (!isFixed() || !wasReset) {
                        postPosition();
                        target.trigger('preFixed.ScrollToFixed');

                        // Set the target element to fixed.
                        setFixed();

                        // Reset the last offset left because we just went fixed.
                        lastOffsetLeft = -1;

                        target.trigger('fixed.ScrollToFixed');
                    }
                    // If the page has been scrolled horizontally as well, move the
                    // target element accordingly.
                    setLeft(x);
                } else {
                    // Set the target element to unfixed, placing it where it was
                    // before.
                    if (!isUnfixed() || !wasReset) {
                        postPosition();
                        target.trigger('preUnfixed.ScrollToFixed');
                        setUnfixed();
                        target.trigger('unfixed.ScrollToFixed');
                    }
                }
            } else {
                if (limit > 0) {
                    if (y + $(window).height() - target.outerHeight(true) >= limit - (getMarginTop() || -getBottom())) {
                        if (isFixed()) {
                            postPosition();
                            target.trigger('preUnfixed.ScrollToFixed');

                            if (originalPosition === 'absolute') {
                                setAbsolute();
                            } else {
                                setUnfixed();
                            }

                            target.trigger('unfixed.ScrollToFixed');
                        }
                    } else {
                        if (!isFixed()) {
                            postPosition();
                            target.trigger('preFixed.ScrollToFixed');
                            setFixed();
                        }
                        setLeft(x);
                        target.trigger('fixed.ScrollToFixed');
                    }
                } else {
                    setLeft(x);
                }
            }
        }

        function getBottom() {
            if (!base.options.bottom) return 0;
            return base.options.bottom;
        }

        function postPosition() {
            var position = target.css('position');

            if (position == 'absolute') {
                target.trigger('postAbsolute.ScrollToFixed');
            } else if (position == 'fixed') {
                target.trigger('postFixed.ScrollToFixed');
            } else {
                target.trigger('postUnfixed.ScrollToFixed');
            }
        }

        var windowResize = function(event) {
            // Check if the element is visible before updating it's position, which
            // improves behavior with responsive designs where this element is hidden.
            if(target.is(':visible')) {
                isReset = false;
                checkScroll();
			}
        }

        var windowScroll = function(event) {
            checkScroll();
        }

        // From: http://kangax.github.com/cft/#IS_POSITION_FIXED_SUPPORTED
        var isPositionFixedSupported = function() {
            var container = document.body;

            if (document.createElement && container && container.appendChild && container.removeChild) {
                var el = document.createElement('div');

                if (!el.getBoundingClientRect) return null;

                el.innerHTML = 'x';
                el.style.cssText = 'position:fixed;top:100px;';
                container.appendChild(el);

                var originalHeight = container.style.height,
                originalScrollTop = container.scrollTop;

                container.style.height = '3000px';
                container.scrollTop = 500;

                var elementTop = el.getBoundingClientRect().top;
                container.style.height = originalHeight;

                var isSupported = (elementTop === 100);
                container.removeChild(el);
                container.scrollTop = originalScrollTop;

                return isSupported;
            }

            return null;
        }

        var preventDefault = function(e) {
            e = e || window.event;
            if (e.preventDefault) {
                e.preventDefault();
            }
            e.returnValue = false;
        }

        // Initializes this plugin. Captures the options passed in, turns this
        // off for devices that do not support fixed position, adds the spacer,
        // and binds to the window scroll and resize events.
        base.init = function() {
            // Capture the options for this plugin.
            base.options = $
                    .extend({}, $.ScrollToFixed.defaultOptions, options);

            // Turn off this functionality for devices that do not support it.
            // if (!(base.options && base.options.dontCheckForPositionFixedSupport)) {
            //     var fixedSupported = isPositionFixedSupported();
            //     if (!fixedSupported) return;
            // }

            // Put the target element on top of everything that could be below
            // it. This reduces flicker when the target element is transitioning
            // to fixed.
            base.$el.css('z-index', base.options.zIndex);

            // Create a spacer element to fill the void left by the target
            // element when it goes fixed.
            spacer = $('<div />');

            position = target.css('position');
            originalPosition = target.css('position');

            originalOffset = $.extend({}, target.offset());

            // Place the spacer right after the target element.
            if (isUnfixed()) base.$el.after(spacer);

            // Reset the target element offsets when the window is resized, then
            // check to see if we need to fix or unfix the target element.
            $(window).bind('resize.ScrollToFixed', windowResize);

            // When the window scrolls, check to see if we need to fix or unfix
            // the target element.
            $(window).bind('scroll.ScrollToFixed', windowScroll);

            if (base.options.preFixed) {
                target.bind('preFixed.ScrollToFixed', base.options.preFixed);
            }
            if (base.options.postFixed) {
                target.bind('postFixed.ScrollToFixed', base.options.postFixed);
            }
            if (base.options.preUnfixed) {
                target.bind('preUnfixed.ScrollToFixed', base.options.preUnfixed);
            }
            if (base.options.postUnfixed) {
                target.bind('postUnfixed.ScrollToFixed', base.options.postUnfixed);
            }
            if (base.options.preAbsolute) {
                target.bind('preAbsolute.ScrollToFixed', base.options.preAbsolute);
            }
            if (base.options.postAbsolute) {
                target.bind('postAbsolute.ScrollToFixed', base.options.postAbsolute);
            }
            if (base.options.fixed) {
                target.bind('fixed.ScrollToFixed', base.options.fixed);
            }
            if (base.options.unfixed) {
                target.bind('unfixed.ScrollToFixed', base.options.unfixed);
            }

            if (base.options.spacerClass) {
                spacer.addClass(base.options.spacerClass);
            }

            target.bind('resize.ScrollToFixed', function() {
                spacer.height(target.height());
            });

            target.bind('scroll.ScrollToFixed', function() {
                target.trigger('preUnfixed.ScrollToFixed');
                setUnfixed();
                target.trigger('unfixed.ScrollToFixed');
                checkScroll();
            });

            target.bind('detach.ScrollToFixed', function(ev) {
                preventDefault(ev);

                target.trigger('preUnfixed.ScrollToFixed');
                setUnfixed();
                target.trigger('unfixed.ScrollToFixed');

                $(window).unbind('resize.ScrollToFixed', windowResize);
                $(window).unbind('scroll.ScrollToFixed', windowScroll);

                target.unbind('.ScrollToFixed');
                base.$el.removeData('ScrollToFixed');
            });

            // Reset everything.
            windowResize();
        };

        // Initialize the plugin.
        base.init();
    };

    // Sets the option defaults.
    $.ScrollToFixed.defaultOptions = {
        marginTop : 0,
        limit : 0,
        bottom : -1,
        zIndex : 1000
    };

    // Returns enhanced elements that will fix to the top of the page when the
    // page is scrolled.
    $.fn.scrollToFixed = function(options) {
        return this.each(function() {
            (new $.ScrollToFixed(this, options));
        });
    };
})(jQuery);
<|endoftext|>


<commit_before>maxId = 0;
maxColorId = 0;

mainFoodChain1 = JSON.parse('[ { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 } ], "foodChain": [ { "type": "egg", "id": 3, "colorId": 1 }, { "type": "family", "id": 4, "gators": [ { "type": "gator", "id": 6, "colorId": 2 }, { "type": "gator", "id": 7, "colorId": 3 } ], "foodChain": [ { "type": "egg", "id": 8, "colorId": 3 } ] }, { "type": "family", "id": 5, "gators": [ { "type": "gator", "id": 9, "colorId": 4 }, { "type": "gator", "id": 10, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 11, "colorId": 4 } ] } ] }, { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 }, { "type": "gator", "id": 3, "colorId": 2 } ], "foodChain": [ { "type": "egg", "id": 4, "colorId": 1 } ] }]');
mainFoodChain2 = JSON.parse('[ { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 } ], "foodChain": [ { "type": "egg", "id": 3, "colorId": 1 }, { "type": "family", "id": 4, "gators": [ { "type": "gator", "id": 6, "colorId": 2 }, { "type": "gator", "id": 7, "colorId": 3 } ], "foodChain": [ { "type": "egg", "id": 8, "colorId": 3 } ] }, { "type": "family", "id": 5, "gators": [ { "type": "gator", "id": 9, "colorId": 4 }, { "type": "gator", "id": 10, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 11, "colorId": 4 } ] } ] }, { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 }, { "type": "gator", "id": 3, "colorId": 2 } ], "foodChain": [ { "type": "egg", "id": 4, "colorId": 1 } ] }]');

function getMaxIds(foodChain){
  for (var i = 0; i < foodChain.length; i++) {
    if(foodChain[i].id>maxId){
      maxId = foodChain[i].id;
    }

    if(foodChain[i].type=="family"){
      getMaxIds(foodChain[i].foodChain);

      for (var j = 0; j < foodChain[i].gators.length; j++) {
        if(foodChain[i].gators[j].colorId > maxColorId){
          maxColorId = foodChain[i].gators[j].colorId;
        }

        if(foodChain[i].gators[j].id>maxId){
          maxId = foodChain[i].id;
        }
      }
    }else{
      if(foodChain[i].colorId > maxColorId){
        maxColorId = foodChain[i].colorId;
      }
    }
  }
}

function reduce(foodChain){
  if(foodChain[0].gators.length>0){//alpha reduce or done
    if(foodChain.length==1){
      console.log("donezo");
      return 0;
    }
    console.log("alpha");

    gator = foodChain[0].gators[0];
    food = foodChain[1];
    replaceEggs(foodChain[0], gator.colorId, food);
    foodChain.splice(1, 1);//removes the food
    foodChain[0].gators.splice(0,1);//removes the gator
  }else{//eta reduce
    console.log("eta");
    Array.prototype.unshift.apply(foodChain, foodChain.shift().foodChain);
  }
  return 1;
}

function isEqual(foodChain1, foodChain2) {
	if (foodChain1.length != foodChain2.length) return 0;
	for (var i = 0; i < foodChain1.length; i++)
		if (foodChain1[i].type != foodChain2[i].type) return 0;
	var eggMap1 = {};
	var eggMap2 = {};
	var gatorMap1 = {};
	var gatorMap2 = {};
	// Iterate over families and eggs (elements)
	for (var i = 0; i < foodChain1.length; i++) {
		console.log("i: ", i)
		var element1 = foodChain1[i];
		var element2 = foodChain2[i];
		if (element1.type == "egg") {
			// if we already have a mapping for this color but it's different now, the food-chains are different
			if ((element1.colorId in eggMap1) && eggMap1[element1.colorId] != element2.colorId)
				return 0;
			if ((element2.colorId in eggMap2) && eggMap2[element2.colorId] != element1.colorId)
				return 0;
			// if we haven't seen this color yet, add this mapping
			if (!(element1 in eggMap1))
				eggMap1[element1.colorId] = element2.colorId;
			if (!(element2 in eggMap2))
				eggMap2[element2.colorId] = element1.colorId;
		}
		else if (element1.type == "family") {
			if (element1.gators.length != element2.gators.length) return 0;
			if (element1.foodChain.length != element2.foodChain.length) return 0;
			// Iterate over gators
			var gators1 = element1.gators;
			var gators2 = element2.gators;
			for (var i = 0; i < gators1.length; i++) {
				console.log("1: ", gators1[i]);
				//console.log("2: ", gators2[i]);
			}
			for (var i = 0; i < gators1.length; i++) {
				// if we already have a mapping for this color but it's different now, the food-chains are different
				if ((gators1[i].colorId in gatorMap1) && gatorMap1[gators1[i].colorId] != gators2[i].colorId)
					return 0;
				if ((gators2[i].colorId in gatorMap2) && gatorMap2[gators2[i].colorId] != gators1[i].colorId)
					return 0;
				// if we haven't seen this color yet, add this mapping
				if (!(gators1[i] in gatorMap1))
					gatorMap1[gators1[i].colorId] = gators2[i].colorId;
				if (!(gators2[i] in gatorMap2))
					gatorMap2[gators2[i].colorId] = gators1[i].colorId;
			}
			// Recurse for sub-foodChains
			if (!isEqual(element1.foodChain, element2.foodChain)) return 0;
		}
	}
	return 1;
}

function replaceEggs(family, colorId, newFamily){
  for (var i = 0; i < family.foodChain.length; i++) {
    if(family.foodChain[i].type=="family"){
      replaceEggs(family.foodChain[i], colorId, newFamily);
    }else{
      if(family.foodChain[i].colorId==colorId){
        family.foodChain[i] = copyFamily(newFamily, {});
      }
    }
  }
}

function copyFamily(family, colorMap){
  newFamily = {type:"family", id:++maxId, gators:[], foodChain:[]};//create blank family with new Id

  for (var i=0; i < family.gators.length; i++){//add each gator over with new Id's and new color Id's
    newFamily.gators[i]={type:"gator", id:++maxId, colorId:++maxColorId};
    colorMap[family.gators[i].colorId]=maxColorId;//mark that this colorId is changed for all children eggs
  }

  for (var i=0; i < family.foodChain.length; i++){
    if(family.foodChain[i].type=="family"){
      newFamily.foodChain[i] = copyFamily(family.foodChain[i], colorMap);
    }else{
      newFamily.foodChain[i] = {type:"egg", id:++maxId};

      if(family.foodChain[i].colorId in colorMap){
        newFamily.foodChain[i].colorId = colorMap[family.foodChain[i].colorId];
      }else{
        newFamily.foodChain[i].colorId = family.foodChain[i].colorId;
      }
    }
  }
  return newFamily;

}
/*
getMaxIds(mainFoodChain1);

console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));

console.log(maxColorId);
*/
console.log(isEqual(mainFoodChain1, mainFoodChain2));

/*
family:
  type="family"
  id
  gators = []//gators
  foodChain = []//eggs or families

gator:
  type="gator"
  id
  colorId

egg:
  type="egg"
  id
  colorId
*/
<commit_msg>fixes the colorId and Id's of the example<commit_after>maxId = 0;
maxColorId = 0;

mainFoodChain1 = JSON.parse('[ { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 } ], "foodChain": [ { "type": "egg", "id": 3, "colorId": 1 }, { "type": "family", "id": 4, "gators": [ { "type": "gator", "id": 6, "colorId": 2 }, { "type": "gator", "id": 7, "colorId": 3 } ], "foodChain": [ { "type": "egg", "id": 8, "colorId": 3 } ] }, { "type": "family", "id": 5, "gators": [ { "type": "gator", "id": 9, "colorId": 4 }, { "type": "gator", "id": 10, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 11, "colorId": 4 } ] } ] }, { "type": "family", "id": 12, "gators": [ { "type": "gator", "id": 13, "colorId": 4 }, { "type": "gator", "id": 14, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 15, "colorId": 4 } ] }]');
mainFoodChain2 = JSON.parse('[ { "type": "family", "id": 1, "gators": [ { "type": "gator", "id": 2, "colorId": 1 } ], "foodChain": [ { "type": "egg", "id": 3, "colorId": 1 }, { "type": "family", "id": 4, "gators": [ { "type": "gator", "id": 6, "colorId": 2 }, { "type": "gator", "id": 7, "colorId": 3 } ], "foodChain": [ { "type": "egg", "id": 8, "colorId": 3 } ] }, { "type": "family", "id": 5, "gators": [ { "type": "gator", "id": 9, "colorId": 4 }, { "type": "gator", "id": 10, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 11, "colorId": 4 } ] } ] }, { "type": "family", "id": 12, "gators": [ { "type": "gator", "id": 13, "colorId": 4 }, { "type": "gator", "id": 14, "colorId": 5 } ], "foodChain": [ { "type": "egg", "id": 15, "colorId": 4 } ] }]');

function getMaxIds(foodChain){
  for (var i = 0; i < foodChain.length; i++) {
    if(foodChain[i].id>maxId){
      maxId = foodChain[i].id;
    }

    if(foodChain[i].type=="family"){
      getMaxIds(foodChain[i].foodChain);

      for (var j = 0; j < foodChain[i].gators.length; j++) {
        if(foodChain[i].gators[j].colorId > maxColorId){
          maxColorId = foodChain[i].gators[j].colorId;
        }

        if(foodChain[i].gators[j].id>maxId){
          maxId = foodChain[i].id;
        }
      }
    }else{
      if(foodChain[i].colorId > maxColorId){
        maxColorId = foodChain[i].colorId;
      }
    }
  }
}

function reduce(foodChain){
  if(foodChain[0].gators.length>0){//alpha reduce or done
    if(foodChain.length==1){
      console.log("donezo");
      return 0;
    }
    console.log("alpha");

    gator = foodChain[0].gators[0];
    food = foodChain[1];
    replaceEggs(foodChain[0], gator.colorId, food);
    foodChain.splice(1, 1);//removes the food
    foodChain[0].gators.splice(0,1);//removes the gator
  }else{//eta reduce
    console.log("eta");
    Array.prototype.unshift.apply(foodChain, foodChain.shift().foodChain);
  }
  return 1;
}

function isEqual(foodChain1, foodChain2) {
	if (foodChain1.length != foodChain2.length) return 0;
	for (var i = 0; i < foodChain1.length; i++)
		if (foodChain1[i].type != foodChain2[i].type) return 0;
	var eggMap1 = {};
	var eggMap2 = {};
	var gatorMap1 = {};
	var gatorMap2 = {};
	// Iterate over families and eggs (elements)
	for (var i = 0; i < foodChain1.length; i++) {
		console.log("i: ", i)
		var element1 = foodChain1[i];
		var element2 = foodChain2[i];
		if (element1.type == "egg") {
			// if we already have a mapping for this color but it's different now, the food-chains are different
			if ((element1.colorId in eggMap1) && eggMap1[element1.colorId] != element2.colorId)
				return 0;
			if ((element2.colorId in eggMap2) && eggMap2[element2.colorId] != element1.colorId)
				return 0;
			// if we haven't seen this color yet, add this mapping
			if (!(element1 in eggMap1))
				eggMap1[element1.colorId] = element2.colorId;
			if (!(element2 in eggMap2))
				eggMap2[element2.colorId] = element1.colorId;
		}
		else if (element1.type == "family") {
			if (element1.gators.length != element2.gators.length) return 0;
			if (element1.foodChain.length != element2.foodChain.length) return 0;
			// Iterate over gators
			var gators1 = element1.gators;
			var gators2 = element2.gators;
			for (var i = 0; i < gators1.length; i++) {
				console.log("1: ", gators1[i]);
				//console.log("2: ", gators2[i]);
			}
			for (var i = 0; i < gators1.length; i++) {
				// if we already have a mapping for this color but it's different now, the food-chains are different
				if ((gators1[i].colorId in gatorMap1) && gatorMap1[gators1[i].colorId] != gators2[i].colorId)
					return 0;
				if ((gators2[i].colorId in gatorMap2) && gatorMap2[gators2[i].colorId] != gators1[i].colorId)
					return 0;
				// if we haven't seen this color yet, add this mapping
				if (!(gators1[i] in gatorMap1))
					gatorMap1[gators1[i].colorId] = gators2[i].colorId;
				if (!(gators2[i] in gatorMap2))
					gatorMap2[gators2[i].colorId] = gators1[i].colorId;
			}
			// Recurse for sub-foodChains
			if (!isEqual(element1.foodChain, element2.foodChain)) return 0;
		}
	}
	return 1;
}

function replaceEggs(family, colorId, newFamily){
  for (var i = 0; i < family.foodChain.length; i++) {
    if(family.foodChain[i].type=="family"){
      replaceEggs(family.foodChain[i], colorId, newFamily);
    }else{
      if(family.foodChain[i].colorId==colorId){
        family.foodChain[i] = copyFamily(newFamily, {});
      }
    }
  }
}

function copyFamily(family, colorMap){
  newFamily = {type:"family", id:++maxId, gators:[], foodChain:[]};//create blank family with new Id

  for (var i=0; i < family.gators.length; i++){//add each gator over with new Id's and new color Id's
    newFamily.gators[i]={type:"gator", id:++maxId, colorId:++maxColorId};
    colorMap[family.gators[i].colorId]=maxColorId;//mark that this colorId is changed for all children eggs
  }

  for (var i=0; i < family.foodChain.length; i++){
    if(family.foodChain[i].type=="family"){
      newFamily.foodChain[i] = copyFamily(family.foodChain[i], colorMap);
    }else{
      newFamily.foodChain[i] = {type:"egg", id:++maxId};

      if(family.foodChain[i].colorId in colorMap){
        newFamily.foodChain[i].colorId = colorMap[family.foodChain[i].colorId];
      }else{
        newFamily.foodChain[i].colorId = family.foodChain[i].colorId;
      }
    }
  }
  return newFamily;

}
/*
getMaxIds(mainFoodChain1);

console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));
reduce(mainFoodChain1);
console.log(JSON.stringify(mainFoodChain1));

console.log(maxColorId);
*/
console.log(isEqual(mainFoodChain1, mainFoodChain2));

/*
family:
  type="family"
  id
  gators = []//gators
  foodChain = []//eggs or families

gator:
  type="gator"
  id
  colorId

egg:
  type="egg"
  id
  colorId
*/
<|endoftext|>


<commit_before>(function($,a,b){var c={a:$(b.body).append('

'),b:$('#tooltip-search'),c:$('#toggle-code-view')},d={a:function(){var j1="";if(a.getSelection){j1=a.getSelection()}else if(b.getSelection){j1=b.getSelection()}else if(b.selection){j1=b.selection.createRange().text}return j1},b:{a:function(a1,a2,a3){var a4,a5;if(a3){a4=new Date();a4.setTime(a4.getTime()+(a3*24*60*60*1000));a5="; expires="+a4.toGMTString()}else{a5=""}b.cookie=a1+"="+a2+a5+"; path=/"},b:function(b1){var b2=b1+"=",b3=b.cookie.split(';'),b4;for(var i=0;i<b3.length;i++){b4=b3[i];while(b4.charAt(0)==' ')b4=b4.substring(1,b4.length);if(b4.indexOf(b2)===0)return b4.substring(b2.length,b4.length)}return null}}};c.c.on("change",function(){c.a[this.checked?"addClass":"removeClass"]('bright-code');d.b.a('pre',(this.checked?true:false),(this.checked?1000:-1))}).prop('checked',d.b.b('pre'));c.a[d.b.b('pre')?"addClass":"removeClass"]('bright-code');c.a.on("mouseup",function(e1){if(/pre|code/.test(e1.target.nodeName.toLowerCase())||$(e1.target).closest('pre').length>0)return;var e2=d.a().toString().replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),e3=e1.pageX-100,e4=e1.pageY;a.setTimeout(function(){c.b.css({'display':(e2!==""&&e2.length<70)?'block':'none','top':e4+'px','left':e3+'px'}).html('Telusuri “'+e2+'” di blogTelusuri “'+e2+'” dengan Google')},50)})})(jQuery,window,document);
<commit_msg>Delete tooltip-search.js<commit_after><|endoftext|>


<commit_before>/*
 *  Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
$(function () {
    validator.initValidationEvents('form-asset-create', function () {
    });
    $('#btn-create-asset').removeAttr('disabled');
    var obtainFormMeta = function (formId) {
        return $(formId).data();
    };
    var populateTags = function (arr) {
        var entry;
        var modifiedArr = [];
        var tagEntry;

        //The Select2 plugin creates multiple entries in the FormData
        //object.These duplicates need to be removed and a single
        //_tags entry created in their place

        arr.forEach(function (entry) {
            if (entry.name !== '_tags') {
                modifiedArr.push(entry);
            } else {
                tagEntry = entry;
                if (tagEntry == undefined) {
                    return;
                }
                tagEntry.value = tagsAPI.selectedTags();
            }
        });
        modifiedArr.push(tagEntry);
        return modifiedArr;
    };

    $('#form-asset-create').ajaxForm({
        beforeSubmit: function (arr) {
            var createButton = $('#btn-create-asset');
            createButton.attr('disabled', 'disabled');
            createButton.next().attr('disabled', 'disabled');
            /*caramel.render('loading', 'Creating asset. Please wait..', function (info, content) {
             var $content = $(content).removeClass('loading-animation-big').addClass('loading-animation');
             createButton.parent().append($content);
             });*/
            // populateTags(arr);
            if (!validator.isValidForm('form-asset-create')) {
                window.scrollTo(0, 0);
                $('div.error').each(function () {
                    var $container = $(this).closest('div.responsive-form-container');
                    if (!$container.hasClass('in')) {
                        $container.show('fast').addClass('in');
                    }
                });
                $('#btn-create-asset').removeAttr('disabled');
                setTimeout(
                    function () {
                        $('.loading-animation').remove();
                    }, 1000);
                return false;
            }
            messages.alertInfoLoader(' Creating the new asset. Please wait...');
        },
        success: function (data) {
            var options = obtainFormMeta('#form-asset-create');
            var type = PublisherUtils.resolveCurrentPageAssetType();
            $('#btn-create-asset').removeAttr('disabled');
            $.cookie("new-asset-" + type, data.id + ":" + type + ":" + data.name);
            window.location = options.redirectUrl;
        },
        error: function (response) {
            var result;
            messages.hideAlertInfoLoader();
            if (response && response.responseText) {
                result = JSON.parse(response.responseText);
            }
            if (result && result.moreInfomation) {
                messages.alertError('Unable to create the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.' + result.moreInfomation);
            } else {
                messages.alertError('Unable to add the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.');
            }
            $('#btn-create-asset').removeAttr('disabled');
            $('.fa-spinner').parent().remove();
        }
    });
    var initDatePicker = function () {
        if ($(this).attr('data-render-options') == "date-time") {
            var dateField = this;
            $(this).DatePicker({
                mode: 'single',
                position: 'right',
                onBeforeShow: function (el) {
                    if ($(dateField).val().replace(/^\s+|\s+$/g, "")) {
                        $(dateField).DatePickerSetDate($(dateField).val(), true);
                    }

                },
                onChange: function (date, el) {
                    $(el).val((date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear());
                    if ($('#closeOnSelect input').attr('checked')) {
                        $(el).DatePickerHide();
                    }
                }
            });
        }
    };

    $('#form-asset-create input[type="text"]').each(initDatePicker);

    var removeUnboundRow = function (link) {
        var table = link.closest('table');
        var requiredOneRow = false;
        var numberOfRows = $('tr', table).length;
        if (table.attr('data-required-row')) {
            requiredOneRow = true;
        }
        if (requiredOneRow && numberOfRows == 2) {
            messages.alertError('Required to have at-least one row.');
            return false;
        }
        if (numberOfRows == 2) {
            table.hide();
        }
        link.closest('tr').remove();
    };

    $('.js-add-unbounded-row').click(function () {
        var tableName = $(this).attr('data-name');
        var table = $('#table_' + tableName);
        table.find('thead').show();
        var referenceRow = $('#table_reference_' + tableName);
        var newRow = referenceRow.clone().removeAttr('id');
        $('input[type="text"]', newRow).each(function () {
            var attr = $(this).attr('data-original-title');
            if (typeof attr !== typeof undefined && attr !== false) {
                $(this).attr('title', $(this).attr('data-original-title'));
            }
        });
        $('input[type="text"]', newRow).val('');
        table.show().append(newRow);
        table.find('thead').show();
    });

    $('.js-unbounded-table').on('click', 'a', function (event) {
        removeUnboundRow($(event.target));
    });

    $('.js-unbounded-table').on('click', 'input[type="checkbox"]', function (event) {
        var checkbox = event.target;
        var hiddenField = $(checkbox).next();
        if ($(checkbox).is(":checked")) {
            $(hiddenField).val('on');
        } else {
            $(hiddenField).val('off');
        }
    });

    $('.tmp_refernceTableForUnbounded').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('.tmp_refernceTableForOptionText').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('#form-asset-create a.collapsing-h2').off('click', '**').on('click', function (e) {
        e.preventDefault();
        var $panel = $(this).parent().next();
        if ($panel.is(":visible")) {
            $panel.slideUp();
            $(this).parent().addClass('collapsed');
        } else {
            $panel.slideDown();
            $(this).parent().removeClass('collapsed');
        }
    });
    /**
     * Hides tables which dose not contain required fields.
     * count the number of required fields in one table, if count equals to zero
     * then hide that table. First table will expand always
     */
    $('#form-asset-create .responsive-form-container').each(function (index) {
        if ($(this).find('.required-field').length == 0 && index != 0) {
            $(this).hide();
            $('.field-title').eq(index).addClass("collapsed");
        }
    });

    initTaxonomyBrowser(null);

    String.prototype.replaceAll = function (find, replace) {
        var str = this;
        return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
    };

    $('#btn-create-asset').click(function (e) {
        var taxonomyList = $('#taxonomy-list')[0];
        if (selectedTaxonomy && taxonomyList) {
            taxonomyList.value = selectedTaxonomy.join(',');
        }
    });

    $('button[type=reset]').click(function (e) {
        initTaxonomyBrowser(null);
    });
});
<commit_msg>Added new fix for REGISTRY-3896<commit_after>/*
 *  Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
$(function () {
    validator.initValidationEvents('form-asset-create', function () {
    });
    $('#btn-create-asset').removeAttr('disabled');
    var obtainFormMeta = function (formId) {
        return $(formId).data();
    };
    var populateTags = function (arr) {
        var entry;
        var modifiedArr = [];
        var tagEntry;

        //The Select2 plugin creates multiple entries in the FormData
        //object.These duplicates need to be removed and a single
        //_tags entry created in their place

        arr.forEach(function (entry) {
            if (entry.name !== '_tags') {
                modifiedArr.push(entry);
            } else {
                tagEntry = entry;
                if (tagEntry == undefined) {
                    return;
                }
                tagEntry.value = tagsAPI.selectedTags();
            }
        });
        modifiedArr.push(tagEntry);
        return modifiedArr;
    };

    $('#form-asset-create').ajaxForm({
        beforeSubmit: function (arr) {
            var createButton = $('#btn-create-asset');
            createButton.attr('disabled', 'disabled');
            createButton.next().attr('disabled', 'disabled');
            /*caramel.render('loading', 'Creating asset. Please wait..', function (info, content) {
             var $content = $(content).removeClass('loading-animation-big').addClass('loading-animation');
             createButton.parent().append($content);
             });*/
            // populateTags(arr);
            if (!validator.isValidForm('form-asset-create')) {
                window.scrollTo(0, 0);
                $('div.error').each(function () {
                    var $container = $(this).closest('div.responsive-form-container');
                    if (!$container.hasClass('in')) {
                        $container.show('fast').addClass('in');
                    }
                });
                $('#btn-create-asset').removeAttr('disabled');
                setTimeout(
                    function () {
                        $('.loading-animation').remove();
                    }, 1000);
                return false;
            }
            messages.alertInfoLoader(' Creating the new asset. Please wait...');
        },
        success: function (data) {
            var options = obtainFormMeta('#form-asset-create');
            var type = PublisherUtils.resolveCurrentPageAssetType();
            $('#btn-create-asset').removeAttr('disabled');
            $.cookie("new-asset-" + type, data.id + ":" + type + ":" + data.name);
            window.location = options.redirectUrl;
        },
        error: function (response) {
            var result;
            messages.hideAlertInfoLoader();
            if (response && response.responseText) {
                result = JSON.parse(response.responseText);
            }
            if (result && result.moreInfomation) {
                messages.alertError('Unable to create the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.' + result.moreInfomation);
            } else {
                messages.alertError('Unable to add the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.');
            }
            $('#btn-create-asset').removeAttr('disabled');
            $('.fa-spinner').parent().remove();
        }
    });
    var initDatePicker = function () {
        if ($(this).attr('data-render-options') == "date-time") {
            var dateField = this;
            $(this).DatePicker({
                mode: 'single',
                position: 'right',
                onBeforeShow: function (el) {
                    if ($(dateField).val().replace(/^\s+|\s+$/g, "")) {
                        $(dateField).DatePickerSetDate($(dateField).val(), true);
                    }

                },
                onChange: function (date, el) {
                    $(el).val((date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear());
                    if ($('#closeOnSelect input').attr('checked')) {
                        $(el).DatePickerHide();
                    }
                }
            });
        }
    };

    $('#form-asset-create input[type="text"]').each(initDatePicker);

    var removeUnboundRow = function (link) {
        var table = link.closest('table');
        var requiredOneRow = false;
        var numberOfRows = $('tr', table).length;
        if (table.attr('data-required-row')) {
            requiredOneRow = true;
        }
        if (requiredOneRow && numberOfRows == 2) {
            messages.alertError('Required to have at-least one row.');
            return false;
        }
        if (numberOfRows == 2) {
            table.hide();
        }
        link.closest('tr').remove();
    };

    $('.js-add-unbounded-row').click(function () {
        var tableName = $(this).attr('data-name');
        var table = $('#table_' + tableName);
        table.find('thead').show();
        var referenceRow = $('#table_reference_' + tableName);
        var newRow = referenceRow.clone().removeAttr('id');
        $('[data-toggle="tooltip"]', newRow).each(function () {
            var attr = $(this).attr('data-original-title');
            if (typeof attr !== typeof undefined && attr !== false) {
                $(this).attr('title', $(this).attr('data-original-title'));
            }
        });
        $('input[type="text"]', newRow).val('');
        table.show().append(newRow);
        table.find('thead').show();
    });

    $('.js-unbounded-table').on('click', 'a', function (event) {
        removeUnboundRow($(event.target));
    });

    $('.js-unbounded-table').on('click', 'input[type="checkbox"]', function (event) {
        var checkbox = event.target;
        var hiddenField = $(checkbox).next();
        if ($(checkbox).is(":checked")) {
            $(hiddenField).val('on');
        } else {
            $(hiddenField).val('off');
        }
    });

    $('.tmp_refernceTableForUnbounded').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('.tmp_refernceTableForOptionText').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('#form-asset-create a.collapsing-h2').off('click', '**').on('click', function (e) {
        e.preventDefault();
        var $panel = $(this).parent().next();
        if ($panel.is(":visible")) {
            $panel.slideUp();
            $(this).parent().addClass('collapsed');
        } else {
            $panel.slideDown();
            $(this).parent().removeClass('collapsed');
        }
    });
    /**
     * Hides tables which dose not contain required fields.
     * count the number of required fields in one table, if count equals to zero
     * then hide that table. First table will expand always
     */
    $('#form-asset-create .responsive-form-container').each(function (index) {
        if ($(this).find('.required-field').length == 0 && index != 0) {
            $(this).hide();
            $('.field-title').eq(index).addClass("collapsed");
        }
    });

    initTaxonomyBrowser(null);

    String.prototype.replaceAll = function (find, replace) {
        var str = this;
        return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
    };

    $('#btn-create-asset').click(function (e) {
        var taxonomyList = $('#taxonomy-list')[0];
        if (selectedTaxonomy && taxonomyList) {
            taxonomyList.value = selectedTaxonomy.join(',');
        }
    });

    $('button[type=reset]').click(function (e) {
        initTaxonomyBrowser(null);
    });
});
<|endoftext|>


<commit_before>/**
 * @file Build class
 * @since 0.1.6
 */
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfDefineGetClassSecuredConstructor*/ // Allocate a secured named constructor
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*#endif*/

Object.assign(_GpfClassDefinition.prototype, {

    /**
     * @inheritdoc
     * @since 0.1.6
     */
    _build: function () {
        var newClass,
            newPrototype;
        this._resolveConstructor();
        newClass = _gpfDefineGetClassSecuredConstructor(this);
        // Basic JavaScript inheritance mechanism: Defines the newClass prototype as an instance of the super class
        newPrototype = Object.create(this._extend.prototype);
        // Populate our constructed prototype object
        newClass.prototype = newPrototype;
        // Enforce the constructor to be what we expect
        newPrototype.constructor = newClass;
        this._buildPrototype(newPrototype);
        return newClass;
    },

    /**
     * Add method to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} methodName Method name
     * @param {Function} method Method
     * @since 0.1.7
     */
    _addMethodToPrototype: function (newPrototype, methodName, method) {
        newPrototype[methodName] = this._superify(method, methodName);
    },

    /**
     * Add member to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} memberName Member name
     * @param {*} value Member value
     * @since 0.1.7
     */
    _addMemberToPrototype: function (newPrototype, memberName, value) {
        if ("function" === typeof value) {
            this._addMethodToPrototype(newPrototype, memberName, value);
        } else {
            newPrototype[memberName] = value;
        }
    },

    /**
     * Build the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @since 0.1.7
     */
    _buildPrototype: function (newPrototype) {
        _gpfObjectForEach(this._initialDefinition, function (value, memberName) {
            if (memberName.charAt(0) !== "$" && memberName !== "constructor") {
                this._addMemberToPrototype(newPrototype, memberName, value); //eslint-disable-line no-invalid-this
            }
        }, this);
    },

    /**
     * Set the inherited constructor if not Object
     * @since 0.1.7
     */
    _setResolvedConstructorToInherited: function () {
        if (this._extend !== Object) {
            this._resolvedConstructor = this._extend;
        }
    },

    /**
     * Assign the proper constructor to _resolvedConstructor
     * @since 0.1.7
     */
    _resolveConstructor: function () {
        if (this._initialDefinition.hasOwnProperty("constructor")) {
            /* jshint -W069*/ /*eslint-disable dot-notation*/
            this._resolvedConstructor = this._superify(this._initialDefinition["constructor"], "constructor");
            /* jshint +W069*/ /*eslint-enable dot-notation*/
        } else {
            this._setResolvedConstructorToInherited();
        }
    }

});
<commit_msg>!yoda style (#280)<commit_after>/**
 * @file Build class
 * @since 0.1.6
 */
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfDefineGetClassSecuredConstructor*/ // Allocate a secured named constructor
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*#endif*/

Object.assign(_GpfClassDefinition.prototype, {

    /**
     * @inheritdoc
     * @since 0.1.6
     */
    _build: function () {
        var newClass,
            newPrototype;
        this._resolveConstructor();
        newClass = _gpfDefineGetClassSecuredConstructor(this);
        // Basic JavaScript inheritance mechanism: Defines the newClass prototype as an instance of the super class
        newPrototype = Object.create(this._extend.prototype);
        // Populate our constructed prototype object
        newClass.prototype = newPrototype;
        // Enforce the constructor to be what we expect
        newPrototype.constructor = newClass;
        this._buildPrototype(newPrototype);
        return newClass;
    },

    /**
     * Add method to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} methodName Method name
     * @param {Function} method Method
     * @since 0.1.7
     */
    _addMethodToPrototype: function (newPrototype, methodName, method) {
        newPrototype[methodName] = this._superify(method, methodName);
    },

    /**
     * Add member to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} memberName Member name
     * @param {*} value Member value
     * @since 0.1.7
     */
    _addMemberToPrototype: function (newPrototype, memberName, value) {
        if (typeof value === "function") {
            this._addMethodToPrototype(newPrototype, memberName, value);
        } else {
            newPrototype[memberName] = value;
        }
    },

    /**
     * Build the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @since 0.1.7
     */
    _buildPrototype: function (newPrototype) {
        _gpfObjectForEach(this._initialDefinition, function (value, memberName) {
            if (memberName.charAt(0) !== "$" && memberName !== "constructor") {
                this._addMemberToPrototype(newPrototype, memberName, value); //eslint-disable-line no-invalid-this
            }
        }, this);
    },

    /**
     * Set the inherited constructor if not Object
     * @since 0.1.7
     */
    _setResolvedConstructorToInherited: function () {
        if (this._extend !== Object) {
            this._resolvedConstructor = this._extend;
        }
    },

    /**
     * Assign the proper constructor to _resolvedConstructor
     * @since 0.1.7
     */
    _resolveConstructor: function () {
        if (this._initialDefinition.hasOwnProperty("constructor")) {
            /* jshint -W069*/ /*eslint-disable dot-notation*/
            this._resolvedConstructor = this._superify(this._initialDefinition["constructor"], "constructor");
            /* jshint +W069*/ /*eslint-enable dot-notation*/
        } else {
            this._setResolvedConstructorToInherited();
        }
    }

});
<|endoftext|>


<commit_before>const express = require('express');
const db = require('../models');
const router = express.Router();

const favorite = {
  add: (req, res) => {

  },

  browse: (req, res) => {
    const userId = req.user.id;
    db.Favorite.findAll({
      where: {
        user_id: userId
      },
      attributes: ['restaurant_id']
    }).then((favorites) => {
      res.status(200).json({ favorites: favorites });
    })
  }
}

module.exports = favorite
<commit_msg>fetch favorites successfully<commit_after>const express = require('express');
const db = require('../models');
const router = express.Router();

const favorite = {
  add: (req, res) => {

  },

  browse: (req, res) => {
    const userId = req.user.id;
    db.Favorite.findAll({
      where: {
        user_id: userId
      },
      attributes: ['restaurant_id']
    }).then((favorites) => {
      const temp = favorites.map(function(favorite){return favorite.restaurant_id});
      res.status(200).json({ favorites: temp });
    })
  }
}

module.exports = favorite
<|endoftext|>


<commit_before>const fs = require('fs-extra');
const path = require('path');
const inquirer = require('inquirer');
const crlf = require('crlf');
const glob = require('glob-promise');

const runScript = require('./libs/run-script');
const logWelcome = require('./libs/log/welcome');
const logAbort = require('./libs/log/abort');
const logFinish = require('./libs/log/finish');
const spinner = require('./packages/koot/utils/spinner');

const prePublish = async () => {
    const title = 'pre-publish';
    const waiting = spinner(title + '...');

    const packages = await glob(
        path.resolve(__dirname, 'packages/*/package.json')
    );
    const bins = [];

    // 汇总所有 bin 文件
    for (const packageJson of packages) {
        const dir = path.dirname(packageJson);
        const { bin = {} } = await fs.readJson(packageJson);
        for (const pathname of Object.values(bin)) {
            bins.push(path.resolve(dir, pathname));
        }
    }

    // 将所有 bin 文件的换行符改为 LF
    for (const file of bins) {
        await new Promise((resolve, reject) => {
            crlf.set(file, 'LF', (err, endingType) => {
                if (err) return reject(err);
                resolve(endingType);
            });
        });
    }

    // git commit
    const git = require('simple-git/promise')(__dirname);
    const complete = () => {
        waiting.stop();
        spinner(title).succeed();
    };
    try {
        const { modified = [] } = await git.status();
        if (modified.length) {
            await git.add('./*');
            await git.commit(`changed all bins' line breaks to LF`);
        }
        complete();
    } catch (e) {
        if (e.message === 'No staged files match any of provided globs.')
            complete();
        else console.error(e);
    }
};

const run = async () => {
    logWelcome('Publish');

    const defaultSelected = [
        // 'koot',
        // 'koot-webpack'
    ];

    const dirPackages = path.resolve(__dirname, './packages');
    const packages = (await fs.readdir(dirPackages)).filter(filename => {
        const dir = path.resolve(dirPackages, filename);
        const lstat = fs.lstatSync(dir);
        if (!lstat.isDirectory()) return false;

        // 检查 package.json
        const filePackage = path.resolve(dir, 'package.json');
        if (!fs.existsSync(filePackage)) return false;

        let p;
        try {
            p = fs.readJsonSync(filePackage);
        } catch (e) {}

        if (typeof p !== 'object') return false;

        if (p.private) return false;

        return true;
    });

    const { selected = [] } = await inquirer.prompt({
        type: 'checkbox',
        name: 'selected',
        message: 'Select package(s) to publish\n ',
        choices: packages,
        default: defaultSelected
    });
    console.log('');
    if (!selected.length) {
        logAbort('No package selected.');
        return;
    }

    const { tag = false } = await inquirer.prompt({
        type: 'list',
        name: 'tag',
        message: 'Select tag for NPM',
        choices: [
            {
                name: 'Please select a tag',
                value: false
            },
            {
                name: 'No tag (none)',
                value: ''
            },
            'next'
        ],
        default: 0
    });
    console.log('');
    if (tag === false) {
        logAbort('No tag selected.');
        return;
    }

    await prePublish();
    await runScript(
        `lerna publish` +
            ` --ignore-changes "packages/!(${selected.join('|')})/**"` +
            (tag ? ` --dist-tag ${tag}` : '')
    );

    logFinish();
};

run().catch(async e => console.error(e));
<commit_msg>update publish script<commit_after>const fs = require('fs-extra');
const path = require('path');
const inquirer = require('inquirer');
const crlf = require('crlf');
const glob = require('glob-promise');

const runScript = require('./libs/run-script');
const logWelcome = require('./libs/log/welcome');
const logAbort = require('./libs/log/abort');
const logFinish = require('./libs/log/finish');
const spinner = require('./packages/koot/utils/spinner');

const prePublish = async () => {
    const title = 'pre-publish';
    const waiting = spinner(title + '...');

    const packages = await glob(
        path.resolve(__dirname, 'packages/*/package.json')
    );
    const bins = [];

    // 汇总所有 bin 文件
    for (const packageJson of packages) {
        const dir = path.dirname(packageJson);
        const { bin = {} } = await fs.readJson(packageJson);
        for (const pathname of Object.values(bin)) {
            bins.push(path.resolve(dir, pathname));
        }
    }

    // 将所有 bin 文件的换行符改为 LF
    for (const file of bins) {
        await new Promise((resolve, reject) => {
            crlf.set(file, 'LF', (err, endingType) => {
                if (err) return reject(err);
                resolve(endingType);
            });
        });
    }

    // git commit
    const git = require('simple-git/promise')(__dirname);
    const complete = () => {
        waiting.stop();
        spinner(title).succeed();
        console.log(' ');
    };
    try {
        const { modified = [] } = await git.status();
        if (modified.length) {
            await git.add('./*');
            await git.commit(`changed all bins' line breaks to LF`);
        }
        complete();
    } catch (e) {
        if (e.message === 'No staged files match any of provided globs.')
            complete();
        else console.error(e);
    }
};

const run = async () => {
    logWelcome('Publish');

    const defaultSelected = [
        // 'koot',
        // 'koot-webpack'
    ];

    const dirPackages = path.resolve(__dirname, './packages');
    const packages = (await fs.readdir(dirPackages)).filter(filename => {
        const dir = path.resolve(dirPackages, filename);
        const lstat = fs.lstatSync(dir);
        if (!lstat.isDirectory()) return false;

        // 检查 package.json
        const filePackage = path.resolve(dir, 'package.json');
        if (!fs.existsSync(filePackage)) return false;

        let p;
        try {
            p = fs.readJsonSync(filePackage);
        } catch (e) {}

        if (typeof p !== 'object') return false;

        if (p.private) return false;

        return true;
    });

    const { selected = [] } = await inquirer.prompt({
        type: 'checkbox',
        name: 'selected',
        message: 'Select package(s) to publish\n ',
        choices: packages,
        default: defaultSelected
    });
    console.log('');
    if (!selected.length) {
        logAbort('No package selected.');
        return;
    }

    const { tag = false } = await inquirer.prompt({
        type: 'list',
        name: 'tag',
        message: 'Select tag for NPM',
        choices: [
            {
                name: 'Please select a tag',
                value: false
            },
            {
                name: 'No tag (none)',
                value: ''
            },
            'next'
        ],
        default: 0
    });
    console.log('');
    if (tag === false) {
        logAbort('No tag selected.');
        return;
    }

    await prePublish();
    await runScript(
        `lerna publish` +
            ` --ignore-changes "packages/!(${selected.join('|')})/**"` +
            (tag ? ` --dist-tag ${tag}` : '')
    );

    logFinish();
};

run().catch(async e => console.error(e));
<|endoftext|>


<commit_before>import React from 'react';
import { connect } from 'react-redux';
import Input from '../components/Input';
import Select from '../components/Select';
import Button from '../components/Button';

const ListForm = connect(state => state)(
	({ dataFromAPI }) => {
		if (dataFromAPI.loading) {
			return (
Loading...
);
		}

		return (

								<input type="checkbox" />

								<input type="text" value="Title" />
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Type]"
									data={['All', 'Deposits', 'Withdrawals']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Day]"
									data={['All', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<input type="text" value="Min Amount" />
								<Button text="Down" />
								<Button text="Close" />

								<input type="text" value="Max Amount" />
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Platforms]"
									data={['All', 'MT4', 'MT5', 'Tradologic']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Servers]"
									data={['All', 'Live20', 'Live21']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Groups]"
									data={['All', 'usd-11', 'usd-risk']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Modified By]"
									data={['All', 'admin', 'user']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="Modified Date"
									data={['All']}
								/>

								Save

						{dataFromAPI.response.data.map((item, key) => (

									<input type="checkbox" />

									title

									<Select
										data={['All', 'Deposits', 'Withdrawals']}
									/>

									<Select
										data={['All', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']}
									/>

									<input type="text" value="Min Amount" />

									<input type="text" value="Max Amount" />

									<Select
										data={['All', 'MT4', 'MT5', 'Tradologic']}
									/>

									<Select
										data={['All', 'Live20', 'Live21']}
									/>

									<Select
										data={['All', 'usd-11', 'usd-risk']}
									/>

									<Select
										data={['All', 'admin', 'user']}
									/>

									<Select
										data={['All']}
									/>

									<Button text="Save" />

						))}

					<Button text="Delete All"/ >
					<Button text="Save All" />

						Prev
						1
						...
						2
						15
						Next

					Show Per:
					<Select data={[100, 200, 300]} />

		);
	}
);

export default ListForm;
<commit_msg>Add some data Add Delete<commit_after>import React from 'react';
import { connect } from 'react-redux';
import Input from '../components/Input';
import Select from '../components/Select';
import Button from '../components/Button';

const ListForm = connect(state => state)(
	({ dataFromAPI }) => {
		if (dataFromAPI.loading) {
			return (
Loading...
);
		}

		return (

								<input type="checkbox" />

								<input type="text" value="Title" />
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Type]"
									data={['All', 'Deposits', 'Withdrawals']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Day]"
									data={['All', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<input type="text" value="Min Amount" />
								<Button text="Down" />
								<Button text="Close" />

								<input type="text" value="Max Amount" />
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Platforms]"
									data={['All', 'MT4', 'MT5', 'Tradologic']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Servers]"
									data={['All', 'Live20', 'Live21']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Groups]"
									data={['All', 'usd-11', 'usd-risk']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="[Modified By]"
									data={['All', 'admin', 'user']}
								/>
								<Button text="Down" />
								<Button text="Close" />

								<Select
									title="Modified Date"
									data={['All']}
								/>

								Save

								Delete

						{dataFromAPI.response.data.map((item) => (

									<input type="checkbox" />

									{item.comment}

									<Select
										data={['All', 'Deposits', 'Withdrawals']}
									/>

									<Select
										data={['All', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']}
									/>

									<input type="text" value="Min Amount" value={item.amount} />

									<input type="text" value="Max Amount" value={item.amount} />

									<Select
										data={['All', 'MT4', 'MT5', 'Tradologic']}
									/>

									<Select
										data={['All', 'Live20', 'Live21']}
									/>

									<Select
										data={['All', 'usd-11', 'usd-risk']}
									/>

									<Select
										data={['All', 'admin', 'user']}
									/>

									<Select
										data={['All']}
									/>

									<Button text="Save" />

									<Button text="Delete" />

						))}

					<Button text="Delete All"/ >
					<Button text="Save All" />

						Prev
						1
						...
						2
						15
						Next

					Show Per:
					<Select data={[100, 200, 300]} />

		);
	}
);

export default ListForm;
<|endoftext|>