joosy 1.2.0.alpha.73 → 1.2.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gruntfile.coffee +56 -18
  3. data/bower.json +1 -1
  4. data/build/joosy/form.js +1 -0
  5. data/build/joosy/resources.js +1 -0
  6. data/build/joosy.js +2 -2774
  7. data/package.json +5 -4
  8. data/source/joosy/application.coffee +9 -7
  9. data/source/joosy/{extensions/resources-form/form.coffee → form.coffee} +58 -51
  10. data/source/joosy/helpers/form.coffee +241 -0
  11. data/source/joosy/helpers/index.coffee +3 -0
  12. data/source/joosy/helpers/routes.coffee +3 -1
  13. data/source/joosy/helpers/view.coffee +9 -9
  14. data/source/joosy/joosy.coffee +3 -5
  15. data/source/joosy/module.coffee +9 -4
  16. data/source/joosy/modules/dom.coffee +33 -31
  17. data/source/joosy/modules/events.coffee +24 -20
  18. data/source/joosy/modules/filters.coffee +38 -35
  19. data/source/joosy/modules/page/title.coffee +3 -3
  20. data/source/joosy/modules/renderer.coffee +23 -18
  21. data/source/joosy/modules/resources/identity_map.coffee +45 -0
  22. data/source/joosy/modules/resources/model.coffee +146 -0
  23. data/source/joosy/modules/widgets_manager.coffee +8 -8
  24. data/source/joosy/resources/array.coffee +0 -5
  25. data/source/joosy/resources/hash.coffee +8 -13
  26. data/source/joosy/resources/index.coffee +2 -0
  27. data/source/joosy/{extensions/resources → resources}/rest.coffee +48 -19
  28. data/source/joosy/resources/scalar.coffee +8 -10
  29. data/source/joosy/router.coffee +13 -12
  30. data/source/joosy/templaters/jst.coffee +3 -2
  31. data/source/joosy/widget.coffee +17 -15
  32. data/source/joosy.coffee +2 -0
  33. data/source/vendor/es5-shim.js +1316 -0
  34. data/source/vendor/inflections.js +598 -0
  35. data/source/vendor/metamorph.js +457 -0
  36. data/spec/helpers/matchers.coffee +4 -4
  37. data/spec/joosy/core/application_spec.coffee +1 -1
  38. data/spec/joosy/core/helpers/view_spec.coffee +2 -2
  39. data/spec/joosy/core/joosy_spec.coffee +8 -4
  40. data/spec/joosy/core/modules/dom_spec.coffee +7 -7
  41. data/spec/joosy/core/modules/events_spec.coffee +2 -2
  42. data/spec/joosy/core/modules/filters_spec.coffee +7 -8
  43. data/spec/joosy/core/modules/module_spec.coffee +5 -5
  44. data/spec/joosy/core/router_spec.coffee +3 -3
  45. data/spec/joosy/core/widget_spec.coffee +6 -6
  46. data/spec/joosy/environments/amd_spec.coffee +4 -2
  47. data/spec/joosy/environments/global_spec.coffee +1 -1
  48. data/spec/joosy/{extensions/form → form}/form_spec.coffee +9 -16
  49. data/spec/joosy/{extensions/form → form}/helpers/forms_spec.coffee +5 -5
  50. data/spec/joosy/{core/resources → resources}/array_spec.coffee +2 -2
  51. data/spec/joosy/{core/resources → resources}/hash_spec.coffee +0 -8
  52. data/spec/joosy/{core/modules/resources → resources/modules}/cacher_spec.coffee +0 -0
  53. data/spec/joosy/resources/modules/identity_map_spec.coffee +47 -0
  54. data/spec/joosy/{extensions/resources/base_spec.coffee → resources/modules/model_spec.coffee} +28 -48
  55. data/spec/joosy/{extensions/resources → resources}/rest_spec.coffee +29 -22
  56. data/spec/joosy/{core/resources → resources}/scalar_spec.coffee +8 -8
  57. data/templates/application/application.coffee.tt +0 -2
  58. data/templates/environment/app/haml/index.haml +2 -2
  59. data/templates/environment/package.json +1 -1
  60. metadata +23 -19
  61. data/build/joosy/extensions/resources-form.js +0 -590
  62. data/build/joosy/extensions/resources.js +0 -561
  63. data/source/joosy/extensions/resources/base.coffee +0 -282
  64. data/source/joosy/extensions/resources/index.coffee +0 -1
  65. data/source/joosy/extensions/resources-form/helpers/form.coffee +0 -104
  66. data/source/joosy/extensions/resources-form/index.coffee +0 -1
  67. data/source/metamorph.coffee +0 -410
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c93a94e26133a7f31ce8568c0f30123014c392ec
4
- data.tar.gz: 8d69ccc6b80a2da510a272e1bda09b543a79a49a
3
+ metadata.gz: 712dee510fd146a72ec3b152c14d7b9061bce2d0
4
+ data.tar.gz: 45c15340f4cd4e875c765b730fa7635198ed0137
5
5
  SHA512:
