Skip to content

Commit

Permalink
MDL-41238 atto - close menu style when clicking anywhere outside it
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnfwlr committed Sep 6, 2013
1 parent b69ec28 commit 21f6c52
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ M.editor_atto = M.editor_atto || {
var disabled = this.getAttribute('disabled');
var overlayid = this.getAttribute('data-menu');
var overlay = M.editor_atto.menus[overlayid];

var menu = overlay.get('bodyContent');
if (overlay.get('visible') || disabled) {
overlay.hide();
menu.detach('clickoutside');
} else {
menu.on('clickoutside', function(ev) {
if (ev.target.ancestor() !== this) {
if (overlay.get('visible')) {
menu.detach('clickoutside');
overlay.hide();
}
}
}, this);
overlay.show();
}

},

/**
Expand Down Expand Up @@ -163,7 +171,6 @@ M.editor_atto = M.editor_atto || {

var menu = Y.Node.create('<div class="atto_' + plugin + '_menu' +
' atto_menu" data-editor="' + Y.Escape.html(elementid) + '"></div>');

var i = 0, entry = {};

for (i = 0; i < entries.length; i++) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ M.editor_atto = M.editor_atto || {
var disabled = this.getAttribute('disabled');
var overlayid = this.getAttribute('data-menu');
var overlay = M.editor_atto.menus[overlayid];

var menu = overlay.get('bodyContent');
if (overlay.get('visible') || disabled) {
overlay.hide();
menu.detach('clickoutside');
} else {
menu.on('clickoutside', function(ev) {
if (ev.target.ancestor() !== this) {
if (overlay.get('visible')) {
menu.detach('clickoutside');
overlay.hide();
}
}
}, this);
overlay.show();
}

},

/**
Expand Down Expand Up @@ -163,7 +171,6 @@ M.editor_atto = M.editor_atto || {

var menu = Y.Node.create('<div class="atto_' + plugin + '_menu' +
' atto_menu" data-editor="' + Y.Escape.html(elementid) + '"></div>');

var i = 0, entry = {};

for (i = 0; i < entries.length; i++) {
Expand Down
13 changes: 10 additions & 3 deletions lib/editor/atto/yui/src/editor/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ M.editor_atto = M.editor_atto || {
var disabled = this.getAttribute('disabled');
var overlayid = this.getAttribute('data-menu');
var overlay = M.editor_atto.menus[overlayid];

var menu = overlay.get('bodyContent');
if (overlay.get('visible') || disabled) {
overlay.hide();
menu.detach('clickoutside');
} else {
menu.on('clickoutside', function(ev) {
if (ev.target.ancestor() !== this) {
if (overlay.get('visible')) {
menu.detach('clickoutside');
overlay.hide();
}
}
}, this);
overlay.show();
}

},

/**
Expand Down Expand Up @@ -161,7 +169,6 @@ M.editor_atto = M.editor_atto || {

var menu = Y.Node.create('<div class="atto_' + plugin + '_menu' +
' atto_menu" data-editor="' + Y.Escape.html(elementid) + '"></div>');

var i = 0, entry = {};

for (i = 0; i < entries.length; i++) {
Expand Down

0 comments on commit 21f6c52

Please sign in to comment.