diff --git a/assets/dist/datagrid.js b/assets/dist/datagrid.js index 1317ab88..13f490e3 100755 --- a/assets/dist/datagrid.js +++ b/assets/dist/datagrid.js @@ -613,7 +613,7 @@ $.nette.ext('datagrid.reset-filter-by-column', { return grid.find('[data-datagrid-reset-filter-by-column]').each(function() { var new_href; key = $(this).attr('data-datagrid-reset-filter-by-column'); - new_href = href.replace('do=examplesGrid-resetFilter', 'do=' + payload._datagrid_name + '-resetColumnFilter'); + new_href = href.replace('do=' + payload._datagrid_name + '-resetFilter', 'do=' + payload._datagrid_name + '-resetColumnFilter'); new_href += '&' + payload._datagrid_name + '-key=' + key; return $(this).attr('href', new_href); }); diff --git a/assets/dist/datagrid.min.js b/assets/dist/datagrid.min.js index 9910677b..40205e62 100755 --- a/assets/dist/datagrid.min.js +++ b/assets/dist/datagrid.min.js @@ -1 +1 @@ -var datagridFitlerMultiSelect,datagridSortable,datagridSortableTree;$(document).on("click","[data-datagrid-confirm]:not(.ajax)",function(t){return confirm($(t.target).closest("a").attr("data-datagrid-confirm"))?void 0:(t.stopPropagation(),t.preventDefault())}),$.nette.ext("datagrid.confirm",{before:function(t,e){var a;return e.nette&&(a=e.nette.el.data("datagrid-confirm"))?confirm(a):void 0}}),$(document).on("change","select[data-autosubmit-per-page]",function(){return $(this).parent().find("input[type=submit]").click()}).on("change","select[data-autosubmit]",function(){return $(this).closest("form").submit()}).on("change","input[data-autosubmit][data-autosubmit-change]",function(t){var e,a;return a=t.which||t.keyCode||0,clearTimeout(window.datagrid_autosubmit_timer),e=$(this),window.datagrid_autosubmit_timer=setTimeout(function(t){return function(){return e.closest("form").submit()}}(this),200)}).on("keyup","input[data-autosubmit]",function(t){var e,a;return a=t.which||t.keyCode||0,13!==a&&(a>=9&&40>=a||a>=112&&123>=a)?void 0:(clearTimeout(window.datagrid_autosubmit_timer),e=$(this),window.datagrid_autosubmit_timer=setTimeout(function(t){return function(){return e.closest("form").submit()}}(this),200))}).on("keydown",".datagrid-inline-edit input",function(t){var e;return e=t.which||t.keyCode||0,13===e?(t.stopPropagation(),t.preventDefault(),$(this).closest("tr").find('.col-action-inline-edit [name="inline_edit[submit]"]').click()):void 0}),$(document).on("keydown","input[data-datagrid-manualsubmit]",function(t){var e;return e=t.which||t.keyCode||0,13===e?(t.stopPropagation(),t.preventDefault(),$(this).closest("form").submit()):void 0}),document.addEventListener("change",function(t){var e,a,i,d,r,n,o,l,s,c;if(i=t.target.getAttribute("data-check"),i&&(e=document.querySelector(".datagrid-"+i+" input[data-check]:checked"),c=document.querySelector(".datagrid-"+i+' select[name="group_action[group_action]"]'),c&&(e?c.disabled=!1:(c.disabled=!0,c.value="")),r=window.navigator.userAgent.indexOf("MSIE "),r?(a=document.createEvent("Event"),a.initEvent("change",!0,!0)):a=new Event("change",{bubbles:!0}),c&&c.dispatchEvent(a)),i=t.target.getAttribute("data-check-all")){for(o=document.querySelectorAll("input[type=checkbox][data-check-all-"+i+"]"),s=[],d=0,l=o.length;l>d;d++)n=o[d],n.checked=t.target.checked,r=window.navigator.userAgent.indexOf("MSIE "),r?(a=document.createEvent("Event"),a.initEvent("change",!0,!0)):a=new Event("change",{bubbles:!0}),s.push(n.dispatchEvent(a));return s}}),window.datagridSerializeUrl=function(t,e){var a=[];for(var i in t)if(t.hasOwnProperty(i)){var d=e?e+"["+i+"]":i,r=t[i];if(null!==r&&""!==r)if("object"==typeof r){var n=window.datagridSerializeUrl(r,d);n&&a.push(n)}else a.push(encodeURIComponent(d)+"="+encodeURIComponent(r))}return a.join("&")},datagridSortable=function(){return"undefined"!=typeof $.fn.sortable?$(".datagrid [data-sortable]").sortable({handle:".handle-sort",items:"tr",axis:"y",update:function(t,e){var a,i,d,r,n,o,l;return o=e.item.closest("tr[data-id]"),d=o.data("id"),n=null,r=null,o.prev().length&&(n=o.prev().data("id")),o.next().length&&(r=o.next().data("id")),l=$(this).data("sortable-url"),i={},a=o.closest(".datagrid").find("tbody").attr("data-sortable-parent-path"),i[(a+"-item_id").replace(/^-/,"")]=d,i[(a+"-prev_id").replace(/^-/,"")]=n,i[(a+"-next_id").replace(/^-/,"")]=r,$.nette.ajax({type:"GET",url:l,data:i,error:function(t,e,a){return alert(t.statusText)}})},helper:function(t,e){return e.children().each(function(){return $(this).width($(this).width())}),e}}):void 0},$(function(){return datagridSortable()}),"undefined"==typeof datagridSortableTree&&(datagridSortableTree=function(){return"undefined"!=typeof $(".datagrid-tree-item-children").sortable?$(".datagrid-tree-item-children").sortable({handle:".handle-sort",items:".datagrid-tree-item:not(.datagrid-tree-item:first-child)",toleranceElement:"> .datagrid-tree-item-content",connectWith:".datagrid-tree-item-children",update:function(t,e){var a,i,d,r,n,o,l,s,c;return $(".toggle-tree-to-delete").remove(),s=e.item.closest(".datagrid-tree-item[data-id]"),d=s.data("id"),l=null,r=null,o=null,s.prev().length&&(l=s.prev().data("id")),s.next().length&&(r=s.next().data("id")),n=s.parent().closest(".datagrid-tree-item"),n.length&&(n.find(".datagrid-tree-item-children").first().css({display:"block"}),n.addClass("has-children"),o=n.data("id")),(c=$(this).data("sortable-url"))?(n.find("[data-toggle-tree]").first().removeClass("hidden"),a=s.closest(".datagrid-tree").attr("data-sortable-parent-path"),i={},i[(a+"-item_id").replace(/^-/,"")]=d,i[(a+"-prev_id").replace(/^-/,"")]=l,i[(a+"-next_id").replace(/^-/,"")]=r,i[(a+"-parent_id").replace(/^-/,"")]=o,$.nette.ajax({type:"GET",url:c,data:i,error:function(t,e,a){return"abort"!==a?alert(t.statusText):void 0}})):void 0},stop:function(t,e){return $(".toggle-tree-to-delete").removeClass("toggle-tree-to-delete")},start:function(t,e){var a;return a=e.item.parent().closest(".datagrid-tree-item"),a.length&&2===a.find(".datagrid-tree-item").length?a.find("[data-toggle-tree]").addClass("toggle-tree-to-delete"):void 0}}):void 0}),$(function(){return datagridSortableTree()}),$.nette.ext("datagrid.happy",{success:function(){var t,e,a,i,d,r,n,o,l,s,c,u,g,f;for(window.happy&&window.happy.reset(),n=$(".datagrid"),f=[],o=0,u=n.length;u>o;o++){for(r=n[o],i=r.classList,a="",c=0,g=i.length;g>c;c++)t=i[c],a=a+"."+t;e=document.querySelectorAll(a+" input[data-check]:checked"),1===e.length&&"toggle-all"===e[0].getAttribute("name")?(s=document.querySelector(a+" input[name=toggle-all]"),s?(s.checked=!1,l=window.navigator.userAgent.indexOf("MSIE "),l?(d=document.createEvent("Event"),d.initEvent("change",!0,!0)):d=new Event("change",{bubbles:!0}),f.push(s.dispatchEvent(d))):f.push(void 0)):f.push(void 0)}return f}}),$.nette.ext("datagrid.sortable",{success:function(){return datagridSortable()}}),$.nette.ext("datagrid.forms",{success:function(){return $(".datagrid").find("form").each(function(){return window.Nette.initForm(this)})}}),$.nette.ext("datagrid.url",{success:function(t){var e,a,i,d;return t._datagrid_url&&window.history.pushState&&(e=window.location.protocol+"//"+window.location.host,a=window.location.pathname,i=window.datagridSerializeUrl(t.state).replace(/&+$/gm,""),d=i?e+a+"?"+i.replace(/\&*$/,""):e+a,d+=window.location.hash,window.location.href!==d)?window.history.pushState({path:d},"",d):void 0}}),$.nette.ext("datagrid.sort",{success:function(t){var e,a,i,d;if(t._datagrid_sort){i=t._datagrid_sort,d=[];for(a in i)e=i[a],d.push($("#datagrid-sort-"+a).attr("href",e));return d}}}),$.nette.ext("datargid.item_detail",{before:function(t,e){var a,i;return e.nette&&e.nette.el.attr("data-toggle-detail")?(a=e.nette.el.attr("data-toggle-detail"),i=$(".item-detail-"+a),i.hasClass("loaded")?i.find(".item-detail-content").size()?(i.hasClass("toggled")?i.find(".item-detail-content").slideToggle("fast",function(t){return function(){return i.toggleClass("toggled")}}(this)):(i.toggleClass("toggled"),i.find(".item-detail-content").slideToggle("fast")),!1):(i.removeClass("toggled"),!0):i.addClass("loaded")):void 0},success:function(t){var e,a;return t._datagrid_toggle_detail?(e=t._datagrid_toggle_detail,a=$(".item-detail-"+e),a.toggleClass("toggled"),a.find(".item-detail-content").slideToggle("fast")):void 0}}),$.nette.ext("datagrid.tree",{before:function(t,e){var a;return e.nette&&e.nette.el.attr("data-toggle-tree")&&(e.nette.el.toggleClass("toggle-rotate"),a=e.nette.el.closest(".datagrid-tree-item").find(".datagrid-tree-item-children").first(),a.hasClass("loaded"))?(a.slideToggle("fast"),!1):!0},success:function(t){var e,a,i,d,r,n,o;if(t._datagrid_tree){i=t._datagrid_tree,e=$('.datagrid-tree-item[data-id="'+i+'"]').find(".datagrid-tree-item-children").first(),e.addClass("loaded"),r=t.snippets;for(d in r)n=r[d],a=$(n),o=$('
'),o.attr("data-id",a.attr("data-id")),o.append(a),a.data("has-children")&&o.addClass("has-children"),e.append(o);e.addClass("loaded"),e.slideToggle("fast"),$.nette.load()}return datagridSortableTree()}}),$(document).on("click","[data-datagrid-editable-url]",function(t){var e,a,i,d,r,n,o,l,s,c,u;if(d=$(this),!d.hasClass("datagrid-inline-edit")&&!d.hasClass("editing")){d.addClass("editing"),u=d.html().trim().replace("
","\n"),d.data("value",u),"textarea"===d.data("datagrid-editable-type")?(l=$(""),o=parseInt(d.css("padding").replace(/[^-\d\.]/g,""),10),r=d.outerHeight(),s=Math.round(parseFloat(d.css("line-height"))),n=(r-2*o)/s,l.attr("rows",Math.round(n))):"select"===d.data("datagrid-editable-type")?(l=$(d.data("datagrid-editable-element")),l.find("option").each(function(){return $(this).text()===u?l.find("option[value="+$(this).val()+"]").prop("selected",!0):void 0})):(l=$(''),l.val(u)),i=d.data("datagrid-editable-attrs");for(e in i)a=i[e],l.attr(e,a);return d.removeClass("edited"),d.html(l),c=function(t,e){return u=e.val(),u!==t.data("value")&&$.nette.ajax({url:t.data("datagrid-editable-url"),data:{value:u},method:"POST",success:function(){return t.html(u),t.addClass("edited")},error:function(){return t.html(t.data("value")),t.addClass("edited-error")}}),setTimeout(function(){return t.removeClass("editing")},1200)},d.find("input,textarea,select").focus().on("blur",function(){return c(d,$(this))}).on("keydown",function(t){return"textarea"!==d.data("datagrid-editable-type")&&13===t.which?(t.stopPropagation(),t.preventDefault(),c(d,$(this))):27===t.which?(t.stopPropagation(),t.preventDefault(),d.removeClass("editing"),d.html(d.data("value"))):void 0}),d.find("select").on("change",function(){return c(d,$(this))})}}),$.nette.ext("datagrid.after_inline_edit",{success:function(t){var e;return e=$(".datagrid-"+t._datagrid_name),t._datagrid_inline_edited?(e.find("tr[data-id="+t._datagrid_inline_edited+"] > td").addClass("edited"),e.find(".datagrid-inline-edit-trigger").removeClass("hidden")):t._datagrid_inline_edit_cancel?e.find(".datagrid-inline-edit-trigger").removeClass("hidden"):void 0}}),$(document).on("click","[data-datagrid-toggle-inline-add]",function(t){var e;return t.stopPropagation(),t.preventDefault(),e=$(this).closest(".datagrid").find(".datagrid-row-inline-add"),e.hasClass("datagrid-row-inline-add-hidden")&&e.removeClass("datagrid-row-inline-add-hidden"),e.find("input:not([readonly]),textarea:not([readonly])").first().focus()}),$(document).on("mousedown","[data-datagrid-cancel-inline-add]",function(t){return t.stopPropagation(),t.preventDefault(),$(".datagrid-row-inline-add").addClass("datagrid-row-inline-add-hidden")}),$.nette.ext("datagrid-toggle-inline-add",{success:function(t){return t._datagrid_inline_added?($(".datagrid-row-inline-add").find("textarea").html(""),$(".datagrid-row-inline-add").find("input[type!=submit]").val(""),$(".datagrid-row-inline-add").addClass("datagrid-row-inline-add-hidden")):void 0}}),datagridFitlerMultiSelect=function(){var t;return t=$(".selectpicker").first(),$.fn.selectpicker?$.fn.selectpicker.defaults={countSelectedText:t.data("i18n-selected"),iconBase:"",tickIcon:t.data("selected-icon-check")}:void 0},$(function(){return datagridFitlerMultiSelect()}),$.nette.ext("datagrid.fitlerMultiSelect",{success:function(){return datagridFitlerMultiSelect(),$.fn.selectpicker?$(".selectpicker").selectpicker():void 0}}),$.nette.ext("datagrid.inline-editing",{success:function(t){return t._datagrid_inline_editing?$(".datagrid-inline-edit-trigger").addClass("hidden"):void 0}}),$.nette.ext("datagrid.redraw-item",{success:function(t){var e;return t._datagrid_redraw_item_class?(e=$("tr[data-id="+t._datagrid_redraw_item_id+"]"),e.attr("class",t._datagrid_redraw_item_class)):void 0}}),$.nette.ext("datagrid.reset-filter-by-column",{success:function(t){var e,a,i,d,r,n;if(t._datagrid_name&&(e=$(".datagrid-"+t._datagrid_name),e.find("[data-datagrid-reset-filter-by-column]").addClass("hidden"),t.non_empty_filters&&t.non_empty_filters.length)){for(n=t.non_empty_filters,i=0,r=n.length;r>i;i++)d=n[i],e.find("[data-datagrid-reset-filter-by-column="+d+"]").removeClass("hidden");return a=e.find(".reset-filter").attr("href"),e.find("[data-datagrid-reset-filter-by-column]").each(function(){var e;return d=$(this).attr("data-datagrid-reset-filter-by-column"),e=a.replace("do=examplesGrid-resetFilter","do="+t._datagrid_name+"-resetColumnFilter"),e+="&"+t._datagrid_name+"-key="+d,$(this).attr("href",e)})}}}); \ No newline at end of file +var datagridFitlerMultiSelect,datagridSortable,datagridSortableTree;$(document).on("click","[data-datagrid-confirm]:not(.ajax)",function(t){return confirm($(t.target).closest("a").attr("data-datagrid-confirm"))?void 0:(t.stopPropagation(),t.preventDefault())}),$.nette.ext("datagrid.confirm",{before:function(t,e){var a;return e.nette&&(a=e.nette.el.data("datagrid-confirm"))?confirm(a):void 0}}),$(document).on("change","select[data-autosubmit-per-page]",function(){return $(this).parent().find("input[type=submit]").click()}).on("change","select[data-autosubmit]",function(){return $(this).closest("form").submit()}).on("change","input[data-autosubmit][data-autosubmit-change]",function(t){var e,a;return a=t.which||t.keyCode||0,clearTimeout(window.datagrid_autosubmit_timer),e=$(this),window.datagrid_autosubmit_timer=setTimeout(function(t){return function(){return e.closest("form").submit()}}(this),200)}).on("keyup","input[data-autosubmit]",function(t){var e,a;return a=t.which||t.keyCode||0,13!==a&&(a>=9&&40>=a||a>=112&&123>=a)?void 0:(clearTimeout(window.datagrid_autosubmit_timer),e=$(this),window.datagrid_autosubmit_timer=setTimeout(function(t){return function(){return e.closest("form").submit()}}(this),200))}).on("keydown",".datagrid-inline-edit input",function(t){var e;return e=t.which||t.keyCode||0,13===e?(t.stopPropagation(),t.preventDefault(),$(this).closest("tr").find('.col-action-inline-edit [name="inline_edit[submit]"]').click()):void 0}),$(document).on("keydown","input[data-datagrid-manualsubmit]",function(t){var e;return e=t.which||t.keyCode||0,13===e?(t.stopPropagation(),t.preventDefault(),$(this).closest("form").submit()):void 0}),document.addEventListener("change",function(t){var e,a,d,i,r,n,o,l,s,c;if(d=t.target.getAttribute("data-check"),d&&(e=document.querySelector(".datagrid-"+d+" input[data-check]:checked"),c=document.querySelector(".datagrid-"+d+' select[name="group_action[group_action]"]'),c&&(e?c.disabled=!1:(c.disabled=!0,c.value="")),r=window.navigator.userAgent.indexOf("MSIE "),r?(a=document.createEvent("Event"),a.initEvent("change",!0,!0)):a=new Event("change",{bubbles:!0}),c&&c.dispatchEvent(a)),d=t.target.getAttribute("data-check-all")){for(o=document.querySelectorAll("input[type=checkbox][data-check-all-"+d+"]"),s=[],i=0,l=o.length;l>i;i++)n=o[i],n.checked=t.target.checked,r=window.navigator.userAgent.indexOf("MSIE "),r?(a=document.createEvent("Event"),a.initEvent("change",!0,!0)):a=new Event("change",{bubbles:!0}),s.push(n.dispatchEvent(a));return s}}),window.datagridSerializeUrl=function(t,e){var a=[];for(var d in t)if(t.hasOwnProperty(d)){var i=e?e+"["+d+"]":d,r=t[d];if(null!==r&&""!==r)if("object"==typeof r){var n=window.datagridSerializeUrl(r,i);n&&a.push(n)}else a.push(encodeURIComponent(i)+"="+encodeURIComponent(r))}return a.join("&")},datagridSortable=function(){return"undefined"!=typeof $.fn.sortable?$(".datagrid [data-sortable]").sortable({handle:".handle-sort",items:"tr",axis:"y",update:function(t,e){var a,d,i,r,n,o,l;return o=e.item.closest("tr[data-id]"),i=o.data("id"),n=null,r=null,o.prev().length&&(n=o.prev().data("id")),o.next().length&&(r=o.next().data("id")),l=$(this).data("sortable-url"),d={},a=o.closest(".datagrid").find("tbody").attr("data-sortable-parent-path"),d[(a+"-item_id").replace(/^-/,"")]=i,d[(a+"-prev_id").replace(/^-/,"")]=n,d[(a+"-next_id").replace(/^-/,"")]=r,$.nette.ajax({type:"GET",url:l,data:d,error:function(t,e,a){return alert(t.statusText)}})},helper:function(t,e){return e.children().each(function(){return $(this).width($(this).width())}),e}}):void 0},$(function(){return datagridSortable()}),"undefined"==typeof datagridSortableTree&&(datagridSortableTree=function(){return"undefined"!=typeof $(".datagrid-tree-item-children").sortable?$(".datagrid-tree-item-children").sortable({handle:".handle-sort",items:".datagrid-tree-item:not(.datagrid-tree-item:first-child)",toleranceElement:"> .datagrid-tree-item-content",connectWith:".datagrid-tree-item-children",update:function(t,e){var a,d,i,r,n,o,l,s,c;return $(".toggle-tree-to-delete").remove(),s=e.item.closest(".datagrid-tree-item[data-id]"),i=s.data("id"),l=null,r=null,o=null,s.prev().length&&(l=s.prev().data("id")),s.next().length&&(r=s.next().data("id")),n=s.parent().closest(".datagrid-tree-item"),n.length&&(n.find(".datagrid-tree-item-children").first().css({display:"block"}),n.addClass("has-children"),o=n.data("id")),(c=$(this).data("sortable-url"))?(n.find("[data-toggle-tree]").first().removeClass("hidden"),a=s.closest(".datagrid-tree").attr("data-sortable-parent-path"),d={},d[(a+"-item_id").replace(/^-/,"")]=i,d[(a+"-prev_id").replace(/^-/,"")]=l,d[(a+"-next_id").replace(/^-/,"")]=r,d[(a+"-parent_id").replace(/^-/,"")]=o,$.nette.ajax({type:"GET",url:c,data:d,error:function(t,e,a){return"abort"!==a?alert(t.statusText):void 0}})):void 0},stop:function(t,e){return $(".toggle-tree-to-delete").removeClass("toggle-tree-to-delete")},start:function(t,e){var a;return a=e.item.parent().closest(".datagrid-tree-item"),a.length&&2===a.find(".datagrid-tree-item").length?a.find("[data-toggle-tree]").addClass("toggle-tree-to-delete"):void 0}}):void 0}),$(function(){return datagridSortableTree()}),$.nette.ext("datagrid.happy",{success:function(){var t,e,a,d,i,r,n,o,l,s,c,u,g,f;for(window.happy&&window.happy.reset(),n=$(".datagrid"),f=[],o=0,u=n.length;u>o;o++){for(r=n[o],d=r.classList,a="",c=0,g=d.length;g>c;c++)t=d[c],a=a+"."+t;e=document.querySelectorAll(a+" input[data-check]:checked"),1===e.length&&"toggle-all"===e[0].getAttribute("name")?(s=document.querySelector(a+" input[name=toggle-all]"),s?(s.checked=!1,l=window.navigator.userAgent.indexOf("MSIE "),l?(i=document.createEvent("Event"),i.initEvent("change",!0,!0)):i=new Event("change",{bubbles:!0}),f.push(s.dispatchEvent(i))):f.push(void 0)):f.push(void 0)}return f}}),$.nette.ext("datagrid.sortable",{success:function(){return datagridSortable()}}),$.nette.ext("datagrid.forms",{success:function(){return $(".datagrid").find("form").each(function(){return window.Nette.initForm(this)})}}),$.nette.ext("datagrid.url",{success:function(t){var e,a,d,i;return t._datagrid_url&&window.history.pushState&&(e=window.location.protocol+"//"+window.location.host,a=window.location.pathname,d=window.datagridSerializeUrl(t.state).replace(/&+$/gm,""),i=d?e+a+"?"+d.replace(/\&*$/,""):e+a,i+=window.location.hash,window.location.href!==i)?window.history.pushState({path:i},"",i):void 0}}),$.nette.ext("datagrid.sort",{success:function(t){var e,a,d,i;if(t._datagrid_sort){d=t._datagrid_sort,i=[];for(a in d)e=d[a],i.push($("#datagrid-sort-"+a).attr("href",e));return i}}}),$.nette.ext("datargid.item_detail",{before:function(t,e){var a,d;return e.nette&&e.nette.el.attr("data-toggle-detail")?(a=e.nette.el.attr("data-toggle-detail"),d=$(".item-detail-"+a),d.hasClass("loaded")?d.find(".item-detail-content").size()?(d.hasClass("toggled")?d.find(".item-detail-content").slideToggle("fast",function(t){return function(){return d.toggleClass("toggled")}}(this)):(d.toggleClass("toggled"),d.find(".item-detail-content").slideToggle("fast")),!1):(d.removeClass("toggled"),!0):d.addClass("loaded")):void 0},success:function(t){var e,a;return t._datagrid_toggle_detail?(e=t._datagrid_toggle_detail,a=$(".item-detail-"+e),a.toggleClass("toggled"),a.find(".item-detail-content").slideToggle("fast")):void 0}}),$.nette.ext("datagrid.tree",{before:function(t,e){var a;return e.nette&&e.nette.el.attr("data-toggle-tree")&&(e.nette.el.toggleClass("toggle-rotate"),a=e.nette.el.closest(".datagrid-tree-item").find(".datagrid-tree-item-children").first(),a.hasClass("loaded"))?(a.slideToggle("fast"),!1):!0},success:function(t){var e,a,d,i,r,n,o;if(t._datagrid_tree){d=t._datagrid_tree,e=$('.datagrid-tree-item[data-id="'+d+'"]').find(".datagrid-tree-item-children").first(),e.addClass("loaded"),r=t.snippets;for(i in r)n=r[i],a=$(n),o=$('
'),o.attr("data-id",a.attr("data-id")),o.append(a),a.data("has-children")&&o.addClass("has-children"),e.append(o);e.addClass("loaded"),e.slideToggle("fast"),$.nette.load()}return datagridSortableTree()}}),$(document).on("click","[data-datagrid-editable-url]",function(t){var e,a,d,i,r,n,o,l,s,c,u;if(i=$(this),!i.hasClass("datagrid-inline-edit")&&!i.hasClass("editing")){i.addClass("editing"),u=i.html().trim().replace("
","\n"),i.data("value",u),"textarea"===i.data("datagrid-editable-type")?(l=$(""),o=parseInt(i.css("padding").replace(/[^-\d\.]/g,""),10),r=i.outerHeight(),s=Math.round(parseFloat(i.css("line-height"))),n=(r-2*o)/s,l.attr("rows",Math.round(n))):"select"===i.data("datagrid-editable-type")?(l=$(i.data("datagrid-editable-element")),l.find("option").each(function(){return $(this).text()===u?l.find("option[value="+$(this).val()+"]").prop("selected",!0):void 0})):(l=$(''),l.val(u)),d=i.data("datagrid-editable-attrs");for(e in d)a=d[e],l.attr(e,a);return i.removeClass("edited"),i.html(l),c=function(t,e){return u=e.val(),u!==t.data("value")&&$.nette.ajax({url:t.data("datagrid-editable-url"),data:{value:u},method:"POST",success:function(){return t.html(u),t.addClass("edited")},error:function(){return t.html(t.data("value")),t.addClass("edited-error")}}),setTimeout(function(){return t.removeClass("editing")},1200)},i.find("input,textarea,select").focus().on("blur",function(){return c(i,$(this))}).on("keydown",function(t){return"textarea"!==i.data("datagrid-editable-type")&&13===t.which?(t.stopPropagation(),t.preventDefault(),c(i,$(this))):27===t.which?(t.stopPropagation(),t.preventDefault(),i.removeClass("editing"),i.html(i.data("value"))):void 0}),i.find("select").on("change",function(){return c(i,$(this))})}}),$.nette.ext("datagrid.after_inline_edit",{success:function(t){var e;return e=$(".datagrid-"+t._datagrid_name),t._datagrid_inline_edited?(e.find("tr[data-id="+t._datagrid_inline_edited+"] > td").addClass("edited"),e.find(".datagrid-inline-edit-trigger").removeClass("hidden")):t._datagrid_inline_edit_cancel?e.find(".datagrid-inline-edit-trigger").removeClass("hidden"):void 0}}),$(document).on("click","[data-datagrid-toggle-inline-add]",function(t){var e;return t.stopPropagation(),t.preventDefault(),e=$(this).closest(".datagrid").find(".datagrid-row-inline-add"),e.hasClass("datagrid-row-inline-add-hidden")&&e.removeClass("datagrid-row-inline-add-hidden"),e.find("input:not([readonly]),textarea:not([readonly])").first().focus()}),$(document).on("mousedown","[data-datagrid-cancel-inline-add]",function(t){return t.stopPropagation(),t.preventDefault(),$(".datagrid-row-inline-add").addClass("datagrid-row-inline-add-hidden")}),$.nette.ext("datagrid-toggle-inline-add",{success:function(t){return t._datagrid_inline_added?($(".datagrid-row-inline-add").find("textarea").html(""),$(".datagrid-row-inline-add").find("input[type!=submit]").val(""),$(".datagrid-row-inline-add").addClass("datagrid-row-inline-add-hidden")):void 0}}),datagridFitlerMultiSelect=function(){var t;return t=$(".selectpicker").first(),$.fn.selectpicker?$.fn.selectpicker.defaults={countSelectedText:t.data("i18n-selected"),iconBase:"",tickIcon:t.data("selected-icon-check")}:void 0},$(function(){return datagridFitlerMultiSelect()}),$.nette.ext("datagrid.fitlerMultiSelect",{success:function(){return datagridFitlerMultiSelect(),$.fn.selectpicker?$(".selectpicker").selectpicker():void 0}}),$.nette.ext("datagrid.inline-editing",{success:function(t){return t._datagrid_inline_editing?$(".datagrid-inline-edit-trigger").addClass("hidden"):void 0}}),$.nette.ext("datagrid.redraw-item",{success:function(t){var e;return t._datagrid_redraw_item_class?(e=$("tr[data-id="+t._datagrid_redraw_item_id+"]"),e.attr("class",t._datagrid_redraw_item_class)):void 0}}),$.nette.ext("datagrid.reset-filter-by-column",{success:function(t){var e,a,d,i,r,n;if(t._datagrid_name&&(e=$(".datagrid-"+t._datagrid_name),e.find("[data-datagrid-reset-filter-by-column]").addClass("hidden"),t.non_empty_filters&&t.non_empty_filters.length)){for(n=t.non_empty_filters,d=0,r=n.length;r>d;d++)i=n[d],e.find("[data-datagrid-reset-filter-by-column="+i+"]").removeClass("hidden");return a=e.find(".reset-filter").attr("href"),e.find("[data-datagrid-reset-filter-by-column]").each(function(){var e;return i=$(this).attr("data-datagrid-reset-filter-by-column"),e=a.replace("do="+t._datagrid_name+"-resetFilter","do="+t._datagrid_name+"-resetColumnFilter"),e+="&"+t._datagrid_name+"-key="+i,$(this).attr("href",e)})}}}); \ No newline at end of file diff --git a/assets/src/datagrid.coffee b/assets/src/datagrid.coffee index 6993cac8..8c0d239b 100644 --- a/assets/src/datagrid.coffee +++ b/assets/src/datagrid.coffee @@ -587,7 +587,8 @@ $.nette.ext('datagrid.reset-filter-by-column', { grid.find('[data-datagrid-reset-filter-by-column]').each -> key = $(this).attr('data-datagrid-reset-filter-by-column') - new_href = href.replace('do=examplesGrid-resetFilter', 'do=' + payload._datagrid_name + '-resetColumnFilter') + new_href = href.replace('do=' + payload._datagrid_name + '-resetFilter', 'do=' + payload._datagrid_name + '-resetColumnFilter') new_href += '&' + payload._datagrid_name + '-key=' + key + $(this).attr('href', new_href) })