<commit_before>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Responsive presentation and behavior for HTML data panels
//>>label: Panel
//>>group: Widgets
//>>css.structure: ../css/structure/jquery.mobile.panel.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css

define( [ "jquery", "../jquery.mobile.widget", "./page", "./page.sections" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

$.widget( "mobile.panel", $.mobile.widget, {
	options: {
		classes: {
			panel: "ui-panel",
			contentWrap: "ui-panel-content-wrap"
		},
		theme: null,
		position: "left",
		dismissible: true,
		display: "reveal",
		initSelector: ":jqmData(role='panel')"
	},
	_handleLink: function( roleType , callback ){
		var elId = this.element.attr( "id" ),
			self = this;
		$( document ).on( "vclick" , "a", function( e ) {
			var $link = $( this ),
				id = $link.attr( "href" ).split( "#" )[1];
			if( elId === id ){
				e.preventDefault();
				callback.call( self , $link , id );
				return false;
			}
		});
	},
	_blockPage: function( options ){
		var deferred = $.Deferred();
		var $div = $( "<div>" ),
			$panel = this,
			$el = this.element,
			slideDir = options.position === "left" ? "right" : "left",
			clickable = options.dismissible,
			klass = "ui-panel-dismiss",
			$page = $el.closest( ":jqmData(role='page')" ),
			$contentsWrap = $page.find( "." + options.classes.contentWrap ),
			responsiveClasses;

		setTimeout(function(){
			if( clickable ){
				responsiveClasses = $panel.element[0].className.match(/ui-responsive-?\w*/g) || [];
				for( var j = 0, len = responsiveClasses.length; j < len; j++ ){
					$contentsWrap.addClass( responsiveClasses[ j ] );
				}
				$div.addClass( "ui-panel-dismiss-overlay" )
					.css( "height" , $.mobile.activePage.height() )
					.css( slideDir , 0 )
					.attr( "id" , "page-block" )
					.addClass( klass )
					.appendTo( $.mobile.activePage );
				$div.bind( "vclick" , function(){
					$panel.close();
				});
			}
			deferred.resolve( options );
		}, 0); // TODO get rid of setTimeout 0 hacks
		return deferred.promise();
	},
	_create: function() {
		var o = this.options,
			$el = this.element,
			$closeLink = $el.find( "[data-rel=close]" ),
			$page = $el.closest( ":jqmData(role='page')" );

		$el.addClass( o.classes.panel );
		if( $page.find( "." + o.classes.contentWrap ).length === 0 ){
			$page.find( ".ui-header, .ui-content, .ui-footer" ).wrapAll( '<div class="' + o.classes.contentWrap + '" />' );
		}
		if( o.theme ){
			$el.addClass( "ui-body-" + o.theme );
		}

		$page.addClass( $.support.cssTransform3d ? "ui-panel-transforms" : "ui-panel-positioning" );

		this._handleLink( "panel" , function( $link , id ){
			var options = $.extend( {} , this.options ),
				op = {
					position: $link.jqmData( "position" ),
					dismissible: $link.jqmData( "dismissible" ),
					display: $link.jqmData( "display" )
				};
			for( var i in op ){
				if( op.hasOwnProperty( i ) && typeof op[ i ] !== "undefined" ){
					options[ i ] = op[ i ];
				}
			}
			$( "#" + id ).panel( "toggle" , {
				position: options.position,//left right
				dismissible: options.dismissible,//true or false
				display: options.display,// overlay or push
				link: $link
			});
		});
		$closeLink.on( "vclick" , function( e ){
			e.preventDefault();
			$el.panel( "close" );
			return false;
		});

		$el.on( "swipeleft" , function( e ){
			$( this ).panel( "close" );
		});

		this._trigger( "create" );
	},
	_position: function( options ){
		var deferred = $.Deferred();<commit_msg>Panel: Made swipe to close work on the whole page and work in either direction<commit_after>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Responsive presentation and behavior for HTML data panels
//>>label: Panel
//>>group: Widgets
//>>css.structure: ../css/structure/jquery.mobile.panel.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css

define( [ "jquery", "../jquery.mobile.widget", "./page", "./page.sections" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

$.widget( "mobile.panel", $.mobile.widget, {
	options: {
		classes: {
			panel: "ui-panel",
			contentWrap: "ui-panel-content-wrap"
		},
		theme: null,
		position: "left",
		dismissible: true,
		display: "reveal",
		initSelector: ":jqmData(role='panel')"
	},
	_handleLink: function( roleType , callback ){
		var elId = this.element.attr( "id" ),
			self = this;
		$( document ).on( "vclick" , "a", function( e ) {
			var $link = $( this ),
				id = $link.attr( "href" ).split( "#" )[1];
			if( elId === id ){
				e.preventDefault();
				callback.call( self , $link , id );
				return false;
			}
		});
	},
	_blockPage: function( options ){
		var deferred = $.Deferred();
		var $div = $( "<div>" ),
			$panel = this,
			$el = this.element,
			slideDir = options.position === "left" ? "right" : "left",
			clickable = options.dismissible,
			klass = "ui-panel-dismiss",
			$page = $el.closest( ":jqmData(role='page')" ),
			$contentsWrap = $page.find( "." + options.classes.contentWrap ),
			responsiveClasses;

		setTimeout(function(){
			if( clickable ){
				responsiveClasses = $panel.element[0].className.match(/ui-responsive-?\w*/g) || [];
				for( var j = 0, len = responsiveClasses.length; j < len; j++ ){
					$contentsWrap.addClass( responsiveClasses[ j ] );
				}
				$div.addClass( "ui-panel-dismiss-overlay" )
					.css( "height" , $.mobile.activePage.height() )
					.css( slideDir , 0 )
					.attr( "id" , "page-block" )
					.addClass( klass )
					.appendTo( $.mobile.activePage );
				$div.bind( "vclick" , function(){
					$panel.close();
				});
			}
			deferred.resolve( options );
		}, 0); // TODO get rid of setTimeout 0 hacks
		return deferred.promise();
	},
	_create: function() {
		var o = this.options,
			$el = this.element,
			$closeLink = $el.find( "[data-rel=close]" ),
			$page = $el.closest( ":jqmData(role='page')" );

		$el.addClass( o.classes.panel );
		if( $page.find( "." + o.classes.contentWrap ).length === 0 ){
			$page.find( ".ui-header, .ui-content, .ui-footer" ).wrapAll( '<div class="' + o.classes.contentWrap + '" />' );
		}
		if( o.theme ){
			$el.addClass( "ui-body-" + o.theme );
		}

		$page.addClass( $.support.cssTransform3d ? "ui-panel-transforms" : "ui-panel-positioning" );

		this._handleLink( "panel" , function( $link , id ){
			var options = $.extend( {} , this.options ),
				op = {
					position: $link.jqmData( "position" ),
					dismissible: $link.jqmData( "dismissible" ),
					display: $link.jqmData( "display" )
				};
			for( var i in op ){
				if( op.hasOwnProperty( i ) && typeof op[ i ] !== "undefined" ){
					options[ i ] = op[ i ];
				}
			}
			$( "#" + id ).panel( "toggle" , {
				position: options.position,//left right
				dismissible: options.dismissible,//true or false
				display: options.display,// overlay or push
				link: $link
			});
		});
		$closeLink.on( "vclick" , function( e ){
			e.preventDefault();
			$el.panel( "close" );
			return false;
		});

		$page.on( "swipe" , function( e ){
  			$( ".ui-panel-active" ).panel( "close" );
		});

		this._trigger( "create" );
	},
	_position: function( options ){
		var deferred = $.Deferred();
{'fraction_non_alphanumeric': 0.20349717747487264, 'fraction_numerical': 0.0022029464408646563, 'mean_word_length': 3.09009009009009, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5588452', 'n_tokens_mistral': 2975, 'n_tokens_neox': 2511, 'n_words': 555}