Files
Testing/html5-chat/js/jquery.splitter-0.15.0.min.js

1 line
6.2 KiB
JavaScript
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
(function($,undefined){var count=0;var splitter_id=null;var splitters=[];var current_splitter=null;$.fn.split=function(options){var data=this.data("splitter");if(data){return data}var panel_1;var panel_2;var settings=$.extend({limit:100,orientation:"horizontal",position:"50%",invisible:false,onDragStart:$.noop,onDragEnd:$.noop,onDrag:$.noop},options||{});this.settings=settings;var cls;var children=this.children();if(settings.orientation=="vertical"){panel_1=children.first().addClass("left_panel");panel_2=panel_1.next().addClass("right_panel");cls="vsplitter"}else if(settings.orientation=="horizontal"){panel_1=children.first().addClass("top_panel");panel_2=panel_1.next().addClass("bottom_panel");cls="hsplitter"}if(settings.invisible){cls+=" splitter-invisible"}var width=this.width();var height=this.height();var id=count++;this.addClass("splitter_panel");var splitter=$("<div/>").addClass(cls).bind("mouseenter touchstart",function(){splitter_id=id}).bind("mouseleave touchend",function(){splitter_id=null}).insertAfter(panel_1);var position;function widthWithoutScrollbar(selector){var tempDiv=$("<div/>");$(selector).append(tempDiv);var elemwidth=tempDiv.width();tempDiv.remove();return elemwidth}function get_position(position){if(typeof position==="number"){return position}else if(typeof position==="string"){var match=position.match(/^([0-9\.]+)(px|%)$/);if(match){if(match[2]=="px"){return+match[1]}else{if(settings.orientation=="vertical"){return width*+match[1]/100}else if(settings.orientation=="horizontal"){return height*+match[1]/100}}}else{}}else{}}var self=$.extend(this,{refresh:function(){var new_width=this.width();var new_height=this.height();if(width!=new_width||height!=new_height){width=this.width();height=this.height();self.position(position)}},position:function(){if(settings.orientation=="vertical"){return function(n,silent){if(n===undefined){return position}else{position=get_position(n);var sw=splitter.width();var sw2=sw/2;if(settings.invisible){var pw=panel_1.width(position).outerWidth();panel_2.width(self.width()-pw);splitter.css("left",pw-sw2)}else{var pw=panel_1.width(position-sw).outerWidth();panel_2.width(self.width()-pw-sw2);splitter.css("left",pw)}}if(!silent){self.find(".splitter_panel").trigger("splitter.resize")}return self}}else if(settings.orientation=="horizontal"){return function(n,silent){if(n===undefined){return position}else{position=get_position(n);var sw=splitter.height();var sw2=sw/2;if(settings.invisible){var pw=panel_1.height(position).outerHeight();panel_2.height(self.height()-pw);splitter.css("top",pw-sw2)}else{var pw=panel_1.height(position-sw2).outerHeight();panel_2.height(self.height()-pw-sw);splitter.css("top",pw)}}if(!silent){self.find(".splitter_panel").trigger("splitter.resize")}return self}}else{return $.noop}}(),orientation:settings.orientation,limit:settings.limit,isActive:function(){return splitter_id===id},destroy:function(){self.removeClass("splitter_panel");splitter.unbind("mouseenter");splitter.unbind("mouseleave");splitter.unbind("touchstart");splitter.unbind("touchmove");splitter.unbind("touchend");splitter.unbind("touchleave");splitter.unbind("touchcancel");if(settings.orientation=="vertical"){panel_1.removeClass("left_panel");panel_2.removeClass("right_panel")}else if(settings.orientation=="horizontal"){panel_1.removeClass("top_panel");panel_2.removeClass("bottom_panel")}self.unbind("splitter.resize");self.find(".splitter_panel").trigger("splitter.resize");splitters[id]=null;splitter.remove();var not_null=false;for(var i=splitters.length;i--;){if(splitters[i]!==null){not_null=true;break}}if(!not_null){$(document.documentElement).unbind(".splitter");$(window).unbind("resize.splitter");self.data("splitter",null);splitters=[];count=0}}});self.bind("splitter.resize",function(e){var pos=self.position();if(self.orientation=="vertical"&&pos>self.width()){pos=self.width()-self.limit-1}else if(self.orientation=="horizontal"&&pos>self.height()){pos=self.height()-self.limit-1}if(pos<self.limit){pos=self.limit+1}self.position(pos,true)});var pos;if(settings.orientation=="vertical"){