push_type_wysiwyg 0.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +20 -0
  3. data/README.md +3 -0
  4. data/app/assets/javascripts/push_type/froala_overrides/file_upload.js +133 -0
  5. data/app/assets/javascripts/push_type/froala_overrides/froala_editor.js +34 -0
  6. data/app/assets/javascripts/push_type/froala_overrides/image_editor.js +215 -0
  7. data/app/assets/javascripts/push_type/froala_overrides/media_manager.js +184 -0
  8. data/app/assets/javascripts/push_type/media_styles.js.coffee.erb +5 -0
  9. data/app/assets/javascripts/push_type/wysiwyg.js.coffee +50 -0
  10. data/app/assets/stylesheets/push_type/froala_overrides.scss +77 -0
  11. data/app/assets/stylesheets/push_type/pt_theme.scss +373 -0
  12. data/app/assets/stylesheets/push_type/wysiwyg.scss +36 -0
  13. data/app/controllers/push_type/wysiwyg_media_controller.rb +43 -0
  14. data/app/fields/push_type/wysiwyg_field.rb +10 -0
  15. data/app/helpers/push_type/wysiwyg_media_helper.rb +34 -0
  16. data/config/routes.rb +3 -0
  17. data/lib/push_type/wysiwyg/engine.rb +16 -0
  18. data/lib/push_type/wysiwyg.rb +14 -0
  19. data/lib/push_type_wysiwyg.rb +2 -0
  20. data/lib/tasks/push_type_tasks.rake +4 -0
  21. data/test/controllers/push_type/wysiwyg_media_controller_test.rb +58 -0
  22. data/test/dummy/README.rdoc +28 -0
  23. data/test/dummy/Rakefile +6 -0
  24. data/test/dummy/app/assets/javascripts/application.js +16 -0
  25. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  26. data/test/dummy/app/controllers/application_controller.rb +5 -0
  27. data/test/dummy/app/helpers/application_helper.rb +2 -0
  28. data/test/dummy/app/models/page.rb +10 -0
  29. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  30. data/test/dummy/app/views/nodes/page.html.erb +3 -0
  31. data/test/dummy/bin/bundle +3 -0
  32. data/test/dummy/bin/rails +4 -0
  33. data/test/dummy/bin/rake +4 -0
  34. data/test/dummy/bin/setup +29 -0
  35. data/test/dummy/config/application.rb +14 -0
  36. data/test/dummy/config/boot.rb +4 -0
  37. data/test/dummy/config/database.yml +85 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +41 -0
  40. data/test/dummy/config/environments/production.rb +79 -0
  41. data/test/dummy/config/environments/test.rb +42 -0
  42. data/test/dummy/config/initializers/assets.rb +11 -0
  43. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  45. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/test/dummy/config/initializers/inflections.rb +16 -0
  47. data/test/dummy/config/initializers/mime_types.rb +4 -0
  48. data/test/dummy/config/initializers/push_type.rb +15 -0
  49. data/test/dummy/config/initializers/session_store.rb +3 -0
  50. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/test/dummy/config/locales/en.yml +23 -0
  52. data/test/dummy/config/routes.rb +59 -0
  53. data/test/dummy/config/secrets.yml +22 -0
  54. data/test/dummy/config.ru +4 -0
  55. data/test/dummy/db/migrate/20150208150336_create_push_type_users.push_type.rb +13 -0
  56. data/test/dummy/db/migrate/20150208150337_create_push_type_nodes.push_type.rb +25 -0
  57. data/test/dummy/db/migrate/20150208150338_create_push_type_node_hierarchies.push_type.rb +17 -0
  58. data/test/dummy/db/migrate/20150208150339_create_push_type_assets.push_type.rb +19 -0
  59. data/test/dummy/db/schema.rb +67 -0
  60. data/test/dummy/db/seeds.rb +7 -0
  61. data/test/dummy/log/test.log +1309 -0
  62. data/test/dummy/public/404.html +67 -0
  63. data/test/dummy/public/422.html +67 -0
  64. data/test/dummy/public/500.html +66 -0
  65. data/test/dummy/public/favicon.ico +0 -0
  66. data/test/dummy/public/robots.txt +5 -0
  67. data/test/dummy/tmp/cache/assets/test/sprockets/0a170bcd46595a69e9181ea5eb52ec6f +0 -0
  68. data/test/dummy/tmp/cache/assets/test/sprockets/853c1095ab6e7f4eba1f3406f0f3bba6 +0 -0
  69. data/test/helpers/push_type/wysiwyg_media_helper_test.rb +41 -0
  70. data/test/models/push_type/wysiwyg_field_test.rb +9 -0
  71. data/test/test_helper.rb +21 -0
  72. data/vendor/assets/javascripts/jquery.simplePagination.js +334 -0
  73. metadata +252 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,41 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe WysiwygMediaHelper do
