From 745d815ae897f8d5c48c8f89044489cee3f6b96f Mon Sep 17 00:00:00 2001 From: Max Guglielmi Date: Sun, 15 Feb 2015 19:55:23 +1100 Subject: [PATCH] Started pop-up filter module --- Gruntfile.js | 2 +- dist/filtergrid.css | 2 +- dist/tablefilter.js | 2 +- src-es6/modules/popupFilter.js | 196 +++++++++++++++++ src/core.js | 384 +++++++++++++++++---------------- src/index.html | 1 + src/modules/popupFilter.js | 199 +++++++++++++++++ src/modules/popupFilter.js.map | 1 + 8 files changed, 597 insertions(+), 190 deletions(-) create mode 100644 src-es6/modules/popupFilter.js create mode 100644 src/modules/popupFilter.js create mode 100644 src/modules/popupFilter.js.map diff --git a/Gruntfile.js b/Gruntfile.js index 30200823..0389cceb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -150,4 +150,4 @@ module.exports = function (grunt) { grunt.registerTask('dev', ['jshint', '6to5', 'concat', 'cssmin', 'copy']); grunt.registerTask('toes5', ['6to5']); grunt.registerTask('test', ['qunit']); -}; \ No newline at end of file +}; diff --git a/dist/filtergrid.css b/dist/filtergrid.css index 4fffda04..cb7bd867 100644 --- a/dist/filtergrid.css +++ b/dist/filtergrid.css @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------ - TableFilter stylesheet by Max Guglielmi - - (build date: Sun Feb 15 2015 15:02:22) + - (build date: Sun Feb 15 2015 19:52:24) - Edit below for your projects' needs ------------------------------------------------------------------------*/ diff --git a/dist/tablefilter.js b/dist/tablefilter.js index 73ceda9c..70019cfb 100644 --- a/dist/tablefilter.js +++ b/dist/tablefilter.js @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------ - TableFilter v3.0.0 by Max Guglielmi - - build date: Sun Feb 15 2015 15:02:21 + - build date: Sun Feb 15 2015 15:16:20 - http://tablefilter.free.fr - Copyright (c) 2014, Licensed under the MIT License ------------------------------------------------------------------------*/ diff --git a/src-es6/modules/popupFilter.js b/src-es6/modules/popupFilter.js new file mode 100644 index 00000000..669bfa19 --- /dev/null +++ b/src-es6/modules/popupFilter.js @@ -0,0 +1,196 @@ +import {Types} from '../types'; +import {Dom} from '../dom'; +import {Event} from '../event'; +import {Helpers} from '../helpers'; + +export class PopupFilter{ + + /** + * Pop-up filter component + * @param {Object} tf TableFilter instance + */ + constructor(tf){ + // Configuration object + var f = tf.fObj; + + // Enable external filters behaviour + tf.isExternalFlt = true; + tf.externalFltTgtIds = []; + + //filter icon path + this.popUpImgFlt = f.popup_filters_image || + tf.themesPath+'icn_filter.gif'; + //active filter icon path + this.popUpImgFltActive = f.popup_filters_image_active || + tf.themesPath+'icn_filterActive.gif'; + this.popUpImgFltHtml = f.popup_filters_image_html || + 'Column filter'; + //defines css class for popup div containing filter + this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter'; + //callback function before popup filtes is opened + this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ? + f.on_before_popup_filter_open : null; + //callback function after popup filtes is opened + this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ? + f.on_after_popup_filter_open : null; + //callback function before popup filtes is closed + this.onBeforePopUpClose = + Types.isFn(f.on_before_popup_filter_close) ? + f.on_before_popup_filter_close : null; + //callback function after popup filtes is closed + this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ? + f.on_after_popup_filter_close : null; + + //stores filters spans + this.popUpFltSpans = []; + //stores filters icons + this.popUpFltImgs = []; + //stores filters containers + this.popUpFltElms = this.popUpFltElmCache || []; + this.popUpFltAdjustToContainer = true; + + this.tf = tf; + } + + onClick(e){ + var evt = e || global.event, + elm = evt.target.parentNode, + colIndex = parseInt(elm.getAttribute('ci'), 10); + + // o.CloseAllPopupFilters(colIndex); + this.closeAll(colIndex); + // o.TogglePopupFilter(colIndex); + this.toggle(colIndex); + + if(this.popUpFltAdjustToContainer){ + var popUpDiv = this.popUpFltElms[colIndex], + header = this.tf.GetHeaderElement(colIndex), + headerWidth = header.clientWidth * 0.95; + if(Helpers.isIE()){ + var headerLeft = Dom.position(header).left; + popUpDiv.style.left = (headerLeft) + 'px'; + } + popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; + } + Event.cancel(evt); + Event.stop(evt); + } + + /** + * Initialize DOM elements + */ + init(){ + var tf = this.tf; + for(var i=0; i { this.onClick(evt); }); + this.popUpFltSpans[i] = popUpSpan; + this.popUpFltImgs[i] = popUpSpan.firstChild; + } + } + + + buildAll(){ + for(var i=0; i { Event.stop(evt); }); + this.popUpFltElms[colIndex] = popUpDiv; + } + + toggle(colIndex){ + var tf = this.tf, + popUpFltElm = this.popUpFltElms[colIndex]; + if(popUpFltElm.style.display === 'none' || + popUpFltElm.style.display === ''){ + if(this.onBeforePopUpOpen){ + this.onBeforePopUpOpen.call( + null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = 'block'; + if(tf['col'+colIndex] === tf.fltTypeInp){ + tf.GetFilterElement(colIndex).focus(); + } + if(this.onAfterPopUpOpen){ + this.onAfterPopUpOpen.call( + null, this, this.popUpFltElms[colIndex], colIndex); + } + } else { + if(this.onBeforePopUpClose){ + this.onBeforePopUpClose.call( + null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = 'none'; + if(this.onAfterPopUpClose){ + this.onAfterPopUpClose.call( + null, this, this.popUpFltElms[colIndex], colIndex); + } + } + } + + closeAll(exceptIdx){ + for(var i=0; i'; - //defines css class for popup div containing filter - this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter'; - //callback function before popup filtes is opened - this.onBeforePopUpOpen = types.isFn(f.on_before_popup_filter_open) ? - f.on_before_popup_filter_open : null; - //callback function after popup filtes is opened - this.onAfterPopUpOpen = types.isFn(f.on_after_popup_filter_open) ? - f.on_after_popup_filter_open : null; - //callback function before popup filtes is closed - this.onBeforePopUpClose = - types.isFn(f.on_before_popup_filter_close) ? - f.on_before_popup_filter_close : null; - //callback function after popup filtes is closed - this.onAfterPopUpClose = types.isFn(f.on_after_popup_filter_close) ? - f.on_after_popup_filter_close : null; - this.externalFltTgtIds = []; - //stores filters spans - this.popUpFltSpans = []; - //stores filters icons - this.popUpFltImgs = []; - //stores filters containers - this.popUpFltElms = this.popUpFltElmCache || []; - this.popUpFltAdjustToContainer = true; + // SetPopupFilterIcons: function(){ + // if(!this.popUpFilters){ + // return; + // } + // //external filters behaviour is enabled + // this.isExternalFlt = true; + // var f = this.fObj; + // //filter icon path + // this.popUpImgFlt = f.popup_filters_image || + // this.themesPath+'icn_filter.gif'; + // //active filter icon path + // this.popUpImgFltActive = f.popup_filters_image_active || + // this.themesPath+'icn_filterActive.gif'; + // this.popUpImgFltHtml = f.popup_filters_image_html || + // 'Column filter'; + // //defines css class for popup div containing filter + // this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter'; + // //callback function before popup filtes is opened + // this.onBeforePopUpOpen = types.isFn(f.on_before_popup_filter_open) ? + // f.on_before_popup_filter_open : null; + // //callback function after popup filtes is opened + // this.onAfterPopUpOpen = types.isFn(f.on_after_popup_filter_open) ? + // f.on_after_popup_filter_open : null; + // //callback function before popup filtes is closed + // this.onBeforePopUpClose = + // types.isFn(f.on_before_popup_filter_close) ? + // f.on_before_popup_filter_close : null; + // //callback function after popup filtes is closed + // this.onAfterPopUpClose = types.isFn(f.on_after_popup_filter_close) ? + // f.on_after_popup_filter_close : null; + // this.externalFltTgtIds = []; + // //stores filters spans + // this.popUpFltSpans = []; + // //stores filters icons + // this.popUpFltImgs = []; + // //stores filters containers + // this.popUpFltElms = this.popUpFltElmCache || []; + // this.popUpFltAdjustToContainer = true; - function onClick(e){ - var evt = e || global.event, - colIndex = parseInt(this.getAttribute('ci'), 10); + // function onClick(e){ + // var evt = e || global.event, + // colIndex = parseInt(this.getAttribute('ci'), 10); - o.CloseAllPopupFilters(colIndex); - o.TogglePopupFilter(colIndex); + // o.CloseAllPopupFilters(colIndex); + // o.TogglePopupFilter(colIndex); - if(o.popUpFltAdjustToContainer){ - var popUpDiv = o.popUpFltElms[colIndex], - header = o.GetHeaderElement(colIndex), - headerWidth = header.clientWidth * 0.95; - if(hlp.isIE()){ - var headerLeft = dom.position(header).left; - popUpDiv.style.left = (headerLeft) + 'px'; - } - popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; - } - evt.cancel(evt); - evt.stop(evt); - } + // if(o.popUpFltAdjustToContainer){ + // var popUpDiv = o.popUpFltElms[colIndex], + // header = o.GetHeaderElement(colIndex), + // headerWidth = header.clientWidth * 0.95; + // if(hlp.isIE()){ + // var headerLeft = dom.position(header).left; + // popUpDiv.style.left = (headerLeft) + 'px'; + // } + // popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; + // } + // evt.cancel(evt); + // evt.stop(evt); + // } - var o = this; - for(var i=0; i"; + //defines css class for popup div containing filter + this.popUpDivCssClass = f.popup_div_css_class || "popUpFilter"; + //callback function before popup filtes is opened + this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ? f.on_before_popup_filter_open : null; + //callback function after popup filtes is opened + this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ? f.on_after_popup_filter_open : null; + //callback function before popup filtes is closed + this.onBeforePopUpClose = Types.isFn(f.on_before_popup_filter_close) ? f.on_before_popup_filter_close : null; + //callback function after popup filtes is closed + this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ? f.on_after_popup_filter_close : null; + + //stores filters spans + this.popUpFltSpans = []; + //stores filters icons + this.popUpFltImgs = []; + //stores filters containers + this.popUpFltElms = this.popUpFltElmCache || []; + this.popUpFltAdjustToContainer = true; + + this.tf = tf; + }; + + _classProps(PopupFilter, null, { + onClick: { + writable: true, + value: function (e) { + var evt = e || global.event, elm = evt.target.parentNode, colIndex = parseInt(elm.getAttribute("ci"), 10); + + // o.CloseAllPopupFilters(colIndex); + this.closeAll(colIndex); + // o.TogglePopupFilter(colIndex); + this.toggle(colIndex); + + if (this.popUpFltAdjustToContainer) { + var popUpDiv = this.popUpFltElms[colIndex], header = this.tf.GetHeaderElement(colIndex), headerWidth = header.clientWidth * 0.95; + if (Helpers.isIE()) { + var headerLeft = Dom.position(header).left; + popUpDiv.style.left = (headerLeft) + "px"; + } + popUpDiv.style.width = parseInt(headerWidth, 10) + "px"; + } + Event.cancel(evt); + Event.stop(evt); + } + }, + init: { + writable: true, + value: function () { + var _this = this; + var tf = this.tf; + for (var i = 0; i < tf.nbCells; i++) { + if (tf["col" + i] === tf.fltTypeNone) { + continue; + } + var popUpSpan = Dom.create("span", ["id", tf.prfxPopUpSpan + tf.id + "_" + i], ["ci", i]); + popUpSpan.innerHTML = this.popUpImgFltHtml; + var header = tf.GetHeaderElement(i); + header.appendChild(popUpSpan); + // popUpSpan.onclick = onClick; + Event.add(popUpSpan, "click", function (evt) { + _this.onClick(evt); + }); + this.popUpFltSpans[i] = popUpSpan; + this.popUpFltImgs[i] = popUpSpan.firstChild; + } + } + }, + buildAll: { + writable: true, + value: function () { + for (var i = 0; i < this.popUpFltElmCache.length; i++) { + this.build(i, this.popUpFltElmCache[i]); + } + } + }, + build: { + writable: true, + value: function (colIndex, div) { + var tf = this.tf; + var popUpDiv = !div ? Dom.create("div", ["id", tf.prfxPopUpDiv + tf.id + "_" + colIndex]) : div; + popUpDiv.className = this.popUpDivCssClass; + tf.externalFltTgtIds.push(popUpDiv.id); + var header = tf.GetHeaderElement(colIndex); + header.insertBefore(popUpDiv, header.firstChild); + //popUpDiv.onclick = function(e){ evt.stop(e || global.event); }; + Event.add(popUpDiv, "click", function (evt) { + Event.stop(evt); + }); + this.popUpFltElms[colIndex] = popUpDiv; + } + }, + toggle: { + writable: true, + value: function (colIndex) { + var tf = this.tf, popUpFltElm = this.popUpFltElms[colIndex]; + if (popUpFltElm.style.display === "none" || popUpFltElm.style.display === "") { + if (this.onBeforePopUpOpen) { + this.onBeforePopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = "block"; + if (tf["col" + colIndex] === tf.fltTypeInp) { + tf.GetFilterElement(colIndex).focus(); + } + if (this.onAfterPopUpOpen) { + this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + } else { + if (this.onBeforePopUpClose) { + this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = "none"; + if (this.onAfterPopUpClose) { + this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + } + } + }, + closeAll: { + writable: true, + value: function (exceptIdx) { + for (var i = 0; i < this.popUpFltElms.length; i++) { + if (i === exceptIdx) { + continue; + } + var popUpFltElm = this.popUpFltElms[i]; + if (popUpFltElm) { + popUpFltElm.style.display = "none"; + } + } + } + }, + buildIcons: { + writable: true, + value: function () { + for (var i = 0; i < this.popUpFltImgs.length; i++) { + this.buildIcon(i, false); + } + } + }, + buildIcon: { + writable: true, + value: function (colIndex, active) { + var activeImg = Types.isUndef(active) ? true : active; + if (this.popUpFltImgs[colIndex]) { + this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt; + } + } + }, + destroy: { + writable: true, + value: function () { + this.popUpFltElmCache = []; + for (var i = 0; i < this.popUpFltElms.length; i++) { + var popUpFltElm = this.popUpFltElms[i], popUpFltSpan = this.popUpFltSpans[i]; + if (popUpFltElm) { + popUpFltElm.parentNode.removeChild(popUpFltElm); + this.popUpFltElmCache[i] = popUpFltElm; + } + popUpFltElm = null; + if (popUpFltSpan) { + popUpFltSpan.parentNode.removeChild(popUpFltSpan); + } + popUpFltSpan = null; + } + } + } + }); + + return PopupFilter; + })(); + + exports.PopupFilter = PopupFilter; +}); \ No newline at end of file diff --git a/src/modules/popupFilter.js.map b/src/modules/popupFilter.js.map new file mode 100644 index 00000000..0ad20c56 --- /dev/null +++ b/src/modules/popupFilter.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["src-es6/modules/popupFilter.js"],"names":[],"mappings":";;;;;;;;MAAQ,KAAK,UAAL,KAAK;MACL,GAAG,QAAH,GAAG;MACH,KAAK,UAAL,KAAK;MACL,OAAO,YAAP,OAAO;MAEF,WAAW;QAAX,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AC,QAAQ,EAAE,MAAM,EAAC;AACvB,cAAI,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;AACtD,cAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAC;AAC3B,gBAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,MAAM,GACpC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC;WACjD;SACJ;;AAED,aAAO;;eAAA,YAAE;AACL,cAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC3B,eAAI,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC;AACzC,gBAAI,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAClC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AACzC,gBAAG,WAAW,EAAC;AACX,yBAAW,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAChD,kBAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;aAC1C;AACD,uBAAW,GAAG,IAAI,CAAC;AACnB,gBAAG,YAAY,EAAC;AACZ,0BAAY,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;aACrD;AACD,wBAAY,GAAG,IAAI,CAAC;WACvB;SACJ;;;;WA7LQ,WAAW;;;UAAX,WAAW,GAAX,WAAW","file":"src-es6/modules/popupFilter.js","sourcesContent":["import {Types} from '../types';\r\nimport {Dom} from '../dom';\r\nimport {Event} from '../event';\r\nimport {Helpers} from '../helpers';\r\n\r\nexport class PopupFilter{\r\n\r\n /**\r\n * Pop-up filter component\r\n * @param {Object} tf TableFilter instance\r\n */\r\n constructor(tf){\r\n // Configuration object\r\n var f = tf.fObj;\r\n\r\n // Enable external filters behaviour\r\n tf.isExternalFlt = true;\r\n tf.externalFltTgtIds = [];\r\n\r\n //filter icon path\r\n this.popUpImgFlt = f.popup_filters_image ||\r\n tf.themesPath+'icn_filter.gif';\r\n //active filter icon path\r\n this.popUpImgFltActive = f.popup_filters_image_active ||\r\n tf.themesPath+'icn_filterActive.gif';\r\n this.popUpImgFltHtml = f.popup_filters_image_html ||\r\n '\"Column';\r\n //defines css class for popup div containing filter\r\n this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter';\r\n //callback function before popup filtes is opened\r\n this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ?\r\n f.on_before_popup_filter_open : null;\r\n //callback function after popup filtes is opened\r\n this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ?\r\n f.on_after_popup_filter_open : null;\r\n //callback function before popup filtes is closed\r\n this.onBeforePopUpClose =\r\n Types.isFn(f.on_before_popup_filter_close) ?\r\n f.on_before_popup_filter_close : null;\r\n //callback function after popup filtes is closed\r\n this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ?\r\n f.on_after_popup_filter_close : null;\r\n\r\n //stores filters spans\r\n this.popUpFltSpans = [];\r\n //stores filters icons\r\n this.popUpFltImgs = [];\r\n //stores filters containers\r\n this.popUpFltElms = this.popUpFltElmCache || [];\r\n this.popUpFltAdjustToContainer = true;\r\n\r\n this.tf = tf;\r\n }\r\n\r\n onClick(e){\r\n var evt = e || global.event,\r\n elm = evt.target.parentNode,\r\n colIndex = parseInt(elm.getAttribute('ci'), 10);\r\n\r\n // o.CloseAllPopupFilters(colIndex);\r\n this.closeAll(colIndex);\r\n // o.TogglePopupFilter(colIndex);\r\n this.toggle(colIndex);\r\n\r\n if(this.popUpFltAdjustToContainer){\r\n var popUpDiv = this.popUpFltElms[colIndex],\r\n header = this.tf.GetHeaderElement(colIndex),\r\n headerWidth = header.clientWidth * 0.95;\r\n if(Helpers.isIE()){\r\n var headerLeft = Dom.position(header).left;\r\n popUpDiv.style.left = (headerLeft) + 'px';\r\n }\r\n popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';\r\n }\r\n Event.cancel(evt);\r\n Event.stop(evt);\r\n }\r\n\r\n /**\r\n * Initialize DOM elements\r\n */\r\n init(){\r\n var tf = this.tf;\r\n for(var i=0; i { this.onClick(evt); });\r\n this.popUpFltSpans[i] = popUpSpan;\r\n this.popUpFltImgs[i] = popUpSpan.firstChild;\r\n }\r\n }\r\n\r\n\r\n buildAll(){\r\n for(var i=0; i { Event.stop(evt); });\r\n this.popUpFltElms[colIndex] = popUpDiv;\r\n }\r\n\r\n toggle(colIndex){\r\n var tf = this.tf,\r\n popUpFltElm = this.popUpFltElms[colIndex];\r\n if(popUpFltElm.style.display === 'none' ||\r\n popUpFltElm.style.display === ''){\r\n if(this.onBeforePopUpOpen){\r\n this.onBeforePopUpOpen.call(\r\n null, this, this.popUpFltElms[colIndex], colIndex);\r\n }\r\n popUpFltElm.style.display = 'block';\r\n if(tf['col'+colIndex] === tf.fltTypeInp){\r\n tf.GetFilterElement(colIndex).focus();\r\n }\r\n if(this.onAfterPopUpOpen){\r\n this.onAfterPopUpOpen.call(\r\n null, this, this.popUpFltElms[colIndex], colIndex);\r\n }\r\n } else {\r\n if(this.onBeforePopUpClose){\r\n this.onBeforePopUpClose.call(\r\n null, this, this.popUpFltElms[colIndex], colIndex);\r\n }\r\n popUpFltElm.style.display = 'none';\r\n if(this.onAfterPopUpClose){\r\n this.onAfterPopUpClose.call(\r\n null, this, this.popUpFltElms[colIndex], colIndex);\r\n }\r\n }\r\n }\r\n\r\n closeAll(exceptIdx){\r\n for(var i=0; i