Commit ca1dc3cd0f30aac4fd6db707ecdaa96d443d62d4

Authored by Victor Costa
1 parent 38d05154

container_block: put javascript in a js file

plugins/container_block/lib/container_block_plugin.rb
@@ -16,4 +16,8 @@ class ContainerBlockPlugin < Noosfero::Plugin @@ -16,4 +16,8 @@ class ContainerBlockPlugin < Noosfero::Plugin
16 true 16 true
17 end 17 end
18 18
  19 + def js_files
  20 + 'container_block.js'
  21 + end
  22 +
19 end 23 end
plugins/container_block/public/container_block.js 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +function toggleMoveContainerChildren(container, box) {
  2 + var div = jQuery('#box-'+box+' > .block-outer > .block');
  3 + if(div.is('.ui-resizable')) {
  4 + div.find("a").die("click");
  5 + div.resizable('destroy');
  6 + } else {
  7 + div.find("a").live("click", function(e) {
  8 + e.preventDefault();
  9 + });
  10 + div.resizable({
  11 + handles: 'e, w',
  12 + containment: '#block-'+container+' .block-inner-2',
  13 + resize: function( event, ui ) {
  14 + ui.element.height('auto');
  15 + }
  16 + });
  17 + }
  18 +}
  19 +
  20 +function containerChildrenWidth(container, box) {
  21 + widths = "";
  22 + jQuery('#box-'+box+' > .block-outer > .block').each(function(i) {
  23 + childId = jQuery(this).attr('id').match(/block-(\d+)/)[1];
  24 + widths+=childId+","+jQuery(this).width()+"|";
  25 + });
  26 + return "widths="+widths;
  27 +}
plugins/container_block/views/blocks/container.rhtml
@@ -24,37 +24,4 @@ @@ -24,37 +24,4 @@
24 :loaded => "close_loading();", 24 :loaded => "close_loading();",
25 :complete => "display_notice(request.responseText);"%> 25 :complete => "display_notice(request.responseText);"%>
26 </div> 26 </div>
27 -  
28 - <script>  
29 - function toggleMoveContainerChildren(container, box) {  
30 - var div = jQuery('#box-'+box+' > .block-outer > .block');  
31 - var targetDiv = jQuery('#box-'+box+' .block-outer .block-target');  
32 - if(div.is('.ui-resizable')) {  
33 - targetDiv.show();  
34 - div.find("a").die("click");  
35 - div.resizable('destroy');  
36 - } else {  
37 - targetDiv.hide();  
38 - div.find("a").live("click", function(e) {  
39 - e.preventDefault();  
40 - });  
41 - div.resizable({  
42 - handles: 'e, w',  
43 - containment: '#block-'+container+' .block-inner-2',  
44 - resize: function( event, ui ) {  
45 - ui.element.height('auto');  
46 - }  
47 - });  
48 - }  
49 - }  
50 -  
51 - function containerChildrenWidth(container, box) {  
52 - widths = "";  
53 - jQuery('#box-'+box+' > .block-outer > .block').each(function(i) {  
54 - childId = jQuery(this).attr('id').match(/block-(\d+)/)[1];  
55 - widths+=childId+","+jQuery(this).width()+"|";  
56 - });  
57 - return "widths="+widths;  
58 - }  
59 - </script>  
60 <% end %> 27 <% end %>