Permalink
Browse files

Updated documentation and Knockback to 0.16.4

  • Loading branch information...
1 parent 6241dea commit 060259979ee4d4f2e24ea3eef301f36f89ed3431 Kevin Malakoff committed Sep 12, 2012
Showing with 324 additions and 168 deletions.
  1. +2 −2 Bakefile.coffee
  2. +6 −6 README.md
  3. +3 −3 examples/pnp-t-e_jq_kb.html
  4. +3 −3 examples/pnp-t_jq_kb.html
  5. +3 −3 examples/pns-e_jq_kb.html
  6. +3 −3 examples/pns_jq_kb.html
  7. +27 −17 knockback-page-navigator-panes.js
  8. +1 −1 knockback-page-navigator-panes.min.js
  9. +8 −1 knockback-page-navigator-simple.js
  10. +1 −1 knockback-page-navigator-simple.min.js
  11. +19 −16 knockback-pane-navigator.js
  12. +1 −1 knockback-pane-navigator.min.js
  13. +6 −6 packages/npm/README.md
  14. +27 −17 packages/npm/knockback-page-navigator-panes.js
  15. +1 −1 packages/npm/knockback-page-navigator-panes.min.js
  16. +8 −1 packages/npm/knockback-page-navigator-simple.js
  17. +1 −1 packages/npm/knockback-page-navigator-simple.min.js
  18. +19 −16 packages/npm/knockback-pane-navigator.js
  19. +1 −1 packages/npm/knockback-pane-navigator.min.js
  20. +27 −17 packages/nuget/Content/Scripts/knockback-page-navigator-panes.js
  21. +1 −1 packages/nuget/Content/Scripts/knockback-page-navigator-panes.min.js
  22. +8 −1 packages/nuget/Content/Scripts/knockback-page-navigator-simple.js
  23. +1 −1 packages/nuget/Content/Scripts/knockback-page-navigator-simple.min.js
  24. +19 −16 packages/nuget/Content/Scripts/knockback-pane-navigator.js
  25. +1 −1 packages/nuget/Content/Scripts/knockback-pane-navigator.min.js
  26. +1 −0 src/component-imports.coffee
  27. +12 −2 src/knockback-page-navigator-panes/knockback-page-navigator-panes.coffee
  28. +10 −2 src/knockback-page-navigator-simple/knockback-page-navigator-simple.coffee
  29. +28 −2 src/knockback-pane-navigator/knockback-pane-navigator-helpers.coffee
  30. +9 −8 src/knockback-pane-navigator/knockback-pane-navigator.coffee
  31. +10 −0 src/knockback-sample-transitions/knockback-transition-cover-vertical.coffee
  32. +10 −0 src/knockback-sample-transitions/knockback-transition-fade-in.coffee
  33. +10 −0 src/knockback-sample-transitions/knockback-transition-navigation-slide.coffee
  34. +35 −0 src/shared/knockback-page-navigator-helpers.coffee
  35. +0 −15 src/shared/knockback-page-navigator.coffee
  36. +2 −2 test/vendor/knockback-core-stack-0.16.3.js
