active_admin_pro 0.1.5 → 0.1.6
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/app/assets/javascripts/active_admin_pro/components/autocomplete_input.js +53 -0
- data/app/assets/stylesheets/active_admin_pro/components/autocomplete_input.scss +57 -0
- data/app/inputs/autocomplete_input.rb +5 -0
- data/lib/active_admin_pro/summernote_image/summernote_image.rb +1 -1
- data/lib/active_admin_pro/version.rb +1 -1
- data/vendor/assets/javascripts/awesomplete.js +392 -0
- data/vendor/assets/javascripts/jquery.scrollTo.js +210 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d6a621bc2fa55ca47e8c1b172b0ed468a9300b
|
4
|
+
data.tar.gz: 6f497b8a8b7ab7eeb6115013fda4d5b2bcb7c24a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82ae43471cfd6eaed7911faa980b333b7a96543b25b3479d952a439d869552ab1ac6cd9ad4095fd46536f4bd83668a528065df7a815707cbac9e95f118ff362e
|
7
|
+
data.tar.gz: 030e64520e8f4409f3d50330702f4be213a14cf333b831fafbe029fc4a0097a60a7a5d2e1b1f319a6ee7b079979231468cf933d1165424ad15fd9439946d4c86
|
@@ -0,0 +1,53 @@
|
|
1
|
+
//= require awesomplete
|
2
|
+
//= require jquery.scrollTo
|
3
|
+
|
4
|
+
/* globals Awesomplete */
|
5
|
+
(function() {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
// Enable auto-complete input fields.
|
9
|
+
// @see http://leaverou.github.io/awesomplete/
|
10
|
+
App.register('component').enter(function() {
|
11
|
+
$('input.autocomplete').each(function() {
|
12
|
+
var autocomplete = new Awesomplete(this, { maxItems: 9999 });
|
13
|
+
|
14
|
+
var input = $(this);
|
15
|
+
var list = $(input.siblings('ul'));
|
16
|
+
list.css('width', input.outerWidth());
|
17
|
+
|
18
|
+
// Open the auto complete list when the input is focused
|
19
|
+
input.focus(function() {
|
20
|
+
autocomplete.evaluate();
|
21
|
+
autocomplete.open();
|
22
|
+
});
|
23
|
+
|
24
|
+
// Scroll list to top when opened
|
25
|
+
input.bind('awesomplete-open', function() {
|
26
|
+
list.scrollTo(0);
|
27
|
+
});
|
28
|
+
|
29
|
+
// Scroll list up or down to the selected element
|
30
|
+
input.bind('awesomplete-highlight', function(e) {
|
31
|
+
var item = $(list.find('li[aria-selected="true"]'));
|
32
|
+
if (item === undefined || item === null || item.position() === undefined) { return; }
|
33
|
+
|
34
|
+
// Gather the list and item heights so we can scroll to the item
|
35
|
+
var itemHeight = item.height();
|
36
|
+
var itemTop = item.position().top;
|
37
|
+
var listHeight = list.height();
|
38
|
+
var itemCount = listHeight / itemHeight;
|
39
|
+
|
40
|
+
// Scroll the item to the bottom or top of the list if not visible
|
41
|
+
if (itemTop >= listHeight) {
|
42
|
+
list.scrollTo(item, {
|
43
|
+
offset: {
|
44
|
+
top: -itemHeight * (itemCount - 1)
|
45
|
+
}
|
46
|
+
});
|
47
|
+
} else if (itemTop < 0) {
|
48
|
+
list.scrollTo(item);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
});
|
52
|
+
});
|
53
|
+
})();
|
@@ -0,0 +1,57 @@
|
|
1
|
+
$autocomplete-background-color: #fff;
|
2
|
+
$autocomplete-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
|
3
|
+
$autocomplete-highlight-color: #000;
|
4
|
+
$autocomplete-item-height: 40px;
|
5
|
+
$autocomplete-max-items: 5;
|
6
|
+
$autocomplete-selected-background-color: $accent-color;
|
7
|
+
$autocomplete-selected-color: text-color($autocomplete-selected-background-color);
|
8
|
+
|
9
|
+
.input.autocomplete {
|
10
|
+
z-index: 5;
|
11
|
+
}
|
12
|
+
|
13
|
+
.awesomplete {
|
14
|
+
position: relative;
|
15
|
+
|
16
|
+
ul {
|
17
|
+
background-color: $autocomplete-background-color;
|
18
|
+
box-shadow: $autocomplete-box-shadow;
|
19
|
+
left: 2px;
|
20
|
+
list-style-type: none;
|
21
|
+
margin: 0;
|
22
|
+
max-height: $autocomplete-item-height * $autocomplete-max-items;
|
23
|
+
overflow-y: auto;
|
24
|
+
padding: 0;
|
25
|
+
position: absolute;
|
26
|
+
top: 100%;
|
27
|
+
z-index: 6;
|
28
|
+
}
|
29
|
+
|
30
|
+
li {
|
31
|
+
cursor: pointer;
|
32
|
+
height: $autocomplete-item-height;
|
33
|
+
line-height: $autocomplete-item-height;
|
34
|
+
padding: 0 0.5em;
|
35
|
+
}
|
36
|
+
|
37
|
+
mark {
|
38
|
+
background-color: transparent;
|
39
|
+
color: $autocomplete-highlight-color;
|
40
|
+
font-weight: bold;
|
41
|
+
}
|
42
|
+
|
43
|
+
li:hover,
|
44
|
+
li[aria-selected="true"] {
|
45
|
+
background-color: $autocomplete-selected-background-color;
|
46
|
+
color: $autocomplete-selected-color;
|
47
|
+
|
48
|
+
mark {
|
49
|
+
color: $autocomplete-selected-color;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
.visually-hidden {
|
54
|
+
position: absolute;
|
55
|
+
visibility: hidden;
|
56
|
+
}
|
57
|
+
}
|
@@ -25,7 +25,7 @@ ActiveAdmin.register ActiveAdminPro::SummernoteImage do
|
|
25
25
|
file_ext = File.extname(@file.original_filename)
|
26
26
|
file_base = File.basename(@file.original_filename, file_ext)
|
27
27
|
time = Time.now.to_i
|
28
|
-
"aap/si/#{file_base}
|
28
|
+
"aap/si/#{file_base.parameterize}-#{time}#{file_ext}"
|
29
29
|
end
|
30
30
|
|
31
31
|
def google_storage_bucket
|
@@ -0,0 +1,392 @@
|
|
1
|
+
/**
|
2
|
+
* Simple, lightweight, usable local autocomplete library for modern browsers
|
3
|
+
* Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P
|
4
|
+
* @author Lea Verou http://leaverou.github.io/awesomplete
|
5
|
+
* MIT license
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function () {
|
9
|
+
|
10
|
+
var _ = function (input, o) {
|
11
|
+
var me = this;
|
12
|
+
|
13
|
+
// Setup
|
14
|
+
|
15
|
+
this.input = $(input);
|
16
|
+
this.input.setAttribute("autocomplete", "off");
|
17
|
+
this.input.setAttribute("aria-autocomplete", "list");
|
18
|
+
|
19
|
+
o = o || {};
|
20
|
+
|
21
|
+
configure.call(this, {
|
22
|
+
minChars: 2,
|
23
|
+
maxItems: 10,
|
24
|
+
autoFirst: false,
|
25
|
+
filter: _.FILTER_CONTAINS,
|
26
|
+
sort: _.SORT_BYLENGTH,
|
27
|
+
item: function (text, input) {
|
28
|
+
var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
|
29
|
+
return $.create("li", {
|
30
|
+
innerHTML: html,
|
31
|
+
"aria-selected": "false"
|
32
|
+
});
|
33
|
+
},
|
34
|
+
replace: function (text) {
|
35
|
+
this.input.value = text;
|
36
|
+
}
|
37
|
+
}, o);
|
38
|
+
|
39
|
+
this.index = -1;
|
40
|
+
|
41
|
+
// Create necessary elements
|
42
|
+
|
43
|
+
this.container = $.create("div", {
|
44
|
+
className: "awesomplete",
|
45
|
+
around: input
|
46
|
+
});
|
47
|
+
|
48
|
+
this.ul = $.create("ul", {
|
49
|
+
hidden: "",
|
50
|
+
inside: this.container
|
51
|
+
});
|
52
|
+
|
53
|
+
this.status = $.create("span", {
|
54
|
+
className: "visually-hidden",
|
55
|
+
role: "status",
|
56
|
+
"aria-live": "assertive",
|
57
|
+
"aria-relevant": "additions",
|
58
|
+
inside: this.container
|
59
|
+
});
|
60
|
+
|
61
|
+
// Bind events
|
62
|
+
|
63
|
+
$.bind(this.input, {
|
64
|
+
"input": this.evaluate.bind(this),
|
65
|
+
"blur": this.close.bind(this),
|
66
|
+
"keydown": function(evt) {
|
67
|
+
var c = evt.keyCode;
|
68
|
+
|
69
|
+
// If the dropdown `ul` is in view, then act on keydown for the following keys:
|
70
|
+
// Enter / Esc / Up / Down
|
71
|
+
if(me.opened) {
|
72
|
+
if (c === 13 && me.selected) { // Enter
|
73
|
+
evt.preventDefault();
|
74
|
+
me.select();
|
75
|
+
}
|
76
|
+
else if (c === 27) { // Esc
|
77
|
+
me.close();
|
78
|
+
}
|
79
|
+
else if (c === 38 || c === 40) { // Down/Up arrow
|
80
|
+
evt.preventDefault();
|
81
|
+
me[c === 38? "previous" : "next"]();
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
$.bind(this.input.form, {"submit": this.close.bind(this)});
|
88
|
+
|
89
|
+
$.bind(this.ul, {"mousedown": function(evt) {
|
90
|
+
var li = evt.target;
|
91
|
+
|
92
|
+
if (li !== this) {
|
93
|
+
|
94
|
+
while (li && !/li/i.test(li.nodeName)) {
|
95
|
+
li = li.parentNode;
|
96
|
+
}
|
97
|
+
|
98
|
+
if (li && evt.button === 0) { // Only select on left click
|
99
|
+
me.select(li);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}});
|
103
|
+
|
104
|
+
if (this.input.hasAttribute("list")) {
|
105
|
+
this.list = "#" + input.getAttribute("list");
|
106
|
+
input.removeAttribute("list");
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
this.list = this.input.getAttribute("data-list") || o.list || [];
|
110
|
+
}
|
111
|
+
|
112
|
+
_.all.push(this);
|
113
|
+
};
|
114
|
+
|
115
|
+
_.prototype = {
|
116
|
+
set list(list) {
|
117
|
+
if (Array.isArray(list)) {
|
118
|
+
this._list = list;
|
119
|
+
}
|
120
|
+
else if (typeof list === "string" && list.indexOf(",") > -1) {
|
121
|
+
this._list = list.split(/\s*,\s*/);
|
122
|
+
}
|
123
|
+
else { // Element or CSS selector
|
124
|
+
list = $(list);
|
125
|
+
|
126
|
+
if (list && list.children) {
|
127
|
+
this._list = slice.apply(list.children).map(function (el) {
|
128
|
+
return el.textContent.trim();
|
129
|
+
});
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
if (document.activeElement === this.input) {
|
134
|
+
this.evaluate();
|
135
|
+
}
|
136
|
+
},
|
137
|
+
|
138
|
+
get selected() {
|
139
|
+
return this.index > -1;
|
140
|
+
},
|
141
|
+
|
142
|
+
get opened() {
|
143
|
+
return this.ul && this.ul.getAttribute("hidden") == null;
|
144
|
+
},
|
145
|
+
|
146
|
+
close: function () {
|
147
|
+
this.ul.setAttribute("hidden", "");
|
148
|
+
this.index = -1;
|
149
|
+
|
150
|
+
$.fire(this.input, "awesomplete-close");
|
151
|
+
},
|
152
|
+
|
153
|
+
open: function () {
|
154
|
+
this.ul.removeAttribute("hidden");
|
155
|
+
|
156
|
+
if (this.autoFirst && this.index === -1) {
|
157
|
+
this.goto(0);
|
158
|
+
}
|
159
|
+
|
160
|
+
$.fire(this.input, "awesomplete-open");
|
161
|
+
},
|
162
|
+
|
163
|
+
next: function () {
|
164
|
+
var count = this.ul.children.length;
|
165
|
+
|
166
|
+
this.goto(this.index < count - 1? this.index + 1 : -1);
|
167
|
+
},
|
168
|
+
|
169
|
+
previous: function () {
|
170
|
+
var count = this.ul.children.length;
|
171
|
+
|
172
|
+
this.goto(this.selected? this.index - 1 : count - 1);
|
173
|
+
},
|
174
|
+
|
175
|
+
// Should not be used, highlights specific item without any checks!
|
176
|
+
goto: function (i) {
|
177
|
+
var lis = this.ul.children;
|
178
|
+
|
179
|
+
if (this.selected) {
|
180
|
+
lis[this.index].setAttribute("aria-selected", "false");
|
181
|
+
}
|
182
|
+
|
183
|
+
this.index = i;
|
184
|
+
|
185
|
+
if (i > -1 && lis.length > 0) {
|
186
|
+
lis[i].setAttribute("aria-selected", "true");
|
187
|
+
this.status.textContent = lis[i].textContent;
|
188
|
+
}
|
189
|
+
|
190
|
+
$.fire(this.input, "awesomplete-highlight");
|
191
|
+
},
|
192
|
+
|
193
|
+
select: function (selected) {
|
194
|
+
selected = selected || this.ul.children[this.index];
|
195
|
+
|
196
|
+
if (selected) {
|
197
|
+
var prevented;
|
198
|
+
|
199
|
+
$.fire(this.input, "awesomplete-select", {
|
200
|
+
text: selected.textContent,
|
201
|
+
preventDefault: function () {
|
202
|
+
prevented = true;
|
203
|
+
}
|
204
|
+
});
|
205
|
+
|
206
|
+
if (!prevented) {
|
207
|
+
this.replace(selected.textContent);
|
208
|
+
this.close();
|
209
|
+
$.fire(this.input, "awesomplete-selectcomplete");
|
210
|
+
}
|
211
|
+
}
|
212
|
+
},
|
213
|
+
|
214
|
+
evaluate: function() {
|
215
|
+
var me = this;
|
216
|
+
var value = this.input.value;
|
217
|
+
|
218
|
+
if (value.length >= this.minChars && this._list.length > 0) {
|
219
|
+
this.index = -1;
|
220
|
+
// Populate list with options that match
|
221
|
+
this.ul.innerHTML = "";
|
222
|
+
|
223
|
+
this._list
|
224
|
+
.filter(function(item) {
|
225
|
+
return me.filter(item, value);
|
226
|
+
})
|
227
|
+
.sort(this.sort)
|
228
|
+
.every(function(text, i) {
|
229
|
+
me.ul.appendChild(me.item(text, value));
|
230
|
+
|
231
|
+
return i < me.maxItems - 1;
|
232
|
+
});
|
233
|
+
|
234
|
+
if (this.ul.children.length === 0) {
|
235
|
+
this.close();
|
236
|
+
} else {
|
237
|
+
this.open();
|
238
|
+
}
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
this.close();
|
242
|
+
}
|
243
|
+
}
|
244
|
+
};
|
245
|
+
|
246
|
+
// Static methods/properties
|
247
|
+
|
248
|
+
_.all = [];
|
249
|
+
|
250
|
+
_.FILTER_CONTAINS = function (text, input) {
|
251
|
+
return RegExp($.regExpEscape(input.trim()), "i").test(text);
|
252
|
+
};
|
253
|
+
|
254
|
+
_.FILTER_STARTSWITH = function (text, input) {
|
255
|
+
return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text);
|
256
|
+
};
|
257
|
+
|
258
|
+
_.SORT_BYLENGTH = function (a, b) {
|
259
|
+
if (a.length !== b.length) {
|
260
|
+
return a.length - b.length;
|
261
|
+
}
|
262
|
+
|
263
|
+
return a < b? -1 : 1;
|
264
|
+
};
|
265
|
+
|
266
|
+
// Private functions
|
267
|
+
|
268
|
+
function configure(properties, o) {
|
269
|
+
for (var i in properties) {
|
270
|
+
var initial = properties[i],
|
271
|
+
attrValue = this.input.getAttribute("data-" + i.toLowerCase());
|
272
|
+
|
273
|
+
if (typeof initial === "number") {
|
274
|
+
this[i] = parseInt(attrValue);
|
275
|
+
}
|
276
|
+
else if (initial === false) { // Boolean options must be false by default anyway
|
277
|
+
this[i] = attrValue !== null;
|
278
|
+
}
|
279
|
+
else if (initial instanceof Function) {
|
280
|
+
this[i] = null;
|
281
|
+
}
|
282
|
+
else {
|
283
|
+
this[i] = attrValue;
|
284
|
+
}
|
285
|
+
|
286
|
+
if (!this[i] && this[i] !== 0) {
|
287
|
+
this[i] = (i in o)? o[i] : initial;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
// Helpers
|
293
|
+
|
294
|
+
var slice = Array.prototype.slice;
|
295
|
+
|
296
|
+
function $(expr, con) {
|
297
|
+
return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
|
298
|
+
}
|
299
|
+
|
300
|
+
function $$(expr, con) {
|
301
|
+
return slice.call((con || document).querySelectorAll(expr));
|
302
|
+
}
|
303
|
+
|
304
|
+
$.create = function(tag, o) {
|
305
|
+
var element = document.createElement(tag);
|
306
|
+
|
307
|
+
for (var i in o) {
|
308
|
+
var val = o[i];
|
309
|
+
|
310
|
+
if (i === "inside") {
|
311
|
+
$(val).appendChild(element);
|
312
|
+
}
|
313
|
+
else if (i === "around") {
|
314
|
+
var ref = $(val);
|
315
|
+
ref.parentNode.insertBefore(element, ref);
|
316
|
+
element.appendChild(ref);
|
317
|
+
}
|
318
|
+
else if (i in element) {
|
319
|
+
element[i] = val;
|
320
|
+
}
|
321
|
+
else {
|
322
|
+
element.setAttribute(i, val);
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
return element;
|
327
|
+
};
|
328
|
+
|
329
|
+
$.bind = function(element, o) {
|
330
|
+
if (element) {
|
331
|
+
for (var event in o) {
|
332
|
+
var callback = o[event];
|
333
|
+
|
334
|
+
event.split(/\s+/).forEach(function (event) {
|
335
|
+
element.addEventListener(event, callback);
|
336
|
+
});
|
337
|
+
}
|
338
|
+
}
|
339
|
+
};
|
340
|
+
|
341
|
+
$.fire = function(target, type, properties) {
|
342
|
+
var evt = document.createEvent("HTMLEvents");
|
343
|
+
|
344
|
+
evt.initEvent(type, true, true );
|
345
|
+
|
346
|
+
for (var j in properties) {
|
347
|
+
evt[j] = properties[j];
|
348
|
+
}
|
349
|
+
|
350
|
+
target.dispatchEvent(evt);
|
351
|
+
};
|
352
|
+
|
353
|
+
$.regExpEscape = function (s) {
|
354
|
+
return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
|
355
|
+
}
|
356
|
+
|
357
|
+
// Initialization
|
358
|
+
|
359
|
+
function init() {
|
360
|
+
$$("input.awesomplete").forEach(function (input) {
|
361
|
+
new _(input);
|
362
|
+
});
|
363
|
+
}
|
364
|
+
|
365
|
+
// Are we in a browser? Check for Document constructor
|
366
|
+
if (typeof Document !== "undefined") {
|
367
|
+
// DOM already loaded?
|
368
|
+
if (document.readyState !== "loading") {
|
369
|
+
init();
|
370
|
+
}
|
371
|
+
else {
|
372
|
+
// Wait for it
|
373
|
+
document.addEventListener("DOMContentLoaded", init);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
_.$ = $;
|
378
|
+
_.$$ = $$;
|
379
|
+
|
380
|
+
// Make sure to export Awesomplete on self when in a browser
|
381
|
+
if (typeof self !== "undefined") {
|
382
|
+
self.Awesomplete = _;
|
383
|
+
}
|
384
|
+
|
385
|
+
// Expose Awesomplete as a CJS module
|
386
|
+
if (typeof exports === "object") {
|
387
|
+
module.exports = _;
|
388
|
+
}
|
389
|
+
|
390
|
+
return _;
|
391
|
+
|
392
|
+
}());
|
@@ -0,0 +1,210 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery.scrollTo
|
3
|
+
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
|
4
|
+
* Licensed under MIT
|
5
|
+
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
6
|
+
* @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
|
7
|
+
* @author Ariel Flesler
|
8
|
+
* @version 2.1.2
|
9
|
+
*/
|
10
|
+
;(function(factory) {
|
11
|
+
'use strict';
|
12
|
+
if (typeof define === 'function' && define.amd) {
|
13
|
+
// AMD
|
14
|
+
define(['jquery'], factory);
|
15
|
+
} else if (typeof module !== 'undefined' && module.exports) {
|
16
|
+
// CommonJS
|
17
|
+
module.exports = factory(require('jquery'));
|
18
|
+
} else {
|
19
|
+
// Global
|
20
|
+
factory(jQuery);
|
21
|
+
}
|
22
|
+
})(function($) {
|
23
|
+
'use strict';
|
24
|
+
|
25
|
+
var $scrollTo = $.scrollTo = function(target, duration, settings) {
|
26
|
+
return $(window).scrollTo(target, duration, settings);
|
27
|
+
};
|
28
|
+
|
29
|
+
$scrollTo.defaults = {
|
30
|
+
axis:'xy',
|
31
|
+
duration: 0,
|
32
|
+
limit:true
|
33
|
+
};
|
34
|
+
|
35
|
+
function isWin(elem) {
|
36
|
+
return !elem.nodeName ||
|
37
|
+
$.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
|
38
|
+
}
|
39
|
+
|
40
|
+
$.fn.scrollTo = function(target, duration, settings) {
|
41
|
+
if (typeof duration === 'object') {
|
42
|
+
settings = duration;
|
43
|
+
duration = 0;
|
44
|
+
}
|
45
|
+
if (typeof settings === 'function') {
|
46
|
+
settings = { onAfter:settings };
|
47
|
+
}
|
48
|
+
if (target === 'max') {
|
49
|
+
target = 9e9;
|
50
|
+
}
|
51
|
+
|
52
|
+
settings = $.extend({}, $scrollTo.defaults, settings);
|
53
|
+
// Speed is still recognized for backwards compatibility
|
54
|
+
duration = duration || settings.duration;
|
55
|
+
// Make sure the settings are given right
|
56
|
+
var queue = settings.queue && settings.axis.length > 1;
|
57
|
+
if (queue) {
|
58
|
+
// Let's keep the overall duration
|
59
|
+
duration /= 2;
|
60
|
+
}
|
61
|
+
settings.offset = both(settings.offset);
|
62
|
+
settings.over = both(settings.over);
|
63
|
+
|
64
|
+
return this.each(function() {
|
65
|
+
// Null target yields nothing, just like jQuery does
|
66
|
+
if (target === null) return;
|
67
|
+
|
68
|
+
var win = isWin(this),
|
69
|
+
elem = win ? this.contentWindow || window : this,
|
70
|
+
$elem = $(elem),
|
71
|
+
targ = target,
|
72
|
+
attr = {},
|
73
|
+
toff;
|
74
|
+
|
75
|
+
switch (typeof targ) {
|
76
|
+
// A number will pass the regex
|
77
|
+
case 'number':
|
78
|
+
case 'string':
|
79
|
+
if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
|
80
|
+
targ = both(targ);
|
81
|
+
// We are done
|
82
|
+
break;
|
83
|
+
}
|
84
|
+
// Relative/Absolute selector
|
85
|
+
targ = win ? $(targ) : $(targ, elem);
|
86
|
+
/* falls through */
|
87
|
+
case 'object':
|
88
|
+
if (targ.length === 0) return;
|
89
|
+
// DOMElement / jQuery
|
90
|
+
if (targ.is || targ.style) {
|
91
|
+
// Get the real position of the target
|
92
|
+
toff = (targ = $(targ)).offset();
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
|
97
|
+
|
98
|
+
$.each(settings.axis.split(''), function(i, axis) {
|
99
|
+
var Pos = axis === 'x' ? 'Left' : 'Top',
|
100
|
+
pos = Pos.toLowerCase(),
|
101
|
+
key = 'scroll' + Pos,
|
102
|
+
prev = $elem[key](),
|
103
|
+
max = $scrollTo.max(elem, axis);
|
104
|
+
|
105
|
+
if (toff) {// jQuery / DOMElement
|
106
|
+
attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
|
107
|
+
|
108
|
+
// If it's a dom element, reduce the margin
|
109
|
+
if (settings.margin) {
|
110
|
+
attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
|
111
|
+
attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
|
112
|
+
}
|
113
|
+
|
114
|
+
attr[key] += offset[pos] || 0;
|
115
|
+
|
116
|
+
if (settings.over[pos]) {
|
117
|
+
// Scroll to a fraction of its width/height
|
118
|
+
attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
|
119
|
+
}
|
120
|
+
} else {
|
121
|
+
var val = targ[pos];
|
122
|
+
// Handle percentage values
|
123
|
+
attr[key] = val.slice && val.slice(-1) === '%' ?
|
124
|
+
parseFloat(val) / 100 * max
|
125
|
+
: val;
|
126
|
+
}
|
127
|
+
|
128
|
+
// Number or 'number'
|
129
|
+
if (settings.limit && /^\d+$/.test(attr[key])) {
|
130
|
+
// Check the limits
|
131
|
+
attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
|
132
|
+
}
|
133
|
+
|
134
|
+
// Don't waste time animating, if there's no need.
|
135
|
+
if (!i && settings.axis.length > 1) {
|
136
|
+
if (prev === attr[key]) {
|
137
|
+
// No animation needed
|
138
|
+
attr = {};
|
139
|
+
} else if (queue) {
|
140
|
+
// Intermediate animation
|
141
|
+
animate(settings.onAfterFirst);
|
142
|
+
// Don't animate this axis again in the next iteration.
|
143
|
+
attr = {};
|
144
|
+
}
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
animate(settings.onAfter);
|
149
|
+
|
150
|
+
function animate(callback) {
|
151
|
+
var opts = $.extend({}, settings, {
|
152
|
+
// The queue setting conflicts with animate()
|
153
|
+
// Force it to always be true
|
154
|
+
queue: true,
|
155
|
+
duration: duration,
|
156
|
+
complete: callback && function() {
|
157
|
+
callback.call(elem, targ, settings);
|
158
|
+
}
|
159
|
+
});
|
160
|
+
$elem.animate(attr, opts);
|
161
|
+
}
|
162
|
+
});
|
163
|
+
};
|
164
|
+
|
165
|
+
// Max scrolling position, works on quirks mode
|
166
|
+
// It only fails (not too badly) on IE, quirks mode.
|
167
|
+
$scrollTo.max = function(elem, axis) {
|
168
|
+
var Dim = axis === 'x' ? 'Width' : 'Height',
|
169
|
+
scroll = 'scroll'+Dim;
|
170
|
+
|
171
|
+
if (!isWin(elem))
|
172
|
+
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
|
173
|
+
|
174
|
+
var size = 'client' + Dim,
|
175
|
+
doc = elem.ownerDocument || elem.document,
|
176
|
+
html = doc.documentElement,
|
177
|
+
body = doc.body;
|
178
|
+
|
179
|
+
return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
|
180
|
+
};
|
181
|
+
|
182
|
+
function both(val) {
|
183
|
+
return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
|
184
|
+
}
|
185
|
+
|
186
|
+
// Add special hooks so that window scroll properties can be animated
|
187
|
+
$.Tween.propHooks.scrollLeft =
|
188
|
+
$.Tween.propHooks.scrollTop = {
|
189
|
+
get: function(t) {
|
190
|
+
return $(t.elem)[t.prop]();
|
191
|
+
},
|
192
|
+
set: function(t) {
|
193
|
+
var curr = this.get(t);
|
194
|
+
// If interrupt is true and user scrolled, stop animating
|
195
|
+
if (t.options.interrupt && t._last && t._last !== curr) {
|
196
|
+
return $(t.elem).stop();
|
197
|
+
}
|
198
|
+
var next = Math.round(t.now);
|
199
|
+
// Don't waste CPU
|
200
|
+
// Browsers don't render floating point scroll
|
201
|
+
if (curr !== next) {
|
202
|
+
$(t.elem)[t.prop](next);
|
203
|
+
t._last = this.get(t);
|
204
|
+
}
|
205
|
+
}
|
206
|
+
};
|
207
|
+
|
208
|
+
// AMD requirement
|
209
|
+
return $scrollTo;
|
210
|
+
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Pattison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -303,6 +303,7 @@ files:
|
|
303
303
|
- app/assets/javascripts/active_admin_pro.js
|
304
304
|
- app/assets/javascripts/active_admin_pro/actions/new.js
|
305
305
|
- app/assets/javascripts/active_admin_pro/actions/show.js
|
306
|
+
- app/assets/javascripts/active_admin_pro/components/autocomplete_input.js
|
306
307
|
- app/assets/javascripts/active_admin_pro/components/codemirror_input.js
|
307
308
|
- app/assets/javascripts/active_admin_pro/components/link.js
|
308
309
|
- app/assets/javascripts/active_admin_pro/components/phone_input.js
|
@@ -317,6 +318,7 @@ files:
|
|
317
318
|
- app/assets/stylesheets/active_admin_pro/breakpoints.scss
|
318
319
|
- app/assets/stylesheets/active_admin_pro/components/_input_variables.scss
|
319
320
|
- app/assets/stylesheets/active_admin_pro/components/actions.scss
|
321
|
+
- app/assets/stylesheets/active_admin_pro/components/autocomplete_input.scss
|
320
322
|
- app/assets/stylesheets/active_admin_pro/components/boolean_input.scss
|
321
323
|
- app/assets/stylesheets/active_admin_pro/components/button.scss
|
322
324
|
- app/assets/stylesheets/active_admin_pro/components/check_boxes_input.scss
|
@@ -468,6 +470,7 @@ files:
|
|
468
470
|
- app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_visual-grid.scss
|
469
471
|
- app/assets/stylesheets/active_admin_pro/vendor/normalize.css
|
470
472
|
- app/assets/stylesheets/codemirror/themes/active_admin_pro.scss
|
473
|
+
- app/inputs/autocomplete_input.rb
|
471
474
|
- app/inputs/codemirror_input.rb
|
472
475
|
- app/inputs/datepicker_input.rb
|
473
476
|
- app/inputs/phone_input.rb
|
@@ -483,6 +486,7 @@ files:
|
|
483
486
|
- lib/generators/active_admin_pro/install_generator.rb
|
484
487
|
- lib/tasks/active_admin_pro_tasks.rake
|
485
488
|
- spec/spec_helper.rb
|
489
|
+
- vendor/assets/javascripts/awesomplete.js
|
486
490
|
- vendor/assets/javascripts/bootstrap.js
|
487
491
|
- vendor/assets/javascripts/codemirror.js
|
488
492
|
- vendor/assets/javascripts/codemirror/addons/comment/comment.js
|
@@ -575,6 +579,7 @@ files:
|
|
575
579
|
- vendor/assets/javascripts/codemirror/modes/yaml.js
|
576
580
|
- vendor/assets/javascripts/intl-tel-input.js
|
577
581
|
- vendor/assets/javascripts/intl-tel-utils.js
|
582
|
+
- vendor/assets/javascripts/jquery.scrollTo.js
|
578
583
|
- vendor/assets/javascripts/slug.js
|
579
584
|
- vendor/assets/javascripts/summernote.js
|
580
585
|
- vendor/assets/stylesheets/codemirror.css
|