X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ff0ce1c6ab545ab8b7f4166caae9d59e6a67b421..5d3277b79ffef805948ca0e105135d13179926b6:/apps/wolnelektury_core/static/js/widget.js diff --git a/apps/wolnelektury_core/static/js/widget.js b/apps/wolnelektury_core/static/js/widget.js index 54700de7d..3b680fc7d 100644 --- a/apps/wolnelektury_core/static/js/widget.js +++ b/apps/wolnelektury_core/static/js/widget.js @@ -1,106 +1,8 @@ -/* create basic elements */ -var id = "wl"; -var widget = document.getElementById(id); -var linkLogo = document.createElement('a'); -var logo = document.createElement('img'); -var form = document.createElement('form'); -var inputText = document.createElement('input'); -var inputSubmit = document.createElement('input'); -var body = document.getElementsByTagName('body') -var stylesheet = document.createElement('link'); -var stylesheetJQUI = document.createElement('linl'); - -var host = 'localhost:8000'; //'www.wolnelektury.pl'; - -/* set attributes of created elements */ -stylesheet.setAttribute('type', 'text/css'); -stylesheet.setAttribute('rel', 'stylesheet'); -stylesheet.setAttribute('href', 'http://'+host+'/static/css/widget.css'); -stylesheetJQUI.setAttribute('type', 'text/css'); -stylesheetJQUI.setAttribute('rel', 'stylesheet'); -stylesheetJQUI.setAttribute('href', 'http://'+host+'/static/css/ui-lightness/jquery-ui-1.8.16.custom.css'); -linkLogo.setAttribute('href', 'http://'+host); -logo.setAttribute('src', 'http://'+host+'/static/img/logo-bez.png'); -form.setAttribute('action', 'http://'+host+'/szukaj/'); -form.setAttribute('method', 'get'); -form.setAttribute('accept-charset', 'utf-8'); -form.setAttribute('id', 'wl-form'); -inputText.setAttribute('type', 'text'); -inputText.setAttribute('title', 'tytul, autor, motyw/temat, epoka, rodzaj, gatunek'); -inputText.setAttribute('value', ''); -inputText.setAttribute('name', 'q'); -inputText.setAttribute('id', 'id_qq'); -inputText.setAttribute('data-source', 'http://'+host+'/szukaj/hint'); -/*inputText.setAttribute('size', '13');*/ -inputSubmit.setAttribute('type', 'image'); -inputSubmit.setAttribute('src', 'http://'+host+'/static/img/search.png'); -/* inputSubmit.setAttribute('style', 'position:relative; top:5px; margin-left:5px');*/ - -/* import jquery and autocomplete */ -var scriptJ = document.createElement('script'); -scriptJ.setAttribute('type', 'text/javascript'); -scriptJ.setAttribute('src', 'http://'+host+'/static/js/jquery.js'); - -var scriptUI = document.createElement('script'); -scriptUI.setAttribute('type', 'text/javascript'); -scriptUI.setAttribute('src', 'http://'+host+'/static/js/jquery-ui-1.8.2.custom.min.js'); -scriptUI.setAttribute('id', 'wl-jquery-ui-script') - -var scriptSearch = document.createElement('script'); -scriptSearch.setAttribute('type', 'text/javascript'); -scriptSearch.setAttribute('src', 'http://'+host+'/static/js/search.js'); -scriptSearch.setAttribute('id', 'wl-search-script') - - -body[0].appendChild(scriptJ); -body[0].appendChild(scriptUI); -body[0].appendChild(scriptSearch); - -/* append elements to widget */ -widget.appendChild(stylesheet); -//widget.appendChild(stylesheetJQUI); -widget.appendChild(linkLogo); -linkLogo.appendChild(logo); -widget.appendChild(form); -form.appendChild(inputText); -form.appendChild(inputSubmit); - -/* ...and a little make-up */ -/* -widget.style.borderColor = "#84BF2A"; -widget.style.borderWidth = "2px"; -widget.style.borderStyle = "solid"; -widget.style.width = "160px"; -widget.style.padding = "10px"; -widget.style.fontSize = "12px"; -form.style.paddingTop = "10px"; -*/ - -/* resize - if needed */ -if(widget.getAttribute('width') == '140'){ - logo.setAttribute('width', '140'); - inputText.setAttribute('size', '10'); - widget.style.width = "140px"; -} - -var wl_loaded_scripts = {}; - -function wl_initialize_after_load(just_loaded) { - wl_loaded_scripts[just_loaded] = true; - if (wl_loaded_scripts.jquery - && wl_loaded_scripts.ui - && wl_loaded_scripts.search) { - var s = $('#id_qq'); - s.search({source: s.attr('data-source')}); - } -} - -scriptJ.onload = function() { wl_initialize_after_load('jquery'); }; -scriptJ.onreadystatechange = function() { if (scriptJ.readyState == 'complete') { wl_initialize_after_load('jquery'); } }; - -scriptUI.onload = function() { wl_initialize_after_load('ui'); }; -scriptUI.onreadystatechange = function() { if (scriptUI.readyState == 'complete') { wl_initialize_after_load('jquery'); } }; - -scriptSearch.onload = function() { wl_initialize_after_load('search'); }; -scriptSearch.onreadystatechange = function() { if (scriptSearch.readyState == 'complete') { wl_initialize_after_load('jquery'); } }; - +var WOLNELEKTURY_LOADED; +if (WOLNELEKTURY_LOADED == undefined) { + var iframe = document.createElement('iframe'); + iframe.setAttribute('style', 'width: 100%; height: 140px; border: none; box-shadow: 0 0 .5rem #191919;'); + iframe.setAttribute('src', '//wolnelektury.pl/widget.html'); + document.getElementById('wl').appendChild(iframe); + WOLNELEKTURY_LOADED = true; +} \ No newline at end of file