joosy 1.2.0.alpha.41 → 1.2.0.alpha.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gruntfile.coffee +27 -7
  4. data/bin/joosy +1 -1
  5. data/bower.json +3 -2
  6. data/build/joosy/extensions/preloaders.js +189 -0
  7. data/build/joosy/extensions/resources-form.js +588 -0
  8. data/build/joosy/extensions/resources.js +673 -0
  9. data/build/joosy.js +2395 -0
  10. data/{src/joosy/generators → generators}/base.coffee +2 -2
  11. data/{src/joosy/generators → generators/command}/command.coffee +16 -3
  12. data/generators/command/help.coffee +38 -0
  13. data/{src/joosy/generators → generators}/layout.coffee +0 -0
  14. data/{src/joosy/generators → generators}/page.coffee +0 -0
  15. data/{src/joosy/generators → generators}/project/base.coffee +2 -4
  16. data/{src/joosy/generators → generators}/project/standalone.coffee +4 -3
  17. data/{src/joosy/generators → generators}/project.coffee +0 -0
  18. data/generators/templates/application/base/application.coffee +13 -0
  19. data/{templates → generators/templates}/application/base/helpers/application.coffee +0 -0
  20. data/{templates → generators/templates}/application/base/layouts/application.coffee +0 -0
  21. data/{templates → generators/templates}/application/base/pages/application.coffee +0 -0
  22. data/{templates → generators/templates}/application/base/pages/welcome/index.coffee +0 -0
  23. data/{templates → generators/templates}/application/base/routes.coffee +0 -0
  24. data/{templates → generators/templates}/application/base/templates/layouts/application.jst.hamlc +0 -0
  25. data/{templates → generators/templates}/application/base/templates/pages/welcome/index.jst.hamlc +0 -0
  26. data/{templates → generators/templates}/application/standalone/Gruntfile.coffee +1 -0
  27. data/{templates → generators/templates}/application/standalone/Procfile +0 -0
  28. data/{templates → generators/templates}/application/standalone/_gitignore +0 -0
  29. data/generators/templates/application/standalone/bower.json +17 -0
  30. data/{templates → generators/templates}/application/standalone/package.json +0 -0
  31. data/{templates → generators/templates}/application/standalone/source/haml/index.haml +0 -0
  32. data/{templates → generators/templates}/application/standalone/source/stylesheets/application.styl +0 -0
  33. data/{templates → generators/templates}/layout/basic.coffee +0 -0
  34. data/{templates → generators/templates}/layout/namespaced.coffee +0 -0
  35. data/{templates → generators/templates}/page/basic.coffee +0 -0
  36. data/{templates → generators/templates}/page/namespaced.coffee +0 -0
  37. data/{templates → generators/templates}/widget/basic.coffee +0 -0
  38. data/{templates → generators/templates}/widget/namespaced.coffee +0 -0
  39. data/{src/joosy/generators → generators}/widget.coffee +0 -0
  40. data/lib/joosy.rb +3 -3
  41. data/package.json +2 -3
  42. data/source/joosy/application.coffee +95 -0
  43. data/source/joosy/events/namespace.coffee +24 -0
  44. data/{src → source}/joosy/extensions/preloaders/caching.coffee +0 -0
  45. data/{src → source}/joosy/extensions/preloaders/index.coffee +0 -0
  46. data/{src → source}/joosy/extensions/preloaders/inline.coffee +0 -0
  47. data/{src → source}/joosy/extensions/resources/base.coffee +16 -8
  48. data/{src → source}/joosy/extensions/resources/collection.coffee +0 -0
  49. data/{src → source}/joosy/extensions/resources/index.coffee +0 -0
  50. data/{src → source}/joosy/extensions/resources/rest.coffee +0 -0
  51. data/{src → source}/joosy/extensions/resources/rest_collection.coffee +0 -0
  52. data/{src → source}/joosy/extensions/resources-form/form.coffee +18 -18
  53. data/{src → source}/joosy/extensions/resources-form/helpers/form.coffee +6 -6
  54. data/{src → source}/joosy/extensions/resources-form/index.coffee +0 -0
  55. data/source/joosy/helpers/routes.coffee +10 -0
  56. data/source/joosy/helpers/view.coffee +115 -0
  57. data/{src/joosy/core → source/joosy}/helpers/widgets.coffee +1 -1
  58. data/{src/joosy/core → source/joosy}/joosy.coffee +59 -19
  59. data/source/joosy/layout.coffee +73 -0
  60. data/{src/joosy/core → source/joosy}/module.coffee +7 -2
  61. data/{src/joosy/core/modules/container.coffee → source/joosy/modules/dom.coffee} +24 -17
  62. data/source/joosy/modules/events.coffee +156 -0
  63. data/source/joosy/modules/filters.coffee +67 -0
  64. data/{src/joosy/core → source/joosy}/modules/log.coffee +7 -3
  65. data/source/joosy/modules/page/scrolling.coffee +51 -0
  66. data/source/joosy/modules/page/title.coffee +18 -0
  67. data/{src/joosy/core → source/joosy}/modules/renderer.coffee +12 -13
  68. data/{src/joosy/core → source/joosy}/modules/time_manager.coffee +5 -1
  69. data/{src/joosy/core → source/joosy}/modules/widgets_manager.coffee +9 -5
  70. data/source/joosy/page.coffee +68 -0
  71. data/{src/joosy/core → source/joosy}/resources/watcher.coffee +5 -1
  72. data/source/joosy/router.coffee +305 -0
  73. data/{src/joosy/core → source/joosy}/templaters/jst.coffee +10 -7
  74. data/source/joosy/widget.coffee +385 -0
  75. data/source/joosy.coffee +1 -0
  76. data/{src/vendor → source}/metamorph.coffee +0 -0
  77. data/spec/helpers/matchers.coffee +8 -1
  78. data/spec/joosy/core/application_spec.coffee +121 -20
  79. data/spec/joosy/core/helpers/view_spec.coffee +3 -3
  80. data/spec/joosy/core/helpers/widgets_spec.coffee +3 -6
  81. data/spec/joosy/core/joosy_spec.coffee +0 -5
  82. data/spec/joosy/core/layout_spec.coffee +2 -28
  83. data/spec/joosy/core/modules/dom_spec.coffee +133 -0
  84. data/spec/joosy/core/modules/events_spec.coffee +16 -9
  85. data/spec/joosy/core/modules/filters_spec.coffee +232 -89
  86. data/spec/joosy/core/modules/log_spec.coffee +2 -2
  87. data/spec/joosy/core/modules/renderer_spec.coffee +8 -4
  88. data/spec/joosy/core/page_spec.coffee +2 -201
  89. data/spec/joosy/core/router_spec.coffee +295 -233
  90. data/spec/joosy/core/templaters/jst_spec.coffee +1 -1
  91. data/spec/joosy/core/widget_spec.coffee +373 -34
  92. data/spec/joosy/environments/amd_spec.coffee +38 -0
  93. data/spec/joosy/environments/global_spec.coffee +21 -0
  94. data/spec/joosy/extensions/form/form_spec.coffee +18 -18
  95. data/spec/joosy/extensions/form/helpers/forms_spec.coffee +1 -1
  96. data/spec/joosy/extensions/resources/base_spec.coffee +23 -11
  97. data/tasks/joosy.coffee +6 -9
  98. metadata +75 -69
  99. data/lib/extensions/preloaders.js +0 -193
  100. data/lib/extensions/resources-form.js +0 -592
  101. data/lib/extensions/resources.js +0 -675
  102. data/lib/joosy.js +0 -2199
  103. data/spec/joosy/core/modules/container_spec.coffee +0 -153
  104. data/spec/joosy/core/modules/widget_manager_spec.coffee +0 -96
  105. data/src/joosy/core/application.coffee +0 -59
  106. data/src/joosy/core/helpers/view.coffee +0 -52
  107. data/src/joosy/core/layout.coffee +0 -174
  108. data/src/joosy/core/modules/events.coffee +0 -188
  109. data/src/joosy/core/modules/filters.coffee +0 -42
  110. data/src/joosy/core/page.coffee +0 -383
  111. data/src/joosy/core/router.coffee +0 -313
  112. data/src/joosy/core/widget.coffee +0 -88
  113. data/src/joosy.coffee +0 -1
  114. data/templates/application/base/application.coffee +0 -9
  115. data/templates/application/standalone/bower.json +0 -7
