From 7b7d7d1bd23f66ac158c4695bb1bd7d75b8e934f Mon Sep 17 00:00:00 2001
From: Bruno Dias <dias.h.bruno@gmail.com>
Date: Tue, 22 Mar 2016 22:16:53 -0300
Subject: [PATCH 04/11] moved example to the examples folder.

---
 examples/index.html |  39 +++++++++++++++++
 examples/main.js    |  79 ++++++++++++++++++++++++++++++++++
 index.html          | 119 ----------------------------------------------------
 3 files changed, 118 insertions(+), 119 deletions(-)
 create mode 100644 examples/index.html
 create mode 100644 examples/main.js
 delete mode 100644 index.html

diff --git a/examples/index.html b/examples/index.html
new file mode 100644
index 0000000..6b5f29f
--- /dev/null
+++ b/examples/index.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Bulk</title>
+  </head>
+  <body>
+      <p>Selected: <span id="selected"></span></p>
+    <table>
+      <thead>
+        <tr>
+          <th><input id="selectAll" type="checkbox" value=""/></th>
+          <th>Name</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td><input type="checkbox" value=""/></td>
+          <td>Name A</td>
+        </tr>
+        <tr>
+          <td><input type="checkbox" value=""/></td>
+          <td>Name B</td>
+        </tr>
+        <tr>
+          <td><input type="checkbox" value=""/></td>
+          <td>Name C</td>
+        </tr>
+        <tr>
+          <td><input type="checkbox" value=""/></td>
+          <td>Name D</td>
+        </tr>
+      </tbody>
+    </table>
+
+    <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
+    <script src="../bulk.js" type="text/javascript"></script>
+    <script src="main.js" type="text/javascript"></script>
+  </body>
+</html>
diff --git a/examples/main.js b/examples/main.js
new file mode 100644
index 0000000..52ce69e
--- /dev/null
+++ b/examples/main.js
@@ -0,0 +1,79 @@
+$(function() {
+  var sl = $("#selected");
+  var all = $("#selectAll");
+  var inputs = $("tbody input[type=checkbox]");
+  var collection = [];
+  // transform the inputs into a 'pair' of (uuid, <input />).
+  inputs.each(function(i, k) {
+    collection.push({ uuid: i + 1, content: k });
+  });
+
+  // the scope, to make things easy.
+  var scope = {};
+
+  // the api.
+  var bulkAction = bulk(scope, {
+    // toId maps the object from the data source,
+    // to the unique id in the list.
+    toId: function(x) {
+      return x.uuid;
+    },
+    // updates will always be executed for any change,
+    // except when settings the 'dataSource'.
+    update: function(scope, event, eventName) {
+      // get the list of selected ids.
+      var selected = scope.bulkAction.list();
+
+      // if not 'all', unmark the all checkbox.
+      if (!scope.bulkAction.all()) {
+        all[0].checked = '';
+      } else {
+        all[0].checked = 'checked';
+      }
+
+      // mark as checked if the uuid is in the selected list.
+      scope.collection.map(function(o, k) {
+        var checked = selected.indexOf(o.uuid) > -1;
+        o.content.checked = checked ? 'checked' : '';
+      });
+      // display info.
+      if (scope.bulkAction.all()) {
+        sl.html("all");
+      } else {
+        if (selected.length > 0) {
+          sl.html(selected.join(","));
+        } else {
+          sl.html("none");
+        }
+      }
+    }
+  });
+
+  // set the data source.
+  bulkAction.dataSource(collection);
+
+  // inject in the scope for easy access.
+  scope.bulkAction = bulkAction;
+  scope.collection = collection;
+
+  var k = setInterval(function() {
+    if (bulkAction.all()) {
+      return;
+    }
+    bulkAction.mark(parseInt(Math.random() * 4) + 1);
+  }, 1000);
+
+  // default value.
+  sl.html("none");
+
+  // events.
+  all.click(function(event) {
+    bulkAction.toogleAll(event);
+  });
+
+  collection.map(function(o, k) {
+    $(o.content).click(function(event) {
+      bulkAction.toogleMark(o.uuid, event);
+    });
+  });
+});
diff --git a/index.html b/index.html
deleted file mode 100644
index 16b8f41..0000000
--- a/index.html
+++ /dev/null
@@ -1,119 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <title>Bulk</title>
-  </head>
-  <body>
-      <p>Selected: <span id="selected"></span></p>
-    <table>
-      <thead>
-        <tr>
-          <th><input id="selectAll" type="checkbox" value=""/></th>
-          <th>Name</th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td><input type="checkbox" value=""/></td>
-          <td>Name A</td>
-        </tr>
-        <tr>
-          <td><input type="checkbox" value=""/></td>
-          <td>Name B</td>
-        </tr>
-        <tr>
-          <td><input type="checkbox" value=""/></td>
-          <td>Name C</td>
-        </tr>
-        <tr>
-          <td><input type="checkbox" value=""/></td>
-          <td>Name D</td>
-        </tr>
-      </tbody>
-    </table>
-
-    <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
-    <script src="bulk.js" type="text/javascript"></script>
-    <script type="text/javascript">
-     $(function() {
-         var sl = $("#selected");
-         var all = $("#selectAll");
-         var inputs = $("tbody input[type=checkbox]");
-         var collection = [];
-         // transform the inputs into a 'pair' of (uuid, <input />).
-         inputs.each(function(i, k) {
-             collection.push({ uuid: i + 1, content: k });
-         });
-
-         // the scope, to make things easy.
-         var scope = {};
-
-         // the api.
-         var bulkAction = bulk(scope, {
-             // toId maps the object from the data source,
-             // to the unique id in the list.
-             toId: function(x) {
-                 return x.uuid;
-             },
-             // updates will always be executed for any change,
-             // except when settings the 'dataSource'.
-             update: function(scope, event, eventName) {
-                 // get the list of selected ids.
-                 var selected = scope.bulkAction.list();
-
-                 // if not 'all', unmark the all checkbox.
-                 if (!scope.bulkAction.all()) {
-                     all[0].checked = '';
-                 } else {
-                     all[0].checked = 'checked';
-                 }
-
-                 // mark as checked if the uuid is in the selected list.
-                 scope.collection.map(function(o, k) {
-                     var checked = selected.indexOf(o.uuid) > -1;
-                     o.content.checked = checked ? 'checked' : '';
-                 });
-                 // display info.
-                 if (scope.bulkAction.all()) {
-                     sl.html("all");
-                 } else {
-                     if (selected.length > 0) {
-                         sl.html(selected.join(","));
-                     } else {
-                         sl.html("none");
-                     }
-                 }
-             }
-         });
-
-         // set the data source.
-         bulkAction.dataSource(collection);
-
-         // inject in the scope for easy access.
-         scope.bulkAction = bulkAction;
-         scope.collection = collection;
-
-         var k = setInterval(function() {
-             if (bulkAction.all()) {
-                 return;
-             }
-             bulkAction.mark(parseInt(Math.random() * 4) + 1);
-         }, 1000);
-
-         // default value.
-         sl.html("none");
-
-         // events.
-         all.click(function(event) {
-             bulkAction.toogleAll(event);
-         });
-
-         collection.map(function(o, k) {
-             $(o.content).click(function(event) {
-                 bulkAction.toogleMark(o.uuid, event);
-             });
-         });
-     });
-    </script>
-  </body>
-</html>
-- 
2.6.4

