Permalink
Browse files

removed mtv.store.coffee; updated Backbone.sync method to work with n…

…ewest Backbone.js
  • Loading branch information...
Ryan Nagle
Ryan Nagle committed Nov 15, 2011
1 parent 123d134 commit 77ff79ae5c3a1e38ee4f06d5318c41eb9da99eb2
Showing with 10 additions and 63 deletions.
  1. +4 −1 coffee/mtv.coffee
  2. +0 −54 coffee/mtv.store.coffee
  3. +4 −2 devjs/mtv.js
  4. +1 −1 mtv.min.js
  5. +1 −5 wp-plugin.php
View
@@ -46,10 +46,13 @@ window.MTV = new Object
# Custom Backbone sync function that works with wordpress ajax
#
if Backbone in window or window['Backbone'] isnt null
- Backbone.sync = (method, model, success, error) ->
+ Backbone.sync = (method, model, options) ->
data = if method is 'create' or method is 'update' then model.toJSON() else null
url = unless method is 'read' then "#{model.url()}/#{method}" else model.url()
+ success = options.success
+ error = options.error
+
MTV.do_ajax url, data, success, error
View
@@ -1,54 +0,0 @@
-unless $ then $ = jQuery
-
-#
-# Simple storage API
-# Uses HTML5 localStorage if available. Otherwise falls back to cookie storage.
-# Always uses a cookie to expire storage. Defaults to the length of the session.
-#
-window.MTV.Store = new Object
- expires: null # session
-
- get: (key) ->
- if @has_local_storage()
- json_data = if $.cookie(key + '-timer') then localStorage.getItem(key) else null
- else
- json_data = $.cookie(key)
-
- # Deserialize
- if json_data then JSON.parse json_data else no
-
- save: (key, val) ->
- # Prep data
- json_data = JSON.stringify val
-
- if @has_local_storage()
- $.cookie(key + '-timer', 'true',
- expires: @expires
- path: '/'
- )
- localStorage.setItem(key, json_data)
- else
- $.cookie(key, json_data,
- expires: @expires
- path: '/'
- )
-
- remove: (key) ->
- if @has_local_storage()
- $.cookie(key + '-timer', null,
- path: '/'
- )
- localStorage.removeItem(key)
- else
- $.cookie(key, null,
- path: '/'
- )
-
- has_local_storage: `function() {
- try {
- return 'localStorage' in window && window['localStorage'] !== null;
- } catch (e) {
- return false;
- }
- }`
-
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -34,14 +34,10 @@
);
if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
- wp_register_script('mtv',
+ wp_register_script('mtv-all',
plugins_url('/mtv/devjs/mtv.js'),
array('jquery'),
MTV_VERSION);
- wp_register_script('mtv-all',
- '',
- array('mtv'),
- MTV_VERSION);
$js_runtime_settings['DEBUG'] = true;

0 comments on commit 77ff79a

Please sign in to comment.