Skip to content
Browse files

Migration to try using kb.loadUrl

  • Loading branch information...
1 parent 1d734a4 commit bdacb9e7c3f3aa8e9888875a5850f78551e713e5 Kevin Malakoff committed Sep 16, 2012
Showing with 242 additions and 86 deletions.
  1. +3 −1 README.md
  2. +4 −4 examples/pnp-t_zpt_bb.html
  3. +13 −2 knockback-page-navigator-panes.js
  4. +1 −1 knockback-page-navigator-panes.min.js
  5. +12 −1 knockback-page-navigator-simple.js
  6. +1 −1 knockback-page-navigator-simple.min.js
  7. +3 −1 knockback-pane-navigator.js
  8. +1 −1 knockback-pane-navigator.min.js
  9. +5 −1 packages/npm/README.md
  10. +19 −10 packages/npm/knockback-page-navigator-panes.js
  11. +1 −1 packages/npm/knockback-page-navigator-panes.min.js
  12. +17 −9 packages/npm/knockback-page-navigator-simple.js
  13. +1 −1 packages/npm/knockback-page-navigator-simple.min.js
  14. +7 −4 packages/npm/knockback-pane-navigator.js
  15. +1 −1 packages/npm/knockback-pane-navigator.min.js
  16. +19 −10 packages/nuget/Content/Scripts/knockback-page-navigator-panes.js
  17. +1 −1 packages/nuget/Content/Scripts/knockback-page-navigator-panes.min.js
  18. +17 −9 packages/nuget/Content/Scripts/knockback-page-navigator-simple.js
  19. +1 −1 packages/nuget/Content/Scripts/knockback-page-navigator-simple.min.js
  20. +7 −4 packages/nuget/Content/Scripts/knockback-pane-navigator.js
  21. +1 −1 packages/nuget/Content/Scripts/knockback-pane-navigator.min.js
  22. +2 −1 src/component-imports.coffee
  23. +1 −1 src/knockback-pane-navigator/knockback-pane-navigator-helpers.coffee
  24. +10 −1 src/shared/knockback-page-navigator-helpers.coffee
  25. +22 −3 test/knockback-page-navigator-panes/test-amd.coffee
  26. +1 −1 test/knockback-page-navigator-panes/test-latest-amd.html
  27. +23 −4 test/knockback-page-navigator-panes/test.coffee
  28. +22 −3 test/knockback-page-navigator-simple/test-amd.coffee
  29. +1 −1 test/knockback-page-navigator-simple/test-latest-amd.html
  30. +23 −4 test/knockback-page-navigator-simple/test.coffee
  31. +1 −1 test/knockback-pane-navigator/test-latest-amd.html
  32. +1 −1 test/knockback-pane-navigator/test.coffee
