window_rails 0.2.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +25 -18
- data/LICENSE +1 -2
- data/README.md +69 -0
- data/app/assets/javascripts/window_rails.js +1 -0
- data/app/assets/javascripts/window_rails/base.js +458 -0
- data/app/assets/stylesheets/window_rails.css +3 -0
- data/app/assets/stylesheets/window_rails/csspinner.css +472 -0
- data/lib/window_rails.rb +8 -9
- data/lib/window_rails/engine.rb +4 -8
- data/lib/window_rails/generators.rb +118 -0
- data/lib/window_rails/holder.rb +40 -0
- data/lib/window_rails/version.rb +2 -6
- data/lib/window_rails/windows.rb +28 -0
- metadata +35 -30
- data/README.rdoc +0 -111
- data/app/controllers/window_rails_controller.rb +0 -50
- data/config/routes.rb +0 -9
- data/lib/window_rails/window_rails_generators.rb +0 -451
- data/lib/window_rails/window_rails_view.rb +0 -46
- data/lib/window_rails/window_rails_windows.rb +0 -47
- data/rails/init.rb +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b40da2d75bc405b6b1bb2217538d8043207f9542
|
4
|
+
data.tar.gz: ec24e04aad5bf6c8a17d7817cf47784ed7f7a077
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d409b75763fdc7f3f8ac4c945da12dfbc64b2e46777da12166ab3a4245acd10d9403d65b99eec8737a0039df224cb0f7106be68631c634de432cc4dbf5ffc5f
|
7
|
+
data.tar.gz: e969a15ccf052870294a02dee57a8b43000d069d168e153dfbb2304cf807e9932c1283cb0aa67d74c635bb0c7efc5e2b7a13065b8651f84acc58fc0177f67564
|
@@ -1,64 +1,71 @@
|
|
1
|
-
|
1
|
+
## v1.0.0
|
2
|
+
* Migrate to bootstrap based modals
|
3
|
+
* Complete API refactor
|
4
|
+
|
5
|
+
## v0.2.12
|
6
|
+
* Fixes for proper loading in Rails 3.2
|
7
|
+
|
8
|
+
## v0.2.11
|
2
9
|
* Provides windowing methods to ActionView::Base for JS templates
|
3
10
|
* Removes deprecated rake tasks
|
4
11
|
|
5
|
-
|
12
|
+
## v0.2.10
|
6
13
|
* Fixes close window bug
|
7
14
|
|
8
|
-
|
15
|
+
## v0.2.9
|
9
16
|
* Let #window return raw string when passed :raw argument
|
10
17
|
* Check for window before attempting to close a window
|
11
18
|
|
12
|
-
|
19
|
+
## v0.2.8
|
13
20
|
* Request content as HTML when loading window
|
14
21
|
|
15
|
-
|
22
|
+
## v0.2.7
|
16
23
|
* Remove content holder element after window has been closed to prevent orphaned content
|
17
24
|
|
18
|
-
|
25
|
+
## v0.2.6
|
19
26
|
* Fixes for #link_to_window
|
20
27
|
|
21
|
-
|
28
|
+
## v0.2.5
|
22
29
|
* Better height/width determination for resize methods
|
23
30
|
|
24
|
-
|
31
|
+
## v0.2.4
|
25
32
|
* Add #resize_to_fit, #auto_resize and #center_window methods
|
26
33
|
|
27
|
-
|
34
|
+
## v0.2.3
|
28
35
|
* Add config directory to gemspec
|
29
36
|
* Provide Rails 3 compatible routing
|
30
37
|
|
31
|
-
|
38
|
+
## v0.2.2
|
32
39
|
* Fix bug in #close_window
|
33
40
|
|
34
|
-
|
41
|
+
## v0.2.1
|
35
42
|
* Enable #observe_dynamically_loaded_field for compatibility (outputs prototype)
|
36
43
|
|
37
|
-
|
44
|
+
## v0.2.0
|
38
45
|
* Rebuild off jquery-ui dialogs
|
39
46
|
|
40
|
-
|
47
|
+
## v0.1.4
|
41
48
|
* Fix to #update_window method to accept content not key
|
42
49
|
|
43
|
-
|
50
|
+
## v0.1.3
|
44
51
|
* Rails init inclusion within gem package
|
45
52
|
|
46
|
-
|
53
|
+
## v0.1.2
|
47
54
|
* Add rake task for install
|
48
55
|
* Pull window content from reference to prevent writing content multiple times
|
49
56
|
|
50
|
-
|
57
|
+
## v0.1.1
|
51
58
|
* Proper rails loading when included via gem
|
52
59
|
* Fix for window jumping when constraints applied
|
53
60
|
* Fix for #observe_dynamically_loaded_field when using a function instead of callback
|
54
61
|
* Make IFrame usage optional
|
55
62
|
|
56
|
-
|
63
|
+
## v0.1.0
|
57
64
|
* Lots of cleanup
|
58
65
|
* Better builders available
|
59
66
|
* #observe_dynamically_loaded_field to watch things that have been inserted into the DOM
|
60
67
|
* Better window handling
|
61
68
|
* Default class set to alphacube
|
62
69
|
|
63
|
-
|
70
|
+
## v0.0.1
|
64
71
|
* Initial release
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Current WindowRails License:
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2014 Chris Roberts <chrisroberts.code@gmail.com>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
@@ -19,4 +19,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
19
19
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
20
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# WindowRails
|
2
|
+
|
3
|
+
Rails helper for easy to use modals via bootstrap.
|
4
|
+
|
5
|
+
## Important note
|
6
|
+
|
7
|
+
As of the 1.0 release, window_rails has been re-implemented
|
8
|
+
using bootstrap as the core.
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
* jQuery
|
13
|
+
* Bootstrap
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add window_rails to your application Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'window_rails'
|
21
|
+
```
|
22
|
+
|
23
|
+
and then update your application manifests:
|
24
|
+
|
25
|
+
```
|
26
|
+
// app/assets/javascripts/application.js
|
27
|
+
//= require window_rails
|
28
|
+
```
|
29
|
+
|
30
|
+
```
|
31
|
+
/*
|
32
|
+
* app/assets/stylesheets/application.css
|
33
|
+
*= require window_rails
|
34
|
+
*/
|
35
|
+
```
|
36
|
+
|
37
|
+
## Basic usage
|
38
|
+
|
39
|
+
### Show an alert
|
40
|
+
|
41
|
+
```erb
|
42
|
+
<%= open_alert_window('This is an alert!') %>
|
43
|
+
```
|
44
|
+
|
45
|
+
### Close alert
|
46
|
+
|
47
|
+
```erb
|
48
|
+
<%= close_alert_window %>
|
49
|
+
```
|
50
|
+
|
51
|
+
### Create a new window
|
52
|
+
|
53
|
+
```erb
|
54
|
+
<%= create_window(:name => 'my-window', :title => 'My Window!', :content => 'Some Content') %>
|
55
|
+
```
|
56
|
+
|
57
|
+
### Close window
|
58
|
+
|
59
|
+
```erb
|
60
|
+
<%= close_window('my-window') %>
|
61
|
+
```
|
62
|
+
|
63
|
+
## Infos
|
64
|
+
|
65
|
+
* Repository: https://github.com/chrisroberts/window_rails
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
* WindowRails is released under an MIT license
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree ./window_rails
|
@@ -0,0 +1,458 @@
|
|
1
|
+
var window_rails = {alert: {}, info: {}, confirm: {action: {}}, loading: {}, configuration: {}, hooks: {}};
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Access configuration
|
5
|
+
*
|
6
|
+
* @param key [String] configuration name
|
7
|
+
* @param default_value [Object] default value if no value found
|
8
|
+
* @return [Object]
|
9
|
+
**/
|
10
|
+
window_rails.config = function(key, default_value){
|
11
|
+
if(window_rails.configuration[key] == undefined){
|
12
|
+
return default_value;
|
13
|
+
} else {
|
14
|
+
return window_rails.configuration[key];
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Generate internal name
|
20
|
+
*
|
21
|
+
* @param name [String]
|
22
|
+
* @return [String] internal name
|
23
|
+
**/
|
24
|
+
window_rails.namer = function(name){
|
25
|
+
return 'window-rails-' + name;
|
26
|
+
}
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Generate DOM ID for name
|
30
|
+
*
|
31
|
+
* @param name [String]
|
32
|
+
* @return [String] DOM ID
|
33
|
+
**/
|
34
|
+
window_rails.dom_ider = function(name){
|
35
|
+
return '#' + window_rails.namer(name);
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Provide window DOM element for name
|
40
|
+
*
|
41
|
+
* @param name [String]
|
42
|
+
* @return [jQuery Element]
|
43
|
+
**/
|
44
|
+
window_rails.window_for = function(name){
|
45
|
+
return $(window_rails.dom_ider(name));
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Create a new window
|
50
|
+
*
|
51
|
+
* @param args [Hash]
|
52
|
+
* @option args [String] :name window name
|
53
|
+
* @option args [String] :title
|
54
|
+
* @option args [String] :content
|
55
|
+
* @option args [String] :size size of window (large or small)
|
56
|
+
**/
|
57
|
+
window_rails.create_window = function(args){
|
58
|
+
if(window_rails.window_for(args.name).length == 0){
|
59
|
+
window_rails.initialize_window(args);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Open a window
|
65
|
+
*
|
66
|
+
* @param name [String] window name
|
67
|
+
* @param args [Hash]
|
68
|
+
* @option args [String] :title
|
69
|
+
* @option args [String] :content
|
70
|
+
* @option args [true,false] :esc_close allow escape key window close
|
71
|
+
* @option args [true,false] :show show by default
|
72
|
+
* @option args [true,false] :backdrop show backdrop
|
73
|
+
* @option args [true,false] :static_backdrop do not allow backdrop click close
|
74
|
+
**/
|
75
|
+
window_rails.open_window = function(name, args){
|
76
|
+
if(args){
|
77
|
+
if(args.title){
|
78
|
+
$(window_rails.dom_ider(name) + ' .modal-title').html(args.title);
|
79
|
+
}
|
80
|
+
if(args.content){
|
81
|
+
$(window_rails.dom_ider(name) + ' .modal-body').html(args.content);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
backdrop = args.backdrop == undefined ? true : args.backdrop;
|
86
|
+
if(backdrop && args.static_backdrop){
|
87
|
+
backdrop = 'static';
|
88
|
+
}
|
89
|
+
|
90
|
+
window_rails.window_for(name).modal({
|
91
|
+
keyboard: args.esc_close == undefined ? window_rails.config('default_esc_close', true) : args.esc_close,
|
92
|
+
show: args.show == undefined ? window_rails.config('default_open_show', true) : args.show,
|
93
|
+
backdrop: backdrop
|
94
|
+
});
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Close window
|
99
|
+
*
|
100
|
+
* @param name [String] window name
|
101
|
+
**/
|
102
|
+
window_rails.close_window = function(name){
|
103
|
+
window_rails.window_for(name).modal('hide');
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Open alert window
|
108
|
+
*
|
109
|
+
* @param args [Hash]
|
110
|
+
* @option args [String] :title
|
111
|
+
* @option args [String] :content
|
112
|
+
**/
|
113
|
+
window_rails.alert.open = function(args){
|
114
|
+
args.static_backdrop = true;
|
115
|
+
window_rails.open_window('alert', args);
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Close alert window
|
120
|
+
**/
|
121
|
+
window_rails.alert.close = function(){
|
122
|
+
window_rails.close_window('alert');
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Open info window
|
127
|
+
*
|
128
|
+
* @param args [Hash]
|
129
|
+
* @option args [String] :title
|
130
|
+
* @option args [String] :content
|
131
|
+
* @option args [Integer] :auto_close close info after given seconds
|
132
|
+
**/
|
133
|
+
window_rails.info.open = function(args){
|
134
|
+
window_rails.open_window('info', args);
|
135
|
+
if(args.auto_close){
|
136
|
+
setTimeout(
|
137
|
+
function(){ window_rails.info.close(); },
|
138
|
+
args.auto_close * 1000
|
139
|
+
)
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Close info window
|
145
|
+
**/
|
146
|
+
window_rails.info.close = function(){
|
147
|
+
window_rails.close_window('info');
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Open confirm window
|
152
|
+
*
|
153
|
+
* @param args [Hash]
|
154
|
+
* @option args [String] :title content for title
|
155
|
+
* @option args [String] :content content for content
|
156
|
+
* @option args [String] :url URL to load on acceptance
|
157
|
+
* @option args [String] :ajax AJAX method to use (get, post, etc)
|
158
|
+
* @option args [String] :progress title for loading window while in progres
|
159
|
+
* @option args [String] :complete content for info window upon completion
|
160
|
+
**/
|
161
|
+
window_rails.confirm.open = function(args){
|
162
|
+
window_rails.confirm.action = args;
|
163
|
+
args.static_backdrop = true;
|
164
|
+
window_rails.open_window('confirm', args);
|
165
|
+
}
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Close confirm window
|
169
|
+
**/
|
170
|
+
window_rails.confirm.close = function(){
|
171
|
+
window_rails.close_window('confirm');
|
172
|
+
}
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Execute defined action for confirmation
|
176
|
+
**/
|
177
|
+
window_rails.confirm.execute = function(){
|
178
|
+
args = window_rails.confirm.action;
|
179
|
+
window_rails.confirm.close();
|
180
|
+
window_rails.confirm.action = {};
|
181
|
+
window_rails.loading.open({
|
182
|
+
title: args.progress
|
183
|
+
});
|
184
|
+
if(args.ajax){
|
185
|
+
$.ajax({
|
186
|
+
url: args.url,
|
187
|
+
type: args.ajax.toUpperCase()
|
188
|
+
}).error(function(data, status){
|
189
|
+
window_rails.loading.close();
|
190
|
+
if(args.error){
|
191
|
+
msg = args.error;
|
192
|
+
} else {
|
193
|
+
msg = data.responseText;
|
194
|
+
}
|
195
|
+
window_rails.alert.open({
|
196
|
+
title: args.title,
|
197
|
+
content: msg
|
198
|
+
});
|
199
|
+
}).success(function(data){
|
200
|
+
window_rails.loading.close();
|
201
|
+
window_rails.info.open({
|
202
|
+
title: args.title,
|
203
|
+
content: args.complete || 'Action complete',
|
204
|
+
auto_close: window_rails.config('confirm_info_auto_close', 5)
|
205
|
+
});
|
206
|
+
});
|
207
|
+
} else {
|
208
|
+
document.location = args.url;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Open loading window
|
214
|
+
*
|
215
|
+
* @param style [String] style of spinner (valid class in csspinner or progress)
|
216
|
+
* @param title [String] title of window
|
217
|
+
**/
|
218
|
+
window_rails.loading.open = function(style, title){
|
219
|
+
if(style){
|
220
|
+
if(typeof style === 'object'){
|
221
|
+
title = style.title;
|
222
|
+
style = style.style;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
if(!style){
|
226
|
+
style = 'standard';
|
227
|
+
}
|
228
|
+
if(!title){
|
229
|
+
title = 'Loading...';
|
230
|
+
}
|
231
|
+
if(style == 'progress'){
|
232
|
+
content = '<div class="progress progress-striped active look-busy"><div class="progress-bar progress-bar-info" aria-valuemax="100" aria-valuemin="0" aria-valuenow="5" role="progressbar" style="width: 5%"></div></div>';
|
233
|
+
} else {
|
234
|
+
content = '<div style="height: 50px" class="' + style + ' csspinner no-overlay standard" />';
|
235
|
+
}
|
236
|
+
window_rails.open_window('loading', {
|
237
|
+
esc_close: false,
|
238
|
+
title: title,
|
239
|
+
static_backdrop: true,
|
240
|
+
content: content
|
241
|
+
});
|
242
|
+
if(style == 'progress'){
|
243
|
+
window_rails.loading.progress_look_busy();
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Start progress bar busy action on loading display
|
249
|
+
**/
|
250
|
+
window_rails.loading.progress_look_busy = function(){
|
251
|
+
$('body').data(
|
252
|
+
'window-rails-loading-progress',
|
253
|
+
window_rails.config('loading_progress_increments', 3)
|
254
|
+
);
|
255
|
+
window_rails.loading.run_look_busy();
|
256
|
+
}
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Perform busy action
|
260
|
+
* @note this should generally not be called directly
|
261
|
+
* @see window_rails.loading.progress_look_busy
|
262
|
+
**/
|
263
|
+
window_rails.loading.run_look_busy = function(){
|
264
|
+
setTimeout(function(){
|
265
|
+
allowed_max = window_rails.config('loading_progress_max', 90);
|
266
|
+
elm = $('#window-rails-loading .progress-bar-info');
|
267
|
+
if(elm.length > 0){
|
268
|
+
completed = Number(elm.attr('aria-valuenow'));
|
269
|
+
busy_by = $('body').data('window-rails-loading-progress');
|
270
|
+
addition = (100 - completed) / busy_by;
|
271
|
+
if(busy_by < 9){
|
272
|
+
$('body').data('window-rails-loading-progress', busy_by / 0.75);
|
273
|
+
}
|
274
|
+
completed_now = completed + addition;
|
275
|
+
if(completed_now > allowed_max){
|
276
|
+
completed_now = allowed_max;
|
277
|
+
}
|
278
|
+
elm.attr('aria-valuenow', completed_now);
|
279
|
+
elm.attr('style', 'width: ' + completed_now + '%');
|
280
|
+
window_rails.loading.run_look_busy();
|
281
|
+
}
|
282
|
+
}, 2500);
|
283
|
+
}
|
284
|
+
|
285
|
+
/**
|
286
|
+
* Close loading window
|
287
|
+
**/
|
288
|
+
window_rails.loading.close = function(){
|
289
|
+
window_rails.close_window('loading');
|
290
|
+
}
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Initialize a new window. Creates DOM elements required for modal.
|
294
|
+
*
|
295
|
+
* @param args [Hash]
|
296
|
+
* @option args [String] :name window name
|
297
|
+
* @option args [String] :size large or small
|
298
|
+
* @option args [String] :title
|
299
|
+
* @option args [String] :content
|
300
|
+
* @option args [String] :footer
|
301
|
+
**/
|
302
|
+
window_rails.initialize_window = function(args){
|
303
|
+
if(!args.name){
|
304
|
+
throw new Error('Name must be set when initializing a new window!');
|
305
|
+
}
|
306
|
+
name = window_rails.namer(args.name);
|
307
|
+
if(args.size == 'large'){
|
308
|
+
size = 'lg';
|
309
|
+
} else {
|
310
|
+
size = window_rails.config('default_size', 'sm');
|
311
|
+
}
|
312
|
+
if(args.footer){
|
313
|
+
footer = '\
|
314
|
+
<div class="modal-footer">\
|
315
|
+
' + args.footer + '\
|
316
|
+
</div>\
|
317
|
+
';
|
318
|
+
} else {
|
319
|
+
footer = '';
|
320
|
+
}
|
321
|
+
$('#window-rails-container').append('\
|
322
|
+
<div id="' + name + '" class="modal fade" role="modal" aria-labelledby="' + name + '" aria-hidden="true">\
|
323
|
+
<div class="modal-dialog modal-' + size + '">\
|
324
|
+
<div class="modal-content">\
|
325
|
+
<div class="modal-header">\
|
326
|
+
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">\
|
327
|
+
×\
|
328
|
+
</button>\
|
329
|
+
<h4 class="modal-title">' + args.title + '</h4>\
|
330
|
+
</div>\
|
331
|
+
<div class="modal-body">\
|
332
|
+
' + args.content + '\
|
333
|
+
</div>\
|
334
|
+
</div>\
|
335
|
+
</div>\
|
336
|
+
</div>\
|
337
|
+
');
|
338
|
+
}
|
339
|
+
|
340
|
+
/**
|
341
|
+
* Initialize the document for window rails
|
342
|
+
**/
|
343
|
+
window_rails.init = function(){
|
344
|
+
if(!window_rails.initialized){
|
345
|
+
$('body').append('\
|
346
|
+
<div id="window-rails-container">\
|
347
|
+
<div id="window-rails-alert" class="modal fade" role="modal" aria-labelledby="window-rails-alert" aria-hidden="true">\
|
348
|
+
<div class="modal-dialog modal-sm">\
|
349
|
+
<div class="modal-content">\
|
350
|
+
<div class="modal-header bg-danger">\
|
351
|
+
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">\
|
352
|
+
×\
|
353
|
+
</button>\
|
354
|
+
<h4 class="modal-title">Alert</h4>\
|
355
|
+
</div>\
|
356
|
+
<div class="modal-body">\
|
357
|
+
Alert message\
|
358
|
+
</div>\
|
359
|
+
</div>\
|
360
|
+
</div>\
|
361
|
+
</div>\
|
362
|
+
<div id="window-rails-info" class="modal fade" role="modal" aria-labelledby="window-rails-info" aria-hidden="true">\
|
363
|
+
<div class="modal-dialog modal-sm">\
|
364
|
+
<div class="modal-content">\
|
365
|
+
<div class="modal-header bg-info">\
|
366
|
+
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">\
|
367
|
+
×\
|
368
|
+
</button>\
|
369
|
+
<h4 class="modal-title">Info</h4>\
|
370
|
+
</div>\
|
371
|
+
<div class="modal-body">\
|
372
|
+
Information message\
|
373
|
+
</div>\
|
374
|
+
</div>\
|
375
|
+
</div>\
|
376
|
+
</div>\
|
377
|
+
<div id="window-rails-confirm" class="modal fade" role="modal" aria-labelledby="window-rails-confirm" aria-hidden="true">\
|
378
|
+
<div class="modal-dialog modal-sm">\
|
379
|
+
<div class="modal-content">\
|
380
|
+
<div class="modal-header bg-warning">\
|
381
|
+
<h4 class="modal-title">Confirm</h4>\
|
382
|
+
</div>\
|
383
|
+
<div class="modal-body">\
|
384
|
+
Please confirm!\
|
385
|
+
</div>\
|
386
|
+
<div class="modal-footer">\
|
387
|
+
<button type="button" class="btn btn-danger window-rails-confirm-cancel">Cancel</button>\
|
388
|
+
<button type="button" class="btn btn-success window-rails-confirm-ok">OK</button>\
|
389
|
+
</div>\
|
390
|
+
</div>\
|
391
|
+
</div>\
|
392
|
+
</div>\
|
393
|
+
</div>\
|
394
|
+
<div id="window-rails-loading" class="modal fade" role="modal" aria-labelledby="window-rails-loading" aria-hidden="true">\
|
395
|
+
<div class="modal-dialog modal-sm">\
|
396
|
+
<div class="modal-content">\
|
397
|
+
<div class="modal-header">\
|
398
|
+
<b class="modal-title">Loading...</b>\
|
399
|
+
</div>\
|
400
|
+
<div class="modal-body">\
|
401
|
+
<div style="height: 50px" class="csspinner no-overlay standard" />\
|
402
|
+
</div>\
|
403
|
+
</div>\
|
404
|
+
</div>\
|
405
|
+
</div>\
|
406
|
+
</div>\
|
407
|
+
');
|
408
|
+
window_rails.hooks.init();
|
409
|
+
window_rails.initialized = true
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
/**
|
414
|
+
* Hook for displaying the confirmation window
|
415
|
+
**/
|
416
|
+
window_rails.hooks.open_window = function(){
|
417
|
+
window_rails.confirm.open({
|
418
|
+
title: $(this).attr('window-rails-title'),
|
419
|
+
content: $(this).attr('window-rails-confirm'),
|
420
|
+
ajax: $(this).attr('window-rails-ajax'),
|
421
|
+
url: $(this).attr('window-rails-url'),
|
422
|
+
progress: $(this).attr('window-rails-progress'),
|
423
|
+
complete: $(this).attr('window-rails-complete'),
|
424
|
+
error: $(this).attr('window-rails-error')
|
425
|
+
});
|
426
|
+
}
|
427
|
+
|
428
|
+
/**
|
429
|
+
* Hook for closing confirm window
|
430
|
+
**/
|
431
|
+
window_rails.hooks.close_confirm = function(){
|
432
|
+
window_rails.confirm.action = {};
|
433
|
+
window_rails.confirm.close();
|
434
|
+
}
|
435
|
+
|
436
|
+
/**
|
437
|
+
* Hook into interesting events
|
438
|
+
**/
|
439
|
+
window_rails.hooks.init = function(){
|
440
|
+
window_rails.hooks.init_links();
|
441
|
+
$('.window-rails-confirm-cancel').on('click', window_rails.hooks.close_confirm)
|
442
|
+
$('.window-rails-confirm-ok').on('click', window_rails.confirm.execute);
|
443
|
+
}
|
444
|
+
|
445
|
+
/**
|
446
|
+
* Hook links to handle window rails
|
447
|
+
*
|
448
|
+
* @param dom_filter [String]
|
449
|
+
**/
|
450
|
+
window_rails.hooks.init_links = function(dom_filter){
|
451
|
+
if(!dom_filter){
|
452
|
+
dom_filter = '';
|
453
|
+
}
|
454
|
+
$(dom_filter + ' .window-rails').on('click', window_rails.hooks.open_window);
|
455
|
+
}
|
456
|
+
|
457
|
+
// Initialize once page has loaded
|
458
|
+
$(document).ready(window_rails.init);
|