@@ -8,7 +8,7 @@ if module?
8
8
  class Base
9
9
  constructor: (@options, @destination, @templates) ->
10
10
  @destination ||= process?.cwd()
11
- @templates ||= @join(__dirname, '..', '..', '..', 'templates') if __dirname?
11
+ @templates ||= @join(__dirname, 'templates') if __dirname?
12
12
  @actions = []
13
13
 
14
14
  getNamespace: (name) ->
@@ -51,7 +51,7 @@ class Base
51
51
  # Methods that have to be overrided outside of Node.js
52
52
  #
53
53
  version: ->
54
- require('../../../package.json').version
54
+ require('../package.json').version
55
55
 
56
56
  #
57
57
  # Node-base performer
@@ -1,10 +1,22 @@
1
1
  module.exports = ->
2
2
  Sugar = require 'sugar'
3
3
  cli = require 'command-router'
4
- meta = require '../../../package.json'
4
+ meta = require '../../package.json'
5
5
  grunt = require 'grunt'
6
6
  path = require 'path'
7
7
 
8
+ cli.command /help\s?(.*)/, ->
9
+ name = cli.params.splats[0]
10
+ commands = ['new', 'generate']
11
+ name = 'banner' if name == ''
12
+
13
+ if !commands.some(name) && name != 'banner'
14
+ console.error "Unknown command '#{name}'. Possible values: #{commands.join(', ')}."
15
+ process.exit 1
16
+
17
+ helper = require('./help')
18
+ helper[name]()
19
+
8
20
  cli.command /new\s?(.*)?/, ->
