diff --git a/smash/web/api_urls.py b/smash/web/api_urls.py index e2edbc6da7c9199ad5cc17d09248b854f640e080..15e088c588272d0656c5c81f770317c7421c8e24 100644 --- a/smash/web/api_urls.py +++ b/smash/web/api_urls.py @@ -21,4 +21,5 @@ urlpatterns = [ url(r'countries$', api_views.countries, name='web.api.countries'), url(r'specializations$', api_views.specializations, name='web.api.specializations'), url(r'units$', api_views.units, name='web.api.units'), + url(r'referrals$', api_views.referrals, name='web.api.referrals'), ] diff --git a/smash/web/api_views.py b/smash/web/api_views.py index 2569471cd4400a8ee7e90effb75e42e18a244131..5b984fdeee1f42fc38095cf37cabc6bbe7b21d6a 100644 --- a/smash/web/api_views.py +++ b/smash/web/api_views.py @@ -6,26 +6,33 @@ from django.http import JsonResponse def cities(request): X = Subject.objects.all().values_list('city').distinct() return JsonResponse({ - "cities" : [x[0] for x in X] + "cities" : [x[0] for x in X if len(x) > 0] }) def countries(request): X = Subject.objects.all().values_list('country').distinct() return JsonResponse({ - "countries" : [x[0] for x in X] + "countries" : [x[0] for x in X if len(x) > 0] + }) + + +def referrals(request): + X = Subject.objects.all().values_list('referral').distinct() + return JsonResponse({ + "referrals" : [x[0] for x in X if len(x) > 0] }) def specializations(request): X = Worker.objects.all().values_list('specialization').distinct() return JsonResponse({ - "specializations" : [x[0] for x in X] + "specializations" : [x[0] for x in X if len(x) > 0] }) def units(request): X = Worker.objects.all().values_list('unit').distinct() return JsonResponse({ - "units" : [x[0] for x in X] + "units" : [x[0] for x in X if len(x) > 0] }) diff --git a/smash/web/models.py b/smash/web/models.py index 0ee99a4f9578a9d1d66d6465dd79fce58842ef7a..d877da37f5f0f78be65b5f25be7351fb2279df4e 100644 --- a/smash/web/models.py +++ b/smash/web/models.py @@ -171,6 +171,9 @@ class Item (models.Model): def __str__(self): return self.name + def __unicode__(self): + return self.name + class Room (models.Model): equipment = models.ManyToManyField(Item, @@ -199,6 +202,9 @@ class Room (models.Model): def __str__(self): return "%d %s %s" % (self.room_number, self.address, self.city) + def __unicode__(self): + return "%d %s %s" % (self.room_number, self.address, self.city) + class AppointmentType (models.Model): required_equipment = models.ManyToManyField(Item, @@ -230,6 +236,9 @@ class AppointmentType (models.Model): def __str__(self): return self.apCode + def __unicode__(self): + return self.apCode + class Worker (models.Model): languages = models.ManyToManyField(Language, @@ -276,8 +285,6 @@ class Worker (models.Model): return True return False - def __str__(self): - return "%s %s" % (self.first_name, self.last_name) @staticmethod def get_details(the_user): @@ -293,6 +300,12 @@ class Worker (models.Model): # https://docs.djangoproject.com/en/1.10/topics/db/models/#field-options return (str(person[0]), person[0].get_role_display()) + def __str__(self): + return "%s %s" % (self.first_name, self.last_name) + + def __unicode__(self): + return "%s %s" % (self.first_name, self.last_name) + class FlyingTeam(models.Model): doctor = models.ForeignKey(Worker, related_name='FlyingTeamDoctor', @@ -314,6 +327,9 @@ class FlyingTeam(models.Model): def __str__(self): return "%s %s %s" % (self.doctor.last_name, self.nurse.last_name, self.psychologist.last_name) + def __unicode__(self): + return "%s %s %s" % (self.doctor.last_name, self.nurse.last_name, self.psychologist.last_name) + class Avaibility(models.Model): person = models.ForeignKey(Worker, on_delete=models.CASCADE, @@ -336,6 +352,9 @@ class Avaibility(models.Model): def __str__(self): return "%d %s %s" % (self.day_number, self.person.last_name, self.person.first_name) + def __unicode__(self): + return "%d %s %s" % (self.day_number, self.person.last_name, self.person.first_name) + class Holiday(models.Model): person = models.ForeignKey(Worker, on_delete=models.CASCADE, @@ -351,6 +370,9 @@ class Holiday(models.Model): def __str__(self): return "%s %s" % (self.person.first_name, self.person.last_name) + def __unicode__(self): + return "%s %s" % (self.person.first_name, self.person.last_name) + class Appointment(models.Model): flying_team = models.ForeignKey(FlyingTeam, diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/LICENSE b/smash/web/static/AdminLTE/plugins/awesomplete/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ee7698757ae3b051e355508114132bfca8f41e4e --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Lea Verou + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css new file mode 100644 index 0000000000000000000000000000000000000000..d8fed9dc756c065433a86ff8ef674e0b78b1b647 --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css @@ -0,0 +1,104 @@ +.awesomplete [hidden] { + display: none; +} + +.awesomplete .visually-hidden { + position: absolute; + clip: rect(0, 0, 0, 0); +} + +.awesomplete { + /* display: inline-block; */ + position: relative; +} + +.awesomplete > input { + display: block; +} + +.awesomplete > ul { + position: absolute; + left: 0; + z-index: 1; + min-width: 100%; + box-sizing: border-box; + list-style: none; + padding: 0; + margin: 0; + background: #fff; +} + +.awesomplete > ul:empty { + display: none; +} + +.awesomplete > ul { + border-radius: .3em; + margin: .2em 0 0; + background: hsla(0,0%,100%,.9); + background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8)); + border: 1px solid rgba(0,0,0,.3); + box-shadow: .05em .2em .6em rgba(0,0,0,.2); + text-shadow: none; +} + +@supports (transform: scale(0)) { + .awesomplete > ul { + transition: .3s cubic-bezier(.4,.2,.5,1.4); + transform-origin: 1.43em -.43em; + } + + .awesomplete > ul[hidden], + .awesomplete > ul:empty { + opacity: 0; + transform: scale(0); + display: block; + transition-timing-function: ease; + } +} + + /* Pointer */ + .awesomplete > ul:before { + content: ""; + position: absolute; + top: -.43em; + left: 1em; + width: 0; height: 0; + padding: .4em; + background: white; + border: inherit; + border-right: 0; + border-bottom: 0; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + } + + .awesomplete > ul > li { + position: relative; + padding: .2em .5em; + cursor: pointer; + } + + .awesomplete > ul > li:hover { + background: hsl(200, 40%, 80%); + color: black; + } + + .awesomplete > ul > li[aria-selected="true"] { + background: hsl(205, 40%, 40%); + color: white; + } + + .awesomplete mark { + background: hsl(65, 100%, 50%); + } + + .awesomplete li:hover mark { + background: hsl(68, 100%, 41%); + } + + .awesomplete li[aria-selected="true"] mark { + background: hsl(86, 100%, 21%); + color: inherit; + } +/*# sourceMappingURL=awesomplete.css.map */ diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css.map b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css.map new file mode 100644 index 0000000000000000000000000000000000000000..97dafae135ab79fdcdfe5f5720371f2edad52903 --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["awesomplete.base.css","awesomplete.theme.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"awesomplete.css","sourcesContent":[".awesomplete [hidden] {\n display: none;\n}\n\n.awesomplete .visually-hidden {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n}\n\n.awesomplete {\n display: inline-block;\n position: relative;\n}\n\n.awesomplete > input {\n display: block;\n}\n\n.awesomplete > ul {\n position: absolute;\n left: 0;\n z-index: 1;\n min-width: 100%;\n box-sizing: border-box;\n list-style: none;\n padding: 0;\n margin: 0;\n background: #fff;\n}\n\n.awesomplete > ul:empty {\n display: none;\n}\n",".awesomplete > ul {\n\tborder-radius: .3em;\n\tmargin: .2em 0 0;\n\tbackground: hsla(0,0%,100%,.9);\n\tbackground: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));\n\tborder: 1px solid rgba(0,0,0,.3);\n\tbox-shadow: .05em .2em .6em rgba(0,0,0,.2);\n\ttext-shadow: none;\n}\n\n@supports (transform: scale(0)) {\n\t.awesomplete > ul {\n\t\ttransition: .3s cubic-bezier(.4,.2,.5,1.4);\n\t\ttransform-origin: 1.43em -.43em;\n\t}\n\t\n\t.awesomplete > ul[hidden],\n\t.awesomplete > ul:empty {\n\t\topacity: 0;\n\t\ttransform: scale(0);\n\t\tdisplay: block;\n\t\ttransition-timing-function: ease;\n\t}\n}\n\n\t/* Pointer */\n\t.awesomplete > ul:before {\n\t\tcontent: \"\";\n\t\tposition: absolute;\n\t\ttop: -.43em;\n\t\tleft: 1em;\n\t\twidth: 0; height: 0;\n\t\tpadding: .4em;\n\t\tbackground: white;\n\t\tborder: inherit;\n\t\tborder-right: 0;\n\t\tborder-bottom: 0;\n\t\t-webkit-transform: rotate(45deg);\n\t\ttransform: rotate(45deg);\n\t}\n\n\t.awesomplete > ul > li {\n\t\tposition: relative;\n\t\tpadding: .2em .5em;\n\t\tcursor: pointer;\n\t}\n\t\n\t.awesomplete > ul > li:hover {\n\t\tbackground: hsl(200, 40%, 80%);\n\t\tcolor: black;\n\t}\n\t\n\t.awesomplete > ul > li[aria-selected=\"true\"] {\n\t\tbackground: hsl(205, 40%, 40%);\n\t\tcolor: white;\n\t}\n\t\n\t\t.awesomplete mark {\n\t\t\tbackground: hsl(65, 100%, 50%);\n\t\t}\n\t\t\n\t\t.awesomplete li:hover mark {\n\t\t\tbackground: hsl(68, 100%, 41%);\n\t\t}\n\t\t\n\t\t.awesomplete li[aria-selected=\"true\"] mark {\n\t\t\tbackground: hsl(86, 100%, 21%);\n\t\t\tcolor: inherit;\n\t\t}"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.js b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.js new file mode 100644 index 0000000000000000000000000000000000000000..fc9d803c108b738210c8204639d9d66c5ecd9e46 --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.js @@ -0,0 +1,454 @@ +/** + * Simple, lightweight, usable local autocomplete library for modern browsers + * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P + * @author Lea Verou http://leaverou.github.io/awesomplete + * MIT license + */ + +(function () { + +var _ = function (input, o) { + var me = this; + + // Setup + + this.isOpened = false; + + this.input = $(input); + this.input.setAttribute("autocomplete", "off"); + this.input.setAttribute("aria-autocomplete", "list"); + + o = o || {}; + + configure(this, { + minChars: 2, + maxItems: 10, + autoFirst: false, + data: _.DATA, + filter: _.FILTER_CONTAINS, + sort: o.sort === false ? false : _.SORT_BYLENGTH, + item: _.ITEM, + replace: _.REPLACE + }, o); + + this.index = -1; + + // Create necessary elements + + this.container = $.create("div", { + className: "awesomplete", + around: input + }); + + this.ul = $.create("ul", { + hidden: "hidden", + inside: this.container + }); + + this.status = $.create("span", { + className: "visually-hidden", + role: "status", + "aria-live": "assertive", + "aria-relevant": "additions", + inside: this.container + }); + + // Bind events + + $.bind(this.input, { + "input": this.evaluate.bind(this), + "blur": this.close.bind(this, { reason: "blur" }), + "keydown": function(evt) { + var c = evt.keyCode; + + // If the dropdown `ul` is in view, then act on keydown for the following keys: + // Enter / Esc / Up / Down + if(me.opened) { + if (c === 13 && me.selected) { // Enter + evt.preventDefault(); + me.select(); + } + else if (c === 27) { // Esc + me.close({ reason: "esc" }); + } + else if (c === 38 || c === 40) { // Down/Up arrow + evt.preventDefault(); + me[c === 38? "previous" : "next"](); + } + } + } + }); + + $.bind(this.input.form, {"submit": this.close.bind(this, { reason: "submit" })}); + + $.bind(this.ul, {"mousedown": function(evt) { + var li = evt.target; + + if (li !== this) { + + while (li && !/li/i.test(li.nodeName)) { + li = li.parentNode; + } + + if (li && evt.button === 0) { // Only select on left click + evt.preventDefault(); + me.select(li, evt.target); + } + } + }}); + + if (this.input.hasAttribute("list")) { + this.list = "#" + this.input.getAttribute("list"); + this.input.removeAttribute("list"); + } + else { + this.list = this.input.getAttribute("data-list") || o.list || []; + } + + _.all.push(this); +}; + +_.prototype = { + set list(list) { + if (Array.isArray(list)) { + this._list = list; + } + else if (typeof list === "string" && list.indexOf(",") > -1) { + this._list = list.split(/\s*,\s*/); + } + else { // Element or CSS selector + list = $(list); + + if (list && list.children) { + var items = []; + slice.apply(list.children).forEach(function (el) { + if (!el.disabled) { + var text = el.textContent.trim(); + var value = el.value || text; + var label = el.label || text; + if (value !== "") { + items.push({ label: label, value: value }); + } + } + }); + this._list = items; + } + } + + if (document.activeElement === this.input) { + this.evaluate(); + } + }, + + get selected() { + return this.index > -1; + }, + + get opened() { + return this.isOpened; + }, + + close: function (o) { + if (!this.opened) { + return; + } + + this.ul.setAttribute("hidden", ""); + this.isOpened = false; + this.index = -1; + + $.fire(this.input, "awesomplete-close", o || {}); + }, + + open: function () { + this.ul.removeAttribute("hidden"); + this.isOpened = true; + + if (this.autoFirst && this.index === -1) { + this.goto(0); + } + + $.fire(this.input, "awesomplete-open"); + }, + + next: function () { + var count = this.ul.children.length; + this.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) ); + }, + + previous: function () { + var count = this.ul.children.length; + var pos = this.index - 1; + + this.goto(this.selected && pos !== -1 ? pos : count - 1); + }, + + // Should not be used, highlights specific item without any checks! + goto: function (i) { + var lis = this.ul.children; + + if (this.selected) { + lis[this.index].setAttribute("aria-selected", "false"); + } + + this.index = i; + + if (i > -1 && lis.length > 0) { + lis[i].setAttribute("aria-selected", "true"); + this.status.textContent = lis[i].textContent; + + // scroll to highlighted element in case parent's height is fixed + this.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight; + + $.fire(this.input, "awesomplete-highlight", { + text: this.suggestions[this.index] + }); + } + }, + + select: function (selected, origin) { + if (selected) { + this.index = $.siblingIndex(selected); + } else { + selected = this.ul.children[this.index]; + } + + if (selected) { + var suggestion = this.suggestions[this.index]; + + var allowed = $.fire(this.input, "awesomplete-select", { + text: suggestion, + origin: origin || selected + }); + + if (allowed) { + this.replace(suggestion); + this.close({ reason: "select" }); + $.fire(this.input, "awesomplete-selectcomplete", { + text: suggestion + }); + } + } + }, + + evaluate: function() { + var me = this; + var value = this.input.value; + + if (value.length >= this.minChars && this._list.length > 0) { + this.index = -1; + // Populate list with options that match + this.ul.innerHTML = ""; + + this.suggestions = this._list + .map(function(item) { + return new Suggestion(me.data(item, value)); + }) + .filter(function(item) { + return me.filter(item, value); + }); + + if (this.sort !== false) { + this.suggestions = this.suggestions.sort(this.sort); + } + + this.suggestions = this.suggestions.slice(0, this.maxItems); + + this.suggestions.forEach(function(text) { + me.ul.appendChild(me.item(text, value)); + }); + + if (this.ul.children.length === 0) { + this.close({ reason: "nomatches" }); + } else { + this.open(); + } + } + else { + this.close({ reason: "nomatches" }); + } + } +}; + +// Static methods/properties + +_.all = []; + +_.FILTER_CONTAINS = function (text, input) { + return RegExp($.regExpEscape(input.trim()), "i").test(text); +}; + +_.FILTER_STARTSWITH = function (text, input) { + return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text); +}; + +_.SORT_BYLENGTH = function (a, b) { + if (a.length !== b.length) { + return a.length - b.length; + } + + return a < b? -1 : 1; +}; + +_.ITEM = function (text, input) { + var html = input.trim() === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>"); + return $.create("li", { + innerHTML: html, + "aria-selected": "false" + }); +}; + +_.REPLACE = function (text) { + this.input.value = text.value; +}; + +_.DATA = function (item/*, input*/) { return item; }; + +// Private functions + +function Suggestion(data) { + var o = Array.isArray(data) + ? { label: data[0], value: data[1] } + : typeof data === "object" && "label" in data && "value" in data ? data : { label: data, value: data }; + + this.label = o.label || o.value; + this.value = o.value; +} +Object.defineProperty(Suggestion.prototype = Object.create(String.prototype), "length", { + get: function() { return this.label.length; } +}); +Suggestion.prototype.toString = Suggestion.prototype.valueOf = function () { + return "" + this.label; +}; + +function configure(instance, properties, o) { + for (var i in properties) { + var initial = properties[i], + attrValue = instance.input.getAttribute("data-" + i.toLowerCase()); + + if (typeof initial === "number") { + instance[i] = parseInt(attrValue); + } + else if (initial === false) { // Boolean options must be false by default anyway + instance[i] = attrValue !== null; + } + else if (initial instanceof Function) { + instance[i] = null; + } + else { + instance[i] = attrValue; + } + + if (!instance[i] && instance[i] !== 0) { + instance[i] = (i in o)? o[i] : initial; + } + } +} + +// Helpers + +var slice = Array.prototype.slice; + +function $(expr, con) { + return typeof expr === "string"? (con || document).querySelector(expr) : expr || null; +} + +function $$(expr, con) { + return slice.call((con || document).querySelectorAll(expr)); +} + +$.create = function(tag, o) { + var element = document.createElement(tag); + + for (var i in o) { + var val = o[i]; + + if (i === "inside") { + $(val).appendChild(element); + } + else if (i === "around") { + var ref = $(val); + ref.parentNode.insertBefore(element, ref); + element.appendChild(ref); + } + else if (i in element) { + element[i] = val; + } + else { + element.setAttribute(i, val); + } + } + + return element; +}; + +$.bind = function(element, o) { + if (element) { + for (var event in o) { + var callback = o[event]; + + event.split(/\s+/).forEach(function (event) { + element.addEventListener(event, callback); + }); + } + } +}; + +$.fire = function(target, type, properties) { + var evt = document.createEvent("HTMLEvents"); + + evt.initEvent(type, true, true ); + + for (var j in properties) { + evt[j] = properties[j]; + } + + return target.dispatchEvent(evt); +}; + +$.regExpEscape = function (s) { + return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); +}; + +$.siblingIndex = function (el) { + /* eslint-disable no-cond-assign */ + for (var i = 0; el = el.previousElementSibling; i++); + return i; +}; + +// Initialization + +function init() { + $$("input.awesomplete").forEach(function (input) { + new _(input); + }); +} + +// Are we in a browser? Check for Document constructor +if (typeof Document !== "undefined") { + // DOM already loaded? + if (document.readyState !== "loading") { + init(); + } + else { + // Wait for it + document.addEventListener("DOMContentLoaded", init); + } +} + +_.$ = $; +_.$$ = $$; + +// Make sure to export Awesomplete on self when in a browser +if (typeof self !== "undefined") { + self.Awesomplete = _; +} + +// Expose Awesomplete as a CJS module +if (typeof module === "object" && module.exports) { + module.exports = _; +} + +return _; + +}()); diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js new file mode 100644 index 0000000000000000000000000000000000000000..c0faecf60bf2b754449cf36b665cc230a42e44da --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js @@ -0,0 +1,3 @@ +// Awesomplete - Lea Verou - MIT license +!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):s===!1?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;this.isOpened=!1,this.input=i(t),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-autocomplete","list"),n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:r.SORT_BYLENGTH,item:r.ITEM,replace:r.REPLACE},n),this.index=-1,this.container=i.create("div",{className:"awesomplete",around:t}),this.ul=i.create("ul",{hidden:"hidden",inside:this.container}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-relevant":"additions",inside:this.container}),i.bind(this.input,{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select()):27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}}),i.bind(this.input.form,{submit:this.close.bind(this,{reason:"submit"})}),i.bind(this.ul,{mousedown:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target))}}}),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if(t=i(t),t&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.ul.removeAttribute("hidden"),this.isOpened=!0,this.autoFirst&&this.index===-1&&this.goto(0),i.fire(this.input,"awesomplete-open")},next:function(){var t=this.ul.children.length;this.goto(this.index<t-1?this.index+1:t?0:-1)},previous:function(){var t=this.ul.children.length,e=this.index-1;this.goto(this.selected&&e!==-1?e:t-1)},goto:function(t){var e=this.ul.children;this.selected&&e[this.index].setAttribute("aria-selected","false"),this.index=t,t>-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var n=this.suggestions[this.index],s=i.fire(this.input,"awesomplete-select",{text:n,origin:e||t});s&&(this.replace(n),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}).sort(this.sort).slice(0,this.maxItems),this.suggestions.forEach(function(t){e.ul.appendChild(e.item(t,i))}),0===this.ul.children.length?this.close({reason:"nomatches"}):this.open()):this.close({reason:"nomatches"})}},r.all=[],r.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},r.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},r.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t<e?-1:1},r.ITEM=function(t,e){var n=""===e?t:t.replace(RegExp(i.regExpEscape(e.trim()),"gi"),"<mark>$&</mark>");return i.create("li",{innerHTML:n,"aria-selected":"false"})},r.REPLACE=function(t){this.input.value=t.value},r.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var o=Array.prototype.slice;return i.create=function(t,e){var n=document.createElement(t);for(var s in e){var r=e[s];if("inside"===s)i(r).appendChild(n);else if("around"===s){var o=i(r);o.parentNode.insertBefore(n,o),n.appendChild(o)}else s in n?n[s]=r:n.setAttribute(s,r)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),r.$=i,r.$$=n,"undefined"!=typeof self&&(self.Awesomplete=r),"object"==typeof module&&module.exports&&(module.exports=r),r}(); +//# sourceMappingURL=awesomplete.min.js.map diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js.map b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js.map new file mode 100644 index 0000000000000000000000000000000000000000..435391aa608831528cbad3310776bd25bae702a5 --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["awesomplete.js"],"names":["Suggestion","data","o","Array","isArray","label","value","this","configure","instance","properties","i","initial","attrValue","input","getAttribute","toLowerCase","parseInt","Function","$","expr","con","document","querySelector","$$","slice","call","querySelectorAll","init","forEach","_","me","isOpened","setAttribute","minChars","maxItems","autoFirst","DATA","filter","FILTER_CONTAINS","sort","SORT_BYLENGTH","item","ITEM","replace","REPLACE","index","container","create","className","around","ul","hidden","inside","status","role","aria-live","aria-relevant","bind","evaluate","blur","close","reason","keydown","evt","c","keyCode","opened","selected","preventDefault","select","form","submit","mousedown","li","target","test","nodeName","parentNode","button","hasAttribute","list","removeAttribute","all","push","prototype","_list","indexOf","split","children","items","apply","el","disabled","text","textContent","trim","activeElement","fire","open","goto","next","count","length","previous","pos","lis","suggestions","origin","siblingIndex","suggestion","allowed","innerHTML","map","appendChild","RegExp","regExpEscape","FILTER_STARTSWITH","a","b","html","aria-selected","Object","defineProperty","String","get","toString","valueOf","tag","element","createElement","val","ref","insertBefore","event","callback","addEventListener","type","createEvent","initEvent","j","dispatchEvent","s","previousElementSibling","Document","readyState","self","Awesomplete","module","exports"],"mappings":";CAOC,WAsSD,QAASA,GAAWC,GACnB,GAAIC,GAAIC,MAAMC,QAAQH,IAChBI,MAAOJ,EAAK,GAAIK,MAAOL,EAAK,IACd,gBAATA,IAAqB,SAAWA,IAAQ,SAAWA,GAAOA,GAASI,MAAOJ,EAAMK,MAAOL,EAElGM,MAAKF,MAAQH,EAAEG,OAASH,EAAEI,MAC1BC,KAAKD,MAAQJ,EAAEI,MAShB,QAASE,GAAUC,EAAUC,EAAYR,GACxC,IAAK,GAAIS,KAAKD,GAAY,CACzB,GAAIE,GAAUF,EAAWC,GACrBE,EAAYJ,EAASK,MAAMC,aAAa,QAAUJ,EAAEK,cAEjC,iBAAZJ,GACVH,EAASE,GAAKM,SAASJ,GAEfD,KAAY,EACpBH,EAASE,GAAmB,OAAdE,EAEND,YAAmBM,UAC3BT,EAASE,GAAK,KAGdF,EAASE,GAAKE,EAGVJ,EAASE,IAAsB,IAAhBF,EAASE,KAC5BF,EAASE,GAAMA,IAAKT,GAAIA,EAAES,GAAKC,IASlC,QAASO,GAAEC,EAAMC,GAChB,MAAuB,gBAATD,IAAoBC,GAAOC,UAAUC,cAAcH,GAAQA,GAAQ,KAGlF,QAASI,GAAGJ,EAAMC,GACjB,MAAOI,GAAMC,MAAML,GAAOC,UAAUK,iBAAiBP,IAgEtD,QAASQ,KACRJ,EAAG,qBAAqBK,QAAQ,SAAUf,GACzC,GAAIgB,GAAEhB,KAtZR,GAAIgB,GAAI,S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EAAGmD,uBAAwBpI,KAChD,MAAOA,IAYgB,mBAAbqI,YAEkB,YAAxB1H,SAAS2H,WACZrH,IAIAN,SAASkH,iBAAiB,mBAAoB5G,IAIhDE,EAAEX,EAAIA,EACNW,EAAEN,GAAKA,EAGa,mBAAT0H,QACVA,KAAKC,YAAcrH,GAIE,gBAAXsH,SAAuBA,OAAOC,UACxCD,OAAOC,QAAUvH,GAGXA","file":"awesomplete.min.js","sourcesContent":["/**\n * Simple, lightweight, usable local autocomplete library for modern browsers\n * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P\n * @author Lea Verou http://leaverou.github.io/awesomplete\n * MIT license\n */\n\n(function () {\n\nvar _ = function (input, o) {\n\tvar me = this;\n\n\t// Setup\n\n\tthis.isOpened = false;\n\n\tthis.input = $(input);\n\tthis.input.setAttribute(\"autocomplete\", \"off\");\n\tthis.input.setAttribute(\"aria-autocomplete\", \"list\");\n\n\to = o || {};\n\n\tconfigure(this, {\n\t\tminChars: 2,\n\t\tmaxItems: 10,\n\t\tautoFirst: false,\n\t\tdata: _.DATA,\n\t\tfilter: _.FILTER_CONTAINS,\n\t\tsort: _.SORT_BYLENGTH,\n\t\titem: _.ITEM,\n\t\treplace: _.REPLACE\n\t}, o);\n\n\tthis.index = -1;\n\n\t// Create necessary elements\n\n\tthis.container = $.create(\"div\", {\n\t\tclassName: \"awesomplete\",\n\t\taround: input\n\t});\n\n\tthis.ul = $.create(\"ul\", {\n\t\thidden: \"hidden\",\n\t\tinside: this.container\n\t});\n\n\tthis.status = $.create(\"span\", {\n\t\tclassName: \"visually-hidden\",\n\t\trole: \"status\",\n\t\t\"aria-live\": \"assertive\",\n\t\t\"aria-relevant\": \"additions\",\n\t\tinside: this.container\n\t});\n\n\t// Bind events\n\n\t$.bind(this.input, {\n\t\t\"input\": this.evaluate.bind(this),\n\t\t\"blur\": this.close.bind(this, { reason: \"blur\" }),\n\t\t\"keydown\": function(evt) {\n\t\t\tvar c = evt.keyCode;\n\n\t\t\t// If the dropdown `ul` is in view, then act on keydown for the following keys:\n\t\t\t// Enter / Esc / Up / Down\n\t\t\tif(me.opened) {\n\t\t\t\tif (c === 13 && me.selected) { // Enter\n\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\tme.select();\n\t\t\t\t}\n\t\t\t\telse if (c === 27) { // Esc\n\t\t\t\t\tme.close({ reason: \"esc\" });\n\t\t\t\t}\n\t\t\t\telse if (c === 38 || c === 40) { // Down/Up arrow\n\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\tme[c === 38? \"previous\" : \"next\"]();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t$.bind(this.input.form, {\"submit\": this.close.bind(this, { reason: \"submit\" })});\n\n\t$.bind(this.ul, {\"mousedown\": function(evt) {\n\t\tvar li = evt.target;\n\n\t\tif (li !== this) {\n\n\t\t\twhile (li && !/li/i.test(li.nodeName)) {\n\t\t\t\tli = li.parentNode;\n\t\t\t}\n\n\t\t\tif (li && evt.button === 0) { // Only select on left click\n\t\t\t\tevt.preventDefault();\n\t\t\t\tme.select(li, evt.target);\n\t\t\t}\n\t\t}\n\t}});\n\n\tif (this.input.hasAttribute(\"list\")) {\n\t\tthis.list = \"#\" + this.input.getAttribute(\"list\");\n\t\tthis.input.removeAttribute(\"list\");\n\t}\n\telse {\n\t\tthis.list = this.input.getAttribute(\"data-list\") || o.list || [];\n\t}\n\n\t_.all.push(this);\n};\n\n_.prototype = {\n\tset list(list) {\n\t\tif (Array.isArray(list)) {\n\t\t\tthis._list = list;\n\t\t}\n\t\telse if (typeof list === \"string\" && list.indexOf(\",\") > -1) {\n\t\t\t\tthis._list = list.split(/\\s*,\\s*/);\n\t\t}\n\t\telse { // Element or CSS selector\n\t\t\tlist = $(list);\n\n\t\t\tif (list && list.children) {\n\t\t\t\tvar items = [];\n\t\t\t\tslice.apply(list.children).forEach(function (el) {\n\t\t\t\t\tif (!el.disabled) {\n\t\t\t\t\t\tvar text = el.textContent.trim();\n\t\t\t\t\t\tvar value = el.value || text;\n\t\t\t\t\t\tvar label = el.label || text;\n\t\t\t\t\t\tif (value !== \"\") {\n\t\t\t\t\t\t\titems.push({ label: label, value: value });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis._list = items;\n\t\t\t}\n\t\t}\n\n\t\tif (document.activeElement === this.input) {\n\t\t\tthis.evaluate();\n\t\t}\n\t},\n\n\tget selected() {\n\t\treturn this.index > -1;\n\t},\n\n\tget opened() {\n\t\treturn this.isOpened;\n\t},\n\n\tclose: function (o) {\n\t\tif (!this.opened) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ul.setAttribute(\"hidden\", \"\");\n\t\tthis.isOpened = false;\n\t\tthis.index = -1;\n\n\t\t$.fire(this.input, \"awesomplete-close\", o || {});\n\t},\n\n\topen: function () {\n\t\tthis.ul.removeAttribute(\"hidden\");\n\t\tthis.isOpened = true;\n\n\t\tif (this.autoFirst && this.index === -1) {\n\t\t\tthis.goto(0);\n\t\t}\n\n\t\t$.fire(this.input, \"awesomplete-open\");\n\t},\n\n\tnext: function () {\n\t\tvar count = this.ul.children.length;\n\t\tthis.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) );\n\t},\n\n\tprevious: function () {\n\t\tvar count = this.ul.children.length;\n\t\tvar pos = this.index - 1;\n\n\t\tthis.goto(this.selected && pos !== -1 ? pos : count - 1);\n\t},\n\n\t// Should not be used, highlights specific item without any checks!\n\tgoto: function (i) {\n\t\tvar lis = this.ul.children;\n\n\t\tif (this.selected) {\n\t\t\tlis[this.index].setAttribute(\"aria-selected\", \"false\");\n\t\t}\n\n\t\tthis.index = i;\n\n\t\tif (i > -1 && lis.length > 0) {\n\t\t\tlis[i].setAttribute(\"aria-selected\", \"true\");\n\t\t\tthis.status.textContent = lis[i].textContent;\n\n\t\t\t$.fire(this.input, \"awesomplete-highlight\", {\n\t\t\t\ttext: this.suggestions[this.index]\n\t\t\t});\n\t\t}\n\t},\n\n\tselect: function (selected, origin) {\n\t\tif (selected) {\n\t\t\tthis.index = $.siblingIndex(selected);\n\t\t} else {\n\t\t\tselected = this.ul.children[this.index];\n\t\t}\n\n\t\tif (selected) {\n\t\t\tvar suggestion = this.suggestions[this.index];\n\n\t\t\tvar allowed = $.fire(this.input, \"awesomplete-select\", {\n\t\t\t\ttext: suggestion,\n\t\t\t\torigin: origin || selected\n\t\t\t});\n\n\t\t\tif (allowed) {\n\t\t\t\tthis.replace(suggestion);\n\t\t\t\tthis.close({ reason: \"select\" });\n\t\t\t\t$.fire(this.input, \"awesomplete-selectcomplete\", {\n\t\t\t\t\ttext: suggestion\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n\n\tevaluate: function() {\n\t\tvar me = this;\n\t\tvar value = this.input.value;\n\n\t\tif (value.length >= this.minChars && this._list.length > 0) {\n\t\t\tthis.index = -1;\n\t\t\t// Populate list with options that match\n\t\t\tthis.ul.innerHTML = \"\";\n\n\t\t\tthis.suggestions = this._list\n\t\t\t\t.map(function(item) {\n\t\t\t\t\treturn new Suggestion(me.data(item, value));\n\t\t\t\t})\n\t\t\t\t.filter(function(item) {\n\t\t\t\t\treturn me.filter(item, value);\n\t\t\t\t})\n\t\t\t\t.sort(this.sort)\n\t\t\t\t.slice(0, this.maxItems);\n\n\t\t\tthis.suggestions.forEach(function(text) {\n\t\t\t\t\tme.ul.appendChild(me.item(text, value));\n\t\t\t\t});\n\n\t\t\tif (this.ul.children.length === 0) {\n\t\t\t\tthis.close({ reason: \"nomatches\" });\n\t\t\t} else {\n\t\t\t\tthis.open();\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.close({ reason: \"nomatches\" });\n\t\t}\n\t}\n};\n\n// Static methods/properties\n\n_.all = [];\n\n_.FILTER_CONTAINS = function (text, input) {\n\treturn RegExp($.regExpEscape(input.trim()), \"i\").test(text);\n};\n\n_.FILTER_STARTSWITH = function (text, input) {\n\treturn RegExp(\"^\" + $.regExpEscape(input.trim()), \"i\").test(text);\n};\n\n_.SORT_BYLENGTH = function (a, b) {\n\tif (a.length !== b.length) {\n\t\treturn a.length - b.length;\n\t}\n\n\treturn a < b? -1 : 1;\n};\n\n_.ITEM = function (text, input) {\n\tvar html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), \"gi\"), \"<mark>$&</mark>\");\n\treturn $.create(\"li\", {\n\t\tinnerHTML: html,\n\t\t\"aria-selected\": \"false\"\n\t});\n};\n\n_.REPLACE = function (text) {\n\tthis.input.value = text.value;\n};\n\n_.DATA = function (item/*, input*/) { return item; };\n\n// Private functions\n\nfunction Suggestion(data) {\n\tvar o = Array.isArray(data)\n\t ? { label: data[0], value: data[1] }\n\t : typeof data === \"object\" && \"label\" in data && \"value\" in data ? data : { label: data, value: data };\n\n\tthis.label = o.label || o.value;\n\tthis.value = o.value;\n}\nObject.defineProperty(Suggestion.prototype = Object.create(String.prototype), \"length\", {\n\tget: function() { return this.label.length; }\n});\nSuggestion.prototype.toString = Suggestion.prototype.valueOf = function () {\n\treturn \"\" + this.label;\n};\n\nfunction configure(instance, properties, o) {\n\tfor (var i in properties) {\n\t\tvar initial = properties[i],\n\t\t attrValue = instance.input.getAttribute(\"data-\" + i.toLowerCase());\n\n\t\tif (typeof initial === \"number\") {\n\t\t\tinstance[i] = parseInt(attrValue);\n\t\t}\n\t\telse if (initial === false) { // Boolean options must be false by default anyway\n\t\t\tinstance[i] = attrValue !== null;\n\t\t}\n\t\telse if (initial instanceof Function) {\n\t\t\tinstance[i] = null;\n\t\t}\n\t\telse {\n\t\t\tinstance[i] = attrValue;\n\t\t}\n\n\t\tif (!instance[i] && instance[i] !== 0) {\n\t\t\tinstance[i] = (i in o)? o[i] : initial;\n\t\t}\n\t}\n}\n\n// Helpers\n\nvar slice = Array.prototype.slice;\n\nfunction $(expr, con) {\n\treturn typeof expr === \"string\"? (con || document).querySelector(expr) : expr || null;\n}\n\nfunction $$(expr, con) {\n\treturn slice.call((con || document).querySelectorAll(expr));\n}\n\n$.create = function(tag, o) {\n\tvar element = document.createElement(tag);\n\n\tfor (var i in o) {\n\t\tvar val = o[i];\n\n\t\tif (i === \"inside\") {\n\t\t\t$(val).appendChild(element);\n\t\t}\n\t\telse if (i === \"around\") {\n\t\t\tvar ref = $(val);\n\t\t\tref.parentNode.insertBefore(element, ref);\n\t\t\telement.appendChild(ref);\n\t\t}\n\t\telse if (i in element) {\n\t\t\telement[i] = val;\n\t\t}\n\t\telse {\n\t\t\telement.setAttribute(i, val);\n\t\t}\n\t}\n\n\treturn element;\n};\n\n$.bind = function(element, o) {\n\tif (element) {\n\t\tfor (var event in o) {\n\t\t\tvar callback = o[event];\n\n\t\t\tevent.split(/\\s+/).forEach(function (event) {\n\t\t\t\telement.addEventListener(event, callback);\n\t\t\t});\n\t\t}\n\t}\n};\n\n$.fire = function(target, type, properties) {\n\tvar evt = document.createEvent(\"HTMLEvents\");\n\n\tevt.initEvent(type, true, true );\n\n\tfor (var j in properties) {\n\t\tevt[j] = properties[j];\n\t}\n\n\treturn target.dispatchEvent(evt);\n};\n\n$.regExpEscape = function (s) {\n\treturn s.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n};\n\n$.siblingIndex = function (el) {\n\t/* eslint-disable no-cond-assign */\n\tfor (var i = 0; el = el.previousElementSibling; i++);\n\treturn i;\n};\n\n// Initialization\n\nfunction init() {\n\t$$(\"input.awesomplete\").forEach(function (input) {\n\t\tnew _(input);\n\t});\n}\n\n// Are we in a browser? Check for Document constructor\nif (typeof Document !== \"undefined\") {\n\t// DOM already loaded?\n\tif (document.readyState !== \"loading\") {\n\t\tinit();\n\t}\n\telse {\n\t\t// Wait for it\n\t\tdocument.addEventListener(\"DOMContentLoaded\", init);\n\t}\n}\n\n_.$ = $;\n_.$$ = $$;\n\n// Make sure to export Awesomplete on self when in a browser\nif (typeof self !== \"undefined\") {\n\tself.Awesomplete = _;\n}\n\n// Expose Awesomplete as a CJS module\nif (typeof module === \"object\" && module.exports) {\n\tmodule.exports = _;\n}\n\nreturn _;\n\n}());\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.theme.css b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.theme.css new file mode 100644 index 0000000000000000000000000000000000000000..8a964f11735510d956e60fa7fac86e4b4cf8fbad --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/awesomplete.theme.css @@ -0,0 +1,69 @@ +.awesomplete > ul { + border-radius: .3em; + margin: .2em 0 0; + background: hsla(0,0%,100%,.9); + background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8)); + border: 1px solid rgba(0,0,0,.3); + box-shadow: .05em .2em .6em rgba(0,0,0,.2); + text-shadow: none; +} + +@supports (transform: scale(0)) { + .awesomplete > ul { + transition: .3s cubic-bezier(.4,.2,.5,1.4); + transform-origin: 1.43em -.43em; + } + + .awesomplete > ul[hidden], + .awesomplete > ul:empty { + opacity: 0; + transform: scale(0); + display: block; + transition-timing-function: ease; + } +} + + /* Pointer */ + .awesomplete > ul:before { + content: ""; + position: absolute; + top: -.43em; + left: 1em; + width: 0; height: 0; + padding: .4em; + background: white; + border: inherit; + border-right: 0; + border-bottom: 0; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + } + + .awesomplete > ul > li { + position: relative; + padding: .2em .5em; + cursor: pointer; + } + + .awesomplete > ul > li:hover { + background: hsl(200, 40%, 80%); + color: black; + } + + .awesomplete > ul > li[aria-selected="true"] { + background: hsl(205, 40%, 40%); + color: white; + } + + .awesomplete mark { + background: hsl(65, 100%, 50%); + } + + .awesomplete li:hover mark { + background: hsl(68, 100%, 41%); + } + + .awesomplete li[aria-selected="true"] mark { + background: hsl(86, 100%, 21%); + color: inherit; + } \ No newline at end of file diff --git a/smash/web/static/AdminLTE/plugins/awesomplete/style.css b/smash/web/static/AdminLTE/plugins/awesomplete/style.css new file mode 100644 index 0000000000000000000000000000000000000000..68763ffe6359fe1e704616987abc34450904613c --- /dev/null +++ b/smash/web/static/AdminLTE/plugins/awesomplete/style.css @@ -0,0 +1,292 @@ +body { + max-width: 50rem; + padding: 1rem; + margin: auto; + background: hsl(35, 80%, 94%); + color: hsl(35, 50%, 20%); + text-shadow: 0 1px 1px white; + font: 120%/1.6 Baskerville, Palatino Linotype, Palatino, serif; +} + +a { + color: #58a; +} + +h1 { + text-align: center; + font-weight: 600; +} + + section > h1 { + margin-top: 2em; + } + +h2 { + color: hsl(35, 50%, 40%); + font-weight: 600; + font-size: 120%; +} + +ul { + margin: 0; + padding-left: .8em; +} + +strong { + font-weight: 600; +} + +abbr { + border-bottom: .1em dotted hsl(40, 80%, 40%); + cursor: help; +} + +input, button { + font: inherit; + text-shadow: inherit; +} + +button { + padding: .1em .5em; + border-radius: .3em; + background: hsl(80, 80%, 80%); + background: linear-gradient(hsl(40, 70%, 80%), hsl(40, 70%, 70%)); + border: 1px solid rgba(0,0,0,.3); + box-shadow: 0 1px white inset, 0 .3em .3em -.3em rgba(0,0,0,.3); +} + +input { + width: 12em; + padding: .1em .3em; + border: 0; + border: 1px solid hsl(35, 80%, 60%); + background: hsla(0,0%,100%,.2); + border-radius: .3em; + box-shadow: .05em .1em .3em rgba(0,0,0,.3) inset; +} + +@keyframes pulsate { + to { + box-shadow: .05em .1em .3em rgba(0,0,0,.3) inset, 0 0 .3em .1em #58a; + } +} + +input:focus { + outline: none; + border: 1px solid #58a; + animation: pulsate 2s infinite alternate linear; + background: hsla(0,0%,100%,.5); +} + +header { + max-width: 37rem; + margin: 0 auto 2em; + text-align: center; + font-size: 150%; + font-style: italic; +} + + header h1 { + margin: .1em 0; + text-align: center; + color: hsl(35, 50%, 40%); + font-size: 400%; + line-height: 1; + font-style: italic; + font-weight: normal; + } + + header p { + margin: 0; + } + + header p a { + text-decoration: none; + color: inherit; + } + + .size { + position: absolute; + top: 1em; + right: 1em; + width: 4em; + padding: .8em .6em 1em; + background: hsl(40, 80%, 40%); + color: hsl(35, 80%, 94%); + text-shadow: none; + text-align: center; + line-height: 1.1; + text-indent: -.1em; + outline: .1em dotted; + outline-offset: -.3em; + text-decoration: none; + border-radius: .15em; + } + + .size:hover { + background: #58a; + } + + .size strong { + display: block; + margin-bottom: .1em; + font-size: 150%; + line-height: 1; + font-weight: 900; + font-style: normal; + } + + .size .amp { + position: absolute; + left: 0; right: 0; + bottom: 0; + color: hsla(35, 80%, 94%,.3); + font-size: 350%; + } + + nav { + margin-top: .5em; + } + + nav a { + position: relative; + display: inline-block; + padding: 0 .4em; + margin: 0 .1em; + + color: hsl(35, 80%, 94%); + text-shadow: none; + text-decoration: none; + font-size: 80%; + } + + nav a::before { + content: ""; + position: absolute; + top: 0; left: 0; right: 0; bottom: 0; + z-index: -1; + border-radius: .2em; + background: hsl(40, 80%, 40%); + -webkit-transform: skew(-16deg); + transform: skew(-16deg); + } + + nav a[href="#download"] { + font-weight: 600; + } + + nav a[href="#download"]::before { + background: hsl(65, 85%, 35%); + } + + nav a:hover::before { + background: #58a; + } + + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: hsl(35, 70%, 88%); + font-size: 80%; + border-radius: .3em; +} + +footer { + padding: .6em; + border-top: 1px solid rgba(0,0,0,.3); + margin-top: 1em; + text-align: center; +} + +pre { + position: relative; +} + +pre::before { + position: absolute; + top: 0; + right: .5em; + padding: .3em .4em; + border-radius: 0 0 .3em .3em; + background: hsl(35, 50%, 60%); + color: hsl(35, 80%, 90%); + text-shadow: none; + font: bold 100%/1 Baskerville, Palatino Linotype, Palatino, serif; +} + +pre.language-markup::before { + content: "HTML"; +} + +pre.language-javascript::before { + content: "JS"; +} + +table { + table-layout: fixed; + border-spacing: 0; + border-collapse: collapse; +} + +th { + font-size: 75%; +} + +td { + vertical-align: top; + padding: .5em; + border: 1px solid rgba(0,0,0,.1); +} + +:not(pre) > code[class*="language-"] { + background: none; +} + +.github-star { + position: absolute; + top: 1em; + left: 1em; +} + +#carbonads { + position: absolute; + top: 100%; + top: calc(100vh - 15em); + right: 1em; + max-width: 10em; + max-width: -webkit-min-content; + max-width: min-content; + font-size: 75%; +} + + #carbonads a { + text-decoration: none; + color: inherit; + } + + #carbonads img { + display: block; + } + +#combobox .dropdown-input { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} +#combobox .dropdown-btn { + vertical-align: top; + height: 36.5px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +#combobox .caret { + display: inline-block; + width: 0; + height: 0; + margin-left: 2px; + vertical-align: middle; + border-top: 4px dashed; + border-top: 4px solid; + border-right: 4px solid transparent; + border-left: 4px solid transparent; +} diff --git a/smash/web/templates/doctors/add.html b/smash/web/templates/doctors/add.html index 1c647eb7d340c25f61166f64f1a9286b89bdb1e0..a0b2b9a6431931f58c0731c6c9601d81140b43b5 100644 --- a/smash/web/templates/doctors/add.html +++ b/smash/web/templates/doctors/add.html @@ -4,8 +4,7 @@ {% block styles %} {{ block.super }} - <!-- DataTables --> - <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> +<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}" /> {% endblock styles %} {% block page_title %}'workers'{% endblock page_title %} @@ -75,18 +74,15 @@ {% block scripts %} {{ block.super }} - <script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script> - <script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script> - <script> - $(function () { - $('#table').DataTable({ - "paging": true, - "lengthChange": false, - "searching": true, - "ordering": true, - "info": true, - "autoWidth": false - }); - }); - </script> + <script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script> + <script> + // If ever to debug and thinking why it doesn't work => look if theres 'null' in data from API + $.get("{% url 'web.api.specializations' %}", function(data) { + new Awesomplete(document.querySelector("#id_specialization")).list = data.specializations; + }); + $.get("{% url 'web.api.units' %}", function(data) { + new Awesomplete(document.querySelector("#id_unit")).list = data.units; + }); + </script> + {% endblock scripts %} diff --git a/smash/web/templates/subjects/add.html b/smash/web/templates/subjects/add.html index 240ccf60ebe2d17a8cad41e4f402d2eb457c6761..3cd51d6c19da4a3b1f48031e85ff8c12c6b97733 100644 --- a/smash/web/templates/subjects/add.html +++ b/smash/web/templates/subjects/add.html @@ -4,8 +4,7 @@ {% block styles %} {{ block.super }} - <!-- DataTables --> - <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> + <link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}" /> {% endblock styles %} {% block page_title %}'subjects'{% endblock page_title %} @@ -74,18 +73,20 @@ {% block scripts %} {{ block.super }} - <script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script> - <script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script> - <script> - $(function () { - $('#table').DataTable({ - "paging": true, - "lengthChange": false, - "searching": true, - "ordering": true, - "info": true, - "autoWidth": false - }); - }); - </script> + <script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script> + <script> + $(document).ready(function() { + // If ever to debug and thinking why it doesn't work => look if theres 'null' in data from API + $.get("{% url 'web.api.cities' %}", function(data) { + new Awesomplete(document.querySelector("#id_city")).list = data.cities; + }); + $.get("{% url 'web.api.countries' %}", function(data) { + new Awesomplete(document.querySelector("#id_country")).list = data.countries; + }); + $.get("{% url 'web.api.referrals' %}", function(data) { + new Awesomplete(document.querySelector("#id_referral")).list = data.referrals; + }); + }); + + </script> {% endblock scripts %} diff --git a/smash/web/views.py b/smash/web/views.py index 61b950a86485edd8ff9ad2af60b9a9ce20dcc1fb..9acb1d4b8359db660d8069068f02b43ec49bd2cd 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals from django.shortcuts import redirect, render from django.http import HttpResponse from django.template import loader