{"version":3,"sources":["kendo.pivot.fieldmenu.js"],"names":["f","define","$","undefined","removeExpr","expressions","name","idx","length","result","field","push","findFilters","filter","member","operator","filterOperator","filters","checkNodes","nodes","values","value","split","checked","inArray","uniqueName","checkedNodeIds","checkedNodes","level","hasChildren","children","view","kendo","window","ui","MENU","proxy","NS","Widget","FILTER_ITEM","ARIA_LABEL","PivotFieldMenu","extend","init","element","options","fn","call","this","_dataSource","_layout","notify","events","filterable","sortable","messages","info","sortAscending","sortDescending","filterFields","include","title","clear","ok","cancel","operators","contains","doesnotcontain","startswith","endswith","eq","neq","wrapper","template","MENUTEMPLATE","ns","menu","target","orientation","showOn","closeOnClick","open","_menuOpen","select","_select","copyAnchorStyles","data","_createWindow","_initFilterForm","filterForm","find","filterProxy","_filter","_filterOperator","DropDownList","_filterValue","_updateFilterAriaLabel","on","_reset","_setFilterForm","expression","val","_clearFilters","dataSource","splice","indexOf","_convert","schema","model","fields","currentMember","type","parseFloat","parseJSON","e","that","preventDefault","close","selectedOperator","selectedOperatorName","attr","_sort","dir","sort","setDataSource","PivotDataSource","create","includeWindow","WINDOWTEMPLATE","_applyIncludes","_closeWindow","Window","visible","resizable","_windowOpen","resultExpression","treeView","rootChecked","existingExpression","join","_treeViewDataSource","HierarchicalDataSource","id","item","parseInt","childrenCardinality","transport","read","restrictions","node","get","memberUniqueName","replace","treeOp","levelUniqueName","schemaMembers","done","success","fail","error","_createTreeView","TreeView","autoBind","dataTextField","checkboxes","checkChildren","dataBound","progress","event","closest","not","kendoWindow","hasClass","center","destroy","LABELMENUTEMPLATE","plugin","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,yBACH,kBACA,aACA,eACA,iBACA,sBACDD,IACL,WAyXE,MA3WC,UAAUE,EAAGC,GAmTV,QAASC,GAAWC,EAAaC,GAAjC,GAEaC,GAASC,EADdC,IACJ,KAASF,EAAM,EAAGC,EAASH,EAAYG,OAA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HAAoJwI,EAAoB,4BACt9B/C,EAAiB,4TACrB9F,GAAG8I,OAAOvI,IACZR,OAAOD,MAAMiJ,QACRhJ,OAAOD,OACE,kBAAV/B,SAAwBA,OAAOiL,IAAMjL,OAAS,SAAUkL,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.pivot.fieldmenu.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.pivot.fieldmenu', [\n 'kendo.pivotgrid',\n 'kendo.menu',\n 'kendo.window',\n 'kendo.treeview',\n 'kendo.dropdownlist'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'pivot.fieldmenu',\n name: 'PivotFieldMenu',\n category: 'web',\n description: 'The PivotFieldMenu widget allows the user to filter on fields displayed in PivotGrid',\n depends: [\n 'menu',\n 'window',\n 'treeview',\n 'dropdownlist'\n ],\n advanced: true\n };\n (function ($, undefined) {\n var kendo = window.kendo;\n var ui = kendo.ui;\n var MENU = 'kendoContextMenu';\n var proxy = $.proxy;\n var NS = '.kendoPivotFieldMenu';\n var Widget = ui.Widget;\n var FILTER_ITEM = 'k-filter-item';\n var ARIA_LABEL = 'aria-label';\n var PivotFieldMenu = Widget.extend({\n init: function (element, options) {\n Widget.fn.init.call(this, element, options);\n this._dataSource();\n this._layout();\n kendo.notify(this);\n },\n events: [],\n options: {\n name: 'PivotFieldMenu',\n filter: null,\n filterable: true,\n sortable: true,\n messages: {\n info: 'Show items with value that:',\n sortAscending: 'Sort Ascending',\n sortDescending: 'Sort Descending',\n filterFields: 'Fields Filter',\n filter: 'Filter',\n include: 'Include Fields...',\n title: 'Fields to include',\n clear: 'Clear',\n ok: 'OK',\n cancel: 'Cancel',\n operators: {\n contains: 'Contains',\n doesnotcontain: 'Does not contain',\n startswith: 'Starts with',\n endswith: 'Ends with',\n eq: 'Is equal to',\n neq: 'Is not equal to'\n }\n }\n },\n _layout: function () {\n var options = this.options;\n this.wrapper = $(kendo.template(MENUTEMPLATE)({\n ns: kendo.ns,\n filterable: options.filterable,\n sortable: options.sortable,\n messages: options.messages\n }));\n this.menu = this.wrapper[MENU]({\n filter: options.filter,\n target: this.element,\n orientation: 'vertical',\n showOn: 'click',\n closeOnClick: false,\n open: proxy(this._menuOpen, this),\n select: proxy(this._select, this),\n copyAnchorStyles: false\n }).data(MENU);\n this._createWindow();\n if (options.filterable) {\n this._initFilterForm();\n }\n },\n _initFilterForm: function () {\n var filterForm = this.menu.element.find('.' + FILTER_ITEM);\n var filterProxy = proxy(this._filter, this);\n this._filterOperator = new kendo.ui.DropDownList(filterForm.find('select'));\n this._filterValue = filterForm.find('.k-textbox');\n this._updateFilterAriaLabel();\n filterForm.on('submit' + NS, filterProxy).on('click' + NS, '.k-button-filter', filterProxy).on('click' + NS, '.k-button-clear', proxy(this._reset, this));\n },\n _setFilterForm: function (expression) {\n var filterOperator = this._filterOperator;\n var operator = '';\n var value = '';\n if (expression) {\n operator = expression.operator;\n value = expression.value;\n }\n filterOperator.value(operator);\n if (!filterOperator.value()) {\n filterOperator.select(0);\n }\n this._filterValue.val(value);\n },\n _clearFilters: function (member) {\n var filter = this.dataSource.filter() || {};\n var expressions;\n var idx = 0;\n var length;\n filter.filters = filter.filters || [];\n expressions = findFilters(filter, member);\n for (length = expressions.length; idx < length; idx++) {\n filter.filters.splice(filter.filters.indexOf(expressions[idx]), 1);\n }\n return filter;\n },\n _convert: function (value) {\n var schema = this.dataSource.options.schema;\n var field = ((schema.model || {}).fields || {})[this.currentMember];\n if (field) {\n if (field.type === 'number') {\n value = parseFloat(value);\n } else if (field.type === 'boolean') {\n value = Boolean($.parseJSON(value));\n }\n }\n return value;\n },\n _filter: function (e) {\n var that = this;\n var value = that._convert(that._filterValue.val());\n e.preventDefault();\n if (value === '') {\n that.menu.close();\n return;\n }\n var expression = {\n field: that.currentMember,\n operator: that._filterOperator.value(),\n value: value\n };\n var filter = that._clearFilters(that.currentMember);\n filter.filters.push(expression);\n that.dataSource.filter(filter);\n that.menu.close();\n },\n _updateFilterAriaLabel: function () {\n var filterForm = this.menu.element.find('.' + FILTER_ITEM);\n var selectedOperator = this._filterOperator.value();\n var selectedOperatorName = this.options.messages.operators[selectedOperator];\n filterForm.find('select').attr(ARIA_LABEL, selectedOperatorName);\n },\n _reset: function (e) {\n var that = this;\n var filter = that._clearFilters(that.currentMember);\n e.preventDefault();\n if (!filter.filters[0]) {\n filter = {};\n }\n that.dataSource.filter(filter);\n that._setFilterForm(null);\n that.menu.close();\n },\n _sort: function (dir) {\n var field = this.currentMember;\n var expressions = this.dataSource.sort() || [];\n expressions = removeExpr(expressions, field);\n expressions.push({\n field: field,\n dir: dir\n });\n this.dataSource.sort(expressions);\n this.menu.close();\n },\n setDataSource: function (dataSource) {\n this.options.dataSource = dataSource;\n this._dataSource();\n },\n _dataSource: function () {\n this.dataSource = kendo.data.PivotDataSource.create(this.options.dataSource);\n },\n _createWindow: function () {\n var messages = this.options.messages;\n this.includeWindow = $(kendo.template(WINDOWTEMPLATE)({ messages: messages })).on('click' + NS, '.k-button-ok', proxy(this._applyIncludes, this)).on('click' + NS, '.k-button-cancel', proxy(this._closeWindow, this));\n this.includeWindow = new ui.Window(this.includeWindow, {\n title: messages.title,\n visible: false,\n resizable: false,\n open: proxy(this._windowOpen, this)\n });\n },\n _applyIncludes: function (e) {\n var checkedNodes = [];\n var resultExpression;\n var view = this.treeView.dataSource.view();\n var rootChecked = view[0].checked;\n var filter = this.dataSource.filter();\n var existingExpression = findFilters(filter, this.currentMember, 'in')[0];\n checkedNodeIds(view, checkedNodes);\n if (existingExpression) {\n if (rootChecked) {\n filter.filters.splice(filter.filters.indexOf(existingExpression), 1);\n if (!filter.filters.length) {\n filter = {};\n }\n } else {\n existingExpression.value = checkedNodes.join(',');\n }\n resultExpression = filter;\n }\n if (checkedNodes.length) {\n if (!resultExpression && !rootChecked) {\n resultExpression = {\n field: this.currentMember,\n operator: 'in',\n value: checkedNodes.join(',')\n };\n if (filter) {\n filter.filters.push(resultExpression);\n resultExpression = filter;\n }\n }\n }\n if (resultExpression) {\n this.dataSource.filter(resultExpression);\n }\n this._closeWindow(e);\n },\n _closeWindow: function (e) {\n e.preventDefault();\n this.includeWindow.close();\n },\n _treeViewDataSource: function () {\n var that = this;\n return kendo.data.HierarchicalDataSource.create({\n schema: {\n model: {\n id: 'uniqueName',\n hasChildren: function (item) {\n return parseInt(item.childrenCardinality, 10) > 0;\n }\n }\n },\n transport: {\n read: function (options) {\n var restrictions = {};\n var node = that.treeView.dataSource.get(options.data.uniqueName);\n var name = options.data.uniqueName;\n if (!name) {\n restrictions.levelUniqueName = that.currentMember + '.[(ALL)]';\n } else {\n restrictions.memberUniqueName = node.uniqueName.replace(/\\&/g, '&');\n restrictions.treeOp = 1;\n }\n that.dataSource.schemaMembers(restrictions).done(function (data) {\n checkNodes(that.dataSource.filter(), that.currentMember, data);\n options.success(data);\n }).fail(options.error);\n }\n }\n });\n },\n _createTreeView: function (element) {\n var that = this;\n that.treeView = new ui.TreeView(element, {\n autoBind: false,\n dataSource: that._treeViewDataSource(),\n dataTextField: 'caption',\n template: '#: data.item.caption || data.item.name #',\n checkboxes: { checkChildren: true },\n dataBound: function () {\n ui.progress(that.includeWindow.element, false);\n }\n });\n },\n _menuOpen: function (e) {\n if (!e.event) {\n return;\n }\n var attr = kendo.attr('name');\n this.currentMember = $(e.event.target).closest('[' + attr + ']').attr(attr);\n if (this.options.filterable) {\n this._setFilterForm(findFilters(this.dataSource.filter(), this.currentMember)[0]);\n }\n },\n _select: function (e) {\n var item = $(e.item);\n $('.k-pivot-filter-window').not(this.includeWindow.element).kendoWindow('close');\n if (item.hasClass('k-include-item')) {\n this.includeWindow.center().open();\n } else if (item.hasClass('k-sort-asc')) {\n this._sort('asc');\n } else if (item.hasClass('k-sort-desc')) {\n this._sort('desc');\n } else if (item.hasClass(FILTER_ITEM)) {\n this._updateFilterAriaLabel();\n }\n },\n _windowOpen: function () {\n if (!this.treeView) {\n this._createTreeView(this.includeWindow.element.find('.k-treeview'));\n }\n ui.progress(this.includeWindow.element, true);\n this.treeView.dataSource.read();\n },\n destroy: function () {\n Widget.fn.destroy.call(this);\n if (this.menu) {\n this.menu.destroy();\n this.menu = null;\n }\n if (this.treeView) {\n this.treeView.destroy();\n this.treeView = null;\n }\n if (this.includeWindow) {\n this.includeWindow.destroy();\n this.includeWindow = null;\n }\n this.wrapper = null;\n this.element = null;\n }\n });\n function removeExpr(expressions, name) {\n var result = [];\n for (var idx = 0, length = expressions.length; idx < length; idx++) {\n if (expressions[idx].field !== name) {\n result.push(expressions[idx]);\n }\n }\n return result;\n }\n function findFilters(filter, member, operator) {\n if (!filter) {\n return [];\n }\n filter = filter.filters;\n var idx = 0;\n var result = [];\n var length = filter.length;\n var filterOperator;\n for (; idx < length; idx++) {\n filterOperator = filter[idx].operator;\n if ((!operator && filterOperator !== 'in' || filterOperator === operator) && filter[idx].field === member) {\n result.push(filter[idx]);\n }\n }\n return result;\n }\n function checkNodes(filter, member, nodes) {\n var values, idx = 0, length = nodes.length;\n filter = findFilters(filter, member, 'in')[0];\n if (!filter) {\n for (; idx < length; idx++) {\n nodes[idx].checked = true;\n }\n } else {\n values = filter.value.split(',');\n for (; idx < length; idx++) {\n nodes[idx].checked = $.inArray(nodes[idx].uniqueName, values) >= 0;\n }\n }\n }\n function checkedNodeIds(nodes, checkedNodes) {\n var idx, length = nodes.length;\n for (idx = 0; idx < length; idx++) {\n if (nodes[idx].checked && nodes[idx].level() !== 0) {\n checkedNodes.push(nodes[idx].uniqueName);\n }\n if (nodes[idx].hasChildren) {\n checkedNodeIds(nodes[idx].children.view(), checkedNodes);\n }\n }\n }\n var LABELMENUTEMPLATE = '