9
21
  name = cli.params.splats[0]
10
22
 
@@ -12,7 +24,7 @@ module.exports = ->
12
24
  console.error "Usage: `new :name`. Run `help` for details."
13
25
  process.exit(1)
14
26
 
15
- generator = require('./project')
27
+ generator = require('../project')
16
28
  generator = new generator(name: name)
17
29
  generator.generate()
18
30
  generator.perform -> process.exit 0
@@ -36,11 +48,12 @@ module.exports = ->
36
48
  console.error "Failed: `source' directory not found. Are you in the root of project?"
37
49
  process.exit 1
38
50
 
39
- generator = require("./#{entity}")
51
+ generator = require("../#{entity}")
40
52
  generator = new generator({name: name}, path.join(process.cwd(), 'source'))
41
53
  generator.generate()
42
54
  generator.perform -> process.exit 0
43
55
 
56
+
44
57
  cli.on 'notfound', (action) ->
45
58
  if action.length > 0
46
59
  console.error "'#{action}' is an unknown action :("
@@ -0,0 +1,38 @@
1
+ module.exports =
2
+
3
+ generate: ->
4
+ console.log 'Usage:'
5
+ console.log ' joosy generate :generator'
6
+ console.log ''
7
+ console.log 'Description:'
8
+ console.log ' Runs one of the following generators to create something for you:'
9
+ console.log ''
10
+ console.log ' page create new page'
11
+ console.log ' resource create new resource'
12
+ console.log ' widget create new widget'
13
+ console.log ' layout create new layout'
14
+
15
+ new: ->
16
+ console.log 'Usage:'
17
+ console.log ' joosy new :name'
18
+ console.log ''
19
+ console.log 'Description:'
20
+ console.log ' Generates brand new Joosy application named :name (directory with the name of application will be created)'
21
+
22
+ banner: ->
23
+ console.log ' __________________________'
24
+ console.log ' /_ ____ ____ ____ __ __/'
25
+ console.log ' __/ / / / ___/ / /'
26
+ console.log ' / / / / / / /__ / / /'
27
+ console.log ' /____/____/____/____/__ /'
28
+ console.log '/_________________________/'
29
+ console.log ''
30
+ console.log 'Usage:'
31
+ console.log ' joosy COMMAND [ARGS]'
32
+ console.log ''
33
+ console.log 'Available commands:'
34
+ console.log ' generate Insert new entity in the application (short-cut alias "g")'
35
+ console.log ' new Create a new application'
36
+ console.log ''
37
+ console.log 'Description:'
38
+ console.log ' Help is also available on per-command basis (joosy help command)'
File without changes
File without changes
@@ -9,9 +9,6 @@ class ProjectBase extends @Base
9
9
  constructor: (@options, destination, templates) ->
