joosy 0.1.0.alpha → 1.0.0.RC1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.codoopts +5 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +15 -2
  4. data/Gemfile.lock +102 -81
  5. data/Guardfile +16 -16
  6. data/LICENSE +22 -0
  7. data/MIT-LICENSE +2 -2
  8. data/README.md +118 -0
  9. data/app/assets/javascripts/joosy/core/application.js.coffee +53 -0
  10. data/app/assets/javascripts/joosy/core/form.js.coffee +338 -0
  11. data/app/assets/javascripts/joosy/core/helpers/form.js.coffee +72 -0
  12. data/app/assets/javascripts/joosy/core/helpers/view.js.coffee +42 -0
  13. data/app/assets/javascripts/joosy/core/helpers/widgets.js.coffee +14 -0
  14. data/app/assets/javascripts/joosy/core/joosy.js.coffee +184 -0
  15. data/app/assets/javascripts/joosy/core/layout.js.coffee +168 -0
  16. data/app/assets/javascripts/joosy/core/modules/container.js.coffee +124 -0
  17. data/app/assets/javascripts/joosy/core/modules/events.js.coffee +122 -0
  18. data/app/assets/javascripts/joosy/core/modules/filters.js.coffee +39 -0
  19. data/app/assets/javascripts/joosy/core/modules/log.js.coffee +36 -0
  20. data/app/assets/javascripts/joosy/core/modules/module.js.coffee +117 -0
  21. data/app/assets/javascripts/joosy/core/modules/renderer.js.coffee +200 -0
  22. data/app/assets/javascripts/joosy/core/modules/time_manager.js.coffee +46 -0
  23. data/app/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +87 -0
  24. data/app/assets/javascripts/joosy/core/page.js.coffee +387 -0
  25. data/app/assets/javascripts/joosy/core/preloader.js.coffee +13 -0
  26. data/app/assets/javascripts/joosy/core/resource/collection.js.coffee +175 -0
  27. data/app/assets/javascripts/joosy/core/resource/generic.js.coffee +303 -0
  28. data/app/assets/javascripts/joosy/core/resource/rest.js.coffee +244 -0
  29. data/app/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +24 -0
  30. data/app/assets/javascripts/joosy/core/router.js.coffee +201 -0
  31. data/app/assets/javascripts/joosy/core/templaters/rails_jst.js.coffee +37 -0
  32. data/app/assets/javascripts/joosy/core/widget.js.coffee +85 -0
  33. data/app/assets/javascripts/joosy/preloaders/caching.js.coffee +169 -0
  34. data/app/assets/javascripts/joosy/preloaders/inline.js.coffee +56 -0
  35. data/{vendor → app}/assets/javascripts/joosy.js.coffee +0 -1
  36. data/app/helpers/joosy/sprockets_helper.rb +39 -12
  37. data/joosy.gemspec +4 -3
  38. data/lib/joosy/rails/engine.rb +12 -1
  39. data/lib/joosy/rails/version.rb +2 -2
  40. data/lib/joosy.rb +9 -0
  41. data/lib/rails/generators/joosy/application_generator.rb +15 -3
  42. data/lib/rails/generators/joosy/joosy_base.rb +2 -2
  43. data/lib/rails/generators/joosy/layout_generator.rb +8 -1
  44. data/lib/rails/generators/joosy/page_generator.rb +21 -6
  45. data/lib/rails/generators/joosy/preloader_generator.rb +14 -7
  46. data/lib/rails/generators/joosy/resource_generator.rb +29 -0
  47. data/lib/rails/generators/joosy/templates/app/helpers/application.js.coffee +4 -0
  48. data/lib/rails/generators/joosy/templates/app/layouts/application.js.coffee +1 -0
  49. data/lib/rails/generators/joosy/templates/app/layouts/template.js.coffee +1 -1
  50. data/lib/rails/generators/joosy/templates/app/pages/application.js.coffee +1 -1
  51. data/lib/rails/generators/joosy/templates/app/pages/template.js.coffee +3 -3
  52. data/lib/rails/generators/joosy/templates/app/pages/welcome/index.js.coffee +22 -0
  53. data/lib/rails/generators/joosy/templates/app/resources/template.js.coffee +2 -0
  54. data/lib/rails/generators/joosy/templates/app/routes.js.coffee +7 -1
  55. data/lib/rails/generators/joosy/templates/app/templates/layouts/application.jst.hamlc +2 -0
  56. data/lib/rails/generators/joosy/templates/app/templates/pages/welcome/index.jst.hamlc +7 -0
  57. data/lib/rails/generators/joosy/templates/app/widgets/template.js.coffee +2 -2
  58. data/lib/rails/generators/joosy/templates/app.js.coffee +4 -0
  59. data/lib/rails/generators/joosy/templates/app_preloader.js.coffee.erb +9 -12
  60. data/lib/rails/generators/joosy/templates/app_resources_predefiner.js.coffee.erb +11 -0
  61. data/lib/rails/generators/joosy/templates/preload.html.erb +5 -6
  62. data/lib/rails/generators/joosy/templates/preload.html.haml +3 -5
  63. data/lib/rails/generators/joosy/widget_generator.rb +8 -1
  64. data/lib/rails/resources_with_joosy.rb +11 -0
  65. data/spec/javascripts/helpers/spec_helper.js.coffee +25 -0
  66. data/spec/javascripts/joosy/core/application_spec.js.coffee +40 -0
  67. data/spec/javascripts/joosy/core/form_spec.js.coffee +200 -0
  68. data/spec/javascripts/joosy/core/helpers/forms_spec.js.coffee +103 -0
  69. data/spec/javascripts/joosy/core/helpers/view_spec.js.coffee +10 -0
  70. data/spec/javascripts/joosy/core/joosy_spec.js.coffee +97 -0
  71. data/spec/javascripts/joosy/core/layout_spec.js.coffee +50 -0
  72. data/spec/javascripts/joosy/core/modules/container_spec.js.coffee +32 -27
  73. data/spec/javascripts/joosy/core/modules/events_spec.js.coffee +55 -18
  74. data/spec/javascripts/joosy/core/modules/filters_spec.js.coffee +28 -27
  75. data/spec/javascripts/joosy/core/modules/log_spec.js.coffee +3 -3
  76. data/spec/javascripts/joosy/core/modules/module_spec.js.coffee +6 -15
  77. data/spec/javascripts/joosy/core/modules/renderer_spec.js.coffee +203 -0
  78. data/spec/javascripts/joosy/core/modules/time_manager_spec.js.coffee +12 -7
  79. data/spec/javascripts/joosy/core/modules/widget_manager_spec.js.coffee +31 -17
  80. data/spec/javascripts/joosy/core/page_spec.js.coffee +178 -0
  81. data/spec/javascripts/joosy/core/resource/collection_spec.js.coffee +84 -0
  82. data/spec/javascripts/joosy/core/resource/generic_spec.js.coffee +149 -0
  83. data/spec/javascripts/joosy/core/resource/rest_collection_spec.js.coffee +31 -0
  84. data/spec/javascripts/joosy/core/resource/rest_spec.js.coffee +171 -0
  85. data/spec/javascripts/joosy/core/router_spec.js.coffee +143 -0
  86. data/spec/javascripts/joosy/core/templaters/rails_jst_spec.js.coffee +25 -0
  87. data/spec/javascripts/joosy/core/widget_spec.js.coffee +40 -0
  88. data/spec/javascripts/joosy/preloaders/caching_spec.js.coffee +36 -0
  89. data/spec/javascripts/joosy/preloaders/inline_spec.js.coffee +16 -0
  90. data/spec/javascripts/support/assets/coolface.jpg +0 -0
  91. data/spec/javascripts/support/assets/okay.jpg +0 -0
  92. data/spec/javascripts/support/assets/test.js +1 -0
  93. data/spec/javascripts/support/sinon-ie-1.3.1.js +82 -0
  94. data/vendor/assets/javascripts/jquery.form.js +978 -963
  95. data/vendor/assets/javascripts/metamorph.js +409 -0
  96. data/vendor/assets/javascripts/sugar.js +1057 -366
  97. metadata +95 -50
  98. data/README.rdoc +0 -3
  99. data/lib/joosy/forms.rb +0 -47
  100. data/lib/joosy-rails.rb +0 -5
  101. data/lib/rails/generators/joosy/templates/preload.html.slim +0 -21
  102. data/tmp/javascripts/.gitignore +0 -1
  103. data/tmp/spec/javascripts/helpers/.gitignore +0 -1
  104. data/vendor/assets/javascripts/base64.js +0 -135
  105. data/vendor/assets/javascripts/inflection.js +0 -656
  106. data/vendor/assets/javascripts/joosy/core/application.js.coffee +0 -26
  107. data/vendor/assets/javascripts/joosy/core/form.js.coffee +0 -87
  108. data/vendor/assets/javascripts/joosy/core/joosy.js.coffee +0 -62
  109. data/vendor/assets/javascripts/joosy/core/layout.js.coffee +0 -38
  110. data/vendor/assets/javascripts/joosy/core/modules/container.js.coffee +0 -51
  111. data/vendor/assets/javascripts/joosy/core/modules/events.js.coffee +0 -17
  112. data/vendor/assets/javascripts/joosy/core/modules/filters.js.coffee +0 -39
  113. data/vendor/assets/javascripts/joosy/core/modules/log.js.coffee +0 -12
  114. data/vendor/assets/javascripts/joosy/core/modules/module.js.coffee +0 -28
  115. data/vendor/assets/javascripts/joosy/core/modules/time_manager.js.coffee +0 -23
  116. data/vendor/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +0 -45
  117. data/vendor/assets/javascripts/joosy/core/page.js.coffee +0 -136
  118. data/vendor/assets/javascripts/joosy/core/resource/rest.js.coffee +0 -69
  119. data/vendor/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +0 -42
  120. data/vendor/assets/javascripts/joosy/core/router.js.coffee +0 -75
  121. data/vendor/assets/javascripts/joosy/core/widget.js.coffee +0 -35
  122. data/vendor/assets/javascripts/joosy/preloader/development.js.coffee +0 -27
  123. data/vendor/assets/javascripts/joosy/preloader/production.js.coffee +0 -84