5
+
6
+ describe '#wysiwyg_assets_hash' do
7
+ let(:assets) { PushType::Asset.page(1).per(2) }
8
+ before { 4.times { FactoryGirl.create :image_asset } }
9
+ subject { wysiwyg_assets_hash(assets) }
10
+ it { subject.must_be_instance_of Hash }
11
+ it { subject.key?(:assets).must_equal true }
12
+ it { subject.key?(:meta).must_equal true }
13
+ it { subject[:assets].must_be_instance_of Array }
14
+ it { subject[:assets].size.must_equal 2 }
15
+ end
16
+
17
+ describe '#wysiwyg_assets_meta' do
18
+ let(:assets) { PushType::Asset.page(1).per(2) }
19
+ before { 4.times { FactoryGirl.create :image_asset } }
20
+ subject { wysiwyg_assets_meta(assets) }
21
+ it { subject.must_be_instance_of Hash }
22
+ it { subject.key?(:current_page).must_equal true }
23
+ it { subject.key?(:total_pages).must_equal true }
24
+ it { subject[:current_page].must_equal 1 }
25
+ it { subject[:total_pages].must_equal 2 }
26
+ end
27
+
28
+ describe '#wysiwyg_asset_hash' do
29
+ let(:asset) { FactoryGirl.create :image_asset }
30
+ subject { wysiwyg_asset_hash(asset) }
31
+ it { subject.must_be_instance_of Hash }
32
+ it { subject.key?(:src).must_equal true }
33
+ it { subject.key?(:info).must_equal true }
34
+ it { subject[:info].key?(:id).must_equal true }
35
+ it { subject[:info].key?(:src).must_equal true }
36
+ it { subject[:info].key?(:kind).must_equal true }
37
+ it { subject[:info].key?(:title).must_equal true }
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe WysiwygField do
5
+ let(:field) { PushType::WysiwygField.new :foo }
6
+ it { field.form_helper.must_equal :text_area }
7
+ it { field.html_options[:class].must_equal 'froala' }
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
3
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
4
+ #ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
5
+ require "rails/test_help"
6
+ require "minitest/rails"
7
+
8
+ # To add Capybara feature tests add `gem "minitest-rails-capybara"`
9
+ # to the test group in the Gemfile and uncomment the following:
10
+ # require "minitest/rails/capybara"
11
+
12
+ # Uncomment for awesome colorful output
13
+ require 'minitest/pride'
14
+
15
+ # Require PushType testing setup
16
+ require 'push_type/testing/setup'
17
+ require 'push_type/testing/factories'
18
+
19
+ # Load support files
20
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
+
@@ -0,0 +1,334 @@
1
+ /**
2
+ * simplePagination.js v1.6
3
+ * A simple jQuery pagination plugin.
4
+ * http://flaviusmatis.github.com/simplePagination.js/
5
+ *
6
+ * Copyright 2012, Flavius Matis
7
+ * Released under the MIT license.
8
+ * http://flaviusmatis.github.com/license.html
9
+ */
10
+
11
+ (function($){
12
+
13
+ var methods = {
14
+ init: function(options) {
15
+ var o = $.extend({
16
+ items: 1,
17
+ itemsOnPage: 1,
18
+ pages: 0,
19
+ displayedPages: 5,
20
+ edges: 2,
21
+ currentPage: 0,
22
+ hrefTextPrefix: '#page-',
23
+ hrefTextSuffix: '',
24
+ prevText: 'Prev',
25
+ nextText: 'Next',
26
+ ellipseText: '&hellip;',
27
+ cssStyle: 'light-theme',
28
+ labelMap: [],
29
+ selectOnClick: true,
30
+ nextAtFront: false,
31
+ invertPageOrder: false,
32
+ useStartEdge : true,
33
+ useEndEdge : true,
34
+ onPageClick: function(pageNumber, event) {
35
+ // Callback triggered when a page is clicked
36
+ // Page number is given as an optional parameter
37
+ },
38
+ onInit: function() {
39
+ // Callback triggered immediately after initialization
40
+ }
41
+ }, options || {});
42
+
43
+ var self = this;
44
+
45
+ o.pages = o.pages ? o.pages : Math.ceil(o.items / o.itemsOnPage) ? Math.ceil(o.items / o.itemsOnPage) : 1;
46
+ if (o.currentPage)
47
+ o.currentPage = o.currentPage - 1;
48
+ else
49
+ o.currentPage = !o.invertPageOrder ? 0 : o.pages - 1;
50
+ o.halfDisplayed = o.displayedPages / 2;
51
+
52
+ this.each(function() {
53
+ self.addClass(o.cssStyle + ' simple-pagination').data('pagination', o);
54
+ methods._draw.call(self);
55
+ });
56
+
57
+ o.onInit();
58
+
59
+ return this;
60
+ },
61
+
62
+ selectPage: function(page) {
63
+ methods._selectPage.call(this, page - 1);
64
+ return this;
65
+ },
66
+
67
+ prevPage: function() {
68
+ var o = this.data('pagination');
69
+ if (!o.invertPageOrder) {
70
+ if (o.currentPage > 0) {
71
+ methods._selectPage.call(this, o.currentPage - 1);
72
+ }
73
+ } else {
74
+ if (o.currentPage < o.pages - 1) {
75
+ methods._selectPage.call(this, o.currentPage + 1);
76
+ }
77
+ }
78
+ return this;
79
+ },
80
+
81
+ nextPage: function() {
82
+ var o = this.data('pagination');
83
+ if (!o.invertPageOrder) {
84
+ if (o.currentPage < o.pages - 1) {
85
+ methods._selectPage.call(this, o.currentPage + 1);
86
+ }
87
+ } else {
88
+ if (o.currentPage > 0) {
89
+ methods._selectPage.call(this, o.currentPage - 1);
90
+ }
91
+ }
92
+ return this;
93
+ },
94
+
95
+ getPagesCount: function() {
96
+ return this.data('pagination').pages;
97
+ },
98
+
99
+ getCurrentPage: function () {
100
+ return this.data('pagination').currentPage + 1;
101
+ },
102
+
103
+ destroy: function(){
104
+ this.empty();
105
+ return this;
106
+ },
107
+
108
+ drawPage: function (page) {
109
+ var o = this.data('pagination');
110
+ o.currentPage = page - 1;
111
+ this.data('pagination', o);
112
+ methods._draw.call(this);
113
+ return this;
114
+ },
115
+
116
+ redraw: function(){
117
+ methods._draw.call(this);
118
+ return this;
119
+ },
120
+
121
+ disable: function(){
122
+ var o = this.data('pagination');
123
+ o.disabled = true;
124
+ this.data('pagination', o);
125
+ methods._draw.call(this);
126
+ return this;
127
+ },
128
+
129
+ enable: function(){
130
+ var o = this.data('pagination');
131
+ o.disabled = false;
132
+ this.data('pagination', o);
133
+ methods._draw.call(this);
134
+ return this;
135
+ },
136
+
137
+ updateItems: function (newItems) {
138
+ var o = this.data('pagination');
139
+ o.items = newItems;
140
+ o.pages = methods._getPages(o);
141
+ this.data('pagination', o);
142
+ methods._draw.call(this);
143
+ },
144
+
145
+ updateItemsOnPage: function (itemsOnPage) {
146
+ var o = this.data('pagination');
147
+ o.itemsOnPage = itemsOnPage;
148
+ o.pages = methods._getPages(o);
149
+ this.data('pagination', o);
150
+ methods._selectPage.call(this, 0);
151
+ return this;
152
+ },
153
+
154
+ _draw: function() {
155
+ var o = this.data('pagination'),
156
+ interval = methods._getInterval(o),
157
+ i,
158
+ tagName;
159
+
160
+ methods.destroy.call(this);
161
+
162
+ tagName = (typeof this.prop === 'function') ? this.prop('tagName') : this.attr('tagName');
163
+
164
+ var $panel = tagName === 'UL' ? this : $('<ul class="pagination"></ul>').appendTo(this);
165
+
166
+ // Generate Prev link
167
+ if (o.prevText) {
168
+ methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage - 1 : o.currentPage + 1, {text: o.prevText, classes: 'prev'});
169
+ }
170
+
171
+ // Generate Next link (if option set for at front)
172
+ if (o.nextText && o.nextAtFront) {
173
+ methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage + 1 : o.currentPage - 1, {text: o.nextText, classes: 'next'});
174
+ }
175
+
176
+ // Generate start edges
177
+ if (!o.invertPageOrder) {
178
+ if (interval.start > 0 && o.edges > 0) {
179
+ if(o.useStartEdge) {
180
+ var end = Math.min(o.edges, interval.start);
181
+ for (i = 0; i < end; i++) {
182
+ methods._appendItem.call(this, i);
183
+ }
184
+ }
185
+ if (o.edges < interval.start && (interval.start - o.edges != 1)) {
186
+ $panel.append('<li class="unavailable"><span class="ellipse">' + o.ellipseText + '</span></li>');
187
+ } else if (interval.start - o.edges == 1) {
188
+ methods._appendItem.call(this, o.edges);
189
+ }
190
+ }
191
+ } else {
192
+ if (interval.end < o.pages && o.edges > 0) {
193
+ if(o.useStartEdge) {
194
+ var begin = Math.max(o.pages - o.edges, interval.end);
195
+ for (i = o.pages - 1; i >= begin; i--) {
196
+ methods._appendItem.call(this, i);
197
+ }
198
+ }
199
+
200
+ if (o.pages - o.edges > interval.end && (o.pages - o.edges - interval.end != 1)) {
201
+ $panel.append('<li class="unavailable"><span class="ellipse">' + o.ellipseText + '</span></li>');
202
+ } else if (o.pages - o.edges - interval.end == 1) {
203
+ methods._appendItem.call(this, interval.end);
204
+ }
205
+ }
206
+ }
207
+
208
+ // Generate interval links
209
+ if (!o.invertPageOrder) {
210
+ for (i = interval.start; i < interval.end; i++) {
211
+ methods._appendItem.call(this, i);
212
+ }
213
+ } else {
214
+ for (i = interval.end - 1; i >= interval.start; i--) {
215
+ methods._appendItem.call(this, i);
216
+ }
217
+ }
218
+
219
+ // Generate end edges
220
+ if (!o.invertPageOrder) {
221
+ if (interval.end < o.pages && o.edges > 0) {
222
+ if (o.pages - o.edges > interval.end && (o.pages - o.edges - interval.end != 1)) {
223
+ $panel.append('<li class="unavailable"><span class="ellipse">' + o.ellipseText + '</span></li>');
224
+ } else if (o.pages - o.edges - interval.end == 1) {
225
+ methods._appendItem.call(this, interval.end);
226
+ }
227
+ if(o.useEndEdge) {
228
+ var begin = Math.max(o.pages - o.edges, interval.end);
229
+ for (i = begin; i < o.pages; i++) {
230
+ methods._appendItem.call(this, i);
231
+ }
232
+ }
233
+ }
234
+ } else {
235
+ if (interval.start > 0 && o.edges > 0) {
236
+ if (o.edges < interval.start && (interval.start - o.edges != 1)) {
237
+ $panel.append('<li class="unavailable"><span class="ellipse">' + o.ellipseText + '</span></li>');
238
+ } else if (interval.start - o.edges == 1) {
239
+ methods._appendItem.call(this, o.edges);
240
+ }
241
+
242
+ if(o.useEndEdge) {
243
+ var end = Math.min(o.edges, interval.start);
244
+ for (i = end - 1; i >= 0; i--) {
245
+ methods._appendItem.call(this, i);
246
+ }
247
+ }
248
+ }
249
+ }
250
+
251
+ // Generate Next link (unless option is set for at front)
252
+ if (o.nextText && !o.nextAtFront) {
253
+ methods._appendItem.call(this, !o.invertPageOrder ? o.currentPage + 1 : o.currentPage - 1, {text: o.nextText, classes: 'next'});
254
+ }
255
+ },
256
+
257
+ _getPages: function(o) {
258
+ var pages = Math.ceil(o.items / o.itemsOnPage);
259
+ return pages || 1;
260
+ },
261
+
262
+ _getInterval: function(o) {
263
+ return {
264
+ start: Math.ceil(o.currentPage > o.halfDisplayed ? Math.max(Math.min(o.currentPage - o.halfDisplayed, (o.pages - o.displayedPages)), 0) : 0),
265
+ end: Math.ceil(o.currentPage > o.halfDisplayed ? Math.min(o.currentPage + o.halfDisplayed, o.pages) : Math.min(o.displayedPages, o.pages))
266
+ };
267
+ },
268
+
269
+ _appendItem: function(pageIndex, opts) {
270
+ var self = this, options, $link, o = self.data('pagination'), $linkWrapper = $('<li></li>'), $ul = self.find('ul');
271
+
272
+ pageIndex = pageIndex < 0 ? 0 : (pageIndex < o.pages ? pageIndex : o.pages - 1);
273
+
274
+ options = {
275
+ text: pageIndex + 1,
276
+ classes: ''
277
+ };
278
+
279
+ if (o.labelMap.length && o.labelMap[pageIndex]) {
280
+ options.text = o.labelMap[pageIndex];
281
+ }
282
+
283
+ options = $.extend(options, opts || {});
284
+
285
+ if (pageIndex == o.currentPage || o.disabled) {
286
+ if (o.disabled || options.text == o.prevText || options.text == o.nextText) {
287
+ $linkWrapper.addClass('unavailable');
288
+ } else {
289
+ $linkWrapper.addClass('current');
290
+ }
291
+ }
292
+ $link = $('<a href="' + o.hrefTextPrefix + (pageIndex + 1) + o.hrefTextSuffix + '" class="page-link">' + (options.text) + '</a>');
293
+ $link.click(function(event){
294
+ return methods._selectPage.call(self, pageIndex, event);
295
+ });
296
+
297
+ if (options.classes) {
298
+ $link.addClass(options.classes);
299
+ }
300
+
301
+ $linkWrapper.append($link);
302
+
303
+ if ($ul.length) {
304
+ $ul.append($linkWrapper);
305
+ } else {
306
+ self.append($linkWrapper);
307
+ }
308
+ },
309
+
310
+ _selectPage: function(pageIndex, event) {
311
+ var o = this.data('pagination');
312
+ o.currentPage = pageIndex;
313
+ if (o.selectOnClick) {
314
+ methods._draw.call(this);
315
+ }
316
+ return o.onPageClick(pageIndex + 1, event);
317
+ }
318
+
319
+ };
320
+
321
+ $.fn.pagination = function(method) {
322
+
323
+ // Method calling logic
324
+ if (methods[method] && method.charAt(0) != '_') {
325
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
326
+ } else if (typeof method === 'object' || !method) {
327
+ return methods.init.apply(this, arguments);
328
+ } else {
329
+ $.error('Method ' + method + ' does not exist on jQuery.pagination');
330
+ }
331
+
332
+ };
333
+
334
+ })(jQuery);