Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Close #21 , Close #18 and Close #23 - titles, before-after-show-hide-…

…events and modals are fixed
  • Loading branch information...
commit 4ecb74b36db0000a9efd2e6a1916e19b3f54f93b 1 parent 7ca48e9
@finnsson authored
Showing with 12 additions and 22 deletions.
  1. +12 −16 pager.js
  2. +0 −6 test/should_show_modal.html
View
28 pager.js
@@ -11,9 +11,11 @@ _ko.arrayValue = function (arr) {
});
};
-pager.ChildManager = function (children) {
+pager.ChildManager = function (children, page) {
var currentChild = null;
+ var me = this;
+ this.page = page;
/*
@@ -42,15 +44,15 @@ pager.ChildManager = function (children) {
}
}
});
- // find modals in parent - but only if this page is not a modal!
+ // find modals in parent - but only if 1) no match is found, 2) this page got a parent and 3) this page is not a modal!
var isModal = false;
- /*
- if (!currentChild && me.page.parentPage) {
+
+ if (!currentChild && me.page.parentPage && !me.page.getValue().modal) {
var parentChildren = me.page.parentPage.children;
_.each(parentChildren(), function (child) {
if (!match) {
- var id = _ko.value(_ko.value(child.valueAccessor()).id);
- var modal = _ko.value(_ko.value(child.valueAccessor()).modal);
+ var id = child.getId();
+ var modal = child.getValue().modal;
if (modal) {
if (id === currentRoute ||
((currentRoute === '' || currentRoute == null) && id === 'start')) {
@@ -60,23 +62,17 @@ pager.ChildManager = function (children) {
}
if (id === '?' && !wildcard) {
wildcard = child;
+ isModal = true;
}
}
}
});
}
- */
+
if (!currentChild && wildcard) {
currentChild = wildcard;
currentChild.currentId = currentRoute;
}
- /*
- if (oldCurrentChild === currentChild && oldCurrentChild) {
- if(!$(oldCurrentChild.element).is(':visible')) {
- oldCurrentChild.showPage();
- }
- return;
- }*/
if (oldCurrentChild) {
oldCurrentChild.hidePage(function () {
if (currentChild) {
@@ -101,7 +97,7 @@ pager.start = function (viewModel) {
pager.extendWithPage = function (viewModel) {
viewModel.$page = new pager.Page();
- pager.childManager = new pager.ChildManager(viewModel.$page.children);
+ pager.childManager = new pager.ChildManager(viewModel.$page.children, viewModel.$page);
viewModel.$page.childManager = pager.childManager;
};
@@ -139,7 +135,7 @@ pager.Page = function (element, valueAccessor, allBindingsAccessor, viewModel, b
this.children = ko.observableArray([]);
- this.childManager = new pager.ChildManager(this.children);
+ this.childManager = new pager.ChildManager(this.children, this);
this.parentPage = null;
this.currentId = null;
};
View
6 test/should_show_modal.html
@@ -48,10 +48,6 @@
window.location.hash = '#first/second/ok';
- ok(true, "not now");
- start();
-
- /*
until(function () {
return $('#modal').is(':visible');
@@ -75,8 +71,6 @@
});
- */
-
});
</script>
Please sign in to comment.
Something went wrong with that request. Please try again.