Commit e1636c58 authored by Sven Franck's avatar Sven Franck

updated JQM listview to support data-enhanced (needs PR to JQM)

parent 555fcce6
......@@ -2757,9 +2757,6 @@ if ( !$.support.boxShadow ) {
// addNew is used whenever a new page is added
add: function( url, data ) {
console.log("ADDING entry to URL history")
console.log(url)
console.log(data)
data = data || {};
//if there's forward history, wipe it
......@@ -3037,7 +3034,6 @@ if ( !$.support.boxShadow ) {
return;
}
}
// account for direct manipulation of the hash. That is, we will receive a popstate
// when the hash is changed by assignment, and it won't have a state associated. We
// then need to squash the hash. See below for handling of hash assignment that
......@@ -3154,6 +3150,7 @@ if ( !$.support.boxShadow ) {
$.mobile.navigate.navigator = new $.mobile.Navigator( $.mobile.navigate.history );
var loc = $.mobile.path.parseLocation();
$.mobile.navigate.history.add( loc.href, {hash: loc.hash} );
})( jQuery );
......@@ -4475,24 +4472,18 @@ $.widget( "mobile.page", {
},
go: function( steps ) {
console.log("GOOO")
//if hashlistening is enabled use native history method
if ( $.mobile.hashListeningEnabled ) {
console.log("wtf")
console.log(steps)
window.history.go( steps );
} else {
console.log("JQM handle");
//we are not listening to the hash so handle history internally
var activeIndex = $.mobile.navigate.history.activeIndex,
index = activeIndex + parseInt( steps, 10 ),
url = $.mobile.navigate.history.stack[ index ].url,
direction = ( steps >= 1 )? "forward" : "back";
console.log(activeIndex)
console.log(index)
console.log(url)
console.log(direction)
//update the history object
$.mobile.navigate.history.activeIndex = index;
$.mobile.navigate.history.previousIndex = activeIndex;
......@@ -4505,7 +4496,8 @@ $.widget( "mobile.page", {
// TODO rename _handleDestination
_handleDestination: function( to ) {
var history;
// console.log("Handling destination")
// console.log(to)
// clean the hash for comparison if it's a url
if ( $.type(to) === "string" ) {
to = $.mobile.path.stripHash( to );
......@@ -4524,19 +4516,28 @@ $.widget( "mobile.page", {
//
// TODO move check to history object or path object?
to = !$.mobile.path.isPath( to ) ? ( $.mobile.path.makeUrlAbsolute( "#" + to, this._getDocumentBase() ) ) : to;
// console.log("here")
// console.log(to)
// If we're about to go to an initial URL that contains a
// reference to a non-existent internal page, go to the first
// page instead. We know that the initial hash refers to a
// non-existent page, because the initial hash did not end
// up in the initial history entry
// HACK: AND IF IT DID???
// TODO move check to history object?
// console.log("PROBLEM")
if ( to === $.mobile.path.makeUrlAbsolute( "#" + history.initialDst, this._getDocumentBase() ) &&
history.stack.length &&
//$.mobile.path.parseUrl(history.stack[0].url).hash.replace("#","") !== history.initialDst.replace( $.mobile.dialogHashKey, "" ) &&
history.stack[0].url !== history.initialDst.replace( $.mobile.dialogHashKey, "" ) ) {
// console.log("there")
to = this._getInitialContent();
// console.log(to)
}
}
// console.log("TO SET TO")
// console.log(to)
return to || this._getInitialContent();
},
......@@ -4610,6 +4611,8 @@ $.widget( "mobile.page", {
return;
}
}
// console.log("changing content")
// console.log(to);
this._changeContent( this._handleDestination( to ), changePageOptions );
},
......@@ -5151,12 +5154,12 @@ $.widget( "mobile.page", {
// in the loadPage callback where it exists
triggerData.absUrl = settings.absUrl;
}
// Let listeners know we're about to change the current page.
this.element.trigger( pbcEvent, triggerData );
// If the default behavior is prevented, stop here!
if ( pbcEvent.isDefaultPrevented() ) {
// console.log("PUM, stop!")
return false;
}
......@@ -5177,7 +5180,8 @@ $.widget( "mobile.page", {
// Make sure we have a fromPage.
settings.fromPage = settings.fromPage || this.activePage;
// console.log("triggerBeforechange with")
// console.log(to)
// if the page beforechange default is prevented return early
if ( !this._triggerPageBeforeChange(to, triggerData, settings) ) {
return;
......@@ -5212,8 +5216,6 @@ $.widget( "mobile.page", {
alreadyThere, newPageTitle,
params, cssTransitionDeferred,
beforeTransition;
console.log("transition");
console.log(toPage)
// If we are in the midst of a transition, queue the current request.
// We'll call changePage() once we're done with the current transition
......@@ -5269,7 +5271,7 @@ $.widget( "mobile.page", {
isDialog = ( settings.role === "dialog" ||
toPage.jqmData( "role" ) === "dialog" ) &&
toPage.jqmData( "dialog" ) !== true;
console.log("THIS IS A DIAOLIG transition");
// By default, we prevent changePage requests when the fromPage and toPage
// are the same element, but folks that generate content
// manually/dynamically and reuse pages want to be able to transition to
......@@ -5344,7 +5346,6 @@ $.widget( "mobile.page", {
// we're about to display another dialog, then we must add another hash
// and history entry on top so that one may navigate back to the
// original dialog
console.log("we are inside a isDialog and active")
if ( active.url &&
active.url.indexOf( $.mobile.dialogHashKey ) > -1 &&
this.activePage &&
......@@ -5353,9 +5354,8 @@ $.widget( "mobile.page", {
settings.changeHash = false;
alreadyThere = true;
console.log("and already there is set to true")
}
console.log(alreadyThere);
// Normally, we tack on a dialog hash key, but if this is the location
// of a stale dialog, we reuse the URL from the entry
url = ( active.url || "" );
......@@ -5393,10 +5393,6 @@ $.widget( "mobile.page", {
//add page to history stack if it's not back or forward
if ( !historyDir && alreadyThere ) {
console.log("ADDING page to history!")
console.log(historyDir)
console.log(!historyDir)
console.log(alreadyThere)
$.mobile.navigate.history.getActive().pageUrl = pageUrl;
}
......@@ -5591,6 +5587,8 @@ $.widget( "mobile.page", {
};
$.mobile.changePage = function( to, options ) {
// console.log("changePage with to =")
// console.log(to)
$.mobile.pageContainer.pagecontainer( "change", to, options );
};
......@@ -7153,24 +7151,26 @@ $.widget( "mobile.listview", $.extend( {
splitTheme: null,
corners: true,
shadow: true,
inset: false
inset: false,
enhanced: false
},
_create: function() {
var t = this,
listviewClasses = "";
var o = this.options,
listviewClasses;
listviewClasses += t.options.inset ? " ui-listview-inset" : "";
if (!o.enhanced) {
listviewClasses = o.inset ? " ui-listview-inset" : "";
if ( !!t.options.inset ) {
listviewClasses += t.options.corners ? " ui-corner-all" : "";
listviewClasses += t.options.shadow ? " ui-shadow" : "";
}
// create listview markup
t.element.addClass( " ui-listview" + listviewClasses );
if ( !!o.inset ) {
listviewClasses += o.corners ? " ui-corner-all" : "";
listviewClasses += o.shadow ? " ui-shadow" : "";
}
t.refresh( true );
// create listview markup
this.element.addClass( " ui-listview" + listviewClasses );
}
this.refresh( true );
},
// TODO: Remove in 1.5
......@@ -7216,123 +7216,126 @@ $.widget( "mobile.listview", $.extend( {
refresh: function( create ) {
var buttonClass, pos, numli, item, itemClass, itemTheme, itemIcon, icon, a,
isDivider, startCount, newStartCount, value, last, splittheme, splitThemeClass, spliticon,
altButtonClass, dividerTheme, li,
altButtonClass, dividerTheme, li, ol, start, itemClassDict, countBubbles, countTheme, countThemeClass,
o = this.options,
$list = this.element,
ol = !!$.nodeName( $list[ 0 ], "ol" ),
start = $list.attr( "start" ),
itemClassDict = {},
countBubbles = $list.find( ".ui-li-count" ),
countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme,
$list = this.element;
if (!o.enhanced && create) {
ol = !!$.nodeName( $list[ 0 ], "ol" );
start = $list.attr( "start" );
itemClassDict = {};
countBubbles = $list.find( ".ui-li-count" );
countTheme = getAttr( $list[ 0 ], "counttheme" ) || o.countTheme;
countThemeClass = countTheme ? "ui-body-" + countTheme : "ui-body-inherit";
if ( o.theme ) {
$list.addClass( "ui-group-theme-" + o.theme );
}
if ( o.theme ) {
$list.addClass( "ui-group-theme-" + o.theme );
}
// Check if a start attribute has been set while taking a value of 0 into account
if ( ol && ( start || start === 0 ) ) {
startCount = parseInt( start, 10 ) - 1;
$list.css( "counter-reset", "listnumbering " + startCount );
}
// Check if a start attribute has been set while taking a value of 0 into account
if ( ol && ( start || start === 0 ) ) {
startCount = parseInt( start, 10 ) - 1;
$list.css( "counter-reset", "listnumbering " + startCount );
}
this._beforeListviewRefresh();
this._beforeListviewRefresh();
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" );
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" );
for ( pos = 0, numli = li.length; pos < numli; pos++ ) {
item = li.eq( pos );
itemClass = "";
for ( pos = 0, numli = li.length; pos < numli; pos++ ) {
item = li.eq( pos );
itemClass = "";
if ( create || item[ 0 ].className.search( /\bui-li-static\b|\bui-li-divider\b/ ) < 0 ) {
a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
isDivider = ( getAttr( item[ 0 ], "role" ) === "list-divider" );
value = item.attr( "value" );
itemTheme = getAttr( item[ 0 ], "theme" );
if ( create || item[ 0 ].className.search( /\bui-li-static\b|\bui-li-divider\b/ ) < 0 ) {
a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
isDivider = ( getAttr( item[ 0 ], "role" ) === "list-divider" );
value = item.attr( "value" );
itemTheme = getAttr( item[ 0 ], "theme" );
if ( a.length && a[ 0 ].className.search( /\bui-btn\b/ ) < 0 && !isDivider ) {
itemIcon = getAttr( item[ 0 ], "icon" );
icon = ( itemIcon === false ) ? false : ( itemIcon || o.icon );
if ( a.length && a[ 0 ].className.search( /\bui-btn\b/ ) < 0 && !isDivider ) {
itemIcon = getAttr( item[ 0 ], "icon" );
icon = ( itemIcon === false ) ? false : ( itemIcon || o.icon );
// TODO: Remove in 1.5 together with links.js (links.js / .ui-link deprecated in 1.4)
a.removeClass( "ui-link" );
// TODO: Remove in 1.5 together with links.js (links.js / .ui-link deprecated in 1.4)
a.removeClass( "ui-link" );
buttonClass = "ui-btn";
buttonClass = "ui-btn";
if ( itemTheme ) {
buttonClass += " ui-btn-" + itemTheme;
}
if ( itemTheme ) {
buttonClass += " ui-btn-" + itemTheme;
}
if ( a.length > 1 ) {
itemClass = "ui-li-has-alt";
last = a.last();
splittheme = getAttr( last[ 0 ], "theme" ) || o.splitTheme || getAttr( item[ 0 ], "theme", true );
splitThemeClass = splittheme ? " ui-btn-" + splittheme : "";
spliticon = getAttr( last[ 0 ], "icon" ) || getAttr( item[ 0 ], "icon" ) || o.splitIcon;
altButtonClass = "ui-btn ui-btn-icon-notext ui-icon-" + spliticon + splitThemeClass;
last
.attr( "title", $.trim( last.getEncodedText() ) )
.addClass( altButtonClass )
.empty();
} else if ( icon ) {
buttonClass += " ui-btn-icon-right ui-icon-" + icon;
}
if ( a.length > 1 ) {
itemClass = "ui-li-has-alt";
last = a.last();
splittheme = getAttr( last[ 0 ], "theme" ) || o.splitTheme || getAttr( item[ 0 ], "theme", true );
splitThemeClass = splittheme ? " ui-btn-" + splittheme : "";
spliticon = getAttr( last[ 0 ], "icon" ) || getAttr( item[ 0 ], "icon" ) || o.splitIcon;
altButtonClass = "ui-btn ui-btn-icon-notext ui-icon-" + spliticon + splitThemeClass;
last
.attr( "title", $.trim( last.getEncodedText() ) )
.addClass( altButtonClass )
.empty();
} else if ( icon ) {
buttonClass += " ui-btn-icon-right ui-icon-" + icon;
}
a.first().addClass( buttonClass );
} else if ( isDivider ) {
dividerTheme = ( getAttr( item[ 0 ], "theme" ) || o.dividerTheme || o.theme );
a.first().addClass( buttonClass );
} else if ( isDivider ) {
dividerTheme = ( getAttr( item[ 0 ], "theme" ) || o.dividerTheme || o.theme );
itemClass = "ui-li-divider ui-bar-" + ( dividerTheme ? dividerTheme : "inherit" );
itemClass = "ui-li-divider ui-bar-" + ( dividerTheme ? dividerTheme : "inherit" );
item.attr( "role", "heading" );
} else if ( a.length <= 0 ) {
itemClass = "ui-li-static ui-body-" + ( itemTheme ? itemTheme : "inherit" );
item.attr( "role", "heading" );
} else if ( a.length <= 0 ) {
itemClass = "ui-li-static ui-body-" + ( itemTheme ? itemTheme : "inherit" );
}
if ( ol && value ) {
newStartCount = parseInt( value , 10 ) - 1;
item.css( "counter-reset", "listnumbering " + newStartCount );
}
}
if ( ol && value ) {
newStartCount = parseInt( value , 10 ) - 1;
item.css( "counter-reset", "listnumbering " + newStartCount );
// Instead of setting item class directly on the list item
// at this point in time, push the item into a dictionary
// that tells us what class to set on it so we can do this after this
// processing loop is finished.
if ( !itemClassDict[ itemClass ] ) {
itemClassDict[ itemClass ] = [];
}
itemClassDict[ itemClass ].push( item[ 0 ] );
}
// Instead of setting item class directly on the list item
// at this point in time, push the item into a dictionary
// that tells us what class to set on it so we can do this after this
// processing loop is finished.
// Set the appropriate listview item classes on each list item.
// The main reason we didn't do this
// in the for-loop above is because we can eliminate per-item function overhead
// by calling addClass() and children() once or twice afterwards. This
// can give us a significant boost on platforms like WP7.5.
if ( !itemClassDict[ itemClass ] ) {
itemClassDict[ itemClass ] = [];
for ( itemClass in itemClassDict ) {
$( itemClassDict[ itemClass ] ).addClass( itemClass );
}
itemClassDict[ itemClass ].push( item[ 0 ] );
}
countBubbles.each( function() {
$( this ).closest( "li" ).addClass( "ui-li-has-count" );
});
if ( countThemeClass ) {
countBubbles.addClass( countThemeClass );
}
// Set the appropriate listview item classes on each list item.
// The main reason we didn't do this
// in the for-loop above is because we can eliminate per-item function overhead
// by calling addClass() and children() once or twice afterwards. This
// can give us a significant boost on platforms like WP7.5.
// Deprecated in 1.4. From 1.5 you have to add class ui-li-has-thumb or ui-li-has-icon to the LI.
this._addThumbClasses( li );
this._addThumbClasses( li.find( ".ui-btn" ) );
for ( itemClass in itemClassDict ) {
$( itemClassDict[ itemClass ] ).addClass( itemClass );
}
this._afterListviewRefresh();
countBubbles.each( function() {
$( this ).closest( "li" ).addClass( "ui-li-has-count" );
});
if ( countThemeClass ) {
countBubbles.addClass( countThemeClass );
this._addFirstLastClasses( li, this._getVisibles( li, create ), create );
}
// Deprecated in 1.4. From 1.5 you have to add class ui-li-has-thumb or ui-li-has-icon to the LI.
this._addThumbClasses( li );
this._addThumbClasses( li.find( ".ui-btn" ) );
this._afterListviewRefresh();
this._addFirstLastClasses( li, this._getVisibles( li, create ), create );
}
}, $.mobile.behaviors.addFirstLastClasses ) );
......@@ -9973,6 +9976,7 @@ $.widget( "mobile.popup", {
},
_eatEventAndClose: function( theEvent ) {
theEvent.mother = "fucker";
theEvent.preventDefault();
theEvent.stopImmediatePropagation();
if ( this.options.dismissible ) {
......@@ -10595,9 +10599,8 @@ $.widget( "mobile.popup", {
var parsedDst, toUrl,
currentOptions = this.options,
immediate = false;
console.log("CLOSING")
if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ) {
console.log("return = do nothing?");
return;
}
......@@ -10607,21 +10610,22 @@ $.widget( "mobile.popup", {
if ( theEvent && theEvent.type === "pagebeforechange" && data ) {
// Determine whether we need to rapid-close the popup, or whether we can
// take the time to run the closing transition
console.log("hm...data.toPage =")
console.log(data.toPage);
if ( typeof data.toPage === "string" ) {
parsedDst = data.toPage;
} else {
parsedDst = data.toPage.jqmData( "url" );
console.log("object, so parsedDst is toPage data-url ="+parsedDst);
}
parsedDst = $.mobile.path.parseUrl( parsedDst );
toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash;
// console.log("comparing myUrl with parsedDst")
// console.log(this._myUrl)
// console.log($.mobile.path.makeUrlAbsolute( toUrl ))
if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ) {
// Going to a different page - close immediately
immediate = true;
} else {
// console.log("SET TO STOP!")
theEvent.preventDefault();
}
}
......@@ -13355,6 +13359,7 @@ $.widget( "mobile.filterable", {
});
this._setInput( opts.input );
if ( !opts.enhanced ) {
this._filterItems( ( ( this._search && this._search.val() ) || "" ).toLowerCase() );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment