[O] Separate checkIndex
This commit is contained in:
@@ -48,16 +48,13 @@ export default class NavController
|
|||||||
*/
|
*/
|
||||||
updateIndex(index: Index | string, history?: boolean)
|
updateIndex(index: Index | string, history?: boolean)
|
||||||
{
|
{
|
||||||
// Convert index format if it is hash only
|
index = this.checkIndex(index);
|
||||||
if (typeof index == 'string') index = {hash: index, identifier: index};
|
|
||||||
|
|
||||||
// Call custom event
|
// Call custom event
|
||||||
if (this.updateCallback != null) this.updateCallback();
|
if (this.updateCallback != null) this.updateCallback();
|
||||||
|
|
||||||
// Null case
|
// Null case
|
||||||
if (history == null) history = true;
|
if (history == null) history = true;
|
||||||
if (index.title == null) index.title = FormatUtils.toTitleCase(index.hash);
|
|
||||||
|
|
||||||
// Record history or not
|
// Record history or not
|
||||||
if (history)
|
if (history)
|
||||||
{
|
{
|
||||||
@@ -78,6 +75,20 @@ export default class NavController
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check index conversion
|
||||||
|
*
|
||||||
|
* @param index Hash and title | Hash only
|
||||||
|
* @return Index Hash and title
|
||||||
|
*/
|
||||||
|
private checkIndex(index: Index | string): Index
|
||||||
|
{
|
||||||
|
// Convert index format if it is hash only
|
||||||
|
if (typeof index == 'string') index = {hash: index, identifier: index};
|
||||||
|
if (index.title == null) index.title = FormatUtils.toTitleCase(index.hash);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
get id(): string
|
get id(): string
|
||||||
{
|
{
|
||||||
return this.index.identifier
|
return this.index.identifier
|
||||||
|
|||||||
Reference in New Issue
Block a user