|
1 | | -var populateWindow = function(link) { |
2 | | - var markdownRequest = new Request({ |
3 | | - "url": here + 'manual/en-US/' + link, |
4 | | - "method": "get", |
5 | | - "onSuccess": function(response) { |
6 | | - $('docwin').set('html', marked(response)); |
7 | | - } |
8 | | - }).send(); |
| 1 | +;(function($) { |
| 2 | + var populateWindow = function(link) { |
| 3 | + var markdownRequest = new Request({ |
| 4 | + "url": here + 'manual/en-US/' + link, |
| 5 | + "method": "get", |
| 6 | + "onSuccess": function(response) { |
| 7 | + $('docwin').set('html', marked(response)); |
| 8 | + } |
| 9 | + }).send(); |
9 | 10 |
|
10 | | - $$('.nav-list li').each( |
11 | | - function(item) { |
12 | | - if (item.getElements('a').length == 0) { |
13 | | - item.addClass('nav-header'); |
14 | | - } |
15 | | - } |
16 | | - ); |
| 11 | + $$('.nav-list li').each( |
| 12 | + function(item) { |
| 13 | + if (item.getElements('a').length == 0) { |
| 14 | + item.addClass('nav-header'); |
| 15 | + } |
| 16 | + } |
| 17 | + ); |
17 | 18 |
|
18 | | - $$('.nav-list a').each( |
19 | | - function(item, index) |
20 | | - { |
21 | | - if (link == item.get('href')) |
22 | | - { |
23 | | - item.getParent('li').addClass('active'); |
24 | | - } |
25 | | - else |
26 | | - { |
27 | | - item.getParent('li').removeClass('active'); |
28 | | - } |
29 | | - }.bind(this) |
30 | | - ); |
31 | | -} |
| 19 | + $$('.nav-list a').each( |
| 20 | + function(item, index) |
| 21 | + { |
| 22 | + if (link == item.get('href')) |
| 23 | + { |
| 24 | + item.getParent('li').addClass('active'); |
| 25 | + } |
| 26 | + else |
| 27 | + { |
| 28 | + item.getParent('li').removeClass('active'); |
| 29 | + } |
| 30 | + }.bind(this) |
| 31 | + ); |
| 32 | + } |
32 | 33 |
|
33 | | -var populateMenu = function() { |
34 | | - var markdownRequest = new Request({ |
35 | | - "url": here + 'manual/en-US/menu.md', |
36 | | - "method": "get", |
37 | | - "onSuccess": function (response) { |
38 | | - $('doc-menu').set('html', marked(response)); |
39 | | - $$('#doc-menu ul').each(function(el) { |
40 | | - el.addClass('nav'); |
41 | | - el.addClass('nav-list'); |
42 | | - }); |
| 34 | + var populateMenu = function() { |
| 35 | + var markdownRequest = new Request({ |
| 36 | + "url": here + 'manual/en-US/menu.md', |
| 37 | + "method": "get", |
| 38 | + "onSuccess": function (response) { |
| 39 | + $('doc-menu').set('html', marked(response)); |
| 40 | + $$('#doc-menu ul').each(function(el) { |
| 41 | + el.addClass('nav'); |
| 42 | + el.addClass('nav-list'); |
| 43 | + }); |
43 | 44 |
|
44 | | - $$('.nav-list li').each( |
45 | | - function(item) { |
46 | | - if (item.getElements('a').length == 0) { |
47 | | - item.addClass('nav-header'); |
48 | | - } |
49 | | - } |
50 | | - ); |
51 | | - } |
52 | | - }).send(); |
53 | | -} |
| 45 | + $$('.nav-list li').each( |
| 46 | + function(item) { |
| 47 | + if (item.getElements('a').length == 0) { |
| 48 | + item.addClass('nav-header'); |
| 49 | + } |
| 50 | + } |
| 51 | + ); |
| 52 | + } |
| 53 | + }).send(); |
| 54 | + } |
54 | 55 |
|
55 | | -var populateVersion = function() { |
56 | | - var versionRequest = new Request({ |
57 | | - "url": here + 'manual/en-US/version.md', |
58 | | - "method": "get", |
59 | | - "onSuccess": function(response) { |
60 | | - $('version').set('html', marked(response)); |
61 | | - } |
62 | | - }).send(); |
63 | | -} |
| 56 | + var populateVersion = function() { |
| 57 | + var versionRequest = new Request({ |
| 58 | + "url": here + 'manual/en-US/version.md', |
| 59 | + "method": "get", |
| 60 | + "onSuccess": function(response) { |
| 61 | + $('version').set('html', marked(response)); |
| 62 | + } |
| 63 | + }).send(); |
| 64 | + } |
64 | 65 |
|
65 | | -window.addEvent('domready', function() { |
66 | | - var urlParts = document.URL.split('?', 2); |
67 | | - state = {}; |
68 | | - here = urlParts[0]; |
| 66 | + window.addEvent('domready', function() { |
| 67 | + var urlParts = document.URL.split('?', 2); |
| 68 | + state = {}; |
| 69 | + here = urlParts[0]; |
69 | 70 |
|
70 | | - if (urlParts.length > 1) |
71 | | - { |
72 | | - var currentDoc = urlParts[1]; |
73 | | - } |
74 | | - else |
75 | | - { |
76 | | - var currentDoc = "coding-standards/introduction.md"; |
77 | | - } |
| 71 | + if (urlParts.length > 1) |
| 72 | + { |
| 73 | + var currentDoc = urlParts[1]; |
| 74 | + } |
| 75 | + else |
| 76 | + { |
| 77 | + var currentDoc = "coding-standards/introduction.md"; |
| 78 | + } |
78 | 79 |
|
79 | | - marked.setOptions({ |
80 | | - gfm: true, |
81 | | - pedantic: false, |
82 | | - sanitize: false, |
83 | | - highlight: function(code, lang) { |
84 | | - var that; |
85 | | - Rainbow.color(code, lang, function(hl_code) { that = hl_code; }); |
86 | | - return that; |
87 | | - } |
88 | | - }) |
89 | | - populateMenu(); |
90 | | - populateWindow(currentDoc); |
91 | | - populateVersion(); |
| 80 | + marked.setOptions({ |
| 81 | + gfm: true, |
| 82 | + pedantic: false, |
| 83 | + sanitize: false, |
| 84 | + highlight: function(code, lang) { |
| 85 | + var that; |
| 86 | + Rainbow.color(code, lang, function(hl_code) { that = hl_code; }); |
| 87 | + return that; |
| 88 | + } |
| 89 | + }) |
| 90 | + populateMenu(); |
| 91 | + populateWindow(currentDoc); |
| 92 | + populateVersion(); |
92 | 93 |
|
93 | | - document.id('main').addEvent('click:relay(a)', function (event, target) { |
94 | | - if (target.get('href').substring(0, 4) != 'http' && target.get('href').substring(0, 1) != '#') |
95 | | - { |
96 | | - populateWindow(target.get('href')); |
97 | | - event.preventDefault(); |
98 | | - history.pushState(state, target.get('href'), "?" + target.get('href')); |
99 | | - } |
100 | | - }); |
101 | | -}); |
| 94 | + document.id('main').addEvent('click:relay(a)', function (event, target) { |
| 95 | + if (target.get('href').substring(0, 4) != 'http' && target.get('href').substring(0, 1) != '#') |
| 96 | + { |
| 97 | + populateWindow(target.get('href')); |
| 98 | + event.preventDefault(); |
| 99 | + history.pushState(state, target.get('href'), "?" + target.get('href')); |
| 100 | + } |
| 101 | + }); |
| 102 | + }); |
| 103 | +})(document.id) |
0 commit comments