diff --git a/datatables.json b/datatables.json index f305275..6bd7861 100644 --- a/datatables.json +++ b/datatables.json @@ -25,5 +25,5 @@ ], "src-repo": "http://github.com/DataTables/Buttons", "last-tag": "3.1.2", - "last-sync": "70c236b07d2fb7c41887b178e59c10c3258fe9ab" + "last-sync": "7099db386b1f372bd2fc6db24739dcf34ec9f802" } \ No newline at end of file diff --git a/js/dataTables.buttons.js b/js/dataTables.buttons.js index a023fcf..3a34a07 100644 --- a/js/dataTables.buttons.js +++ b/js/dataTables.buttons.js @@ -693,6 +693,13 @@ $.extend(Buttons.prototype, { attachTo.push(built); } + // Any button type can have a drop icon set + if (built.conf.dropIcon && ! built.conf.split) { + $(built.node) + .addClass(this.c.dom.button.dropClass) + .append(this.c.dom.button.dropHtml); + } + // Create the dropdown for a collection if (built.conf.buttons) { built.collection = $( @@ -700,8 +707,6 @@ $.extend(Buttons.prototype, { ); built.conf._collection = built.collection; - $(built.node).append(domCollection.action.dropHtml); - this._expandButton( built.buttons, built.conf.buttons, @@ -1006,7 +1011,8 @@ $.extend(Buttons.prototype, { dropdownConf.dropdown.className + ' dt-button">' ) - .html(dropdownConf.dropdown.dropHtml) + .html(this.c.dom.button.dropHtml) + .addClass(this.c.dom.button.dropClass) .on('click.dtb', function (e) { e.preventDefault(); e.stopPropagation(); @@ -2073,10 +2079,6 @@ Buttons.defaults = { className: 'dt-buttons' }, collection: { - action: { - // action button - dropHtml: '' - }, container: { // The element used for the dropdown className: 'dt-button-collection', @@ -2102,7 +2104,9 @@ Buttons.defaults = { liner: { tag: 'span', className: '' - } + }, + dropClass: '', + dropHtml: '' }, split: { action: { @@ -2114,7 +2118,6 @@ Buttons.defaults = { // button to trigger the dropdown align: 'split-right', className: 'dt-button-split-drop', - dropHtml: '', splitAlignClass: 'dt-button-split-left', tag: 'button' }, @@ -2141,6 +2144,7 @@ $.extend(_dtButtons, { }, className: 'buttons-collection', closeButton: false, + dropIcon: true, init: function (dt, button) { button.attr('aria-expanded', false); }, diff --git a/js/dataTables.buttons.min.js b/js/dataTables.buttons.min.js index c3069b3..6405a78 100644 --- a/js/dataTables.buttons.min.js +++ b/js/dataTables.buttons.min.js @@ -1,4 +1,4 @@ /*! Buttons for DataTables 3.1.2 * © SpryMedia Ltd - datatables.net/license */ -!function(e){var o,i;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return e(t,window,document)}):"object"==typeof exports?(o=require("jquery"),i=function(t,n){n.fn.dataTable||require("datatables.net")(t,n)},"undefined"==typeof window?module.exports=function(t,n){return t=t||window,n=n||o(t),i(t,n),e(n,t,t.document)}:(i(window,o),module.exports=e(o,window,window.document))):e(jQuery,window,document)}(function(x,m,v){"use strict";var e=x.fn.dataTable,o=0,C=0,_=e.ext.buttons,i=null;function y(t,n,e){x.fn.animate?t.stop().fadeIn(n,e):(t.css("display","block"),e&&e.call(t))}function w(t,n,e){x.fn.animate?t.stop().fadeOut(n,e):(t.css("display","none"),e&&e.call(t))}function A(n,t){if(!e.versionCheck("2"))throw"Warning: Buttons requires DataTables 2 or newer";if(!(this instanceof A))return function(t){return new A(t,n).container()};!0===(t=void 0===t?{}:t)&&(t={}),Array.isArray(t)&&(t={buttons:t}),this.c=x.extend(!0,{},A.defaults,t),t.buttons&&(this.c.buttons=t.buttons),this.s={dt:new e.Api(n),buttons:[],listenKeys:"",namespace:"dtb"+o++},this.dom={container:x("<"+this.c.dom.container.tag+"/>").addClass(this.c.dom.container.className)},this._constructor()}x.extend(A.prototype,{action:function(t,n){t=this._nodeToButton(t);return void 0===n?t.conf.action:(t.conf.action=n,this)},active:function(t,n){var t=this._nodeToButton(t),e=this.c.dom.button.active,o=x(t.node);return t.inCollection&&this.c.dom.collection.button&&void 0!==this.c.dom.collection.button.active&&(e=this.c.dom.collection.button.active),void 0===n?o.hasClass(e):(o.toggleClass(e,void 0===n||n),this)},add:function(t,n,e){var o=this.s.buttons;if("string"==typeof n){for(var i=n.split("-"),s=this.s,r=0,a=i.length-1;r"),h.conf._collection=h.collection,x(h.node).append(c.action.dropHtml),this._expandButton(h.buttons,h.conf.buttons,h.conf.split,!a,a,s,h.conf)),h.conf.split){h.collection=x("<"+c.container.tag+"/>"),h.conf._collection=h.collection;for(var b=0;b").addClass("dt-button-spacer "+n.style+" "+p.spacer.className).html(i(n.text)),{conf:n,node:d,inserter:d,buttons:[],inCollection:t,isSplit:e,collection:null,textNode:d};if(n.available&&!n.available(f,n)&&!n.html)return!1;n.html?c=x(n.html):(r=function(t,n,e,o,i){o.action.call(n.button(e),t,n,e,o,i),x(n.table().node()).triggerHandler("buttons-action.dt",[n.button(e),n,e,o])},a=function(t,n,e,o){o.async?(u.processing(e[0],!0),setTimeout(function(){r(t,n,e,o,function(){u.processing(e[0],!1)})},o.async)):r(t,n,e,o,function(){})},d=n.tag||p.tag,l=void 0===n.clickBlurs||n.clickBlurs,c=x("<"+d+"/>").addClass(p.className).attr("tabindex",this.s.dt.settings()[0].iTabIndex).attr("aria-controls",this.s.dt.table().node().id).on("click.dtb",function(t){t.preventDefault(),!c.hasClass(p.disabled)&&n.action&&a(t,f,c,n),l&&c.trigger("blur")}).on("keypress.dtb",function(t){13===t.keyCode&&(t.preventDefault(),!c.hasClass(p.disabled))&&n.action&&a(t,f,c,n)}),"a"===d.toLowerCase()&&c.attr("href","#"),"button"===d.toLowerCase()&&c.attr("type","button"),s=p.liner.tag?(d=x("<"+p.liner.tag+"/>").html(i(n.text)).addClass(p.liner.className),"a"===p.liner.tag.toLowerCase()&&d.attr("href","#"),c.append(d),d):(c.html(i(n.text)),c),!1===n.enabled&&c.addClass(p.disabled),n.className&&c.addClass(n.className),n.titleAttr&&c.attr("title",i(n.titleAttr)),n.attr&&c.attr(n.attr),n.namespace||(n.namespace=".dt-button-"+C++),void 0!==n.config&&n.config.split&&(n.split=n.config.split));var h,b,g,m,v,y,d=this.c.dom.buttonContainer,d=d&&d.tag?x("<"+d.tag+"/>").addClass(d.className).append(c):c;return this._addKey(n),this.c.buttonCreated&&(d=this.c.buttonCreated(n,d)),e&&(b=(h=t?x.extend(!0,this.c.dom.split,this.c.dom.collection.split):this.c.dom.split).wrapper,g=x("<"+b.tag+"/>").addClass(b.className).append(c),m=x.extend(n,{autoClose:!0,align:h.dropdown.align,attr:{"aria-haspopup":"dialog","aria-expanded":!1},className:h.dropdown.className,closeButton:!1,splitAlignClass:h.dropdown.splitAlignClass,text:h.dropdown.text}),this._addKey(m),v=function(t,n,e,o){_.split.action.call(n.button(g),t,n,e,o),x(n.table().node()).triggerHandler("buttons-action.dt",[n.button(e),n,e,o]),e.attr("aria-expanded",!0)},y=x('').html(h.dropdown.dropHtml).on("click.dtb",function(t){t.preventDefault(),t.stopPropagation(),y.hasClass(p.disabled)||v(t,f,y,m),l&&y.trigger("blur")}).on("keypress.dtb",function(t){13===t.keyCode&&(t.preventDefault(),y.hasClass(p.disabled)||v(t,f,y,m))}),0===n.split.length&&y.addClass("dtb-hide-drop"),g.append(y).attr(m.attr)),{conf:n,node:(e?g:c).get(0),inserter:e?g:d,buttons:[],inCollection:t,isSplit:e,inSplit:o,collection:null,textNode:s}},_checkSplitEnable:function(t){t=t||this.s.buttons;for(var n=0;n").addClass(h.containerClassName).addClass(h.collectionLayout).addClass(h.splitAlignClass).addClass(n).css("display","none").attr({"aria-modal":!0,role:"dialog"}),o=x(o).addClass(h.contentClassName).attr("role","menu").appendTo(e),g.attr("aria-expanded","true"),g.parents("body")[0]!==v.body&&(g=v.body.lastChild),h.popoverTitle?e.prepend('
'+h.popoverTitle+"
"):h.collectionTitle&&e.prepend('
'+h.collectionTitle+"
"),h.closeButton&&e.prepend('
×
').addClass("dtb-collection-closeable"),y(e.insertAfter(g),h.fade),f=x(t.table().container()),n=e.css("position"),"container"!==h.span&&"dt-container"!==h.align||(g=g.parent(),e.css("width",f.width())),"absolute"===n?(t=x(g[0].offsetParent),f=g.position(),n=g.offset(),a=t.offset(),s=t.position(),r=m.getComputedStyle(t[0]),a.height=t.outerHeight(),a.width=t.width()+parseFloat(r.paddingLeft),a.right=a.left+a.width,a.bottom=a.top+a.height,a=f.top+g.outerHeight(),l=f.left,e.css({top:a,left:l}),r=m.getComputedStyle(e[0]),(c=e.offset()).height=e.outerHeight(),c.width=e.outerWidth(),c.right=c.left+c.width,c.bottom=c.top+c.height,c.marginTop=parseFloat(r.marginTop),c.marginBottom=parseFloat(r.marginBottom),h.dropup&&(a=f.top-c.height-c.marginTop-c.marginBottom),"button-right"!==h.align&&!e.hasClass(h.rightAlignClassName)||(l=f.left-c.width+g.outerWidth()),"dt-container"!==h.align&&"container"!==h.align||lx(m).width()&&(l=x(m).width()-c.width-s.left),n.left+l<0&&(l=-n.left),s.top+a+c.height>x(m).height()+x(m).scrollTop()&&(a=f.top-c.height-c.marginTop-c.marginBottom),t.offset().top+a").addClass(n).css("display","none").insertAfter(o),e):w(x("div."+n),e,function(){x(this).removeClass(n).remove()})},A.instanceSelector=function(t,s){var r,a,l;return null==t?x.map(s,function(t){return t.inst}):(r=[],a=x.map(s,function(t){return t.name}),(l=function(t){var n;if(Array.isArray(t))for(var e=0,o=t.length;e)|(