rocky 0.1.2.pre → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -133
- data/lib/rocky/version.rb +1 -1
- data/vendor/assets/javascripts/backbone.js +589 -505
- data/vendor/assets/javascripts/middleware/component/json_form.js.coffee +8 -13
- data/vendor/assets/javascripts/middleware/system/env.js.coffee +9 -0
- data/vendor/assets/javascripts/middleware.js.coffee +4 -1
- metadata +5 -5
- data/vendor/assets/javascripts/middleware/component/modal.js.coffee +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b359b1c9b8c3d5472c22efe659e22cfe0152eaa0
|
4
|
+
data.tar.gz: 4e42a783a6cf192ecd56c6a68401debc1d9ce7f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 190e15323df7306766cf663ac41b3e5a5ddc3ddc259d911f5bae79254071c1f1792499da98bae4e1f41d49cad757cc8401d32029a0110e87c1f747f12c989b56
|
7
|
+
data.tar.gz: e625d4b5982b981378454cd296b38cf4cc7bbb391f6b6f175b68687340a8f716d4072cf69b085444b2111d97b0d441f7571cf4e29ab181c47935039aa8f15120
|
data/README.md
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
# Rocky
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
### Latest News:
|
6
|
-
+ 26.03 JsonForm Component added to core, reBind() added to Base class.
|
3
|
+
[](https://travis-ci.org/Semjonow/rocky)
|
7
4
|
|
8
5
|
Rocky is CoffeeScript Middleware that binds class objects with HTML page elements.
|
9
6
|
Class objects interact with page elements through Backbone events.
|
10
|
-
Rocky also implements the logic of the following components:
|
11
|
-
Modal (Dynamic building and binding)
|
12
|
-
Puppet page (Blank page, which closed after the action and sends instructions to the parent window)
|
13
|
-
|
14
7
|
|
15
8
|
## Installation
|
16
9
|
|
@@ -23,137 +16,13 @@ And then execute:
|
|
23
16
|
$ bundle
|
24
17
|
$ rails g rocky:install
|
25
18
|
|
26
|
-
Last command will add the following lines
|
19
|
+
Last command will add the following lines to file (app/assets/javascripts/application.js):
|
27
20
|
|
28
21
|
//= require underscore
|
29
22
|
//= require backbone
|
30
23
|
//= require middleware
|
31
24
|
//= require application/#{your_application_name}
|
32
25
|
|
33
|
-
## Login Form example
|
34
|
-
|
35
|
-
Login Controller (SessionsController):
|
36
|
-
|
37
|
-
def new
|
38
|
-
@user_session = UserSession.new
|
39
|
-
end
|
40
|
-
|
41
|
-
def create
|
42
|
-
@user_session = log_in(params[:user_session])
|
43
|
-
|
44
|
-
if logged_in?
|
45
|
-
render :json => { :completed => true, :url => root_path }
|
46
|
-
else
|
47
|
-
flash.now[:alert] = "Incorrect email or password"
|
48
|
-
render :json => { :completed => false, :template => render_to_string("sessions/new") }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
Login Template (sessions/new.haml):
|
53
|
-
|
54
|
-
.login.form{ :data => { :block => "login_form" } }
|
55
|
-
|
56
|
-
- flash.each do |key, value|
|
57
|
-
%div{ :class => "alert alert-#{key == :notice ? 'success' : 'error'}" }= value
|
58
|
-
|
59
|
-
= form_for(@user_session, :url => login_path, :remote => true, :method => :post) do |form|
|
60
|
-
|
61
|
-
.field
|
62
|
-
= form.label :email
|
63
|
-
= form.text_field :email, :autofocus => true
|
64
|
-
|
65
|
-
.field
|
66
|
-
= form.label :password
|
67
|
-
= form.password_field :password
|
68
|
-
|
69
|
-
.actions
|
70
|
-
link_to "Facebook login", "javascript:void(0)", :data => { :url => "facebook_oauth2_path",
|
71
|
-
:action => "open_connection",
|
72
|
-
:name => "Log into My Application",
|
73
|
-
:width => 600,
|
74
|
-
:height => 400 }
|
75
|
-
|
76
|
-
= form.check_box :remember_me
|
77
|
-
= form.label :remember_me, "Keep me logged in"
|
78
|
-
= link_to "Log In", "javascript:void(0)", :data => { :action => "submit" }
|
79
|
-
|
80
|
-
Login CoffeeScript View Class (app/assets/javascripts/application/view/login.js.coffee):
|
81
|
-
|
82
|
-
class MyApplicationName.Views.Login extends Middleware.System.Base
|
83
|
-
|
84
|
-
constructor: (@container) ->
|
85
|
-
super(@container)
|
86
|
-
@initForm()
|
87
|
-
|
88
|
-
initForm: =>
|
89
|
-
@form = @container.find("form")
|
90
|
-
|
91
|
-
MyApplicationName.Views.Login.initOpenConnection(@form.find("a[data-action=open_connection]"))
|
92
|
-
|
93
|
-
@form.on "ajax:success", @createResponse
|
94
|
-
@form.on "request:completed", @completeForm
|
95
|
-
@form.on "request:failed", @updateForm
|
96
|
-
|
97
|
-
@submitButton = @form.find("a[data-action=submit]")
|
98
|
-
@submitButton.on "click", =>
|
99
|
-
@form.trigger("submit.rails")
|
100
|
-
|
101
|
-
createResponse: (event, json) =>
|
102
|
-
if json["completed"] == true
|
103
|
-
@form.trigger("request:completed", json)
|
104
|
-
else
|
105
|
-
@form.trigger("request:failed", json)
|
106
|
-
|
107
|
-
completeForm: (event, json) =>
|
108
|
-
window.location.replace(json["url"])
|
109
|
-
|
110
|
-
updateForm: (event, json) =>
|
111
|
-
@container.replaceWith(json["template"])
|
112
|
-
MyApplicationName.Views.Login.bindMany("*[data-block=login_form]")
|
113
|
-
|
114
|
-
@initOpenConnection: (button) ->
|
115
|
-
button.on "click", (e) ->
|
116
|
-
left = (screen.width/2)-(button.data("width")/2)
|
117
|
-
top = (screen.height/2)-(button.data("height")/2)
|
118
|
-
window.open(button.data("url"),
|
119
|
-
button.data("name"),
|
120
|
-
"menubar=no,toolbar=no,status=no,width=#{button.data('width')},height=#{button.data('height')},toolbar=no,left=#{left},top=#{top}"
|
121
|
-
).focus()
|
122
|
-
|
123
|
-
e.stopPropagation()
|
124
|
-
return false
|
125
|
-
|
126
|
-
jQuery ->
|
127
|
-
MyApplicationName.Views.Login.bindMany("*[data-block=login_form]")
|
128
|
-
|
129
|
-
### Modal Example:
|
130
|
-
|
131
|
-
HTML Header:
|
132
|
-
|
133
|
-
%header{ :data => { :block => "header" } }
|
134
|
-
.buttons
|
135
|
-
- if logged_in?
|
136
|
-
= link_to "Edit account", edit_user_path(current_user), :data => { :remote => true, :action => "edit_user" }
|
137
|
-
|
138
|
-
Header CoffeeScript View Class (app/assets/javascripts/application/views/header.js.coffee):
|
139
|
-
|
140
|
-
class MyApplicationName.Views.Header extends Middleware.System.Base
|
141
|
-
|
142
|
-
constructor: (@container) ->
|
143
|
-
super(@container)
|
144
|
-
@initElements()
|
145
|
-
|
146
|
-
initElements: =>
|
147
|
-
@editUserButton = @container.find("a[data-action='edit_user']")
|
148
|
-
@editUserButton.on "ajax:success", @createEditUserContainer
|
149
|
-
|
150
|
-
createEditUserContainer: (event, json) =>
|
151
|
-
@editUserContainer = Middleware.Component.Modal.create("edit_user")
|
152
|
-
@editUserContainer.fill("hello")
|
153
|
-
|
154
|
-
jQuery ->
|
155
|
-
MyApplicationname.Views.Header.bindMany("*[data-block='header']")
|
156
|
-
|
157
26
|
|
158
27
|
## Contributing
|
159
28
|
|
data/lib/rocky/version.rb
CHANGED