diff options
author | Jochen Topf <jochen@topf.org> | 2012-01-23 18:17:57 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2012-01-23 18:17:57 +0100 |
commit | 3b2fd30d7ecb26c71b0db3f0fc1c6f69775330c3 (patch) | |
tree | 55f60ebeb706ce87835f6e485a92043231502b17 /web | |
parent | 9e2e806221d12e0804559e626c88994e5197399a (diff) | |
download | taginfo-3b2fd30d7ecb26c71b0db3f0fc1c6f69775330c3.tar taginfo-3b2fd30d7ecb26c71b0db3f0fc1c6f69775330c3.tar.gz |
Remove need for jQuery.ready(), cleanup language_comparison_table_for_keys_in_the_wiki report
Diffstat (limited to 'web')
-rw-r--r-- | web/lib/javascript.rb | 8 | ||||
-rw-r--r-- | web/views/index.erb | 12 | ||||
-rw-r--r-- | web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb | 60 | ||||
-rw-r--r-- | web/views/test/tags.erb | 11 |
4 files changed, 13 insertions, 78 deletions
diff --git a/web/lib/javascript.rb b/web/lib/javascript.rb index f37646b..cadaa4f 100644 --- a/web/lib/javascript.rb +++ b/web/lib/javascript.rb @@ -39,14 +39,6 @@ class JQuery # show up as JQuery class methods. extend R18n::Helpers - def self.ready - page = '' - content = yield page - "jQuery(document).ready(function() {\n" + - (page=='' ? content : page) + - "});\n" - end - def self.flexigrid(id, options) defaults = { :method => 'GET', diff --git a/web/views/index.erb b/web/views/index.erb index bc76ed7..7d2285c 100644 --- a/web/views/index.erb +++ b/web/views/index.erb @@ -49,13 +49,11 @@ </table> <% javascript do JS.raw('function tagcloud_data() { return ' + @tags.map{ |tag| [tag['key'], tagcloud_size(tag)] }.to_json.gsub(/\],/, "],\n")) + "; }\n" + - - JQuery.ready do - JS.raw(<<"JAVASCRIPT") -jQuery(window).resize(resize_home); -resize_home(); - + JS.raw(<<"JAVASCRIPT") +function page_init() { + jQuery(window).resize(resize_home); + resize_home(); +} JAVASCRIPT - end end %> diff --git a/web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb b/web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb index 8c50a38..3221a41 100644 --- a/web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb +++ b/web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb @@ -1,14 +1,3 @@ -<% - @languages = @db.execute('SELECT language FROM wiki_languages ORDER by language').map do |row| - row['language'] - end - - lang_lookup = Hash.new - @languages.each_with_index do |lang, idx| - lang_lookup[lang] = idx + 1 - end - @languages_lookup = @languages.map{ |lang| "'#{lang}': #{lang_lookup[lang]}" }.join(', ') -%> <div class="pre"> <h1><%= t.reports.language_comparison_table_for_keys_in_the_wiki.name %></h1> <%= t.reports.language_comparison_table_for_keys_in_the_wiki.intro %> @@ -23,51 +12,4 @@ <tr><td><img src="/img/sources/wiki/wiki-r.png" alt="[r]"/></td><td><%= t.reports.language_comparison_table_for_keys_in_the_wiki.icons.redirect %></td></tr> </table> </div> -<script type="text/javascript"> - jQuery(document).ready(function() { - var lang_to_idx = { - <%= @languages_lookup %> - }; - var rp = calculate_flexigrid_rp(jQuery('div.box')) - 1; - current_grid = 'grid-keys'; - grids[current_grid] = jQuery('#grid-keys').flexigrid({ - url: '/api/2/wiki/keys', - method: 'GET', - dataType: 'json', - colModel: [ - { display: '<br/>Key', name: 'key', width: 200, sortable: true }, - <% @languages.each do |lang| %> - { display: '<%= ::Language[lang].native_name %><br /><span class="lang" style="margin-top: 2px;"><%= lang %></span>', name: '<%= lang %>', align: 'center', width: 60, sortable: false }, - <% end %> - ], - searchitems: [ - { display: 'Key', name: 'key' } - ], - sortname: 'key', - sortorder: 'asc', - showToggleBtn: false, - showTableToggleBtn: false, - usepager: true, - useRp: false, - rp: rp, - height: 'auto', - onSuccess: function(grid) { - grid.fixHeight(); - }, - preProcess: function(data) { - return { - total: data.total, - page: data.page, - rows: jQuery.map(data.data, function(row, i) { - d = [link_to_key(row.key) <%= @languages.map{ ", ''"}.join() %>]; - for (var lang in row.lang) { - ptype = row.lang[lang]; - d[lang_to_idx[lang]] = '<img src="/img/sources/wiki/wiki-' + ptype + '.png" alt="[' + ptype + ']"/>'; - } - return { 'cell': d }; - }) - }; - } - }); - }); -</script> +<% javascript "#{ r18n.locale.code }/reports/language_comparison_table_for_keys_in_the_wiki" %> diff --git a/web/views/test/tags.erb b/web/views/test/tags.erb index 5b235d2..32e71a0 100644 --- a/web/views/test/tags.erb +++ b/web/views/test/tags.erb @@ -7,8 +7,9 @@ <a href="/tags/<%= h tag['key'] %>" class="popkey" style="font-size: <%= tagcloud_size(tag) %>px;" title="<%= tag['count'] %>"><%= h tag['key'] %></a> <% end %> -<script type="text/javascript"> - jQuery(document).ready(function() { +<% javascript do + JS.raw(<<"JAVASCRIPT") +function page_init() { jQuery('#popular-keys').flexigrid({ url: '/api/2/db/popular_keys', method: 'GET', @@ -47,5 +48,7 @@ return data; } }); - }); -</script> +} +JAVASCRIPT +end +%> |