1 | /** |
---|
2 | * technikum29.de | javascripts: english translation system loader |
---|
3 | * |
---|
4 | * Um die Ladezeiten des translation systems geringer zu halten, werden |
---|
5 | * JavaScript und CSS dynamisch nachgeladen. |
---|
6 | * @param success_function Function to execute after set_enabled(true) has been called. |
---|
7 | * @returns immediately returns, asynchronous content loading |
---|
8 | **/ |
---|
9 | |
---|
10 | if(!t29) window.t29 = {}; // the t29 namespace |
---|
11 | |
---|
12 | if(!t29.tr) t29.tr = {}; // translation system namespace |
---|
13 | t29.tr.preloader = {}; // namespace for this preloading system |
---|
14 | t29.tr.preloader.enabled_string = // text for sidebar with enabled tr system |
---|
15 | "<h3>Improve this page</h3><p>Simply click on any paragraph to correct it. Thank you!</p>" |
---|
16 | +"<span class='button gray'>Finished!</span>"; |
---|
17 | |
---|
18 | t29.tr.preloader.start = function(success_function) { |
---|
19 | // kruder Hack, um die Ladezeit zu ueberstehen: schon mal Designaenderung |
---|
20 | $("body").toggleClass("tr-enabled tr-disabled"); |
---|
21 | $.getScript('/en/dev/translation/editor.js', function(){ |
---|
22 | t29.tr.set_enabled(true); if(success_function) success_function(); }); |
---|
23 | $.get('/en/dev/translation/editor.css', function(css) { |
---|
24 | $("<style type='text/css'/>").html(css).appendTo("head"); |
---|
25 | }); |
---|
26 | |
---|
27 | // text, nur einmal und so. bessere bedingung - schauen ob schon mal gestartet wurde. |
---|
28 | if(!$("#sidebar-tr .tr-enabled").length) { |
---|
29 | $("<div class='tr-enabled'/>").html(t29.tr.preloader.enabled_string).appendTo('#sidebar-tr'); |
---|
30 | } |
---|
31 | }; |
---|
32 | |
---|
33 | t29.tr.preloader.onload = function() { |
---|
34 | $("#sidebar-tr a").click(function() { |
---|
35 | t29.tr.preloader.start(); |
---|
36 | return false; |
---|
37 | }).attr('href', '#help_with_mistakes'); |
---|
38 | |
---|
39 | // startup tr system with query string like ?tr or ...tr-... |
---|
40 | // or for people who opened link in another tab |
---|
41 | if(location.search.match(/tr-|^tr/i) || location.hash.match(/help_with_mistakes/)) { |
---|
42 | t29.tr.preloader.start(function(){ t29.tr.display_startup_notice('querystring'); }); |
---|
43 | } else if(location.hostname.match(/^edit/i)) { |
---|
44 | t29.tr.preloader.start(function(){ t29.tr.display_startup_notice('editdomain'); }); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | $(t29.tr.preloader); |
---|