alchemy_cms 2.4.rc2 → 2.4.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitignore +2 -1
  2. data/.travis.yml +7 -4
  3. data/README.md +1 -0
  4. data/alchemy_cms.gemspec +19 -1
  5. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +5 -2
  6. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +1 -1
  7. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +4 -21
  8. data/app/assets/javascripts/alchemy/alchemy.windows.js +0 -1
  9. data/app/assets/stylesheets/alchemy/base.scss +4 -0
  10. data/app/assets/stylesheets/alchemy/elements.scss +59 -60
  11. data/app/assets/stylesheets/alchemy/flash.scss +3 -3
  12. data/app/assets/stylesheets/alchemy/form_elements.scss +15 -2
  13. data/app/assets/stylesheets/alchemy/jquery-ui.scss +11 -3
  14. data/app/assets/stylesheets/alchemy/mixins.scss +9 -0
  15. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  16. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +4 -0
  17. data/app/assets/stylesheets/alchemy/variables.scss +5 -1
  18. data/app/controllers/alchemy/admin/base_controller.rb +18 -3
  19. data/app/controllers/alchemy/admin/elements_controller.rb +4 -7
  20. data/app/controllers/alchemy/admin/pages_controller.rb +3 -4
  21. data/app/controllers/alchemy/admin/resources_controller.rb +1 -18
  22. data/app/controllers/alchemy/admin/users_controller.rb +8 -5
  23. data/app/helpers/alchemy/admin/pages_helper.rb +6 -1
  24. data/app/models/alchemy/content.rb +26 -5
  25. data/app/models/alchemy/element.rb +1 -0
  26. data/app/models/alchemy/essence_richtext.rb +1 -1
  27. data/app/models/alchemy/page.rb +131 -88
  28. data/app/views/alchemy/admin/clipboard/insert.js.erb +1 -1
  29. data/app/views/alchemy/admin/elements/create.js.erb +6 -1
  30. data/app/views/alchemy/admin/elements/trash.js.erb +1 -3
  31. data/app/views/alchemy/admin/resources/_form.html.erb +13 -1
  32. data/app/views/alchemy/admin/trash/index.html.erb +1 -1
  33. data/app/views/alchemy/base/remote_errors.js.erb +5 -1
  34. data/app/views/alchemy/essences/_essence_link_view.html.erb +2 -0
  35. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
  36. data/config/locales/alchemy.de.yml +11 -4
  37. data/lib/alchemy/capistrano.rb +59 -1
  38. data/lib/alchemy/essence.rb +1 -0
  39. data/lib/alchemy/seeder.rb +39 -49
  40. data/lib/alchemy/tinymce.rb +1 -1
  41. data/lib/alchemy/version.rb +1 -1
  42. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +1 -1
  43. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +3 -0
  44. data/lib/rails/generators/alchemy/elements/templates/view.html.haml +2 -2
  45. data/lib/rails/generators/alchemy/elements/templates/view.html.slim +2 -2
  46. data/lib/tasks/database.rake +25 -0
  47. data/lib/tasks/install.rake +5 -14
  48. data/spec/factories.rb +10 -0
  49. data/spec/integration/admin/resources_integration_spec.rb +64 -23
  50. data/spec/integration/pages_controller_spec.rb +0 -2
  51. data/spec/libraries/resources_helper_spec.rb +6 -2
  52. data/spec/models/content_spec.rb +31 -0
  53. data/spec/models/element_spec.rb +7 -2
  54. data/spec/models/page_spec.rb +36 -0
  55. data/vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.1_0_1.js +676 -0
  56. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +298 -238
  57. data/vendor/assets/javascripts/tiny_mce/langs/de.js +1 -1
  58. data/vendor/assets/javascripts/tiny_mce/langs/en.js +1 -1
  59. data/vendor/assets/javascripts/tiny_mce/license.txt +6 -6
  60. data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +1 -1
  61. data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +97 -97
  62. data/vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/template.htm +376 -386
  63. data/vendor/assets/javascripts/tiny_mce/plugins/paste/editor_plugin.js +1 -1
  64. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pastetext.js +30 -30
  65. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pasteword.js +45 -45
  66. data/vendor/assets/javascripts/tiny_mce/plugins/paste/langs/de_dlg.js +1 -1
  67. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pastetext.htm +17 -20
  68. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pasteword.htm +12 -12
  69. data/vendor/assets/javascripts/tiny_mce/plugins/table/cell.htm +173 -183
  70. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/cell.css +4 -4
  71. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/row.css +7 -7
  72. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/table.css +3 -3
  73. data/vendor/assets/javascripts/tiny_mce/plugins/table/editor_plugin.js +1 -1
  74. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/cell.js +280 -282
  75. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/merge_cells.js +15 -15
  76. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/row.js +221 -204
  77. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/table.js +448 -435
  78. data/vendor/assets/javascripts/tiny_mce/plugins/table/langs/de_dlg.js +1 -1
  79. data/vendor/assets/javascripts/tiny_mce/plugins/table/merge_cells.htm +22 -24
  80. data/vendor/assets/javascripts/tiny_mce/plugins/table/row.htm +136 -144
  81. data/vendor/assets/javascripts/tiny_mce/plugins/table/table.htm +168 -184
  82. data/vendor/assets/javascripts/tiny_mce/themes/advanced/about.htm +46 -62
  83. data/vendor/assets/javascripts/tiny_mce/themes/advanced/anchor.htm +16 -17
  84. data/vendor/assets/javascripts/tiny_mce/themes/advanced/charmap.htm +47 -56
  85. data/vendor/assets/javascripts/tiny_mce/themes/advanced/color_picker.htm +52 -69
  86. data/vendor/assets/javascripts/tiny_mce/themes/advanced/editor_template.js +1 -852
  87. data/vendor/assets/javascripts/tiny_mce/themes/advanced/image.htm +69 -79
  88. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
  89. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/about.js +48 -48
  90. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/anchor.js +50 -37
  91. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/charmap.js +317 -317
  92. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/color_picker.js +345 -331
  93. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/image.js +248 -246
  94. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/link.js +152 -146
  95. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/source_editor.js +53 -31
  96. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de.js +1 -1
  97. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +1 -1
  98. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en.js +1 -1
  99. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +1 -1
  100. data/vendor/assets/javascripts/tiny_mce/themes/advanced/link.htm +46 -53
  101. data/vendor/assets/javascripts/tiny_mce/themes/advanced/shortcuts.htm +45 -57
  102. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/content.css +47 -182
  103. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +93 -399
  104. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +191 -890
  105. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/content.css +24 -102
  106. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +79 -377
  107. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/ui.css +80 -451
  108. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +45 -167
  109. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +93 -399
  110. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +194 -889
  111. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +7 -33
  112. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +4 -15
  113. data/vendor/assets/javascripts/tiny_mce/themes/advanced/source_editor.htm +16 -19
  114. data/vendor/assets/javascripts/tiny_mce/tiny_mce.js +1 -1
  115. data/vendor/assets/javascripts/tiny_mce/tiny_mce_popup.js +1 -1
  116. data/vendor/assets/javascripts/tiny_mce/utils/editable_selects.js +46 -46
  117. data/vendor/assets/javascripts/tiny_mce/utils/form_utils.js +124 -124
  118. data/vendor/assets/javascripts/tiny_mce/utils/mctabs.js +112 -112
  119. data/vendor/assets/javascripts/tiny_mce/utils/validate.js +213 -213
  120. metadata +11 -6
  121. data/spec/dummy/public/404.html.bak +0 -26
  122. data/vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.min.js +0 -8
