Skip to content

Commit

Permalink
Merge branch 'pr/2'
Browse files Browse the repository at this point in the history
  • Loading branch information
micc83 committed Apr 22, 2014
2 parents 193eebf + 4eed81e commit 0c089d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "editTable",
"version": "0.1.0",
"version": "0.1.1",
"description": "jQuery plugin that implement a data table input",
"keywords": [
"table",
Expand Down
6 changes: 3 additions & 3 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<meta name="description" content="jQuery editTable is a very small jQuery Plugin (~1Kb gzipped) that fill the gap left by the missing of a default input field for data tables.">
<link rel="stylesheet" href="main.css">
<script src="//code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="../jquery.edittable.js?v=0.1.0"></script>
<script type="text/javascript" src="../jquery.edittable.js?v=0.1.1"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="../jquery.edittable.css?v=0.1.0">
<link rel="stylesheet" href="../jquery.edittable.css?v=0.1.1">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script>
$(window).ready(function () {
Expand Down Expand Up @@ -116,7 +116,7 @@

<div class="container">

<h1>jQuery editTable <span>v0.1.0</span></h1>
<h1>jQuery editTable <span>v0.1.1</span></h1>

<a href="https://twitter.com/micc1983" class="twitter-follow-button" data-show-count="true" data-lang="en">Follow @micc1983</a>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="Micc1983">Tweet</a>
Expand Down
21 changes: 13 additions & 8 deletions jquery.edittable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! editTable v0.1.0 by Alessandro Benoit */
/*! editTable v0.1.1 by Alessandro Benoit */
(function ($, window, i) {

'use strict';
Expand Down Expand Up @@ -80,8 +80,8 @@
for (a = 0; a < crow; a += 1) {
buildRow(data[a], s.headerCols.length).appendTo($table.find('tbody'));
}
} else {
// Variable columns
} else if ( data[0] ) {
// Variable columns
for (a = 0; a < data[0].length; a += 1) {
$table.find('thead tr').append(defaultth);
}
Expand Down Expand Up @@ -124,7 +124,12 @@
// Fill the table with data from textarea or given properties
if ($el.is('textarea')) {

reset = JSON.parse($el.val());
try {
reset = JSON.parse($el.val());
} catch (e) {
reset = s.data;
}

$el.after($table);

// If inside a form set the textarea content on submit
Expand All @@ -144,7 +149,7 @@
// Add column
$table.on('click', '.addcol', function () {

var colid = parseInt($(this).parents('tr').children().index($(this).parent('th')), 10);
var colid = parseInt($(this).closest('tr').children().index($(this).parent('th')), 10);

colnumber += 1;

Expand All @@ -166,7 +171,7 @@
return false;
}

var colid = parseInt($(this).parents('tr').children().index($(this).parent('th')), 10);
var colid = parseInt($(this).closest('tr').children().index($(this).parent('th')), 10);

colnumber -= 1;

Expand All @@ -190,7 +195,7 @@

rownumber += 1;

$(this).parents('tr').after(buildRow(0, colnumber));
$(this).closest('tr').after(buildRow(0, colnumber));

$table.find('.delrow').removeClass('disabled');

Expand All @@ -210,7 +215,7 @@

checkButtons();

$(this).parents('tr').remove();
$(this).closest('tr').remove();

$table.find('.addrow').removeClass('disabled');

Expand Down
4 changes: 2 additions & 2 deletions jquery.edittable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0c089d6

Please sign in to comment.