10
10
  super(@options, destination, templates)
11
11
 
12
- @options.name ||= 'application'
13
- @options.name = @options.name.split('/').pop()
14
-
15
12
  generate: ->
16
13
  @file ['resources', '.gitkeep']
17
14
  @file ['widgets', '.gitkeep']
@@ -31,7 +28,8 @@ class ProjectBase extends @Base
31
28
 
32
29
 
33
30
  @template ['application', 'base', 'application.coffee'], ['application.coffee'],
34
- application: @options.name
31
+ templaterPrefix: @options.templaterPrefix || null
32
+ enableHTML5: !!@options.enableHTML5
35
33
  dependencies: @options.dependencies.replace /^\s+|\s+$/g, ''
36
34
 
37
35
  @actions
@@ -15,16 +15,17 @@ class ProjectStandalone extends @Base
15
15
  @file ['vendor', '.gitkeep']
16
16
 
17
17
  @copy ['application', 'standalone', '_gitignore'], ['.gitignore']
18
- @copy ['application', 'standalone', 'bower.json'], ['bower.json']
19
18
  @copy ['application', 'standalone', 'Gruntfile.coffee'], ['Gruntfile.coffee']
20
19
  @copy ['application', 'standalone', 'Procfile'], ['Procfile']
21
20
 
22
- @copy ['application', 'standalone', 'source', 'haml', 'index.haml'],
21
+ @copy ['application', 'standalone', 'source', 'haml', 'index.haml'],
23
22
  ['source', 'haml', 'index.haml']
24
23
 
25
24
  @copy ['application', 'standalone', 'source', 'stylesheets', 'application.styl'],
26
25
  ['source', 'stylesheets', 'application.styl']
27
26
 
27
+ @template ['application', 'standalone', 'bower.json'], ['bower.json'],
28
+ application: @options.name
28
29
  @template ['application', 'standalone', 'package.json'], ['package.json'],
29
30
  joosy_version: @version()
30
31
 
@@ -33,4 +34,4 @@ class ProjectStandalone extends @Base
33
34
  if module?
34
35
  module.exports = ProjectStandalone
35
36
  else
36
- @Generator = ProjectStandalone
37
+ @Generator = ProjectStandalone
File without changes
@@ -0,0 +1,13 @@
1
+ <%= dependencies %>
2
+ #
3
+ #= require joosy
4
+ #
5
+ #= require_tree ./
6
+ #= require_self
7
+
8
+ $ ->
9
+ Joosy.Application.initialize 'body',
10
+ router:
11
+ html5: <%= enableHTML5 %><% if (templaterPrefix && templaterPrefix.length > 0) { %>
12
+ templater:
13
+ prefix: '<%= templaterPrefix %>'<% } %>
@@ -23,6 +23,7 @@ module.exports = (grunt) ->
23
23
  path: '/'