6
- metadata.gz: 57cead0f12f2bc1e652e723247688a78ed4bcf842d657d9396e9a13b8bc7bd90ea524f2f868be2a570c114a6601e7907fc2c7f5892ef389022170144791639af
7
- data.tar.gz: 477925bb13b147ad0d52a822262bc20cbfda09d687dc1125e571cf4afd8c738234cf30fcedc1618437f71dbdf82ae035b047cad0b598f2e3bafb2b08c60f7da1
6
+ metadata.gz: 4f9d3fcacba24bed114dafa69b149cb85be48bb63152bd32ce7acfa32318589d4eb4dc0dabdf9297b343652c3a4e3bebdc4a7c804816a4a1f916d9b7ce17593f
7
+ data.tar.gz: ed5b409afb761622fbe4fb0f2829e60aa507f6bde2f39f9957e6e6c42de886796baa712df69edfa9bb004e2b41dd82ba9f369ee704eeb08bb0412f10b4ce3b19
data/Gruntfile.coffee CHANGED
@@ -10,11 +10,10 @@ module.exports = (grunt) ->
10
10
  src: grunt.util._([
11
11
  [
12
12
  'bower_components/sinonjs/sinon.js',
13
- 'bower_components/sugar/release/sugar-full.min.js',
14
13
  'spec/helpers/*.coffee'
15
14
  ],
16
15
  vendor,
17
- 'joosy.coffee',
16
+ 'joosy.coffee',
18
17
  specs
19
18
  ]).flatten()
20
19
 
@@ -31,6 +30,7 @@ module.exports = (grunt) ->
31
30
  # Grunt extensions
32
31
  #
33
32
  grunt.loadNpmTasks 'grill'
33
+ grunt.loadNpmTasks 'grunt-contrib-uglify'
34
34
  grunt.loadNpmTasks 'grunt-contrib-testem'
35
35
  grunt.loadNpmTasks 'grunt-coffeelint'
36
36
  grunt.loadNpmTasks 'grunt-release'
@@ -44,15 +44,30 @@ module.exports = (grunt) ->
44
44
  assets:
45
45
  destination: 'build'
46
46
  paths: 'source'
47
- root: ['joosy.coffee', 'joosy/extensions/*']
47
+ root: ['joosy.coffee', 'joosy/resources', 'joosy/form.coffee']
48
+
49
+ uglify:
50
+ everything:
51
+ options:
52
+ report: 'min'
53
+ files:
54
+ 'build/joosy.js': 'build/joosy.js'
55
+ 'build/joosy/resources.js': 'build/joosy/resources.js'
56
+ 'build/joosy/form.js': 'build/joosy/form.js'
48
57
 
49
58
  coffeelint:
50
59
  source:
51
60
  files:
52
- src: 'source/joosy/**/*.coffee'
61
+ src: ['source/joosy/**/*.coffee', 'spec/**/*.coffee']
53
62
  options:
54
63
  'max_line_length':
55
64
  level: 'ignore'
65
+ 'arrow_spacing':
66
+ level: 'error'
67
+ 'line_endings':
68
+ level: 'error'
69
+ 'no_empty_param_list':
70
+ level: 'error'
56
71
 
57
72
  'gh-pages':
58
73
  docs:
@@ -65,32 +80,55 @@ module.exports = (grunt) ->
65
80
 
66
81
  testem:
67
82
  core: testemOptions(
68
- 'bower_components/jquery/jquery.js',
83
+ [
84
+ 'bower_components/jquery/jquery.js'
85
+ ],
69
86
  'spec/joosy/core/**/*_spec.coffee'
70
87
  )
