Merge branch 'master' of git@github.com:fnp/wolnelektury
[wolnelektury.git] / wolnelektury / static / js / widget.js
1 /* create basic elements */
2 var id          = "wl";
3 var widget      = document.getElementById(id);
4 var linkLogo    = document.createElement('a');
5 var logo        = document.createElement('img');
6 var form        = document.createElement('form');
7 var inputText   = document.createElement('input');
8 var inputSubmit = document.createElement('input');
9 var body        = document.getElementsByTagName('body')
10 var stylesheet = document.createElement('link');
11
12 /* set attributes of created elements */
13 stylesheet.setAttribute('type', 'text/css');
14 stylesheet.setAttribute('rel', 'stylesheet');
15 stylesheet.setAttribute('href', 'http://www.wolnelektury.pl/static/css/widget.css');
16 linkLogo.setAttribute('href', 'http://www.wolnelektury.pl');
17 logo.setAttribute('src', 'http://www.wolnelektury.pl/static/img/logo.png');
18 form.setAttribute('action', 'http://www.wolnelektury.pl/katalog/szukaj/');
19 form.setAttribute('method', 'get');
20 form.setAttribute('accept-charset', 'utf-8');
21 form.setAttribute('id', 'wl-form');
22 inputText.setAttribute('type', 'text');
23 inputText.setAttribute('title', 'tytul, autor, motyw/temat, epoka, rodzaj, gatunek');
24 inputText.setAttribute('value', '');
25 inputText.setAttribute('name', 'q');
26 inputText.setAttribute('id', 'id_q');
27 inputSubmit.setAttribute('type', 'submit');
28 inputSubmit.setAttribute('value', 'Szukaj');
29
30 /* import jquery and autocomplete */
31 var scriptJ = document.createElement('script');
32 scriptJ.setAttribute('type', 'text/javascript');
33 scriptJ.setAttribute('src', 'http://www.wolnelektury.pl/static/js/jquery.js');
34
35 var scriptAutoComplete = document.createElement('script');
36 scriptAutoComplete.setAttribute('type', 'text/javascript');
37 scriptAutoComplete.setAttribute('src', 'http://www.wolnelektury.pl/static/js/jquery-ui-1.8.2.custom.min.js');
38
39 var scriptInit = document.createElement('script');
40 scriptInit.setAttribute('type', 'text/javascript');
41 scriptInit.setAttribute('src', 'http://www.wolnelektury.pl/static/js/widgetInit.js');
42
43 body[0].appendChild(scriptJ);
44 body[0].appendChild(scriptAutoComplete);
45 body[0].appendChild(scriptInit);
46
47 /* append elements to widget */
48 widget.appendChild(stylesheet);
49 widget.appendChild(linkLogo);
50 linkLogo.appendChild(logo);
51 widget.appendChild(form);
52 form.appendChild(inputText);
53 form.appendChild(inputSubmit);
54
55 /* ...and a little make-up */
56 widget.style.borderColor = "#84BF2A";
57 widget.style.borderWidth = "2px";
58 widget.style.borderStyle = "solid";
59 widget.style.width = "260px";
60 widget.style.padding = "10px";
61 widget.style.fontSize = "12px";
62 form.style.paddingTop = "10px";