Integrate Harry's modifications to reload pop-up content
This commit is contained in:
		
							parent
							
								
									b002c411ce
								
							
						
					
					
						commit
						ea19f11fe2
					
				| 
						 | 
					@ -375,16 +375,24 @@ modalWindow : function(settings,callbackFn){
 | 
				
			||||||
	var tempheight = settings.height;
 | 
						var tempheight = settings.height;
 | 
				
			||||||
	var tempwidth = settings.width;
 | 
						var tempwidth = settings.width;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
						var maxheight = (rgmaskHeight*85)/100;
 | 
				
			||||||
 | 
						var maxwidth = (rgmaskWidth*85)/100;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
	if(typeof tempheight!="undefined"){
 | 
						if(typeof tempheight!="undefined"){
 | 
				
			||||||
		if(tempheight.charAt(tempheight.length-1)=='%')
 | 
							if(tempheight.charAt(tempheight.length-1)=='%')
 | 
				
			||||||
			tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
 | 
								tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
 | 
				
			||||||
 | 
							if(tempheight>maxheight)
 | 
				
			||||||
 | 
								tempheight=maxheight;	
 | 
				
			||||||
	}else{tempheight="auto";}
 | 
						}else{tempheight="auto";}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(typeof tempwidth!="undefined"){
 | 
						if(typeof tempwidth!="undefined"){
 | 
				
			||||||
		if(tempwidth.charAt(tempwidth.length-1)=='%')
 | 
							if(tempwidth.charAt(tempwidth.length-1)=='%')
 | 
				
			||||||
			tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
 | 
								tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
 | 
				
			||||||
 | 
							if(tempwidth>maxwidth)
 | 
				
			||||||
 | 
								tempwidth=maxwidth;
 | 
				
			||||||
	}else{tempwidth="auto";}
 | 
						}else{tempwidth="auto";}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
 | 
						$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
 | 
				
			||||||
	$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199});
 | 
						$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199});
 | 
				
			||||||
	$rss("body").append('<div id="rgWindow"></div>');
 | 
						$rss("body").append('<div id="rgWindow"></div>');
 | 
				
			||||||
| 
						 | 
					@ -410,14 +418,19 @@ modalWindow : function(settings,callbackFn){
 | 
				
			||||||
			rgWTop = (rgmaskHeight-tempheight)/2;
 | 
								rgWTop = (rgmaskHeight-tempheight)/2;
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			tempheight=$rss("#rgWindow").height();
 | 
								tempheight=$rss("#rgWindow").height();
 | 
				
			||||||
 | 
								if(tempheight>maxheight)
 | 
				
			||||||
 | 
									tempheight=maxheight;
 | 
				
			||||||
			rgWTop=(rgmaskHeight-tempheight)/2;
 | 
								rgWTop=(rgmaskHeight-tempheight)/2;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if(tempwidth!="auto")
 | 
							if(tempwidth!="auto")
 | 
				
			||||||
			rgWLeft = (rgmaskWidth-tempwidth)/2;
 | 
								rgWLeft = (rgmaskWidth-tempwidth)/2;
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			tempwidth=$rss("#rgWindow").width();
 | 
								tempwidth=$rss("#rgWindow").width();
 | 
				
			||||||
 | 
								if(tempwidth>maxwidth)
 | 
				
			||||||
 | 
									tempwidth=maxwidth;
 | 
				
			||||||
			rgWLeft=(rgmaskWidth-tempwidth)/2;
 | 
								rgWLeft=(rgmaskWidth-tempwidth)/2;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							tempwidth+=25;
 | 
				
			||||||
		$rss("#rgWindow").empty().show();
 | 
							$rss("#rgWindow").empty().show();
 | 
				
			||||||
		var closebtn = "";
 | 
							var closebtn = "";
 | 
				
			||||||
		if(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("<div id='rgwindow_temp_div'></div>");
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						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){
 | 
					modalWindowClose : function(callbackFn){
 | 
				
			||||||
	if($rss("#rgWindow").length>0){
 | 
						if($rss("#rgWindow").length>0){
 | 
				
			||||||
		$rss("#rgWindow").empty();
 | 
							$rss("#rgWindow").empty();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ class Admin::AssetsController < ApplicationController
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
        format.html { render :action => :new }
 | 
					        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
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,7 @@ class Admin::AssetsController < ApplicationController
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
        format.html { render :action => :edit }
 | 
					        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
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 %>
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,3 @@
 | 
				
			||||||
var to_render = '';
 | 
					<%= render :template => 'js/get_to_render', :locals => {:value => value, :values => values, :partial => partial, :locals => locals} %>
 | 
				
			||||||
<% 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 %>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#<%= id %>").<%= function %>(to_render);
 | 
					$("#<%= id %>").<%= function %>(to_render);
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					<%= render :template => 'js/get_to_render', :locals => {:value => value, :values => values, :partial => partial, :locals => locals} %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rcom.modalWindowUpdate({loadHtml:to_render});
 | 
				
			||||||
		Loading…
	
		Reference in New Issue