diff options
author | Stephen Finucane <stephen.finucane@intel.com> | 2016-03-14 16:11:56 +0000 |
---|---|---|
committer | Stephen Finucane <stephen.finucane@intel.com> | 2016-03-15 11:30:36 +0000 |
commit | 44fe7bae80be9de34c6d6ce4e239f51beb2f16ff (patch) | |
tree | 0721b24a2078c3ebf66fc92aefaedf7b548cb807 | |
parent | 254b7fb1fdae3b3632770b93e3e269267fbbff96 (diff) | |
download | patchwork-44fe7bae80be9de34c6d6ce4e239f51beb2f16ff.tar patchwork-44fe7bae80be9de34c6d6ce4e239f51beb2f16ff.tar.gz |
js: Allow shift-select of checkboxes
Allow bulk modification of patches through shift-select of the check
boxes on each line.
This allows for the removal of the 'common.js' file, which was only
being used in one location.
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
-rw-r--r-- | htdocs/js/bundle.js | 6 | ||||
-rw-r--r-- | htdocs/js/common.js | 25 | ||||
l--------- | htdocs/js/jquery.checkboxes-1.0.6.min.js | 1 | ||||
-rw-r--r-- | lib/packages/jquery/jquery.checkboxes-1.0.6.min.js | 1 | ||||
-rw-r--r-- | patchwork/templates/patchwork/patch-list.html | 14 | ||||
-rw-r--r-- | templates/base.html | 2 |
6 files changed, 21 insertions, 28 deletions
diff --git a/htdocs/js/bundle.js b/htdocs/js/bundle.js index 0bdf41a..c969d0b 100644 --- a/htdocs/js/bundle.js +++ b/htdocs/js/bundle.js @@ -80,3 +80,9 @@ function row_to_patch_id(node) return id_str.substring(i + 1); } + +function confirm_delete(type, name) +{ + return confirm("Are you sure you want to delete the " + type + + " '" + name + "'?"); +} diff --git a/htdocs/js/common.js b/htdocs/js/common.js deleted file mode 100644 index f725693..0000000 --- a/htdocs/js/common.js +++ /dev/null @@ -1,25 +0,0 @@ - -function confirm_delete(type, name) -{ - return confirm("Are you sure you want to delete the " + type + - " '" + name + "'?"); -} - -function select_all(obj) -{ - var value = obj.checked; - var form = obj.form; - - select_all_checkbox = obj; - - for (var i = 0; i < form.elements.length; i++ ) { - var element = form.elements[i]; - if (element.type != 'checkbox') { - continue; - } - if (element.name.substring(0, 9) != 'patch_id:') { - continue; - } - element.checked = value; - } -} diff --git a/htdocs/js/jquery.checkboxes-1.0.6.min.js b/htdocs/js/jquery.checkboxes-1.0.6.min.js new file mode 120000 index 0000000..dfef5d4 --- /dev/null +++ b/htdocs/js/jquery.checkboxes-1.0.6.min.js @@ -0,0 +1 @@ +../../lib/packages/jquery/jquery.checkboxes-1.0.6.min.js
\ No newline at end of file diff --git a/lib/packages/jquery/jquery.checkboxes-1.0.6.min.js b/lib/packages/jquery/jquery.checkboxes-1.0.6.min.js new file mode 100644 index 0000000..b8ab064 --- /dev/null +++ b/lib/packages/jquery/jquery.checkboxes-1.0.6.min.js @@ -0,0 +1 @@ +/*! checkboxes.js v1.0.6 | (c) 2013, 2014 Rubens Mariuzzo | http://github.com/rmariuzzo/checkboxes.js/LICENSE */"use strict";!function(a){var b=function(a){this.$context=a};b.prototype.check=function(){this.$context.find(":checkbox").filter(":not(:disabled)").prop("checked",!0)},b.prototype.uncheck=function(){this.$context.find(":checkbox").filter(":not(:disabled)").prop("checked",!1)},b.prototype.toggle=function(){this.$context.find(":checkbox").filter(":not(:disabled)").each(function(){var b=a(this);b.prop("checked",!b.is(":checked"))})},b.prototype.max=function(a){if(a>0){var b=this;this.$context.on("click.checkboxes.max",":checkbox",function(){b.$context.find(":checked").length===a?b.$context.find(":checkbox:not(:checked)").prop("disabled",!0):b.$context.find(":checkbox:not(:checked)").prop("disabled",!1)})}else this.$context.off("click.checkboxes")},b.prototype.range=function(b){if(b){var c=this;this.$context.on("click.checkboxes.range",":checkbox",function(b){var d=a(b.target);if(b.shiftKey&&c.$last){var e=c.$context.find(":checkbox"),f=e.index(c.$last),g=e.index(d),h=Math.min(f,g),i=Math.max(f,g)+1;e.slice(h,i).filter(":not(:disabled)").prop("checked",d.prop("checked"))}c.$last=d})}else this.$context.off("click.checkboxes.range")};var c=a.fn.checkboxes;a.fn.checkboxes=function(c){var d=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=a(this),f=e.data("checkboxes");f||e.data("checkboxes",f=new b(e,"object"==typeof c&&c)),"string"==typeof c&&f[c]&&f[c].apply(f,d)})},a.fn.checkboxes.Constructor=b,a.fn.checkboxes.noConflict=function(){return a.fn.checkboxes=c,this};var d=function(b){var c=a(b.target),d=c.attr("href"),e=a(c.data("context")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=c.data("action");e&&f&&(c.is(":checkbox")||b.preventDefault(),e.checkboxes(f))},e=function(){a("[data-toggle^=checkboxes]").each(function(){var b=a(this),c=b.data();delete c.toggle;for(var d in c)b.checkboxes(d,c[d])})};a(document).on("click.checkboxes.data-api","[data-toggle^=checkboxes]",d),a(document).on("ready.checkboxes.data-api",e)}(window.jQuery);
\ No newline at end of file diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html index 66149c3..167363e 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/patch-list.html @@ -40,18 +40,28 @@ <script type="text/javascript"> $(document).ready(function() { $('#patchlist').stickyTableHeaders(); + + $('#check-all').change(function(e) { + if(this.checked) { + $('#patchlist').checkboxes('check'); + } else { + $('#patchlist').checkboxes('uncheck'); + } + e.preventDefault(); + }); }); </script> <form method="post"> {% csrf_token %} <input type="hidden" name="form" value="patchlistform"/> <input type="hidden" name="project" value="{{project.id}}"/> -<table class="table table-hover table-condensed pw-list" id="patchlist"> +<table id="patchlist" class="table table-hover table-condensed pw-list" + data-toggle="checkboxes" data-range="true"> <thead> <tr> {% if user.is_authenticated %} <th> - <input type="checkbox" onChange="select_all(this)"/> + <input type="checkbox" id="check-all"/> </th> {% endif %} diff --git a/templates/base.html b/templates/base.html index 8e101dd..0e9dd0f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,9 +7,9 @@ <link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.min.css" %}"/> <link rel="stylesheet" type="text/css" href="{% static "css/selectize.bootstrap3.css" %}"/> <link rel="stylesheet" type="text/css" href="{% static "css/style.css" %}"/> - <script type="text/javascript" src="{% static "js/common.js" %}"></script> <script type="text/javascript" src="{% static "js/jquery-1.10.1.min.js" %}"></script> <script type="text/javascript" src="{% static "js/jquery.stickytableheaders.min.js" %}"></script> + <script type="text/javascript" src="{% static "js/jquery.checkboxes-1.0.6.min.js" %}"></script> <!-- IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> |