71
- zepto: testemOptions(
72
- 'bower_components/zepto/zepto.js',
88
+ 'core-zepto': testemOptions(
89
+ [
90
+ 'bower_components/zepto/zepto.js'
91
+ ],
73
92
  'spec/joosy/core/**/*_spec.coffee'
74
93
  )
94
+ resources: testemOptions(
95
+ [
96
+ 'bower_components/jquery/jquery.js'
97
+ ],
98
+ [
99
+ 'joosy/resources/index.coffee',
100
+ 'spec/joosy/resources/**/*_spec.coffee'
101
+ ]
102
+ )
103
+ form: testemOptions(
104
+ [
105
+ 'bower_components/jquery/jquery.js',
106
+ 'bower_components/jquery-form/jquery.form.js'
107
+ ],
108
+ [
109
+ 'joosy/resources/index.coffee',
110
+ 'joosy/form.coffee',
111
+ 'joosy/helpers/form.coffee',
112
+ 'spec/joosy/form/**/*_spec.coffee'
113
+ ]
114
+ )
75
115
  'environments-global': testemOptions(
76
- 'bower_components/jquery/jquery.js',
116
+ [
117
+ 'bower_components/jquery/jquery.js'
118
+ ],
77
119
  'spec/joosy/environments/global_spec.coffee'
78
120
  )
79
121
  'environments-amd': testemOptions(
80
122
  [
81
123
  'bower_components/jquery/jquery.js',
124
+ 'bower_components/jquery-form/jquery.form.js',
82
125
  'bower_components/requirejs/require.js'
83
126
  ],
84
- 'spec/joosy/environments/amd_spec.coffee'
85
- )
86
- extensions: testemOptions(
87
- [
88
- 'bower_components/jquery/jquery.js',
89
- 'bower_components/jquery-form/jquery.form.js'
90
- ],
91
127
  [
92
- 'joosy/extensions/*',
93
- 'spec/joosy/extensions/**/*_spec.coffee'
128
+ 'joosy/resources/index.coffee',
129
+ 'joosy/form.coffee',
130
+ 'joosy/helpers/form.coffee',
131
+ 'spec/joosy/environments/amd_spec.coffee'
94
132
  ]
95
133
  )
96
134
 
@@ -106,7 +144,7 @@ module.exports = (grunt) ->
106
144
  #
107
145
  grunt.registerTask 'default', 'testem'
108
146
 
109
- grunt.registerTask 'compile', ['bowerize', 'grill:compile']
147
+ grunt.registerTask 'compile', ['bowerize', 'grill:compile', 'uglify']
110
148
 
111
149
  grunt.registerTask 'test', ->
112
150
  grunt.task.run 'coffeelint'
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.73",
3
+ "version": "1.2.0-beta.1",
4
4
  "main": "build/joosy.js",
5
5
  "ignore": [
6
6
  "lib",
@@ -0,0 +1 @@
1
+ (function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Form=function(a){function c(a,b){var c,d,e,f,g=this;if(null==b&&(b={}),"function"==typeof b)this.success=b;else for(c in b)e=b[c],this[c]=e;this.$container=$(a),0!==this.$container.length&&(this.__assignElements(),this.__delegateEvents(),d=null!=(f=this.$container.get(0).getAttribute("method"))?f.toLowerCase():void 0,d&&-1!==!["get","post"].indexOf(d)&&(this.__markMethod(d),this.$container.attr("method","POST")),this.$container.ajaxForm({dataType:"json",beforeSend:function(){return g.__debounce.apply(g,arguments)?!1:(g.__before.apply(g,arguments),g.__pending_request=!0,g.debugAs(g,"beforeSend: pending_request = true"),!0)},success:function(){return g.__pending_request=!1,g.debugAs(g,"success: pending_request = false"),g.__success.apply(g,arguments)},error:function(){return g.__pending_request=!1,g.debugAs(g,"error: pending_request = false"),g.__error.apply(g,arguments)},xhr:function(){var a;return a=$.ajaxSettings.xhr(),null!=a.upload&&g.progress&&(a.upload.onprogress=function(a){return a.lengthComputable?g.progress((100*(a.position/a.total)).round(2)):void 0}),a}}),null!=this.resource&&(this.fill(this.resource,b),delete this.resource),null!=this.action&&(this.$container.attr("action",this.action),this.$container.attr("method","POST")),null!=this.method&&this.__markMethod(this.method))}return b(c,a),c.include(Joosy.Modules.DOM),c.include(Joosy.Modules.Log),c.include(Joosy.Modules.Events),c.prototype.invalidationClass="field_with_errors",c.prototype.substitutions={},c.mapElements({fields:"input,select,textarea"}),c.submit=function(a,b){return null==b&&(b={}),a=new this(a,b),a.$container.submit(),a.unbind(),null},c.attach=function(){return function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(Joosy.Form,arguments,function(){})},c.prototype.unbind=function(){return this.$container.unbind("submit").find("input:submit,input:image,button:submit").unbind("click")},c.prototype.fill=function(a,b){var c,d,e,f=this;return"function"==typeof a.build&&(a=a.build()),this.__resource=a,c=null!=(null!=b?b.decorator:void 0)?b.decorator(a.data):a.data,d=function(a,b){var c,e,g;if(!a.__joosy_form_filler_lock){a.__joosy_form_filler_lock=!0,g=function(a,c){var e,g,h,i,j,k,l;if(i=f.concatFieldName(b,a),h=f.$fields().filter("[name='"+i+"']:not(:file),[name='"+inflection.underscore(i)+"']:not(:file),[name='"+inflection.camelize(i,!0)+"']:not(:file)"),h.length>0&&(h.is(":checkbox")?c?h.attr("checked","checked"):h.removeAttr("checked"):h.is(":radio")?h.filter("[value='"+c+"']").attr("checked","checked"):h.val(c)),c instanceof Joosy.Resources.Array){for(l=[],g=j=0,k=c.length;k>j;g=++j)e=c[g],l.push(d(e.data,f.concatFieldName(b,"["+a+"_attributes]["+g+"]")));return l}return c instanceof Joosy.Resources.REST?d(c.data,f.concatFieldName(b,"["+a+"_attributes]")):(null!=c?c.constructor:void 0)===Object||c instanceof Array?d(c,i):void 0};for(c in a)e=a[c],g(c,e);return delete a.__joosy_form_filler_lock}},d(c,a.__entityName||b.resourceName),$("input[name=_method]",this.$container).remove(),a.id()&&this.__markMethod((null!=b?b.method:void 0)||"PUT"),e=(null!=b?b.action:void 0)||(null!=a.id()?a.memberPath():a.collectionPath()),this.$container.attr("action",e),this.$container.attr("method","POST")},c.prototype.submit=function(){return this.$container.submit()},c.prototype.serialize=function(a){var b;return null==a&&(a=!0),b=this.$container.serialize(),a&&(b=b.replace(/\&?\_method\=put/i,"")),b},c.prototype.__success=function(a,b,c){var d;return c?"function"==typeof this.success?this.success(a):void 0:200<=(d=a.status)&&300>d?this.success(a.json):this.__error(a.json)},c.prototype.__before=function(){return null==this.before||this.before.apply(this,arguments)===!0?this.$fields().removeClass(this.invalidationClass):void 0},c.prototype.__error=function(a){var b,c,d,e,f,g=this;if(c=function(){if(!a.responseText)return a;try{return a=jQuery.parseJSON(a.responseText)}catch(c){return b=c,{}}}(),null==this.error||this.error(c)===!0){c=this.__stringifyErrors(c),f=function(a,b){var c;return c=g.findField(a).addClass(g.invalidationClass),"function"==typeof g.notification?g.notification(c,b):void 0};for(d in c)e=c[d],f(d,e);return c}return!1},c.prototype.__debounce=function(a){return this.debugAs(this,"debounce: pending_request == "+this.__pending_request),this.__pending_request&&this.debounce!==!1&&(this.debounce||Joosy.Form.debounceForms)?(a.abort(),this.debugAs(this,"debounce: xhr aborted"),!0):!1},c.prototype.findField=function(a){return this.$fields().filter("[name='"+a+"']")},c.prototype.__markMethod=function(a){return null==a&&(a="PUT"),a=$("<input/>",{type:"hidden",name:"_method",value:a}),this.$container.append(a)},c.prototype.__stringifyErrors=function(a){var b,c,d,e,f,g=this;d={},(null!=a?null!=(f=a.errors)?f.constructor:void 0:void 0)===Object&&(a=a.errors),e=function(a,b){var c,e,f,h,i,j,k,l,m;if(null!=g.substitutions[a]&&(a=g.substitutions[a]),b.constructor===Object||g.isArrayOfObjects(b)){l=g.__foldInlineEntities(b),m=[];for(e in l)i=l[e],m.push(d[a+e]=i);return m}if(-1!==a.indexOf("."))for(h=a.split("."),a=h.shift(),(g.resourceName||g.__resource)&&(f=g.resourceName||g.__resource.__entityName,a=f+("["+a+"]")),j=0,k=h.length;k>j;j++)c=h[j],a+="["+c+"]";else(g.resourceName||g.__resource)&&(f=g.resourceName||g.__resource.__entityName,a=f+("["+a+"]"));return d[a]=b};for(b in a)c=a[b],e(b,c);return d},c.prototype.__foldInlineEntities=function(a,b,c){var d,e;null==b&&(b=""),null==c&&(c={});for(d in a)e=a[d],(null!=e?e.constructor:void 0)===Object||this.isArrayOfObjects(e)?this.__foldInlineEntities(e,""+b+"["+d+"]",c):c[""+b+"["+d+"]"]=e;return c},c.prototype.concatFieldName=function(a,b){var c;return c=this.splitFieldName(a).concat(this.splitFieldName(b)),""+c[0]+"["+c.slice(1).join("][")+"]"},c.prototype.splitFieldName=function(a){var b,c;return c=a.split("]["),b=c[0].split("["),2===b.length&&(0===b[0].length?c.splice(0,1,b[1]):c.splice(0,1,b[0],b[1]),c[c.length-1]=c[c.length-1].split("]")[0]),c},c.prototype.isArrayOfObjects=function(a){return a instanceof Array&&0===a.filter(function(a){return(null!=a?a.constructor:void 0)!==Object}).length},c}(Joosy.Module),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/form",function(){return Joosy.Form})}).call(this);
@@ -0,0 +1 @@
1
+ (function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Resources.Array=function(a){function c(){this.__fillData(arguments,!1)}return b(c,a),Joosy.Module.merge(c,Joosy.Module),c.include(Joosy.Modules.Events),c.include(Joosy.Modules.Filters),c.registerPlainFilters("beforeLoad"),c.prototype.set=function(a,b){return this[a]=b,this.trigger("changed"),b},c.prototype.load=function(){return this.__fillData(arguments)},c.prototype.clone=function(){var a;return a=new this.constructor,a.data=this.slice(0),a},c.prototype.push=function(){var a;return a=c.__super__.push.apply(this,arguments),this.trigger("changed"),a},c.prototype.pop=function(){var a;return a=c.__super__.pop.apply(this,arguments),this.trigger("changed"),a},c.prototype.shift=function(){var a;return a=c.__super__.shift.apply(this,arguments),this.trigger("changed"),a},c.prototype.unshift=function(){var a;return a=c.__super__.unshift.apply(this,arguments),this.trigger("changed"),a},c.prototype.splice=function(){var a;return a=c.__super__.splice.apply(this,arguments),this.trigger("changed"),a},c.prototype.__fillData=function(a,b){var c,d,e,f;for(null==b&&(b=!0),a=this.slice.call(a,0),this.length>0&&this.splice(0,this.length),f=this.__applyBeforeLoads(a),d=0,e=f.length;e>d;d++)c=f[d],this.push(c);return b&&this.trigger("changed"),null},c}(Array),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/resources/array",function(){return Joosy.Resources.Array})}).call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Resources.Hash=function(a){function c(a){return null==a&&(a={}),c.__super__.constructor.call(this,function(){return this.__fillData(a,!1)})}return b(c,a),c.include(Joosy.Modules.Events),c.include(Joosy.Modules.Filters),c.registerPlainFilters("beforeLoad"),c.prototype.load=function(a){return this.__fillData(a),this},c.prototype.__get=function(a){var b,c,d;return d=this.__callTarget(a,!0),b=d[0],c=d[1],b?b instanceof Joosy.Resources.Hash?b(c):b[c]:void 0},c.prototype.__set=function(a,b){var c,d,e;return e=this.__callTarget(a),c=e[0],d=e[1],c instanceof Joosy.Resources.Hash?c(d,b):c[d]=b,this.trigger("changed"),b},c.prototype.__call=function(a,b){return arguments.length>1?this.__set(a,b):this.__get(a)},c.prototype.__callTarget=function(a,b){var c,d,e,f,g;if(null==b&&(b=!1),-1!==a.indexOf(".")&&null==this.data[a]){for(a=a.split("."),c=a.pop(),e=this.data,f=0,g=a.length;g>f;f++){if(d=a[f],b&&null==e[d])return!1;null==e[d]&&(e[d]={}),e=e instanceof Joosy.Resources.Hash?e(d):e[d]}return[e,c]}return[this.data,a]},c.prototype.__fillData=function(a,b){return null==b&&(b=!0),this.data=this.__applyBeforeLoads(a),b&&this.trigger("changed"),null},c.prototype.toString=function(){return JSON.stringify(this.data)},c}(Joosy.Function),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/resources/hash",function(){return Joosy.Resources.Hash})}.call(this),function(){Joosy.Modules.Resources={}}.call(this),function(){Joosy.Modules.Resources.Model={included:function(){return this.primaryKey=function(a){return this.prototype.__primaryKey=a},this.collection=function(a){return this.prototype.__collection=a},this.entity=function(a){return this.prototype.__entityName=a},this.map=function(a,b){if(null==b&&(b=!1),b||(b=window[inflection.camelize(inflection.singularize(a))]),!b)throw new Error(""+Joosy.Module.__className(this)+"> class can not be detected for '"+a+"' mapping");return this.beforeLoad(function(c){var d;return null==b.build&&(b=b()),c[a]instanceof Array?(d=c[a].map(function(a){return b.build(a)}),c[a]=function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(b.prototype.__collection,d,function(){})):c[a]&&(c[a]=b.build(c[a])),c})},this.build=function(a){return null==a&&(a={}),new this(a)},this.grab=function(a){return this.build({}).grab(a)}},__primaryKey:"id",__collection:Joosy.Resources.Array,id:function(){var a;return null!=(a=this.data)?a[this.__primaryKey]:void 0},knownAttributes:function(){return Object.keys(this.data)},load:function(a,b){return null==b&&(b=!1),b&&(this.data={}),this.__fillData(a),this},__fillData:function(a,b){return null==b&&(b=!0),this.raw=a,this.hasOwnProperty("data")||(this.data={}),Joosy.Module.merge(this.data,this.__applyBeforeLoads(a)),b&&this.trigger("changed"),null},grab:function(a){var b,c,d,e,f;for(b={},f=$(a).serializeArray(),d=0,e=f.length;e>d;d++)c=f[d],b[c.name]?(b[c.name]instanceof Array||(b[c.name]=[b[c.name]]),b[c.name].push(c.value)):b[c.name]=c.value;return this.load(b)},toString:function(){return"<Resource "+this.__entityName+"> "+JSON.stringify(this.data)}}}.call(this),function(){var a,b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},d=[].slice;Joosy.Resources.REST=function(b){function e(){return a=e.__super__.constructor.apply(this,arguments)}return c(e,b),e.include(Joosy.Modules.Resources.Model),e.registerPlainFilters("beforeSave"),e.beforeLoad(function(a){var b;return a.constructor===Object&&1===Object.keys(a).length&&this.__entityName&&(b=inflection.camelize(this.__entityName,!0),a[b]&&(a=a[b])),a}),e.requestOptions=function(a){return this.prototype.__requestOptions=a},e.source=function(a){return this.__source=a},e.__atWrapper=function(){var a,b,c=this;return b=arguments[0],a=2<=arguments.length?d.call(arguments,1):[],1===a.length&&a[0]instanceof Array?this.__atWrapper.apply(this,[b].concat(d.call(a[0]))):b(function(b){return b.__source=a.reduce(function(a,b){return a+=b instanceof Joosy.Resources.REST?b.memberPath():b.replace(/^\/?/,"/")},""),b.__source+="/"+inflection.pluralize(c.prototype.__entityName)})},e.at=function(){var a=this;return this.__atWrapper.apply(this,[function(b){var d,e;return d=function(a){function d(){return e=d.__super__.constructor.apply(this,arguments)}return c(d,a),b(d),d}(a)}].concat(d.call(arguments)))},e.prototype.at=function(){var a,b;return a=1<=arguments.length?d.call(arguments,0):[],new((b=this.constructor).at.apply(b,a))(this.data)},e.prototype.__interpolatePath=function(a,b){return b instanceof Array||(b=[b]),b.reduce(function(a,b){return b instanceof Joosy.Resources.REST&&(b=b.id()),a.replace(/:[^\/]+/,b)},a)},e.collectionPath=function(){var a,b;return a=1<=arguments.length?d.call(arguments,0):[],(b=this.prototype).collectionPath.apply(b,a)},e.prototype.collectionPath=function(a,b){var c,d;return null==a&&(a=[]),null==b&&(b={}),a.constructor===Object&&(b=a,a=[]),b.url?b.url:(d=this.__source||this.constructor.__source,d?c=this.__interpolatePath(d,a):(c="/",this.constructor.__namespace__.length>0&&(c+=this.constructor.__namespace__.map(String.prototype.underscore).join("/")+"/"),c+=inflection.pluralize(this.__entityName)),b.action&&(c+="/"+b.action),c)},e.memberPath=function(){var a,b;return a=1<=arguments.length?d.call(arguments,0):[],(b=this.prototype).memberPath.apply(b,a)},e.prototype.memberPath=function(a,b){var c,d,e;return null==a&&(a=[]),null==b&&(b={}),a.constructor===Object&&(b=a,a=[]),b.url?b.url:(a instanceof Array||(a=[a]),d=this.id()||a.pop(),c=b.action,a.push(this.id()),e=this.collectionPath(a,Joosy.Module.merge(b,{action:void 0}))+("/"+d),null!=c&&(e+="/"+c),e)},e.get=function(a,b){var c;return c=this.prototype.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.__query(this.collectionPath(a),"GET",a.params,b)},e.post=function(a,b){var c;return c=this.prototype.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.__query(this.collectionPath(a),"POST",a.params,b)},e.put=function(a,b){var c;return c=this.prototype.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.__query(this.collectionPath(a),"PUT",a.params,b)},e["delete"]=function(a,b){var c;return c=this.prototype.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.__query(this.collectionPath(a),"DELETE",a.params,b)},e.prototype.get=function(a,b){var c;return c=this.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.constructor.__query(this.memberPath(a),"GET",a.params,b)},e.prototype.post=function(a,b){var c;return c=this.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.constructor.__query(this.memberPath(a),"POST",a.params,b)},e.prototype.put=function(a,b){var c;return c=this.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.constructor.__query(this.memberPath(a),"PUT",a.params,b)},e.prototype["delete"]=function(a,b){var c;return c=this.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.constructor.__query(this.memberPath(a),"DELETE",a.params,b)},e.prototype.reload=function(a,b){var c,d=this;return null==a&&(a={}),null==b&&(b=!1),c=this.__extractOptionsAndCallback(a,b),a=c[0],b=c[1],this.constructor.__query(this.memberPath(a),"GET",a.params,function(a,c,e){return null!=c&&d.load(c),"function"==typeof b?b(a,d,c,e):void 0})},e.find=function(a,b,c){var d,e;return null==b&&(b={}),null==c&&(c=!1),e=this.prototype.__extractOptionsAndCallback(b,c),b=e[0],c=e[1],d={},d[this.prototype.__primaryKey]=a instanceof Array?a[a.length-1]:a,d=this.build(d),a instanceof Array&&a.length>1&&(d.__source=this.collectionPath(a)),this.__query(this.memberPath(a,b),"GET",b.params,function(a,b,e){return null!=b&&d.load(b),"function"==typeof c?c(a,d,b,e):void 0}),d},e.all=function(a,b,c){var d,e,f,g=this;return null==b&&(b={}),null==c&&(c=!1),"function"==typeof a||a.constructor===Object?(e=this.prototype.__extractOptionsAndCallback(a,b),b=e[0],c=e[1],a=[]):(f=this.prototype.__extractOptionsAndCallback(b,c),b=f[0],c=f[1]),d=new this.prototype.__collection,this.__query(this.collectionPath(a,b),"GET",b.params,function(b,e,f){var h;if(null!=(h=e)){if(h.constructor===Object&&!(h=h[inflection.pluralize(g.prototype.__entityName)]))throw new Error("Invalid data for `all` received: "+JSON.stringify(h));h=h.map(function(b){var c;return c=g.build(b),a.length>1&&(c.__source=g.collectionPath(a)),c}),d.load.apply(d,h)}return"function"==typeof c?c(b,d,e,f):void 0}),d},e.prototype.save=function(a){var b=this;return this.id()?this.put({params:this.__applyBeforeSaves(this.data)},function(c,d){return c||b.load(d),"function"==typeof a?a(c,b):void 0}):this.constructor.post({params:this.__applyBeforeSaves(this.data)},function(c,d){return c||b.load(d),"function"==typeof a?a(c,b):void 0})},e.__query=function(a,b,c,d){var e;return e={url:a,data:c,type:b,cache:!1,dataType:"json"},"function"==typeof d?(e.success=function(a,b,c){return d(!1,a,c)},e.error=function(a){return d(a)}):Joosy.Module.merge(e,d),this.prototype.__requestOptions instanceof Function?this.prototype.__requestOptions(e):this.prototype.__requestOptions&&Joosy.Module.merge(e,this.prototype.__requestOptions),$.ajax(e)},e.prototype.__extractOptionsAndCallback=function(a,b){return"function"==typeof a&&(b=a,a={}),[a,b]},e}(Joosy.Resources.Hash),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/resources/rest",function(){return Joosy.Resources.REST})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Resources.Scalar=function(a){function c(a){return c.__super__.constructor.call(this,function(){return this.load(a)})}return b(c,a),c.include(Joosy.Modules.Events),c.include(Joosy.Modules.Filters),c.registerPlainFilters("beforeLoad"),c.prototype.load=function(a){return this.value=this.__applyBeforeLoads(a),this.trigger("changed"),this.value},c.prototype.clone=function(){return new this.constructor(this.value)},c.prototype.__call=function(){return arguments.length>0?this.__set(arguments[0]):this.__get()},c.prototype.__get=function(){return this.value},c.prototype.__set=function(a){return this.value=a,this.trigger("changed")},c.prototype.valueOf=function(){return this.value.valueOf()},c.prototype.toString=function(){return this.value.toString()},c}(Joosy.Function),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/resources/scalar",function(){return Joosy.Resources.Scalar})}.call(this),function(){var a=[].slice;Joosy.Modules.Resources.Cacher={included:function(){return this.cache=function(a){return this.prototype.__cacheKey=a},this.fetcher=function(a){return this.prototype.__fetcher=a},this.cached=function(a,b,c){var d,e=this;return null==b&&(b=!1),null==c&&(c=!1),"function"==typeof b&&(c=b,b=void 0),b||(b=this.prototype.__cacheKey),c||(c=this.prototype.__fetcher),b&&localStorage&&localStorage[b]?(d=function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(this,JSON.parse(localStorage[b]),function(){}),"function"==typeof a&&a(d),d.refresh()):this.fetch(function(b){return d=function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(e,b,function(){}),"function"==typeof a?a(d):void 0})},this.fetch=function(b){var c=this;return this.prototype.__fetcher(function(){var d;return d=1<=arguments.length?a.call(arguments,0):[],c.prototype.__cacheKey&&localStorage&&(localStorage[c.prototype.__cacheKey]=JSON.stringify(d)),b(d)})}},refresh:function(a){var b=this;return this.constructor.fetch(function(c){return b.load.apply(b,c),"function"==typeof a?a(b):void 0})}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/resources/cacher",function(){return Joosy.Modules.Resources.Cacher})}.call(this),function(){Joosy.Modules.Resources.IdentityMap={extended:function(){return this.prototype.__identityHolder=this},identityReset:function(){return this.prototype.__identityHolder.identity={}},identityPath:function(a){return[this.prototype.__entityName,"s"+(this.__source||""),a[this.prototype.__primaryKey]]},build:function(a){var b,c,d,e,f,g,h,i;if(null==a&&(a={}),d=this.identityPath(a),0===d.filter(function(a){return null==a}).length){for(e=null!=(g=this.prototype.__identityHolder).identity?(g=this.prototype.__identityHolder).identity:g.identity={},b=d.pop(),h=0,i=d.length;i>h;h++)c=d[h],e=null!=e[c]?e[c]:e[c]={};return f={},f[this.prototype.__primaryKey]=a[this.prototype.__primaryKey],null==e[b]&&(e[b]=new this(f)),e[b].load(a)}return new this(a)}}}.call(this),function(){}.call(this);