thin_man 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/thin_man.js +445 -465
- data/lib/thin_man/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d3ad1b7b7d906597566cf1b1d8f2bc529f82be
|
4
|
+
data.tar.gz: 81c67a1a5e66e4a4403d68bc4ec27adaacd6dfc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b99ae5b6516c58f94e85077e1534a0d4b2db6dbbee324610adb647c6cc841b3658f4226bc741438050b1b224dddcd4ec5fb9b432cb223cf52872c512aa6b294d
|
7
|
+
data.tar.gz: 52ed6c0bf877bc1773fd8e8937369de0bb7adea7381824247af62bf69977cf277720cdf5bc26ca24eebc09ee02a5218e07fc6b9652b17d613690c0706a2675db
|
@@ -1,499 +1,479 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return this_class;
|
9
|
-
};
|
10
|
-
|
11
|
-
// This is a utility to convert a javascript object to a query string and append it to a url.
|
12
|
-
function toUrlParams(params){
|
13
|
-
var params_array = [];
|
14
|
-
$.each(params, function(key,value){
|
15
|
-
params_array.push([key,value].join('='));
|
16
|
-
});
|
17
|
-
return params_array.join('&');
|
18
|
-
};
|
19
|
-
|
20
|
-
function addUrlParams(url,params){
|
21
|
-
if(url.match(/\?/)){
|
22
|
-
url = url + '&' + toUrlParams(params);
|
23
|
-
} else {
|
24
|
-
url = url + '?' + toUrlParams(params);
|
25
|
-
}
|
26
|
-
return url;
|
27
|
-
};
|
28
|
-
|
29
|
-
var AjaxSubmission = Class.extend({
|
30
|
-
init: function(jq_obj,params){
|
31
|
-
this.jq_obj = jq_obj;
|
32
|
-
this.params = params;
|
33
|
-
if(!this.params){ this.params = {}}
|
34
|
-
this.getTrigger();
|
35
|
-
this.getTarget();
|
36
|
-
this.getErrorTarget();
|
37
|
-
this.insert_method = this.getInsertMethod();
|
38
|
-
var ajax_submission = this;
|
39
|
-
this.ajax_options = {
|
40
|
-
url: ajax_submission.getAjaxUrl(),
|
41
|
-
type: ajax_submission.getAjaxType(),
|
42
|
-
datatype: ajax_submission.getAjaxDataType(),
|
43
|
-
data: ajax_submission.getData(),
|
44
|
-
beforeSend: function(jqXHr) { return ajax_submission.ajaxBefore(jqXHr) },
|
45
|
-
success: function(data,textStatus,jqXHR) { ajax_submission.ajaxSuccess(data,textStatus,jqXHR) },
|
46
|
-
error: function(jqXHr) { ajax_submission.ajaxError(jqXHr) },
|
47
|
-
complete: function(jqXHr) { ajax_submission.ajaxComplete(jqXHr) }
|
48
|
-
};
|
49
|
-
$.ajax(ajax_submission.ajax_options);
|
50
|
-
},
|
51
|
-
getTarget: function(){
|
52
|
-
var target_selector = this.jq_obj.data('ajax-target');
|
53
|
-
if(target_selector){
|
54
|
-
this.target = $(target_selector);
|
55
|
-
}
|
56
|
-
},
|
57
|
-
getErrorTarget: function(){
|
58
|
-
if($(this.jq_obj.data('error-target')).length > 0){
|
59
|
-
this.error_target = $(this.jq_obj.data('error-target'));
|
60
|
-
}else{
|
61
|
-
this.error_target = $(this.jq_obj.data('ajax-target'));
|
62
|
-
}
|
63
|
-
},
|
64
|
-
getAjaxDataType: function(){
|
65
|
-
return this.jq_obj.data('return-type') || 'html';
|
66
|
-
},
|
67
|
-
getInsertMethod: function(){
|
68
|
-
return this.jq_obj.data('insert-method') || 'html';
|
69
|
-
},
|
70
|
-
getData: function() {
|
71
|
-
return null;
|
72
|
-
},
|
73
|
-
insertHtml: function(data) {
|
74
|
-
if(this.target){
|
75
|
-
this.target[this.insert_method](data);
|
76
|
-
this.target.find('input,select,textarea').filter(':visible:enabled:first').each(function(){
|
77
|
-
if(!$(this).data('date-picker')){
|
78
|
-
$(this).focus();
|
79
|
-
}
|
80
|
-
});
|
81
|
-
}
|
82
|
-
},
|
83
|
-
ajaxSuccess: function(data,textStatus,jqXHR){
|
84
|
-
if(typeof data === 'string'){
|
85
|
-
this.insertHtml(data);
|
86
|
-
} else if(typeof data === 'object') {
|
87
|
-
if(typeof data.html != 'undefined'){
|
88
|
-
this.insertHtml(data.html)
|
1
|
+
var initThinMan = function(){
|
2
|
+
thin_man = {
|
3
|
+
getSubClass: function(sub_class_name,parent_class){
|
4
|
+
if((typeof(sub_class_name) == 'string') && (sub_class_name != '') && (sub_class_name != 'true')){
|
5
|
+
var this_class = sub_class_name;
|
6
|
+
} else {
|
7
|
+
var this_class = parent_class;
|
89
8
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
9
|
+
return this_class;
|
10
|
+
},
|
11
|
+
AjaxSubmission: Class.extend({
|
12
|
+
init: function(jq_obj,params){
|
13
|
+
this.jq_obj = jq_obj;
|
14
|
+
this.params = params;
|
15
|
+
if(!this.params){ this.params = {}}
|
16
|
+
this.getTrigger();
|
17
|
+
this.getTarget();
|
18
|
+
this.getErrorTarget();
|
19
|
+
this.insert_method = this.getInsertMethod();
|
20
|
+
var ajax_submission = this;
|
21
|
+
this.ajax_options = {
|
22
|
+
url: ajax_submission.getAjaxUrl(),
|
23
|
+
type: ajax_submission.getAjaxType(),
|
24
|
+
datatype: ajax_submission.getAjaxDataType(),
|
25
|
+
data: ajax_submission.getData(),
|
26
|
+
beforeSend: function(jqXHr) { return ajax_submission.ajaxBefore(jqXHr) },
|
27
|
+
success: function(data,textStatus,jqXHR) { ajax_submission.ajaxSuccess(data,textStatus,jqXHR) },
|
28
|
+
error: function(jqXHr) { ajax_submission.ajaxError(jqXHr) },
|
29
|
+
complete: function(jqXHr) { ajax_submission.ajaxComplete(jqXHr) }
|
30
|
+
};
|
31
|
+
$.ajax(ajax_submission.ajax_options);
|
32
|
+
},
|
33
|
+
getTarget: function(){
|
34
|
+
var target_selector = this.jq_obj.data('ajax-target');
|
35
|
+
if(target_selector){
|
36
|
+
this.target = $(target_selector);
|
37
|
+
}
|
38
|
+
},
|
39
|
+
getErrorTarget: function(){
|
40
|
+
if($(this.jq_obj.data('error-target')).length > 0){
|
41
|
+
this.error_target = $(this.jq_obj.data('error-target'));
|
42
|
+
}else{
|
43
|
+
this.error_target = $(this.jq_obj.data('ajax-target'));
|
44
|
+
}
|
45
|
+
},
|
46
|
+
getAjaxDataType: function(){
|
47
|
+
return this.jq_obj.data('return-type') || 'html';
|
48
|
+
},
|
49
|
+
getInsertMethod: function(){
|
50
|
+
return this.jq_obj.data('insert-method') || 'html';
|
51
|
+
},
|
52
|
+
getData: function() {
|
53
|
+
return null;
|
54
|
+
},
|
55
|
+
insertHtml: function(data) {
|
56
|
+
if(this.target){
|
57
|
+
this.target[this.insert_method](data);
|
58
|
+
this.target.find('input,select,textarea').filter(':visible:enabled:first').each(function(){
|
59
|
+
if(!$(this).data('date-picker')){
|
60
|
+
$(this).focus();
|
61
|
+
}
|
62
|
+
});
|
63
|
+
}
|
64
|
+
},
|
65
|
+
ajaxSuccess: function(data,textStatus,jqXHR){
|
66
|
+
if(typeof data === 'string'){
|
67
|
+
this.insertHtml(data);
|
68
|
+
} else if(typeof data === 'object') {
|
69
|
+
if(typeof data.html != 'undefined'){
|
70
|
+
this.insertHtml(data.html)
|
98
71
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
72
|
+
if(typeof data.class_triggers != 'undefined'){
|
73
|
+
$.each(data.class_triggers, function(class_name, params){
|
74
|
+
try{
|
75
|
+
klass = eval(class_name);
|
76
|
+
new klass(params);
|
77
|
+
} catch(err) {
|
78
|
+
console.log("Error trying to instantiate class " + class_name + " from ajax response:")
|
79
|
+
console.log(err)
|
80
|
+
}
|
81
|
+
})
|
109
82
|
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
83
|
+
if(typeof data.function_calls != 'undefined'){
|
84
|
+
$.each(data.function_calls, function(func_name, params){
|
85
|
+
try{
|
86
|
+
func = eval(func_name);
|
87
|
+
func(params);
|
88
|
+
} catch(err) {
|
89
|
+
console.log("Error trying to instantiate function " + func_name + " from ajax response:")
|
90
|
+
console.log(err)
|
91
|
+
}
|
92
|
+
})
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if(this.target){
|
96
|
+
var ajax_flash = this.target.children().last().data('ajax-flash');
|
97
|
+
if((jqXHR.status == 200) && ajax_flash){
|
98
|
+
new thin_man.AjaxFlash('success', ajax_flash.notice,this.target);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
if ((jqXHR.status == 200) && !(typeof step === 'undefined')) {
|
102
|
+
$(form_map[step]).ScrollTo();
|
103
|
+
}
|
104
|
+
if(this.removeOnSuccess()){
|
105
|
+
if($(this.removeOnSuccess())){
|
106
|
+
$(this.removeOnSuccess()).remove();
|
107
|
+
}
|
108
|
+
}
|
109
|
+
if(this.emptyOnSuccess()){
|
110
|
+
if($(this.emptyOnSuccess())){
|
111
|
+
$(this.emptyOnSuccess()).empty();
|
112
|
+
}
|
113
|
+
}
|
114
|
+
},
|
115
|
+
ajaxComplete: function(jqXHR) {
|
116
|
+
this.showTrigger();
|
117
|
+
if(this.progress_indicator){
|
118
|
+
this.progress_indicator.stop();
|
119
|
+
}
|
120
|
+
try{
|
121
|
+
response_data = JSON.parse(jqXHR.responseText)
|
122
|
+
} catch(err) {
|
123
|
+
response_data = {}
|
124
|
+
// hmmm, the response is not JSON, so there's no flash.
|
125
|
+
}
|
126
|
+
if(typeof response_data.flash_message != 'undefined'){
|
127
|
+
var flash_style = this.httpResponseToFlashStyle(jqXHR.status);
|
128
|
+
var flash_duration = null;
|
129
|
+
if(typeof response_data.flash_persist != 'undefined'){
|
130
|
+
if(response_data.flash_persist){
|
131
|
+
flash_duration = 'persist'
|
132
|
+
} else {
|
133
|
+
flash_duration = 'fade'
|
134
|
+
}
|
135
|
+
}
|
136
|
+
if(this.target){
|
137
|
+
new thin_man.AjaxFlash(flash_style, response_data.flash_message,this.target, flash_duration);
|
138
|
+
}else{
|
139
|
+
new thin_man.AjaxFlash(flash_style, response_data.flash_message,this.jq_obj, flash_duration);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
if('function' == typeof this.params.on_complete){
|
143
|
+
this.params.on_complete()
|
144
|
+
}
|
145
|
+
},
|
146
|
+
ajaxBefore: function(jqXHr) {
|
147
|
+
this.toggleLoading();
|
148
|
+
this.progress_indicator = new thin_man.AjaxProgress(this.trigger);
|
149
|
+
},
|
150
|
+
ajaxError: function(jqXHR) {
|
151
|
+
if(jqXHR.status == 409){
|
152
|
+
this.error_target.html(jqXHR.responseText);
|
153
|
+
}else if(jqXHR.status == 500){
|
154
|
+
alert('There was an error communicating with the server.')
|
155
|
+
}
|
156
|
+
},
|
157
|
+
getTrigger: function(){},
|
158
|
+
hideTrigger: function(){},
|
159
|
+
showTrigger: function(){},
|
160
|
+
toggleLoading: function() {
|
161
|
+
if(this.target){
|
162
|
+
if (this.target.find('[data-loading-visible="false"]').length > 0) {
|
163
|
+
this.target.find('[data-loading-visible="false"]').addClass('hidden');
|
164
|
+
}
|
165
|
+
if (this.target.find('[data-loading-visible="true"]').length > 0) {
|
166
|
+
this.target.find('[data-loading-visible="true"]').removeClass('hidden');
|
167
|
+
}
|
168
|
+
}
|
169
|
+
},
|
170
|
+
removeOnSuccess: function(){
|
171
|
+
return this.jq_obj.data('remove-on-success')
|
172
|
+
},
|
173
|
+
emptyOnSuccess: function(){
|
174
|
+
return this.jq_obj.data('empty-on-success')
|
175
|
+
},
|
176
|
+
httpResponseToFlashStyle: function(response_code){
|
177
|
+
if([403,409,500].indexOf(response_code) > -1){
|
178
|
+
return 'error'
|
179
|
+
}
|
180
|
+
if([200,202].indexOf(response_code) > -1){
|
181
|
+
return 'success'
|
182
|
+
}
|
183
|
+
return 'error'
|
117
184
|
}
|
118
|
-
}
|
119
|
-
|
120
|
-
$
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
185
|
+
}),
|
186
|
+
AjaxBrowserPushConnector: Class.extend({
|
187
|
+
init: function($connector){
|
188
|
+
this.trigger = $connector.find('button, input[type="submit"]');
|
189
|
+
if(this.trigger.length < 1){
|
190
|
+
this.trigger = $connector;
|
191
|
+
}
|
192
|
+
this.browser_push_progress_indicator = new thin_man.AjaxProgress(this.trigger);
|
193
|
+
$connector.data('browser-push-progress-indicator-object', this.browser_push_progress_indicator);
|
125
194
|
}
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
|
195
|
+
}),
|
196
|
+
AjaxBrowserPushFlash: Class.extend({
|
197
|
+
init: function($flash){
|
198
|
+
this.message = $flash.data('ajax-browser-push-flash')
|
199
|
+
this.$target = $($flash.data('ajax-browser-push-flash-target'));
|
200
|
+
this.$target.data('ajax-browser-push-flash',this.message);
|
130
201
|
}
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
this.progress_indicator.stop();
|
137
|
-
}
|
138
|
-
try{
|
139
|
-
response_data = JSON.parse(jqXHR.responseText)
|
140
|
-
} catch(err) {
|
141
|
-
response_data = {}
|
142
|
-
// hmmm, the response is not JSON, so there's no flash.
|
143
|
-
}
|
144
|
-
if(typeof response_data.flash_message != 'undefined'){
|
145
|
-
var flash_style = this.httpResponseToFlashStyle(jqXHR.status);
|
146
|
-
var flash_duration = null;
|
147
|
-
if(typeof response_data.flash_persist != 'undefined'){
|
148
|
-
if(response_data.flash_persist){
|
149
|
-
flash_duration = 'persist'
|
202
|
+
}),
|
203
|
+
AjaxProgress: Class.extend({
|
204
|
+
init: function(target){
|
205
|
+
if(target.not(':visible')){
|
206
|
+
var targetOffset = target.parent().offset();
|
150
207
|
} else {
|
151
|
-
|
208
|
+
var targetOffset = target.offset();
|
209
|
+
}
|
210
|
+
if(targetOffset){
|
211
|
+
var targetLeft = targetOffset.left;
|
212
|
+
var targetTop = targetOffset.top;
|
213
|
+
this.progress_container = $('#ajax_progress_container').clone();
|
214
|
+
uuid = new UUID;
|
215
|
+
this.progress_container.prop('id', uuid.value);
|
216
|
+
$('body').append(this.progress_container);
|
217
|
+
this.progress_container.css({position:'absolute',left: targetLeft, top: targetTop});
|
218
|
+
this.progress_container.show();
|
219
|
+
}
|
220
|
+
},
|
221
|
+
stop: function(){
|
222
|
+
if(this.progress_container){
|
223
|
+
this.progress_container.remove();
|
224
|
+
// This is a hack to force finding the element. For some ridiculous reason in certain cases
|
225
|
+
// the progress_container is present, can be logged in console, yet cannot be removed.
|
226
|
+
// Finding it again by its unique id allows us to remove it. baffled me, but it works now in all known cases.
|
227
|
+
$actual_progress_container = $('#' + this.progress_container.attr('id'))
|
228
|
+
$actual_progress_container.remove();
|
152
229
|
}
|
153
230
|
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
231
|
+
}),
|
232
|
+
AjaxFlash: Class.extend({
|
233
|
+
init: function(type,message,elem,duration){
|
234
|
+
this.flash_container = $('#thin-man-flash-container').clone();
|
235
|
+
$('body').append(this.flash_container);
|
236
|
+
this.flash_container.css({position:'absolute',visibility: 'hidden'});
|
237
|
+
this.alert_type = type;
|
238
|
+
this.elem = elem;
|
239
|
+
var alert_class = 'alert-' + type;
|
240
|
+
this.flash_container.addClass(alert_class);
|
241
|
+
$('#thin-man-flash-content', this.flash_container).html(message);
|
242
|
+
this.flash_container.show();
|
243
|
+
this.setFadeBehavior(duration);
|
244
|
+
this.reposition(elem);
|
245
|
+
},
|
246
|
+
setFadeBehavior: function(duration){
|
247
|
+
if(duration){
|
248
|
+
if('persist' == duration){
|
249
|
+
this.fade = false
|
250
|
+
} else {
|
251
|
+
this.fade = true
|
252
|
+
}
|
253
|
+
}else{ //default behavior if persist duration is not sent back with message
|
254
|
+
if('error' == this.alert_type || 'warning' == this.alert_type || 'info' == this.alert_type){
|
255
|
+
this.fade = false;
|
256
|
+
} else {
|
257
|
+
this.fade = true;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
},
|
261
|
+
reposition: function(elem){
|
262
|
+
var this_window = {
|
263
|
+
top: $(window).scrollTop(),
|
264
|
+
left: $(window).scrollLeft(),
|
265
|
+
height: $(window).outerHeight(),
|
266
|
+
width: $(window).outerWidth()
|
267
|
+
};
|
268
|
+
var this_flash = {
|
269
|
+
height: this.flash_container.outerHeight(),
|
270
|
+
width: this.flash_container.outerWidth()
|
271
|
+
}
|
272
|
+
this_window.vert_middle = (this_window.top + (this_window.height / 2));
|
273
|
+
this_window.horiz_middle = (this_window.left + (this_window.width / 2));
|
274
|
+
this_flash.half_height = (this_flash.height / 2);
|
275
|
+
this_flash.half_width = (this_flash.width / 2);
|
276
|
+
var new_top = this_window.vert_middle - this_flash.half_height;
|
277
|
+
var new_left = this_window.horiz_middle - this_flash.half_width;
|
278
|
+
this.flash_container.css({left: new_left, top: new_top, visibility: 'visible'});
|
279
|
+
var ajax_flash = this;
|
280
|
+
if (this.fade) {
|
281
|
+
setTimeout(function(){ajax_flash.fadeOut()},1618);
|
282
|
+
}
|
283
|
+
},
|
284
|
+
fadeOut: function(){
|
285
|
+
this.flash_container.fadeOut('slow');
|
182
286
|
}
|
183
|
-
|
184
|
-
|
287
|
+
}),
|
288
|
+
AjaxSorter: Class.extend({
|
289
|
+
init: function(jq_obj){
|
290
|
+
var sort_container = jq_obj;
|
291
|
+
var base_url = sort_container.data('url');
|
292
|
+
sort_container.sortable({
|
293
|
+
helper: "clone",
|
294
|
+
tolerance: 'pointer',
|
295
|
+
stop: function( event, ui) {
|
296
|
+
new thin_man.AjaxSortSubmission(sort_container);
|
297
|
+
}
|
298
|
+
});
|
299
|
+
jq_obj.disableSelection();
|
185
300
|
}
|
301
|
+
})
|
302
|
+
};
|
303
|
+
thin_man.AjaxFormSubmission = thin_man.AjaxSubmission.extend({
|
304
|
+
getAjaxUrl: function(){
|
305
|
+
return this.jq_obj.attr('action');
|
306
|
+
},
|
307
|
+
getAjaxType: function(){
|
308
|
+
return this.jq_obj.attr('method') || 'POST'
|
309
|
+
},
|
310
|
+
getData: function(){
|
311
|
+
var data_array = this.jq_obj.serializeArray();
|
312
|
+
return data_array;
|
313
|
+
},
|
314
|
+
getTrigger: function(){
|
315
|
+
this.trigger = this.jq_obj.find('button, input[type="submit"]');
|
316
|
+
},
|
317
|
+
hideTrigger: function(){
|
318
|
+
this.trigger.css('visibility','hidden');
|
319
|
+
},
|
320
|
+
showTrigger: function(){
|
321
|
+
this.trigger.css('visibility','visible');
|
186
322
|
}
|
187
|
-
},
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
323
|
+
}),
|
324
|
+
thin_man.AjaxLinkSubmission = thin_man.AjaxSubmission.extend({
|
325
|
+
getAjaxUrl: function(){
|
326
|
+
return this.jq_obj.attr('href');
|
327
|
+
},
|
328
|
+
getData: function(){
|
329
|
+
var this_data = {authenticity_token: $('[name="csrf-token"]').attr('content')};
|
330
|
+
if(this.jq_obj.data('form-data')){
|
331
|
+
$.extend(this_data,this.jq_obj.data('form-data'))
|
332
|
+
}
|
333
|
+
return this_data
|
334
|
+
},
|
335
|
+
getAjaxType: function(){
|
336
|
+
return this.jq_obj.data('ajax-method') || 'GET'
|
337
|
+
},
|
338
|
+
getTrigger: function(){
|
339
|
+
this.trigger = this.jq_obj;
|
340
|
+
},
|
341
|
+
hideTrigger: function(){
|
342
|
+
this.trigger.css('visibility','hidden');
|
343
|
+
},
|
344
|
+
showTrigger: function(){
|
345
|
+
this.trigger.css('visibility','visible');
|
197
346
|
}
|
198
|
-
|
199
|
-
|
347
|
+
}),
|
348
|
+
thin_man.AjaxModalOpener = thin_man.AjaxLinkSubmission.extend({
|
349
|
+
ajaxSuccess: function(data,textStatus,jqXHR) {
|
350
|
+
this._super(data,textStatus,jqXHR);
|
351
|
+
$(this.jq_obj.data('ajax-modal')).modal();
|
200
352
|
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
this.
|
353
|
+
}),
|
354
|
+
thin_man.AddALineForm = thin_man.AjaxFormSubmission.extend({
|
355
|
+
ajaxSuccess: function(data,textStatus,jqXHR) {
|
356
|
+
this._super(data,textStatus,jqXHR);
|
357
|
+
$(this.jq_obj.data('container')).empty();
|
358
|
+
},
|
359
|
+
ajaxError: function(jqXHR){
|
360
|
+
this.insert_method = 'html';
|
361
|
+
this._super(jqXHR);
|
210
362
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
var targetOffset = target.parent().offset();
|
226
|
-
} else {
|
227
|
-
var targetOffset = target.offset();
|
363
|
+
}),
|
364
|
+
thin_man.EmptyForm = thin_man.AjaxFormSubmission.extend({
|
365
|
+
ajaxSuccess: function(data,textStatus,jqXHR) {
|
366
|
+
var clicked_button = $("input[type=submit][clicked=true]")[0];
|
367
|
+
this._super(data,textStatus,jqXHR);
|
368
|
+
if ($(clicked_button).data('clone') != true) {
|
369
|
+
$(this.jq_obj)[0].reset();
|
370
|
+
};
|
371
|
+
$(this.jq_obj).find('input[type=text],textarea,select').filter(':visible:first').focus();
|
372
|
+
$("[data-autocomplete]").trigger("chosen:updated");
|
373
|
+
},
|
374
|
+
ajaxError: function(jqXHR){
|
375
|
+
this.insert_method = 'html';
|
376
|
+
this._super(jqXHR);
|
228
377
|
}
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
this.
|
233
|
-
|
234
|
-
|
235
|
-
$
|
236
|
-
|
237
|
-
|
378
|
+
}),
|
379
|
+
thin_man.ModalCloserForm = thin_man.AjaxFormSubmission.extend({
|
380
|
+
ajaxSuccess: function(data,textStatus,jqXHR) {
|
381
|
+
this._super(data,textStatus,jqXHR);
|
382
|
+
$modal = $(this.jq_obj.data('modal-container'));
|
383
|
+
$modal.modal('hide');
|
384
|
+
$modal.remove();
|
385
|
+
},
|
386
|
+
ajaxError: function(jqXHR){
|
387
|
+
this._super(jqXHR);
|
388
|
+
$modal = $(this.jq_obj.data('modal-container'));
|
389
|
+
$modal.modal();
|
238
390
|
}
|
239
|
-
},
|
240
|
-
|
241
|
-
|
242
|
-
this.
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
$actual_progress_container = $('#' + this.progress_container.attr('id'))
|
247
|
-
$actual_progress_container.remove();
|
391
|
+
}),
|
392
|
+
thin_man.ResetOnSubmitForm = thin_man.AjaxFormSubmission.extend({
|
393
|
+
ajaxSuccess: function(data, textStatus, jqXHR) {
|
394
|
+
this._super(data, textStatus, jqXHR);
|
395
|
+
$(this.jq_obj).each(function() {
|
396
|
+
this.reset();
|
397
|
+
});
|
248
398
|
}
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
this.flash_container.css({position:'absolute',visibility: 'hidden'});
|
256
|
-
this.alert_type = type;
|
257
|
-
this.elem = elem;
|
258
|
-
var alert_class = 'alert-' + type;
|
259
|
-
this.flash_container.addClass(alert_class);
|
260
|
-
$('#thin-man-flash-content', this.flash_container).html(message);
|
261
|
-
this.flash_container.show();
|
262
|
-
this.setFadeBehavior(duration);
|
263
|
-
this.reposition(elem);
|
264
|
-
},
|
265
|
-
setFadeBehavior: function(duration){
|
266
|
-
if(duration){
|
267
|
-
if('persist' == duration){
|
268
|
-
this.fade = false
|
269
|
-
} else {
|
270
|
-
this.fade = true
|
271
|
-
}
|
272
|
-
}else{ //default behavior if persist duration is not sent back with message
|
273
|
-
if('error' == this.alert_type || 'warning' == this.alert_type || 'info' == this.alert_type){
|
274
|
-
this.fade = false;
|
275
|
-
} else {
|
276
|
-
this.fade = true;
|
399
|
+
}),
|
400
|
+
thin_man.DeleteLink = thin_man.AjaxSubmission.extend({
|
401
|
+
ajaxSuccess: function(data,textStatus,jqXHR){
|
402
|
+
this._super(data,textStatus,jqXHR);
|
403
|
+
if(this.target){
|
404
|
+
this.target.remove();
|
277
405
|
}
|
406
|
+
},
|
407
|
+
getAjaxType: function(){
|
408
|
+
return 'DELETE';
|
409
|
+
},
|
410
|
+
getAjaxUrl: function(){
|
411
|
+
return this.jq_obj.attr('href');
|
412
|
+
},
|
413
|
+
getData: function(){
|
414
|
+
return {authenticity_token: $('[name="csrf-token"]').attr('content')};
|
415
|
+
},
|
416
|
+
ajaxBefore: function(jqXHR){
|
417
|
+
return confirm("Are you sure you want to delete this?");
|
278
418
|
}
|
279
|
-
},
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
};
|
287
|
-
var this_flash = {
|
288
|
-
height: this.flash_container.outerHeight(),
|
289
|
-
width: this.flash_container.outerWidth()
|
290
|
-
}
|
291
|
-
this_window.vert_middle = (this_window.top + (this_window.height / 2));
|
292
|
-
this_window.horiz_middle = (this_window.left + (this_window.width / 2));
|
293
|
-
this_flash.half_height = (this_flash.height / 2);
|
294
|
-
this_flash.half_width = (this_flash.width / 2);
|
295
|
-
var new_top = this_window.vert_middle - this_flash.half_height;
|
296
|
-
var new_left = this_window.horiz_middle - this_flash.half_width;
|
297
|
-
this.flash_container.css({left: new_left, top: new_top, visibility: 'visible'});
|
298
|
-
var ajax_flash = this;
|
299
|
-
if (this.fade) {
|
300
|
-
setTimeout(function(){ajax_flash.fadeOut()},1618);
|
419
|
+
}),
|
420
|
+
thin_man.ReplaceDelete = thin_man.DeleteLink.extend({
|
421
|
+
ajaxSuccess: function(data,textStatus,jqXHR){
|
422
|
+
this.target[this.insert_method](data);
|
423
|
+
},
|
424
|
+
ajaxBefore: function(jqXHR){
|
425
|
+
//noop
|
301
426
|
}
|
302
|
-
},
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
}
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
},
|
312
|
-
getAjaxType: function(){
|
313
|
-
return this.jq_obj.attr('method') || 'POST'
|
314
|
-
},
|
315
|
-
getData: function(){
|
316
|
-
var data_array = this.jq_obj.serializeArray();
|
317
|
-
return data_array;
|
318
|
-
},
|
319
|
-
getTrigger: function(){
|
320
|
-
this.trigger = this.jq_obj.find('button, input[type="submit"]');
|
321
|
-
},
|
322
|
-
hideTrigger: function(){
|
323
|
-
this.trigger.css('visibility','hidden');
|
324
|
-
},
|
325
|
-
showTrigger: function(){
|
326
|
-
this.trigger.css('visibility','visible');
|
327
|
-
}
|
328
|
-
});
|
427
|
+
}),
|
428
|
+
thin_man.AjaxSortSubmission = thin_man.AjaxLinkSubmission.extend({
|
429
|
+
getAjaxUrl: function(){
|
430
|
+
return this._super() + '?' + this.jq_obj.sortable("serialize");
|
431
|
+
},
|
432
|
+
getAjaxType: function(){
|
433
|
+
return 'PUT';
|
434
|
+
},
|
435
|
+
ajaxSuccess: function(){
|
329
436
|
|
330
|
-
var AjaxLinkSubmission = AjaxSubmission.extend({
|
331
|
-
getAjaxUrl: function(){
|
332
|
-
return this.jq_obj.attr('href');
|
333
|
-
},
|
334
|
-
getData: function(){
|
335
|
-
var this_data = {authenticity_token: $('[name="csrf-token"]').attr('content')};
|
336
|
-
if(this.jq_obj.data('form-data')){
|
337
|
-
$.extend(this_data,this.jq_obj.data('form-data'))
|
338
437
|
}
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
},
|
347
|
-
hideTrigger: function(){
|
348
|
-
this.trigger.css('visibility','hidden');
|
349
|
-
},
|
350
|
-
showTrigger: function(){
|
351
|
-
this.trigger.css('visibility','visible');
|
352
|
-
}
|
353
|
-
});
|
354
|
-
|
355
|
-
var AjaxModalOpener = AjaxLinkSubmission.extend({
|
356
|
-
ajaxSuccess: function(data,textStatus,jqXHR) {
|
357
|
-
this._super(data,textStatus,jqXHR);
|
358
|
-
$(this.jq_obj.data('ajax-modal')).modal();
|
359
|
-
}
|
360
|
-
});
|
361
|
-
|
362
|
-
var AddALineForm = AjaxFormSubmission.extend({
|
363
|
-
ajaxSuccess: function(data,textStatus,jqXHR) {
|
364
|
-
this._super(data,textStatus,jqXHR);
|
365
|
-
$(this.jq_obj.data('container')).empty();
|
366
|
-
},
|
367
|
-
ajaxError: function(jqXHR){
|
368
|
-
this.insert_method = 'html';
|
369
|
-
this._super(jqXHR);
|
370
|
-
}
|
371
|
-
});
|
372
|
-
|
373
|
-
var EmptyForm = AjaxFormSubmission.extend({
|
374
|
-
ajaxSuccess: function(data,textStatus,jqXHR) {
|
375
|
-
var clicked_button = $("input[type=submit][clicked=true]")[0];
|
376
|
-
this._super(data,textStatus,jqXHR);
|
377
|
-
if ($(clicked_button).data('clone') != true) {
|
378
|
-
$(this.jq_obj)[0].reset();
|
379
|
-
};
|
380
|
-
$(this.jq_obj).find('input[type=text],textarea,select').filter(':visible:first').focus();
|
381
|
-
$("[data-autocomplete]").trigger("chosen:updated");
|
382
|
-
},
|
383
|
-
ajaxError: function(jqXHR){
|
384
|
-
this.insert_method = 'html';
|
385
|
-
this._super(jqXHR);
|
386
|
-
}
|
387
|
-
});
|
388
|
-
|
389
|
-
var ModalCloserForm = AjaxFormSubmission.extend({
|
390
|
-
ajaxSuccess: function(data,textStatus,jqXHR) {
|
391
|
-
this._super(data,textStatus,jqXHR);
|
392
|
-
$modal = $(this.jq_obj.data('modal-container'));
|
393
|
-
$modal.modal('hide');
|
394
|
-
$modal.remove();
|
395
|
-
},
|
396
|
-
ajaxError: function(jqXHR){
|
397
|
-
this._super(jqXHR);
|
398
|
-
$modal = $(this.jq_obj.data('modal-container'));
|
399
|
-
$modal.modal();
|
400
|
-
}
|
401
|
-
});
|
402
|
-
|
403
|
-
var ResetOnSubmitForm = AjaxFormSubmission.extend({
|
404
|
-
ajaxSuccess: function(data, textStatus, jqXHR) {
|
405
|
-
this._super(data, textStatus, jqXHR);
|
406
|
-
$(this.jq_obj).each(function() {
|
407
|
-
this.reset();
|
438
|
+
})
|
439
|
+
$(document).ready(function(){
|
440
|
+
$(document).on('click','[data-ajax-link]',function(e){
|
441
|
+
e.preventDefault();
|
442
|
+
var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'AjaxLinkSubmission'));
|
443
|
+
var submission = new this_class($(this));
|
444
|
+
return false;
|
408
445
|
});
|
409
|
-
}
|
410
|
-
});
|
411
|
-
|
412
|
-
var DeleteLink = AjaxSubmission.extend({
|
413
|
-
ajaxSuccess: function(data,textStatus,jqXHR){
|
414
|
-
this._super(data,textStatus,jqXHR);
|
415
|
-
if(this.target){
|
416
|
-
this.target.remove();
|
417
|
-
}
|
418
|
-
},
|
419
|
-
getAjaxType: function(){
|
420
|
-
return 'DELETE';
|
421
|
-
},
|
422
|
-
getAjaxUrl: function(){
|
423
|
-
return this.jq_obj.attr('href');
|
424
|
-
},
|
425
|
-
getData: function(){
|
426
|
-
return {authenticity_token: $('[name="csrf-token"]').attr('content')};
|
427
|
-
},
|
428
|
-
ajaxBefore: function(jqXHR){
|
429
|
-
return confirm("Are you sure you want to delete this?");
|
430
|
-
}
|
431
|
-
});
|
432
|
-
|
433
|
-
var AjaxSortSubmission = AjaxLinkSubmission.extend({
|
434
|
-
getAjaxUrl: function(){
|
435
|
-
return this._super() + '?' + this.jq_obj.sortable("serialize");
|
436
|
-
},
|
437
|
-
getAjaxType: function(){
|
438
|
-
return 'PUT';
|
439
|
-
},
|
440
|
-
ajaxSuccess: function(){
|
441
446
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
var
|
446
|
-
|
447
|
-
var sort_container = jq_obj;
|
448
|
-
var base_url = sort_container.data('url');
|
449
|
-
sort_container.sortable({
|
450
|
-
helper: "clone",
|
451
|
-
tolerance: 'pointer',
|
452
|
-
stop: function( event, ui) {
|
453
|
-
new AjaxSortSubmission(sort_container);
|
454
|
-
}
|
447
|
+
$(document).on('submit','[data-ajax-form]',function(e){
|
448
|
+
e.preventDefault();
|
449
|
+
var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'AjaxFormSubmission'));
|
450
|
+
var submission = new this_class($(this));
|
451
|
+
return false;
|
455
452
|
});
|
456
|
-
jq_obj.disableSelection();
|
457
|
-
}
|
458
|
-
});
|
459
|
-
|
460
453
|
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
}
|
466
|
-
}
|
467
|
-
});
|
454
|
+
$(document).on('click','[data-ajax-delete]',function(e){
|
455
|
+
e.preventDefault();
|
456
|
+
var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'DeleteLink'));
|
457
|
+
var deletion = new this_class($(this));
|
458
|
+
});
|
468
459
|
|
469
|
-
$(document).
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
var submission = new this_class($(this));
|
474
|
-
return false;
|
475
|
-
});
|
460
|
+
$(document).on('click', '[data-change-url]',function(e){
|
461
|
+
e.preventDefault();
|
462
|
+
new thin_man.AjaxPushState($(this))
|
463
|
+
})
|
476
464
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
var submission = new this_class($(this));
|
481
|
-
return false;
|
482
|
-
});
|
465
|
+
$('[data-sortable]').each(function(){
|
466
|
+
new thin_man.AjaxSorter($(this));
|
467
|
+
});
|
483
468
|
|
484
|
-
$(document).on('click','[data-ajax-delete]',function(e){
|
485
|
-
e.preventDefault();
|
486
|
-
var this_class = eval(getSubClass($(this).data('sub-type'),'DeleteLink'));
|
487
|
-
var deletion = new this_class($(this));
|
488
469
|
});
|
489
470
|
|
490
|
-
|
491
|
-
e.preventDefault();
|
492
|
-
new AjaxPushState($(this))
|
493
|
-
})
|
471
|
+
};
|
494
472
|
|
495
|
-
|
496
|
-
|
473
|
+
if(typeof Class === "undefined"){
|
474
|
+
$.getScript('https://rawgit.com/edraut/js_inheritance/a6c1e40986ecb276335b0a0b1792abd01f05ff6c/inheritance.js', function(){
|
475
|
+
initThinMan();
|
497
476
|
});
|
498
|
-
|
499
|
-
|
477
|
+
}else{
|
478
|
+
initThinMan();
|
479
|
+
}
|
data/lib/thin_man/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thin_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut, Adam Bialek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|