Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Disable when editor expand is off.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 1, 2014
1 parent 07fcd58 commit fa1120e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
4 changes: 4 additions & 0 deletions editor-expand.js
Expand Up @@ -661,6 +661,8 @@ jQuery( document ).ready( function( $ ) {
}

adjust();

$document.trigger( 'editor-expand-on' );
}

function off() {
Expand Down Expand Up @@ -705,6 +707,8 @@ jQuery( document ).ready( function( $ ) {
if ( height ) {
$textEditor.height( height );
}

$document.trigger( 'editor-expand-off' );
}

// Start on load
Expand Down
32 changes: 27 additions & 5 deletions focus.js
Expand Up @@ -22,7 +22,8 @@ window.jQuery( function( $ ) {
mceBind = function() {},
mceUnbind = function() {},
dfw = window.getUserSetting( 'dfw' ),
isOn = dfw ? !! parseInt( dfw, 10 ) : true,
isActive = window.getUserSetting( 'editor_expand' ) === 'on',
isOn = isActive ? dfw ? !! parseInt( dfw, 10 ) : true : false,
traveledX = 0,
traveledY = 0,
buffer = 20,
Expand Down Expand Up @@ -55,8 +56,26 @@ window.jQuery( function( $ ) {
mouseY = event.pageY;
} );

function activate() {
if ( ! isActive ) {
isActive = true;

button.disabled( false );
}
}

function deactivate() {
if ( isActive ) {
off();

isActive = false;

button.disabled( true );
}
}

function on() {
if ( ! isOn ) {
if ( ! isOn && isActive ) {
isOn = true;

mceBind();
Expand Down Expand Up @@ -319,12 +338,13 @@ window.jQuery( function( $ ) {

$document.on( 'tinymce-editor-setup.focus', function( event, editor ) {
editor.addButton( 'wp_fullscreen', {
tooltip: 'Distraction Free Writing',
onclick: toggle,
classes: 'wp-fullscreen btn widget',
disabled: ! isActive,
onclick: toggle,
onPostRender: function() {
button = this;
}
},
tooltip: 'Distraction Free Writing',
} );
} );

Expand Down Expand Up @@ -370,6 +390,8 @@ window.jQuery( function( $ ) {
}
} );

$document.on( 'editor-expand-on.focus', activate ).on( 'editor-expand-off.focus', deactivate );

if ( isOn ) {
$content.on( 'keydown.focus', fadeOut );

Expand Down

0 comments on commit fa1120e

Please sign in to comment.