View
4 README.md
@@ -9,6 +9,8 @@ KnockbackNavigators.js provides page navigators, a pane navigator, and transitio
**Note**: if you are using Knockback-Navigators.js with Knockback.js without a module loader, you must include Knockback.js before Knockback-Navigators.js.
+**Note**: Currenty Knockback-Navigators.js only supports the window.location.hash functions. If anyone has recommendations for generalizing it for Push State as well, please submit an issue to make your proposal. The main issue is leaving the routing solution up to the library user (allowing for any routing solution) and generalizing the mechanism for checking the fragment to route.
+
#Download Latest (0.1.1):
Please see the [release notes](https://github.com/kmalakoff/knockback-navigators/blob/master/RELEASE_NOTES.md) for upgrade pointers.
@@ -28,7 +30,7 @@ If you have some production quality transitions that you'd like to submit to the
###Module Loading
-Knockback-Navigators.js is compatible with Require.js and AMD module loading. Module names:
+Knockback-Navigators.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:
* 'knockback-page-navigator-panes' - knockback-page-navigator-panes.js. Comes bundled with knockback-pane-navigator.js
* 'knockback-page-navigator-simple' - knockback-page-navigator-simple.js.
View
8 examples/pnp-t_zpt_bb.html
@@ -17,22 +17,22 @@
<!-- VIEWS -->
<div class='pane' id='main'>
<div class='hero-unit'>
- <a href='#page1' class='btn btn-warning btn-small'>Page1</a>
+ <a onclick="kb.loadUrl('page1')" class='btn btn-warning btn-small'>Page1</a>
<h1>Main</h1>
</div>
</div>
<div class='pane' id='page1'>
<div class='hero-unit'>
- <a href='#' class='btn btn-small'><i class='icon-step-backward'></i><span> Back</span></a>
- <a href='#page2' class='btn btn-warning btn-small'>Page2</a>
+ <a onclick="kb.loadUrl('')" class='btn btn-small'><i class='icon-step-backward'></i><span> Back</span></a>
+ <a onclick="kb.loadUrl('page2')" class='btn btn-warning btn-small'>Page2</a>
<h1>Page1</h1>
</div>
</div>
<div class='pane' id='page2'>
<div class='hero-unit'>
- <a href='#page1' class='btn btn-small'><i class='icon-step-backward'></i><span> Back</span></a>
+ <a onclick="kb.loadUrl('page1')" class='btn btn-small'><i class='icon-step-backward'></i><span> Back</span></a>
<h1>Page2</h1>
</div>
</div>
View
15 knockback-page-navigator-panes.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -474,7 +476,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
@@ -615,9 +617,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
View
2 knockback-page-navigator-panes.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
13 knockback-page-navigator-simple.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -212,9 +214,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
View
2 knockback-page-navigator-simple.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
View
4 knockback-pane-navigator.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -350,7 +352,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
View
2 knockback-pane-navigator.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
6 packages/npm/README.md
@@ -7,6 +7,10 @@ KnockbackNavigators.js provides page navigators, a pane navigator, and transitio
* [API Documentation](http://kmalakoff.github.com/knockback-navigators/doc/index.html)
* [Live Examples](http://kmalakoff.github.com/knockback-navigators/)
+**Note**: if you are using Knockback-Navigators.js with Knockback.js without a module loader, you must include Knockback.js before Knockback-Navigators.js.
+
+**Note**: Currenty Knockback-Navigators.js only supports the window.location.hash functions. If anyone has recommendations for generalizing it for Push State as well, please submit an issue to make your proposal. The main issue is leaving the routing solution up to the library user (allowing for any routing solution) and generalizing the mechanism for checking the fragment to route.
+
#Download Latest (0.1.1):
Please see the [release notes](https://github.com/kmalakoff/knockback-navigators/blob/master/RELEASE_NOTES.md) for upgrade pointers.
@@ -26,7 +30,7 @@ If you have some production quality transitions that you'd like to submit to the
###Module Loading
-Knockback-Navigators.js is compatible with Require.js and AMD module loading. Module names:
+Knockback-Navigators.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:
* 'knockback-page-navigator-panes' - knockback-page-navigator-panes.js. Comes bundled with knockback-pane-navigator.js
* 'knockback-page-navigator-simple' - knockback-page-navigator-simple.js.
View
29 packages/npm/knockback-page-navigator-panes.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -160,7 +162,7 @@ kb.PageNavigatorPanes = (function() {
active_page = this.activePage();
active_page.el || pane_navigator.ensureElement(active_page);
if (active_page.el.parentNode !== this.el) {
- $(this.el).append(active_page.el);
+ this.el.appendChild(active_page.el);
}
return active_page;
}
@@ -181,10 +183,7 @@ kb.PageNavigatorPanes = (function() {
var page_navigator;
page_navigator = this;
return function() {
- if (page_navigator.destroyed) {
- return;
- }
- return page_navigator.routeTriggered(this, callback, arguments);
+ page_navigator.destroyed || page_navigator.routeTriggered(this, callback, arguments);
};
};
@@ -349,6 +348,7 @@ kb.PaneNavigator = (function() {
if (!previous_pane) {
return null;
}
+ previous_pane.activate(this.el);
this.cleanupTransition(true);
active_pane = this.activePane();
if ('transition' in options) {
@@ -476,7 +476,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
@@ -617,9 +617,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
@@ -717,15 +726,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/npm/knockback-page-navigator-panes.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&$(this.el).append(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){if(t.destroyed)return;return t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
26 packages/npm/knockback-page-navigator-simple.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -143,7 +145,7 @@ kb.PageNavigatorSimple = (function() {
active_page = this.activePage();
active_page.el || pane_navigator.ensureElement(active_page);
if (active_page.el.parentNode !== this.el) {
- $(this.el).append(active_page.el);
+ this.el.appendChild(active_page.el);
}
return active_page;
}
@@ -160,10 +162,7 @@ kb.PageNavigatorSimple = (function() {
var page_navigator;
page_navigator = this;
return function() {
- if (page_navigator.destroyed) {
- return;
- }
- return page_navigator.routeTriggered(this, callback, arguments);
+ page_navigator.destroyed || page_navigator.routeTriggered(this, callback, arguments);
};
};
@@ -215,9 +214,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
@@ -315,15 +323,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/npm/knockback-page-navigator-simple.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&$(this.el).append(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){if(t.destroyed)return;return t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
View
11 packages/npm/knockback-pane-navigator.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -222,6 +224,7 @@ kb.PaneNavigator = (function() {
if (!previous_pane) {
return null;
}
+ previous_pane.activate(this.el);
this.cleanupTransition(true);
active_pane = this.activePane();
if ('transition' in options) {
@@ -349,7 +352,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
@@ -551,15 +554,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/npm/knockback-pane-navigator.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
29 packages/nuget/Content/Scripts/knockback-page-navigator-panes.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -160,7 +162,7 @@ kb.PageNavigatorPanes = (function() {
active_page = this.activePage();
active_page.el || pane_navigator.ensureElement(active_page);
if (active_page.el.parentNode !== this.el) {
- $(this.el).append(active_page.el);
+ this.el.appendChild(active_page.el);
}
return active_page;
}
@@ -181,10 +183,7 @@ kb.PageNavigatorPanes = (function() {
var page_navigator;
page_navigator = this;
return function() {
- if (page_navigator.destroyed) {
- return;
- }
- return page_navigator.routeTriggered(this, callback, arguments);
+ page_navigator.destroyed || page_navigator.routeTriggered(this, callback, arguments);
};
};
@@ -349,6 +348,7 @@ kb.PaneNavigator = (function() {
if (!previous_pane) {
return null;
}
+ previous_pane.activate(this.el);
this.cleanupTransition(true);
active_pane = this.activePane();
if ('transition' in options) {
@@ -476,7 +476,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
@@ -617,9 +617,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
@@ -717,15 +726,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/nuget/Content/Scripts/knockback-page-navigator-panes.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&$(this.el).append(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){if(t.destroyed)return;return t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-panes",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorPanes=function(){function e(e,n){n==null&&(n={}),e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","previousPage","activeUrl","loadPage","goBack","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.pane_navigator=new t.PaneNavigator(e,n)}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.pane_navigator.destroy(),this.pane_navigator=null},e.prototype.hasHistory=function(){return!this.pane_navigator.no_history},e.prototype.activePage=function(){return this.pane_navigator.activePane()},e.prototype.activeUrl=function(){var e;return(e=this.pane_navigator.activePane())?e.url:null},e.prototype.previousPage=function(){return this.pane_navigator.previousPane()},e.prototype.previousUrl=function(){var e;return(e=this.pane_navigator.previousPage())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),i=t.popOverrideTransition(),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):this.pane_navigator.push(new t.Pane(e,window.location.hash),i?{transition:i}:null)},e.prototype.goBack=function(){var e,n;return n=t.popOverrideTransition(),this.pane_navigator.pop(),!(e=this.pane_navigator.activePane())||t.loadUrl(e.url),e},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r,i,s;s=window.location.hash;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if((i=this.previousPage())&&i.url===s)return this.goBack();if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorPanes=t.PageNavigatorPanes),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorPanes={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorPanes(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
26 packages/nuget/Content/Scripts/knockback-page-navigator-simple.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -143,7 +145,7 @@ kb.PageNavigatorSimple = (function() {
active_page = this.activePage();
active_page.el || pane_navigator.ensureElement(active_page);
if (active_page.el.parentNode !== this.el) {
- $(this.el).append(active_page.el);
+ this.el.appendChild(active_page.el);
}
return active_page;
}
@@ -160,10 +162,7 @@ kb.PageNavigatorSimple = (function() {
var page_navigator;
page_navigator = this;
return function() {
- if (page_navigator.destroyed) {
- return;
- }
- return page_navigator.routeTriggered(this, callback, arguments);
+ page_navigator.destroyed || page_navigator.routeTriggered(this, callback, arguments);
};
};
@@ -215,9 +214,18 @@ kb.popOverrideTransition = function() {
}
};
+kb.dispatchUrl = function(url) {
+ window.location.hash = url;
+ if (window.Backbone && window.Backbone.History.started) {
+ return window.Backbone.history.loadUrl(url);
+ } else if (window.Path) {
+ return window.Path.dispatch(url);
+ }
+};
+
kb.loadUrl = function(url, transition) {
kb.override_transitions.push(transition);
- return window.location.hash = url;
+ return kb.dispatchUrl(url);
};
kb.loadUrlFn = function(url, transition) {
@@ -315,15 +323,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/nuget/Content/Scripts/knockback-page-navigator-simple.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&$(this.el).append(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){if(t.destroyed)return;return t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.loadUrl=function(e,n){return t.override_transitions.push(n),window.location.hash=e},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-page-navigator-simple",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PageNavigatorSimple=function(){function e(e,t){this.options=t!=null?t:{},e||r(this,"el"),s.bindAll(this,"hasHistory","activePage","activeUrl","loadPage","dispatcher"),this.el=e.length?e[0]:e,$(this.el).addClass("page"),this.active_page=n.observable()}return e.prototype.destroy=function(){return this.destroyed=!0,this.el=null,this.active_page=null},e.prototype.hasHistory=function(){return!1},e.prototype.activePage=function(){return this.active_page()},e.prototype.activeUrl=function(){var e;return(e=this.active_page())?e.url:null},e.prototype.loadPage=function(e){var n,i;return e||r(this,"page info"),this.activeUrl()===window.location.hash?(n=this.activePage(),n.el||pane_navigator.ensureElement(n),n.el.parentNode!==this.el&&this.el.appendChild(n.el),n):((i=this.activePage())&&i.destroy(this.options),n=new t.Pane(e,window.location.hash),n.activate(this.el),this.active_page(n),n)},e.prototype.dispatcher=function(e){var t;return t=this,function(){t.destroyed||t.routeTriggered(this,e,arguments)}},e.prototype.routeTriggered=function(e,t,n){var r;if((r=this.activePage())&&r.url===window.location.hash)return this.loadPage(r);if(t)return t.apply(e,n)},e}(),typeof exports!="undefined"&&(exports.PageNavigatorSimple=t.PageNavigatorSimple),n&&n.bindingHandlers&&(n.bindingHandlers.PageNavigatorSimple={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PageNavigatorSimple(e,o),t.utils.wrappedPageNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return typeof o.unloaded=="function"&&o.unloaded(u),t.utils.wrappedPageNavigator(e,null)}),typeof o.loaded=="function"?o.loaded(u):void 0}}),t.override_transitions=[],t.popOverrideTransition=function(){return t.override_transitions.length?t.override_transitions.pop():null},t.dispatchUrl=function(e){window.location.hash=e;if(window.Backbone&&window.Backbone.History.started)return window.Backbone.history.loadUrl(e);if(window.Path)return window.Path.dispatch(e)},t.loadUrl=function(e,n){return t.override_transitions.push(n),t.dispatchUrl(e)},t.loadUrlFn=function(e,n){return function(r,i){t.loadUrl(e,n),!r||!r.stopPropagation||(i=r);if(i&&i.stopPropagation)return i.stopPropagation(),i.preventDefault()}},t.utils||(t.utils={}),t.utils.wrappedPageNavigator=function(e,t){return arguments.length===1||e.__kb_page_navigator===t?e.__kb_page_navigator:(e.__kb_page_navigator&&e.__kb_page_navigator.destroy(),e.__kb_page_navigator=t,t)},t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t})}).call(this);
View
11 packages/nuget/Content/Scripts/knockback-pane-navigator.js
@@ -33,6 +33,8 @@ try {
this.kb || (this.kb = kb || (kb = {}));
+this.Backbone || (this.Backbone = this.kb.Backbone);
+
try {
ko = typeof require !== 'undefined' ? require('knockout') : this.ko;
} catch (e) {
@@ -222,6 +224,7 @@ kb.PaneNavigator = (function() {
if (!previous_pane) {
return null;
}
+ previous_pane.activate(this.el);
this.cleanupTransition(true);
active_pane = this.activePane();
if ('transition' in options) {
@@ -349,7 +352,7 @@ kb.utils.wrappedPaneNavigator = function(el, value) {
return value;
};
-if ($.fn) {
+if (this.$ && $.fn) {
$.fn.findByPath = function(path) {
var $current_el, component, components, current_el, el, results, _i, _j, _len, _len1;
results = [];
@@ -551,15 +554,15 @@ kb.Pane = (function() {
return this;
};
- Pane.prototype.activate = function(el) {
+ Pane.prototype.activate = function(container_el) {
var view_model;
this.ensureElement();
if ($(this.el).hasClass('active')) {
return;
}
$(this.el).addClass('active');
- if (this.el.parentNode !== el) {
- $(el).append(this.el);
+ if (this.el.parentNode !== container_el) {
+ container_el.appendChild(this.el);
}
view_model = this.view_model ? this.view_model : ko.dataFor(this.el);
if (view_model && view_model.activate) {
View
2 packages/nuget/Content/Scripts/knockback-pane-navigator.min.js
@@ -3,4 +3,4 @@
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
-*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={}));try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&$(e).append(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
+*/(function(){return function(e){return typeof define=="function"&&define.amd?define("knockback-pane-navigator",e):e.call(this)}(function(){var e,t,n,r,i,s;r=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is missing"},i=function(e,t){throw""+(s.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"};try{this.kb=t=!this.kb&&typeof require!="undefined"?require("knockback"):this.kb}catch(o){({})}this.kb||(this.kb=t||(t={})),this.Backbone||(this.Backbone=this.kb.Backbone);try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(o){({})}return n||(n={}),n.observable||(n.dataFor=function(e){return null},n.removeNode=function(e){return $(e).remove()},n.observable=function(e){var t;return t=e,function(e){return arguments.length?t=e:t}},n.observableArray=function(e){var t;return t=n.observable(arguments.length?e:[]),t.push=function(){return t().push.apply(t(),arguments)},t.pop=function(){return t().pop.apply(t(),arguments)},t}),s=this._?this._:t._?t._:{},s.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},s.bindAll=function(t,n){var r,i,s,o;o=Array.prototype.slice.call(arguments,1);for(i=0,s=o.length;i<s;i++)r=o[i],e(t,r)}),s.isElement||(s.isElement=function(e){return e&&e.nodeType===1}),this.x$&&(this.$=this.x$),t.PaneNavigator=function(){function e(e,t){var i,s;e||r(this,"el");for(i in t)s=t[i],this[i]=s;this.panes=n.observableArray(),this.el=e&&e.length?e[0]:e,$(this.el).addClass("pane-navigator")}return e.prototype.destroy=function(){return this.el=null,this.clear({silent:!0})},e.prototype.clear=function(e){var t,n,r,i;e==null&&(e={}),this.cleanupTransition(!0),(t=this.activePane())&&t.destroy(this),n=this.panes(),i=n.slice(),i.pop(),n.splice(0,n.length);while(r=i.pop())r.el&&r.destroy(this);return e.silent||this.panes([]),this},e.prototype.activePane=function(){return this.paneAt(-1)},e.prototype.previousPane=function(){return this.paneAt(-2)},e.prototype.paneAt=function(e){var t,n;return n=this.panes(),t=e<0?n.length+e:e,t>=0&&t<n.length?n[t]:null},e.prototype.push=function(e,t){var n,r,i,o=this;t==null&&(t={});if(!e)return;return this.cleanupTransition(!0),"transition"in t&&(e.transition=t.transition),e.activate(this.el),t.silent?this.panes().push(e):this.panes.push(e),i=this.previousPane(),r=!1,n=function(){var e;if(r)return;r=!0,o.cleanupTransition();if(i)return o.no_history?(e=o.panes(),e.splice(s.indexOf(e,i),1),i.destroy(o)):i.deactivate(o)},e&&(e.transition||this.transition)?this.startTransition(e,i,n,!0):n(),e},e.prototype.pop=function(e){var t,n,r,i,s=this;return e==null&&(e={}),i=this.previousPane(),i?(i.activate(this.el),this.cleanupTransition(!0),t=this.activePane(),"transition"in e&&(t.transition=e.transition),this.panes.pop(),r=!1,n=function(){if(r)return;r=!0,s.cleanupTransition();if(t)return t.destroy(s)},t&&(t.transition||this.transition)?this.startTransition(t,i,n,!1):n(),i):null},e.prototype.startTransition=function(e,n,i,s){var o,u,a,f,l,c,h,p;if(!e)return;e.transition&&e.transition.options&&(l=e.transition.options.use_previous),l&&(h=[n,e],e=h[0],n=h[1],s=!s),f=e.transition?e.transition:this.transition;if(!f)return null;typeof f=="string"&&(f={name:f}),t.transistions[f.name]||r(this,"transition "+f.name),a={forward:s};for(u in f)c=f[u],a[u]=c;return a.inverse&&(p=[n,e],e=p[0],n=p[1],a.forward=!a.forward),delete a.inverse,e&&e.activate(this.el),n&&n.activate(this.el),o={container_el:this.el,from_el:n?n.el:null,to_el:e?e.el:null,callback:i},this.active_transition={callback:i,transition:new t.transistions[f.name](o,a)},this.active_transition.transition.start()},e.prototype.cleanupTransition=function(e){var t;if(!this.active_transition)return;return t=this.active_transition,this.active_transition=null,e&&t.transition.cancel(),t.callback()},e}(),typeof exports!="undefined"&&(exports.PaneNavigator=t.PaneNavigator),t.transistions||(t.transistions={}),s.indexOf||(s.indexOf=function(e,t){var n,r;for(n in e){r=e[n];if(r===t)return n}return-1}),t.utils||(t.utils={}),t.utils.wrappedPaneNavigator=function(e,t){return arguments.length===1||e.__kb_pane_navigator===t?e.__kb_pane_navigator:(e.__kb_pane_navigator&&e.__kb_pane_navigator.destroy(),e.__kb_pane_navigator=t,t)},this.$&&$.fn&&($.fn.findByPath=function(e){var t,n,r,i,s,o,u,a,f,l;o=[];for(u=0,f=this.length;u<f;u++){s=this[u],r=e.split("/"),i=s;for(a=0,l=r.length;a<l;a++){n=r[a],n[0]==="^"?(e=n.substring(1),e?(t=$(i).closest(e),i=t.length?t[0]:null):i=i.parentNode):n===".."?i=i.parentNode:(t=$(i).find(n),i=t.length?t[0]:null);if(!i)break}i&&o.push(i)}return $(o)},$.fn.findPaneNavigator=function(){var e,n,r,i,s,o,u,a,f,l,c;for(u=0,f=this.length;u<f;u++){r=this[u];if(o=r.getAttribute("data-path"))return e=this.findByPath(o),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null;n=$(r).parent();while(n.length&&!n.is("div"))n=n.parent();c=n.parent().find(".pane-navigator");for(a=0,l=c.length;a<l;a++){s=c[a];if(i=t.utils.wrappedPaneNavigator(s))return i}return e=$(r).closest(".pane-navigator"),e.length&&(i=t.utils.wrappedPaneNavigator(e[0]))?i:null}}),t.nextPane=function(e,n){var r,i,o,u;i=s.isElement(e)?e:e.currentTarget?e.currentTarget:n.currentTarget,u=$(i).findPaneNavigator();if(!u||!(r=u.activePane()))return;o=r.el;while(o=o.nextSibling)if(s.isElement(o)&&$(o).hasClass("pane"))break;if(o)return u.push(new t.Pane(o))},t.previousPane=function(e,t){var n,r;n=s.isElement(e)?e:e.currentTarget?e.currentTarget:t.currentTarget,r=$(n).findPaneNavigator();if(r&&r.activePane())return r.pop()},n.bindingHandlers&&(n.bindingHandlers.PaneNavigator={init:function(e,r,i,s){var o,u;return o=n.utils.unwrapObservable(r()),"no_remove"in o||(o.no_remove=!0),u=new t.PaneNavigator(e,o),t.utils.wrappedPaneNavigator(e,u),n.utils.domNodeDisposal.addDisposeCallback(e,function(){return t.utils.wrappedPaneNavigator(e,null)}),$(e).addClass("pane-navigator")},update:function(e,n){var r;return r=function(){var n,r;r=t.utils.wrappedPaneNavigator(e);if(r.activePane())return;n=$(r.el).children().filter(".pane");if(n.length)return r.push(new t.Pane(n[0]))},e.children.length?r():setTimeout(r,0)}}),t.Pane=function(){function e(e,t){arguments.length&&(this.url=t),this.setInfo(e)}return e.prototype.destroy=function(e){return e==null&&(e={}),this.deactivate(e),this.removeElement(e,!0),this.create=null,this.el=null},e.prototype.setInfo=function(e){var t,n;if(s.isElement(e))this.el=e;else for(t in e)n=e[t],this[t]=n;return this.el&&$(this.el).addClass("pane"),this},e.prototype.ensureElement=function(){var e;return this.el?this.el:(this.create||r(this,"create"),e=this.create.apply(this,this.args),e&&this.setInfo(e),this.el||r(this,"element"),this.el&&$(this.el).addClass("pane"),this)},e.prototype.removeElement=function(e,t){e==null&&(e={});if(!this.el)return this;if(e.no_remove)return;return t||this.create&&!e.no_destroy?(n.removeNode(this.el),this.el=null):this.el.parentNode&&this.el.parentNode.removeChild(this.el),this},e.prototype.activate=function(e){var t;this.ensureElement();if($(this.el).hasClass("active"))return;return $(this.el).addClass("active"),this.el.parentNode!==e&&e.appendChild(this.el),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.activate&&t.activate(this),this},e.prototype.deactivate=function(e){var t;e==null&&(e={});if(!this.el||!$(this.el).hasClass("active"))return;return $(this.el).removeClass("active"),t=this.view_model?this.view_model:n.dataFor(this.el),t&&t.deactivate&&t.deactivate(this),this.removeElement(e),this},e}(),typeof exports!="undefined"&&(exports.Pane=t.Pane),t.TransitionSavedState=function(){function e(e,t){var n,r;this.el_states=[];if(!t)return;for(r in t)n=t[r],this.push(e[r],n)}return e.prototype.push=function(e,t){var n,r,i,s;if(!e)return;r={className:""+e.className,css:{}};if(t)for(i=0,s=t.length;i<s;i++)n=t[i],r.css[n]=e.style[n];return this.el_states.push({el:e,state:r}),this},e.prototype.restore=function(){var e,t,n,r,i,s,o,u,a;u=this.el_states;for(s=0,o=u.length;s<o;s++){t=u[s],e=t.el,r=t.state;if(!e||!r)continue;"className"in r&&(e.className=r.className),a=r.css;for(n in a)i=a[n],e.style[n]=i}return this.el_states=null,this},e}(),typeof exports!="undefined"&&(exports.TransitionSavedState=t.TransitionSavedState),t})}).call(this);
View
3 src/component-imports.coffee
@@ -7,9 +7,10 @@ throwUnexpected = (instance, message) -> throw "#{if _.isString(instance) then i
# import Knockback is it exists
try (@kb = kb = if not @kb and (typeof(require) isnt 'undefined') then require('knockback') else @kb) catch e then {}
@kb or= kb or= {} # empty namesapce
+@Backbone or= @kb.Backbone
# import Knockout or provide a replacement for ko.observable and ko.observableArray
-try (ko = if (typeof(require) != 'undefined') then require('knockout') else @ko) catch e then {}
+try (ko = if not @ko and (typeof(require) != 'undefined') then require('knockout') else @ko) catch e then {}
ko or= {} # empty namesapce
unless ko.observable # no Knockout, make minimal fake ko.observable and and ko.observableArray for simplifying the watching API
View
2 src/knockback-pane-navigator/knockback-pane-navigator-helpers.coffee
@@ -19,7 +19,7 @@ kb.utils.wrappedPaneNavigator = (el, value) ->
return value
# custom find by path
-if $.fn
+if @$ and $.fn
$.fn.findByPath = (path) ->
results = []
for el in this
View
11 src/shared/knockback-page-navigator-helpers.coffee
@@ -4,13 +4,22 @@ kb.override_transitions = []
kb.popOverrideTransition = ->
if kb.override_transitions.length then kb.override_transitions.pop() else null
+# Use a known dispatcher to route a url. Default is setting the window.location.hash.
+# If you require supporting for a different router, override/replace this method.
+kb.dispatchUrl = (url) ->
+ window.location.hash = url # TODO: this is asynchronous...is this error-resistent enough?
+ if window.Backbone and window.Backbone.History.started
+ window.Backbone.history.loadUrl(url)
+ else if window.Path
+ window.Path.dispatch(url)
+
# Helper to load a url.
#
# @param [String] url the url to load
# @param [String|Object] transition transition options. Either a name or `{name: 'TransitionName', option1: option2: ...}`
kb.loadUrl = (url, transition) ->
kb.override_transitions.push(transition)
- window.location.hash = url # this is asynchronous. TODO: is this error-resistent enough?
+ kb.dispatchUrl(url)
# Helper that creates a function that can be used in your HTML bindings for loading a url. Use this when you need to declare the loadUrl function but you are not calling it immediately
#
View
25 test/knockback-page-navigator-panes/test-amd.coffee
@@ -11,13 +11,32 @@ $(document).ready( ->
)
test("1. Basic Usage", ->
- # kb.statistics = new kb.Statistics() # turn on stats
-
el = $('<div></div>')[0]
page_navigator = new kb.PageNavigatorPanes(el)
equal(el, page_navigator.el, "container element")
+ )
+
+ test("2. Click-Based navigation", ->
+ # onclick
+ el = $("""
+ <a onclick="kb.loadUrl('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
- # equal(kb.statistics.registeredStatsString('all released'), 'all released', "Cleanup: stats"); kb.statistics = null
+ # bound view model
+ el = $("""
+ <a data-bind="click: kb.loadUrlFn('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ ko.applyBindings({}, el)
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
)
)
)
View
2 test/knockback-page-navigator-panes/test-latest-amd.html
@@ -11,7 +11,7 @@
'backbone': "../vendor/backbone-0.9.2",
'knockout': "../vendor/knockout-2.1.0",
'knockback': "../vendor/knockback-core-0.16.5",
- 'knockback-page-navigator-panes': "../../knockback-page-navigator-panes",
+ 'knockback-page-navigator-panes': "../../knockback-page-navigator-panes"
}
});
</script>
View
27 test/knockback-page-navigator-panes/test.coffee
@@ -2,7 +2,7 @@ $(document).ready( ->
module("knockback-page-navigator-panes.js")
# import Underscore (or Lo-Dash with precedence), Backbone, Knockout, and Knockback
- if (typeof(require) isnt 'undefined') then _ = require('underscore') else _ = window._
+ _ = if not window._ and (typeof(require) isnt 'undefined') then require('underscore') else window._
_ = _._ if _ and _.hasOwnProperty('_') # LEGACY
Backbone = if not window.Backbone and (typeof(require) isnt 'undefined') then require('backbone') else window.Backbone
ko = if not window.ko and (typeof(require) isnt 'undefined') then require('knockout') else window.ko
@@ -14,12 +14,31 @@ $(document).ready( ->
)
test("1. Basic Usage", ->
- # kb.statistics = new kb.Statistics() # turn on stats
-
el = $('<div></div>')[0]
page_navigator = new kb.PageNavigatorPanes(el)
equal(el, page_navigator.el, "container element")
+ )
+
+ test("2. Click-Based navigation", ->
+ # onclick
+ el = $("""
+ <a onclick="kb.loadUrl('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
- # equal(kb.statistics.registeredStatsString('all released'), 'all released', "Cleanup: stats"); kb.statistics = null
+ # bound view model
+ el = $("""
+ <a data-bind="click: kb.loadUrlFn('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ ko.applyBindings({}, el)
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
)
)
View
25 test/knockback-page-navigator-simple/test-amd.coffee
@@ -11,13 +11,32 @@ $(document).ready( ->
)
test("1. Basic Usage", ->
- # kb.statistics = new kb.Statistics() # turn on stats
-
el = $('<div></div>')[0]
page_navigator = new kb.PageNavigatorSimple(el)
equal(el, page_navigator.el, "container element")
+ )
+
+ test("2. Click-Based navigation", ->
+ # onclick
+ el = $("""
+ <a onclick="kb.loadUrl('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
- # equal(kb.statistics.registeredStatsString('all released'), 'all released', "Cleanup: stats"); kb.statistics = null
+ # bound view model
+ el = $("""
+ <a data-bind="click: kb.loadUrlFn('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ ko.applyBindings({}, el)
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
)
)
)
View
2 test/knockback-page-navigator-simple/test-latest-amd.html
@@ -11,7 +11,7 @@
'backbone': "../vendor/backbone-0.9.2",
'knockout': "../vendor/knockout-2.1.0",
'knockback': "../vendor/knockback-core-0.16.5",
- 'knockback-page-navigator-simple': "../../knockback-page-navigator-simple",
+ 'knockback-page-navigator-simple': "../../knockback-page-navigator-simple"
}
});
</script>
View
27 test/knockback-page-navigator-simple/test.coffee
@@ -2,7 +2,7 @@ $(document).ready( ->
module("knockback-page-navigator-simple.js")
# import Underscore (or Lo-Dash with precedence), Backbone, Knockout, and Knockback
- if (typeof(require) isnt 'undefined') then _ = require('underscore') else _ = window._
+ _ = if not window._ and (typeof(require) isnt 'undefined') then require('underscore') else window._
_ = _._ if _ and _.hasOwnProperty('_') # LEGACY
Backbone = if not window.Backbone and (typeof(require) isnt 'undefined') then require('backbone') else window.Backbone
ko = if not window.ko and (typeof(require) isnt 'undefined') then require('knockout') else window.ko
@@ -14,12 +14,31 @@ $(document).ready( ->
)
test("1. Basic Usage", ->
- # kb.statistics = new kb.Statistics() # turn on stats
-
el = $('<div></div>')[0]
page_navigator = new kb.PageNavigatorSimple(el)
equal(el, page_navigator.el, "container element")
+ )
+
+ test("2. Click-Based navigation", ->
+ # onclick
+ el = $("""
+ <a onclick="kb.loadUrl('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
- # equal(kb.statistics.registeredStatsString('all released'), 'all released', "Cleanup: stats"); kb.statistics = null
+ # bound view model
+ el = $("""
+ <a data-bind="click: kb.loadUrlFn('test1', {name: 'NavigationSlide', inverse: true})">Examples</a>
+ """)[0]
+ ko.applyBindings({}, el)
+ window.location.hash = ''
+ equal(window.location.hash, '', "onclick: no location hash")
+ $(el).click()
+ equal(window.location.hash, '#test1', "onclick: test1 location hash")
+ equal(kb.popOverrideTransition().name, 'NavigationSlide', "onclick: transition found")
)
)
View
2 test/knockback-pane-navigator/test-latest-amd.html
@@ -11,7 +11,7 @@
'backbone': "../vendor/backbone-0.9.2",
'knockout': "../vendor/knockout-2.1.0",
'knockback': "../vendor/knockback-core-0.16.5",
- 'knockback-pane-navigator': "../../knockback-pane-navigator",
+ 'knockback-pane-navigator': "../../knockback-pane-navigator"
}
});
</script>
View
2 test/knockback-pane-navigator/test.coffee
@@ -2,7 +2,7 @@ $(document).ready( ->
module("knockback-pane-navigator.js")
# import Underscore (or Lo-Dash with precedence), Backbone, Knockout, and Knockback
- if (typeof(require) isnt 'undefined') then _ = require('underscore') else _ = window._
+ _ = if not window._ and (typeof(require) isnt 'undefined') then require('underscore') else window._
_ = _._ if _ and _.hasOwnProperty('_') # LEGACY
Backbone = if not window.Backbone and (typeof(require) isnt 'undefined') then require('backbone') else window.Backbone
ko = if not window.ko and (typeof(require) isnt 'undefined') then require('knockout') else window.ko

0 comments on commit bdacb9e

Please sign in to comment.
Something went wrong with that request. Please try again.