Merge branch 'master' of github.com:DataTables/Plugins

pull/284/head
Allan Jardine 9 years ago
commit 0d24e17467

@ -1,5 +1,5 @@
/*!*************************************************** /*!***************************************************
* datatables.mark.js v1.0.0 * datatables.mark.js v2.0.0
* https://github.com/julmot/datatables.mark.js * https://github.com/julmot/datatables.mark.js
* Copyright (c) 2016, Julian Motz * Copyright (c) 2016, Julian Motz
* Released under the MIT license https://git.io/voRZ7 * Released under the MIT license https://git.io/voRZ7
@ -9,11 +9,11 @@
((factory, window, document) => { ((factory, window, document) => {
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
define(["jquery", "datatables", "markjs"], jQuery => { define(["jquery", "datatables.net", "markjs"], jQuery => {
return factory(window, document, jQuery); return factory(window, document, jQuery);
}); });
} else if (typeof exports === "object") { } else if (typeof exports === "object") {
require("datatables"); require("datatables.net");
require("markjs"); require("markjs");
factory(window, document, require("jquery")); factory(window, document, require("jquery"));
} else { } else {
@ -27,20 +27,36 @@
} }
this.instance = dtInstance; this.instance = dtInstance;
this.options = typeof options === "object" ? options : {}; this.options = typeof options === "object" ? options : {};
this.intervalThreshold = 49;
this.intervalMs = 300;
this.initMarkListener(); this.initMarkListener();
} }
initMarkListener() { initMarkListener() {
this.instance.on("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth", this.mark.bind(this)); const ev = "draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth";
let intvl = null;
this.instance.on(ev, () => {
const rows = this.instance.rows({
filter: "applied",
page: "current"
}).nodes().length;
if (rows > this.intervalThreshold) {
clearTimeout(intvl);
intvl = setTimeout(() => {
this.mark();
}, this.intervalMs);
} else {
this.mark();
}
});
this.instance.on("destroy", () => { this.instance.on("destroy", () => {
this.instance.off("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth"); this.instance.off(ev);
}); });
this.mark(); this.mark();
} }
mark() { mark() {
const globalSearch = this.instance.search(); const globalSearch = this.instance.search();
$(this.instance.table().body()).unmark(this.options); $(this.instance.table().body()).unmark(this.options);
this.instance.columns({ this.instance.columns({
search: "applied", search: "applied",

@ -1,7 +1,7 @@
/*!*************************************************** /*!***************************************************
* datatables.mark.js v1.0.0 * datatables.mark.js v2.0.0
* https://github.com/julmot/datatables.mark.js * https://github.com/julmot/datatables.mark.js
* Copyright (c) 2016, Julian Motz * Copyright (c) 2016, Julian Motz
* Released under the MIT license https://git.io/voRZ7 * Released under the MIT license https://git.io/voRZ7
*****************************************************/ *****************************************************/
"use strict";((factory,window,document) => {if(typeof define==="function"&&define.amd){define(["jquery","datatables","markjs"],jQuery => {return factory(window,document,jQuery);});}else if(typeof exports==="object"){require("datatables");require("markjs");factory(window,document,require("jquery"));}else {factory(window,document,jQuery);}})((window,document,$) => {class Mark_DataTables{constructor(dtInstance,options){if(typeof $.fn.mark!=="function"||typeof $.fn.unmark!=="function"){throw new Error("jquery.mark.js is necessary for datatables.mark.js");}this.instance=dtInstance;this.options=typeof options==="object"?options:{};this.initMarkListener();}initMarkListener(){this.instance.on("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth",this.mark.bind(this));this.instance.on("destroy",() => {this.instance.off("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth");});this.mark();}mark(){const globalSearch=this.instance.search();$(this.instance.table().body()).unmark(this.options);this.instance.columns({search:"applied",page:"current"}).nodes().each((nodes,colIndex) => {const columnSearch=this.instance.column(colIndex).search(),searchVal=columnSearch||globalSearch;if(searchVal){nodes.forEach(node => {$(node).mark(searchVal,this.options);});}});}}$(document).on("init.dt.dth",(event,settings) => {if(event.namespace!=="dt"){return;}const dtInstance=$.fn.dataTable.Api(settings);let options=null;if(dtInstance.init().mark){options=dtInstance.init().mark;}else if($.fn.dataTable.defaults.mark){options=$.fn.dataTable.defaults.mark;}if(options===null){return;}new Mark_DataTables(dtInstance,options);});},window,document); "use strict";((factory,window,document)=>{if(typeof define==="function"&&define.amd){define(["jquery","datatables.net","markjs"],jQuery=>{return factory(window,document,jQuery);});}else if(typeof exports==="object"){require("datatables.net");require("markjs");factory(window,document,require("jquery"));}else{factory(window,document,jQuery);}})((window,document,$)=>{class Mark_DataTables{constructor(dtInstance,options){if(typeof $.fn.mark!=="function"||typeof $.fn.unmark!=="function"){throw new Error("jquery.mark.js is necessary for datatables.mark.js");}this.instance=dtInstance;this.options=typeof options==="object"?options:{};this.intervalThreshold=49;this.intervalMs=300;this.initMarkListener();}initMarkListener(){const ev="draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth";let intvl=null;this.instance.on(ev,()=>{const rows=this.instance.rows({filter:"applied",page:"current"}).nodes().length;if(rows>this.intervalThreshold){clearTimeout(intvl);intvl=setTimeout(()=>{this.mark();},this.intervalMs);}else{this.mark();}});this.instance.on("destroy",()=>{this.instance.off(ev);});this.mark();}mark(){const globalSearch=this.instance.search();$(this.instance.table().body()).unmark(this.options);this.instance.columns({search:"applied",page:"current"}).nodes().each((nodes,colIndex)=>{const columnSearch=this.instance.column(colIndex).search(),searchVal=columnSearch||globalSearch;if(searchVal){nodes.forEach(node=>{$(node).mark(searchVal,this.options);});}});}}$(document).on("init.dt.dth",(event,settings)=>{if(event.namespace!=="dt"){return;}const dtInstance=$.fn.dataTable.Api(settings);let options=null;if(dtInstance.init().mark){options=dtInstance.init().mark;}else if($.fn.dataTable.defaults.mark){options=$.fn.dataTable.defaults.mark;}if(options===null){return;}new Mark_DataTables(dtInstance,options);});},window,document);