24
24
  src: 'index.haml'
25
25
  dest: 'public/index.html'
26
+ url: ['/', '/index.html']
26
27
 
27
28
  uglify:
28
29
  application:
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "<%= application %>",
3
+ "version": "0.0.1",
4
+ "main": "source/haml/index.html",
5
+ "ignore": [
6
+ "**/.*",
7
+ "node_modules",
8
+ "bower_components",
9
+ "test",
10
+ "tests"
11
+ ],
12
+ "dependencies": {
13
+ "jquery": "~2.0.2",
14
+ "sugar": "~1.3.9",
15
+ "jquery-form": "~3.37.0"
16
+ }
17
+ }
File without changes
data/lib/joosy.rb CHANGED
@@ -8,15 +8,15 @@ module Joosy
8
8
 
9
9
  def self.assets_paths
10
10
  [
11
- File.expand_path('../../src', __FILE__)
11
+ File.expand_path('../../source', __FILE__)
12
12
  ]
13
13
  end
14
14
 
15
15
  def self.generators_path
16
- File.expand_path '../../src/joosy/generators', __FILE__
16
+ File.expand_path '../../generators', __FILE__
17
17
  end
18
18
 
19
19
  def self.templates_path
20
- File.expand_path '../../templates', __FILE__
20
+ File.expand_path '../../generators/templates', __FILE__
21
21
  end
22
22
  end
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.41",
7
+ "version": "1.2.0-alpha.51",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "commander": "~1.2.0",
29
29
  "colors": "~0.6.0-1",
30
30
  "grunt": "~0.4.1",
31
- "mincer": "~0.4.6",
31
+ "mincer": "~0.5.2",
32
32
  "connect": "~2.7.11",
33
33
  "haml-coffee": "~1.11.1",
34
34
  "proxy-middleware": "~0.4.0",
@@ -37,7 +37,6 @@
37
37
  "nib": "~0.9.1"
38
38
  },
