PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/app/vendor/backbone.localstorage/README.md

https://github.com/corsairdnb/vuaro
Markdown | 122 lines | 86 code | 36 blank | 0 comment | 0 complexity | 0a8bb6a4fdffd06b29806ab17209b008 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # Backbone localStorage Adapter v1.1.7
  2. [![Build Status](https://secure.travis-ci.org/jeromegn/Backbone.localStorage.png?branch=master)](http://travis-ci.org/jeromegn/Backbone.localStorage)
  3. Quite simply a localStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database.
  4. [![Gittip](http://badgr.co/gittip/jeromegn.png)](https://www.gittip.com/jeromegn/)
  5. ## Usage
  6. Include Backbone.localStorage after having included Backbone.js:
  7. ```html
  8. <script type="text/javascript" src="backbone.js"></script>
  9. <script type="text/javascript" src="backbone.localStorage.js"></script>
  10. ```
  11. Create your collections like so:
  12. ```javascript
  13. window.SomeCollection = Backbone.Collection.extend({
  14. localStorage: new Backbone.LocalStorage("SomeCollection"), // Unique name within your app.
  15. // ... everything else is normal.
  16. });
  17. ```
  18. ### RequireJS
  19. Include [RequireJS](http://requirejs.org):
  20. ```html
  21. <script type="text/javascript" src="lib/require.js"></script>
  22. ```
  23. RequireJS config:
  24. ```javascript
  25. require.config({
  26. paths: {
  27. jquery: "lib/jquery",
  28. underscore: "lib/underscore",
  29. backbone: "lib/backbone",
  30. localstorage: "lib/backbone.localStorage"
  31. }
  32. });
  33. ```
  34. Define your collection as a module:
  35. ```javascript
  36. define("SomeCollection", ["localstorage"], function() {
  37. var SomeCollection = Backbone.Collection.extend({
  38. localStorage: new Backbone.LocalStorage("SomeCollection") // Unique name within your app.
  39. });
  40. return SomeCollection;
  41. });
  42. ```
  43. Require your collection:
  44. ```javascript
  45. require(["SomeCollection"], function(SomeCollection) {
  46. // ready to use SomeCollection
  47. });
  48. ```
  49. ### CommonJS
  50. If you're using [browserify](https://github.com/substack/node-browserify).
  51. Install using `npm install backbone.localstorage`, and require the module.
  52. ```javascript
  53. Backbone.LocalStorage = require("backbone.localstorage");
  54. ```
  55. ##Support
  56. If you're having a problem with using the project, get help at CodersClan.
  57. <a href="http://codersclan.net/forum/index.php?repo_id=67"><img src="http://www.codersclan.net/graphics/getSupport_blue_big.png" width="160"></a>
  58. ## Contributing
  59. You'll need node and to `npm install` before being able to run the minification script.
  60. 1. Fork;
  61. 2. Write code, with tests;
  62. 3. `make test` or `open spec/runner.html`;
  63. 4. Create a pull request.
  64. Have fun!
  65. ## Acknowledgments
  66. - [Mark Woodall](https://github.com/llad): initial tests (now refactored);
  67. - [Martin H채cker](https://github.com/dwt): many fixes and the test isolation.
  68. ## License
  69. Licensed under MIT license
  70. Copyright (c) 2010 Jerome Gravel-Niquet
  71. Permission is hereby granted, free of charge, to any person obtaining
  72. a copy of this software and associated documentation files (the
  73. "Software"), to deal in the Software without restriction, including
  74. without limitation the rights to use, copy, modify, merge, publish,
  75. distribute, sublicense, and/or sell copies of the Software, and to
  76. permit persons to whom the Software is furnished to do so, subject to
  77. the following conditions:
  78. The above copyright notice and this permission notice shall be
  79. included in all copies or substantial portions of the Software.
  80. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  81. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  82. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  83. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  84. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  85. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  86. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.