Better way of fixing the djselectable problem - use bootstrap buttons
authorMagnus Hagander <magnus@hagander.net>
Wed, 23 Apr 2014 17:11:01 +0000 (19:11 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 23 Apr 2014 17:11:01 +0000 (19:11 +0200)
pgcommitfest/commitfest/templates/base.html
pgcommitfest/commitfest/templates/base_form.html
pgcommitfest/commitfest/views.py

index 55b6e84e47b987214c66a7b4076ae3111b327e77..940b2bf5ed29a15130077deee0315c9cb8696546 100644 (file)
@@ -41,7 +41,7 @@
 <script src="/static/commitfest/js/bootstrap-collapse.js"></script>
 <script src="/static/commitfest/js/jquery-ui.js"></script>
 <script type="text/javascript" src="/static/selectable/js/jquery.dj.selectable.js"></script>
-{%if not block_bootstrap_button%}<script src="/static/commitfest/js/bootstrap-button.js"></script>{%endif%}
+<script src="/static/commitfest/js/bootstrap-button.js"></script>
 <script src="/static/commitfest/js/commitfest.js"></script>
 {%block morescript%}{%endblock%}
 </html>
index d4c135a92734a4d06e7cff85c1329cb4edbd0662..4b079dced0ae6af50f5cc11fc93020966e6d5706 100644 (file)
@@ -66,6 +66,23 @@ div.controls ul.selectable-deck li.selectable-deck-item a.selectable-deck-remove
 {%if threadbrowse %}
 {%block morescript%}
 <script>
+/* Set up djselectable to use bootstrap buttons */
+$.ui.djselectable.prototype._comboButtonTemplate = function (input) {
+    var icon = $("<i>").addClass("icon-chevron-down");
+    // Remove current classes on the text input
+    $(input).attr("class", "");
+    // Wrap with input-append
+    $(input).wrap('<div class="input-append" />');
+    // Return button link with the chosen icon
+    return $("<a>").append(icon).addClass("btn btn-mini");
+};
+$.ui.djselectable.prototype._removeButtonTemplate = function (item) {
+    var icon = $("<i>").addClass("icon-remove-sign");
+    // Return button link with the chosen icon
+    return $("<a>").append(icon).addClass("btn btn-mini");
+};
+
+/* Build our button callbacks */
 $(document).ready(function() {
    $('button.attachThreadButton').each(function (i,o) {
       var b = $(o);
index ba0f9113e423033c40c6e3c7459e7dd7de524bca..6a72b93adc2d359d6e62395df0468950ff47a976 100644 (file)
@@ -168,7 +168,6 @@ def patchform(request, cfid, patchid):
                'title': 'Edit patch',
                'breadcrumbs': [{'title': cf.name, 'href': '/%s/' % cf.pk},
                                                {'title': 'View patch', 'href': '/%s/%s/' % (cf.pk, patch.pk)}],
-               'block_bootstrap_button': True,
        }, context_instance=RequestContext(request))
 
 @login_required