Skip to content

Commit bd711e9

Browse files
committed
Added fade transitions to fetchlinks.
1 parent f02ad3d commit bd711e9

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

css/structure/jquery.mobile.core.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ div.ui-mobile-viewport { overflow-x: hidden; }
2323
@media screen and (orientation: landscape){
2424
.ui-mobile, .ui-mobile .ui-page { min-height: 300px; }
2525
}
26-
2726
/* native overflow scrolling */
2827
.ui-page.ui-mobile-touch-overflow,
2928
.ui-mobile-touch-overflow.ui-native-fixed .ui-content {

docs/pages/fetchlinks.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ <h2>AJAX Fetch Links</h2>
2626

2727
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-rel=&quot;dialog&quot;</strong>&gt;Link&lt;/a&gt;
2828
</code></pre>
29-
<p>Note: The below example temporary contains a <code>data-fragment</code> attribute.</p>
30-
31-
<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>
32-
>>>>>>> Refactored sections JS to use widget factory scheme; continued work on fetchlinks/inline loader.
29+
<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>
3330

3431
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-target=&quot;.quote&quot;</strong>&gt;
3532
</code></pre>
3633

3734

35+
<div class="quote">
36+
<p>To be replaced.</p>
37+
</div>
38+
39+
40+
3841
<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>
3942

4043
<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 @@ <h2>Local Fetch Links</h2>
6568

6669
</div>
6770

68-
<div class="quote">
69-
<p>To be replaced.</p>
70-
</div>
71-
7271
</div>
7372

7473

js/jquery.mobile.fetchlink.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
66
},
77
_create: function() {
88

9-
$( this.element ).click(function() {
9+
$( this.element )
10+
.click(function() {
1011
var el = $( this ),
1112
url = el.attr( "href" ),
1213
target = el.data( "target" ),
@@ -36,23 +37,19 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
3637
});
3738

3839
$.get( url, function( data ) {
39-
40-
/* Swiped from the jQuery core; $.get() should really be replaced by .load() */
4140
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
4241
data = $( $("<div/>").append( data.replace( rscript, "" ) ).find( load ) )
4342
responseEl = !fragment ? $( data.html() ) : data;
43+
44+
setTimeout(function() {
45+
targetEl[ method ]( responseEl.addClass('fade in') );
4446

45-
setTimeout(function() {
46-
targetEl[ method ]( responseEl );
47-
responseEl
48-
.trigger( "create" )
49-
.trigger( "fetchlink", { target : targetEl, data: responseEl } );
5047
responseEl
51-
.find('[data-role="header"]')
5248
.trigger( "create" )
53-
}, 2000 );
54-
});
55-
49+
.trigger( "fetchlink", { target : targetEl, data: responseEl });
50+
}, 300);
51+
52+
});
5653
}
5754
}
5855
return false;
@@ -61,8 +58,12 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
6158
}
6259
});
6360

64-
$( document ).bind( "inlineLoader", function( e ){
65-
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
61+
$( document ).bind( "inlineLoader", function( e ){
62+
$( e.target ).children().removeClass('fade in').addClass('fade out');
63+
64+
setTimeout(function() {
65+
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
66+
}, 300);
6667
});
6768

6869
//auto self-init widgets

js/jquery.mobile.page.sections.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ $.widget( "mobile.sections", $.mobile.widget, {
3939

4040
//apply theming and markup modifications to page,header,content,footer
4141
if ( role === "header" || role === "footer" ) {
42-
4342
var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
4443

4544
$this

0 commit comments

Comments
 (0)