wangrong
2025-09-23 40634ebaf5863a599bba8ca2c0575ca079fb8e15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
$(function () {
  $(window).resize(refHeight)
  refHeight()
 
  // 切换选项卡
  $(".mp_tab_tit li").click(function () {
    if ($(this).hasClass("cur") || $(this).hasClass("disabled")) {
      return false
    } else {
      let that = $(this),
        index = that.index()
      that.addClass("cur").siblings("li").removeClass("cur")
      that.parent().siblings(".mp_tab_con").children().eq(index).addClass("cur").siblings().removeClass("cur")
 
      let _id = $(this).attr("id")
      localforage.setItem(storageName, _id)
    }
  })
 
  $("#tab_attr").click(function () {
    $(".mp_tab_ava").hide()
    $(".mp_tab_con").show()
  })
 
  $("#tab_availability").click(function () {
    $(".mp_tab_con").hide()
    $(".mp_tab_ava").show()
  })
 
  // mp_tree
  $(".open").click(changeOpenShowHide)
})
 
// function tab2plot() {
//     $("#tab_attr").addClass('disabled');
//     $("#tab_latlng").addClass('disabled');
//     $("#tab_plot").click();
// }
 
var storageName = "mars3d_plotAttr"
 
function tab2attr() {
  // $("#tab_attr").removeClass('disabled');
  // $("#tab_latlng").removeClass('disabled');
 
  // if ($("#tab_plot").hasClass('cur'))
 
  //读取localStorage值
  localforage.getItem(storageName).then(function (last_attr_tab) {
    if (last_attr_tab != null) {
      $("#" + last_attr_tab).click()
    } else {
      $("#tab_attr").click()
    }
  })
}
 
function changeOpenShowHide() {
  let openlis = $(this).siblings()
  let opent = $(this).children(".tree_icon")
  openlis.toggle()
  if (openlis.is(":hidden")) {
    opent.html("+")
  } else {
    opent.html("-")
  }
}
 
function refHeight() {
  $(".mp_tab_card").height($(".mp_box").height() - $(".mp_head").height() - 1)
  $(".mp_tree").height($(".mp_tab_card").height() - 32)
  $(".mp_mark").height($(".mp_tab_card").height() - 80)
}
 
;(function ($) {
  //下拉菜单默认参数
  let defaluts = {
    select: "mp_select",
    select_text: "mp_select_text",
    select_ul: "mp_select_ul"
  }
 
  $.fn.extend({
    // 下拉菜单
    select: function (options) {
      let opts = $.extend({}, defaluts, options)
      return this.each(function () {
        let that = $(this)
        //模拟下拉列表
        if (that.data("value") !== undefined && that.data("value") !== "") {
          that.val(that.data("value"))
        }
        let _html = []
        _html.push('<div class="' + that.attr("class") + '">')
        _html.push('<div class="' + opts.select_text + '">' + that.find(":selected").text() + "</div>")
        _html.push('<ul class="' + opts.select_ul + '">')
        that.children("option").each(function () {
          let option = $(this)
          if (that.data("value") == option.val()) {
            _html.push('<li data-value="' + option.val() + '">' + option.text() + "</li>")
          } else {
            _html.push('<li data-value="' + option.val() + '">' + option.text() + "</li>")
          }
        })
        _html.push("</ul>")
        _html.push("</div>")
        let select = $(_html.join(""))
        let select_text = select.find("." + opts.select_text)
        let select_ul = select.find("." + opts.select_ul)
        that.after(select)
        that.hide()
        //下拉列表操作
        select.click(function (event) {
          $(this).toggleClass("mp_selected")
          $(this)
            .find("." + opts.select_ul)
            .slideToggle()
            .end()
            .siblings("div." + opts.select)
            .find("." + opts.select_ul)
            .slideUp()
          event.stopPropagation()
        })
        $("body").click(function () {
          select_ul.slideUp()
        })
        select_ul.on("click", "li", function () {
          let li = $(this)
          let val = li.addClass("selecton").siblings("li").removeClass("selecton").end().data("value").toString()
          if (val !== that.attr("data-value")) {
            select_text.text(li.text())
            that.attr("data-value", val)
            that.change()
          }
        })
      })
    },
 
    //滑动条
    progress: function (max) {
      let opts = {
        progress: "puiprogress",
        progress_bg: "puiprogress_bg",
        progress_btn: "puiprogress_btn",
        progress_bar: "puiprogress_bar",
        progress_text: "puiprogress_text"
      }
      return this.each(function () {
        let that = $(this)
        //模拟进度条
        let _html = []
        _html.push('<div class="' + opts.progress + '">')
        _html.push('<div class="' + opts.progress_bg + '">')
        _html.push('<div class="' + opts.progress_bar + '">' + "</div>")
        _html.push("</div>")
        _html.push('<div class="' + opts.progress_btn + '">' + "</div>")
        _html.push('<div class="' + opts.progress_text + '">' + that.val() + "%</div>")
        _html.push("</div>")
        let pro = $(_html.join(""))
        let progress_bg = pro.find("." + opts.progress_bg)
        let progress_btn = pro.find("." + opts.progress_btn)
        let progress_bar = pro.find("." + opts.progress_bar)
        let progress_text = pro.find("." + opts.progress_text)
        that.after(pro)
        that.hide()
        //进度条操作
        let tag = false,
          ox = 0,
          left = 0,
          bgleft = 0
        pro.css("width", max)
 
        let _val = Number(that.val())
        left = (max * _val) / 100
        progress_btn.css("left", left)
        progress_bar.width(left)
        progress_text.html(parseInt(_val) + "%")
 
        progress_btn.mousedown(function (e) {
          ox = e.pageX - left
          tag = true
        })
        $(document).mouseup(function () {
          tag = false
        })
        pro.mousemove(function (e) {
          //鼠标移动
          if (tag) {
            left = e.pageX - ox
            if (left <= 0) {
              left = 0
            } else if (left > max) {
              left = max
            }
            progress_btn.css("left", left)
            progress_bar.width(left)
            let _val = parseInt((left / max) * 100)
            progress_text.html(_val + "%")
 
            that.val(_val)
            that.change()
          }
        })
        progress_bg.click(function (e) {
          //鼠标点击
          if (!tag) {
            bgleft = progress_bg.offset().left
            left = e.pageX - bgleft
            if (left <= 0) {
              left = 0
            } else if (left > max) {
              left = max
            }
            progress_btn.css("left", left)
            progress_bar.animate({ width: left }, max)
            let _val = parseInt((left / max) * 100)
            progress_text.html(_val + "%")
            that.val(_val)
            that.change()
          }
        })
      })
    }
  })
})(window.jQuery)