Skip to content
Permalink
Browse files

Merge branch 'master' into selectmenu

  • Loading branch information
fnagel committed Mar 3, 2013
2 parents d94e217 + 6d3a1e1 commit dffe8f66109714af2d4ed8f582af4cf3439433e3
@@ -231,3 +231,8 @@ Pavel Selitskas <p.selitskas@gmail.com>
Bjørn Johansen <bjorn.johansen@metronet.no>
Matthieu Penant <thieum22@hotmail.com>
Dominic Barnes <dominic@dbarnes.info>
David Sullivan <david.sullivan@gmail.com>
Thomas Jaggi <thomas.jaggi@gmail.com>
Vahid Sohrabloo <vahid4134@gmail.com>
Travis Carden <travis.carden@gmail.com>
Bruno M. Custódio <bruno@brunomcustodio.com>
@@ -159,7 +159,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() {

grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
// remove dest file before creating it, to make sure itself is not included
if ( path.existsSync( this.file.dest ) ) {
if ( fs.existsSync( this.file.dest ) ) {
fs.unlinkSync( this.file.dest );
}
var crypto = require( "crypto" ),
@@ -175,67 +175,43 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun
});

grunt.registerTask( "generate_themes", function() {
var download, files, done, configContent,
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
var download, done,
distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ),
configFile = "node_modules/download.jqueryui.com/config.json";
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/";

try {
require.resolve( "download.jqueryui.com" );
} catch( error ) {
throw new Error( "You need to manually install download.jqueryui.com for this task to work" );
}

// copy release files into download builder to avoid cloning again
grunt.file.expandFiles( distFolder + "/**" ).forEach(function( file ) {
grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist\/jquery-ui-/, "") );
});
// make it look for the right version
configContent = grunt.file.readJSON( configFile );
configContent.jqueryUi.stable.version = grunt.config( "pkg.version" );
grunt.file.write( configFile, JSON.stringify( configContent, null, "\t" ) + "\n" );

download = new ( require( "download.jqueryui.com" ) )();

files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
files.forEach(function( fileName ) {
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
download = require( "download.jqueryui.com" )({
config: {
"jqueryUi": {
"stable": { "path": path.resolve( __dirname + "/../../" + distFolder ) }
},
"jquery": "skip"
}
});

done = this.async();
grunt.utils.async.forEach( download.themeroller.gallery(), function( theme, done ) {
var folderName = theme.folderName(),
concatTarget = "css-" + folderName,
cssContent = theme.css(),
cssFolderName = target + "themes/" + folderName + "/",
cssFileName = cssFolderName + "jquery.ui.theme.css",
cssFiles = grunt.config.get( "concat.css.src" )[ 1 ].slice();

grunt.file.write( cssFileName, cssContent );

// get css components, replace the last file with the current theme
cssFiles.splice(-1);
cssFiles.push( "<strip_all_banners:" + cssFileName + ">" );
grunt.config.get( "concat" )[ concatTarget ] = {
src: [ "<banner:meta.bannerCSS>", cssFiles ],
dest: cssFolderName + "jquery-ui.css"
};
grunt.task.run( "concat:" + concatTarget );

theme.fetchImages(function( err, files ) {
if ( err ) {
done( err );
return;
}
files.forEach(function( file ) {
grunt.file.write( cssFolderName + "images/" + file.path, file.data );
});
done();
});
}, function( err ) {
if ( err ) {
grunt.log.error( err );
download.buildThemesBundle(function( error, files ) {
if ( error ) {
grunt.log.error( error );
return done( false );
}
done( !err );

done(
files.every(function( file ) {
try {
grunt.file.write( target + file.path, file.data );
} catch( err ) {
grunt.log.error( err );
return false;
}
return true;
}) && grunt.log.writeln( "Generated at " + target )
);
});
});

@@ -16,11 +16,11 @@
});
});

var cfg = ($.hoverintent = {
sensitivity: 7,
interval: 100
});

