Added fade transitions to fetchlinks.

This commit is contained in:
Mat Marquis 2011-12-12 18:32:18 -05:00
parent f02ad3d67b
commit bd711e9f19
4 changed files with 22 additions and 24 deletions

View file

@ -23,7 +23,6 @@ div.ui-mobile-viewport { overflow-x: hidden; }
@media screen and (orientation: landscape){
.ui-mobile, .ui-mobile .ui-page { min-height: 300px; }
}
/* native overflow scrolling */
.ui-page.ui-mobile-touch-overflow,
.ui-mobile-touch-overflow.ui-native-fixed .ui-content {

View file

@ -26,15 +26,18 @@
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-rel=&quot;dialog&quot;</strong>&gt;Link&lt;/a&gt;
</code></pre>
<p>Note: The below example temporary contains a <code>data-fragment</code> attribute.</p>
<p>A <a data-role="fetchlink" data-target=".quote" href="dialog.html">fetch link</a> is created by adding the <code>data-target</code> attribute to a link. This tells the framework to <strong>not</strong> change pages and instead load the <code>href</code> into the target DOM element on the current page when the link is clicked. The target can be any jQuery selector (or restrict to ID only?). </p>
>>>>>>> Refactored sections JS to use widget factory scheme; continued work on fetchlinks/inline loader.
<p>A <a data-role="fetchlink" data-target=".quote" href="dialog.html" data-transition="fade">fetch link</a> is created by adding the <code>data-target</code> attribute to a link. This tells the framework to <strong>not</strong> change pages and instead load the <code>href</code> into the target DOM element on the current page when the link is clicked. The target can be any jQuery selector (or restrict to ID only?). </p>
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-target=&quot;.quote&quot;</strong>&gt;
</code></pre>
<div class="quote">
<p>To be replaced.</p>
</div>
<p>The <a href="dialog.html" data-role="fetchlink" data-target=".quote" data-fragment="[data-role='content']">content fragment</a> from the loaded page can be specified. By default, the framework will load in the <strong>contents</strong> of the <code>data-role=&quot;page&quot;</code> container (not the page wrapper itself), but it's possible to specify what content from the page to pull into the target by adding a <code>data-fragment</code> attribute to the link with any jQuery selector.</p>
<pre><code>&lt;a href=&quot;dialog.html&quot; data-target=&quot;.quote&quot; <strong>data-fragment=&quot;[data-role='content']&quot;</strong>&gt;
@ -65,10 +68,6 @@
</div>
<div class="quote">
<p>To be replaced.</p>
</div>
</div>

View file

@ -6,7 +6,8 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
},
_create: function() {
$( this.element ).click(function() {
$( this.element )
.click(function() {
var el = $( this ),
url = el.attr( "href" ),
target = el.data( "target" ),
@ -36,23 +37,19 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
});
$.get( url, function( data ) {
/* Swiped from the jQuery core; $.get() should really be replaced by .load() */
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
data = $( $("<div/>").append( data.replace( rscript, "" ) ).find( load ) )
responseEl = !fragment ? $( data.html() ) : data;
setTimeout(function() {
targetEl[ method ]( responseEl.addClass('fade in') );
setTimeout(function() {
targetEl[ method ]( responseEl );
responseEl
.trigger( "create" )
.trigger( "fetchlink", { target : targetEl, data: responseEl } );
responseEl
.find('[data-role="header"]')
.trigger( "create" )
}, 2000 );
});
.trigger( "fetchlink", { target : targetEl, data: responseEl });
}, 300);
});
}
}
return false;
@ -61,8 +58,12 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
}
});
$( document ).bind( "inlineLoader", function( e ){
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
$( document ).bind( "inlineLoader", function( e ){
$( e.target ).children().removeClass('fade in').addClass('fade out');
setTimeout(function() {
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
}, 300);
});
//auto self-init widgets

View file

@ -39,7 +39,6 @@ $.widget( "mobile.sections", $.mobile.widget, {
//apply theming and markup modifications to page,header,content,footer
if ( role === "header" || role === "footer" ) {
var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
$this