annotate Blast output page example trimmed_files/jquery_006.js @ 20:53cd304c5f26

Add index for multiple results; fix layout of query ruler for edge case The query ruler did not layout nicely if the last segment was too short to contain the text. For very short last segments the text is now displayed after the ruler.
author Jan Kanis <jan.code@jankanis.nl>
date Wed, 14 May 2014 16:20:29 +0200
parents ffe82516a83c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
1 jQuery.widget("ui.ncbigrid",{options:{isScrollable:false,height:"10em",hortScrollbarEnabled:false,width:null,isPageable:false,currentPage:1,isPageToolbarHideable:true,pageSize:10,isSortable:false,columnTypes:[],sortFunctions:[],isPresorted:false,sortColumn:-1,sortColumnDir:1,sortRowIndex:0,titleAscending:"sort ascending",titleDescending:"sort descending",ariaLabelAscending:"activate to sort column ascending",ariaLabelDescending:"activate to sort column descending",regExp:false,checkboxToolbarEnabled:false,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
2 filterToolbarEnabled:false,filterToolbarIsCaseInsensitive:null,filterToolbarColumnIndex:null,filterToolbarIsInverse:null,isLoadingMessageShown:true,loadingText:"Loading",collapseRowsEnabled:false,addCommas:false},_init:function(){},_create:function(){this._isStartPageOne=this.options.currentPage===1;this._wrapTable();this._addBasicStyles();this._checkIfCSSIsScrollable();this._attachLoadingMessageListener();if(this.options.isScrollable||this.options.isSortable||this.options.isPageable||this.options.checkboxToolbarEnabled||
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
3 this.options.filterToolbarEnabled)this._addAriaRolesAndStates();this._addRowClickWatcher();this.options.isScrollable&&this._createScrollable();if(this.options.isPageable||this.options.isPagable){this.options.isPageable=true;this._createPageGrid()}if(this.options.isSortable){this._createSortGrid();this.updateAriaTH()}else this._enableCollapseTbodyRows();this.options.checkboxToolbarEnabled&&this._createCheckboxSelectors();this.options.filterToolbarEnabled&&this._createFilterBarControl();this._addRowHoverEvent();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
4 this._addContentsAdjustmentEvent();this._adjustContents()},destroy:function(){jQuery.Widget.prototype.destroy.apply(this,arguments);this.options.isScrollable&&this._destroyScrollable();if(this.options.isPageable||this.options.isPagable)this._destroyPageGrid();this._destroyRowHoverEvent()},_addBasicStyles:function(){this.element.addClass("ui-ncbigrid").attr("cellpadding","0").attr("cellspacing","0")},_checkIfCSSIsScrollable:function(){if(this.element.hasClass("jig-ncbigrid-scroll"))this.options.isScrollable=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
5 true},_wrapTable:function(){var a=this.element.parent().parent();if(!a.hasClass("ui-ncbigrid-outer-div")){this.element.wrap('<div class="ui-ncbigrid-outer-div"><div class="ui-ncbigrid-inner-div"></div></div>');a=this.element.parent().parent()}this.element.find("caption").length>0&&a.addClass("caption-exists");var b=this.options.width;b&&a.css("width",b)},_addRowHoverEvent:function(){jQuery(this.element).on("mouseenter","tbody > tr",function(){var a=jQuery(this);a.hasClass("ignoreHoverHighlight")||
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
6 a.addClass("ui-ncbigrid-row-hover")}).on("mouseleave","tbody > tr",function(){jQuery(this).removeClass("ui-ncbigrid-row-hover")})},_destroyRowHoverEvent:function(){jQuery(this.element).off("mouseenter mouseleave","tr")},_addContentsAdjustmentEvent:function(){var a=this;this.element.on("ncbigridupdated",function(){a._adjustContents()})},_getNumCommaIndices:function(){var a=this.options.columnTypes;if(!a)return[];for(var b=[],c=0;c<a.length;c++)if(a[c]=="numComma"||a[c]=="numberComma")b.push(c);return b},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
7 _getCommaSeparatedValue:function(a){var b=parseInt(a);if(isNaN(b))return a;else{a=a.split(".");b=a[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,");return a[1]?b+"."+a[1]:b}},_adjustContentsForCommas:function(){var a=this._getNumCommaIndices();if(a.length){var b=this;jQuery(this.element).find("tbody td").each(function(){var c=jQuery(this),d=c.parent().find("td").index(c);jQuery.inArray(d,a)!=-1&&c.html(b._getCommaSeparatedValue(c.html()))})}},_adjustContents:function(){this.options.addCommas&&this._adjustContentsForCommas()},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
8 _addAriaRolesAndStates:function(){var a=this.element;a.attr("id")||a.attr("id",jQuery.ui.jig._generateId(this.widgetName));a.parent().parent().attr("role","grid").attr("tabindex","0");a.children("thead").children("tr").attr("role","row").children("th").attr({"aria-controls":a.attr("id"),role:"columnheader",tabindex:"0"});a.children("tbody").attr({role:"alert","aria-live":"polite","aria-relevant":"text"})},updateAriaTH:function(){if(this.options.isSortable){var a=this;this.element.parent().parent().find("div, table").attr("tabindex",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
9 "0").end().find("thead").find("th").each(function(b,c){b="";var d=a.options.ariaLabelAscending;if(jQuery(c).is(".sortDsc")){b="descending";d=a.options.ariaLabelAscending}else if(jQuery(c).is(".sortAsc")){b="ascending";d=a.options.ariaLabelDescending}c=jQuery(c).children("a");jQuery(c).attr("aria-label",jQuery(c).text()+": "+d);b==""?jQuery(c).removeAttr("aria-sort"):jQuery(c).attr("aria-sort",b)})}},_createScrollable:function(){this._storeRefs();this._addScrollClasses();this._copyCaptionHeader();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
10 this._setWidthHeight();this._setWidths();this._registerScrollableListeners()},_destroyScrollable:function(){this._removeScrollClasses();if(this.parts){this.parts.scrollWrapper.removeClass("ui-ncbigrid-scroll");this.parts.headerWrapper.remove();for(var a in this.parts)this.parts[a]=null;this.parts=null}this._windowResize&&jQuery(window).unbind("resize",this._windowResize)},_storeRefs:function(){var a=this.element;this.parts={table:a,ths:a.find("> thead th")}},_addScrollClasses:function(){var a=this.element,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
11 b=a.parent().addClass("ui-ncbigrid-scroll");this.parts.scrollWrapper=b;if(jQuery.browser.webkit){var c=navigator.userAgent;c.indexOf("AppleWebKit")>0&&c.indexOf("Chrome")==-1&&a.addClass("safari")}this.options.hortScrollbarEnabled&&b.addClass("ui-ncbigrid-hort-scroll")},_removeScrollClasses:function(){this.element.removeClass("ui-ncbigrid").removeClass("safari").parent().removeClass("ui-ncbigrid-scroll")},_copyCaptionHeader:function(){var a=this.element,b=a.parent();b.parent();var c=a.find("caption").clone();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
12 a=a.find("> thead").clone();c=jQuery("<div class='ui-ncbigrid-header-wrapper'></div>").append("<table cellpadding='0' cellspacing='0' class='ui-ncbigrid ui-ncbigrid-header'></table>").find("table").append(c).append(a).end();c.insertBefore(b);b=c.find("caption");b.wrapInner("<div></div>");this.parts.captionDiv=b.find("div");this.parts.headerWrapper=c;this.parts.headerThs=c.find("thead th")},_setWidthHeight:function(){this.options.height!==null&&this.parts.scrollWrapper.height(this.options.height)},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
13 _setWidths:function(){function a(j){jQuery(this).width(h[j])}var b=this.parts,c=b.table,d=b.ths,e=b.scrollWrapper,g=b.headerWrapper;b=b.headerThs;var f=jQuery.browser.msie;if(!this.options.hortScrollbarEnabled&&c.data("isMinSet")!==true&&this.element.is(":visible")){var i=c.outerWidth();if(c.width()>e.width()){e.css("min-width",i+16);c.data("isMinSet",true)}}var h=[];d.each(function(){var j=0;if(jQuery(this).is(":visible"))j=jQuery(this).width()+0;h.push(j)});d=c.height()>e.height()?16:0;f=this.options.isSortable&&
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
14 f&&parseInt(jQuery.browser.version,10)<8?d:0;c.parent().parent().find("table.ui-ncbigrid-header").width(c.width()+2-f);c=e.width()-d;g.width(c);this.parts.captionDiv&&this.parts.captionDiv.width(c);b.each(a)},_handleScroll:function(a,b,c){function d(){g._handleScroll(a,b,true)}var e=a.scrollLeft;b.scrollLeft=e;this.parts.captionDiv&&this.parts.captionDiv.css("margin-left",e+"px");var g=this;if(!c){window.setTimeout(d,1);window.setTimeout(d,5)}},_registerScrollableListeners:function(){var a=this;this._windowResize=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
15 function(){a._setWidths()};jQuery(window).resize(this._windowResize);var b=this.element.parent().parent().find(".ui-ncbigrid-header-wrapper")[0];this.element.parent().scroll(function(){a._handleScroll(this,b)});this.element.bind("ncbigridupdated",function(){a._setWidths()});this.element.bind("resetScroll",function(){a._resetScrollToTop()})},_resetScrollToTop:function(){this.parts.scrollWrapper.scrollTop(0)},_createPageGrid:function(){this._createPageBars();this._addPagingEvents();this._gotoPage(this.options.currentPage)},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
16 _destroyPageGrid:function(){if(this._pageBars){this._removePagingEvents();this._removePageBars()}},_pagingControlsHTML:' <div class="ui-ncbigrid-paged-toolbar"> <div class="ui-ncbigrid-paged-countItems">Items <span class="ui-ncbigrid-paged-startRow">1</span> - <span class="ui-ncbigrid-paged-endRow">10</span> of <span class="ui-ncbigrid-paged-totalRows">10</span></div> <div class="ui-ncbigrid-paged-pageControl pagination"> <a href="#" class="ui-ncbigrid-paged-pageControl-first page_link" title="Goto First Page">&lt;&lt; First</a> <span class="ui-ncbigrid-paged-pageControl-first page_link" title="Inactive Goto First Page">&lt;&lt; First</span> <a href="#" class="ui-ncbigrid-paged-pageControl-previous page_link prev" title="Goto Previous Page">&lt; Prev</a> <span class="ui-ncbigrid-paged-pageControl-previous page_link prev" title="Inactive Goto Previous Page">&lt; Prev</span> <label>Page</label> <input type="text" value="1" size="2" title="current page number"/> of <span class="ui-ncbigrid-paged-endPage">2</span> <a href="#" class="ui-ncbigrid-paged-pageControl-next next page_link" title="Goto Next Page">Next &gt;</a> <span class="ui-ncbigrid-paged-pageControl-next next page_link" title="Inactive Goto Next Page">Next &gt;</span> <a href="#" class="ui-ncbigrid-paged-pageControl-last page_link" title="Goto Last Page">Last &gt;&gt;</a> <span class="ui-ncbigrid-paged-pageControl-last page_link" title="Inactive Goto Last Page">Last &gt;&gt;</span> </div> </div>',
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
17 _createPageBars:function(){this._pageToolBar_top=jQuery(this._pagingControlsHTML).addClass("ui-ncbigrid-paged-toolbar-top");this._pageToolBar_bottom=jQuery(this._pagingControlsHTML).addClass("ui-ncbigrid-paged-toolbar-bottom");var a=this.element,b=a.parent().parent();b.prepend(this._pageToolBar_top);b.append(this._pageToolBar_bottom);b.children(".ui-ncbigrid-paged-toolbar-top").children(".ui-ncbigrid-paged-countItems").attr("id",jQuery.ui.jig._generateId("ui-ncbigrid-paged-countItems"));a.attr("aria-describedby",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
18 this._pageToolBar_top.children(".ui-ncbigrid-paged-countItems").attr("id"));this._pageBars=this._pageToolBar_top.add(this._pageToolBar_bottom);this._pageBars.find(":input").each(function(c,d){jQuery(d).attr("id",jQuery.ui.jig._generateId("ui-ncbigrid-paged-current-page")).prev().attr("for",jQuery(d).attr("id"))})},_removePageBars:function(){this._pageToolBar_top.remove();this._pageToolBar_top=null;this._pageToolBar_bottom.remove();this._pageBars=this._pageToolBar_bottom=null;this.element.removeAttr("aria-describedby")},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
19 _addPagingEvents:function(){var a=this,b=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-first"),c=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-previous"),d=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-next"),e=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-last"),g=this._pageBars.find("input");b.click(function(f){a.gotoFirstPage();f.preventDefault()});c.click(function(f){a.gotoPrevPage();f.preventDefault()});d.click(function(f){a.gotoNextPage();f.preventDefault()});e.click(function(f){a.gotoLastPage();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
20 f.preventDefault()});g.keypress(function(f){if(f.keyCode===13){a.gotoPage(this.value.replace(/,/g,""));f.preventDefault()}})},_removePagingEvents:function(){this._pageBars.find("a").unbind("click").end().find("input").unbind("keypress")},_showHidePageToolbar:function(){if(this._pageBars)if(this.options.isPageToolbarHideable)parseInt(this.getRowCount())<=parseInt(this.options.pageSize)?this._pageBars.hide():this._pageBars.show()},_setPage:function(){this.element.trigger("resetScroll");this.element.trigger("pagechanged");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
21 var a=this._getCurrentPage(),b=this.getMaxPage();this._showHidePageToolbar();this._updateRows(a,b);this._updateButtons(a,b);this._updatePagingText(a,b);this._updateGoto(a,b);this._updateItemRange(a,b);this._pageBars.find(".ui-ncbigrid-paged-pageControl").attr({"aria-valuemin":"1","aria-controls":this.element.attr("id"),"aria-valuemax":b,"aria-valuenow":a});this._notifyGridUpdated()},_updateRows:function(a){var b=this.options.pageSize,c=this.getRowCount();a=(a-1)*b;var d=a+b;b=this.element.find("> tbody > tr:not(.ncbigrid-row-filtered)");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
22 var e=this.element.find("> tbody").length>1,g=0;if(e&&a>0)g=b.filter(":lt("+a+")").filter(":has(th)").length;var f="";if(d<c)f+=":lt("+(d+g)+")";if(a>0)f+=":gt("+(a-1+g)+")";c=b;if(f.length>0){b.not(".ui-ncbigrid-rowHidden").addClass("ui-ncbigrid-rowHidden");c=b.filter(f)}c.removeClass("ui-ncbigrid-rowHidden");if(e){a=c.filter(":has(th)").length;if(a>0){b=0;for(c=c.last().next();b<a&&c.length===1;){if(!c.hasClass("ncbigrid-row-filtered")){c.has("th")||b++;c.removeClass("ui-ncbigrid-rowHidden")}c=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
23 c.next()}}}this._notifyGridUpdated()},_updateButtons:function(a,b){var c=b===2,d=a===1,e=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-previous,a.ui-ncbigrid-paged-pageControl-first").css("display",d?"none":"inline").filter("a.ui-ncbigrid-paged-pageControl-first");d=this._pageBars.find("span.ui-ncbigrid-paged-pageControl-previous,span.ui-ncbigrid-paged-pageControl-first").css("display",d?"inline":"none").filter("span.ui-ncbigrid-paged-pageControl-first");b=a===b||b==0;a=this._pageBars.find("a.ui-ncbigrid-paged-pageControl-next,a.ui-ncbigrid-paged-pageControl-last").css("display",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
24 b?"none":"inline").filter("a.ui-ncbigrid-paged-pageControl-last");b=this._pageBars.find("span.ui-ncbigrid-paged-pageControl-next,span.ui-ncbigrid-paged-pageControl-last").css("display",b?"inline":"none").filter("span.ui-ncbigrid-paged-pageControl-last");c&&e.add(d).add(a).add(b).css("display","none")},_updatePagingText:function(a,b){if(b<1)b=1;if(this.options.addCommas)b=this._getCommaSeparatedValue(""+b);this._pageBars.find("div.ui-ncbigrid-paged-pageControl").find("span.ui-ncbigrid-paged-endPage").html(b)},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
25 _updateGoto:function(a){if(this.options.addCommas)a=this._getCommaSeparatedValue(""+a);this._pageBars.find("input").val(a)},_updateItemRange:function(a){var b=parseInt(this.options.pageSize,10),c=this.getRowCount();a=(a-1)*b+1;b=a+b-1;if(b>c)b=c;if(c==0)a=0;if(this.options.addCommas){c=this._getCommaSeparatedValue(""+c);a=this._getCommaSeparatedValue(""+a);b=this._getCommaSeparatedValue(""+b)}var d=this._pageBars.find("div.ui-ncbigrid-paged-countItems");d.find("span.ui-ncbigrid-paged-startRow").html(a);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
26 d.find("span.ui-ncbigrid-paged-endRow").html(b);d.find("span.ui-ncbigrid-paged-totalRows").html(c)},_getCurrentPage:function(){return this.options.currentPage},getCurrentPage:function(){return this._getCurrentPage()},getMaxPage:function(){return Math.ceil(this.getRowCount()/this.options.pageSize)},getRowCount:function(){return jQuery(this.element).find("> tbody > tr:not(.ncbigrid-row-filtered):not(:has(> th))").length},getHeaderRowCount:function(){return jQuery(this.element).find("tbody > tr:has(th)").length},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
27 gotoFirstPage:function(){this._gotoPage(1)},gotoLastPage:function(){this._gotoPage(this.getMaxPage())},gotoNextPage:function(){this._gotoPage(this._getCurrentPage()+1)},gotoPrevPage:function(){this._gotoPage(this._getCurrentPage()-1)},gotoPage:function(a){this._gotoPage(parseInt(a,10))},_gotoPage:function(a){if(isNaN(a)||a<1)a=1;else if(a>this.getMaxPage()){a=this.getMaxPage();if(a<1)a=1}this.options.currentPage=a;this._pagingSelectAllQuestions&&this._pagingSelectAllQuestions.hide();this._setPage()},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
28 _createSortGrid:function(){var a=this.options.sortColumn;if(this.options.sortColumn!==-1){a=a-1;this.options.sortColumn=a!==-1?a:0}this._indexGrid();this._addSortEvents();this._setSortHeaders();this._checkInitialState();this._notifyGridUpdated()},_destroySortGrid:function(){},reindex:function(){for(var a=0;a<this.element.find("tbody tr:eq(0) td").length;a++)this.element.data("sort_order_col_"+a,null);this.element.data("rows",null);this._indexGrid()},_indexGrid:function(){var a=this,b=this.element.find("> tbody");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
29 if(b.length===0)this._isIndexed=false;else for(var c=0;c<b.length;c++)(function(d,e){function g(){for(var o=0;o<50&&k<m;o++){var p=l[k],q=a.getRowValues_DOM(p);if(q.length==0){a._enableCollapseTbodyRows(p);i.push(p);j++}else{q.unshift(k-j,p);f.push(q);h.push(q)}k++}if(k<m)window.setTimeout(g,0);else{a.element.data("tbody"+e+"-rows",h);a.element.data("tbody"+e+"-header",i);a._presort(f,e)}}var f=[],i=[],h=[],j=0,l=jQuery(d).find("> tr"),k=0,m=l.length;if(m===0)a._isIndexed=false;else{a._isIndexed=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
30 true;g()}})(b[c],c)},_presort:function(a,b){function c(h){var j=g.options.sortFunctions[h-2];j||(j=g.element.find("> thead th:eq("+(h-2)+")").data("sortfunc"));if(j)if(typeof j==="function")return j;else if(j.indexOf("fnc:")===0){j=j.substr(4,j.length).split(".");for(var l=window[j[0]],k=1;k<j.length;k++)l=l[j[k]];return g.options.sortFunctions[h]=l}return null}function d(h,j,l){function k(n){if(n.length<2)return n;var r=parseInt(n.length/2),s=n.slice(0,r);n=n.slice(r,n.length);return m(k(s),k(n))}
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
31 function m(n,r){for(var s=[];n.length&&r.length;){var u=false;(u=o?-g.options.sortColumnDir==o.call(g,{data:n[0][j],row:jQuery(n[0][1])},{data:r[0][j],row:jQuery(r[0][1])}):n[0][j]<=r[0][j])?s.push(n.shift()):s.push(r.shift())}for(;n.length;)s.push(n.shift());for(;r.length;)s.push(r.shift());return s}var o=c(j),p=jQuery.browser.msie?100:1E3,q=0,t=[];(function(){for(var n=0;n<p&&q<h.length;n++){t.push(h[q]);q++}q<h.length?setTimeout(arguments.callee,0):l(k(t),j)})()}function e(h,j){var l=0,k=[];(function(){for(var m=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
32 0;m<50&&l<h.length;m++){k.push(h[l][0]);l++}l<h.length?setTimeout(arguments.callee,0):g.element.data("tbody"+b+"-sort_order_col_"+(j-2),k)})()}for(var g=this,f=a[0].length,i=2;i<f;i++)this._getColumnType(i-2)!=="none"&&d(a,i,e)},_getColumnType:function(a){var b=this.options.columnTypes[a];b||(b=this.element.find("> thead th:eq("+a+")").data("columntype"));return b||"str"},getColumnType:function(a){return this._getColumnType(a-1)},getRowValues:function(a){if(typeof a==="number")a=this.element.find("tbody tr:eq("+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
33 a+")");var b=[];a=a[0].getElementsByTagName("td");for(var c=a.length,d=0;d<c;d++)b.push(this._getCellValueHelper(a[d].innerHTML,d));return b},getRowValues_DOM:function(a){var b=[];a=jQuery(a).children("td");for(var c=a.length,d=0;d<c;d++)b.push(this._getCellValueHelper(a[d].textContent||a[d].innerText||"",d));return b},_getCellValue:function(a,b){return this._getCellValueHelper(a.html(),b)},_getCellValueHelper:function(a,b){var c=this._getColumnType(b);switch(c){case "num":case "number":case "float":return a!==
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
34 undefined&&a.length>0?parseFloat(a):Number.POSITIVE_INFINITY;case "int":return a!==undefined&&a.length>0?parseInt(a,10):Number.POSITIVE_INFINITY;case "numberComma":case "numComma":a=(a||"").replace(/[, ]/g,"");return a.length>0?parseFloat(a):Number.POSITIVE_INFINITY;case "date":return new Date(a);case "str-insensitive":return a.toLowerCase();case "str":default:if(typeof c==="function")return c(a);else if(c.indexOf("fnc:")===0){c=c.substr(4,c.length).split(".");for(var d=window[c[0]],e=1;e<c.length;e++)d=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
35 d[c[e]];this.options.columnTypes[b]=d;return d(a)}else return a||""}},getCellValue:function(a,b){if(typeof a==="number")a=this.element.find("tbody tr:eq("+a+")");return this._getCellValue(a.find("td:eq("+b+")"),b)},_addSortEvents:function(){function a(e){b._getColumnType(e)!=="none"&&jQuery(this).wrapInner(d).find("a").data("index",e)}var b=this,c=this.element.find("> thead tr:eq("+this.options.sortRowIndex+") th");this.element.bind("ncbigridcontentchanged",function(){b.reindex()});var d="<a href='#' title='"+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
36 this.options.titleAscending+"'></a>";c.each(a);c=c;if(this.parts&&this.parts.headerThs){this.parts.headerThs.each(a);c=c.add(this.parts.headerThs)}c.find("a").click(function(e){b._sort(jQuery(this).data("index"));e.preventDefault()})},sort:function(a,b){this._sort(a-1,b)},_sort:function(a,b){if(this._isIndexed){this.options.isPageable&&this.element.trigger("resetCheckboxes");var c=b;if(b===undefined)c=this.options.sortColumn!==a?1:-1*this.options.sortColumnDir;this.options.sortColumn=a;this.options.sortColumnDir=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
37 c;this.element.trigger("ncbigridshowloadingbar");this._setSortHeaders();this._waitForCache()}},_setSortHeaders:function(){var a=this.element.find("> thead tr:eq("+this.options.sortRowIndex+") th"),b=null;if(this.parts&&this.parts.headerThs)b=this.parts.headerThs;a.add(b).removeClass("sortAsc sortDsc").addClass("sortNone").find("a").attr("title",this.options.titleAscending);var c=this.options.sortColumn;if(this.options.sortColumn!==-1){var d=this.options.sortColumnDir===1?"sortAsc":"sortDsc",e=this.options.sortColumnDir===
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
38 1?this.options.titleDescending:this.options.titleAscending;a.eq(c).addClass(d).removeClass("sortNone").find("a").attr("title",e);b&&b.eq(c).addClass(d).removeClass("sortNone").find("a").attr("title",e)}this.options.isSortable&&this.updateAriaTH()},_waitForCache:function(){for(var a=this,b=this.options.sortColumn,c=this.element.find("tbody"),d=0;d<c.length;d++)(function(e){var g=a.element.data("tbody"+e+"-sort_order_col_"+b);if(g)a._setTheRows(g,e);else{var f=arguments.callee;setTimeout(function(){f(e)},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
39 10)}})(d)},_setTheRows:function(a,b){var c=this.element.data("tbody"+b+"-header"),d=this.element.data("tbody"+b+"-rows");b=this.element.find("tbody:eq("+b+")");var e=jQuery("<tbody>"),g=c.length;if(g>0)for(var f=0;f<g;f++)e.append(c[f]);if(this.options.sortColumnDir==1)for(f=0;f<a.length;f++){c=d[a[f]][1];e.append(c)}else for(f=a.length-1;f>=0;f--){c=d[a[f]][1];e.append(c)}b.replaceWith(e);this.element.trigger("ncbigridhideloadingbar");if(this.options.isPageable)if(this._isStartPageOne)this.gotoFirstPage();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
40 else{this._gotoPage(this.options.currentPage);this._isStartPageOne=true}this.element.trigger("ncbigridcolumnsorted",[this.options.sortColumn+1,this.options.sortColumnDir])},_checkInitialState:function(){!this.options.isPresorted&&this.options.sortColumn!==-1&&this._sort(this.options.sortColumn,this.options.sortColumnDir)},_checkboxControlsHTML:' <div class="ui-ncbigrid-checkbox-toolbar"> \t\t\t\t\t\t<label>Select:</label>\t\t\t\t\t\t<a href="#" class="ui-ncbigrid-select-all">All</a>\t\t\t\t\t\t<a href="#" class="ui-ncbigrid-select-none">None</a>\t\t\t\t\t\t<label>Selected:</label>\t\t\t\t\t\t<span class="ui-ncbigrid-selected-text">0</span> </div>',
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
41 _pagingSelectAllQuestionHTML:'<div class="ui-ncbigrid-select-question">All <span class="ui-ncbigrid-select-row-count">10</span> items on this page are <span class="selectText1">selected</span>. <a href="#" class="ui-ncbigrid-select-question-all"><span class="selectText2">Select</span> all rows in table</a> <a href="#" class="ui-ncbigrid-select-question-cancel">Cancel</a></div>',_createCheckboxSelectors:function(){this._createCheckboxBar();this._addCheckboxEvents();this._updateCount()},_createCheckboxBar:function(){this._checkboxToolBar_top=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
42 jQuery(this._checkboxControlsHTML).addClass("ui-ncbigrid-checkbox-toolbar-top");this._checkboxToolBar_bottom=jQuery(this._checkboxControlsHTML).addClass("ui-ncbigrid-checkbox-toolbar-bottom");var a=this.element.parent().parent();a.prepend(this._checkboxToolBar_top);if(this.options.isPageable){this._checkboxToolBar_bottom.insertBefore(this._pageToolBar_bottom);this._addSelectAllQuestionToolbar()}else a.append(this._checkboxToolBar_bottom);a.find(".ui-ncbigrid-checkbox-toolbar").attr("aria-controls",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
43 this.element.attr("id"));this._chekboxBars=this._checkboxToolBar_top.add(this._checkboxToolBar_bottom)},_addCheckboxEvents:function(){var a=this;this._chekboxBars.find("a.ui-ncbigrid-select-all").click(function(b){a.checkAll();a._askSelectAllQuestion();b.preventDefault()});this._chekboxBars.find("a.ui-ncbigrid-select-none").click(function(b){a.uncheckAll();a._askSelectAllQuestion(true);b.preventDefault()});jQuery(this.element).on("click","tbody",function(b){a._rowClicked(b)});this.element.bind("resetCheckboxes",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
44 function(){a.uncheckAll()});this._addSelectAllQuestionToolbarEvents()},_addSelectAllQuestionToolbar:function(){if(this.options.checkboxToolbarEnabled){this._pagingSelectAllQuestion_top=jQuery(this._pagingSelectAllQuestionHTML).addClass("ui-ncbigrid-select-question-header");this._pagingSelectAllQuestion_bottom=jQuery(this._pagingSelectAllQuestionHTML).addClass("ui-ncbigrid-select-question-footer");this._pagingSelectAllQuestion_top.insertAfter(this._pageToolBar_top);this._pagingSelectAllQuestion_bottom.insertAfter(this._pageToolBar_bottom);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
45 this._pagingSelectAllQuestions=this._pagingSelectAllQuestion_top.add(this._pagingSelectAllQuestion_bottom);this._pagingSelectAllQuestions.find(".ui-ncbigrid-select-question-all").attr("aria-controls",this.element.attr("id"))}},_addSelectAllQuestionToolbarEvents:function(){if(this.options.checkboxToolbarEnabled){var a=this;this._pagingSelectAllQuestions.find("a.ui-ncbigrid-select-question-all").click(function(b){a[a._askAllSelectionMode](true);a._pagingSelectAllQuestions.hide();b.preventDefault()});
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
46 this._pagingSelectAllQuestions.find("a.ui-ncbigrid-select-question-cancel").click(function(b){a._pagingSelectAllQuestions.hide();b.preventDefault()});this.element.bind("ncbigridpagechanged checkboxrowclicked",function(){a._pagingSelectAllQuestions&&a._pagingSelectAllQuestions.hide()})}},_askSelectAllQuestion:function(a){this._askAllSelectionMode=a?"uncheckAll":"checkAll";if(this.options.isPageable)if(parseInt(this.getRowCount())>=parseInt(this.options.pageSize)){this._pagingSelectAllQuestions.show();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
47 this._updateSelectPageCount(a)}else this._pagingSelectAllQuestions.hide()},_updateSelectPageCount:function(a){var b=this.element.find("> tbody > tr > td > input[type=checkbox]:visible").length;this._pagingSelectAllQuestions.find(".ui-ncbigrid-select-row-count").html(b);this._pagingSelectAllQuestions.find(".selectText1").html(a?"deselected":"selected");this._pagingSelectAllQuestions.find(".selectText2").html(a?"Deselect":"Select")},_updateCount:function(){var a=this.element.find("tbody input[type=checkbox]");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
48 a=a.length>0?a.filter(":checked").length:this.element.find("tbody tr.ui-ncbigrid-row-selected").length;this._chekboxBars.find("span.ui-ncbigrid-selected-text").html(a)},_checkHelper:function(a,b){if(b){b=jQuery(this.element).find("> tbody > tr:not(.ncbigrid-row-filtered) > td > input[type=checkbox]");this._trigger(a?"checkall":"uncheckall",null,[a]);this._checkAllState=a}else b=a&&this.options.isPageable?this.element.find("> tbody > tr > td > input[type=checkbox]:visible"):this.element.find("> tbody > tr > td > input[type=checkbox]");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
49 b.attr("checked",a);b=b.length===0?this.element.find("tbody tr").data("row-selected",a):b.closest("tr");a?b.addClass("ui-ncbigrid-row-selected"):b.removeClass("ui-ncbigrid-row-selected");this._updateCount()},checkAll:function(a){this._checkHelper(true,a);this._trigger("selectallclicked",null,[{acrossAllPages:a}])},uncheckAll:function(a){this._checkHelper(false,a);this._trigger("selectnoneclicked",null,[{acrossAllPages:a}])},_rowClicked:function(a){var b=jQuery(a.target||a.srcElement);a=null;if(b.is("input[type=checkbox]")){a=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
50 b;var c=a.is(":checked")}else if(!b.is("a")){a=b.closest("tr").find("input[type=checkbox]");c=!a.is(":checked");a.attr("checked",c)}b=b.closest("tr");if(a&&a.length===0){c=!b.data("row-selected");b.data("row-selected",c)}c?b.addClass("ui-ncbigrid-row-selected"):b.removeClass("ui-ncbigrid-row-selected");this.element.trigger("checkboxrowclicked");this._updateCount()},_filterBarControlsHTML:' <div class="ui-ncbigrid-filter-toolbar"> \t\t\t\t\t\t\t<label>Filter:</label>\t\t\t\t\t\t\t<input type="text" name="gridFilter" /> </div>',
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
51 _createFilterBarControl:function(){this._createFilterBar();this._addFilterEvents()},_createFilterBar:function(){this._filterToolBar=jQuery(this._filterBarControlsHTML);var a=this.element.parent().parent();a.prepend(this._filterToolBar).children(".ui-ncbigrid-filter-toolbar").attr("aria-controls",this.element.attr("id"));a.addClass("filterToolbar-exists");var b=jQuery.ui.jig._generateId("gridFilter");a.children(".ui-ncbigrid-filter-toolbar").children(":input").attr("id",b).prev().attr("for",b)},_addFilterEvents:function(){var a=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
52 this;this._filterToolBar.find("input[type=text]").keyup(function(b){a._filterGrid(b,this)})},_filterGrid:function(a,b){if(!this._lastRunFilter)this._lastRunFilter="";a=b.value;b=this.options.filterToolbarIsCaseInsensitive||null;var c=this.options.filterToolbarColumnIndex||null,d=this.options.filterToolbarIsInverse||null;this._lastRunFilter.length>0&&a.indexOf(this._lastRunFilter)!==0&&this.removeFilterRows();this._lastRunFilter=a;if(this._lastRunFilter.length>0){var e=false;if(this.options.regExp)try{a=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
53 RegExp(a.replace(/(^\/)|(\/$)/g,""))}catch(g){e=true}e||this.filterRows(a,b,c,d)}},_custFilterCnt:0,filterRows:function(a,b,c,d){function e(){p.options.isPageable&&p._gotoPage(0);p.element.trigger("ncbigridfilterapplied",[a,b,c,g,f]).trigger("ncbigridhideloadingbar");p._notifyGridUpdated()}if(!(typeof a=="undefined"||a.length===0)){this.element.trigger("ncbigridshowloadingbar");if(!jQuery.isArray(a)){orgTxt=a;a=[[a,b,c,d]]}d=f=jQuery("tbody tr:not(.ncbigrid-row-filtered)",this.element);for(var g,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
54 f,i=0;i<a.length;i++){var h=a[i],j=h[0],l=h[2],k=h[3];h="";if(typeof l!="undefined"&&l!==null)h=":nth-child("+l+")";k=k?"not-":"";var m="",o=null;if(typeof j==="function"){m="-functionTest";o=this._custFilterCnt;this._custFilterCnt=o+1;o="filter_temp_"+o;jQuery.ui.jig[o]=j;j="jQuery.ui.jig."+o}else if(j.constructor&&j.constructor.toString().indexOf("RegExp")>0)m="-regexp";else if(b)m="-insensitive";f=l!==null?f.find("td"+h+":"+k+"contains"+m+"("+j+")").parent():f.filter(":"+k+"contains"+m+"("+j+")");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
55 if(o)jQuery.ui.jig[o]=null}var p=this;if(d){g=d.not(f);var q=g.length,t=0;(function(){for(;t<q;){g.eq(t).addClass("ncbigrid-row-filtered").attr("isfiltered","true");t++}e()})()}else e()}},removeFilterRows:function(a,b,c,d,e){function g(){if(l){jQuery.ui.jig[l]=null;a=j}m.options.isPageable&&m._gotoPage(0);m.element.trigger("ncbigridfilterremoved",[a,b,c]);m.options.isPageable?m._gotoPage(m.options.currentPage):m._notifyGridUpdated()}var f=null;if(typeof a!="undefined"&&a.length>0){if(typeof d==="undefined")d=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
56 true;var i="",h="";if(d||e){i=":not(";h=")"}var j=d="",l=null;if(typeof a==="function"){d="-functionTest";var k=this._custFilterCnt;this._custFilterCnt=k+1;l="filter_temp_"+k;j=jQuery.ui.jig[l]=a;a="jQuery.ui.jig."+l}else if(a.constructor&&a.constructor.toString().indexOf("RegExp")>0)d="-regexp";else if(b)d="-insensitive";e=e?"not-":"";if(typeof c!="undefined"&&c!==null){i="tbody tr[isfiltered='true'] td:nth-child("+c+")"+i+":"+e+"contains"+d+"("+a+")"+h;f=this.element.find(i).parent()}else{i="tbody tr[isfiltered='true']"+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
57 i+":contains"+d+"("+a+")"+h;f=this.element.find(i)}}else f=this.element.find("tr.ncbigrid-row-filtered");var m=this;if(f!==null){var o=f.length,p=0;(function(){for(;p<o;){f.eq(p).removeClass("ncbigrid-row-filtered").attr("isfiltered","false");p++}g()})()}else g()},showColumn:function(a){var b=this.element;if(this.options.isScrollable)b=b.add(this.parts.headerWrapper.find("table"));b.children().find(">tr>*:nth-child("+a+")").removeClass("ui-ncbigrid-column-hidden");this._setColumnHiddenData(a,false);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
58 this.element.trigger("showColumn",[a]);this._notifyGridUpdated()},hideColumn:function(a){var b=this.element;if(this.options.isScrollable)b=b.add(this.parts.headerWrapper.find(">table"));b.children().find(">tr>*:nth-child("+a+")").addClass("ui-ncbigrid-column-hidden");this._setColumnHiddenData(a,true);this.element.trigger("hideColumn",[a]);this._notifyGridUpdated()},_setColumnHiddenData:function(a,b){var c=this.element.data("dataHiddenCols");c||(c=[]);c[a]=b;this.element.data("dataHiddenCols",c)},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
59 getHiddenShownColumns:function(){var a=[],b=[],c=this.element.data("dataHiddenCols");if(c)for(var d in c)c[d]?a.push(d):b.push(d);return{hidden:a,shown:b}},_attachLoadingMessageListener:function(){var a=this;this.element.bind("ncbigridshowloadingbar",function(){a._showLoadingMessage()}).bind("ncbigridhideloadingbar",function(){a._hideLoadingMessage()})},_showLoadingMessage:function(){if(this.options.isLoadingMessageShown){if(!this.isPopperAttached){this.element.parent().parent().ncbipopper({triggerPosition:"top center",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
60 destPosition:"top center",hasArrow:false,closeEvent:"custom",openEvent:"custom",openAnimation:"none",closeAnimation:"none",destText:this.options.loadingText,isDestElementCloseClick:false,isDocumentElementCloseClick:false,isEscapeKeyClose:false,isTriggerElementCloseClick:false});this.isPopperAttached=true}this.element.parent().parent().ncbipopper("open")}},_hideLoadingMessage:function(){this.options.isLoadingMessageShown&&this.element.parent().parent().ncbipopper("close")},_addRowClickWatcher:function(){var a=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
61 this;jQuery(this.element).on("click","tbody",function(b){b=jQuery(b.srcElement||b.target).closest("td");if(b.length===1){var c=b.closest("tr");a.element.trigger("ncbigridrowclick",[{row:c,cell:b,rowIndex:c[0].rowIndex,cellIndex:b[0].cellIndex}])}})},_notifyGridUpdated:function(){this.element.trigger("ncbigridupdated")},_notifyGridContentChanged:function(){this.element.trigger("ncbigridcontentchanged")},addHTMLRowData:function(a,b,c,d){var e=this.getRowCount(),g="";if(typeof b=="undefined")g=":last-child";
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
62 else{if(b>e)b=e;else if(b<0){b=1;c="before"}g=":nth-child("+b+")"}b=d!==undefined?":eq("+d+")":"";if(e===0)jQuery("tbody"+b+g,this.element).append(a);else c&&c.toLowerCase()==="before"?jQuery("tbody"+b+" tr"+g,this.element).before(a):jQuery("tbody"+b+" tr"+g,this.element).after(a);this.options.isPageable?this._gotoPage(this.options.currentPage):this._notifyGridUpdated();this._notifyGridContentChanged()},_deleteRowHelper:function(a,b){b=b!==undefined?":eq("+b+")":"";a?this.element.find("tbody"+b+" tr"+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
63 a).remove():this.element.find("tbody"+b).empty()},deleteAllRows:function(){this._deleteRowHelper();this.options.isPageable&&this._gotoPage(0);this._notifyGridUpdated();this._notifyGridContentChanged()},deleteRow:function(a,b){if(typeof a!="undefined"){a=jQuery.isArray(a)?a.sort():[a];for(var c=a.length-1;c>=0;c--)this._deleteRowHelper(":nth-child("+a[c]+")",b);this.options.isPageable&&this._gotoPage(this.options.currentPage);this._notifyGridUpdated();this._notifyGridContentChanged()}},getCellData:function(a,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
64 b,c){if(!(typeof a=="undefined"||typeof b=="undefined")){a=jQuery("tbody"+(c!==undefined?":eq("+c+")":"")+" tr:nth-child("+a+") td:nth-child("+b+")",this.element);if(a.length==0)return null;return this._getCellValue(a,b)}},getColumnCount:function(a){a=a===false?":visible":"";a=jQuery(this.element).find("tbody tr:not(.ui-ncbigrid-rowHidden):eq(0) td"+a).length;if(a===0)a=jQuery(this.element).find("> thead tr:last th").length;return a},getColumnData:function(a,b){if(typeof a==="undefined")return null;
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
65 else if(jQuery.isArray(a)){for(var c=[],d=0;d<a.length;d++){if(a[d]<=0||a[d]>this.getColumnCount())c.push(null);c.push(this._getColumnDataHelper(a[d]),b)}return c}else{if(a<=0||a>this.getColumnCount())return null;return this._getColumnDataHelper(a,b)}},_getColumnDataHelper:function(a,b){var c=[],d=this,e=this._getColumnType(a-1);if(e==="str"||!e)e="str-sensitive";jQuery("tbody"+(b!==undefined?":eq("+b+")":"")+" tr td:nth-child("+a+")",this.element).each(function(g,f){c.push(d._csColumnTypeConversion(f,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
66 e,true))});if(c.length!==0)return c},getRowData:function(a,b){if(typeof a!=="undefined")if(jQuery.isArray(a)){for(var c=[],d=0;d<a.length;d++)c.push(this._getRowDataHelper(a[d]),b);return c}else return this._getRowDataHelper(a,b)},_getRowDataHelper:function(a,b){var c=[],d=this;jQuery("tbody"+(b!==undefined?":eq("+b+")":"")+" tr:nth-child("+a+") td",this.element).each(function(e){c.push(d._getCellValue(jQuery(this),e))});if(c.length!==0)return c},highlightRows:function(a,b,c,d){var e=jQuery.browser.msie&&
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
67 parseFloat(jQuery.browser.version)<7;if(!(typeof a=="undefined"||a.length===0)){this.element.trigger("ncbigridshowloadingbar");var g=[],f=b?"-insensitive":"";d=d?"not-":"";if(a.constructor&&a.constructor.toString().indexOf("RegExp")>0){f="-regexp";d=""}typeof c!="undefined"?jQuery("tbody tr td"+(":nth-child("+c+")")+":"+d+"contains"+f+"("+a+")",this.element).each(function(i,h){i=jQuery(h).parent();h="ui-ncbigrid-high";if(e)h=i.hasClass("ui-ncbigrid-row-even")?"ui-ncbigrid-row-even-high-IE6":"ui-ncbigrid-row-odd-high-IE6";
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
68 i.addClass(h);jQuery.inArray(i,g)===-1&&g.push(i)}):jQuery("tbody tr:"+d+"contains"+f+"("+a+")",this.element).each(function(i,h){i=jQuery(h);h="ui-ncbigrid-high";if(e)h=i.hasClass("ui-ncbigrid-row-even")?"ui-ncbigrid-row-even-high-IE6":"ui-ncbigrid-row-odd-high-IE6";i.addClass(h);g.push(i)});this.element.trigger("ncbigridhighlightapplied",[a,b,c,g]).trigger("ncbigridhideloadingbar");return{highlightedRows:g}}},removeHighlightRows:function(a,b,c,d){var e=jQuery.browser.msie&&parseFloat(jQuery.browser.version)<
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
69 7;if(typeof a!="undefined"&&a.length>0){var g=[],f=b?"-insensitive":"";d=d?"not-":"";if(a.constructor&&a.constructor.toString().indexOf("RegExp")>0){f="-regexp";d=""}typeof c!="undefined"?jQuery("tbody tr td"+(":nth-child("+c+")")+":"+d+"contains"+f+"("+a+")",this.element).each(function(i,h){i=jQuery(h).parent().removeClass("ui-ncbigrid-high");e&&i.removeClass("ui-ncbigrid-row-odd-high-IE6").removeClass("ui-ncbigrid-row-even-high-IE6");jQuery.inArray(i,g)===-1&&g.push(i)}):jQuery("tbody tr:"+d+"contains"+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
70 f+"("+a+")",this.element).each(function(i,h){i=jQuery(h).removeClass("ui-ncbigrid-high");e&&i.removeClass("ui-ncbigrid-row-odd-high-IE6").removeClass("ui-ncbigrid-row-even-high-IE6");g.push(i)})}else{jQuery(".ui-ncbigrid-high",this.element).removeClass("ui-ncbigrid-high");e&&jQuery(".ui-ncbigrid-row-odd-high-IE6, .ui-ncbigrid-row-even-high-IE6",this.element).removeClass("ui-ncbigrid-row-odd-high-IE6").removeClass("ui-ncbigrid-row-even-high-IE6")}this.element.trigger("ncbigridhighlightremoved",[a,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
71 b,c])},setCellData:function(a,b,c,d){jQuery("tbody"+(d!==undefined?":eq("+d+")":"")+" tr:nth-child("+a+") td:nth-child("+b+")",this.element).text(c);this.element.trigger("ncbigridcellchange",[a,b,this.getCellData(a,b)]);this._notifyGridUpdated();this._notifyGridContentChanged()},setRowData:function(a,b,c){jQuery("tbody"+(c!==undefined?":eq("+c+")":"")+" tr:nth-child("+a+") td",this.element).each(function(d,e){jQuery(e).text(b[d])});this.element.trigger("ncbigridrowchange",[a,this.getRowData(a,c)]);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
72 this._notifyGridUpdated();this._notifyGridContentChanged()},_enableCollapseTbodyRows:function(a){if(this.options.collapseRowsEnabled){a||(a=jQuery(this.element).find("tbody tr:has(th)"));var b=this;jQuery(a).each(function(){jQuery(this).addClass("ui-ncbigrid-collapsable").find("th").eq(0).prepend('<span class="collapsableTbodyIcon ui-icon ui-icon-plus-minus-big-open"></span>').find("span").click(function(c){c.stopPropagation();b._collapseTbodyRows(this.parentNode.parentNode)}).end().end().not(".ignoreCollapse").click(function(){b._collapseTbodyRows(this.parentNode)})})}},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
73 _collapseTbodyRows:function(a){jQuery(a).find("th span.collapsableTbodyIcon").toggleClass("ui-icon-plus-minus-big").toggleClass("ui-icon-plus-minus-big-open").end().siblings().toggleClass("collapsed")}});jQuery.extend(jQuery.expr[":"],{"contains-insensitive":function(a,b,c){return(a.textContent||a.innerText||"").toLowerCase().indexOf((c[3]||"").toLowerCase())>=0}});
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
74 jQuery.extend(jQuery.expr[":"],{"contains-regexp":function(a,b,c){a=jQuery.trim(a.textContent||a.innerText||"");c=c[3];b=c.match(/\/([gi]+)$/);b=b!==null?b[1]:"";c=c.replace(/\/[gi]?$/,"").replace(/^\//,"");return a.match(new RegExp(c,b))!==null}});jQuery.extend(jQuery.expr[":"],{"contains-functionTest":function(a,b,c){a=a.textContent||a.innerText||"";return jQuery.ui.jig._getFncFromStr(c[3])(a)}});
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
75 jQuery.extend(jQuery.expr[":"],{"not-contains":function(a,b,c){return(a.textContent||a.innerText||"").indexOf(c[3]||"")===-1}});jQuery.extend(jQuery.expr[":"],{"not-contains-insensitive":function(a,b,c){return(a.textContent||a.innerText||"").toLowerCase().indexOf((c[3]||"").toLowerCase())===-1}});