mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2025-01-08 16:34:06 +00:00
Add grunt. Automate version setting for configuration files.
This commit is contained in:
parent
23bdea852e
commit
d3577df69b
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
/.idea*
|
/.idea*
|
||||||
/*.xml
|
/*.xml
|
||||||
/bower_components
|
/bower_components
|
||||||
|
/node_modules/*
|
||||||
|
44
bower.json
44
bower.json
@ -1,24 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "devbridge-autocomplete",
|
"name": "devbridge-autocomplete",
|
||||||
"version": "1.2.11",
|
"version": "1.2.11",
|
||||||
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
|
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Tomas Kirda"
|
"Tomas Kirda"
|
||||||
],
|
],
|
||||||
"description": "Autocomplete provides suggestions while you type into the text field.",
|
"description": "Autocomplete provides suggestions while you type into the text field.",
|
||||||
"main": "dist/jquery.autocomplete.js",
|
"main": "dist/jquery.autocomplete.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"ajax",
|
"ajax",
|
||||||
"autocomplete"
|
"autocomplete"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"**/.*",
|
"**/.*",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"bower_components",
|
"bower_components",
|
||||||
"spec"
|
"spec"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jquery": ">=1.7"
|
"jquery": ">=1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@
|
|||||||
"ajax",
|
"ajax",
|
||||||
"autocomplete"
|
"autocomplete"
|
||||||
],
|
],
|
||||||
"version": "1.2.9",
|
"version": "1.2.11",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Tomas Kirda",
|
"name": "Tomas Kirda",
|
||||||
"url": "https://github.com/tkirda"
|
"url": "https://github.com/tkirda"
|
||||||
|
49
dist/jquery.autocomplete.js
vendored
49
dist/jquery.autocomplete.js
vendored
@ -4,11 +4,10 @@
|
|||||||
*
|
*
|
||||||
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
||||||
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jslint browser: true, white: true, plusplus: true */
|
/*jslint browser: true, white: true, plusplus: true */
|
||||||
/*global define, window, document, jQuery */
|
/*global define, window, document, jQuery, exports */
|
||||||
|
|
||||||
// Expose plugin as an AMD module if AMD loader is present:
|
// Expose plugin as an AMD module if AMD loader is present:
|
||||||
(function (factory) {
|
(function (factory) {
|
||||||
@ -16,6 +15,9 @@
|
|||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define(['jquery'], factory);
|
define(['jquery'], factory);
|
||||||
|
} else if (typeof exports === 'object' && typeof require === 'function') {
|
||||||
|
// Browserify
|
||||||
|
factory(require('jquery'));
|
||||||
} else {
|
} else {
|
||||||
// Browser globals
|
// Browser globals
|
||||||
factory(jQuery);
|
factory(jQuery);
|
||||||
@ -138,8 +140,7 @@
|
|||||||
suggestionSelector = '.' + that.classes.suggestion,
|
suggestionSelector = '.' + that.classes.suggestion,
|
||||||
selected = that.classes.selected,
|
selected = that.classes.selected,
|
||||||
options = that.options,
|
options = that.options,
|
||||||
container,
|
container;
|
||||||
noSuggestionsContainer;
|
|
||||||
|
|
||||||
// Remove autocomplete attribute to prevent native suggestions:
|
// Remove autocomplete attribute to prevent native suggestions:
|
||||||
that.element.setAttribute('autocomplete', 'off');
|
that.element.setAttribute('autocomplete', 'off');
|
||||||
@ -276,34 +277,37 @@
|
|||||||
if (orientation == 'auto') {
|
if (orientation == 'auto') {
|
||||||
var viewPortHeight = $(window).height(),
|
var viewPortHeight = $(window).height(),
|
||||||
scrollTop = $(window).scrollTop(),
|
scrollTop = $(window).scrollTop(),
|
||||||
top_overflow = -scrollTop + offset.top - containerHeight,
|
topOverflow = -scrollTop + offset.top - containerHeight,
|
||||||
bottom_overflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight);
|
bottomOverflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight);
|
||||||
|
|
||||||
if (Math.max(top_overflow, bottom_overflow) === top_overflow)
|
orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow)
|
||||||
orientation = 'top';
|
? 'top'
|
||||||
else
|
: 'bottom';
|
||||||
orientation = 'bottom';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orientation === 'top')
|
if (orientation === 'top') {
|
||||||
styles.top += -containerHeight;
|
styles.top += -containerHeight;
|
||||||
else
|
} else {
|
||||||
styles.top += height;
|
styles.top += height;
|
||||||
|
}
|
||||||
|
|
||||||
// If container is not positioned to body,
|
// If container is not positioned to body,
|
||||||
// correct its position using offset parent offset
|
// correct its position using offset parent offset
|
||||||
if(containerParent !== document.body) {
|
if(containerParent !== document.body) {
|
||||||
var opacity = $container.css('opacity'),
|
var opacity = $container.css('opacity'),
|
||||||
parentOffsetDiff;
|
parentOffsetDiff;
|
||||||
if (!that.visible)
|
|
||||||
$container.css('opacity', 0).show();
|
if (!that.visible){
|
||||||
|
$container.css('opacity', 0).show();
|
||||||
|
}
|
||||||
|
|
||||||
parentOffsetDiff = $container.offsetParent().offset();
|
parentOffsetDiff = $container.offsetParent().offset();
|
||||||
styles.top -= parentOffsetDiff.top;
|
styles.top -= parentOffsetDiff.top;
|
||||||
styles.left -= parentOffsetDiff.left;
|
styles.left -= parentOffsetDiff.left;
|
||||||
|
|
||||||
if (!that.visible)
|
if (!that.visible){
|
||||||
$container.css('opacity', opacity).hide();
|
$container.css('opacity', opacity).hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -2px to account for suggestions border.
|
// -2px to account for suggestions border.
|
||||||
@ -444,7 +448,7 @@
|
|||||||
query = that.getQuery(value),
|
query = that.getQuery(value),
|
||||||
index;
|
index;
|
||||||
|
|
||||||
if (that.selection) {
|
if (that.selection && that.currentValue !== query) {
|
||||||
that.selection = null;
|
that.selection = null;
|
||||||
(options.onInvalidateSelection || $.noop).call(that.element);
|
(options.onInvalidateSelection || $.noop).call(that.element);
|
||||||
}
|
}
|
||||||
@ -611,8 +615,7 @@
|
|||||||
noSuggestionsContainer = $(that.noSuggestionsContainer),
|
noSuggestionsContainer = $(that.noSuggestionsContainer),
|
||||||
beforeRender = options.beforeRender,
|
beforeRender = options.beforeRender,
|
||||||
html = '',
|
html = '',
|
||||||
index,
|
index;
|
||||||
width;
|
|
||||||
|
|
||||||
if (options.triggerSelectOnValidInput) {
|
if (options.triggerSelectOnValidInput) {
|
||||||
index = that.findSuggestionIndex(value);
|
index = that.findSuggestionIndex(value);
|
||||||
@ -731,10 +734,12 @@
|
|||||||
|
|
||||||
validateOrientation: function(orientation, fallback) {
|
validateOrientation: function(orientation, fallback) {
|
||||||
orientation = $.trim(orientation || '').toLowerCase();
|
orientation = $.trim(orientation || '').toLowerCase();
|
||||||
|
|
||||||
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
|
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
|
||||||
orientation = fallback;
|
orientation = fallback;
|
||||||
}
|
}
|
||||||
return orientation
|
|
||||||
|
return orientation;
|
||||||
},
|
},
|
||||||
|
|
||||||
processResponse: function (result, originalQuery, cacheKey) {
|
processResponse: function (result, originalQuery, cacheKey) {
|
||||||
@ -765,9 +770,9 @@
|
|||||||
activeItem,
|
activeItem,
|
||||||
selected = that.classes.selected,
|
selected = that.classes.selected,
|
||||||
container = $(that.suggestionsContainer),
|
container = $(that.suggestionsContainer),
|
||||||
children = container.children();
|
children = container.find('.' + that.classes.suggestion);
|
||||||
|
|
||||||
container.children('.' + selected).removeClass(selected);
|
container.find('.' + selected).removeClass(selected);
|
||||||
|
|
||||||
that.selectedIndex = index;
|
that.selectedIndex = index;
|
||||||
|
|
||||||
@ -897,7 +902,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create chainable jQuery plugin:
|
// Create chainable jQuery plugin:
|
||||||
$.fn.autocomplete = function (options, args) {
|
$.fn.autocomplete = $.fn.devbridgeAutocomplete = function (options, args) {
|
||||||
var dataKey = 'autocomplete';
|
var dataKey = 'autocomplete';
|
||||||
// If function invoked without argument return
|
// If function invoked without argument return
|
||||||
// instance of the first matched element:
|
// instance of the first matched element:
|
||||||
|
27
dist/jquery.autocomplete.min.js
vendored
27
dist/jquery.autocomplete.min.js
vendored
File diff suppressed because one or more lines are too long
69
gruntfile.js
Normal file
69
gruntfile.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
var pkg = grunt.file.readJSON('package.json');
|
||||||
|
|
||||||
|
var banner = [
|
||||||
|
'/**',
|
||||||
|
'* Ajax Autocomplete for jQuery, version ' + pkg.version,
|
||||||
|
'* (c) 2014 Tomas Kirda',
|
||||||
|
'*',
|
||||||
|
'* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.',
|
||||||
|
'* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete',
|
||||||
|
'*/'].join('\n') + '\n';
|
||||||
|
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig({
|
||||||
|
pkg: pkg,
|
||||||
|
uglify: {
|
||||||
|
options: {
|
||||||
|
banner: banner
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
src: 'src/jquery.autocomplete.js',
|
||||||
|
dest: 'dist/jquery.autocomplete.min.js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load the plugin that provides the "uglify" task.
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
|
|
||||||
|
// Default task(s).
|
||||||
|
grunt.registerTask('default', ['uglify']);
|
||||||
|
|
||||||
|
grunt.task.registerTask('build', 'Create release', function() {
|
||||||
|
var version = pkg.version
|
||||||
|
src = grunt.file.read('src/jquery.autocomplete.js').replace('%version%', version),
|
||||||
|
filePath = 'dist/jquery.autocomplete.js';
|
||||||
|
|
||||||
|
// Update not minimized release version:
|
||||||
|
console.log('Updating: ' + filePath);
|
||||||
|
grunt.file.write(filePath, src);
|
||||||
|
|
||||||
|
// Update plugin version:
|
||||||
|
filePath = 'devbridge-autocomplete.jquery.json';
|
||||||
|
src = grunt.file.readJSON(filePath);
|
||||||
|
|
||||||
|
if (src.version !== version){
|
||||||
|
src.version = version;
|
||||||
|
console.log('Updating: ' + filePath);
|
||||||
|
grunt.file.write(filePath, JSON.stringify(src, null, 4));
|
||||||
|
} else {
|
||||||
|
console.log('No updates for: ' + filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update bower version:
|
||||||
|
filePath = 'bower.json';
|
||||||
|
src = grunt.file.readJSON(filePath);
|
||||||
|
|
||||||
|
if (src.version !== version){
|
||||||
|
src.version = version;
|
||||||
|
console.log('Updating: ' + filePath);
|
||||||
|
grunt.file.write(filePath, JSON.stringify(src, null, 4));
|
||||||
|
} else {
|
||||||
|
console.log('No updates for: ' + filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
@ -8,5 +8,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jquery": ">=1.7"
|
"jquery": ">=1.7"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"grunt": "^0.4.5",
|
||||||
|
"grunt-contrib-uglify": "^0.5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Ajax Autocomplete for jQuery, version 1.2.11
|
* Ajax Autocomplete for jQuery, version %version%
|
||||||
* (c) 2014 Tomas Kirda
|
* (c) 2014 Tomas Kirda
|
||||||
*
|
*
|
||||||
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
||||||
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jslint browser: true, white: true, plusplus: true */
|
/*jslint browser: true, white: true, plusplus: true */
|
||||||
|
Loading…
Reference in New Issue
Block a user