Skip to content
Permalink
Browse files

Merge branch 't/9816'

  • Loading branch information...
oleq committed Aug 26, 2013
2 parents e6f88ac + 2252695 commit 711cec94ec8e65b6801fc4c43edcf71bc0c09e9d
Showing with 298 additions and 195 deletions.
  1. +2 −0 CHANGES.md
  2. +67 −0 core/tools.js
  3. +229 −195 plugins/floatingspace/plugin.js
@@ -3,6 +3,8 @@ CKEditor 4 Changelog

## CKEditor 4.2.1

* [#9816](http://dev.ckeditor.com/ticket/9816): Floating toolbar does not reposition vertically in several cases.

## CKEditor 4.2

**Important Notes:**
@@ -1012,6 +1012,73 @@
}

return !!domain;
},

/**
* Buffers `input` events (or any `input` calls)
* and triggers `output` not more often than once per `minInterval`.
*
* var buffer = CKEDITOR.tools.eventsBuffer( 200, function() {
* console.log( 'foo!' );
* } );
*
* buffer.input();
* // 'foo!' logged immediately
* buffer.input();
* // nothing logged
* buffer.input();
* // nothing logged
* // ... after 200ms single 'foo!' will be logged
*
* Can be easily used with event:
*
* var buffer = CKEDITOR.tools.eventsBuffer( 200, function() {
* console.log( 'foo!' );
* } );
*
* editor.on( 'key', buffer.input );
* // Note: there's no need to bind buffer as a context.
*
* @since 4.2.1
* @param {Number} minInterval Minimum interval between `output` calls in milliseconds.
* @param {Function} output Function that will be executed as `output`.
* @returns {Object}
* @returns {Function} return.input Buffer's input method.
* @returns {Function} return.reset Resets buffered events – `output` will not be executed
* until next `input` is triggered.
*/
eventsBuffer: function( minInterval, output ) {
var scheduled,
lastOutput = 0;

function triggerOutput() {
lastOutput = ( new Date() ).getTime();
scheduled = false;
output();
}

return {
input: function() {
if ( scheduled )
return;

var diff = ( new Date() ).getTime() - lastOutput;

// If less than minInterval passed after last check,
// schedule next for minInterval after previous one.
if ( diff < minInterval )
scheduled = setTimeout( triggerOutput, minInterval - diff );
else
triggerOutput();
},

reset: function() {
if ( scheduled )
clearTimeout( scheduled );

scheduled = lastOutput = 0;
}
};
}
};
})();

0 comments on commit 711cec9

Please sign in to comment.
You can’t perform that action at this time.