mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Updated materializeCSS to 0.98.1
This commit is contained in:
6
public/css/materialize.min.css
vendored
6
public/css/materialize.min.css
vendored
File diff suppressed because one or more lines are too long
4
public/dist/embed.min.js
vendored
4
public/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
10
public/dist/lib/materialize.min.js
vendored
10
public/dist/lib/materialize.min.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/main.min.js
vendored
8
public/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -134,175 +134,6 @@ $().ready(function(){
|
|||||||
} catch(error){
|
} catch(error){
|
||||||
Helper.log("Error with fetching GitHub commit info");
|
Helper.log("Error with fetching GitHub commit info");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******
|
|
||||||
|
|
||||||
MaterializeCSS fix for autocomplete
|
|
||||||
|
|
||||||
******/
|
|
||||||
|
|
||||||
$.fn.autocomplete = function (options) {
|
|
||||||
// Defaults
|
|
||||||
var defaults = {
|
|
||||||
data: {},
|
|
||||||
limit: Infinity,
|
|
||||||
onAutocomplete: null
|
|
||||||
};
|
|
||||||
|
|
||||||
options = $.extend(defaults, options);
|
|
||||||
|
|
||||||
return this.each(function() {
|
|
||||||
var $input = $(this);
|
|
||||||
var data = options.data,
|
|
||||||
count = 0,
|
|
||||||
activeIndex = -1,
|
|
||||||
oldVal,
|
|
||||||
$inputDiv = $input.closest('.input-field'); // Div to append on
|
|
||||||
|
|
||||||
// Check if data isn't empty
|
|
||||||
if (!$.isEmptyObject(data)) {
|
|
||||||
var $autocomplete = $('<ul class="autocomplete-content dropdown-content"></ul>');
|
|
||||||
var $oldAutocomplete;
|
|
||||||
|
|
||||||
// Append autocomplete element.
|
|
||||||
// Prevent double structure init.
|
|
||||||
if ($inputDiv.length) {
|
|
||||||
$oldAutocomplete = $inputDiv.children('.autocomplete-content.dropdown-content').first();
|
|
||||||
if (!$oldAutocomplete.length) {
|
|
||||||
$inputDiv.append($autocomplete); // Set ul in body
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$oldAutocomplete = $input.next('.autocomplete-content.dropdown-content');
|
|
||||||
if (!$oldAutocomplete.length) {
|
|
||||||
$input.after($autocomplete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($oldAutocomplete.length) {
|
|
||||||
$autocomplete = $oldAutocomplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Highlight partial match.
|
|
||||||
var highlight = function(string, $el) {
|
|
||||||
var img = $el.find('img');
|
|
||||||
var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""),
|
|
||||||
matchEnd = matchStart + string.length - 1,
|
|
||||||
beforeMatch = $el.text().slice(0, matchStart),
|
|
||||||
matchText = $el.text().slice(matchStart, matchEnd + 1),
|
|
||||||
afterMatch = $el.text().slice(matchEnd + 1);
|
|
||||||
$el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
|
|
||||||
if (img.length) {
|
|
||||||
$el.prepend(img);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reset current element position
|
|
||||||
var resetCurrentElement = function() {
|
|
||||||
activeIndex = -1;
|
|
||||||
$autocomplete.find('.active').removeClass('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform search
|
|
||||||
$input.off('keyup.autocomplete').on('keyup.autocomplete', function (e) {
|
|
||||||
// Reset count.
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
// Don't capture enter or arrow key usage.
|
|
||||||
if (e.which === 13 ||
|
|
||||||
e.which === 38 ||
|
|
||||||
e.which === 40) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var val = $input.val().toLowerCase();
|
|
||||||
|
|
||||||
// Check if the input isn't empty
|
|
||||||
if (oldVal !== val) {
|
|
||||||
$autocomplete.empty();
|
|
||||||
resetCurrentElement();
|
|
||||||
|
|
||||||
if (val !== '') {
|
|
||||||
for(var key in data) {
|
|
||||||
if (data.hasOwnProperty(key) &&
|
|
||||||
key.toLowerCase().indexOf(val) !== -1 &&
|
|
||||||
key.toLowerCase() !== val) {
|
|
||||||
// Break if past limit
|
|
||||||
if (count >= options.limit) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var autocompleteOption = $('<li></li>');
|
|
||||||
if (!!data[key]) {
|
|
||||||
autocompleteOption.append('<img src="'+ data[key] +'" class="right circle"><span>'+ key +'</span>');
|
|
||||||
} else {
|
|
||||||
autocompleteOption.append('<span>'+ key +'</span>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$autocomplete.append(autocompleteOption);
|
|
||||||
highlight(val, autocompleteOption);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update oldVal
|
|
||||||
oldVal = val;
|
|
||||||
});
|
|
||||||
|
|
||||||
$input.off('keydown.autocomplete').on('keydown.autocomplete', function (e) {
|
|
||||||
// Arrow keys and enter key usage
|
|
||||||
var keyCode = e.which,
|
|
||||||
liElement,
|
|
||||||
numItems = $autocomplete.children('li').length,
|
|
||||||
$active = $autocomplete.children('.active').first();
|
|
||||||
|
|
||||||
// select element on Enter
|
|
||||||
if (keyCode === 13 && activeIndex >= 0) {
|
|
||||||
liElement = $autocomplete.children('li').eq(activeIndex);
|
|
||||||
if (liElement.length) {
|
|
||||||
liElement.click();
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Capture up and down key
|
|
||||||
if ( keyCode === 38 || keyCode === 40 ) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (keyCode === 38 &&
|
|
||||||
activeIndex > 0) {
|
|
||||||
activeIndex--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyCode === 40 &&
|
|
||||||
activeIndex < (numItems - 1)) {
|
|
||||||
activeIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$active.removeClass('active');
|
|
||||||
if (activeIndex >= 0) {
|
|
||||||
$autocomplete.children('li').eq(activeIndex).addClass('active');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set input value
|
|
||||||
$autocomplete.on('click', 'li', function () {
|
|
||||||
var text = $(this).text().trim();
|
|
||||||
$input.val(text);
|
|
||||||
$input.trigger('change');
|
|
||||||
$autocomplete.empty();
|
|
||||||
resetCurrentElement();
|
|
||||||
|
|
||||||
// Handle onAutocomplete callback.
|
|
||||||
if (typeof(options.onAutocomplete) === "function") {
|
|
||||||
options.onAutocomplete.call(this, text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user