1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

Fix: In IE9 where the table is in an iframe paging elements were not added until after the first draw

* See thread 23915 for details and kudos to helenm for the research into the issue
This commit is contained in:
Allan Jardine 2015-02-04 16:11:59 +00:00
parent 8f3ad35944
commit 4039e77a6f
3 changed files with 11 additions and 9 deletions

View File

@ -1 +1 @@
72b39fd7af8300fe09cbaf2a5f8e41956b15ff16
d96de43a9cd4c3a752929d238833004cd8210d9e

View File

@ -14194,20 +14194,22 @@
// IE9 throws an 'unknown error' if document.activeElement is used
// inside an iframe or frame. Try / catch the error. Not good for
// accessibility, but neither are frames.
var activeEl;
try {
// Because this approach is destroying and recreating the paging
// elements, focus is lost on the select button which is bad for
// accessibility. So we want to restore focus once the draw has
// completed
var activeEl = $(document.activeElement).data('dt-idx');
attach( $(host).empty(), buttons );
if ( activeEl !== null ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
}
activeEl = $(document.activeElement).data('dt-idx');
}
catch (e) {}
attach( $(host).empty(), buttons );
if ( activeEl ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
}
}
}
} );

View File

@ -146,7 +146,7 @@ g.extend(p.ext.oJUIClasses,p.ext.classes,{sPageButton:"fg-button ui-button "+F,s
sSortJUI:ja+"carat-2-n-s",sSortJUIAscAllowed:ja+"carat-1-n",sSortJUIDescAllowed:ja+"carat-1-s",sSortJUIWrapper:"DataTables_sort_wrapper",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead "+F,sScrollFoot:"dataTables_scrollFoot "+F,sHeaderTH:F,sFooterTH:F,sJUIHeader:Xb+" ui-corner-tl ui-corner-tr",sJUIFooter:Xb+" ui-corner-bl ui-corner-br"});var Mb=p.ext.pager;g.extend(Mb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},simple_numbers:function(a,
b){return["previous",Wa(a,b),"next"]},full_numbers:function(a,b){return["first","previous",Wa(a,b),"next","last"]},_numbers:Wa,numbers_length:7});g.extend(!0,p.ext.renderer,{pageButton:{_:function(a,b,c,e,d,f){var h=a.oClasses,i=a.oLanguage.oPaginate,j,l,k=0,n=function(b,e){var m,o,p,r,s=function(b){Ta(a,b.data.action,true)};m=0;for(o=e.length;m<o;m++){r=e[m];if(g.isArray(r)){p=g("<"+(r.DT_el||"div")+"/>").appendTo(b);n(p,r)}else{l=j="";switch(r){case "ellipsis":b.append("<span>&hellip;</span>");
break;case "first":j=i.sFirst;l=r+(d>0?"":" "+h.sPageButtonDisabled);break;case "previous":j=i.sPrevious;l=r+(d>0?"":" "+h.sPageButtonDisabled);break;case "next":j=i.sNext;l=r+(d<f-1?"":" "+h.sPageButtonDisabled);break;case "last":j=i.sLast;l=r+(d<f-1?"":" "+h.sPageButtonDisabled);break;default:j=r+1;l=d===r?h.sPageButtonActive:""}if(j){p=g("<a>",{"class":h.sPageButton+" "+l,"aria-controls":a.sTableId,"data-dt-idx":k,tabindex:a.iTabIndex,id:c===0&&typeof r==="string"?a.sTableId+"_"+r:null}).html(j).appendTo(b);
Va(p,{action:r},s);k++}}}};try{var o=g(Q.activeElement).data("dt-idx");n(g(b).empty(),e);o!==null&&g(b).find("[data-dt-idx="+o+"]").focus()}catch(m){}}}});g.extend(p.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&(!ac.test(a)||!bc.test(a)))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||I(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;
Va(p,{action:r},s);k++}}}},o;try{o=g(Q.activeElement).data("dt-idx")}catch(m){}n(g(b).empty(),e);o&&g(b).find("[data-dt-idx="+o+"]").focus()}}});g.extend(p.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&(!ac.test(a)||!bc.test(a)))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||I(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;
return Rb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Rb(a,c,!0)?"html-num-fmt"+c:null},function(a){return I(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);g.extend(p.ext.type.search,{html:function(a){return I(a)?a:"string"===typeof a?a.replace(Ob," ").replace(Ba,""):""},string:function(a){return I(a)?a:"string"===typeof a?a.replace(Ob," "):a}});var Aa=function(a,b,c,e){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Qb(a,b));a.replace&&(c&&(a=a.replace(c,"")),
e&&(a=a.replace(e,"")));return 1*a};g.extend(x.type.order,{"date-pre":function(a){return Date.parse(a)||0},"html-pre":function(a){return I(a)?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return I(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return a<b?-1:a>b?1:0},"string-desc":function(a,b){return a<b?1:a>b?-1:0}});db("");g.extend(!0,p.ext.renderer,{header:{_:function(a,b,c,e){g(a.nTable).on("order.dt.DT",function(d,
f,g,i){if(a===f){d=c.idx;b.removeClass(c.sSortingClass+" "+e.sSortAsc+" "+e.sSortDesc).addClass(i[d]=="asc"?e.sSortAsc:i[d]=="desc"?e.sSortDesc:c.sSortingClass)}})},jqueryui:function(a,b,c,e){g("<div/>").addClass(e.sSortJUIWrapper).append(b.contents()).append(g("<span/>").addClass(e.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);g(a.nTable).on("order.dt.DT",function(d,f,g,i){if(a===f){d=c.idx;b.removeClass(e.sSortAsc+" "+e.sSortDesc).addClass(i[d]=="asc"?e.sSortAsc:i[d]=="desc"?e.sSortDesc:c.sSortingClass);