alchemy_cms 2.0.7 → 2.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -4
- data/.travis.yml +1 -1
- data/Gemfile +7 -2
- data/README.md +6 -6
- data/Rakefile +26 -18
- data/alchemy_cms.gemspec +14 -14
- data/{assets/stylesheets → app/assets/images/alchemy}/Jcrop.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/ajax_loader.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/alchemy-logo.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/flags.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/gui/navi-tab.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/gui/shading_90.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/gui/toggle.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/icons.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/image_loader.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow_bg.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow_bg_hover.gif +0 -0
- data/{assets/images → app/assets/images/alchemy}/placeholder.png +0 -0
- data/{assets/images/gui → app/assets/images/alchemy}/shading.png +0 -0
- data/{assets/images → app/assets/images/alchemy}/swfupload/browse_button.png +0 -0
- data/{assets/stylesheets/default/img → app/assets/images/alchemy}/tabs.gif +0 -0
- data/{assets/images/jquery-ui → app/assets/images/alchemy}/ui-icons_666666_256x240.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +212 -0
- data/app/assets/javascripts/alchemy/alchemy.buttons.js +36 -0
- data/app/assets/javascripts/alchemy/alchemy.dirty.js +91 -0
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +114 -0
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.element_editor_selector.js +0 -0
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.growler.js +0 -0
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.image_cropper.js +0 -0
- data/app/assets/javascripts/alchemy/alchemy.js +26 -0
- data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +17 -0
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.link_overlay.js +1 -1
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.page_sorter.js +0 -0
- data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.preview.js +0 -0
- data/app/assets/javascripts/alchemy/alchemy.windows.js +438 -0
- data/app/assets/stylesheets/alchemy/_defaults.scss +160 -0
- data/app/assets/stylesheets/alchemy/alchemy.css +9 -0
- data/{assets/stylesheets/alchemy.css → app/assets/stylesheets/alchemy/base.css.scss} +216 -353
- data/{assets/stylesheets/elements.css → app/assets/stylesheets/alchemy/elements.css.scss} +41 -70
- data/{assets/stylesheets/flags.css → app/assets/stylesheets/alchemy/flags.css.scss} +1 -1
- data/{assets/stylesheets/jquery-ui-1.8.7.alchemy.css → app/assets/stylesheets/alchemy/jquery-ui.alchemy.css} +15 -15
- data/{assets/stylesheets/jquery.Jcrop.css → app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss} +3 -3
- data/{assets/stylesheets/jquery.sb.css → app/assets/stylesheets/alchemy/jquery.sb.css.scss} +19 -29
- data/{assets/stylesheets → app/assets/stylesheets/alchemy}/print.css +6 -1
- data/{assets/stylesheets → app/assets/stylesheets/alchemy}/standard_set.css +0 -0
- data/{assets/stylesheets/alchemy_tinymce_content.css → app/assets/stylesheets/alchemy/tinymce_content.css} +0 -0
- data/{assets/stylesheets/alchemy_tinymce_dialog.css → app/assets/stylesheets/alchemy/tinymce_dialog.css} +2 -2
- data/app/controllers/admin/attachments_controller.rb +2 -8
- data/app/controllers/admin/clipboard_controller.rb +2 -2
- data/app/controllers/admin/contents_controller.rb +4 -16
- data/app/controllers/admin/elements_controller.rb +2 -2
- data/app/controllers/admin/essence_audios_controller.rb +0 -3
- data/app/controllers/admin/essence_files_controller.rb +0 -11
- data/app/controllers/admin/essence_flashes_controller.rb +0 -3
- data/app/controllers/admin/essence_pictures_controller.rb +2 -7
- data/app/controllers/admin/essence_videos_controller.rb +0 -3
- data/app/controllers/admin/languages_controller.rb +4 -10
- data/app/controllers/admin/pages_controller.rb +6 -4
- data/app/controllers/admin/pictures_controller.rb +13 -18
- data/app/controllers/admin/trash_controller.rb +0 -5
- data/app/controllers/admin/users_controller.rb +2 -3
- data/app/controllers/alchemy_controller.rb +18 -30
- data/app/controllers/pages_controller.rb +21 -24
- data/app/helpers/admin/elements_helper.rb +5 -0
- data/app/helpers/admin/pages_helper.rb +36 -1
- data/app/helpers/alchemy_helper.rb +39 -17
- data/app/models/attachment.rb +2 -2
- data/app/models/essence_file.rb +1 -1
- data/app/models/page.rb +1 -1
- data/app/sweepers/pages_sweeper.rb +10 -0
- data/app/views/admin/attachments/destroy.js.erb +4 -0
- data/app/views/admin/clipboard/insert.js.erb +12 -19
- data/app/views/admin/contents/create.js.erb +1 -1
- data/app/views/admin/contents/destroy.js.erb +7 -0
- data/app/views/admin/contents/order.js.erb +6 -0
- data/app/views/admin/elements/_element.html.erb +4 -2
- data/app/views/admin/elements/create.js.erb +19 -26
- data/app/views/admin/elements/fold.js.erb +1 -1
- data/app/views/admin/elements/index.html.erb +1 -1
- data/app/views/admin/essence_files/assign.js.erb +8 -0
- data/app/views/admin/essence_pictures/save_link.js.erb +3 -0
- data/app/views/admin/index.html.erb +37 -27
- data/app/views/admin/languages/destroy.js.erb +1 -0
- data/app/views/admin/pages/_page.html.erb +1 -1
- data/app/views/admin/pages/_sitemap.html.erb +1 -1
- data/app/views/admin/pages/edit.html.erb +2 -2
- data/app/views/admin/pages/update.js.erb +1 -1
- data/app/views/admin/partials/_upload_form.html.erb +11 -11
- data/app/views/admin/pictures/archive_overlay.js.erb +1 -0
- data/app/views/admin/pictures/flush.js.erb +2 -0
- data/app/views/admin/pictures/update.js.erb +1 -0
- data/app/views/admin/trash/clear.js.erb +3 -0
- data/app/views/alchemy/error_notice.js.erb +1 -0
- data/app/views/alchemy/permission_denied.js.erb +2 -0
- data/app/views/alchemy/redirect.js.erb +1 -0
- data/app/views/alchemy/remote_errors.js.erb +3 -0
- data/app/views/alchemy/update.js.erb +5 -0
- data/app/views/essences/_essence_file_editor.html.erb +0 -1
- data/app/views/essences/_essence_file_view.html.erb +1 -5
- data/app/views/essences/_essence_picture_tools.html.erb +1 -1
- data/app/views/layouts/alchemy.html.erb +22 -9
- data/app/views/pages/show.rss.builder +1 -1
- data/config/alchemy/elements.yml +0 -5
- data/config/alchemy/page_layouts.yml +1 -1
- data/config/asset_packages.yml +17 -19
- data/config/authorization_rules.rb +1 -0
- data/config/locales/de.yml +0 -1
- data/config/routes.rb +1 -1
- data/lib/alchemy/tinymce.rb +51 -0
- data/lib/alchemy/version.rb +3 -3
- data/lib/alchemy_cms.rb +4 -2
- data/script/rails +6 -0
- data/spec/controllers/admin/clipboard_controller_spec.rb +15 -13
- data/spec/controllers/admin/contents_controller_spec.rb +4 -4
- data/spec/controllers/admin/trash_controller_spec.rb +6 -9
- data/spec/controllers/pages_controller_spec.rb +9 -8
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +3 -3
- data/spec/dummy/config/application.rb +12 -6
- data/spec/dummy/config/database.yml +3 -0
- data/spec/dummy/config/environments/development.rb +7 -3
- data/spec/dummy/config/environments/production.rb +23 -12
- data/spec/dummy/config/environments/test.rb +5 -1
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +1 -1
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/factories.rb +8 -8
- data/spec/helpers/admin/elements_helper_spec.rb +2 -2
- data/spec/helpers/contents_helper_spec.rb +1 -1
- data/spec/helpers/elements_helper_spec.rb +6 -6
- data/spec/helpers/essences_helper_spec.rb +1 -1
- data/spec/helpers/pages_helper_spec.rb +37 -37
- data/spec/integration/pages_controller_spec.rb +29 -26
- data/spec/integration/security_spec.rb +2 -1
- data/spec/models/content_spec.rb +1 -1
- data/spec/models/element_spec.rb +11 -11
- data/spec/models/language_spec.rb +5 -5
- data/spec/models/page_spec.rb +54 -54
- data/spec/models/user_spec.rb +2 -1
- data/spec/routing_spec.rb +1 -1
- data/{assets/javascripts/jquery.js → vendor/assets/javascripts/jquery-1.6.2.min.js} +0 -0
- data/{assets/javascripts/jquery-ui.js → vendor/assets/javascripts/jquery-ui-custom-1.8.16.min.js} +0 -0
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.Jcrop.min.js +0 -0
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.dialogextend.min.js +7 -7
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.in-place-edit.js +0 -0
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.sb.min.js +0 -0
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.scrollTo-1.4.2-min.js +10 -10
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.ui.nestedSortable.js +0 -0
- data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.ui.tabspaging.js +0 -0
- data/{assets → vendor/assets}/javascripts/swfupload/fileprogress.js +202 -202
- data/{assets → vendor/assets}/javascripts/swfupload/handlers.js +171 -171
- data/{assets → vendor/assets}/javascripts/swfupload/queue.js +97 -97
- data/{assets → vendor/assets}/javascripts/swfupload/swfupload.js +980 -980
- data/{assets → vendor/assets}/javascripts/swfupload/swfupload.swf +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/jquery.tinymce.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/langs/de.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/langs/en.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/license.txt +504 -504
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/editor_plugin.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/langs/de.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/langs/en.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +110 -110
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin.js +0 -0
- data/{assets/javascripts/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css → vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.erb} +8 -8
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/inlinepopups/template.htm +387 -387
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/editor_plugin.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/js/pastetext.js +36 -36
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/js/pasteword.js +51 -51
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/langs/de_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/pastetext.htm +26 -26
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/pasteword.htm +21 -21
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/cell.htm +180 -180
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/cell.css +16 -16
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/row.css +25 -25
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/table.css +13 -13
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/editor_plugin.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/cell.js +319 -319
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/merge_cells.js +27 -27
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/row.js +237 -237
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/table.js +450 -450
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/langs/de_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/langs/en_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/merge_cells.htm +32 -32
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/row.htm +158 -158
- data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/table.htm +188 -188
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/about.htm +52 -52
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/anchor.htm +26 -26
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/charmap.htm +51 -51
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/color_picker.htm +74 -74
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/editor_template.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/image.htm +80 -80
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/flash.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/iframe.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/pagebreak.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/quicktime.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/realmedia.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/shockwave.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/trans.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/video.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/windowsmedia.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/about.js +73 -73
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/anchor.js +43 -43
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/charmap.js +355 -355
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/color_picker.js +329 -329
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/image.js +251 -251
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/link.js +153 -153
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/source_editor.js +56 -56
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/de.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/en.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/link.htm +57 -57
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/shortcuts.htm +47 -47
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/content.css +50 -50
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +117 -117
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +214 -214
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +48 -48
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +117 -117
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +217 -217
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +7 -7
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +5 -5
- data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/source_editor.htm +25 -25
- data/{assets → vendor/assets}/javascripts/tiny_mce/tiny_mce.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/tiny_mce_popup.js +0 -0
- data/{assets → vendor/assets}/javascripts/tiny_mce/utils/editable_selects.js +70 -70
- data/{assets → vendor/assets}/javascripts/tiny_mce/utils/form_utils.js +210 -210
- data/{assets → vendor/assets}/javascripts/tiny_mce/utils/mctabs.js +161 -161
- data/{assets → vendor/assets}/javascripts/tiny_mce/utils/validate.js +252 -252
- metadata +338 -369
- data/app/views/elements/_download_editor.html.erb +0 -1
- data/app/views/elements/_download_view.html.erb +0 -3
- data/assets/javascripts/alchemy.js +0 -903
- data/assets/javascripts/jquery.rails.js +0 -315
- data/assets/stylesheets/ie6.css +0 -18
- data/config/initializers/tinymce_hammer.rb +0 -31
@@ -1,162 +1,162 @@
|
|
1
|
-
/**
|
2
|
-
* mctabs.js
|
3
|
-
*
|
4
|
-
* Copyright 2009, Moxiecode Systems AB
|
5
|
-
* Released under LGPL License.
|
6
|
-
*
|
7
|
-
* License: http://tinymce.moxiecode.com/license
|
8
|
-
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
-
*/
|
10
|
-
|
11
|
-
function MCTabs() {
|
12
|
-
this.settings = [];
|
13
|
-
this.onChange = tinyMCEPopup.editor.windowManager.createInstance('tinymce.util.Dispatcher');
|
14
|
-
};
|
15
|
-
|
16
|
-
MCTabs.prototype.init = function(settings) {
|
17
|
-
this.settings = settings;
|
18
|
-
};
|
19
|
-
|
20
|
-
MCTabs.prototype.getParam = function(name, default_value) {
|
21
|
-
var value = null;
|
22
|
-
|
23
|
-
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
|
24
|
-
|
25
|
-
// Fix bool values
|
26
|
-
if (value == "true" || value == "false")
|
27
|
-
return (value == "true");
|
28
|
-
|
29
|
-
return value;
|
30
|
-
};
|
31
|
-
|
32
|
-
MCTabs.prototype.showTab =function(tab){
|
33
|
-
tab.className = 'current';
|
34
|
-
tab.setAttribute("aria-selected", true);
|
35
|
-
tab.setAttribute("aria-expanded", true);
|
36
|
-
tab.tabIndex = 0;
|
37
|
-
};
|
38
|
-
|
39
|
-
MCTabs.prototype.hideTab =function(tab){
|
40
|
-
var t=this;
|
41
|
-
|
42
|
-
tab.className = '';
|
43
|
-
tab.setAttribute("aria-selected", false);
|
44
|
-
tab.setAttribute("aria-expanded", false);
|
45
|
-
tab.tabIndex = -1;
|
46
|
-
};
|
47
|
-
|
48
|
-
MCTabs.prototype.showPanel = function(panel) {
|
49
|
-
panel.className = 'current';
|
50
|
-
panel.setAttribute("aria-hidden", false);
|
51
|
-
};
|
52
|
-
|
53
|
-
MCTabs.prototype.hidePanel = function(panel) {
|
54
|
-
panel.className = 'panel';
|
55
|
-
panel.setAttribute("aria-hidden", true);
|
56
|
-
};
|
57
|
-
|
58
|
-
MCTabs.prototype.getPanelForTab = function(tabElm) {
|
59
|
-
return tinyMCEPopup.dom.getAttrib(tabElm, "aria-controls");
|
60
|
-
};
|
61
|
-
|
62
|
-
MCTabs.prototype.displayTab = function(tab_id, panel_id, avoid_focus) {
|
63
|
-
var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i, t = this;
|
64
|
-
|
65
|
-
tabElm = document.getElementById(tab_id);
|
66
|
-
|
67
|
-
if (panel_id === undefined) {
|
68
|
-
panel_id = t.getPanelForTab(tabElm);
|
69
|
-
}
|
70
|
-
|
71
|
-
panelElm= document.getElementById(panel_id);
|
72
|
-
panelContainerElm = panelElm ? panelElm.parentNode : null;
|
73
|
-
tabContainerElm = tabElm ? tabElm.parentNode : null;
|
74
|
-
selectionClass = t.getParam('selection_class', 'current');
|
75
|
-
|
76
|
-
if (tabElm && tabContainerElm) {
|
77
|
-
nodes = tabContainerElm.childNodes;
|
78
|
-
|
79
|
-
// Hide all other tabs
|
80
|
-
for (i = 0; i < nodes.length; i++) {
|
81
|
-
if (nodes[i].nodeName == "LI") {
|
82
|
-
t.hideTab(nodes[i]);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
// Show selected tab
|
87
|
-
t.showTab(tabElm);
|
88
|
-
}
|
89
|
-
|
90
|
-
if (panelElm && panelContainerElm) {
|
91
|
-
nodes = panelContainerElm.childNodes;
|
92
|
-
|
93
|
-
// Hide all other panels
|
94
|
-
for (i = 0; i < nodes.length; i++) {
|
95
|
-
if (nodes[i].nodeName == "DIV")
|
96
|
-
t.hidePanel(nodes[i]);
|
97
|
-
}
|
98
|
-
|
99
|
-
if (!avoid_focus) {
|
100
|
-
tabElm.focus();
|
101
|
-
}
|
102
|
-
|
103
|
-
// Show selected panel
|
104
|
-
t.showPanel(panelElm);
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
MCTabs.prototype.getAnchor = function() {
|
109
|
-
var pos, url = document.location.href;
|
110
|
-
|
111
|
-
if ((pos = url.lastIndexOf('#')) != -1)
|
112
|
-
return url.substring(pos + 1);
|
113
|
-
|
114
|
-
return "";
|
115
|
-
};
|
116
|
-
|
117
|
-
|
118
|
-
//Global instance
|
119
|
-
var mcTabs = new MCTabs();
|
120
|
-
|
121
|
-
tinyMCEPopup.onInit.add(function() {
|
122
|
-
var tinymce = tinyMCEPopup.getWin().tinymce, dom = tinyMCEPopup.dom, each = tinymce.each;
|
123
|
-
|
124
|
-
each(dom.select('div.tabs'), function(tabContainerElm) {
|
125
|
-
var keyNav;
|
126
|
-
|
127
|
-
dom.setAttrib(tabContainerElm, "role", "tablist");
|
128
|
-
|
129
|
-
var items = tinyMCEPopup.dom.select('li', tabContainerElm);
|
130
|
-
var action = function(id) {
|
131
|
-
mcTabs.displayTab(id, mcTabs.getPanelForTab(id));
|
132
|
-
mcTabs.onChange.dispatch(id);
|
133
|
-
};
|
134
|
-
|
135
|
-
each(items, function(item) {
|
136
|
-
dom.setAttrib(item, 'role', 'tab');
|
137
|
-
dom.bind(item, 'click', function(evt) {
|
138
|
-
action(item.id);
|
139
|
-
});
|
140
|
-
});
|
141
|
-
|
142
|
-
dom.bind(dom.getRoot(), 'keydown', function(evt) {
|
143
|
-
if (evt.keyCode === 9 && evt.ctrlKey && !evt.altKey) { // Tab
|
144
|
-
keyNav.moveFocus(evt.shiftKey ? -1 : 1);
|
145
|
-
tinymce.dom.Event.cancel(evt);
|
146
|
-
}
|
147
|
-
});
|
148
|
-
|
149
|
-
each(dom.select('a', tabContainerElm), function(a) {
|
150
|
-
dom.setAttrib(a, 'tabindex', '-1');
|
151
|
-
});
|
152
|
-
|
153
|
-
keyNav = tinyMCEPopup.editor.windowManager.createInstance('tinymce.ui.KeyboardNavigation', {
|
154
|
-
root: tabContainerElm,
|
155
|
-
items: items,
|
156
|
-
onAction: action,
|
157
|
-
actOnFocus: true,
|
158
|
-
enableLeftRight: true,
|
159
|
-
enableUpDown: true
|
160
|
-
}, tinyMCEPopup.dom);
|
161
|
-
});
|
1
|
+
/**
|
2
|
+
* mctabs.js
|
3
|
+
*
|
4
|
+
* Copyright 2009, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://tinymce.moxiecode.com/license
|
8
|
+
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
function MCTabs() {
|
12
|
+
this.settings = [];
|
13
|
+
this.onChange = tinyMCEPopup.editor.windowManager.createInstance('tinymce.util.Dispatcher');
|
14
|
+
};
|
15
|
+
|
16
|
+
MCTabs.prototype.init = function(settings) {
|
17
|
+
this.settings = settings;
|
18
|
+
};
|
19
|
+
|
20
|
+
MCTabs.prototype.getParam = function(name, default_value) {
|
21
|
+
var value = null;
|
22
|
+
|
23
|
+
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
|
24
|
+
|
25
|
+
// Fix bool values
|
26
|
+
if (value == "true" || value == "false")
|
27
|
+
return (value == "true");
|
28
|
+
|
29
|
+
return value;
|
30
|
+
};
|
31
|
+
|
32
|
+
MCTabs.prototype.showTab =function(tab){
|
33
|
+
tab.className = 'current';
|
34
|
+
tab.setAttribute("aria-selected", true);
|
35
|
+
tab.setAttribute("aria-expanded", true);
|
36
|
+
tab.tabIndex = 0;
|
37
|
+
};
|
38
|
+
|
39
|
+
MCTabs.prototype.hideTab =function(tab){
|
40
|
+
var t=this;
|
41
|
+
|
42
|
+
tab.className = '';
|
43
|
+
tab.setAttribute("aria-selected", false);
|
44
|
+
tab.setAttribute("aria-expanded", false);
|
45
|
+
tab.tabIndex = -1;
|
46
|
+
};
|
47
|
+
|
48
|
+
MCTabs.prototype.showPanel = function(panel) {
|
49
|
+
panel.className = 'current';
|
50
|
+
panel.setAttribute("aria-hidden", false);
|
51
|
+
};
|
52
|
+
|
53
|
+
MCTabs.prototype.hidePanel = function(panel) {
|
54
|
+
panel.className = 'panel';
|
55
|
+
panel.setAttribute("aria-hidden", true);
|
56
|
+
};
|
57
|
+
|
58
|
+
MCTabs.prototype.getPanelForTab = function(tabElm) {
|
59
|
+
return tinyMCEPopup.dom.getAttrib(tabElm, "aria-controls");
|
60
|
+
};
|
61
|
+
|
62
|
+
MCTabs.prototype.displayTab = function(tab_id, panel_id, avoid_focus) {
|
63
|
+
var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i, t = this;
|
64
|
+
|
65
|
+
tabElm = document.getElementById(tab_id);
|
66
|
+
|
67
|
+
if (panel_id === undefined) {
|
68
|
+
panel_id = t.getPanelForTab(tabElm);
|
69
|
+
}
|
70
|
+
|
71
|
+
panelElm= document.getElementById(panel_id);
|
72
|
+
panelContainerElm = panelElm ? panelElm.parentNode : null;
|
73
|
+
tabContainerElm = tabElm ? tabElm.parentNode : null;
|
74
|
+
selectionClass = t.getParam('selection_class', 'current');
|
75
|
+
|
76
|
+
if (tabElm && tabContainerElm) {
|
77
|
+
nodes = tabContainerElm.childNodes;
|
78
|
+
|
79
|
+
// Hide all other tabs
|
80
|
+
for (i = 0; i < nodes.length; i++) {
|
81
|
+
if (nodes[i].nodeName == "LI") {
|
82
|
+
t.hideTab(nodes[i]);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
// Show selected tab
|
87
|
+
t.showTab(tabElm);
|
88
|
+
}
|
89
|
+
|
90
|
+
if (panelElm && panelContainerElm) {
|
91
|
+
nodes = panelContainerElm.childNodes;
|
92
|
+
|
93
|
+
// Hide all other panels
|
94
|
+
for (i = 0; i < nodes.length; i++) {
|
95
|
+
if (nodes[i].nodeName == "DIV")
|
96
|
+
t.hidePanel(nodes[i]);
|
97
|
+
}
|
98
|
+
|
99
|
+
if (!avoid_focus) {
|
100
|
+
tabElm.focus();
|
101
|
+
}
|
102
|
+
|
103
|
+
// Show selected panel
|
104
|
+
t.showPanel(panelElm);
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
MCTabs.prototype.getAnchor = function() {
|
109
|
+
var pos, url = document.location.href;
|
110
|
+
|
111
|
+
if ((pos = url.lastIndexOf('#')) != -1)
|
112
|
+
return url.substring(pos + 1);
|
113
|
+
|
114
|
+
return "";
|
115
|
+
};
|
116
|
+
|
117
|
+
|
118
|
+
//Global instance
|
119
|
+
var mcTabs = new MCTabs();
|
120
|
+
|
121
|
+
tinyMCEPopup.onInit.add(function() {
|
122
|
+
var tinymce = tinyMCEPopup.getWin().tinymce, dom = tinyMCEPopup.dom, each = tinymce.each;
|
123
|
+
|
124
|
+
each(dom.select('div.tabs'), function(tabContainerElm) {
|
125
|
+
var keyNav;
|
126
|
+
|
127
|
+
dom.setAttrib(tabContainerElm, "role", "tablist");
|
128
|
+
|
129
|
+
var items = tinyMCEPopup.dom.select('li', tabContainerElm);
|
130
|
+
var action = function(id) {
|
131
|
+
mcTabs.displayTab(id, mcTabs.getPanelForTab(id));
|
132
|
+
mcTabs.onChange.dispatch(id);
|
133
|
+
};
|
134
|
+
|
135
|
+
each(items, function(item) {
|
136
|
+
dom.setAttrib(item, 'role', 'tab');
|
137
|
+
dom.bind(item, 'click', function(evt) {
|
138
|
+
action(item.id);
|
139
|
+
});
|
140
|
+
});
|
141
|
+
|
142
|
+
dom.bind(dom.getRoot(), 'keydown', function(evt) {
|
143
|
+
if (evt.keyCode === 9 && evt.ctrlKey && !evt.altKey) { // Tab
|
144
|
+
keyNav.moveFocus(evt.shiftKey ? -1 : 1);
|
145
|
+
tinymce.dom.Event.cancel(evt);
|
146
|
+
}
|
147
|
+
});
|
148
|
+
|
149
|
+
each(dom.select('a', tabContainerElm), function(a) {
|
150
|
+
dom.setAttrib(a, 'tabindex', '-1');
|
151
|
+
});
|
152
|
+
|
153
|
+
keyNav = tinyMCEPopup.editor.windowManager.createInstance('tinymce.ui.KeyboardNavigation', {
|
154
|
+
root: tabContainerElm,
|
155
|
+
items: items,
|
156
|
+
onAction: action,
|
157
|
+
actOnFocus: true,
|
158
|
+
enableLeftRight: true,
|
159
|
+
enableUpDown: true
|
160
|
+
}, tinyMCEPopup.dom);
|
161
|
+
});
|
162
162
|
});
|
@@ -1,252 +1,252 @@
|
|
1
|
-
/**
|
2
|
-
* validate.js
|
3
|
-
*
|
4
|
-
* Copyright 2009, Moxiecode Systems AB
|
5
|
-
* Released under LGPL License.
|
6
|
-
*
|
7
|
-
* License: http://tinymce.moxiecode.com/license
|
8
|
-
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
-
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
// String validation:
|
13
|
-
|
14
|
-
if (!Validator.isEmail('myemail'))
|
15
|
-
alert('Invalid email.');
|
16
|
-
|
17
|
-
// Form validation:
|
18
|
-
|
19
|
-
var f = document.forms['myform'];
|
20
|
-
|
21
|
-
if (!Validator.isEmail(f.myemail))
|
22
|
-
alert('Invalid email.');
|
23
|
-
*/
|
24
|
-
|
25
|
-
var Validator = {
|
26
|
-
isEmail : function(s) {
|
27
|
-
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
|
28
|
-
},
|
29
|
-
|
30
|
-
isAbsUrl : function(s) {
|
31
|
-
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
|
32
|
-
},
|
33
|
-
|
34
|
-
isSize : function(s) {
|
35
|
-
return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
|
36
|
-
},
|
37
|
-
|
38
|
-
isId : function(s) {
|
39
|
-
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
|
40
|
-
},
|
41
|
-
|
42
|
-
isEmpty : function(s) {
|
43
|
-
var nl, i;
|
44
|
-
|
45
|
-
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
|
46
|
-
return true;
|
47
|
-
|
48
|
-
if (s.type == 'checkbox' && !s.checked)
|
49
|
-
return true;
|
50
|
-
|
51
|
-
if (s.type == 'radio') {
|
52
|
-
for (i=0, nl = s.form.elements; i<nl.length; i++) {
|
53
|
-
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
|
54
|
-
return false;
|
55
|
-
}
|
56
|
-
|
57
|
-
return true;
|
58
|
-
}
|
59
|
-
|
60
|
-
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
|
61
|
-
},
|
62
|
-
|
63
|
-
isNumber : function(s, d) {
|
64
|
-
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
|
65
|
-
},
|
66
|
-
|
67
|
-
test : function(s, p) {
|
68
|
-
s = s.nodeType == 1 ? s.value : s;
|
69
|
-
|
70
|
-
return s == '' || new RegExp(p).test(s);
|
71
|
-
}
|
72
|
-
};
|
73
|
-
|
74
|
-
var AutoValidator = {
|
75
|
-
settings : {
|
76
|
-
id_cls : 'id',
|
77
|
-
int_cls : 'int',
|
78
|
-
url_cls : 'url',
|
79
|
-
number_cls : 'number',
|
80
|
-
email_cls : 'email',
|
81
|
-
size_cls : 'size',
|
82
|
-
required_cls : 'required',
|
83
|
-
invalid_cls : 'invalid',
|
84
|
-
min_cls : 'min',
|
85
|
-
max_cls : 'max'
|
86
|
-
},
|
87
|
-
|
88
|
-
init : function(s) {
|
89
|
-
var n;
|
90
|
-
|
91
|
-
for (n in s)
|
92
|
-
this.settings[n] = s[n];
|
93
|
-
},
|
94
|
-
|
95
|
-
validate : function(f) {
|
96
|
-
var i, nl, s = this.settings, c = 0;
|
97
|
-
|
98
|
-
nl = this.tags(f, 'label');
|
99
|
-
for (i=0; i<nl.length; i++) {
|
100
|
-
this.removeClass(nl[i], s.invalid_cls);
|
101
|
-
nl[i].setAttribute('aria-invalid', false);
|
102
|
-
}
|
103
|
-
|
104
|
-
c += this.validateElms(f, 'input');
|
105
|
-
c += this.validateElms(f, 'select');
|
106
|
-
c += this.validateElms(f, 'textarea');
|
107
|
-
|
108
|
-
return c == 3;
|
109
|
-
},
|
110
|
-
|
111
|
-
invalidate : function(n) {
|
112
|
-
this.mark(n.form, n);
|
113
|
-
},
|
114
|
-
|
115
|
-
getErrorMessages : function(f) {
|
116
|
-
var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
|
117
|
-
nl = this.tags(f, "label");
|
118
|
-
for (i=0; i<nl.length; i++) {
|
119
|
-
if (this.hasClass(nl[i], s.invalid_cls)) {
|
120
|
-
field = document.getElementById(nl[i].getAttribute("for"));
|
121
|
-
values = { field: nl[i].textContent };
|
122
|
-
if (this.hasClass(field, s.min_cls, true)) {
|
123
|
-
message = ed.getLang('invalid_data_min');
|
124
|
-
values.min = this.getNum(field, s.min_cls);
|
125
|
-
} else if (this.hasClass(field, s.number_cls)) {
|
126
|
-
message = ed.getLang('invalid_data_number');
|
127
|
-
} else if (this.hasClass(field, s.size_cls)) {
|
128
|
-
message = ed.getLang('invalid_data_size');
|
129
|
-
} else {
|
130
|
-
message = ed.getLang('invalid_data');
|
131
|
-
}
|
132
|
-
|
133
|
-
message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
|
134
|
-
return values[b] || '{#' + b + '}';
|
135
|
-
});
|
136
|
-
messages.push(message);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
return messages;
|
140
|
-
},
|
141
|
-
|
142
|
-
reset : function(e) {
|
143
|
-
var t = ['label', 'input', 'select', 'textarea'];
|
144
|
-
var i, j, nl, s = this.settings;
|
145
|
-
|
146
|
-
if (e == null)
|
147
|
-
return;
|
148
|
-
|
149
|
-
for (i=0; i<t.length; i++) {
|
150
|
-
nl = this.tags(e.form ? e.form : e, t[i]);
|
151
|
-
for (j=0; j<nl.length; j++) {
|
152
|
-
this.removeClass(nl[j], s.invalid_cls);
|
153
|
-
nl[j].setAttribute('aria-invalid', false);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
},
|
157
|
-
|
158
|
-
validateElms : function(f, e) {
|
159
|
-
var nl, i, n, s = this.settings, st = true, va = Validator, v;
|
160
|
-
|
161
|
-
nl = this.tags(f, e);
|
162
|
-
for (i=0; i<nl.length; i++) {
|
163
|
-
n = nl[i];
|
164
|
-
|
165
|
-
this.removeClass(n, s.invalid_cls);
|
166
|
-
|
167
|
-
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
|
168
|
-
st = this.mark(f, n);
|
169
|
-
|
170
|
-
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
|
171
|
-
st = this.mark(f, n);
|
172
|
-
|
173
|
-
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
|
174
|
-
st = this.mark(f, n);
|
175
|
-
|
176
|
-
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
|
177
|
-
st = this.mark(f, n);
|
178
|
-
|
179
|
-
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
|
180
|
-
st = this.mark(f, n);
|
181
|
-
|
182
|
-
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
|
183
|
-
st = this.mark(f, n);
|
184
|
-
|
185
|
-
if (this.hasClass(n, s.id_cls) && !va.isId(n))
|
186
|
-
st = this.mark(f, n);
|
187
|
-
|
188
|
-
if (this.hasClass(n, s.min_cls, true)) {
|
189
|
-
v = this.getNum(n, s.min_cls);
|
190
|
-
|
191
|
-
if (isNaN(v) || parseInt(n.value) < parseInt(v))
|
192
|
-
st = this.mark(f, n);
|
193
|
-
}
|
194
|
-
|
195
|
-
if (this.hasClass(n, s.max_cls, true)) {
|
196
|
-
v = this.getNum(n, s.max_cls);
|
197
|
-
|
198
|
-
if (isNaN(v) || parseInt(n.value) > parseInt(v))
|
199
|
-
st = this.mark(f, n);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
return st;
|
204
|
-
},
|
205
|
-
|
206
|
-
hasClass : function(n, c, d) {
|
207
|
-
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
|
208
|
-
},
|
209
|
-
|
210
|
-
getNum : function(n, c) {
|
211
|
-
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
|
212
|
-
c = c.replace(/[^0-9]/g, '');
|
213
|
-
|
214
|
-
return c;
|
215
|
-
},
|
216
|
-
|
217
|
-
addClass : function(n, c, b) {
|
218
|
-
var o = this.removeClass(n, c);
|
219
|
-
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
|
220
|
-
},
|
221
|
-
|
222
|
-
removeClass : function(n, c) {
|
223
|
-
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
|
224
|
-
return n.className = c != ' ' ? c : '';
|
225
|
-
},
|
226
|
-
|
227
|
-
tags : function(f, s) {
|
228
|
-
return f.getElementsByTagName(s);
|
229
|
-
},
|
230
|
-
|
231
|
-
mark : function(f, n) {
|
232
|
-
var s = this.settings;
|
233
|
-
|
234
|
-
this.addClass(n, s.invalid_cls);
|
235
|
-
n.setAttribute('aria-invalid', 'true');
|
236
|
-
this.markLabels(f, n, s.invalid_cls);
|
237
|
-
|
238
|
-
return false;
|
239
|
-
},
|
240
|
-
|
241
|
-
markLabels : function(f, n, ic) {
|
242
|
-
var nl, i;
|
243
|
-
|
244
|
-
nl = this.tags(f, "label");
|
245
|
-
for (i=0; i<nl.length; i++) {
|
246
|
-
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
|
247
|
-
this.addClass(nl[i], ic);
|
248
|
-
}
|
249
|
-
|
250
|
-
return null;
|
251
|
-
}
|
252
|
-
};
|
1
|
+
/**
|
2
|
+
* validate.js
|
3
|
+
*
|
4
|
+
* Copyright 2009, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://tinymce.moxiecode.com/license
|
8
|
+
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
// String validation:
|
13
|
+
|
14
|
+
if (!Validator.isEmail('myemail'))
|
15
|
+
alert('Invalid email.');
|
16
|
+
|
17
|
+
// Form validation:
|
18
|
+
|
19
|
+
var f = document.forms['myform'];
|
20
|
+
|
21
|
+
if (!Validator.isEmail(f.myemail))
|
22
|
+
alert('Invalid email.');
|
23
|
+
*/
|
24
|
+
|
25
|
+
var Validator = {
|
26
|
+
isEmail : function(s) {
|
27
|
+
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
|
28
|
+
},
|
29
|
+
|
30
|
+
isAbsUrl : function(s) {
|
31
|
+
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
|
32
|
+
},
|
33
|
+
|
34
|
+
isSize : function(s) {
|
35
|
+
return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
|
36
|
+
},
|
37
|
+
|
38
|
+
isId : function(s) {
|
39
|
+
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
|
40
|
+
},
|
41
|
+
|
42
|
+
isEmpty : function(s) {
|
43
|
+
var nl, i;
|
44
|
+
|
45
|
+
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
|
46
|
+
return true;
|
47
|
+
|
48
|
+
if (s.type == 'checkbox' && !s.checked)
|
49
|
+
return true;
|
50
|
+
|
51
|
+
if (s.type == 'radio') {
|
52
|
+
for (i=0, nl = s.form.elements; i<nl.length; i++) {
|
53
|
+
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
|
57
|
+
return true;
|
58
|
+
}
|
59
|
+
|
60
|
+
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
|
61
|
+
},
|
62
|
+
|
63
|
+
isNumber : function(s, d) {
|
64
|
+
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
|
65
|
+
},
|
66
|
+
|
67
|
+
test : function(s, p) {
|
68
|
+
s = s.nodeType == 1 ? s.value : s;
|
69
|
+
|
70
|
+
return s == '' || new RegExp(p).test(s);
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
var AutoValidator = {
|
75
|
+
settings : {
|
76
|
+
id_cls : 'id',
|
77
|
+
int_cls : 'int',
|
78
|
+
url_cls : 'url',
|
79
|
+
number_cls : 'number',
|
80
|
+
email_cls : 'email',
|
81
|
+
size_cls : 'size',
|
82
|
+
required_cls : 'required',
|
83
|
+
invalid_cls : 'invalid',
|
84
|
+
min_cls : 'min',
|
85
|
+
max_cls : 'max'
|
86
|
+
},
|
87
|
+
|
88
|
+
init : function(s) {
|
89
|
+
var n;
|
90
|
+
|
91
|
+
for (n in s)
|
92
|
+
this.settings[n] = s[n];
|
93
|
+
},
|
94
|
+
|
95
|
+
validate : function(f) {
|
96
|
+
var i, nl, s = this.settings, c = 0;
|
97
|
+
|
98
|
+
nl = this.tags(f, 'label');
|
99
|
+
for (i=0; i<nl.length; i++) {
|
100
|
+
this.removeClass(nl[i], s.invalid_cls);
|
101
|
+
nl[i].setAttribute('aria-invalid', false);
|
102
|
+
}
|
103
|
+
|
104
|
+
c += this.validateElms(f, 'input');
|
105
|
+
c += this.validateElms(f, 'select');
|
106
|
+
c += this.validateElms(f, 'textarea');
|
107
|
+
|
108
|
+
return c == 3;
|
109
|
+
},
|
110
|
+
|
111
|
+
invalidate : function(n) {
|
112
|
+
this.mark(n.form, n);
|
113
|
+
},
|
114
|
+
|
115
|
+
getErrorMessages : function(f) {
|
116
|
+
var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
|
117
|
+
nl = this.tags(f, "label");
|
118
|
+
for (i=0; i<nl.length; i++) {
|
119
|
+
if (this.hasClass(nl[i], s.invalid_cls)) {
|
120
|
+
field = document.getElementById(nl[i].getAttribute("for"));
|
121
|
+
values = { field: nl[i].textContent };
|
122
|
+
if (this.hasClass(field, s.min_cls, true)) {
|
123
|
+
message = ed.getLang('invalid_data_min');
|
124
|
+
values.min = this.getNum(field, s.min_cls);
|
125
|
+
} else if (this.hasClass(field, s.number_cls)) {
|
126
|
+
message = ed.getLang('invalid_data_number');
|
127
|
+
} else if (this.hasClass(field, s.size_cls)) {
|
128
|
+
message = ed.getLang('invalid_data_size');
|
129
|
+
} else {
|
130
|
+
message = ed.getLang('invalid_data');
|
131
|
+
}
|
132
|
+
|
133
|
+
message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
|
134
|
+
return values[b] || '{#' + b + '}';
|
135
|
+
});
|
136
|
+
messages.push(message);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
return messages;
|
140
|
+
},
|
141
|
+
|
142
|
+
reset : function(e) {
|
143
|
+
var t = ['label', 'input', 'select', 'textarea'];
|
144
|
+
var i, j, nl, s = this.settings;
|
145
|
+
|
146
|
+
if (e == null)
|
147
|
+
return;
|
148
|
+
|
149
|
+
for (i=0; i<t.length; i++) {
|
150
|
+
nl = this.tags(e.form ? e.form : e, t[i]);
|
151
|
+
for (j=0; j<nl.length; j++) {
|
152
|
+
this.removeClass(nl[j], s.invalid_cls);
|
153
|
+
nl[j].setAttribute('aria-invalid', false);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
},
|
157
|
+
|
158
|
+
validateElms : function(f, e) {
|
159
|
+
var nl, i, n, s = this.settings, st = true, va = Validator, v;
|
160
|
+
|
161
|
+
nl = this.tags(f, e);
|
162
|
+
for (i=0; i<nl.length; i++) {
|
163
|
+
n = nl[i];
|
164
|
+
|
165
|
+
this.removeClass(n, s.invalid_cls);
|
166
|
+
|
167
|
+
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
|
168
|
+
st = this.mark(f, n);
|
169
|
+
|
170
|
+
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
|
171
|
+
st = this.mark(f, n);
|
172
|
+
|
173
|
+
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
|
174
|
+
st = this.mark(f, n);
|
175
|
+
|
176
|
+
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
|
177
|
+
st = this.mark(f, n);
|
178
|
+
|
179
|
+
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
|
180
|
+
st = this.mark(f, n);
|
181
|
+
|
182
|
+
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
|
183
|
+
st = this.mark(f, n);
|
184
|
+
|
185
|
+
if (this.hasClass(n, s.id_cls) && !va.isId(n))
|
186
|
+
st = this.mark(f, n);
|
187
|
+
|
188
|
+
if (this.hasClass(n, s.min_cls, true)) {
|
189
|
+
v = this.getNum(n, s.min_cls);
|
190
|
+
|
191
|
+
if (isNaN(v) || parseInt(n.value) < parseInt(v))
|
192
|
+
st = this.mark(f, n);
|
193
|
+
}
|
194
|
+
|
195
|
+
if (this.hasClass(n, s.max_cls, true)) {
|
196
|
+
v = this.getNum(n, s.max_cls);
|
197
|
+
|
198
|
+
if (isNaN(v) || parseInt(n.value) > parseInt(v))
|
199
|
+
st = this.mark(f, n);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
return st;
|
204
|
+
},
|
205
|
+
|
206
|
+
hasClass : function(n, c, d) {
|
207
|
+
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
|
208
|
+
},
|
209
|
+
|
210
|
+
getNum : function(n, c) {
|
211
|
+
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
|
212
|
+
c = c.replace(/[^0-9]/g, '');
|
213
|
+
|
214
|
+
return c;
|
215
|
+
},
|
216
|
+
|
217
|
+
addClass : function(n, c, b) {
|
218
|
+
var o = this.removeClass(n, c);
|
219
|
+
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
|
220
|
+
},
|
221
|
+
|
222
|
+
removeClass : function(n, c) {
|
223
|
+
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
|
224
|
+
return n.className = c != ' ' ? c : '';
|
225
|
+
},
|
226
|
+
|
227
|
+
tags : function(f, s) {
|
228
|
+
return f.getElementsByTagName(s);
|
229
|
+
},
|
230
|
+
|
231
|
+
mark : function(f, n) {
|
232
|
+
var s = this.settings;
|
233
|
+
|
234
|
+
this.addClass(n, s.invalid_cls);
|
235
|
+
n.setAttribute('aria-invalid', 'true');
|
236
|
+
this.markLabels(f, n, s.invalid_cls);
|
237
|
+
|
238
|
+
return false;
|
239
|
+
},
|
240
|
+
|
241
|
+
markLabels : function(f, n, ic) {
|
242
|
+
var nl, i;
|
243
|
+
|
244
|
+
nl = this.tags(f, "label");
|
245
|
+
for (i=0; i<nl.length; i++) {
|
246
|
+
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
|
247
|
+
this.addClass(nl[i], ic);
|
248
|
+
}
|
249
|
+
|
250
|
+
return null;
|
251
|
+
}
|
252
|
+
};
|