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.
- data/.gitignore +2 -1
- data/.travis.yml +7 -4
- data/README.md +1 -0
- data/alchemy_cms.gemspec +19 -1
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +5 -2
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +4 -21
- data/app/assets/javascripts/alchemy/alchemy.windows.js +0 -1
- data/app/assets/stylesheets/alchemy/base.scss +4 -0
- data/app/assets/stylesheets/alchemy/elements.scss +59 -60
- data/app/assets/stylesheets/alchemy/flash.scss +3 -3
- data/app/assets/stylesheets/alchemy/form_elements.scss +15 -2
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +11 -3
- data/app/assets/stylesheets/alchemy/mixins.scss +9 -0
- data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +4 -0
- data/app/assets/stylesheets/alchemy/variables.scss +5 -1
- data/app/controllers/alchemy/admin/base_controller.rb +18 -3
- data/app/controllers/alchemy/admin/elements_controller.rb +4 -7
- data/app/controllers/alchemy/admin/pages_controller.rb +3 -4
- data/app/controllers/alchemy/admin/resources_controller.rb +1 -18
- data/app/controllers/alchemy/admin/users_controller.rb +8 -5
- data/app/helpers/alchemy/admin/pages_helper.rb +6 -1
- data/app/models/alchemy/content.rb +26 -5
- data/app/models/alchemy/element.rb +1 -0
- data/app/models/alchemy/essence_richtext.rb +1 -1
- data/app/models/alchemy/page.rb +131 -88
- data/app/views/alchemy/admin/clipboard/insert.js.erb +1 -1
- data/app/views/alchemy/admin/elements/create.js.erb +6 -1
- data/app/views/alchemy/admin/elements/trash.js.erb +1 -3
- data/app/views/alchemy/admin/resources/_form.html.erb +13 -1
- data/app/views/alchemy/admin/trash/index.html.erb +1 -1
- data/app/views/alchemy/base/remote_errors.js.erb +5 -1
- data/app/views/alchemy/essences/_essence_link_view.html.erb +2 -0
- data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
- data/config/locales/alchemy.de.yml +11 -4
- data/lib/alchemy/capistrano.rb +59 -1
- data/lib/alchemy/essence.rb +1 -0
- data/lib/alchemy/seeder.rb +39 -49
- data/lib/alchemy/tinymce.rb +1 -1
- data/lib/alchemy/version.rb +1 -1
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +1 -1
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +3 -0
- data/lib/rails/generators/alchemy/elements/templates/view.html.haml +2 -2
- data/lib/rails/generators/alchemy/elements/templates/view.html.slim +2 -2
- data/lib/tasks/database.rake +25 -0
- data/lib/tasks/install.rake +5 -14
- data/spec/factories.rb +10 -0
- data/spec/integration/admin/resources_integration_spec.rb +64 -23
- data/spec/integration/pages_controller_spec.rb +0 -2
- data/spec/libraries/resources_helper_spec.rb +6 -2
- data/spec/models/content_spec.rb +31 -0
- data/spec/models/element_spec.rb +7 -2
- data/spec/models/page_spec.rb +36 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.1_0_1.js +676 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +298 -238
- data/vendor/assets/javascripts/tiny_mce/langs/de.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/langs/en.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/license.txt +6 -6
- data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +97 -97
- data/vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/template.htm +376 -386
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pastetext.js +30 -30
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pasteword.js +45 -45
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/langs/de_dlg.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/pastetext.htm +17 -20
- data/vendor/assets/javascripts/tiny_mce/plugins/paste/pasteword.htm +12 -12
- data/vendor/assets/javascripts/tiny_mce/plugins/table/cell.htm +173 -183
- data/vendor/assets/javascripts/tiny_mce/plugins/table/css/cell.css +4 -4
- data/vendor/assets/javascripts/tiny_mce/plugins/table/css/row.css +7 -7
- data/vendor/assets/javascripts/tiny_mce/plugins/table/css/table.css +3 -3
- data/vendor/assets/javascripts/tiny_mce/plugins/table/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/plugins/table/js/cell.js +280 -282
- data/vendor/assets/javascripts/tiny_mce/plugins/table/js/merge_cells.js +15 -15
- data/vendor/assets/javascripts/tiny_mce/plugins/table/js/row.js +221 -204
- data/vendor/assets/javascripts/tiny_mce/plugins/table/js/table.js +448 -435
- data/vendor/assets/javascripts/tiny_mce/plugins/table/langs/de_dlg.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/plugins/table/merge_cells.htm +22 -24
- data/vendor/assets/javascripts/tiny_mce/plugins/table/row.htm +136 -144
- data/vendor/assets/javascripts/tiny_mce/plugins/table/table.htm +168 -184
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/about.htm +46 -62
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/anchor.htm +16 -17
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/charmap.htm +47 -56
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/color_picker.htm +52 -69
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/editor_template.js +1 -852
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/image.htm +69 -79
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/about.js +48 -48
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/anchor.js +50 -37
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/charmap.js +317 -317
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/color_picker.js +345 -331
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/image.js +248 -246
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/link.js +152 -146
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/source_editor.js +53 -31
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/link.htm +46 -53
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/shortcuts.htm +45 -57
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/content.css +47 -182
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +93 -399
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +191 -890
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/content.css +24 -102
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +79 -377
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/ui.css +80 -451
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +45 -167
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +93 -399
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +194 -889
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +7 -33
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +4 -15
- data/vendor/assets/javascripts/tiny_mce/themes/advanced/source_editor.htm +16 -19
- data/vendor/assets/javascripts/tiny_mce/tiny_mce.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/tiny_mce_popup.js +1 -1
- data/vendor/assets/javascripts/tiny_mce/utils/editable_selects.js +46 -46
- data/vendor/assets/javascripts/tiny_mce/utils/form_utils.js +124 -124
- data/vendor/assets/javascripts/tiny_mce/utils/mctabs.js +112 -112
- data/vendor/assets/javascripts/tiny_mce/utils/validate.js +213 -213
- metadata +11 -6
- data/spec/dummy/public/404.html.bak +0 -26
- data/vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.min.js +0 -8
@@ -1,263 +1,255 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
127
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
160
|
-
|
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
|
-
|
175
|
-
|
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
|
-
|
179
|
-
|
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
|
-
|
183
|
-
|
184
|
-
|
203
|
+
function enableButton(direction) {
|
204
|
+
$('.ui-tabs-paging-'+direction, self.element).removeClass('ui-tabs-paging-disabled');
|
205
|
+
}
|
185
206
|
|
186
|
-
|
187
|
-
|
188
|
-
|
207
|
+
// special function defined to handle IE resize issues
|
208
|
+
function handleResize() {
|
209
|
+
if (resizeTimer) clearTimeout(resizeTimer);
|
189
210
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
init();
|
211
|
+
if (windowHeight != $(window).height() || windowWidth != $(window).width())
|
212
|
+
{
|
213
|
+
resizeTimer = setTimeout(init, 100);
|
194
214
|
}
|
215
|
+
}
|
195
216
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
-
|
223
|
+
// show all tabs
|
224
|
+
self.tabs.show();
|
205
225
|
|
206
|
-
|
207
|
-
}
|
226
|
+
initialized = false;
|
208
227
|
|
209
|
-
|
210
|
-
|
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
|
-
|
233
|
+
// ------------- OVERRIDDEN PUBLIC FUNCTIONS -------------
|
234
|
+
self.option = function(optionName, value) {
|
235
|
+
uiTabsFuncs.option.apply(this, [optionName, value]);
|
232
236
|
|
233
|
-
|
234
|
-
|
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
|
250
|
-
if (!initialized || !opts.
|
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
|
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 (
|
258
|
-
// if the the tab
|
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
|
-
|
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 >=
|
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
|
-
|
277
|
-
|
278
|
-
|
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
|
-
|
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);
|