diff --git a/features/mark.js/datatables.mark.css b/features/mark.js/datatables.mark.css new file mode 100644 index 0000000..c11a41e --- /dev/null +++ b/features/mark.js/datatables.mark.css @@ -0,0 +1,4 @@ +mark { + background: orange; + color: black; +} diff --git a/features/mark.js/datatables.mark.es6.js b/features/mark.js/datatables.mark.es6.js new file mode 100644 index 0000000..c4cdeb1 --- /dev/null +++ b/features/mark.js/datatables.mark.es6.js @@ -0,0 +1,80 @@ +/*!*************************************************** + * datatables.mark.js v1.0.0 + * https://github.com/julmot/datatables.mark.js + * Copyright (c) 2016, Julian Motz + * 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); diff --git a/features/mark.js/datatables.mark.es6.min.js b/features/mark.js/datatables.mark.es6.min.js new file mode 100644 index 0000000..ed137bb --- /dev/null +++ b/features/mark.js/datatables.mark.es6.min.js @@ -0,0 +1,7 @@ +/*!*************************************************** + * datatables.mark.js v1.0.0 + * https://github.com/julmot/datatables.mark.js + * Copyright (c) 2016, Julian Motz + * 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); diff --git a/features/mark.js/datatables.mark.js b/features/mark.js/datatables.mark.js new file mode 100644 index 0000000..cab3a29 --- /dev/null +++ b/features/mark.js/datatables.mark.js @@ -0,0 +1,97 @@ +/*!*************************************************** + * datatables.mark.js v1.0.0 + * https://github.com/julmot/datatables.mark.js + * Copyright (c) 2016, Julian Motz + * Released under the MIT license https://git.io/voRZ7 + *****************************************************/ + +"use strict"; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +(function (factory, window, document) { + if (typeof define === "function" && define.amd) { + define(["jquery", "datatables", "markjs"], function (jQuery) { + return factory(window, document, jQuery); + }); + } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object") { + require("datatables"); + require("markjs"); + factory(window, document, require("jquery")); + } else { + factory(window, document, jQuery); + } +})(function (window, document, $) { + var Mark_DataTables = function () { + function Mark_DataTables(dtInstance, options) { + _classCallCheck(this, Mark_DataTables); + + 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 === "undefined" ? "undefined" : _typeof(options)) === "object" ? options : {}; + this.initMarkListener(); + } + + _createClass(Mark_DataTables, [{ + key: "initMarkListener", + value: function initMarkListener() { + var _this = this; + + this.instance.on("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth", this.mark.bind(this)); + this.instance.on("destroy", function () { + _this.instance.off("draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth"); + }); + this.mark(); + } + }, { + key: "mark", + value: function mark() { + var _this2 = this; + + var globalSearch = this.instance.search(); + + $(this.instance.table().body()).unmark(this.options); + this.instance.columns({ + search: "applied", + page: "current" + }).nodes().each(function (nodes, colIndex) { + var columnSearch = _this2.instance.column(colIndex).search(), + searchVal = columnSearch || globalSearch; + if (searchVal) { + nodes.forEach(function (node) { + $(node).mark(searchVal, _this2.options); + }); + } + }); + } + }]); + + return Mark_DataTables; + }(); + + $(document).on("init.dt.dth", function (event, settings) { + if (event.namespace !== "dt") { + return; + } + + var dtInstance = $.fn.dataTable.Api(settings); + + var 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); diff --git a/features/mark.js/datatables.mark.min.css b/features/mark.js/datatables.mark.min.css new file mode 100644 index 0000000..722870b --- /dev/null +++ b/features/mark.js/datatables.mark.min.css @@ -0,0 +1 @@ +mark{background:orange;color:black;} diff --git a/features/mark.js/datatables.mark.min.js b/features/mark.js/datatables.mark.min.js new file mode 100644 index 0000000..f108cbd --- /dev/null +++ b/features/mark.js/datatables.mark.min.js @@ -0,0 +1,7 @@ +/*!*************************************************** + * datatables.mark.js v1.0.0 + * https://github.com/julmot/datatables.mark.js + * Copyright (c) 2016, Julian Motz + * 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