<commit_before><%--
  Created by IntelliJ IDEA.
  User: manvendrask
  Date: 3/16/14
  Time: 12:21 AM
--%>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Animating Knockout.js</title>
    <meta name="layout" content="main"/>
</head>

<body>
<h1>Animating Knockout.js</h1>

<form action="#" method="post">

    <table>
        <thead>
        <tr>
            <th>Product</th>
            <th>Price</th>
            <th></th>
        </tr>
        </thead>
        <tbody data-bind="foreach: items">
        <tr>
            <td data-bind="text: name"></td>
            <td data-bind="text: price"></td>
            <td><button data-bind="click: $root.removeProduct">Remove</button></td>
        </tr>
        </tbody>
    </table>

    <button data-bind="click: addProduct">Add Beer</button>
</form>

<script type="text/javascript">
    function Product(name, price) {
        this.name = ko.observable(name);
        this.price = ko.observable(price);
    }

    function ShoppingCart() {
        var self = this;

        self.instructions = ko.observable("");
        self.hasInstructions = ko.observable(false);

        self.items = ko.observableArray([
            new Product("Beer", 10.99),
            new Product("Brats", 7.99),
            new Product("Buns", 1.49)
        ]);

        self.addProduct = function () {
            self.items.push(new Product("More Beer", 10.99));
        };

        self.removeProduct = function (product) {
            self.items.destroy(product);
        };
    }

    var shoppingVM = new ShoppingCart();
    ko.applyBindings(shoppingVM);
</script>
</body>
</html><commit_msg>Adding animation when removing and adding new rows.<commit_after><%--
  Created by IntelliJ IDEA.
  User: manvendrask
  Date: 3/16/14
  Time: 12:21 AM
--%>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Animating Knockout.js</title>
    <meta name="layout" content="main"/>
</head>

<body>
<h1>Animating Knockout.js</h1>

<form action="#" method="post">

    <table>
        <thead>
        <tr>
            <th>Product</th>
            <th>Price</th>
            <th></th>
        </tr>
        </thead>
        <tbody data-bind="foreach: {data: items, beforeRemove: hideProduct, afterAdd: showProduct}">
        <tr>
            <td data-bind="text: name"></td>
            <td data-bind="text: price"></td>
            <td><button data-bind="click: $root.removeProduct">Remove</button></td>
        </tr>
        </tbody>
    </table>

    <button data-bind="click: addProduct">Add Beer</button>
</form>

<script type="text/javascript">
    function Product(name, price) {
        this.name = ko.observable(name);
        this.price = ko.observable(price);
    }

    function ShoppingCart() {
        var self = this;

        self.instructions = ko.observable("");
        self.hasInstructions = ko.observable(false);

        self.items = ko.observableArray([
            new Product("Beer", 10.99),
            new Product("Brats", 7.99),
            new Product("Buns", 1.49)
        ]);

        self.addProduct = function () {
            self.items.push(new Product("More Beer", 10.99));
        };

        self.removeProduct = function (product) {
            self.items.destroy(product);
        };

        self.showProduct = function (element) {
            if (element.nodeType === 1) {
                $(element).hide().fadeIn();
            }
        };

        self.hideProduct = function (element) {
            if (element.nodeType === 1) {
                $(element).fadeOut(function () {
                    $(element).remove();
                });
            }
        };
    }

    var shoppingVM = new ShoppingCart();
    ko.applyBindings(shoppingVM);
</script>
</body>
</html>
{'fraction_non_alphanumeric': 0.16631467793030624, 'fraction_numerical': 0.014255543822597676, 'mean_word_length': 1.9881703470031546, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3091579', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1175, 'n_words': 234}