Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
Update jQuery 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
myfreeer committed Nov 28, 2016
1 parent c0d2a86 commit 7e55bf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jq.bilibili.min.js

Large diffs are not rendered by default.

1 comment on commit 7e55bf7

@myfreeer
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should notice that there needs a extra function SelectModule

var SelectModule=function(){function b(c,e){this.params={};this._isMobile=!1;if("undefined"!=typeof c&&("string"==typeof c||c instanceof $?(this.obj=$(c),this.params=e||{}):(this.params=c,this.obj=$(this.params.item)),this.obj.length)){this.obj.hasClass("b-slt")||(this.obj=this.obj.find(".b-slt"));this._active=!1;if("undefined"!=typeof this.params.onInit){this.params.onInit(this.obj)}if(0==this.obj.children().length||this.params.selectorData){this.obj=this.createMenu(this.obj)}this.list=this.obj.find(".list");this.init();d.push(this)}}var d=[];window.bindSlt=b.bind=function(a,e){return new b(a,e)};b.create=function(a){var r=$('<div class="b-slt"></div>');$("<span>").addClass("txt").appendTo(r);$("<div>").addClass("b-slt-arrow").appendTo(r);var q=$("<ul>").addClass("list").appendTo(r);a.wrapper&&r.wrap(a.wrapper);var p=a.items||[];1>=p.length&&r.hide();for(var o=0;o<p.length;o++){var n=p[o],i=$("<li></li>").text(n.name).appendTo(q);n.selected&&b.prototype._setSelect.call(this,i);if(n.attributes){for(var j in n.attributes){i.attr(j,n.attributes[j])}}}a.wrapper&&(r=r.parent());return r};b.prototype.init=function(){var f=this.obj,h=this,g=this.list.find("[selected]");0==g.length&&(g=this.list.find("li").eq(0));this._setSelect(g);f.off("mouseenter.selectMenu");f.off("mouseleave.selectMenu");f.off("click.selectMenu");f.on("click.selectMenu",function(c){h._tap(c)});this._isMobile||!1===this.params.hover||(f.on("mouseenter.selectMenu",function(c){h._mover(c)}),f.on("mouseleave.selectMenu",function(c){h._mout(c)}));this.list.find("li").off("click.selectMenu");this.list.on("click","li",function(c){c.stopPropagation();h.select(c,$(this))});f.data("select-menu",this)};b.prototype._mover=function(c){c.stopPropagation();for(var g=0;g<d.length;g++){d[g]._mout(c)}if(!this.obj.attr("disabled")&&this.list.length){var f=this;this.obj.addClass("on");this.list.show();this._active=!0;this.setPos(this.list);if(this._isMobile||!1===this.params.hover){$(document).off("click.selectMenu"),$(document).one("click.selectMenu",function(e){f._mout(e)})}}};b.prototype._mout=function(c){this.obj.removeClass("on");this.list.hide();this._active=!1;(this._isMobile||!1===this.params.hover)&&$(document).off("click.selectMenu")};b.prototype._tap=function(c){this._active?this._mout(c):this._mover(c)};b.prototype.select=function(e,f){this._mout(e);if(!f||this._change(f)){"undefined"==typeof f&&(f=this.value()),this.change(f,e)}};b.prototype.change=function(e,f){e=e||this.value();"function"==typeof this.params.onChange&&this.params.onChange.call(this,e,f)};b.prototype._change=function(c){if(c.attr("selected")||c.attr("disabled")){return !1}this._cancelSelect();this._setSelect(c);return !0};b.prototype._setSelect=function(c){c.attr("selected","selected").addClass("b-state-selected");$(".txt",this.obj).html(c.html())};b.prototype._cancelSelect=function(){$("li",this.list).removeAttr("selected").removeClass("b-state-selected")};b.prototype.value=function(f,h){if(h){var g=this.list.find("["+f+'="'+h+'"]');g.length&&this._change(g);return g}return f?this.getSelected().attr(f):this.getSelected()};b.prototype.getSelected=function(){return this.list.find('[selected="selected"]')};b.prototype.createMenu=function(f){$("<span>").addClass("txt").appendTo(f);$("<div>").addClass("b-slt-arrow").appendTo(f);var h=this.params;this.list=$("<ul>").addClass("list").appendTo(f);"undefined"!=typeof h.createList&&h.createList(this.list);if("undefined"!=typeof h.selectorData){for(var g in h.selectorData){this.add(h.selectorData[g].name,h.selectorData[g].attributes)}}return f};b.prototype.add=function(g,j){var i=$("<li>").html(g).appendTo(this.list);if("undefined"!=typeof j){for(var h in j){i.attr(h,j[h])}}return i};b.prototype.setPos=function(c){c.offset().left+c.width()-10>$(window).scrollLeft()+$(window).width()?c.css({left:"auto",right:"-1px"}):c.css({left:"-1px",right:"auto"})};b.prototype.close=function(c){null!=c&&(c.originalEvent?$(".b-slt").each(function(f,g){var e=$(g);$(".list",e).hide()}):$(".list",c).hide())};b.prototype.getList=function(){return this.obj.find(".list")};b.prototype.reset=function(){var c=this.list.children().first();$("li",this.list).removeAttr("selected").removeClass("b-state-selected");c.attr("selected","selected");$(".txt",this.obj).html(c.html());c.attr("disabled")||this.change(c)};b.prototype.disable=function(){this.obj.addClass("disabled");this.obj.off("mouseenter.selectMenu");this.obj.off("mouseleave.selectMenu");this.obj.off("click.selectMenu");this.list.find("li").off("click.selectMenu")};b.prototype.enable=function(){this.obj.removeClass("disabled");this.init()};return b}();

Please sign in to comment.