From d106988a3d03afce829288dfad6980377a2c47ea Mon Sep 17 00:00:00 2001 From: antarus66 Date: Tue, 20 Oct 2015 16:20:51 +0300 Subject: [PATCH] replace-modals: Replaced alerts by custom. Disabled a confirmation of ckeditor dialog cancelling. --- gulpfile.js | 8 +++-- public/assets/css/style.css | 5 ++- public/js/app.js | 4 +-- public/js/locales/dev.json | 1 + public/js/locales/en-US.json | 1 + public/js/locales/ru-RU.json | 1 + public/js/locales/uk-UA.json | 1 + public/js/tools/alert-overriding.js | 30 +++++++++++++++++ public/js/{ => tools}/validation-model.js | 0 public/js/vendor/ckeditor/config.js | 4 +++ public/js/views/main-layout.js | 3 +- public/js/views/popup/alert.js | 40 +++++++++++++++++++++++ public/js/views/templates/popup/alert.tpl | 14 ++++++++ 13 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 public/js/tools/alert-overriding.js rename public/js/{ => tools}/validation-model.js (100%) create mode 100644 public/js/views/popup/alert.js create mode 100644 public/js/views/templates/popup/alert.tpl diff --git a/gulpfile.js b/gulpfile.js index 7989d40..bd71b58 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -107,6 +107,7 @@ var concatSettings = { jsPathMinFull + 'views/tag/select.js', jsPathMinFull + 'views/tag/view.js', jsPathMinFull + 'views/vote/single.js', + jsPathMinFull + 'views/popup/alert.js', jsPathMinFull + 'views/popup/confirm.js', jsPathMinFull + 'views/role/select.js', jsPathMinFull + 'views/templates/menu/menu.tpl.js', @@ -118,9 +119,11 @@ var concatSettings = { jsPathMinFull + 'views/templates/folder/select.tpl.js', jsPathMinFull + 'views/templates/folder/select-row.tpl.js', jsPathMinFull + 'views/templates/question/form.tpl.js', + jsPathMinFull + 'views/templates/popup/alert.tpl.js', jsPathMinFull + 'views/templates/popup/confirm.tpl.js', jsPathMinFull + 'views/templates/vote/votes.tpl.js', - jsPathMinFull + 'views/templates/role/select-row.tpl.js' + jsPathMinFull + 'views/templates/role/select-row.tpl.js', + jsPathMinFull + 'tools/alert-overriding.js', ] }; @@ -184,7 +187,7 @@ gulp.task('js-prepare-static', function () { jsPathFull + 'vendor/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js', jsPathFull + 'vendor/ckeditor/adapters/jquery.js', jsPathFull + 'app.js', - jsPathFull + 'validation-model.js' + jsPathFull + 'tools/validation-model.js', ]) .pipe(loadStaticExclude()); }); @@ -201,6 +204,7 @@ gulp.task('js-prepare', function () { jsPathFull + 'views/folder/select.js', jsPathFull + 'views/tag/select.js', jsPathFull + 'views/tag/view.js', + jsPathFull + 'views/popup/alert.js', jsPathFull + 'views/popup/confirm.js', jsPathFull + 'views/vote/single.js', jsPathFull + 'views/role/select.js' diff --git a/public/assets/css/style.css b/public/assets/css/style.css index d424f4c..0e21f66 100755 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -756,7 +756,7 @@ body.modal-open { .modal-backdrop.in { width: 100%; height: 100%; - z-index: 3; + z-index: 10100; position: fixed; } @@ -772,6 +772,7 @@ body.modal-open { padding: 0 !important; position: fixed; overflow: hidden; + z-index: 10110; } /* @@ -779,6 +780,7 @@ body.modal-open { | Confirmation form |------------------------------------------------------------------------------ */ +.alert-form, .confirm-form { width: 25%; margin: auto; @@ -786,6 +788,7 @@ body.modal-open { bottom: auto; } +.alert-form .form-group.controls, .confirm-form .form-group.controls { margin-bottom: 0; text-align: center; diff --git a/public/js/app.js b/public/js/app.js index 6c04041..683062e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -4,9 +4,9 @@ define([ 'bootstrap', 'underscore', 'tpl', - 'validation-model', + 'tools/validation-model', 'jquery.scroll', - 'paginator' + 'paginator', ], function (Marionette, Backbone) { var App = new Marionette.Application(); App.queryFlag = []; diff --git a/public/js/locales/dev.json b/public/js/locales/dev.json index 99c64cc..d0ffb69 100644 --- a/public/js/locales/dev.json +++ b/public/js/locales/dev.json @@ -81,6 +81,7 @@ "delete": "Delete", "cancel": "Cancel", + "alert-title": "Attention!", "confirm-title": "Confirmation", "confirm-body": "Do you really want to perform this action?", diff --git a/public/js/locales/en-US.json b/public/js/locales/en-US.json index c82bdb2..2840a19 100644 --- a/public/js/locales/en-US.json +++ b/public/js/locales/en-US.json @@ -80,6 +80,7 @@ "delete": "Delete", "cancel": "Cancel", + "alert-title": "Attention!", "confirm-title": "Confirmation", "confirm-body": "Do you really want to perform this action?", diff --git a/public/js/locales/ru-RU.json b/public/js/locales/ru-RU.json index 3d89495..ded1479 100644 --- a/public/js/locales/ru-RU.json +++ b/public/js/locales/ru-RU.json @@ -80,6 +80,7 @@ "delete": "Удалить", "cancel": "Отмена", + "alert-title": "Внимание!", "confirm-title": "Подтверждение", "confirm-body": "Вы действительно хотите выполнить это действие?", diff --git a/public/js/locales/uk-UA.json b/public/js/locales/uk-UA.json index 7047101..b92aadb 100644 --- a/public/js/locales/uk-UA.json +++ b/public/js/locales/uk-UA.json @@ -80,6 +80,7 @@ "delete": "Видалити", "cancel": "Скасувати", + "alert-title": "Увага!", "confirm-title": "Підтверждення", "confirm-body": "Ви дійсно бажаєте виконати цю операцію?", diff --git a/public/js/tools/alert-overriding.js b/public/js/tools/alert-overriding.js new file mode 100644 index 0000000..e276554 --- /dev/null +++ b/public/js/tools/alert-overriding.js @@ -0,0 +1,30 @@ +define([ + 'app', + 'marionette', + 'backbone', + '../views/popup/alert', +], function (App, Marionette, Backbone, AlertView) { + window.alert = function(message, title) { + var title = title || i18n.t("ui.alert-title"); + + var alertView = new AlertView({ + message: message + }); + + App.trigger('popup:show', { + header: { + title: title + }, + class: 'alert-form', + contentView: alertView + }); + + App.listenTo( + alertView, + 'form:submit', + function () { + App.trigger('popup:close'); + } + ); + }; +}); diff --git a/public/js/validation-model.js b/public/js/tools/validation-model.js similarity index 100% rename from public/js/validation-model.js rename to public/js/tools/validation-model.js diff --git a/public/js/vendor/ckeditor/config.js b/public/js/vendor/ckeditor/config.js index 2a7c9a0..e04fce3 100644 --- a/public/js/vendor/ckeditor/config.js +++ b/public/js/vendor/ckeditor/config.js @@ -98,4 +98,8 @@ // Color of the toolbar (changes '-' placeholders color) config.uiColor = '#f5f5f5'; + + // User should not be asked to confirm close, if any dialog field was + // modified. + config.dialog_noConfirmCancel = true; }; diff --git a/public/js/views/main-layout.js b/public/js/views/main-layout.js index 8f8d966..a0c9d0b 100644 --- a/public/js/views/main-layout.js +++ b/public/js/views/main-layout.js @@ -5,7 +5,8 @@ define([ 'views/menu/mock', 'tpl!views/templates/main-layout.tpl', 'moment', - 'syphon' + 'syphon', + 'tools/alert-overriding', ], function ( App, Marionette, diff --git a/public/js/views/popup/alert.js b/public/js/views/popup/alert.js new file mode 100644 index 0000000..dbbc539 --- /dev/null +++ b/public/js/views/popup/alert.js @@ -0,0 +1,40 @@ +define([ + 'app', + 'marionette', + 'backbone', + 'tpl!views/templates/popup/alert.tpl' +], function ( + App, + Marionette, + Backbone, + AlertTpl +) { + App.Folder.Views.AlertView = Marionette.ItemView.extend({ + tagName: 'div', + id: 'alert', + template: AlertTpl, + + events: { + 'submit form': 'submit' + }, + + submit: function (event) { + event.preventDefault(); + this.trigger('form:submit'); + }, + + render: function () { + this.$el.html(this.template({ + message: this.message, + _t: i18n.t + })); + }, + + initialize: function (options) { + this.message = options.message; + } + }); + + return App.Folder.Views.AlertView; +}); + diff --git a/public/js/views/templates/popup/alert.tpl b/public/js/views/templates/popup/alert.tpl new file mode 100644 index 0000000..f1769ff --- /dev/null +++ b/public/js/views/templates/popup/alert.tpl @@ -0,0 +1,14 @@ +
+
+
+
+

+ <%= message %> +

+
+
+
+
+ +
+
\ No newline at end of file