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.
- data/.codoopts +5 -0
- data/.gitignore +2 -0
- data/Gemfile +15 -2
- data/Gemfile.lock +102 -81
- data/Guardfile +16 -16
- data/LICENSE +22 -0
- data/MIT-LICENSE +2 -2
- data/README.md +118 -0
- data/app/assets/javascripts/joosy/core/application.js.coffee +53 -0
- data/app/assets/javascripts/joosy/core/form.js.coffee +338 -0
- data/app/assets/javascripts/joosy/core/helpers/form.js.coffee +72 -0
- data/app/assets/javascripts/joosy/core/helpers/view.js.coffee +42 -0
- data/app/assets/javascripts/joosy/core/helpers/widgets.js.coffee +14 -0
- data/app/assets/javascripts/joosy/core/joosy.js.coffee +184 -0
- data/app/assets/javascripts/joosy/core/layout.js.coffee +168 -0
- data/app/assets/javascripts/joosy/core/modules/container.js.coffee +124 -0
- data/app/assets/javascripts/joosy/core/modules/events.js.coffee +122 -0
- data/app/assets/javascripts/joosy/core/modules/filters.js.coffee +39 -0
- data/app/assets/javascripts/joosy/core/modules/log.js.coffee +36 -0
- data/app/assets/javascripts/joosy/core/modules/module.js.coffee +117 -0
- data/app/assets/javascripts/joosy/core/modules/renderer.js.coffee +200 -0
- data/app/assets/javascripts/joosy/core/modules/time_manager.js.coffee +46 -0
- data/app/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +87 -0
- data/app/assets/javascripts/joosy/core/page.js.coffee +387 -0
- data/app/assets/javascripts/joosy/core/preloader.js.coffee +13 -0
- data/app/assets/javascripts/joosy/core/resource/collection.js.coffee +175 -0
- data/app/assets/javascripts/joosy/core/resource/generic.js.coffee +303 -0
- data/app/assets/javascripts/joosy/core/resource/rest.js.coffee +244 -0
- data/app/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +24 -0
- data/app/assets/javascripts/joosy/core/router.js.coffee +201 -0
- data/app/assets/javascripts/joosy/core/templaters/rails_jst.js.coffee +37 -0
- data/app/assets/javascripts/joosy/core/widget.js.coffee +85 -0
- data/app/assets/javascripts/joosy/preloaders/caching.js.coffee +169 -0
- data/app/assets/javascripts/joosy/preloaders/inline.js.coffee +56 -0
- data/{vendor → app}/assets/javascripts/joosy.js.coffee +0 -1
- data/app/helpers/joosy/sprockets_helper.rb +39 -12
- data/joosy.gemspec +4 -3
- data/lib/joosy/rails/engine.rb +12 -1
- data/lib/joosy/rails/version.rb +2 -2
- data/lib/joosy.rb +9 -0
- data/lib/rails/generators/joosy/application_generator.rb +15 -3
- data/lib/rails/generators/joosy/joosy_base.rb +2 -2
- data/lib/rails/generators/joosy/layout_generator.rb +8 -1
- data/lib/rails/generators/joosy/page_generator.rb +21 -6
- data/lib/rails/generators/joosy/preloader_generator.rb +14 -7
- data/lib/rails/generators/joosy/resource_generator.rb +29 -0
- data/lib/rails/generators/joosy/templates/app/helpers/application.js.coffee +4 -0
- data/lib/rails/generators/joosy/templates/app/layouts/application.js.coffee +1 -0
- data/lib/rails/generators/joosy/templates/app/layouts/template.js.coffee +1 -1
- data/lib/rails/generators/joosy/templates/app/pages/application.js.coffee +1 -1
- data/lib/rails/generators/joosy/templates/app/pages/template.js.coffee +3 -3
- data/lib/rails/generators/joosy/templates/app/pages/welcome/index.js.coffee +22 -0
- data/lib/rails/generators/joosy/templates/app/resources/template.js.coffee +2 -0
- data/lib/rails/generators/joosy/templates/app/routes.js.coffee +7 -1
- data/lib/rails/generators/joosy/templates/app/templates/layouts/application.jst.hamlc +2 -0
- data/lib/rails/generators/joosy/templates/app/templates/pages/welcome/index.jst.hamlc +7 -0
- data/lib/rails/generators/joosy/templates/app/widgets/template.js.coffee +2 -2
- data/lib/rails/generators/joosy/templates/app.js.coffee +4 -0
- data/lib/rails/generators/joosy/templates/app_preloader.js.coffee.erb +9 -12
- data/lib/rails/generators/joosy/templates/app_resources_predefiner.js.coffee.erb +11 -0
- data/lib/rails/generators/joosy/templates/preload.html.erb +5 -6
- data/lib/rails/generators/joosy/templates/preload.html.haml +3 -5
- data/lib/rails/generators/joosy/widget_generator.rb +8 -1
- data/lib/rails/resources_with_joosy.rb +11 -0
- data/spec/javascripts/helpers/spec_helper.js.coffee +25 -0
- data/spec/javascripts/joosy/core/application_spec.js.coffee +40 -0
- data/spec/javascripts/joosy/core/form_spec.js.coffee +200 -0
- data/spec/javascripts/joosy/core/helpers/forms_spec.js.coffee +103 -0
- data/spec/javascripts/joosy/core/helpers/view_spec.js.coffee +10 -0
- data/spec/javascripts/joosy/core/joosy_spec.js.coffee +97 -0
- data/spec/javascripts/joosy/core/layout_spec.js.coffee +50 -0
- data/spec/javascripts/joosy/core/modules/container_spec.js.coffee +32 -27
- data/spec/javascripts/joosy/core/modules/events_spec.js.coffee +55 -18
- data/spec/javascripts/joosy/core/modules/filters_spec.js.coffee +28 -27
- data/spec/javascripts/joosy/core/modules/log_spec.js.coffee +3 -3
- data/spec/javascripts/joosy/core/modules/module_spec.js.coffee +6 -15
- data/spec/javascripts/joosy/core/modules/renderer_spec.js.coffee +203 -0
- data/spec/javascripts/joosy/core/modules/time_manager_spec.js.coffee +12 -7
- data/spec/javascripts/joosy/core/modules/widget_manager_spec.js.coffee +31 -17
- data/spec/javascripts/joosy/core/page_spec.js.coffee +178 -0
- data/spec/javascripts/joosy/core/resource/collection_spec.js.coffee +84 -0
- data/spec/javascripts/joosy/core/resource/generic_spec.js.coffee +149 -0
- data/spec/javascripts/joosy/core/resource/rest_collection_spec.js.coffee +31 -0
- data/spec/javascripts/joosy/core/resource/rest_spec.js.coffee +171 -0
- data/spec/javascripts/joosy/core/router_spec.js.coffee +143 -0
- data/spec/javascripts/joosy/core/templaters/rails_jst_spec.js.coffee +25 -0
- data/spec/javascripts/joosy/core/widget_spec.js.coffee +40 -0
- data/spec/javascripts/joosy/preloaders/caching_spec.js.coffee +36 -0
- data/spec/javascripts/joosy/preloaders/inline_spec.js.coffee +16 -0
- data/spec/javascripts/support/assets/coolface.jpg +0 -0
- data/spec/javascripts/support/assets/okay.jpg +0 -0
- data/spec/javascripts/support/assets/test.js +1 -0
- data/spec/javascripts/support/sinon-ie-1.3.1.js +82 -0
- data/vendor/assets/javascripts/jquery.form.js +978 -963
- data/vendor/assets/javascripts/metamorph.js +409 -0
- data/vendor/assets/javascripts/sugar.js +1057 -366
- metadata +95 -50
- data/README.rdoc +0 -3
- data/lib/joosy/forms.rb +0 -47
- data/lib/joosy-rails.rb +0 -5
- data/lib/rails/generators/joosy/templates/preload.html.slim +0 -21
- data/tmp/javascripts/.gitignore +0 -1
- data/tmp/spec/javascripts/helpers/.gitignore +0 -1
- data/vendor/assets/javascripts/base64.js +0 -135
- data/vendor/assets/javascripts/inflection.js +0 -656
- data/vendor/assets/javascripts/joosy/core/application.js.coffee +0 -26
- data/vendor/assets/javascripts/joosy/core/form.js.coffee +0 -87
- data/vendor/assets/javascripts/joosy/core/joosy.js.coffee +0 -62
- data/vendor/assets/javascripts/joosy/core/layout.js.coffee +0 -38
- data/vendor/assets/javascripts/joosy/core/modules/container.js.coffee +0 -51
- data/vendor/assets/javascripts/joosy/core/modules/events.js.coffee +0 -17
- data/vendor/assets/javascripts/joosy/core/modules/filters.js.coffee +0 -39
- data/vendor/assets/javascripts/joosy/core/modules/log.js.coffee +0 -12
- data/vendor/assets/javascripts/joosy/core/modules/module.js.coffee +0 -28
- data/vendor/assets/javascripts/joosy/core/modules/time_manager.js.coffee +0 -23
- data/vendor/assets/javascripts/joosy/core/modules/widgets_manager.js.coffee +0 -45
- data/vendor/assets/javascripts/joosy/core/page.js.coffee +0 -136
- data/vendor/assets/javascripts/joosy/core/resource/rest.js.coffee +0 -69
- data/vendor/assets/javascripts/joosy/core/resource/rest_collection.js.coffee +0 -42
- data/vendor/assets/javascripts/joosy/core/router.js.coffee +0 -75
- data/vendor/assets/javascripts/joosy/core/widget.js.coffee +0 -35
- data/vendor/assets/javascripts/joosy/preloader/development.js.coffee +0 -27
- data/vendor/assets/javascripts/joosy/preloader/production.js.coffee +0 -84
@@ -1,75 +0,0 @@
|
|
1
|
-
#= require joosy/core/joosy
|
2
|
-
|
3
|
-
Joosy.Router =
|
4
|
-
rawRoutes: Object.extended()
|
5
|
-
routes: Object.extended()
|
6
|
-
|
7
|
-
map: (routes) ->
|
8
|
-
@rawRoutes.merge routes
|
9
|
-
|
10
|
-
setupRoutes: ->
|
11
|
-
@prepareRoutes @rawRoutes
|
12
|
-
|
13
|
-
@respondRoute(location.hash)
|
14
|
-
$(window).hashchange => @respondRoute(location.hash)
|
15
|
-
|
16
|
-
prepareRoutes: (routes, namespace='') ->
|
17
|
-
if !namespace && routes[404]
|
18
|
-
@wildcardAction = routes[404]
|
19
|
-
delete routes[404]
|
20
|
-
routes.each (path, response) =>
|
21
|
-
path = (namespace+path).replace(/\/{2,}/, '/')
|
22
|
-
if response && (typeof(response) == 'function' || response.prototype?)
|
23
|
-
@prepareRoute path, response
|
24
|
-
else
|
25
|
-
@prepareRoutes Object.extended(response), path
|
26
|
-
|
27
|
-
prepareRoute: (path, response) ->
|
28
|
-
matchPath = path.replace(/\/:([^\/]+)/g, '/([^/]+)').replace(/^\/?/, '^/?').replace(/\/?$/, '/?$')
|
29
|
-
@routes[matchPath] =
|
30
|
-
capture : (path.match(/\/:[^\/]+/g) || []).map((str) -> str.substr(2))
|
31
|
-
action : response
|
32
|
-
|
33
|
-
respondRoute: (hash) ->
|
34
|
-
fullPath = hash.replace(/^#!?/, '')
|
35
|
-
|
36
|
-
if @currentPath != fullPath
|
37
|
-
@currentPath = fullPath
|
38
|
-
found = false
|
39
|
-
|
40
|
-
paramStr = fullPath.split('&')
|
41
|
-
path = paramStr.shift()
|
42
|
-
urlParams = @getUrlParams(paramStr)
|
43
|
-
|
44
|
-
for regex, route of @routes when @routes.hasOwnProperty(regex)
|
45
|
-
if vals = path.match(new RegExp(regex))
|
46
|
-
params = @getRouteParams(vals, route).merge urlParams
|
47
|
-
|
48
|
-
if !Joosy.Module.hasAncestor(route.action, Joosy.Page)
|
49
|
-
route.action.call(this, params)
|
50
|
-
else
|
51
|
-
Joosy.Application.setCurrentPage(route.action, params)
|
52
|
-
found = true
|
53
|
-
break
|
54
|
-
|
55
|
-
if !found && @wildcardAction
|
56
|
-
@wildcardAction(path, urlParams)
|
57
|
-
|
58
|
-
getRouteParams: (vals, route) ->
|
59
|
-
params = Object.extended()
|
60
|
-
vals.shift()
|
61
|
-
for param in route.capture
|
62
|
-
params[param] = vals.shift()
|
63
|
-
return params
|
64
|
-
|
65
|
-
getUrlParams: (paramStr) ->
|
66
|
-
params = {}
|
67
|
-
if paramStr
|
68
|
-
$.each paramStr, () ->
|
69
|
-
if @ != ''
|
70
|
-
pair = @.split '='
|
71
|
-
params[pair[0]] = pair[1]
|
72
|
-
return params
|
73
|
-
|
74
|
-
navigate: (to) ->
|
75
|
-
location.hash = '!'+to
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#= require joosy/core/joosy
|
2
|
-
#= require joosy/core/modules/module
|
3
|
-
#= require joosy/core/modules/log
|
4
|
-
#= require joosy/core/modules/events
|
5
|
-
#= require joosy/core/modules/container
|
6
|
-
#= require joosy/core/modules/filters
|
7
|
-
|
8
|
-
class Joosy.Widget extends Joosy.Module
|
9
|
-
@include Joosy.Modules.Log
|
10
|
-
@include Joosy.Modules.Events
|
11
|
-
@include Joosy.Modules.Container
|
12
|
-
@include Joosy.Modules.Filters
|
13
|
-
|
14
|
-
__render: false
|
15
|
-
|
16
|
-
@render: (callback) ->
|
17
|
-
@::__render = callback
|
18
|
-
|
19
|
-
setInterval: (args...) ->
|
20
|
-
@parent.setInterval(args...)
|
21
|
-
|
22
|
-
setTimeout: (args...) ->
|
23
|
-
@parent.setTimeout(args...)
|
24
|
-
|
25
|
-
navigate: (args...) -> Joosy.Router.navigate(args...)
|
26
|
-
|
27
|
-
__load: (@parent, @container) ->
|
28
|
-
@__render?()
|
29
|
-
@refreshElements()
|
30
|
-
@__delegateEvents()
|
31
|
-
@__runAfterLoads()
|
32
|
-
return @
|
33
|
-
|
34
|
-
__unload: ->
|
35
|
-
@__runAfterUnloads()
|
@@ -1,27 +0,0 @@
|
|
1
|
-
@Preloader =
|
2
|
-
receive: (url, callback) ->
|
3
|
-
head = document.getElementsByTagName("head")[0]
|
4
|
-
script = document.createElement("script")
|
5
|
-
script.src = url# + (if url.match(/\?/) then '&' else '?') + "rand=" + Math.random()
|
6
|
-
|
7
|
-
done = false
|
8
|
-
|
9
|
-
proceed = ->
|
10
|
-
if ( !done && (!this.readyState ||
|
11
|
-
this.readyState == "loaded" || this.readyState == "complete") )
|
12
|
-
|
13
|
-
done = true and callback() if callback
|
14
|
-
script.onload = script.onreadystatechange = null
|
15
|
-
|
16
|
-
script.onload = script.onreadystatechange = proceed
|
17
|
-
|
18
|
-
head.appendChild(script)
|
19
|
-
return undefined
|
20
|
-
|
21
|
-
load: (libraries) ->
|
22
|
-
@start?.call window
|
23
|
-
|
24
|
-
if libraries.length > 0
|
25
|
-
@receive libraries.shift()[0], => @load(libraries)
|
26
|
-
else
|
27
|
-
@complete?.call window
|
@@ -1,84 +0,0 @@
|
|
1
|
-
#= require base64
|
2
|
-
|
3
|
-
window.globalEval = (src) ->
|
4
|
-
if window.execScript
|
5
|
-
window.execScript src
|
6
|
-
else
|
7
|
-
fn = ->
|
8
|
-
window.eval.call window,src
|
9
|
-
fn()
|
10
|
-
|
11
|
-
@Preloader =
|
12
|
-
force: false
|
13
|
-
prefix: "cache:"
|
14
|
-
|
15
|
-
libraries: []
|
16
|
-
counter: 0
|
17
|
-
|
18
|
-
complete: false
|
19
|
-
|
20
|
-
ajax: (url, size, callback) ->
|
21
|
-
x = this.ActiveXObject
|
22
|
-
x = new (if x then x else XMLHttpRequest)('Microsoft.XMLHTTP')
|
23
|
-
|
24
|
-
x.open('GET', url, 1)
|
25
|
-
x.setRequestHeader('Content-type','application/x-www-form-urlencoded')
|
26
|
-
|
27
|
-
if @progress
|
28
|
-
x.onprogress = (event) =>
|
29
|
-
total = if size then size else event.total
|
30
|
-
@progress.call window, Math.round(event.loaded / total * 100 * @counter / @libraries.length), event
|
31
|
-
|
32
|
-
x.onreadystatechange = () -> callback(x) if callback? && x.readyState > 3
|
33
|
-
x.send()
|
34
|
-
|
35
|
-
restore: ->
|
36
|
-
for name, i in @libraries
|
37
|
-
code = window.localStorage.getItem(name)
|
38
|
-
window.globalEval if window.navigator.appName == "Microsoft Internet Explorer" then Base64.decode(code) else code
|
39
|
-
@complete?.call window, (true)
|
40
|
-
|
41
|
-
download: (libraries) ->
|
42
|
-
if libraries.length > 0
|
43
|
-
@counter += 1
|
44
|
-
|
45
|
-
lib = libraries.shift()
|
46
|
-
url = lib[0]
|
47
|
-
size = lib[1]
|
48
|
-
|
49
|
-
@ajax url, size, (xhr) =>
|
50
|
-
code = xhr.responseText
|
51
|
-
window.localStorage.setItem @prefix+url, (if window.navigator.appName == "Microsoft Internet Explorer" then Base64.encode(code) else code)
|
52
|
-
window.globalEval xhr.responseText
|
53
|
-
@download(libraries)
|
54
|
-
else
|
55
|
-
@clean()
|
56
|
-
@complete?.call window, false
|
57
|
-
|
58
|
-
load: (libraries) ->
|
59
|
-
@libraries = libraries.slice()
|
60
|
-
|
61
|
-
for lib, i in @libraries
|
62
|
-
@libraries[i] = @prefix+lib[0]
|
63
|
-
|
64
|
-
if !@force && @check()
|
65
|
-
@restore()
|
66
|
-
else
|
67
|
-
@start?.call window
|
68
|
-
@download(libraries)
|
69
|
-
|
70
|
-
check: ->
|
71
|
-
flag = true
|
72
|
-
for name, i in @libraries
|
73
|
-
flag &&= window.localStorage.getItem(name)?
|
74
|
-
flag
|
75
|
-
|
76
|
-
clean: ->
|
77
|
-
removed = 0
|
78
|
-
|
79
|
-
for element, i in window.localStorage
|
80
|
-
key = window.localStorage.key(i-removed)
|
81
|
-
|
82
|
-
if key.indexOf(@prefix) == 0 && @libraries.indexOf(key) < 0
|
83
|
-
window.localStorage.removeItem(key)
|
84
|
-
removed += 1
|