mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Unminify using 1.5.323
Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
parent
4678528d00
commit
de6ac33ec1
289 changed files with 78483 additions and 54701 deletions
|
@ -1,64 +1,124 @@
|
|||
define(["layoutManager", "globalize", "require", "events", "browser", "alphaPicker", "emby-input", "flexStyles", "material-icons", "css!./searchfields"], function(layoutManager, globalize, require, events, browser, AlphaPicker) {
|
||||
"use strict";
|
||||
define(['layoutManager', 'globalize', 'require', 'events', 'browser', 'alphaPicker', 'emby-input', 'flexStyles', 'material-icons', 'css!./searchfields'], function (layoutManager, globalize, require, events, browser, AlphaPicker) {
|
||||
'use strict';
|
||||
|
||||
function onSearchTimeout() {
|
||||
var instance = this,
|
||||
value = instance.nextSearchValue;
|
||||
value = (value || "").trim(), events.trigger(instance, "search", [value])
|
||||
|
||||
var instance = this;
|
||||
var value = instance.nextSearchValue;
|
||||
|
||||
value = (value || '').trim();
|
||||
events.trigger(instance, 'search', [value]);
|
||||
}
|
||||
|
||||
function triggerSearch(instance, value) {
|
||||
instance.searchTimeout && clearTimeout(instance.searchTimeout), instance.nextSearchValue = value, instance.searchTimeout = setTimeout(onSearchTimeout.bind(instance), 400)
|
||||
|
||||
if (instance.searchTimeout) {
|
||||
clearTimeout(instance.searchTimeout);
|
||||
}
|
||||
|
||||
instance.nextSearchValue = value;
|
||||
instance.searchTimeout = setTimeout(onSearchTimeout.bind(instance), 400);
|
||||
}
|
||||
|
||||
function onAlphaValueClicked(e) {
|
||||
var value = e.detail.value,
|
||||
searchFieldsInstance = this,
|
||||
txtSearch = searchFieldsInstance.options.element.querySelector(".searchfields-txtSearch");
|
||||
if ("backspace" === value) {
|
||||
|
||||
var value = e.detail.value;
|
||||
var searchFieldsInstance = this;
|
||||
|
||||
var txtSearch = searchFieldsInstance.options.element.querySelector('.searchfields-txtSearch');
|
||||
|
||||
if (value === 'backspace') {
|
||||
|
||||
var val = txtSearch.value;
|
||||
txtSearch.value = val.length ? val.substring(0, val.length - 1) : ""
|
||||
} else txtSearch.value += value;
|
||||
txtSearch.dispatchEvent(new CustomEvent("input", {
|
||||
bubbles: !0
|
||||
}))
|
||||
txtSearch.value = val.length ? val.substring(0, val.length - 1) : '';
|
||||
|
||||
} else {
|
||||
txtSearch.value += value;
|
||||
}
|
||||
|
||||
txtSearch.dispatchEvent(new CustomEvent('input', {
|
||||
bubbles: true
|
||||
}));
|
||||
}
|
||||
|
||||
function initAlphaPicker(alphaPickerElement, instance) {
|
||||
|
||||
instance.alphaPicker = new AlphaPicker({
|
||||
element: alphaPickerElement,
|
||||
mode: "keyboard"
|
||||
}), alphaPickerElement.addEventListener("alphavalueclicked", onAlphaValueClicked.bind(instance))
|
||||
mode: 'keyboard'
|
||||
});
|
||||
|
||||
alphaPickerElement.addEventListener('alphavalueclicked', onAlphaValueClicked.bind(instance));
|
||||
}
|
||||
|
||||
function onSearchInput(e) {
|
||||
triggerSearch(this, e.target.value)
|
||||
|
||||
var value = e.target.value;
|
||||
var searchFieldsInstance = this;
|
||||
triggerSearch(searchFieldsInstance, value);
|
||||
}
|
||||
|
||||
function embed(elem, instance, options) {
|
||||
require(["text!./searchfields.template.html"], function(template) {
|
||||
var html = globalize.translateDocument(template, "sharedcomponents");
|
||||
(browser.tizen || browser.orsay) && (html = html.replace("<input ", "<input readonly ")), elem.innerHTML = html, elem.classList.add("searchFields");
|
||||
var txtSearch = elem.querySelector(".searchfields-txtSearch");
|
||||
if (layoutManager.tv) {
|
||||
var alphaPickerElement = elem.querySelector(".alphaPicker");
|
||||
elem.querySelector(".alphaPicker").classList.remove("hide"), initAlphaPicker(alphaPickerElement, instance)
|
||||
|
||||
require(['text!./searchfields.template.html'], function (template) {
|
||||
|
||||
var html = globalize.translateDocument(template, 'sharedcomponents');
|
||||
|
||||
if (browser.tizen || browser.orsay) {
|
||||
html = html.replace('<input ', '<input readonly ');
|
||||
}
|
||||
txtSearch.addEventListener("input", onSearchInput.bind(instance)), instance.focus()
|
||||
})
|
||||
|
||||
elem.innerHTML = html;
|
||||
|
||||
elem.classList.add('searchFields');
|
||||
|
||||
var txtSearch = elem.querySelector('.searchfields-txtSearch');
|
||||
|
||||
if (layoutManager.tv) {
|
||||
var alphaPickerElement = elem.querySelector('.alphaPicker');
|
||||
|
||||
elem.querySelector('.alphaPicker').classList.remove('hide');
|
||||
initAlphaPicker(alphaPickerElement, instance);
|
||||
}
|
||||
|
||||
txtSearch.addEventListener('input', onSearchInput.bind(instance));
|
||||
|
||||
instance.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function SearchFields(options) {
|
||||
this.options = options, embed(options.element, this, options)
|
||||
|
||||
this.options = options;
|
||||
embed(options.element, this, options);
|
||||
}
|
||||
return SearchFields.prototype.focus = function() {
|
||||
this.options.element.querySelector(".searchfields-txtSearch").focus()
|
||||
}, SearchFields.prototype.destroy = function() {
|
||||
|
||||
SearchFields.prototype.focus = function () {
|
||||
|
||||
this.options.element.querySelector('.searchfields-txtSearch').focus();
|
||||
};
|
||||
|
||||
SearchFields.prototype.destroy = function () {
|
||||
|
||||
var options = this.options;
|
||||
options && options.element.classList.remove("searchFields"), this.options = null;
|
||||
if (options) {
|
||||
options.element.classList.remove('searchFields');
|
||||
}
|
||||
this.options = null;
|
||||
|
||||
var alphaPicker = this.alphaPicker;
|
||||
alphaPicker && alphaPicker.destroy(), this.alphaPicker = null;
|
||||
if (alphaPicker) {
|
||||
alphaPicker.destroy();
|
||||
}
|
||||
this.alphaPicker = null;
|
||||
|
||||
var searchTimeout = this.searchTimeout;
|
||||
searchTimeout && clearTimeout(searchTimeout), this.searchTimeout = null, this.nextSearchValue = null
|
||||
}, SearchFields
|
||||
if (searchTimeout) {
|
||||
clearTimeout(searchTimeout);
|
||||
}
|
||||
this.searchTimeout = null;
|
||||
this.nextSearchValue = null;
|
||||
};
|
||||
|
||||
return SearchFields;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue