<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" version="2.0">
  <channel>
    <title>Recent Posts in 'Adding refresh button to URLWindow' | Prototype UI</title>
    <link>http://forums.prototype-ui.com/forums/2/topics/8</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <atom:link rel="search" type="application/opensearchdescription+xml" href="http://forums.prototype-ui.com/open_search.xml"/>
    <description></description>
    <item>
      <title>Adding refresh button to URLWindow replied by biegun @ Wed, 11 Jun 2008 20:25:28 -0000</title>
      <description>&lt;p&gt;and what about refresh button to UI.Window which content is set by setAjaxContent?&lt;br /&gt;i tried to add adress to refresh to in definition of button &lt;br /&gt;&lt;pre&gt;    .addButton('refresh', refreshWindow(...))&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;but i receive error message:&lt;br /&gt;&lt;pre&gt;
this.setAjaxContent is not a function
refreshWindow()~sbak (line 219)
app_windows()~sbak (line 57)
wrapper(load )prototype.js (line 3877)
[Break on this error] this.setAjaxContent('sites/header.html'); 
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;is there sth like this.iframe.contentWindow.location.href stored for AjaxContent?&lt;/p&gt;


	&lt;p&gt;//i&amp;#8217;ve done it in a little different way- when i load from database adress of website to use in setAjaxContent, i save it to the array and re-use in refreshWindow. &amp;#8211; it&amp;#8217;s rather &amp;#8216;back&amp;#8217; then &amp;#8216;refresh&amp;#8217; now.&lt;/p&gt;</description>
      <pubDate>Wed, 11 Jun 2008 20:25:28 -0000</pubDate>
      <guid isPermaLink="false">forums.prototype-ui.com:2:8:485</guid>
      <author>biegun</author>
      <link>http://forums.prototype-ui.com/forums/2/topics/8</link>
    </item>
    <item>
      <title>Adding refresh button to URLWindow replied by nrasch @ Fri, 07 Dec 2007 03:00:07 -0000</title>
      <description>&lt;p&gt;&lt;strong&gt;Refresh and Back Buttons using Prototype-UI URLWindow&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Prototype-UI uses iframes for the URLWindow class.  When making custom refresh or back buttons, it is important to remember that you are restricted to working with pages that come from within your local site.  If you try to access the &lt;span class="caps"&gt;URL&lt;/span&gt; location of a iframe pointing to something outside your site, you get an access denied error in many cases.  Most browsers impliment this on purpose to prevent cross site scripting attacks.&lt;/p&gt;


	&lt;p&gt;Below are the custom extensions to the URLWindow class I used to test with:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
// Custom Extensions to Prototype-UI
UI.URLWindow.addMethods({
    refreshWindow: function() {
        this.setUrl(this.iframe.contentWindow.location.href);
    },

    goBack: function() {
        var frameName = this.element.id + "_frame";
        frames[frameName].history.back();
    }
});
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I then tested this code against an iframe pointing to a url contained &lt;strong&gt;within&lt;/strong&gt; my local site.  The results of testing is as follows:&lt;/p&gt;


	&lt;p&gt;Safari: iframe back -&amp;gt; Broken&lt;br /&gt;Firefox: iframe back -&amp;gt; Works&lt;br /&gt;Opera: iframe back -&amp;gt; Works&lt;br /&gt;&lt;span class="caps"&gt;IE7&lt;/span&gt;: iframe back -&amp;gt; Works&lt;/p&gt;


	&lt;p&gt;Safari: iframe refresh current url location -&amp;gt; Works&lt;br /&gt;Firefox: iframe refresh current url location -&amp;gt; Works&lt;br /&gt;Opera: iframe refresh current url location -&amp;gt; Works&lt;br /&gt;&lt;span class="caps"&gt;IE7&lt;/span&gt;: iframe refresh current url location -&amp;gt; Works&lt;/p&gt;</description>
      <pubDate>Fri, 07 Dec 2007 03:00:07 -0000</pubDate>
      <guid isPermaLink="false">forums.prototype-ui.com:2:8:24</guid>
      <author>nrasch</author>
      <link>http://forums.prototype-ui.com/forums/2/topics/8</link>
    </item>
    <item>
      <title>Adding refresh button to URLWindow replied by nrasch @ Thu, 06 Dec 2007 06:46:57 -0000</title>
      <description>&lt;p&gt;&lt;em&gt;Overview&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;As part of my Prototype-UI testing I wanted to add a &amp;#8216;refresh&amp;#8217; button to my URLWindows.  This briefly explains how I went about it, and the results.&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;Assumptions&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m using Rails on a Windows box for testing, and I&amp;#8217;m using the &amp;#8216;bluelighting&amp;#8217; window style.&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;Adding the button graphic&lt;/em&gt;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Open &amp;#8216;buttons-blue.gif&amp;#8217;&lt;/li&gt;
		&lt;li&gt;Add 40 px to the bottom of the image&amp;#8217;s canvas&lt;/li&gt;
		&lt;li&gt;Copy the non hover and hover versions of your refresh icon into the bottom 40 px of space&lt;/li&gt;
		&lt;li&gt;Save your modified &amp;#8216;buttons-blue.gif&amp;#8217; file&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;em&gt;Modifying the css&lt;/em&gt;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Open &amp;#8216;lighting.css&amp;#8217;&lt;/li&gt;
		&lt;li&gt;Around line 114 (just below the minimize style) add the following:&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
/*CHANGE FOR REFRESH*/
.bluelighting .buttons a.refresh {
  float:left;
    background:transparent url(/themes/window/lighting/buttons-blue_rev1.gif) no-repeat 0 -120px;
    height:20px;
    width:21px;
}

.bluelighting .buttons a.refresh:hover {
    background:transparent url(/themes/window/lighting/buttons-blue_rev1.gif) no-repeat 0 -140px;
}  
/*END CHANGE FOR REFRESH*/
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Note: Please note the -120px and -140px offset.  This utilizes the 40 px of space you added to the &amp;#8216;buttons-blue.gif&amp;#8217; above.  Also note I renamed my gif to &amp;#8216;buttons-blue_rev1.gif&amp;#8217;.&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;Adding the button to the URLWindow&lt;/em&gt;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Create a window object&lt;/li&gt;
		&lt;li&gt;Include the method call &amp;#8216;addButton(&amp;#8216;refresh&amp;#8217;, &amp;#8216;refreshWindow&amp;#8217;)&amp;#8217; into the create window command chain&lt;/li&gt;
		&lt;li&gt;Example: &lt;br /&gt;&lt;pre&gt;&lt;code&gt;
myWin = new UI.URLWindow( { id: 'myWin', url: 'http://www.google.com' } ).setHeader('myWin Example').addButton('refresh').show();
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;Extend the UI.URLWindow class to include the following method:&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
    refreshWindow: function() {
        this.setUrl(this.iframe.src);
    }
&lt;/code&gt;&lt;/pre&gt;

	&lt;ul&gt;
	&lt;li&gt;Save everything, load up a URLWindow, and hit your spiffy new refresh button.  :)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;em&gt;Gotchas&lt;/em&gt;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;From the class source code there does seem to be a way to order the buttons using the &amp;#8216;padding-top&amp;#8217; value as the order index and calling the function &amp;#8216;updateButtonsOrder&amp;#8217;.  However, at this time, I can&amp;#8217;t seem to get it to work&amp;#8230;.&lt;/li&gt;
		&lt;li&gt;If you create a smaller window (:width =&amp;gt; 200, :height =&amp;gt; 200), set a long title, and add a custom button your title will &amp;#8216;spill over&amp;#8217; into the first button&amp;#8217;s space on the title bar&amp;#8230;.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Thanks!&lt;br /&gt;Nathan&lt;/p&gt;</description>
      <pubDate>Thu, 06 Dec 2007 06:46:57 -0000</pubDate>
      <guid isPermaLink="false">forums.prototype-ui.com:2:8:12</guid>
      <author>nrasch</author>
      <link>http://forums.prototype-ui.com/forums/2/topics/8</link>
    </item>
  </channel>
</rss>
