linbei/static/bootstrap.dropdown.cascade/js/bootstrap-cascader.min.js.map

1 line
26 KiB
Plaintext

{"version":3,"sources":["js/bootstrap-cascader.js"],"names":["$","DEF_OPTS","splitChar","cls","btnCls","placeHolder","dropUp","lazy","openOnHover","openOnHoverDelay","openOnHoverDelay4Lazy","isSelectable","item","loaded","children","length","selectable","TPLS","enHtml","value","String","replace","DropdownPanel","data","csd","panel","this","selectItem","itemEl","params","call","setItemOpened","panelEl","removeClass","addClass","selectItemByCode","code","trigger","setSelected","setOpen","c","scrollToOpened","isMatchedSelectedItems","withParents","currItem","j","level","selectedItem","selectedItems","selectedItemCode","currItemData","originData","parent","find","size","scrollTop","top","position","height","destroy","remove","handler","itemCode","loadingItem","loadData","then","refreshPanels","always","appendTo","el","lastPanel","panels","lastPanelEl","lastPanelLeft","Number","css","left","outerWidth","push","isParentAllMatched","hasMatchedChildren","each","i","itemData","itemName","name","n","attr","text","on","selectItem click","openDropdown","openTimeout","clearTimeout","setTimeout","inited","reloaded","isInited","reloading","Cascader","def","initialized","readonly","Array","convertData2Col","isLazy","d","childMap","hasChild","updateBtnText","btn","getValue","htmlClickHandler","e","hasClass","cascader","target","parents","close","setValue","clearValue","names","oldSelectedItems","join","updateViewBySelected","tryFireOnChange","panelNo","rmPanels","splice","rmPanel","off","unshift","newItems","oldItems","fire","allCodesSame","oldItem","oldItemCode","newItem","open","toggleClass","slice","setReadonly","isReadonly","reload","openedItems","defered","Deferred","resolve","reject","promise","cols","insertAfter","hide","click","preventDefault","stopPropagation","fn","bsCascader","args","arguments","$this","extend","val","split","apply","prototype","jQuery"],"mappings":"CAAA,SAAWA,GACT,aAGA,IAAIC,EAAW,CACbC,UAAW,IACXC,IAAK,GACLC,OAAQ,cACRC,YAAa,MACbC,QAAQ,EACRC,MAAM,EACNC,aAAa,EACbC,iBAAkB,IAClBC,sBAAuB,IACvBC,aAAc,SAAUC,GACtB,OAAOA,GAAQA,EAAKC,UAAYD,EAAKE,UAAYF,EAAKE,SAASC,Q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V,OACzCK,EAAIK,OAAOtB,MAASiB,EAAIK,OAAOV,OAAOK,EAAIuE,WAGjD/F,EAAE,QAAQyF,GAAG,QAASuB,IAGxBhH,EAAE6J,GAAGC,WAAa,SAAUjI,GAC1B,IAAIkI,EAAOC,UACX,OAAOtI,KAAKuD,KAAK,WACf,GAAKvD,KAAL,CACA,IAAIuI,EAAQjK,EAAE0B,MAEVoI,EAAaG,EAAM1I,KAAK,cACvBuI,IACHjI,EAAS7B,EAAEkK,OAAO,CAChB7F,GAAI4F,EAAO9I,MAAO8I,EAAME,MAAQF,EAAME,MAAMC,MAAMvI,EAAO3B,WAAa,KAAO,IAC5E2B,GACHiI,EAAa,IAAI3D,EAAStE,GAC1BoI,EAAM1I,KAAK,aAAcuI,IAEL,iBAAXjI,GACTiI,EAAWjI,GAAQwI,MAAMP,EAAYvD,MAAM+D,UAAUzB,MAAM/G,KAAKiI,EAAM,QAtc9E,CA0cGQ","file":"bootstrap-cascader.min.js","sourcesContent":["(function ($) {\n 'use strict';\n\n // DEF_OPTS\n var DEF_OPTS = {\n splitChar: ' ',\n cls: '',\n btnCls: 'btn-default',\n placeHolder: '请选择',\n dropUp: false,\n lazy: false,\n openOnHover: false,\n openOnHoverDelay: 100,\n openOnHoverDelay4Lazy: 200,\n isSelectable: function (item) {\n return item && item.loaded && (!item.children || item.children.length <= 0 || item.selectable);\n }\n };\n\n // TPLS\n var TPLS = {\n containerTpl: '<div class=\"btn-group bootstrap-cascader form-control\"></div>',\n btnTpl: '<button class=\"btn dropdown-toggle bs-placeholder\" type=\"button\">\\\n <span class=\"filter-option pull-left\"></span> <span class=\"caret icon-arrow-down\"></span> <span class=\"icon-cross bsfont icon-jiaochacross78\"></span>\\\n </button>',\n dropdownTpl: '<ul class=\"dropdown-menu\"></ul>',\n dropdownItemTpl: '<li>\\\n <a href=\"javascript:\">\\\n <span class=\"text\"></span>\\\n <span class=\"bsfont icon-ico-right-arrow item-right-arrow\"></span>\\\n <span class=\"bsfont icon-loading item-loading\"></span>\\\n <span class=\"bsfont icon-error\"></span>\\\n </a>\\\n </li>'\n };\n\n var enHtml = function (value) {\n return !value ? '' : String(value).replace(/&/g, \"&amp;\").replace(/>/g, \"&gt;\").replace(/</g, \"&lt;\").replace(/\"/g, \"&quot;\");\n };\n\n // DropdownPanel\n var DropdownPanel = function (data, csd) {\n if (!data || !data.children || data.children.length <= 0) return;\n\n var panel = this;\n this.selectItem = function (item, itemEl) {\n var selectable = csd.params.isSelectable.call(csd, item);\n if (selectable) csd.selectItem(itemEl);\n };\n\n this.setItemOpened = function (item, itemEl) {\n panel.panelEl.children('li').removeClass('open');\n itemEl.addClass('open');\n if (item.loaded && item.children.length == 0) itemEl.addClass('no-child');\n };\n\n this.selectItemByCode = function (code) {\n panel.panelEl.children('li[code=' + enHtml(code) + ']').trigger('selectItem');\n };\n\n this.setSelected = function (item, setOpen) {\n var itemEl = panel.panelEl.children('li[code=' + enHtml(item.code || item.c) + ']');\n itemEl.children('a').addClass('selected');\n if (setOpen) panel.setItemOpened(item, itemEl);\n panel.scrollToOpened();\n };\n\n this.isMatchedSelectedItems = function (item, withParents) {\n var currItem = item;\n for (var j = item.level - 1; j >= 0; j--) {\n var selectedItem = csd.selectedItems[j], selectedItemCode = selectedItem.code || selectedItem.c;\n var currItemData = currItem.originData, currItemCode = currItemData.code || currItemData.c;\n if (selectedItemCode != currItemCode) return false;\n if (withParents === false) return true;\n currItem = currItem.parent;\n }\n return true;\n };\n\n this.scrollToOpened = function () {\n var panelEl = panel.panelEl, selectedItem = panelEl.find('li a.selected').parent();\n if (selectedItem.size() > 0) {\n var scrollTop = panelEl.scrollTop(), top = selectedItem.position().top + scrollTop;\n if (scrollTop < top) {\n top = top - (panelEl.height() - selectedItem.height()) / 2;\n panelEl.scrollTop(top);\n }\n }\n };\n\n this.destroy = function () {\n panel.panelEl.remove();\n };\n\n var handler = function (item, itemEl, selectItem) {\n if (csd.params.lazy && item.loaded === false) {\n itemEl.addClass('bs-loading');\n var itemCode = item.code || item.c;\n\n if (panel.loadingItem) panel.loadingItem = false;\n panel.loadingItem = itemCode;\n\n csd.loadData(item).then(function () {\n if (panel.loadingItem == itemCode)\n csd.refreshPanels(item.level + 1, item);\n }, function () {\n if (panel.loadingItem == itemCode)\n itemEl.addClass('load-error');\n }).always(function () {\n if (panel.loadingItem == itemCode) {\n panel.setItemOpened(item, itemEl);\n panel.loadingItem = false;\n }\n itemEl.removeClass('bs-loading');\n });\n } else {\n csd.refreshPanels(item.level + 1, item);\n panel.setItemOpened(item, itemEl);\n if (selectItem) panel.selectItem(item, itemEl);\n }\n };\n\n panel.panelEl = $(TPLS.dropdownTpl).appendTo(csd.el), panel.data = data;\n\n // set panel position\n var lastPanel = csd.panels[csd.panels.length - 1];\n if (lastPanel) {\n var lastPanelEl = lastPanel.panelEl, lastPanelLeft = Number((lastPanelEl.css('left') || '').replace('px', ''));\n panel.panelEl.css({left: lastPanelLeft + lastPanelEl.outerWidth()})\n }\n csd.panels.push(panel);\n\n // update panel style\n if (csd.panels.length > 0) {\n csd.el.children('.dropdown-menu').removeClass('first-child last-child');\n csd.panels[0].panelEl.addClass('first-child');\n csd.panels[csd.panels.length - 1].panelEl.addClass('last-child');\n }\n\n var isParentAllMatched = false, hasMatchedChildren = false;\n if (csd.selectedItems.length > data.level) isParentAllMatched = panel.isMatchedSelectedItems(data);\n\n $.each(data.children, function (i, item) {\n var itemEl = $(TPLS.dropdownItemTpl).appendTo(panel.panelEl), itemData = item.originData;\n var itemName = itemData.name || itemData.n, itemCode = itemData.code || itemData.c;\n itemEl.data(\"cascaderItem\", item).attr('code', itemCode).attr('title', itemName).find('.text').text(itemName);\n\n itemEl.on({\n 'selectItem click': function () {\n handler(item, itemEl, true);\n },\n 'openDropdown': function () {\n handler(item, itemEl);\n }\n });\n\n if (csd.params.openOnHover) {\n itemEl.on('mouseover', function () {\n if (csd.openTimeout) clearTimeout(csd.openTimeout);\n csd.openTimeout = setTimeout(function () {\n handler(item, itemEl);\n }, csd.params.lazy ? csd.params.openOnHoverDelay4Lazy : csd.params.openOnHoverDelay);\n });\n }\n\n if (item.loaded && (!item.children || item.children.length <= 0)) itemEl.addClass('no-child');\n\n // update selected items view state\n if (csd.selectedItems.length >= item.level && isParentAllMatched) {\n if (panel.isMatchedSelectedItems(item, false)) {\n hasMatchedChildren = true;\n if (csd.selectedItems.length > item.level) {\n handler(item, itemEl, false);\n } else {\n if (csd.selectedItems.length == csd.panels.length)\n $.each(csd.selectedItems, function (j, selectedItem) {\n csd.panels[j].setSelected(selectedItem, j < csd.selectedItems.length - 1);\n });\n csd.inited(), csd.reloaded();\n }\n }\n }\n });\n\n if ((!csd.isInited || csd.reloading) && csd.selectedItems.length > data.level && !hasMatchedChildren && csd.params.lazy)\n csd.isInited ? csd.reloaded() : csd.inited();\n };\n\n // Cascader\n var Cascader = function (params) {\n var csd = this;\n params = params || {};\n for (var def in DEF_OPTS) if (typeof params[def] === 'undefined') params[def] = DEF_OPTS[def];\n csd.params = params, csd.initialized = false, csd.selectedItems = [], csd.readonly = false;\n if (csd.params.value instanceof Array) csd.selectedItems = [];\n\n // initBtn\n var initBtn = function () {\n csd.btn = $(TPLS.btnTpl).addClass(params.btnCls).click(function () {\n csd.open();\n }).appendTo(csd.el);\n csd.btn.children('.icon-cross').click(function (e) {\n csd.clearValue(true);\n e.preventDefault();\n e.stopPropagation();\n });\n updateBtnText(params.placeHolder);\n };\n\n // convertData2Col\n var convertData2Col = function (data, parent) {\n var isLazy = csd.params.lazy;\n $.each(data, function (i, item) {\n var itemCode = item.code || item.c, children = item.data || item.d;\n var itemData = {\n childMap: {}, children: [], loaded: !isLazy || item.hasChild === false,\n level: parent.level + 1, parent: parent, originData: item\n };\n parent.children.push(itemData);\n parent.childMap[itemCode] = itemData;\n if (children && children.length > 0) convertData2Col(children, itemData);\n });\n };\n\n // updateBtnText\n var updateBtnText = function (text) {\n csd.btn.attr('title', text).children('.filter-option').text(text);\n if (csd.getValue().length > 0) csd.btn.removeClass('bs-placeholder').addClass('selected');\n else csd.btn.addClass('bs-placeholder').removeClass('selected');\n };\n\n // htmlClickHandler\n var htmlClickHandler = function (e) {\n if (!csd.el.hasClass('open')) return;\n var cascader = $(e.target).parents('.bootstrap-cascader');\n if (cascader.size() == 0) csd.close();\n else if (cascader[0] != csd.el[0]) csd.close();\n };\n\n // setValue\n csd.setValue = function (value) {\n csd.clearValue();\n\n var names = [], oldSelectedItems = csd.getValue;\n $.each(value, function (i, item) {\n csd.selectedItems.push({code: item.code || item.c, name: item.name || item.n});\n names.push(item.name || item.n);\n });\n updateBtnText(names.join(csd.params.splitChar));\n csd.updateViewBySelected();\n\n csd.tryFireOnChange(oldSelectedItems, csd.getValue());\n };\n\n // refreshPanels\n csd.refreshPanels = function (panelNo, data) {\n var rmPanels = csd.panels.splice(panelNo - 1, csd.panels.length);\n if (rmPanels) $.each(rmPanels, function (i, rmPanel) {\n rmPanel.destroy();\n });\n\n new DropdownPanel(data, csd);\n };\n\n // destroy\n csd.destroy = function () {\n $.each(csd.panels, function (i, panel) {\n panel.destroy();\n });\n $('html').off('click', htmlClickHandler);\n };\n\n // selectItem\n csd.selectItem = function (itemEl) {\n csd.el.find('li a').removeClass('selected');\n itemEl.children('a').addClass('selected');\n csd.el.find('li.open a').addClass('selected');\n\n var item = itemEl.data('cascaderItem'), names = [], oldSelectedItems = csd.getValue();\n csd.selectedItems = [];\n while (item.parent) {\n var itemData = item.originData, code = itemData.code || itemData.c, name = itemData.name || itemData.n;\n csd.selectedItems.unshift({code: code, name: name});\n names.unshift(name);\n item = item.parent;\n }\n\n updateBtnText(names.join(csd.params.splitChar));\n csd.close();\n\n var newItems = csd.getValue();\n csd.tryFireOnChange(oldSelectedItems, newItems);\n csd.params.el.trigger('bs.cascader.select', [newItems]);\n };\n\n // tryFireOnChange\n csd.tryFireOnChange = function (oldItems, newItems) {\n var fire = true;\n if (oldItems != newItems && oldItems.length == newItems.length) {\n var allCodesSame = true;\n $.each(oldItems, function (i, oldItem) {\n var oldItemCode = oldItem.code || oldItem.c, newItem = newItems[i], newItemCode = newItem.code || newItem.c;\n if (oldItemCode != newItemCode) {\n allCodesSame = false;\n return false;\n }\n });\n if (allCodesSame) fire = false;\n }\n if (fire) csd.params.el.trigger('bs.cascader.change', [oldItems, newItems]);\n };\n\n // close\n csd.close = function () {\n csd.el.removeClass('open');\n csd.updateViewBySelected();\n };\n\n // update view by selected\n csd.updateViewBySelected = function () {\n if (csd.selectedItems.length > 0)\n csd.panels[0].selectItemByCode(csd.selectedItems[0].code || csd.selectedItems[0].c);\n };\n\n // open\n csd.open = function () {\n if (csd.readonly) return;\n csd.el.toggleClass('open');\n\n $.each(csd.panels, function (i, panel) {\n panel.scrollToOpened();\n });\n };\n\n // getValue\n csd.getValue = function () {\n return csd.selectedItems.slice();\n };\n\n // clearValue\n csd.clearValue = function (fire) {\n if (csd.readonly) return;\n\n csd.selectedItems = [];\n csd.el.find('.dropdown-menu li a').removeClass('selected');\n updateBtnText(csd.params.placeHolder);\n\n if (fire) csd.params.el.trigger('bs.cascader.clear');\n };\n\n // setReadonly\n csd.setReadonly = function (readonly) {\n readonly = readonly !== false;\n csd.readonly = readonly;\n if (readonly) {\n csd.el.addClass('readonly');\n csd.btn.addClass('disabled');\n } else {\n csd.el.removeClass('readonly');\n csd.btn.removeClass('disabled');\n }\n };\n\n // isReadonly\n csd.isReadonly = function () {\n return csd.readonly;\n };\n\n // reload\n csd.reload = function () {\n csd.reloading = true, csd.data = {childMap: {}, children: [], loaded: false, level: 0};\n csd.loadData().then(function () {\n csd.refreshPanels(1, csd.data);\n if (csd.params.value) csd.setValue(csd.params.value);\n if (!csd.params.lazy || !csd.params.value) csd.reloaded();\n });\n };\n\n // reloaded\n csd.reloaded = function () {\n if (!csd.reloading) return;\n\n csd.reloading = false;\n csd.params.el.trigger('bs.cascader.reloaded');\n };\n\n // inited\n csd.inited = function () {\n if (csd.isInited) return;\n\n csd.isInited = true;\n csd.params.el.trigger('bs.cascader.inited');\n };\n\n // loadData\n csd.loadData = function (item) {\n // get opened items\n var openedItems = [];\n if (item) {\n var currItem = item;\n while (currItem.parent) {\n openedItems.unshift(currItem.originData);\n currItem = currItem.parent;\n }\n } else item = csd.data;\n\n var defered = $.Deferred();\n csd.params.loadData.call(csd, openedItems, function (data) {\n if (data) {\n if (data.length > 0) {\n if (!openedItems || openedItems.length <= 0) csd.data.originData = data;\n convertData2Col(data, item);\n }\n item.loaded = true;\n defered.resolve(data);\n } else defered.reject();\n });\n return defered.promise();\n };\n\n csd.data = {childMap: {}, children: [], loaded: false, level: 0}, csd.panels = [];\n csd.cols = [], csd.el = $(TPLS.containerTpl).addClass(csd.params.cls);\n if (csd.params.dropUp) csd.el.addClass('dropup');\n if (csd.params.replace) {\n csd.el.insertAfter(params.el);\n params.el.hide();\n } else csd.el.appendTo(params.el);\n initBtn();\n if (csd.params.readonly) csd.setReadonly(true);\n\n csd.loadData().always(function () {\n csd.refreshPanels(1, csd.data);\n if (csd.params.value) csd.setValue(csd.params.value);\n if (!csd.params.lazy || !csd.params.value) csd.inited();\n });\n\n $('html').on('click', htmlClickHandler);\n };\n\n $.fn.bsCascader = function (params) {\n var args = arguments;\n return this.each(function () {\n if (!this) return;\n var $this = $(this);\n\n var bsCascader = $this.data(\"bsCascader\");\n if (!bsCascader) {\n params = $.extend({\n el: $this, value: $this.val() ? $this.val().split(params.splitChar || ' ') : ''\n }, params);\n bsCascader = new Cascader(params);\n $this.data(\"bsCascader\", bsCascader);\n }\n if (typeof params === typeof \"a\")\n bsCascader[params].apply(bsCascader, Array.prototype.slice.call(args, 1));\n });\n }\n\n})(jQuery);\n"]}