@ -1,5 +1,5 @@
/*!*************************************************** /*!***************************************************
* datatables.mark.js v1.0.0 * datatables.mark.js v2.0.0
* https://github.com/julmot/datatables.mark.js * https://github.com/julmot/datatables.mark.js
* Copyright (c) 2016, Julian Motz * Copyright (c) 2016, Julian Motz
* Released under the MIT license https://git.io/voRZ7 * Released under the MIT license https://git.io/voRZ7
@ -15,11 +15,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
(function (factory, window, document) { (function (factory, window, document) {
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
define(["jquery", "datatables", "markjs"], function (jQuery) { define(["jquery", "datatables.net", "markjs"], function (jQuery) {
return factory(window, document, jQuery); return factory(window, document, jQuery);
}); });
} else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object") { } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object") {
require("datatables"); require("datatables.net");
require("markjs"); require("markjs");
factory(window, document, require("jquery")); factory(window, document, require("jquery"));
} else { } else {
@ -35,6 +35,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
} }
this.instance = dtInstance; this.instance = dtInstance;
this.options = (typeof options === "undefined" ? "undefined" : _typeof(options)) === "object" ? options : {}; this.options = (typeof options === "undefined" ? "undefined" : _typeof(options)) === "object" ? options : {};
this.intervalThreshold = 49;
this.intervalMs = 300;
this.initMarkListener(); this.initMarkListener();
} }
@ -43,9 +45,24 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function initMarkListener() { value: function initMarkListener() {
var _this = this; var _this = this;
this.instance.on("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth", this.mark.bind(this)); var ev = "draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth";
var intvl = null;
this.instance.on(ev, function () {
var rows = _this.instance.rows({
filter: "applied",
page: "current"
}).nodes().length;
if (rows > _this.intervalThreshold) {
clearTimeout(intvl);
intvl = setTimeout(function () {
_this.mark();
}, _this.intervalMs);
} else {
_this.mark();
}
});
this.instance.on("destroy", function () { this.instance.on("destroy", function () {
_this.instance.off("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth"); _this.instance.off(ev);
}); });
this.mark(); this.mark();
} }
@ -55,7 +72,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var _this2 = this; var _this2 = this;
var globalSearch = this.instance.search(); var globalSearch = this.instance.search();
$(this.instance.table().body()).unmark(this.options); $(this.instance.table().body()).unmark(this.options);
this.instance.columns({ this.instance.columns({
search: "applied", search: "applied",

@ -1,7 +1,7 @@
/*!*************************************************** /*!***************************************************
* datatables.mark.js v1.0.0 * datatables.mark.js v2.0.0
* https://github.com/julmot/datatables.mark.js * https://github.com/julmot/datatables.mark.js
* Copyright (c) 2016, Julian Motz * Copyright (c) 2016, Julian Motz
* Released under the MIT license https://git.io/voRZ7 * Released under the MIT license https://git.io/voRZ7
*****************************************************/ *****************************************************/
"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol?"symbol":typeof a};!function(a,b,c){"function"==typeof define&&define.amd?define(["jquery","datatables","markjs"],function(d){return a(b,c,d)}):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?(require("datatables"),require("markjs"),a(b,c,require("jquery"))):a(b,c,jQuery)}(function(a,b,c){var d=function(){function a(b,d){if(_classCallCheck(this,a),"function"!=typeof c.fn.mark||"function"!=typeof c.fn.unmark)throw new Error("jquery.mark.js is necessary for datatables.mark.js");this.instance=b,this.options="object"===("undefined"==typeof d?"undefined":_typeof(d))?d:{},this.initMarkListener()}return _createClass(a,[{key:"initMarkListener",value:function(){var a=this;this.instance.on("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth",this.mark.bind(this)),this.instance.on("destroy",function(){a.instance.off("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth")}),this.mark()}},{key:"mark",value:function(){var a=this,b=this.instance.search();c(this.instance.table().body()).unmark(this.options),this.instance.columns({search:"applied",page:"current"}).nodes().each(function(d,e){var f=a.instance.column(e).search(),g=f||b;g&&d.forEach(function(b){c(b).mark(g,a.options)})})}}]),a}();c(b).on("init.dt.dth",function(a,b){if("dt"===a.namespace){var e=c.fn.dataTable.Api(b),f=null;e.init().mark?f=e.init().mark:c.fn.dataTable.defaults.mark&&(f=c.fn.dataTable.defaults.mark),null!==f&&new d(e,f)}})},window,document); "use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol?"symbol":typeof a};!function(a,b,c){"function"==typeof define&&define.amd?define(["jquery","datatables.net","markjs"],function(d){return a(b,c,d)}):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?(require("datatables.net"),require("markjs"),a(b,c,require("jquery"))):a(b,c,jQuery)}(function(a,b,c){var d=function(){function a(b,d){if(_classCallCheck(this,a),"function"!=typeof c.fn.mark||"function"!=typeof c.fn.unmark)throw new Error("jquery.mark.js is necessary for datatables.mark.js");this.instance=b,this.options="object"===("undefined"==typeof d?"undefined":_typeof(d))?d:{},this.intervalThreshold=49,this.intervalMs=300,this.initMarkListener()}return _createClass(a,[{key:"initMarkListener",value:function(){var a=this,b="draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth",c=null;this.instance.on(b,function(){var b=a.instance.rows({filter:"applied",page:"current"}).nodes().length;b>a.intervalThreshold?(clearTimeout(c),c=setTimeout(function(){a.mark()},a.intervalMs)):a.mark()}),this.instance.on("destroy",function(){a.instance.off(b)}),this.mark()}},{key:"mark",value:function(){var a=this,b=this.instance.search();c(this.instance.table().body()).unmark(this.options),this.instance.columns({search:"applied",page:"current"}).nodes().each(function(d,e){var f=a.instance.column(e).search(),g=f||b;g&&d.forEach(function(b){c(b).mark(g,a.options)})})}}]),a}();c(b).on("init.dt.dth",function(a,b){if("dt"===a.namespace){var e=c.fn.dataTable.Api(b),f=null;e.init().mark?f=e.init().mark:c.fn.dataTable.defaults.mark&&(f=c.fn.dataTable.defaults.mark),null!==f&&new d(e,f)}})},window,document);