@@ -1,263 +1,255 @@
1
1
  /*
2
- Copyright (c) 2009, http://seyfertdesign.com/jquery/ui-tabs-paging.html
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in
12
- all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- THE SOFTWARE.
2
+ * UI Tabs Paging extension - v1.2 (for jQuery 1.8.2 and jQuery UI 1.9.0)
3
+ *
4
+ * Copyright (c) 2012, http://seyfertdesign.com/jquery/ui-tabs-paging.html
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * Depends:
25
+ * jquery.ui.core.js
26
+ * jquery.ui.widget.js
27
+ * jquery.ui.tabs.js
21
28
  */
22
29
 
23
- (function ($) {
24
-
25
- $.extend($.ui.tabs.prototype, {
26
- paging:function (options) {
27
- var opts = {
28
- tabsPerPage:0,
29
- nextButton:'»',
30
- prevButton:'«',
31
- follow:false,
32
- cycle:false,
33
- selectOnAdd:false,
34
- followOnSelect:false
35
- };
36
-
37
- opts = $.extend(opts, options);
38
-
39
- var self = this, initialized = false, currentPage,
40
- buttonWidth, containerWidth, allTabsWidth, tabWidths,
41
- maxPageWidth, pages, resizeTimer = null,
42
- windowHeight = $(window).height(), windowWidth = $(window).width();
43
-
44
- function init() {
45
- destroy();
30
+ (function($) {
31
+
32
+ // overridden ui.tabs functions
33
+ var uiTabsFuncs = {
34
+ refresh: $.ui.tabs.prototype.refresh,
35
+ option: $.ui.tabs.prototype.option
36
+ };
37
+
38
+ // DEPRECATED in jQuery UI 1.9
39
+ if ( $.uiBackCompat !== false ) {
40
+ uiTabsFuncs = $.extend(
41
+ uiTabsFuncs,
42
+ {
43
+ add: $.ui.tabs.prototype.add,
44
+ remove: $.ui.tabs.prototype.remove
45
+ }
46
+ );
47
+ }
48
+
49
+ $.extend($.ui.tabs.prototype, {
50
+ paging: function(options) {
51
+ var opts = {
52
+ tabsPerPage: 0, // Max number of tabs to display at one time. 0 automatically sizing.
53
+ nextButton: '»', // Text displayed for next button.
54
+ prevButton: '«', // Text displayed for previous button.
55
+ follow: false, // When clicking next button, automatically make first tab active. When clicking previous button automatically make last tab active.
56
+ cycle: false, // When at end of list, next button returns to first page. When at beginning of list previous button goes to end of list.
57
+ activeOnAdd: false, // When new tab is added, make tab active automatically
58
+ followOnActive: false // When tab is changed to active, automatically go move to that tab group.
59
+ };
60
+
61
+ opts = $.extend(opts, options);
62
+
63
+ var self = this, initialized = false, currentPage,
64
+ buttonWidth, containerWidth, allTabsWidth, tabWidths,
65
+ maxPageWidth, pages, resizeTimer = null,
66
+ windowHeight, windowWidth;
67
+
68
+ // initialize paging
69
+ function init() {
70
+ destroy();
71
+
72
+ windowHeight = $(window).height();
73
+ windowWidth = $(window).width();
74
+
75
+ allTabsWidth = 0, currentPage = 0, maxPageWidth = 0, buttonWidth = 0,
76
+ pages = new Array(), tabWidths = new Array(), selectedTabWidths = new Array();
77
+
78
+ containerWidth = self.element.width();
79
+
80
+ // loops through LIs, get width of each tab when selected and unselected.
81
+ var maxDiff = 0; // the max difference between a selected and unselected tab
82
+ self.tabs.each(function(i) {
83
+ if (i == self.options.active) {
84
+ selectedTabWidths[i] = $(this).outerWidth(true);
85
+ tabWidths[i] = self.tabs.eq(i).removeClass('ui-tabs-active').outerWidth(true);
86
+ self.tabs.eq(i).addClass('ui-tabs-active');
87
+ maxDiff = Math.min(maxDiff, Math.abs(selectedTabWidths[i] - tabWidths[i]));
88
+ allTabsWidth += tabWidths[i];
89
+ } else {
90
+ tabWidths[i] = $(this).outerWidth(true);
91
+ selectedTabWidths[i] = self.tabs.eq(i).addClass('ui-tabs-active').outerWidth(true);
92
+ self.tabs.eq(i).removeClass('ui-tabs-active');
93
+ maxDiff = Math.max(maxDiff, Math.abs(selectedTabWidths[i] - tabWidths[i]));
94
+ allTabsWidth += tabWidths[i];
95
+ }
96
+ });
46
97
 
47
- allTabsWidth = 0, currentPage = 0, maxPageWidth = 0, buttonWidth = 0,
48
- pages = new Array(), tabWidths = new Array(), selectedTabWidths = new Array();
49
-
50
- containerWidth = self.element.width();
51
-
52
- // loops through LIs, get width of each tab when selected and unselected.
53
- var maxDiff = 0; // the max difference between a selected and unselected tab
54
- self.lis.each(function (i) {
55
- if (i == self.options.selected) {
56
- selectedTabWidths[i] = $(this).outerWidth(true);
57
- tabWidths[i] = self.lis.eq(i).removeClass('ui-tabs-selected').outerWidth(true);
58
- self.lis.eq(i).addClass('ui-tabs-selected');
59
- maxDiff = Math.min(maxDiff, Math.abs(selectedTabWidths[i] - tabWidths[i]));
60
- allTabsWidth += tabWidths[i];
61
- } else {
62
- tabWidths[i] = $(this).outerWidth(true);
63
- selectedTabWidths[i] = self.lis.eq(i).addClass('ui-tabs-selected').outerWidth(true);
64
- self.lis.eq(i).removeClass('ui-tabs-selected');
65
- maxDiff = Math.max(maxDiff, Math.abs(selectedTabWidths[i] - tabWidths[i]));
66
- allTabsWidth += tabWidths[i];
67
- }
68
- });
69
- // fix padding issues with buttons
70
- // TODO determine a better way to handle this
71
- allTabsWidth += maxDiff + ($.browser.msie ? 4 : 0) + 9;
72
-
73
- // if the width of all tables is greater than the container's width, calculate the pages
74
- if (allTabsWidth > containerWidth) {
75
- // create next button
76
- li = $('<li></li>')
77
- .addClass('ui-state-default ui-tabs-paging-next')
78
- .append($('<a href="#"></a>')
79
- .click(function () {
80
- page('next');
81
- return false;
82
- })
83
- .html(opts.nextButton));
84
-
85
- self.lis.eq(self.length() - 1).after(li);
86
- buttonWidth = li.outerWidth(true);
87
-
88
- // create prev button
89
- li = $('<li></li>')
90
- .addClass('ui-state-default ui-tabs-paging-prev')
91
- .append($('<a href="#"></a>')
92
- .click(function () {
93
- page('prev');
94
- return false;
95
- })
96
- .html(opts.prevButton));
97
- self.lis.eq(0).before(li);
98
- buttonWidth += li.outerWidth(true);
99
-
100
- // TODO determine fix for padding issues to next button
101
- buttonWidth += 19;
102
-
103
- var pageIndex = 0, pageWidth = 0, maxTabPadding = 0;
104
-
105
- // start calculating pageWidths
106
- for (var i = 0; i < tabWidths.length; i++) {
107
- // if first tab of page or selected tab's padding larger than the current max, set the maxTabPadding
108
- if (pageWidth == 0 || selectedTabWidths[i] - tabWidths[i] > maxTabPadding)
109
- maxTabPadding = (selectedTabWidths[i] - tabWidths[i]);
110
-
111
- // if first tab of page, initialize pages variable for page
112
- if (pages[pageIndex] == null) {
113
- pages[pageIndex] = { start:i };
114
-
115
- } else if ((i > 0 && (i % opts.tabsPerPage) == 0) || (tabWidths[i] + pageWidth + buttonWidth + 12) > containerWidth) {
116
- if ((pageWidth + maxTabPadding) > maxPageWidth)
117
- maxPageWidth = (pageWidth + maxTabPadding);
118
- pageIndex++;
119
- pages[pageIndex] = { start:i };
120
- pageWidth = 0;
121
- }
122
- pages[pageIndex].end = i + 1;
123
- pageWidth += tabWidths[i];
124
- if (i == self.options.selected) currentPage = pageIndex;
98
+ // fix padding issues with buttons
99
+ // TODO determine a better way to handle this
100
+ allTabsWidth += maxDiff + ($.browser.msie?4:0) + 9;
101
+
102
+ // if the width of all tables is greater than the container's width, calculate the pages
103
+ if (allTabsWidth > containerWidth) {
104
+ // create next button
105
+ li = $('<li></li>')
106
+ .addClass('ui-state-default ui-tabs-paging-next')
107
+ .append($('<a href="#"></a>')
108
+ .click(function() { page('next'); return false; })
109
+ .html(opts.nextButton));
110
+
111
+ self.tablist.append(li);
112
+ buttonWidth = li.outerWidth(true);
113
+
114
+ // create prev button
115
+ li = $('<li></li>')
116
+ .addClass('ui-state-default ui-tabs-paging-prev')
117
+ .append($('<a href="#"></a>')
118
+ .click(function() { page('prev'); return false; })
119
+ .html(opts.prevButton));
120
+ self.tablist.prepend(li);
121
+ buttonWidth += li.outerWidth(true);
122
+
123
+ // TODO determine fix for padding issues to next button
124
+ buttonWidth += 19;
125
+
126
+ var pageIndex = 0, pageWidth = 0, maxTabPadding = 0;
127
+
128
+ // start calculating pageWidths
129
+ for (var i = 0; i < tabWidths.length; i++) {
130
+ // if first tab of page or selected tab's padding larger than the current max, set the maxTabPadding
131
+ if (pageWidth == 0 || selectedTabWidths[i] - tabWidths[i] > maxTabPadding)
132
+ maxTabPadding = (selectedTabWidths[i] - tabWidths[i]);
133
+
134
+ // if first tab of page, initialize pages variable for page
135
+ if (pages[pageIndex] == null) {
136
+ pages[pageIndex] = { start: i };
137
+
138
+ } else if ((i > 0 && (i % opts.tabsPerPage) == 0) || (tabWidths[i] + pageWidth + buttonWidth + 12) > containerWidth) {
139
+ if ((pageWidth + maxTabPadding) > maxPageWidth)
140
+ maxPageWidth = (pageWidth + maxTabPadding);
141
+ pageIndex++;
142
+ pages[pageIndex] = { start: i };
143
+ pageWidth = 0;
125
144
  }
126
- if ((pageWidth + maxTabPadding) > maxPageWidth)
127
- maxPageWidth = (pageWidth + maxTabPadding);
128
-
129
- // hide all tabs then show tabs for current page
130
- self.lis.hide().slice(pages[currentPage].start, pages[currentPage].end).show();
131
- if (currentPage == (pages.length - 1) && !opts.cycle)
132
- disableButton('next');
133
- if (currentPage == 0 && !opts.cycle)
134
- disableButton('prev');
135
-
136
- // calculate the right padding for the next button
137
- buttonPadding = containerWidth - maxPageWidth - buttonWidth;
138
- if (buttonPadding > 0)
139
- $('.ui-tabs-paging-next', self.element).css({ paddingRight:buttonPadding + 'px' });
140
-
141
- initialized = true;
142
- } else {
143
- destroy();
145
+ pages[pageIndex].end = i+1;
146
+ pageWidth += tabWidths[i];
147
+ if (i == self.options.active) currentPage = pageIndex;
144
148
  }
149
+ if ((pageWidth + maxTabPadding) > maxPageWidth)
150
+ maxPageWidth = (pageWidth + maxTabPadding);
145
151
 
146
- $(window).bind('resize', handleResize);
152
+ // hide all tabs then show tabs for current page
153
+ self.tabs.hide().slice(pages[currentPage].start, pages[currentPage].end).show();
154
+ if (currentPage == (pages.length - 1) && !opts.cycle)
155
+ disableButton('next');
156
+ if (currentPage == 0 && !opts.cycle)
157
+ disableButton('prev');
158
+
159
+ // calculate the right padding for the next button
160
+ buttonPadding = containerWidth - maxPageWidth - buttonWidth;
161
+ if (buttonPadding > 0)
162
+ $('.ui-tabs-paging-next', self.element).css({ paddingRight: buttonPadding + 'px' });
163
+ } else {
164
+ destroy();
147
165
  }
148
166
 
149
- function page(direction) {
150
- currentPage = currentPage + (direction == 'prev' ? -1 : 1);
151
-
152
- if ((direction == 'prev' && currentPage < 0 && opts.cycle) ||
153
- (direction == 'next' && currentPage >= pages.length && !opts.cycle))
154
- currentPage = pages.length - 1;
155
- else if ((direction == 'prev' && currentPage < 0) ||
156
- (direction == 'next' && currentPage >= pages.length && opts.cycle))
157
- currentPage = 0;
167
+ $(window).bind('resize', handleResize);
158
168
 
159
- var start = pages[currentPage].start;
160
- var end = pages[currentPage].end;
161
- self.lis.hide().slice(start, end).show();
162
-
163
- if (direction == 'prev') {
164
- enableButton('next');
165
- if (opts.follow && (self.options.selected < start || self.options.selected > (end - 1))) self.select(end - 1);
166
- if (!opts.cycle && start <= 0) disableButton('prev');
167
- } else {
168
- enableButton('prev');
169
- if (opts.follow && (self.options.selected < start || self.options.selected > (end - 1))) self.select(start);
170
- if (!opts.cycle && end >= self.length()) disableButton('next');
171
- }
172
- }
169
+ initialized = true;
170
+ }
173
171
 
174
- function disableButton(direction) {
175
- $('.ui-tabs-paging-' + direction, self.element).addClass('ui-tabs-paging-disabled');
172
+ // handles paging forward and backward
173
+ function page(direction) {
174
+ currentPage = currentPage + (direction == 'prev'?-1:1);
175
+
176
+ if ((direction == 'prev' && currentPage < 0 && opts.cycle) ||
177
+ (direction == 'next' && currentPage >= pages.length && !opts.cycle))
178
+ currentPage = pages.length - 1;
179
+ else if ((direction == 'prev' && currentPage < 0) ||
180
+ (direction == 'next' && currentPage >= pages.length && opts.cycle))
181
+ currentPage = 0;
182
+
183
+ var start = pages[currentPage].start;
184
+ var end = pages[currentPage].end;
185
+ self.tabs.hide().slice(start, end).show();
186
+
187
+ if (direction == 'prev') {
188
+ enableButton('next');
189
+ if (opts.follow && (self.options.active < start || self.options.active > (end-1))) self.option('active', end-1);
190
+ if (!opts.cycle && start <= 0) disableButton('prev');
191
+ } else {
192
+ enableButton('prev');
193
+ if (opts.follow && (self.options.active < start || self.options.active > (end-1))) self.option('active', start);
194
+ if (!opts.cycle && end >= self.tabs.length) disableButton('next');
176
195
  }
196
+ }
177
197
 
178
- function enableButton(direction) {
179
- $('.ui-tabs-paging-' + direction, self.element).removeClass('ui-tabs-paging-disabled');
180
- }
198
+ // change styling of next/prev buttons when disabled
199
+ function disableButton(direction) {
200
+ $('.ui-tabs-paging-'+direction, self.element).addClass('ui-tabs-paging-disabled');
201
+ }
181
202
 
182
- // special function defined to handle IE6 and IE7 resize issues
183
- function handleResize() {
184
- if (resizeTimer) clearTimeout(resizeTimer);
203
+ function enableButton(direction) {
204
+ $('.ui-tabs-paging-'+direction, self.element).removeClass('ui-tabs-paging-disabled');
205
+ }
185
206
 
186
- if (windowHeight != $(window).height() || windowWidth != $(window).width())
187
- resizeTimer = setTimeout(reinit, 100);
188
- }
207
+ // special function defined to handle IE resize issues
208
+ function handleResize() {
209
+ if (resizeTimer) clearTimeout(resizeTimer);
189
210
 
190
- function reinit() {
191
- windowHeight = $(window).height();
192
- windowWidth = $(window).width();
193
- init();
211
+ if (windowHeight != $(window).height() || windowWidth != $(window).width())
212
+ {
213
+ resizeTimer = setTimeout(init, 100);
194
214
  }
215
+ }
195
216
 
196
- function destroy() {
197
- // remove buttons
198
- $('.ui-tabs-paging-next', self.element).remove();
199
- $('.ui-tabs-paging-prev', self.element).remove();
200
-
201
- // show all tabs
202
- self.lis.show();
217
+ // remove all paging related changes and events
218
+ function destroy() {
219
+ // remove buttons
220
+ $('.ui-tabs-paging-next', self.element).remove();
221
+ $('.ui-tabs-paging-prev', self.element).remove();
203
222
 
204
- initialized = false;
223
+ // show all tabs
224
+ self.tabs.show();
205
225
 
206
- $(window).unbind('resize', handleResize);
207
- }
226
+ initialized = false;
208
227
 
209
- // reconfigure "ui.tabs" add/remove events to reinit paging
210
- var tabsAdd = self.add;
211
- self.add = function (url, label, index) {
212
- // remove paging buttons before adding a tab
213
- if (initialized)
214
- destroy();
228
+ $(window).unbind('resize', handleResize);
229
+ }
215
230
 
216
- tabsAdd.apply(this, [url, label, index]);
217
231
 
218
- if (opts.selectOnAdd) {
219
- if (index == undefined) index = this.lis.length - 1;
220
- this.select(index);
221
- }
222
- // re-initialize paging buttons
223
- init();
224
- };
225
- var tabsRemove = self.remove;
226
- self.remove = function (index) {
227
- // remove paging buttons before removing a tab
228
- if (initialized)
229
- destroy();
230
232
 
231
- tabsRemove.apply(this, [index]);
233
+ // ------------- OVERRIDDEN PUBLIC FUNCTIONS -------------
234
+ self.option = function(optionName, value) {
235
+ uiTabsFuncs.option.apply(this, [optionName, value]);
232
236
 
233
- // re-initialize paging buttons
234
- init();
235
- };
236
- // reconfigure "ui.tabs" select event to change pages if new tab is selected
237
- var tabsSelect = self.select;
238
- self.select = function (index) {
239
- var $panel;
240
- var $parent;
241
- if (typeof(index) === 'string') {
242
- $panel = $('#' + index);
243
- $parent = $panel.parent();
244
- // getting my index
245
- index = $parent.children('.ui-tabs-panel').index($panel);
246
- }
247
- tabsSelect.apply(this, [index]);
237
+ // if "followOnActive" is true, then move page when selection changes
238
+ if (optionName == "active")
239
+ {
248
240
  // if paging is not initialized or it is not configured to
249
- // change pages when a new tab is selected, then do nothing
250
- if (!initialized || !opts.followOnSelect)
251
- return;
241
+ // change pages when a new tab is active, then do nothing
242
+ if (!initialized || !opts.followOnActive)
243
+ return this;
252
244
 
253
- // find the new page based on index of the tab selected
254
- for (i in pages) {
245
+ // find the new page based on index of the active tab
246
+ for (var i in pages) {
255
247
  var start = pages[i].start;
256
248
  var end = pages[i].end;
257
- if (index >= start && index < end) {
258
- // if the the tab selected is not within the currentPage of tabs, then change pages
249
+ if (value >= start && value < end) {
250
+ // if the the active tab is not within the currentPage of tabs, then change pages
259
251
  if (i != currentPage) {
260
- self.lis.hide().slice(start, end).show();
252
+ this.tabs.hide().slice(start, end).show();
261
253
 
262
254
  currentPage = parseInt(i);
263
255
  if (currentPage == 0) {
@@ -265,23 +257,91 @@
265
257
  if (!opts.cycle && start <= 0) disableButton('prev');
266
258
  } else {
267
259
  enableButton('prev');
268
- if (!opts.cycle && end >= self.length()) disableButton('next');
260
+ if (!opts.cycle && end >= this.tabs.length) disableButton('next');
269
261
  }
270
262
  }
271
263
  break;
272
264
  }
273
265
  }
274
- };
266
+ }
267
+
268
+ return this;
269
+ }
270
+
271
+ self.refresh = function() {
272
+ if (initialized)
273
+ {
274
+ destroy();
275
+
276
+ uiTabsFuncs.refresh.apply(this);
275
277
 
276
- // add, remove, and destroy functions specific for paging
277
- $.extend($.ui.tabs.prototype, {
278
- pagingDestroy:function () {
278
+ // re-initialize paging buttons
279
+ init();
280
+ }
281
+
282
+ uiTabsFuncs.refresh.apply(this);
283
+ }
284
+
285
+
286
+ // DEPRECATED in jQuery UI 1.9
287
+ if ( $.uiBackCompat !== false )
288
+ {
289
+ // temporarily remove paging buttons before adding a tab
290
+ self.add = function(url, label, index) {
291
+ if (initialized)
292
+ {
279
293
  destroy();
294
+
295
+ uiTabsFuncs.add.apply(this, [url, label, index]);
296
+
297
+ if (opts.activeOnAdd) {
298
+ if (index == undefined) index = this.tabs.length-1;
299
+ this.option('active', index);
300
+ }
301
+ // re-initialize paging buttons
302
+ init();
303
+
304
+ return this;
305
+ }
306
+
307
+ return uiTabsFuncs.add.apply(this, [url, label, index]);
308
+ }
309
+
310
+ // temporarily remove paging buttons before removing a tab
311
+ self.remove = function(index) {
312
+ if (initialized)
313
+ {
314
+ destroy();
315
+ uiTabsFuncs.remove.apply(this, [index]);
316
+ init();
317
+
318
+ return this;
280
319
  }
281
- });
282
320
 
283
- init();
321
+ return uiTabsFuncs.remove.apply(this, [index]);
322
+ }
284
323
  }
285
- });
324
+
325
+
326
+ // ------------- PUBLIC FUNCTIONS -------------
327
+ $.extend($.ui.tabs.prototype, {
328
+ // public function for removing paging
329
+ pagingDestroy: function() {
330
+ destroy();
331
+ return this;
332
+ },
333
+
334
+ // public function to handle resizes that are not on the window
335
+ pagingResize: function() {
336
+ init();
337
+ return this;
338
+ }
339
+ });
340
+
341
+ // initialize on startup!
342
+ init();
343
+ }
344
+ });
345
+
286
346
 
287
347
  })(jQuery);