39
39
  "devDependencies": {
40
- "grunt-mincer": "~0.3.2",
41
40
  "grunt-contrib-jasmine": "~0.5.1",
42
41
  "grunt-contrib-watch": "~0.4.4",
43
42
  "grunt-contrib-coffee": "~0.7.0",
@@ -0,0 +1,95 @@
1
+ #= require joosy/joosy
2
+ #= require joosy/router
3
+ #= require_tree ./templaters
4
+ #= require_tree ./resources
5
+ #= require_tree ./helpers
6
+
7
+ #
8
+ # Joosy Application container
9
+ #
10
+ # @mixin
11
+ #
12
+ Joosy.Application =
13
+ Pages: {}
14
+ Layouts: {}
15
+ Controls: {}
16
+
17
+ initialized: false
18
+ loading: true
19
+
20
+ config:
21
+ debug: false
22
+ templater:
23
+ prefix: ''
24
+ router:
25
+ html5: false
26
+ base: ''
27
+ prefix: ''
28
+
29
+ #
30
+ # Starts Joosy application by binding to element and bootstraping routes
31
+ #
32
+ # @param [String] name Name of app (the dir its located in)
33
+ # @param [String] selector jQuery-compatible selector of root application element
34
+ # @param [Object] options
35
+ #
36
+ initialize: (@selector, options={}) ->
37
+ if @initialized
38
+ throw new Error 'Attempted to initialize Application twice'
39
+
40
+ Object.merge @config, window.JoosyEnvironment, true if window.JoosyEnvironment?
41
+ Object.merge @config, options, true
42
+
43
+ Joosy.templater new Joosy.Templaters.JST(@config.templater)
44
+ Joosy.debug @config.debug
45
+
46
+ Joosy.Router.setup @config.router, (action, params) =>
47
+ if Joosy.Module.hasAncestor action, Joosy.Page
48
+ @changePage action, params
49
+ else if Object.isFunction(action)
50
+ action(params)
51
+ else
52
+ throw new "Unknown kind of route action"
53
+
54
+ @initialized = true
55
+
56
+ reset: ->
57
+ Joosy.Router.reset()
58
+ Joosy.templater false
59
+ Joosy.debug false
60
+
61
+ @page?.__unload()
62
+ delete @page
63
+
64
+ @loading = true
65
+ @initialized = false
66
+
67
+ navigate: ->
68
+ @router.navigate arguments...
69
+
70
+ #
71
+ # Gets current application root node
72
+ #
73
+ content: ->
74
+ $(@selector)
75
+
76
+ #
77
+ # Switches to given page
78
+ #
79
+ # @param [Joosy.Page] page The class (not object) of page to load
80
+ # @param [Object] params Hash of page params
81
+ #
82
+ changePage: (page, params) ->
83
+ attempt = new page params, @page
84
+
85
+ unless attempt.halted
86
+ if attempt.layoutShouldChange && attempt.layout
87
+ attempt.layout.__bootstrapDefault attempt, @content()
88
+ else
89
+ attempt.__bootstrapDefault @content()
90
+
91
+ @page = attempt
92
+
93
+ # AMD wrapper
94
+ if define?.amd?
95
+ define 'joosy/application', -> Joosy.Application
@@ -0,0 +1,24 @@
1
+ #
2
+ # Events namespace
3
+ #
4
+ # Creates unified collection of bindings to a particular instance
5
+ # that can be unbinded alltogether
6
+ #
7
+ # @example
8
+ # namespace = Joosy.Events.Namespace(something)
9
+ #
10
+ # namespace.bind 'event1', ->
11
+ # namespace.bind 'event2', ->
12
+ # namespace.unbind() # unbinds both bindings
13
+ #
14
+ class Joosy.Events.Namespace
15
+ #
16
+ # @param [Object] @parent Any instance that can trigger events
17
+ #
18
+ constructor: (@parent) ->
19
+ @bindings = []
20
+
21
+ bind: (args...) -> @bindings.push @parent.bind(args...)
22
+ unbind: ->
23
+ @parent.unbind b for b in @bindings
24
+ @bindings = []
@@ -63,7 +63,7 @@ class Joosy.Resources.Base extends Joosy.Module
63
63
  #
64
64
  # Creates the proxy of current resource binded as a child of given entity
65
65
  #
66
- @at: (entity) ->
66
+ @at: (args...) ->
67
67
  #
68
68
  # Class inheritance used to create proxy
69
69
  #
@@ -71,13 +71,21 @@ class Joosy.Resources.Base extends Joosy.Module
71
71
  #
72
72
  class Clone extends this
73
73
 
74
- if entity instanceof Joosy.Resources.Base
75
- Clone.__source = entity.memberPath()
76
- Clone.__source += '/' + @::__entityName.pluralize() if @::__entityName
74
+ if args.length == 1 && Object.isArray(args[0])
75
+ @at(args[0]...)
77
76
  else
78
- Clone.__source = entity
77
+ Clone.__source = args.reduce (path, arg) ->
78
+ path += if arg instanceof Joosy.Resources.Base
79
+ arg.memberPath()
80
+ else
81
+ arg.replace(/^\/?/, '/')
82
+
83
+ , ''
84
+
85
+ if @::__entityName && args[args.length - 1] instanceof Joosy.Resources.Base
86
+ Clone.__source += '/' + @::__entityName.pluralize()
79
87
 
80
- Clone
88
+ Clone
81
89
 
82
90
  #
83
91
  # Sets the entity text name:
@@ -166,7 +174,7 @@ class Joosy.Resources.Base extends Joosy.Module
166
174
  data = {}
167
175
  data[shim.__primaryKey] = id
168
176
 
169
- if Joosy.Application.identity
177
+ if Joosy.Resources.Base.identity
170
178
  id = data[shim.__primaryKey]
171
179
 
172
180
  if id? && Joosy.Resources.Base.identity[klass][id]
@@ -193,7 +201,7 @@ class Joosy.Resources.Base extends Joosy.Module
193
201
  @data[@__primaryKey]
194
202
 
195
203
  knownAttributes: ->
196
- @data.keys()
204
+ Object.keys @data
197
205
 
198
206
  #
199
207
  # Set the resource data manually
@@ -17,10 +17,10 @@
17
17
  #
18
18
  # @include Joosy.Modules.Log
19
19
  # @include Joosy.Modules.Events
20
- # @include Joosy.Modules.Container
20
+ # @include Joosy.Modules.DOM
21
21
  #
22
22
  class Joosy.Form extends Joosy.Module
23
- @include Joosy.Modules.Container
23
+ @include Joosy.Modules.DOM
24
24
  @include Joosy.Modules.Log
25
25
  @include Joosy.Modules.Events
26
26
 
@@ -53,7 +53,7 @@ class Joosy.Form extends Joosy.Module
53
53
  #
54
54
  @submit: (form, options={}) ->
55
55
  form = new @(form, options)
56
- form.container.submit()
56
+ form.$container.submit()
57
57
  form.unbind()
58
58
  null
59
59
 
@@ -101,18 +101,18 @@ class Joosy.Form extends Joosy.Module
101
101
  Object.each options, (key, value) =>
102
102
  @[key] = value
103
103
 
104
- @container = $(form)
105
- return if @container.length == 0
104
+ @$container = $(form)
105
+ return if @$container.length == 0
106
106
 
107
107
  @__assignElements()
108
108
  @__delegateEvents()
109
109
 
110
- method = @container.get(0).getAttribute('method')?.toLowerCase()
110
+ method = @$container.get(0).getAttribute('method')?.toLowerCase()
111
111
  if method && !['get', 'post'].any method
112
112
  @__markMethod method
113
- @container.attr 'method', 'POST'
113
+ @$container.attr 'method', 'POST'
114
114
 
115
- @container.ajaxForm
115
+ @$container.ajaxForm
116
116
  dataType: 'json'
117
117
  beforeSend: =>
118
118
  return false if @__debounce arguments...
@@ -141,8 +141,8 @@ class Joosy.Form extends Joosy.Module
141
141
  delete @resource
142
142
 
143
143
  if @action?
144
- @container.attr 'action', @action
145
- @container.attr 'method', 'POST'
144
+ @$container.attr 'action', @action
145
+ @$container.attr 'method', 'POST'
146
146
 
147
147
  if @method?
148
148
  @__markMethod @method
@@ -151,7 +151,7 @@ class Joosy.Form extends Joosy.Module
151
151
  # Resets form submit behavior to default
152
152
  #
153
153
  unbind: ->
154
- @container.unbind('submit').find('input:submit,input:image,button:submit').unbind('click')
154
+ @$container.unbind('submit').find('input:submit,input:image,button:submit').unbind('click')
155
155
 
156
156
  #
157
157
  # Links current form with given resource and sets values of form inputs from with it.
@@ -202,19 +202,19 @@ class Joosy.Form extends Joosy.Module
202
202
 
203
203
  filler data, resource.__entityName || options.resourceName
204
204
 
205
- $('input[name=_method]', @container).remove()
205
+ $('input[name=_method]', @$container).remove()
206
206
  @__markMethod(options?.method || 'PUT') if resource.id()
207
207
 
208
208
  url = options?.action || (if resource.id()? then resource.memberPath() else resource.collectionPath())
209
209
 
210
- @container.attr 'action', url
211
- @container.attr 'method', 'POST'
210
+ @$container.attr 'action', url
211
+ @$container.attr 'method', 'POST'
212
212
 
213
213
  #
214
214
  # Submit the HTML Form
215
215
  #
216
216
  submit: ->
217
- @container.submit()
217
+ @$container.submit()
218
218
 
219
219
  #
220
220
  # Serializes form into query string.
@@ -224,7 +224,7 @@ class Joosy.Form extends Joosy.Module
224
224
  # @return [String]
225
225
  #
226
226
  serialize: (skipMethod=true) ->
227
- data = @container.serialize()
227
+ data = @$container.serialize()
228
228
  data = data.replace /\&?\_method\=put/i, '' if skipMethod
229
229
 
230
230
  data
@@ -278,7 +278,7 @@ class Joosy.Form extends Joosy.Module
278
278
  __debounce: (xhr) ->
279
279
  @debugAs this, "debounce: pending_request == #{@__pending_request}"
280
280
  if @__pending_request && @debounce != false
281
- if @debounce || Joosy.Application.debounceForms
281
+ if @debounce || Joosy.Form.debounceForms
282
282
  xhr.abort()
283
283
  @debugAs this, "debounce: xhr aborted"
284
284
  return true
@@ -306,7 +306,7 @@ class Joosy.Form extends Joosy.Module
306
306
  name: '_method'
307
307
  value: method
308
308
  )
