diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index 36309900..e993df79 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -375,16 +375,24 @@ modalWindow : function(settings,callbackFn){ var tempheight = settings.height; var tempwidth = settings.width; + var maxheight = (rgmaskHeight*85)/100; + var maxwidth = (rgmaskWidth*85)/100; + if(typeof tempheight!="undefined"){ if(tempheight.charAt(tempheight.length-1)=='%') tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100; + if(tempheight>maxheight) + tempheight=maxheight; }else{tempheight="auto";} if(typeof tempwidth!="undefined"){ if(tempwidth.charAt(tempwidth.length-1)=='%') tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100; + if(tempwidth>maxwidth) + tempwidth=maxwidth; }else{tempwidth="auto";} + $rss("body").append('
'); $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199}); $rss("body").append('
'); @@ -410,14 +418,19 @@ modalWindow : function(settings,callbackFn){ rgWTop = (rgmaskHeight-tempheight)/2; else{ tempheight=$rss("#rgWindow").height(); + if(tempheight>maxheight) + tempheight=maxheight; rgWTop=(rgmaskHeight-tempheight)/2; } if(tempwidth!="auto") rgWLeft = (rgmaskWidth-tempwidth)/2; else{ tempwidth=$rss("#rgWindow").width(); + if(tempwidth>maxwidth) + tempwidth=maxwidth; rgWLeft=(rgmaskWidth-tempwidth)/2; } + tempwidth+=25; $rss("#rgWindow").empty().show(); var closebtn = ""; if(closeBtn) @@ -443,6 +456,65 @@ modalWindow : function(settings,callbackFn){ }); } }, +modalWindowUpdate : function(settings,callbackFn){ + var rgmaskHeight = $rss(window).height(); + var rgmaskWidth = $rss(window).width(); + var tempheight = settings.height; + var tempwidth = settings.width; + var dhtml = ""; + var maxheight = (rgmaskHeight*85)/100; + var maxwidth = (rgmaskWidth*85)/100; + if(typeof tempheight!="undefined"){ + if(tempheight.charAt(tempheight.length-1)=='%') + tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100; + if(tempheight>maxheight) + tempheight=maxheight; + }else{tempheight="auto";} + + if(typeof tempwidth!="undefined"){ + if(tempwidth.charAt(tempwidth.length-1)=='%') + tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100; + if(tempwidth>maxwidth) + tempwidth=maxwidth; + }else{tempwidth="auto";}; + $rss("body").append("
"); + + if(typeof settings.loadDiv!="undefined"){ + dhtml = $rss("#"+settings.loadDiv).html(); + $rss("#rgwindow_temp_div").html(dhtml).hide(); + prepareWindow(); + } + if(typeof settings.loadHtml!="undefined"){ + dhtml = settings.loadHtml; + $rss("#rgwindow_temp_div").html(dhtml).hide(); + prepareWindow(); + } + if(typeof settings.loadPage!="undefined"){ + $rss("#rgwindow_temp_div").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();}); + } + function prepareWindow(){ + if(tempheight!="auto") + rgWTop = (rgmaskHeight-tempheight)/2; + else{ + tempheight=$rss("#rgwindow_temp_div").height(); + if(tempheight>maxheight) + tempheight=maxheight; + rgWTop=(rgmaskHeight-tempheight)/2; + } + if(tempwidth!="auto") + rgWLeft = (rgmaskWidth-tempwidth)/2; + else{ + tempwidth=$rss("#rgwindow_temp_div").width(); + if(tempwidth>maxwidth) + tempwidth=maxwidth; + rgWLeft=(rgmaskWidth-tempwidth)/2; + } + tempwidth+=25; + $rss("#rgContent").empty(); + $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgContent").css("height",tempheight+"px").html(dhtml)}); + $rss("#rgwindow_temp_div").remove(); + } +}, modalWindowClose : function(callbackFn){ if($rss("#rgWindow").length>0){ $rss("#rgWindow").empty(); diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index ba77c1f9..1591cf39 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -38,7 +38,7 @@ class Admin::AssetsController < ApplicationController else respond_to do |format| format.html { render :action => :new } - format.js { render 'js/reload_content', :locals => {:function => 'html', :id => 'pop_up_content', :value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} } + format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} } end end end @@ -53,7 +53,7 @@ class Admin::AssetsController < ApplicationController else respond_to do |format| format.html { render :action => :edit } - format.js { render 'js/reload_content', :locals => {:function => 'html', :id => 'pop_up_content', :value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} } + format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} } end end diff --git a/app/views/js/get_to_render.js.erb b/app/views/js/get_to_render.js.erb new file mode 100644 index 00000000..e13aff8a --- /dev/null +++ b/app/views/js/get_to_render.js.erb @@ -0,0 +1,6 @@ +var to_render = ''; +<% if value %> + to_render = "<%= escape_javascript(render(:partial => partial, :object => value, :locals => locals)) %>" +<% elsif values %> + to_render = "<%= escape_javascript(render(:partial => partial, :collection => values, :locals => locals)) %>" +<% end %> \ No newline at end of file diff --git a/app/views/js/reload_content.js.erb b/app/views/js/reload_content.js.erb index 20943db2..b248a254 100644 --- a/app/views/js/reload_content.js.erb +++ b/app/views/js/reload_content.js.erb @@ -1,8 +1,3 @@ -var to_render = ''; -<% if value %> - to_render = "<%= escape_javascript(render(:partial => partial, :object => value, :locals => locals)) %>" -<% elsif values %> - to_render = "<%= escape_javascript(render(:partial => partial, :collection => values, :locals => locals)) %>" -<% end %> +<%= render :template => 'js/get_to_render', :locals => {:value => value, :values => values, :partial => partial, :locals => locals} %> $("#<%= id %>").<%= function %>(to_render); \ No newline at end of file diff --git a/app/views/js/reload_pop_up.js.erb b/app/views/js/reload_pop_up.js.erb new file mode 100644 index 00000000..fca38ce3 --- /dev/null +++ b/app/views/js/reload_pop_up.js.erb @@ -0,0 +1,3 @@ +<%= render :template => 'js/get_to_render', :locals => {:value => value, :values => values, :partial => partial, :locals => locals} %> + +rcom.modalWindowUpdate({loadHtml:to_render}); \ No newline at end of file