- Improved
Chaplin.Application
:- Added default
Application#initialize
functionality. - Application is now initialized by default with
new Application
constructor method instead ofApplication#initialize
.
- Added default
- Improved
Chaplin.Router
:- Early error is now thrown for
!router:route
and!router:routeByName
methods when nothing is matched.
- Early error is now thrown for
- Improved
Chaplin.View
:regions
option can now be passed to constructor.
- Fix controller disposal after redirect.
- Added full lodash compatibility.
- Removed deferred mix-in (
initDeferred
) support from models, collections and views. - Improved
Chaplin.Controller
andChaplin.Dispatcher
:- Made
Controller#beforeAction
a function. The old object form is not supported anymore. You need to usesuper
like in any other method,beforeAction
s won’t be merged without it. AsyncronousbeforeAction
s with promises are still supported. - Controllers are now disposed automatically after redirection or asynchronous before actions.
- Made
- Improved
Chaplin.Router
:- Fixed bug with preserving query string in URL.
- Removed underscorizing of loaded by default controller names.
deleted_users#show
won’t longer be rewritten todeletedUsers#show
. The controller name in the route is directly used as module name.
- Improved
Chaplin.View
:- Added
keepInElement
property (false by default). When truthy, the view’s DOM element won’t be removed after disposal. View#dispose
now calls Backbone’sView#remove
method.- Subviews are now always an array.
- Added
- Improved
Chaplin.CollectionView
:- Added Backbone 1.0
Collection#set
support.
- Added Backbone 1.0
- Improved
Chaplin.Layout
:- Added inheritance from
Chaplin.View
. - Renamed some methods for compat with
Chaplin.View
:_registeredRegions
toglobalRegions
registerRegion
toregisterGlobalRegion
registerRegion
toregisterGlobalRegions
unregisterRegion
tounregisterGlobalRegion
unregisterRegions
tounregisterGlobalRegions
- Changed default
Layout
element fromdocument
tobody
. - Removed explicit
view.$el.show()
/hide()
for managed views. - Removed
route
property. Usesettings.routeLinks
instead.
- Added inheritance from
- Improved
Chaplin.utils
:- Removed
underscorize
.
- Removed
- Improved
Chaplin.Layout
:- Added
Layout#$
method, which is the same asView#$
. This also fixes how regions behave in Layout.
- Added
- Improved
Chaplin.View
:- The check is now done when listening to collection
dispose
event whether it really came from collection and not from its model.
- The check is now done when listening to collection
- Added
Chaplin.helpers
component. It contains Chaplin-related functions.Chaplin.utils
will contain generic functions.helpers.reverse
allows to get route URL by its name and params.
- Improved
Chaplin.Application
:- Separated router initialisation and start of listening for routing.
The first one as before resides in
Application#initRouter
.Application#startRouting
. You need to launch both. This is breaking change and without it your app will not start routing.
- Separated router initialisation and start of listening for routing.
The first one as before resides in
- Improved
Chaplin.Controller
:- All actions are now initialised with
params, route, options
instead ofparams, options
. Newroute
argument contains information about current route (controller, action, name, path
) and about previous (route.previous
) andoptions
just contain options, passed toBackbone.history.navigate
. - When using redirection in actions, controller will automatically dispose redirected controller.
- All actions are now initialised with
- Improved
Chaplin.Router
:- All routes now have default names in format of (controller + '#' + action).
Router#reverse
will now prepend mount point.- Removed RegExp routes. Use
constraints
route param and strings instead.
- Improved
Chaplin.Layout
:- Allowed registering regions.
- Added
Layout#isExternalLink
that is used when clicking on any event and checks if current one is application-related.
- Improved
Chaplin.View
:- If
autoAttach
option is false, view will not be added to container. - Empty-selector regions are now considered as bound to root view element.
- If
- Improved overall
View
andCollectionView
performance for common cases. - Improved internal API:
- Renamed
matchRoute
global event torouter:match
- Renamed
startupController
global event todispatcher:dispatch
- Changed signatures of many
Dispatcher
methods, they now passroute
too.
- Renamed
- Added support of regions and regions composition with
Chaplin.Composer
. Composer grants the ability for views (and related data) to be persisted beyond one controller action. - Improved
Chaplin.Controller
:- Query string params are now passed to controllers (a feature removed from Backbone 0.9.9).
- Controller actions will now receive an
options
hash as second argument, that containspath
,previousControllerName
and routing options. Previously, the second argument was just apreviousControllerName
string. - Fixed
Controller#redirectTo
signature (url, options
). Controller#dispose
will now unbind all events bound bylistenTo
method.
- Improved
Chaplin.Dispatcher
:- Stop waiting for a Promise returned by a before action when another route is dispatched or the same is dispatched again.
- Improved
Chaplin.Router
:- The
params
andoptions
objects are copied instead of changed to prevent conflicts. If you passparams
andoptions
along with the!router:route
event, the controller action will receive a copy of them. Same forDispatcher
. - Fixed
root
option. - Fixed route reversals on empty patterns (for example, the top-level route).
- The
- Improved
Chaplin.Collection
:Collection#dispose
will now unbind all events bound bylistenTo
method.- Removed
Collection#addAtomic
as it was barely used.
- Improved
Chaplin.Model
:Model#serialize
can be overridden onBackbone.Model
s. Chaplin will use it, if available, andModel#toJSON
if not.Model#dispose
will now unbind all events bound bylistenTo
method.- Improved time complexity of
Model#serialize
from O(n) to amortized O(1).
- Improved
Chaplin.utils
:- Added
utils.getAllPropertyVersions
that allows to gather all property versions from object’s prototypes. - Added
utils.escapeRegExp
that escapes all regular expression characters in string. - Removed
utils.wrapMethod
.
- Added
- Improved
Chaplin.View
:- Added
View#listen
property that allows to declaratively listen to model / collection / mediator / view events. Just like Backbone’sView#events
, which is only for DOM events. - Added new
autoAttach
option which determines whether view should be automatically attached to DOM after render. - Renamed
View#afterRender
toView#attach
. - Removed
View#afterInitialize
. - Removed
View#pass
. Please use stickit instead for advanced model-view binding. - Switched to
$el.toggle()
instead of manual CSSdisplay
setting. Which means non-block elements will behave correctly. - Switched to
Backbone.$
reference for DOM manipulation. This will automatically use jQuery, Zepto or Ender as DOM library. - Early error is now thrown when
View#events
is a function.
- Added
- Improved
Chaplin.CollectionView
:- Renamed
CollectionView#itemsResetted
toCollectionView#itemsReset
. - Renamed
CollectionView#getView
toCollectionView#initItemView
. - Renamed
CollectionView#showHideFallback
toCollectionView#toggleFallback
. - Renamed
CollectionView#showHideLoadingIndicator
toCollectionView#toggleLoadingIndicator
. - Removed
CollectionView#renderAndInsertItem
. - Item views will now be called with
autoRender: false
, which prevents rendering them twice. - Item views will now emit
addedToParent
event instead ofaddedToDOM
when they are appended to collection view. - Optimised performance by not calling jQuery / Zepto
css
/animate
when animations are disabled.
- Renamed
- Updated required Backbone version to 0.9.9+.
- Improved
Chaplin.Collection
:- Removed
Collection#update
since this function is now provided by Backbone itself (Collection#update
in Backbone < 1.0,Collection#set
in Backbone >= 1.0). Thedeep
option is now calledmerge
and it defaults to true.
- Removed
- Improved
Chaplin.Controller
:- Added Rails-like before action filters to
Controller
s. - Added
Controller#redirectToRoute
which works likeController#redirectTo
, but accepts route name instead of URL. - Added flexible
Controller#adjustTitle
method which sets window title. - Added
Backbone.Events
mix-in. - Removed
Controller#title
andController#historyURL
. - Removed ability of redirecting to standalone controllers and action names
in
Controller#redirectTo
.
- Added Rails-like before action filters to
- Improved
Chaplin.Router
:- Added support for named routes.
- Added new global
!router:routeByName
event, which allows to navigate to some route by its reverse name. - Added new global
!router:reverse
event, which allows to get URL of route by its name. - Added
names
option toRouter#match
, which allows to name route’s regular expression matches. - Removed global
!startupController
event.
- Improved
Chaplin.View
:- Removed
View#modelBind
,View#modelUnbind
andView#modelUnbindAll
, since Backbone now implements superiorEvents.listenTo
API. - Chaplin will now fix incorrect inheritance of view DOM events,
bound in declarative manner (with
events
hash). - Moved
View#wrapMethod
toChaplin.utils.wrapMethod
. View#dispose
will now throw an error ifView#initialize
was called withoutsuper
.
- Removed
- Improved
Chaplin.CollectionView
:CollectionView#getTemplateData
no longer returnsitems
property, which increases performance.
- Router options are now allowed to be passed in many places.
New signatures are:
!router:route
global event: path, options, callback (old sig is supported too)Dispatcher#matchRoute
: route, params, optionsController#redirectTo
: path or (controllerName, action, params, options)
- Improved and stabilized codebase.
- Moved
Chaplin.Subscriber
toChaplin.EventBroker
, which now mixinspublishEvent
method to children. - Added
Chaplin.Delayer
, which sets unique and named timeouts and intervals so they can be cleared afterwards when disposing objects. - Added
autoRender
option toChaplin.CollectionView
, likeChaplin.View
. Defaults to true, replaces oldrender
option. - Added
serialize
method to collections - Removed
CollectionView#viewsByCid
andCollectionView#removeView
in favor of consistentView#subview
andView#removeSubview
. - Removed
CollectionView#initSyncMachine
. - Removed
trigger
,on
andoff
methods fromChaplin.mediator
. - Allowed passing of multiple event types to
View#delegate
. - Made various aspects of
Chaplin.Layout
configurable.
- A lot of various global changes.
- Added tests for all components.
- Chaplin now can be used as a standalone library.
- Bug fix: In CollectionView, get the correct item position when rendering the item view. Fixes the rendering of sorted Collections. Before the fix, the item views might have been displayed in the wrong order. (@rendez)
- Fixed correct unsubscribing of global handlers when disposing a collection.
- The codebase now uses consistent code style (@paulmillr).
- Initial release.