@@ -1,656 +0,0 @@
1
- /*
2
- Copyright (c) 2010 Ryan Schuft (ryan.schuft@gmail.com)
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in
12
- all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- THE SOFTWARE.
21
- */
22
-
23
- /*
24
- This code is based in part on the work done in Ruby to support
25
- infection as part of Ruby on Rails in the ActiveSupport's Inflector
26
- and Inflections classes. It was initally ported to Javascript by
27
- Ryan Schuft (ryan.schuft@gmail.com) in 2007.
28
-
29
- The code is available at http://code.google.com/p/inflection-js/
30
-
31
- The basic usage is:
32
- 1. Include this script on your web page.
33
- 2. Call functions on any String object in Javascript
34
-
35
- Currently implemented functions:
36
-
37
- String.pluralize(plural) == String
38
- renders a singular English language noun into its plural form
39
- normal results can be overridden by passing in an alternative
40
-
41
- String.singularize(singular) == String
42
- renders a plural English language noun into its singular form
43
- normal results can be overridden by passing in an alterative
44
-
45
- String.camelize(lowFirstLetter) == String
46
- renders a lower case underscored word into camel case
47
- the first letter of the result will be upper case unless you pass true
48
- also translates "/" into "::" (underscore does the opposite)
49
-
50
- String.underscore() == String
51
- renders a camel cased word into words seperated by underscores
52
- also translates "::" back into "/" (camelize does the opposite)
53
-
54
- String.humanize(lowFirstLetter) == String
55
- renders a lower case and underscored word into human readable form
56
- defaults to making the first letter capitalized unless you pass true
57
-
58
- String.capitalize() == String
59
- renders all characters to lower case and then makes the first upper
60
-
61
- String.dasherize() == String
62
- renders all underbars and spaces as dashes
63
-
64
- String.titleize() == String
65
- renders words into title casing (as for book titles)
66
-
67
- String.demodulize() == String
68
- renders class names that are prepended by modules into just the class
69
-
70
- String.tableize() == String
71
- renders camel cased singular words into their underscored plural form
72
-
73
- String.classify() == String
74
- renders an underscored plural word into its camel cased singular form
75
-
76
- String.foreign_key(dropIdUbar) == String
77
- renders a class name (camel cased singular noun) into a foreign key
78
- defaults to seperating the class from the id with an underbar unless
79
- you pass true
80
-
81
- String.ordinalize() == String
82
- renders all numbers found in the string into their sequence like "22nd"
83
- */
84
-
85
- /*
86
- This sets up a container for some constants in its own namespace
87
- We use the window (if available) to enable dynamic loading of this script
88
- Window won't necessarily exist for non-browsers.
89
- */
90
- if (window && !window.InflectionJS)
91
- {
92
- window.InflectionJS = null;
93
- }
94
-
95
- /*
96
- This sets up some constants for later use
97
- This should use the window namespace variable if available
98
- */
99
- InflectionJS =
100
- {
101
- /*
102
- This is a list of nouns that use the same form for both singular and plural.
103
- This list should remain entirely in lower case to correctly match Strings.
104
- */
105
- uncountable_words: [
106
- 'equipment', 'information', 'rice', 'money', 'species', 'series',
107
- 'fish', 'sheep', 'moose', 'deer', 'news'
108
- ],
109
-
110
- /*
111
- These rules translate from the singular form of a noun to its plural form.
112
- */
113
- plural_rules: [
114
- [new RegExp('(m)an$', 'gi'), '$1en'],
115
- [new RegExp('(pe)rson$', 'gi'), '$1ople'],
116
- [new RegExp('(child)$', 'gi'), '$1ren'],
117
- [new RegExp('^(ox)$', 'gi'), '$1en'],
118
- [new RegExp('(ax|test)is$', 'gi'), '$1es'],
119
- [new RegExp('(octop|vir)us$', 'gi'), '$1i'],
120
- [new RegExp('(alias|status)$', 'gi'), '$1es'],
121
- [new RegExp('(bu)s$', 'gi'), '$1ses'],
122
- [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],
123
- [new RegExp('([ti])um$', 'gi'), '$1a'],
124
- [new RegExp('sis$', 'gi'), 'ses'],
125
- [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],
126
- [new RegExp('(hive)$', 'gi'), '$1s'],
127
- [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],
128
- [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],
129
- [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],
130
- [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],
131
- [new RegExp('(quiz)$', 'gi'), '$1zes'],
132
- [new RegExp('s$', 'gi'), 's'],
133
- [new RegExp('$', 'gi'), 's']
134
- ],
135
-
136
- /*
137
- These rules translate from the plural form of a noun to its singular form.
138
- */
139
- singular_rules: [
140
- [new RegExp('(m)en$', 'gi'), '$1an'],
141
- [new RegExp('(pe)ople$', 'gi'), '$1rson'],
142
- [new RegExp('(child)ren$', 'gi'), '$1'],
143
- [new RegExp('([ti])a$', 'gi'), '$1um'],
144
- [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$','gi'), '$1$2sis'],
145
- [new RegExp('(hive)s$', 'gi'), '$1'],
146
- [new RegExp('(tive)s$', 'gi'), '$1'],
147
- [new RegExp('(curve)s$', 'gi'), '$1'],
148
- [new RegExp('([lr])ves$', 'gi'), '$1f'],
149
- [new RegExp('([^fo])ves$', 'gi'), '$1fe'],
150
- [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],
151
- [new RegExp('(s)eries$', 'gi'), '$1eries'],
152
- [new RegExp('(m)ovies$', 'gi'), '$1ovie'],
153
- [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],
154
- [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],
155
- [new RegExp('(bus)es$', 'gi'), '$1'],
156
- [new RegExp('(o)es$', 'gi'), '$1'],
157
- [new RegExp('(shoe)s$', 'gi'), '$1'],
158
- [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],
159
- [new RegExp('(octop|vir)i$', 'gi'), '$1us'],
160
- [new RegExp('(alias|status)es$', 'gi'), '$1'],
161
- [new RegExp('^(ox)en', 'gi'), '$1'],
162
- [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],
163
- [new RegExp('(matr)ices$', 'gi'), '$1ix'],
164
- [new RegExp('(quiz)zes$', 'gi'), '$1'],
165
- [new RegExp('s$', 'gi'), '']
166
- ],
167
-
168
- /*
169
- This is a list of words that should not be capitalized for title case
170
- */
171
- non_titlecased_words: [
172
- 'and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at',
173
- 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over',
174
- 'with', 'for'
175
- ],
176
-
177
- /*
178
- These are regular expressions used for converting between String formats
179
- */
180
- id_suffix: new RegExp('(_ids|_id)$', 'g'),
181
- underbar: new RegExp('_', 'g'),
182
- space_or_underbar: new RegExp('[\ _]', 'g'),
183
- uppercase: new RegExp('([A-Z])', 'g'),
184
- underbar_prefix: new RegExp('^_'),
185
-
186
- /*
187
- This is a helper method that applies rules based replacement to a String
188
- Signature:
189
- InflectionJS.apply_rules(str, rules, skip, override) == String
190
- Arguments:
191
- str - String - String to modify and return based on the passed rules
192
- rules - Array: [RegExp, String] - Regexp to match paired with String to use for replacement
193
- skip - Array: [String] - Strings to skip if they match
194
- override - String (optional) - String to return as though this method succeeded (used to conform to APIs)
195
- Returns:
196
- String - passed String modified by passed rules
197
- Examples:
198
- InflectionJS.apply_rules("cows", InflectionJs.singular_rules) === 'cow'
199
- */
200
- apply_rules: function(str, rules, skip, override)
201
- {
202
- if (override)
203
- {
204
- str = override;
205
- }
206
- else
207
- {
208
- var ignore = (skip.indexOf(str.toLowerCase()) > -1);
209
- if (!ignore)
210
- {
211
- for (var x = 0; x < rules.length; x++)
212
- {
213
- if (str.match(rules[x][0]))
214
- {
215
- str = str.replace(rules[x][0], rules[x][1]);
216
- break;
217
- }
218
- }
219
- }
220
- }
221
- return str;
222
- }
223
- };
224
-
225
- /*
226
- This lets us detect if an Array contains a given element
227
- Signature:
228
- Array.indexOf(item, fromIndex, compareFunc) == Integer
229
- Arguments:
230
- item - Object - object to locate in the Array
231
- fromIndex - Integer (optional) - starts checking from this position in the Array
232
- compareFunc - Function (optional) - function used to compare Array item vs passed item
233
- Returns:
234
- Integer - index position in the Array of the passed item
235
- Examples:
236
- ['hi','there'].indexOf("guys") === -1
237
- ['hi','there'].indexOf("hi") === 0
238
- */
239
- if (!Array.prototype.indexOf)
240
- {
241
- Array.prototype.indexOf = function(item, fromIndex, compareFunc)
242
- {
243
- if (!fromIndex)
244
- {
245
- fromIndex = -1;
246
- }
247
- var index = -1;
248
- for (var i = fromIndex; i < this.length; i++)
249
- {
250
- if (this[i] === item || compareFunc && compareFunc(this[i], item))
251
- {
252
- index = i;
253
- break;
254
- }
255
- }
256
- return index;
257
- };
258
- }
259
-
260
- /*
261
- You can override this list for all Strings or just one depending on if you
262
- set the new values on prototype or on a given String instance.
263
- */
264
- if (!String.prototype._uncountable_words)
265
- {
266
- String.prototype._uncountable_words = InflectionJS.uncountable_words;
267
- }
268
-
269
- /*
270
- You can override this list for all Strings or just one depending on if you
271
- set the new values on prototype or on a given String instance.
272
- */
273
- if (!String.prototype._plural_rules)
274
- {
275
- String.prototype._plural_rules = InflectionJS.plural_rules;
276
- }
277
-
278
- /*
279
- You can override this list for all Strings or just one depending on if you
280
- set the new values on prototype or on a given String instance.
281
- */
282
- if (!String.prototype._singular_rules)
283
- {
284
- String.prototype._singular_rules = InflectionJS.singular_rules;
285
- }
286
-
287
- /*
288
- You can override this list for all Strings or just one depending on if you
289
- set the new values on prototype or on a given String instance.
290
- */
291
- if (!String.prototype._non_titlecased_words)
292
- {
293
- String.prototype._non_titlecased_words = InflectionJS.non_titlecased_words;
294
- }
295
-
296
- /*
297
- This function adds plurilization support to every String object
298
- Signature:
299
- String.pluralize(plural) == String
300
- Arguments:
301
- plural - String (optional) - overrides normal output with said String
302
- Returns:
303
- String - singular English language nouns are returned in plural form
304
- Examples:
305
- "person".pluralize() == "people"
306
- "octopus".pluralize() == "octopi"
307
- "Hat".pluralize() == "Hats"
308
- "person".pluralize("guys") == "guys"
309
- */
310
- if (!String.prototype.pluralize)
311
- {
312
- String.prototype.pluralize = function(plural)
313
- {
314
- return InflectionJS.apply_rules(
315
- this,
316
- this._plural_rules,
317
- this._uncountable_words,
318
- plural
319
- );
320
- };
321
- }
322
-
323
- /*
324
- This function adds singularization support to every String object
325
- Signature:
326
- String.singularize(singular) == String
327
- Arguments:
328
- singular - String (optional) - overrides normal output with said String
329
- Returns:
330
- String - plural English language nouns are returned in singular form
331
- Examples:
332
- "people".singularize() == "person"
333
- "octopi".singularize() == "octopus"
334
- "Hats".singularize() == "Hat"
335
- "guys".singularize("person") == "person"
336
- */
337
- if (!String.prototype.singularize)
338
- {
339
- String.prototype.singularize = function(singular)
340
- {
341
- return InflectionJS.apply_rules(
342
- this,
343
- this._singular_rules,
344
- this._uncountable_words,
345
- singular
346
- );
347
- };
348
- }
349
-
350
- /*
351
- This function adds camelization support to every String object
352
- Signature:
353
- String.camelize(lowFirstLetter) == String
354
- Arguments:
355
- lowFirstLetter - boolean (optional) - default is to capitalize the first
356
- letter of the results... passing true will lowercase it
357
- Returns:
358
- String - lower case underscored words will be returned in camel case
359
- additionally '/' is translated to '::'
360
- Examples:
361
- "message_properties".camelize() == "MessageProperties"
362
- "message_properties".camelize(true) == "messageProperties"
363
- */
364
- if (!String.prototype.camelize)
365
- {
366
- String.prototype.camelize = function(lowFirstLetter)
367
- {
368
- var str = this.toLowerCase();
369
- var str_path = str.split('/');
370
- for (var i = 0; i < str_path.length; i++)
371
- {
372
- var str_arr = str_path[i].split('_');
373
- var initX = ((lowFirstLetter && i + 1 === str_path.length) ? (1) : (0));
374
- for (var x = initX; x < str_arr.length; x++)
375
- {
376
- str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);
377
- }
378
- str_path[i] = str_arr.join('');
379
- }
380
- str = str_path.join('::');
381
- return str;
382
- };
383
- }
384
-
385
- /*
386
- This function adds underscore support to every String object
387
- Signature:
388
- String.underscore() == String
389
- Arguments:
390
- N/A
391
- Returns:
392
- String - camel cased words are returned as lower cased and underscored
393
- additionally '::' is translated to '/'
394
- Examples:
395
- "MessageProperties".camelize() == "message_properties"
396
- "messageProperties".underscore() == "message_properties"
397
- */
398
- if (!String.prototype.underscore)
399
- {
400
- String.prototype.underscore = function()
401
- {
402
- var str = this;
403
- var str_path = str.split('::');
404
- for (var i = 0; i < str_path.length; i++)
405
- {
406
- str_path[i] = str_path[i].replace(InflectionJS.uppercase, '_$1');
407
- str_path[i] = str_path[i].replace(InflectionJS.underbar_prefix, '');
408
- }
409
- str = str_path.join('/').toLowerCase();
410
- return str;
411
- };
412
- }
413
-
414
- /*
415
- This function adds humanize support to every String object
416
- Signature:
417
- String.humanize(lowFirstLetter) == String
418
- Arguments:
419
- lowFirstLetter - boolean (optional) - default is to capitalize the first
420
- letter of the results... passing true will lowercase it
421
- Returns:
422
- String - lower case underscored words will be returned in humanized form
423
- Examples:
424
- "message_properties".humanize() == "Message properties"
425
- "message_properties".humanize(true) == "message properties"
426
- */
427
- if (!String.prototype.humanize)
428
- {
429
- String.prototype.humanize = function(lowFirstLetter)
430
- {
431
- var str = this.toLowerCase();
432
- str = str.replace(InflectionJS.id_suffix, '');
433
- str = str.replace(InflectionJS.underbar, ' ');
434
- if (!lowFirstLetter)
435
- {
436
- str = str.capitalize();
437
- }
438
- return str;
439
- };
440
- }
441
-
442
- /*
443
- This function adds capitalization support to every String object
444
- Signature:
445
- String.capitalize() == String
446
- Arguments:
447
- N/A
448
- Returns:
449
- String - all characters will be lower case and the first will be upper
450
- Examples:
451
- "message_properties".capitalize() == "Message_properties"
452
- "message properties".capitalize() == "Message properties"
453
- */
454
- if (!String.prototype.capitalize)
455
- {
456
- String.prototype.capitalize = function()
457
- {
458
- var str = this.toLowerCase();
459
- str = str.substring(0, 1).toUpperCase() + str.substring(1);
460
- return str;
461
- };
462
- }
463
-
464
- /*
465
- This function adds dasherization support to every String object
466
- Signature:
467
- String.dasherize() == String
468
- Arguments:
469
- N/A
470
- Returns:
471
- String - replaces all spaces or underbars with dashes
472
- Examples:
473
- "message_properties".capitalize() == "message-properties"
474
- "Message Properties".capitalize() == "Message-Properties"
475
- */
476
- if (!String.prototype.dasherize)
477
- {
478
- String.prototype.dasherize = function()
479
- {
480
- var str = this;
481
- str = str.replace(InflectionJS.space_or_underbar, '-');
482
- return str;
483
- };
484
- }
485
-
486
- /*
487
- This function adds titleize support to every String object
488
- Signature:
489
- String.titleize() == String
490
- Arguments:
491
- N/A
492
- Returns:
493
- String - capitalizes words as you would for a book title
494
- Examples:
495
- "message_properties".titleize() == "Message Properties"
496
- "message properties to keep".titleize() == "Message Properties to Keep"
497
- */
498
- if (!String.prototype.titleize)
499
- {
500
- String.prototype.titleize = function()
501
- {
502
- var str = this.toLowerCase();
503
- str = str.replace(InflectionJS.underbar, ' ');
504
- var str_arr = str.split(' ');
505
- for (var x = 0; x < str_arr.length; x++)
506
- {
507
- var d = str_arr[x].split('-');
508
- for (var i = 0; i < d.length; i++)
509
- {
510
- if (this._non_titlecased_words.indexOf(d[i].toLowerCase()) < 0)
511
- {
512
- d[i] = d[i].capitalize();
513
- }
514
- }
515
- str_arr[x] = d.join('-');
516
- }
517
- str = str_arr.join(' ');
518
- str = str.substring(0, 1).toUpperCase() + str.substring(1);
519
- return str;
520
- };
521
- }
522
-
523
- /*
524
- This function adds demodulize support to every String object
525
- Signature:
526
- String.demodulize() == String
527
- Arguments:
528
- N/A
529
- Returns:
530
- String - removes module names leaving only class names (Ruby style)
531
- Examples:
532
- "Message::Bus::Properties".demodulize() == "Properties"
533
- */
534
- if (!String.prototype.demodulize)
535
- {
536
- String.prototype.demodulize = function()
537
- {
538
- var str = this;
539
- var str_arr = str.split('::');
540
- str = str_arr[str_arr.length - 1];
541
- return str;
542
- };
543
- }
544
-
545
- /*
546
- This function adds tableize support to every String object
547
- Signature:
548
- String.tableize() == String
549
- Arguments:
550
- N/A
551
- Returns:
552
- String - renders camel cased words into their underscored plural form
553
- Examples:
554
- "MessageBusProperty".tableize() == "message_bus_properties"
555
- */
556
- if (!String.prototype.tableize)
557
- {
558
- String.prototype.tableize = function()
559
- {
560
- var str = this;
561
- str = str.underscore().pluralize();
562
- return str;
563
- };
564
- }
565
-
566
- /*
567
- This function adds classification support to every String object
568
- Signature:
569
- String.classify() == String
570
- Arguments:
571
- N/A
572
- Returns:
573
- String - underscored plural nouns become the camel cased singular form
574
- Examples:
575
- "message_bus_properties".classify() == "MessageBusProperty"
576
- */
577
- if (!String.prototype.classify)
578
- {
579
- String.prototype.classify = function()
580
- {
581
- var str = this;
582
- str = str.camelize().singularize();
583
- return str;
584
- };
585
- }
586
-
587
- /*
588
- This function adds foreign key support to every String object
589
- Signature:
590
- String.foreign_key(dropIdUbar) == String
591
- Arguments:
592
- dropIdUbar - boolean (optional) - default is to seperate id with an
593
- underbar at the end of the class name, you can pass true to skip it
594
- Returns:
595
- String - camel cased singular class names become underscored with id
596
- Examples:
597
- "MessageBusProperty".foreign_key() == "message_bus_property_id"
598
- "MessageBusProperty".foreign_key(true) == "message_bus_propertyid"
599
- */
600
- if (!String.prototype.foreign_key)
601
- {
602
- String.prototype.foreign_key = function(dropIdUbar)
603
- {
604
- var str = this;
605
- str = str.demodulize().underscore() + ((dropIdUbar) ? ('') : ('_')) + 'id';
606
- return str;
607
- };
608
- }
609
-
610
- /*
611
- This function adds ordinalize support to every String object
612
- Signature:
613
- String.ordinalize() == String
614
- Arguments:
615
- N/A
616
- Returns:
617
- String - renders all found numbers their sequence like "22nd"
618
- Examples:
619
- "the 1 pitch".ordinalize() == "the 1st pitch"
620
- */
621
- if (!String.prototype.ordinalize)
622
- {
623
- String.prototype.ordinalize = function()
624
- {
625
- var str = this;
626
- var str_arr = str.split(' ');
627
- for (var x = 0; x < str_arr.length; x++)
628
- {
629
- var i = parseInt(str_arr[x]);
630
- if (i === NaN)
631
- {
632
- var ltd = str_arr[x].substring(str_arr[x].length - 2);
633
- var ld = str_arr[x].substring(str_arr[x].length - 1);
634
- var suf = "th";
635
- if (ltd != "11" && ltd != "12" && ltd != "13")
636
- {
637
- if (ld === "1")
638
- {
639
- suf = "st";
640
- }
641
- else if (ld === "2")
642
- {
643
- suf = "nd";
644
- }
645
- else if (ld === "3")
646
- {
647
- suf = "rd";
648
- }
649
- }
650
- str_arr[x] += suf;
651
- }
652
- }
653
- str = str_arr.join(' ');
654
- return str;
655
- };
656
- }
@@ -1,26 +0,0 @@
1
- #= require joosy/core/joosy
2
-
3
- Joosy.Application =
4
- Pages: {}
5
- Layouts: {}
6
- Controls: {}
7
-
8
- selector: false
9
-
10
- initialize: (selector) ->
11
- @selector = selector
12
- Joosy.Router.setupRoutes()
13
-
14
- @sandboxSelector = Joosy.uuid()
15
- @content().after("<div id='#{@sandboxSelector}' style='display:none'></div>")
16
- @sandboxSelector = '#'+@sandboxSelector
17
-
18
- content: ->
19
- $(@selector)
20
-
21
- sandbox: ->
22
- $(@sandboxSelector)
23
-
24
- setCurrentPage: (page, params) ->
25
- #if @page not instanceof page
26
- @page = new page(params, @page)