/*
* hoverIntent | Copyright 2011 Brian Cherne
* http://cherne.net/brian/resources/jquery.hoverIntent.html
* modified by the jQuery UI team
*/
$.event.special.hoverintent = {
setup: function() {
$( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler );
@@ -29,41 +29,56 @@
$( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler );
},
handler: function( event ) {
var that = this,
var currentX, currentY, timeout,
args = arguments,
target = $( event.target ),
cX, cY, pX, pY;
previousX = event.pageX,
previousY = event.pageY;

function track( event ) {
cX = event.pageX;
cY = event.pageY;
currentX = event.pageX;
currentY = event.pageY;
};
pX = event.pageX;
pY = event.pageY;

function clear() {
target
.unbind( "mousemove", track )
.unbind( "mouseout", arguments.callee );
.unbind( "mouseout", clear );
clearTimeout( timeout );
}

function handler() {
if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) {
var prop,
orig = event;

if ( ( Math.abs( previousX - currentX ) +
Math.abs( previousY - currentY ) ) < 7 ) {
clear();
event.type = "hoverintent";
// prevent accessing the original event since the new event

event = $.Event( "hoverintent" );
for ( prop in orig ) {
if ( !( prop in event ) ) {
event[ prop ] = orig[ prop ];
}
}
// Prevent accessing the original event since the new event
// is fired asynchronously and the old event is no longer
// usable (#6028)
event.originalEvent = {};
jQuery.event.handle.apply( that, args );
delete event.originalEvent;

target.trigger( event );
} else {
pX = cX;
pY = cY;
timeout = setTimeout( handler, cfg.interval );
previousX = currentX;
previousY = currentY;
timeout = setTimeout( handler, 100 );
}
}
var timeout = setTimeout( handler, cfg.interval );
target.mousemove( track ).mouseout( clear );
return true;

timeout = setTimeout( handler, 100 );
target.bind({
mousemove: track,
mouseout: clear
});
}
};
</script>
@@ -37,91 +37,52 @@
(function( $ ) {
$.widget( "ui.combobox", {
_create: function() {
var input,
that = this,
wasOpen = false,
select = this.element.hide(),
selected = select.children( ":selected" ),
value = selected.val() ? selected.text() : "",
wrapper = this.wrapper = $( "<span>" )
.addClass( "ui-combobox" )
.insertAfter( select );

function removeIfInvalid( element ) {
var value = $( element ).val(),
matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ),
valid = false;
select.children( "option" ).each(function() {
if ( $( this ).text().match( matcher ) ) {
this.selected = valid = true;
return false;
}
});
this.wrapper = $( "<span>" )
.addClass( "ui-combobox" )
.insertAfter( this.element );

if ( !valid ) {
// remove invalid value, as it didn't match anything
$( element )
.val( "" )
.attr( "title", value + " didn't match any item" )
.tooltip( "open" );
select.val( "" );
setTimeout(function() {
input.tooltip( "close" ).attr( "title", "" );
}, 2500 );
input.data( "ui-autocomplete" ).term = "";
}
}
this._createAutocomplete();
this._createShowAllButton();
},

_createAutocomplete: function() {
var selected = this.element.children( ":selected" ),
value = selected.val() ? selected.text() : "";

input = $( "<input>" )
.appendTo( wrapper )
this.input = $( "<input>" )
.appendTo( this.wrapper )
.val( value )
.attr( "title", "" )
.addClass( "ui-state-default ui-combobox-input" )
.addClass( "ui-state-default ui-combobox-input ui-widget ui-widget-content ui-corner-left" )
.autocomplete({
delay: 0,
minLength: 0,
source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( select.children( "option" ).map(function() {
var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" +
$.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>" ),
value: text,
option: this
};
}) );
},
select: function( event, ui ) {
ui.item.option.selected = true;
that._trigger( "selected", event, {
item: ui.item.option
});
},
change: function( event, ui ) {
if ( !ui.item ) {
removeIfInvalid( this );
}
}
source: $.proxy( this, "_source" )
})
.addClass( "ui-widget ui-widget-content ui-corner-left" );
.tooltip({
tooltipClass: "ui-state-highlight"
});

this._on( this.input, {
autocompleteselect: function( event, ui ) {
ui.item.option.selected = true;
this._trigger( "select", event, {
item: ui.item.option
});
},

autocompletechange: "_removeIfInvalid"
});
},

input.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
_createShowAllButton: function() {
var wasOpen = false;

$( "<a>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.tooltip()
.appendTo( wrapper )
.appendTo( this.wrapper )
.button({
icons: {
primary: "ui-icon-triangle-1-s"
@@ -136,18 +97,62 @@
.click(function() {
input.focus();

// close if already visible
// Close if already visible
if ( wasOpen ) {
return;
}

// pass empty string as value to search for, displaying all results
// Pass empty string as value to search for, displaying all results
input.autocomplete( "search", "" );
});
},

_source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( this.element.children( "option" ).map(function() {
var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text,
value: text,
option: this
};
}) );
},

_removeIfInvalid: function( event, ui ) {

input.tooltip({
tooltipClass: "ui-state-highlight"
// Selected an item, nothing to do
if ( ui.item ) {
return;
}

// Search for a match (case-insensitive)
var value = this.input.val(),
valueLowerCase = value.toLowerCase(),
valid = false;
this.element.children( "option" ).each(function() {
if ( $( this ).text().toLowerCase() === valueLowerCase ) {
this.selected = valid = true;
return false;
}
});

// Found a match, nothing to do
if ( valid ) {
return;
}

// Remove invalid value
this.input
.val( "" )
.attr( "title", value + " didn't match any item" )
.tooltip( "open" );
this.element.val( "" );
this._delay(function() {
this.input.tooltip( "close" ).attr( "title", "" );
}, 2500 );
this.input.data( "ui-autocomplete" ).term = "";
},

_destroy: function() {

0 comments on commit dffe8f6

Please sign in to comment.
You can’t perform that action at this time.