Skip to content

Commit d8ac852

Browse files
committed
Merge branch 't/13213c' into major
2 parents 053d834 + 85f7f17 commit d8ac852

File tree

10 files changed

+403
-59
lines changed

10 files changed

+403
-59
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ New Features:
77

88
* [#13304](http://dev.ckeditor.com/ticket/13304): Added support for passing DOM elements to [`config.sharedSpaces`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-sharedSpaces). Thanks to [Undergrounder](https://github.com/Undergrounder)!
99
* [#13215](http://dev.ckeditor.com/ticket/13215): Added ability to cancel fetching a resource by the Embed plugins.
10+
* [#13213](http://dev.ckeditor.com/ticket/13213): Added [`dialog#setState()`](http://docs.ckeditor.com/#!/api/CKEDITOR.dialog-method-setState) method and used in in Embed dialog to indicate that a resource is being loaded.
1011
* [#13337](http://dev.ckeditor.com/ticket/13337): Added the [`repository.onWidget()`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-method-onWidget) method – a convenient way to listen to [widget](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget) events through the [repository](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository).
1112

1213
Fixed Issues:

plugins/dialog/plugin.js

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
33
* For licensing, see LICENSE.md or http://ckeditor.com/license
44
*/
@@ -43,6 +43,24 @@ CKEDITOR.DIALOG_RESIZE_HEIGHT = 2;
4343
*/
4444
CKEDITOR.DIALOG_RESIZE_BOTH = 3;
4545

46+
/**
47+
* Dialog state when idle.
48+
*
49+
* @readonly
50+
* @property {Number} [=1]
51+
* @member CKEDITOR
52+
*/
53+
CKEDITOR.DIALOG_STATE_IDLE = 1;
54+
55+
/**
56+
* Dialog state when busy.
57+
*
58+
* @readonly
59+
* @property {Number} [=2]
60+
* @member CKEDITOR
61+
*/
62+
CKEDITOR.DIALOG_STATE_BUSY = 2;
63+
4664
( function() {
4765
var cssLength = CKEDITOR.tools.cssLength;
4866

@@ -323,6 +341,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
323341
} );
324342
}
325343

344+
// Set default dialog state.
345+
this.state = CKEDITOR.DIALOG_STATE_IDLE;
346+
326347
if ( definition.onCancel ) {
327348
this.on( 'cancel', function( evt ) {
328349
if ( definition.onCancel.call( this, evt ) === false )
@@ -640,6 +661,14 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
640661

641662
for ( i = 0; i < buttons.length; i++ )
642663
this._.buttons[ buttons[ i ].id ] = buttons[ i ];
664+
665+
/**
666+
* Current state of the dialog. Use {@link #setState} method to update it.
667+
* See {@link #event-state} event to know more.
668+
*
669+
* @readonly
670+
* @property {Number} [state=CKEDITOR.DIALOG_STATE_IDLE]
671+
*/
643672
};
644673

645674
// Focusable interface. Use it via dialog.addFocusable.
@@ -1078,6 +1107,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
10781107
this.foreach( function( contentObj ) {
10791108
contentObj.resetInitValue && contentObj.resetInitValue();
10801109
} );
1110+
1111+
// Reset dialog state back to IDLE, if busy (#13213).
1112+
this.setState( CKEDITOR.DIALOG_STATE_IDLE );
10811113
},
10821114

10831115
/**
@@ -1401,6 +1433,52 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
14011433
for ( var i = index + 1; i < this._.focusList.length; i++ )
14021434
this._.focusList[ i ].focusIndex++;
14031435
}
1436+
},
1437+
1438+
/**
1439+
* Sets dialog {@link #property-state}.
1440+
*
1441+
* @since 4.5
1442+
* @param {Number} state Either {@link CKEDITOR#DIALOG_STATE_IDLE} or {@link CKEDITOR#DIALOG_STATE_BUSY}.
1443+
*/
1444+
setState: function( state ) {
1445+
var oldState = this.state;
1446+
1447+
if ( oldState == state ) {
1448+
return;
1449+
}
1450+
1451+
this.state = state;
1452+
1453+
if ( state == CKEDITOR.DIALOG_STATE_BUSY ) {
1454+
// Insert the spinner on demand.
1455+
if ( !this.parts.spinner ) {
1456+
this.parts.spinner = CKEDITOR.document.createElement( 'div', {
1457+
attributes: {
1458+
'class': 'cke_dialog_spinner'
1459+
},
1460+
styles: {
1461+
'float': 'left',
1462+
'margin-right': '8px'
1463+
}
1464+
} );
1465+
1466+
this.parts.spinner.setHtml( '&#8987;' );
1467+
this.parts.spinner.appendTo( this.parts.title, 1 );
1468+
}
1469+
1470+
// Finally, show the spinner.
1471+
this.parts.spinner.show();
1472+
1473+
this.getButton( 'ok' ).disable();
1474+
} else if ( state == CKEDITOR.DIALOG_STATE_IDLE ) {
1475+
// Hide the spinner. But don't do anything if there is no spinner yet.
1476+
this.parts.spinner && this.parts.spinner.hide();
1477+
1478+
this.getButton( 'ok' ).enable();
1479+
}
1480+
1481+
this.fire( 'state', state );
14041482
}
14051483
};
14061484

@@ -3301,3 +3379,13 @@ CKEDITOR.plugins.add( 'dialog', {
33013379
* @param {Number} data.width The new width.
33023380
* @param {Number} data.height The new height.
33033381
*/
3382+
3383+
/**
3384+
* Fired when a dialog state changes, usually by {@link CKEDITOR.dialog#setState}.
3385+
*
3386+
* @since 4.5
3387+
* @event state
3388+
* @member CKEDITOR.dialog
3389+
* @param data
3390+
* @param {Number} data The new state. Either {@link CKEDITOR#DIALOG_STATE_IDLE} or {@link CKEDITOR#DIALOG_STATE_BUSY}.
3391+
*/

plugins/embedbase/dialogs/embedbase.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ CKEDITOR.dialog.add( 'embedBase', function( editor ) {
1717

1818
onLoad: function() {
1919
var that = this,
20-
okButton = that.getButton( 'ok' ),
2120
loadContentRequest = null;
2221

2322
this.on( 'ok', function( evt ) {
2423
// We're going to hide it manually, after remote response is fetched.
2524
evt.data.hide = false;
2625

27-
// Disable the OK button for the time of loading, so user can't trigger multiple inserts.
28-
okButton.disable();
29-
3026
// We don't want the widget system to finalize widget insertion (it happens with priority 20).
3127
evt.stop();
3228

29+
// Indicate visually that waiting for the response (#13213).
30+
that.setState( CKEDITOR.DIALOG_STATE_BUSY );
31+
3332
var url = that.getValueOf( 'info', 'url' );
3433

3534
loadContentRequest = that.widget.loadContent( url, {
@@ -64,7 +63,8 @@ CKEDITOR.dialog.add( 'embedBase', function( editor ) {
6463
} );
6564

6665
function unlock() {
67-
okButton.enable();
66+
// Visual waiting indicator is no longer needed (#13213).
67+
that.setState( CKEDITOR.DIALOG_STATE_IDLE );
6868
loadContentRequest = null;
6969
}
7070
},

skins/kama/dialog.css

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Comments in this file will give more details about each of the above blocks.
5454
border: solid 1px #ddd;
5555
padding: 5px;
5656
background-color: #fff;
57-
-moz-border-radius: 5px;
58-
-webkit-border-radius: 5px;
5957
border-radius: 5px;
6058
}
6159

@@ -76,6 +74,59 @@ Comments in this file will give more details about each of the above blocks.
7674
border-bottom: 1px solid #eee;
7775
}
7876

77+
.cke_dialog_spinner
78+
{
79+
border-radius: 50%;
80+
81+
width: 12px;
82+
height: 12px;
83+
overflow: hidden;
84+
85+
text-indent: -9999em;
86+
87+
border-top: 2px solid rgba(102, 102, 102, 0.2);
88+
border-right: 2px solid rgba(102, 102, 102, 0.2);
89+
border-bottom: 2px solid rgba(102, 102, 102, 0.2);
90+
border-left: 2px solid rgba(102, 102, 102, 1);
91+
92+
-webkit-animation: dialog_spinner 1s infinite linear;
93+
animation: dialog_spinner 1s infinite linear;
94+
}
95+
96+
/* A GIF fallback for IE8 and IE9 which does not support CSS animations. */
97+
.cke_browser_ie8 .cke_dialog_spinner,
98+
.cke_browser_ie9 .cke_dialog_spinner
99+
{
100+
background: url(images/spinner.gif) center top no-repeat;
101+
width: 16px;
102+
height: 16px;
103+
border: 0;
104+
}
105+
106+
@-webkit-keyframes dialog_spinner
107+
{
108+
0% {
109+
-webkit-transform: rotate(0deg);
110+
transform: rotate(0deg);
111+
}
112+
100% {
113+
-webkit-transform: rotate(360deg);
114+
transform: rotate(360deg);
115+
}
116+
}
117+
118+
@keyframes dialog_spinner
119+
{
120+
0% {
121+
-webkit-transform: rotate(0deg);
122+
transform: rotate(0deg);
123+
}
124+
100% {
125+
-webkit-transform: rotate(360deg);
126+
transform: rotate(360deg);
127+
}
128+
}
129+
79130
/* The outer part of the dialog contants, which contains the contents body
80131
and the footer. */
81132
.cke_dialog_contents
@@ -85,10 +136,6 @@ Comments in this file will give more details about each of the above blocks.
85136
border-bottom: none;
86137
overflow: auto;
87138
padding: 17px 10px 5px 10px;
88-
-moz-border-radius-topleft: 5px;
89-
-moz-border-radius-topright: 5px;
90-
-webkit-border-top-left-radius: 5px;
91-
-webkit-border-top-right-radius: 5px;
92139
border-top-left-radius: 5px;
93140
border-top-right-radius: 5px;
94141
margin-top: 22px;
@@ -110,10 +157,6 @@ Comments in this file will give more details about each of the above blocks.
110157
background-color: #ebebeb;
111158
border: solid 1px #fff;
112159
border-bottom: none;
113-
-moz-border-radius-bottomleft: 5px;
114-
-moz-border-radius-bottomright: 5px;
115-
-webkit-border-bottom-left-radius: 5px;
116-
-webkit-border-bottom-right-radius: 5px;
117160
border-bottom-left-radius: 5px;
118161
border-bottom-right-radius: 5px;
119162
}
@@ -457,8 +500,6 @@ a.cke_dialog_ui_button
457500
border-collapse: separate;
458501
cursor: default;
459502

460-
-moz-border-radius: 5px;
461-
-webkit-border-radius: 5px;
462503
border-radius: 5px;
463504
background: transparent url(images/sprites.png) repeat-x scroll 0 -1069px;
464505
text-align: center;

skins/kama/images/spinner.gif

4.71 KB
Loading

0 commit comments

Comments
 (0)