Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Polishing second level actions in the action menu.

  • Loading branch information...
commit d8fb2310d37a990497c925bc47294a0f71de214a 1 parent 2061ae9
@cezarsa authored
Showing with 43 additions and 12 deletions.
  1. +15 −1 css/action_menu.css
  2. +28 −11 lib/action_menu.js
View
16 css/action_menu.css
@@ -8,6 +8,7 @@ div.action_menu .action_area {
display: -webkit-box;
background-color: rgb(0, 153, 219);
-webkit-border-radius: 5px;
+ white-space: nowrap;
}
div.action_menu .action_area .second_level_hidden {
@@ -15,8 +16,21 @@ div.action_menu .action_area .second_level_hidden {
}
div.action_menu .second_level_trigger {
+ -webkit-box-flex: 1;
+ font-size: 7pt;
+ color: white;
cursor: pointer;
- font-stretch: narrower;
+ text-align: center;
+}
+
+div.action_menu.horizontal .second_level_trigger {
+ padding-top: 5px;
+ padding-right: 1px;
+ padding-left: 1px;
+}
+
+div.action_menu.vertical .second_level_trigger {
+ padding-bottom: 1px;
}
div.action_menu.horizontal div.balloon {
View
39 lib/action_menu.js
@@ -107,8 +107,11 @@ $('#trigger').actionMenu({
this.actionMenuEl.effect('bounce', {times: 2, direction: direction, distance: 10}, 200);
},
- repositionSecondLevelTrigger: function() {
- var direction = this.lastDirection;
+ updateSecondLevelTrigger: function(direction) {
+ var lastDirection = this.lastDirection;
+ if(!direction) {
+ direction = lastDirection;
+ }
var secondLevel = this.secondLevelTrigger;
var secondLevelOpened = secondLevel.data('opened');
if(secondLevelOpened) {
@@ -134,6 +137,11 @@ $('#trigger').actionMenu({
}
},
+ invertActions: function(direction, lastDirection) {
+ var actionArea = this.actionAreaEl;
+ actionArea.children().each(function() { actionArea.prepend(this); });
+ },
+
repositionActions: function() {
this.updateVisibleActions();
@@ -152,6 +160,9 @@ $('#trigger').actionMenu({
this.actionMenuEl.css({display: 'block'});
this.actionMenuEl.removeClass('vertical');
+ if(this.lastDirection) {
+ this.actionMenuEl.removeClass(this.lastDirection);
+ }
this.actionMenuEl.addClass('horizontal');
var actionMenuSize = {width: this.actionMenuEl.width(), height: this.actionMenuEl.height()};
var direction;
@@ -160,11 +171,6 @@ $('#trigger').actionMenu({
this.actionMenuEl.removeClass('horizontal');
this.actionMenuEl.addClass('vertical');
direction = 'down';
- if(secondLevelOpened) {
- secondLevel.html('↑');
- } else {
- secondLevel.html('↓');
- }
} else {
if(availableSpaceRight > actionMenuSize.width && availableSpaceBottom > actionMenuSize.height) {
direction = 'right';
@@ -214,13 +220,24 @@ $('#trigger').actionMenu({
} else if(this.lastDirection == 'up') {
this.balloon.insertBefore(this.actionAreaEl);
}
+
+ if(direction == 'right' || direction == 'down') {
+ if(this.lastDirection == 'left' || this.lastDirection == 'up') {
+ this.invertActions(direction, this.lastDirection);
+ }
+ } else {
+ if(this.lastDirection == 'right' || this.lastDirection == 'down' || !this.lastDirection) {
+ this.invertActions(direction, this.lastDirection);
+ }
+ }
+
+ this.updateSecondLevelTrigger(direction);
+
this.lastDirection = direction;
this.visible = true;
this.actionMenuEl.css({left: x, top: y});
this.actionMenuEl.addClass(direction);
- this.repositionSecondLevelTrigger();
-
return direction;
},
@@ -260,7 +277,7 @@ $('#trigger').actionMenu({
this.actionMenuEl.empty();
this.actionAreaEl = $('<div>').addClass('action_area');
this.secondLevelAreaEl = $('<div>').addClass('second_level');
- this.secondLevelTrigger = $('<div>').html('>').addClass('second_level_trigger');
+ this.secondLevelTrigger = $('<div>').addClass('second_level_trigger');
this.secondLevelTrigger.data('opened', false);
this.balloon = $('<div>').addClass('balloon');
@@ -309,7 +326,7 @@ $('#trigger').actionMenu({
secondLevelActions.removeClass('second_level_hidden');
_this.secondLevelTrigger.data('opened', true);
}
- _this.repositionSecondLevelTrigger();
+ _this.repositionActions();
});
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.