user
This commit is contained in:
@ -2,12 +2,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>fpaste</title>
|
||||
<link rel="stylesheet" type="text/css" href="/css/jquery-ui.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/notifications.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/code.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/view.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/index.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/fonts.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/user.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -35,6 +37,7 @@
|
||||
|
||||
<script type="text/javascript" src="/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery.timeago.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="/js/main.js"></script>
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
@ -52,7 +55,113 @@
|
||||
str.year = "1 year";
|
||||
str.suffixFromNow = null;
|
||||
$("time.timeago").timeago();
|
||||
|
||||
$.widget("custom.combobox", {
|
||||
_create: function() {
|
||||
this.wrapper = $("<span>")
|
||||
.addClass("custom-combobox")
|
||||
.insertAfter(this.element);
|
||||
this.element.hide();
|
||||
this._createAutocomplete();
|
||||
this._createShowAllButton();
|
||||
},
|
||||
_createAutocomplete: function() {
|
||||
var selected = this.element.children(":selected"),
|
||||
value = selected.val() ? selected.text() : "";
|
||||
this.input = $("<input>")
|
||||
.appendTo(this.wrapper)
|
||||
.val(value)
|
||||
.attr("title", "")
|
||||
.addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
|
||||
.autocomplete({
|
||||
delay: 0,
|
||||
minLength: 0,
|
||||
source: $.proxy(this, "_source")
|
||||
})
|
||||
.tooltip({
|
||||
classes: {
|
||||
"ui-tooltip": "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"
|
||||
});
|
||||
},
|
||||
_createShowAllButton: function() {
|
||||
var input = this.input,
|
||||
wasOpen = false;
|
||||
$("<a>")
|
||||
.attr("tabIndex", -1)
|
||||
.attr("title", "Show All Items")
|
||||
.tooltip()
|
||||
.appendTo(this.wrapper)
|
||||
.button({
|
||||
icons: {
|
||||
primary: "ui-icon-triangle-1-s"
|
||||
},
|
||||
text: false
|
||||
})
|
||||
.removeClass("ui-corner-all")
|
||||
.addClass("custom-combobox-toggle ui-corner-right")
|
||||
.on("mousedown", function() {
|
||||
wasOpen = input.autocomplete("widget").is(":visible");
|
||||
})
|
||||
.on("click", function() {
|
||||
input.trigger("focus");
|
||||
if (wasOpen) return;
|
||||
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) {
|
||||
if (ui.item) return;
|
||||
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;
|
||||
}
|
||||
});
|
||||
if (valid) return;
|
||||
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.autocomplete("instance").term = "";
|
||||
},
|
||||
_destroy: function() {
|
||||
this.wrapper.remove();
|
||||
this.element.show();
|
||||
}
|
||||
});
|
||||
$("#lang").combobox();
|
||||
$("#toggle").on("click", function() {
|
||||
$("#lang").toggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user