309
- @container.append method
309
+ @$container.append method
310
310
 
311
311
  #
312
312
  # Prepares server response for default error handler
@@ -61,7 +61,7 @@ Joosy.helpers 'Application', ->
61
61
  d = description(resource, method, options.extendIds)
62
62
  delete options.extendIds
63
63
 
64
- @tag 'label', Joosy.Module.merge(options, for: d.id), content
64
+ @contentTag 'label', content, Joosy.Module.merge(options, for: d.id)
65
65
 
66
66
  ['text', 'file', 'hidden', 'password'].each (type) =>
67
67
  @[type+'Field'] = (resource, method, options={}) -> input type, resource, method, options
@@ -85,15 +85,15 @@ Joosy.helpers 'Application', ->
85
85
  delete htmlOptions.includeBlank
86
86
  opts.unshift ['', '']
87
87
  opts = opts.reduce (str, vals) =>
88
- params = if Object.isArray vals then ['option', { value: vals[1] }, vals[0]] else ['option', {}, vals]
88
+ params = if Object.isArray vals then ['option', vals[0], { value: vals[1] }] else ['option', vals, {}]
89
89
  if htmlOptions.value == (if Object.isArray(vals) then vals[1] else vals)
90
- params[1].selected = 'selected'
91
- str += @.tag.apply @, params
90
+ params[2].selected = 'selected'
91
+ str += @contentTag.apply @, params
92
92
  , ''