View
@@ -12,7 +12,7 @@ module.exports =
'src/knockback-pane-navigator/knockback-pane-navigator.coffee'
'src/knockback-pane-navigator/knockback-pane-navigator-helpers.coffee'
'src/knockback-pane-navigator/knockout-bindings.coffee'
- 'src/shared/knockback-page-navigator.coffee'
+ 'src/shared/knockback-page-navigator-helpers.coffee'
'src/shared/knockback-pane.coffee'
'src/shared/knockback-transition-saved-state.coffee'
]
@@ -25,7 +25,7 @@ module.exports =
'src/component-imports.coffee'
'src/knockback-page-navigator-simple/knockback-page-navigator-simple.coffee'
'src/knockback-page-navigator-simple/knockout-bindings.coffee'
- 'src/shared/knockback-page-navigator.coffee'
+ 'src/shared/knockback-page-navigator-helpers.coffee'
'src/shared/knockback-pane.coffee'
]
View
@@ -71,12 +71,12 @@ Path.dispatch(window.location.hash);
###Dynamic Pages using Knockback.js
-You can dynamic pages either by hand or using Knockback.js's 'kb.renderAutoReleasedTemplate(template_name, view_model, options)' function.
+You can dynamic pages either by hand or using Knockback.js's 'kb.renderTemplate(template_name, view_model, options)' function.
```
...
router.route('', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage( kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))) );
+ page_navigator.loadPage( kb.renderTemplate('page', new PageViewModel(pages.get('main'))) );
}));
...
```
@@ -86,7 +86,7 @@ You can also force pages to unload when they are not active, but supplying a 'cr
```
...
router.route('', null, page_navigator.dispatcher(function(){
- create: function() { return kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page1'))) }
+ create: function() { return kb.renderTemplate('page', new PageViewModel(pages.get('page1'))) }
}));
...
```
@@ -101,7 +101,7 @@ Transitions during routing:
...
router.route('', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('main'))),
transition: 'FadeIn'
});
}));
@@ -114,7 +114,7 @@ With options:
...
router.route('', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('main'))),
transition: {name: 'FadeIn', duration: 1000}
});
}));
@@ -250,7 +250,7 @@ There are three ways to do this in Knockback:
```
// Auto-released Template
-var el = kb.renderAutoReleasedTemplate('template_name', view_model, options);
+var el = kb.renderTemplate('template_name', view_model, options);
// OR: When applying bindings
kb.applyBindings(view_model, el);
@@ -70,19 +70,19 @@ <h1 data-bind="text: title"></h1>
var router = new Backbone.Router()
router.route('', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('main'))),
transition: 'FadeIn'
});
}));
router.route('page1', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page1'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('page1'))),
transition: 'NavigationSlide'
});
}));
router.route('page2', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page2'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('page2'))),
transition: 'CoverVertical'
});
}));
@@ -68,19 +68,19 @@ <h1 data-bind="text: title"></h1>
var router = new Backbone.Router()
router.route('', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('main'))),
transition: 'FadeIn'
});
}));
router.route('page1', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- create: function() { return kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page1'))) },
+ create: function() { return kb.renderTemplate('page', new PageViewModel(pages.get('page1'))) },
transition: 'NavigationSlide'
});
}));
router.route('page2', null, page_navigator.dispatcher(function(){
page_navigator.loadPage({
- el: kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page2'))),
+ el: kb.renderTemplate('page', new PageViewModel(pages.get('page2'))),
transition: 'CoverVertical'
});
}));
@@ -68,13 +68,13 @@ <h1 data-bind="text: title"></h1>
loaded: function(page_navigator) {
var router = new Backbone.Router()
router.route('', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('main'))));
}));
router.route('page1', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page1'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('page1'))));
}));
router.route('page2', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page2'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('page2'))));
}));
}
});
@@ -66,13 +66,13 @@ <h1 data-bind="text: title"></h1>
var page_navigator = new kb.PageNavigatorSimple($('#app')[0]);
var router = new Backbone.Router()
router.route('', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('main'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('main'))));
}));
router.route('page1', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page1'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('page1'))));
}));
router.route('page2', null, page_navigator.dispatcher(function(){
- page_navigator.loadPage(kb.renderAutoReleasedTemplate('page', new PageViewModel(pages.get('page2'))));
+ page_navigator.loadPage(kb.renderTemplate('page', new PageViewModel(pages.get('page2'))));
}));
Backbone.history.start({hashChange: true});
@@ -223,21 +223,6 @@
};
}
- kb.transistions || (kb.transistions = {});
-
- if (!_.indexOf) {
- _.indexOf = function(array, value) {
- var index, test;
- for (index in array) {
- test = array[index];
- if (test === value) {
- return index;
- }
- }
- return -1;
- };
- }
-
kb.PaneNavigator = (function() {
function PaneNavigator(el, options) {
@@ -459,6 +444,21 @@
exports.PaneNavigator = kb.PaneNavigator;
}
+ kb.transistions || (kb.transistions = {});
+
+ if (!_.indexOf) {
+ _.indexOf = function(array, value) {
+ var index, test;
+ for (index in array) {
+ test = array[index];
+ if (test === value) {
+ return index;
+ }
+ }
+ return -1;
+ };
+ }
+
kb.utils || (kb.utils = {});
kb.utils.wrappedPaneNavigator = function(el, value) {
@@ -468,7 +468,8 @@
if (el.__kb_pane_navigator) {
el.__kb_pane_navigator.destroy();
}
- return el.__kb_pane_navigator = value;
+ el.__kb_pane_navigator = value;
+ return value;
};
if ($.fn) {
@@ -489,6 +490,8 @@
} else {
current_el = current_el.parentNode;
}
+ } else if (component === '..') {
+ current_el = current_el.parentNode;
} else {
$current_el = $(current_el).find(component);
current_el = $current_el.length ? $current_el[0] : null;
@@ -615,6 +618,12 @@
return window.location.hash = url;
};
+ kb.loadUrlFn = function(url, transition) {
+ return function() {
+ return kb.loadUrl(url, transition);
+ };
+ };
+
kb.utils || (kb.utils = {});
kb.utils.wrappedPageNavigator = function(el, value) {
@@ -624,7 +633,8 @@
if (el.__kb_page_navigator) {
el.__kb_page_navigator.destroy();
}
- return el.__kb_page_navigator = value;
+ el.__kb_page_navigator = value;
+ return value;
};
kb.Pane = (function() {
Oops, something went wrong.
@@ -214,6 +214,12 @@
return window.location.hash = url;
};
+ kb.loadUrlFn = function(url, transition) {
+ return function() {
+ return kb.loadUrl(url, transition);
+ };
+ };
+
kb.utils || (kb.utils = {});
kb.utils.wrappedPageNavigator = function(el, value) {
@@ -223,7 +229,8 @@
if (el.__kb_page_navigator) {
el.__kb_page_navigator.destroy();
}
- return el.__kb_page_navigator = value;
+ el.__kb_page_navigator = value;
+ return value;
};
kb.Pane = (function() {
@@ -6,4 +6,4 @@
See the following for full license details:
https://github.com/kmalakoff/knockback-navigators/blob/master/LICENSE
Dependencies: None
-*/(function(){var e,t,n,r,i;r=function(e,t){throw""+e.constructor.name+": "+t+" is unexpected"};try{t=typeof require!="undefined"?require("knockback"):this.kb}catch(s){({})}this.kb=t||(t={});try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(s){({})}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}),i=this._?this._:t._?t._:{},i.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},i.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)}),i.isElement||(i.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||throwMissing(this,"el"),i.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,r;if(!e)throw"missing page info";return 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):((r=this.activePage())&&r.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.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.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(i.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;if(this.el)return this.el;if(!this.create)throw"expecting create";e=this.create.apply(this,this.args),e&&this.setInfo(e);if(!this.el)throw"expecting el";return 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)}).call(this);
+*/(function(){var e,t,n,r,i;r=function(e,t){throw""+e.constructor.name+": "+t+" is unexpected"};try{t=typeof require!="undefined"?require("knockback"):this.kb}catch(s){({})}this.kb=t||(t={});try{n=typeof require!="undefined"?require("knockout"):this.ko}catch(s){({})}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}),i=this._?this._:t._?t._:{},i.bindAll||(e=function(e,t){var n;return n=e[t],e[t]=function(){return n.apply(e,arguments)}},i.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)}),i.isElement||(i.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||throwMissing(this,"el"),i.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,r;if(!e)throw"missing page info";return 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):((r=this.activePage())&&r.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(){return t.loadUrl(e,n)}},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(i.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;if(this.el)return this.el;if(!this.create)throw"expecting create";e=this.create.apply(this,this.args),e&&this.setInfo(e);if(!this.el)throw"expecting el";return 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)}).call(this);
Oops, something went wrong.

0 comments on commit 0602599

Please sign in to comment.