@ -157,7 +157,7 @@
iNewStart = 0; iNewStart = 0;
} }
if (iNewStart >= oSettings.fnRecordsDisplay()) { if (iNewStart >= oSettings.fnRecordsDisplay()) {
iNewStart = (Math.ceil((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength; iNewStart = (Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
} }
oSettings._iDisplayStart = iNewStart; oSettings._iDisplayStart = iNewStart;

@ -24,7 +24,9 @@
var unique = 0; var unique = 0;
var types = $.fn.dataTable.ext.type; var types = $.fn.dataTable.ext.type;
$.fn.dataTable.enum = function ( arr ) { // Using form $.fn.dataTable.enum breaks at least YuiCompressor since enum is
// a reserved word in JavaScript
$.fn.dataTable['enum'] = function ( arr ) {
var name = 'enum-'+(unique++); var name = 'enum-'+(unique++);
var lookup = window.Map ? new Map() : {}; var lookup = window.Map ? new Map() : {};

@ -5,7 +5,7 @@
* *
* @name Persian * @name Persian
* @summary Sort Persian strings alphabetically * @summary Sort Persian strings alphabetically
* @author [Afshin Mehrabani](http://www.afshinblog.com/) * @author [Afshin Mehrabani](http://www.afshinm.name/)
* *
* @example * @example
* $('#example').dataTable( { * $('#example').dataTable( {

Loading…
Cancel
Save