93
93
  extendIds = htmlOptions.extendIds
94
94
  delete htmlOptions.value
95
95
  delete htmlOptions.extendIds
96
- @tag 'select', Joosy.Module.merge(description(resource, method, extendIds), htmlOptions), opts
96
+ @contentTag 'select', opts, Joosy.Module.merge(description(resource, method, extendIds), htmlOptions)
97
97
 
98
98
  @textArea = (resource, method, options={}) ->
99
99
  value = options.value
@@ -101,4 +101,4 @@ Joosy.helpers 'Application', ->
101
101
  delete options.value
102
102
  delete options.extendIds
103
103
 
104
- @tag 'textarea', Joosy.Module.merge(description(resource, method, extendIds), options), value
104
+ @contentTag 'textarea', value, Joosy.Module.merge(description(resource, method, extendIds), options)
@@ -0,0 +1,10 @@
1
+ #= require joosy/joosy
2
+ #= require joosy/helpers/view
3
+
4
+ #
5
+ # Rendering and string representation helpers
6
+ #
7
+ Joosy.helpers 'Routes', ->
8
+
9
+ @linkTo = (name='', url='', tagOptions={}) ->
10
+ Joosy.Helpers.Application.contentTag 'a', name, Joosy.Module.merge(tagOptions, 'data-joosy': true, href: url)