summaryrefslogtreecommitdiff
path: root/addons/website/static/lib/summernote/src/js/module/Dialog.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-03-04 14:32:33 +0100
committerChristophe Matthieu <chm@odoo.com>2015-07-10 17:00:13 +0200
commitcebc73ebf9aa2bd6d8026473344af16726effec1 (patch)
tree55a8de23a6cf7f551aeabf58195e7ba8e1c76686 /addons/website/static/lib/summernote/src/js/module/Dialog.js
parentc1f39d0ca74486de714ea85f56b6924a9a520757 (diff)
[IMP] web_editor: move summernote & nearest lib from website
Diffstat (limited to 'addons/website/static/lib/summernote/src/js/module/Dialog.js')
-rw-r--r--addons/website/static/lib/summernote/src/js/module/Dialog.js158
1 files changed, 0 insertions, 158 deletions
diff --git a/addons/website/static/lib/summernote/src/js/module/Dialog.js b/addons/website/static/lib/summernote/src/js/module/Dialog.js
deleted file mode 100644
index 8e7cf07b323..00000000000
--- a/addons/website/static/lib/summernote/src/js/module/Dialog.js
+++ /dev/null
@@ -1,158 +0,0 @@
-define('summernote/module/Dialog', function () {
- /**
- * Dialog
- *
- * @class
- */
- var Dialog = function () {
-
- /**
- * toggle button status
- *
- * @param {jQuery} $btn
- * @param {Boolean} isEnable
- */
- var toggleBtn = function ($btn, isEnable) {
- $btn.toggleClass('disabled', !isEnable);
- $btn.attr('disabled', !isEnable);
- };
-
- /**
- * show image dialog
- *
- * @param {jQuery} $editable
- * @param {jQuery} $dialog
- * @return {Promise}
- */
- this.showImageDialog = function ($editable, $dialog) {
- return $.Deferred(function (deferred) {
- var $imageDialog = $dialog.find('.note-image-dialog');
-
- var $imageInput = $dialog.find('.note-image-input'),
- $imageUrl = $dialog.find('.note-image-url'),
- $imageBtn = $dialog.find('.note-image-btn');
-
- $imageDialog.one('shown.bs.modal', function () {
- // Cloning imageInput to clear element.
- $imageInput.replaceWith($imageInput.clone()
- .on('change', function () {
- deferred.resolve(this.files || this.value);
- $imageDialog.modal('hide');
- })
- .val('')
- );
-
- $imageBtn.click(function (event) {
- event.preventDefault();
-
- deferred.resolve($imageUrl.val());
- $imageDialog.modal('hide');
- });
-
- $imageUrl.on('keyup paste', function (event) {
- var url;
-
- if (event.type === 'paste') {
- url = event.originalEvent.clipboardData.getData('text');
- } else {
- url = $imageUrl.val();
- }
-
- toggleBtn($imageBtn, url);
- }).val('').trigger('focus');
- }).one('hidden.bs.modal', function () {
- $imageInput.off('change');
- $imageUrl.off('keyup paste');
- $imageBtn.off('click');
-
- if (deferred.state() === 'pending') {
- deferred.reject();
- }
- }).modal('show');
- });
- };
-
- /**
- * Show link dialog and set event handlers on dialog controls.
- *
- * @param {jQuery} $dialog
- * @param {Object} linkInfo
- * @return {Promise}
- */
- this.showLinkDialog = function ($editable, $dialog, linkInfo) {
- return $.Deferred(function (deferred) {
- var $linkDialog = $dialog.find('.note-link-dialog');
-
- var $linkText = $linkDialog.find('.note-link-text'),
- $linkUrl = $linkDialog.find('.note-link-url'),
- $linkBtn = $linkDialog.find('.note-link-btn'),
- $openInNewWindow = $linkDialog.find('input[type=checkbox]');
-
- $linkDialog.one('shown.bs.modal', function () {
- $linkText.val(linkInfo.text);
-
- $linkText.on('input', function () {
- // if linktext was modified by keyup,
- // stop cloning text from linkUrl
- linkInfo.text = $linkText.val();
- });
-
- // if no url was given, copy text to url
- if (!linkInfo.url) {
- linkInfo.url = linkInfo.text;
- toggleBtn($linkBtn, linkInfo.text);
- }
-
- $linkUrl.on('input', function () {
- toggleBtn($linkBtn, $linkUrl.val());
- // display same link on `Text to display` input
- // when create a new link
- if (!linkInfo.text) {
- $linkText.val($linkUrl.val());
- }
- }).val(linkInfo.url).trigger('focus').trigger('select');
-
- $openInNewWindow.prop('checked', linkInfo.newWindow);
-
- $linkBtn.one('click', function (event) {
- event.preventDefault();
-
- deferred.resolve({
- range: linkInfo.range,
- url: $linkUrl.val(),
- text: $linkText.val(),
- newWindow: $openInNewWindow.is(':checked')
- });
- $linkDialog.modal('hide');
- });
- }).one('hidden.bs.modal', function () {
- // detach events
- $linkText.off('input');
- $linkUrl.off('input');
- $linkBtn.off('click');
-
- if (deferred.state() === 'pending') {
- deferred.reject();
- }
- }).modal('show');
- }).promise();
- };
-
- /**
- * show help dialog
- *
- * @param {jQuery} $dialog
- */
- this.showHelpDialog = function ($editable, $dialog) {
- return $.Deferred(function (deferred) {
- var $helpDialog = $dialog.find('.note-help-dialog');
-
- $helpDialog.one('hidden.bs.modal', function () {
- deferred.resolve();
- }).modal('show');
- }).promise();
- };
- };
-
- return Dialog;
-});