Edit D:\xinhaisoft\crisis_new\Scripts\jquery.jtree.js
??/* * ???(jTree)??? * ?????(QQ33080907) * ????????2019.09.02 * ?????????????????????????????????? */ // select?????<select><option value="1" data-pid="0">???</option><option value="2" data-pid="1">???</option></select> // ??????????????????0????? (function ($) { 'use strict' // ???chosen???????SS $('head').append('<style>select.jtree + .chosen-container .chosen-results li {padding-top:1px;padding-bottom:1px}</style>') // ???AmazeUI??? // $('head').append('<style>select.jtree + .am-selected-list li{padding-top:0;padding-bottom:0;}</style>') $.fn.jTreeSelect = function (options) { var defaults = { all: false, // ??????[???]??? parid: null // ??????ID????????????????????????0????? } // ?????????????????? var opts = $.extend(defaults, options) var tree = [] var deep = 0 var title = '' var $this return this.each(function () { // ??????????????????????? if ($(this).children().length > 1) { // jQuery??? $this = $(this) // DOM??? var theselect = $this.get(0) // ???class??????css $this.addClass('jtree') // ?????????? var selectid = $('option[selected]', $this).length === 0 ? '' : $('option[selected]', $this).val() // ?????? $this.children().each(function () { if (opts.parid !== null) { tree.push($(this).val() + '|' + ($(this).val() === opts.parid.toString() ? 0 : $(this).data('pid')) + '|' + $(this).text()) } else { tree.push($(this).val() + '|' + $(this).data('pid') + '|' + $(this).text()) } }) // ??????option $this.empty() // ??????????????0???id??1??d??2?????3????????????????? $.each(tree, function (i) { tree[i] = tree[i].split('|') }) // console.log(tree) // ????????????????????????????? $.each(tree, function (i) { tree[i][3] = islast(tree[i][0], tree[i][1]) }) // ??????????????DOM????? showtree(0) // ???[???]??? if (opts.all) { $this.prepend('<option value="">[???]</option>') } // ?????? if (selectid !== '') { position(selectid) theselect.value = selectid theselect.title = title } else if (opts.all) { theselect.selectedIndex = 0 } } }) // ??? function showtree(id) { $.each(tree, function (i) { if (tree[i][1].toString() === id.toString()) { deep++ // ????ption??ext var text = '' for (var j = deep - 2; j > 0; j--) { text += parentislast(tree[i][0], j) ? '??' : '??' } if (deep > 1) { text += tree[i][3] ? '?? ' : '?? ' } text += tree[i][2] // ???????ption $this.append('<option value="' + tree[i][0] + '" data-pid="' + tree[i][1] + '">' + text + '</option>') showtree(tree[i][0]) deep-- } }) } // ???????????????????????????? function islast(id, pid) { // N?????????????????????? var n = 0 var m = 0 for (var i = 0; i < tree.length; i++) { if (tree[i][1] === pid) { if (tree[i][0] === id) { n = i } else { m = i } if (m > 0 && n > 0 && m > n) { return false } } } return true } // ?????????????????????????? function parentislast(id, deep) { var i, j var pid = id for (j = deep; j > 0; j--) { for (i = 0; i < tree.length; i++) { if (tree[i][0] === pid) { pid = tree[i][1] break } } } for (i = 0; i < tree.length; i++) { if (tree[i][0] === pid) { return tree[i][3] } } } // ???????????? function position(id) { if (id) { $.each(tree, function (i) { if (tree[i][0].toString() === id.toString()) { if (title === '') { title = tree[i][2] } else { title = tree[i][2] + ' ?? ' + title } position(tree[i][1]) } }) } } } })(jQuery)
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de