caboose-cms 0.5.71 → 0.5.72
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/model/pager.js +0 -99
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGRkNDQ2ZDUzY2RlZWQ5MWY0NjQ0Zjg3ZjI5YWJlNDE0MGIyZmY4NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGU0ODY2NzA2MDQ5NzdmZWUxYzMxNzM3OTBiMDJiMzA1Mjc4YzYwNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjU2NDc4ODljYjA1MjM0N2JiYmU1N2JiNzZlNjFhMTViZDQ5NjBmMjhlMzcy
|
10
|
+
YjQwYmMzNmIzYjVjZGMyZjdhY2U3NjhlYWFhNzdmN2VmMzkzMDc5YzUzNzFi
|
11
|
+
ZjhlZjZhZjJhMThhODRjYWQ0NTRjNjVhZGU0ZjAyYzAwMTc4Y2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzYyODdiOWJkODRkYWJhMWM3OGJlOTYzZTgyOTY5YWM0ZTc1MjAyMzk2M2Jk
|
14
|
+
NGFkM2E4YWE0ZjA2OTNmYzdjMjAyMTk0MTJmMWYzZjk5ZGY1ZmJjOGIzNWEy
|
15
|
+
Y2M5YjgxZmJjNTRmYjEwNTViNmRlYzAzZTYyNzRiZmExMzc0Y2Q=
|
@@ -1,99 +0,0 @@
|
|
1
|
-
|
2
|
-
var Pager = function(params) { this.init(params); }
|
3
|
-
Pager.prototype = {
|
4
|
-
|
5
|
-
base_url: '',
|
6
|
-
sort: '',
|
7
|
-
desc: false,
|
8
|
-
item_count: 0,
|
9
|
-
items_per_page: 10,
|
10
|
-
page: 1,
|
11
|
-
use_url_params: false,
|
12
|
-
|
13
|
-
init: function(params)
|
14
|
-
{
|
15
|
-
for (var thing in params)
|
16
|
-
this[thing] = params[thing];
|
17
|
-
}
|
18
|
-
|
19
|
-
// Paramters:
|
20
|
-
// cols: Hash { key = sort field, value = text to display }
|
21
|
-
sortable_table_headings: function(cols)
|
22
|
-
{
|
23
|
-
var that = this;
|
24
|
-
this.base_url += this.base_url.indexOf('?') > -1 ? '&' : '?';
|
25
|
-
var str = '';
|
26
|
-
|
27
|
-
var tr = $('<tr/>');
|
28
|
-
$.each(cols, function(sort, text) {
|
29
|
-
var arrow = that.sort == sort ? (that.desc == 1 ? ' ↑' : ' ↓') : '';
|
30
|
-
var link = that.base_url + 'sort=' + sort + '&desc=' + (that.desc == 1 ? '0' : '1');
|
31
|
-
tr.append($('<th/>').append(
|
32
|
-
str += "<th><a href='#{link}'>#{text}#{arrow}</a></th>\n"
|
33
|
-
end
|
34
|
-
return str
|
35
|
-
end
|
36
|
-
|
37
|
-
def generate(summary = true)
|
38
|
-
|
39
|
-
# Check for necessary parameter values
|
40
|
-
return false if !ok(@options['base_url']) # Error: base_url is required for the page bar generator to work.
|
41
|
-
return false if !ok(@options['item_count']) # Error: itemCount is required for the page bar generator to work.
|
42
|
-
|
43
|
-
# Set default parameter values if not present
|
44
|
-
@options['items_per_page'] = 10 if @options["items_per_page"].nil?
|
45
|
-
@options['page'] = 1 if @options["page"].nil?
|
46
|
-
|
47
|
-
page = @options["page"].to_i
|
48
|
-
|
49
|
-
# Max links to show (must be odd)
|
50
|
-
total_links = 5
|
51
|
-
prev_page = page - 1
|
52
|
-
next_page = page + 1
|
53
|
-
total_pages = (@options['item_count'].to_f / @options['items_per_page'].to_f).ceil
|
54
|
-
|
55
|
-
if (total_pages < total_links)
|
56
|
-
start = 1
|
57
|
-
stop = total_pages
|
58
|
-
else
|
59
|
-
start = page - (total_links/2).floor
|
60
|
-
start = 1 if start < 1
|
61
|
-
stop = start + total_links - 1
|
62
|
-
|
63
|
-
if (stop > total_pages)
|
64
|
-
stop = total_pages
|
65
|
-
start = stop - total_links
|
66
|
-
start = 1 if start < 1
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
base_url = url_with_vars
|
71
|
-
base_url << (@use_url_params ? "/" : (base_url.include?("?") ? "&" : "?"))
|
72
|
-
keyval_delim = @use_url_params ? "/" : "="
|
73
|
-
var_delim = @use_url_params ? "/" : "&"
|
74
|
-
|
75
|
-
str = ''
|
76
|
-
str << "<p>Results: showing page #{page} of #{total_pages}</p>\n" if summary
|
77
|
-
|
78
|
-
if (total_pages > 1)
|
79
|
-
str << "<div class='page_links'>\n"
|
80
|
-
if (page > 1)
|
81
|
-
str << "<a href='#{base_url}page#{keyval_delim}#{prev_page}'>Previous</a>"
|
82
|
-
end
|
83
|
-
for i in start..stop
|
84
|
-
if (page != i)
|
85
|
-
str << "<a href='#{base_url}page#{keyval_delim}#{i}'>#{i}</a>"
|
86
|
-
else
|
87
|
-
str << "<span class='current_page'>#{i}</span>"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
if (page < total_pages)
|
91
|
-
str << "<a href='#{base_url}page#{keyval_delim}#{next_page}'>Next</a>"
|
92
|
-
end
|
93
|
-
str << "</div>\n"
|
94
|
-
end
|
95
|
-
|
96
|
-
return str
|
97
|
-
end
|
98
|
-
|
99
|
-
};
|
data/lib/caboose/version.rb
CHANGED