From b59f6618939313a3d4a31963e5e91e69160ad69b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 4 Jun 2013 22:34:21 +0000 Subject: [PATCH] Add portlet created by context menu to bottom, since mouse position is unknown --- home/js/app.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/home/js/app.js b/home/js/app.js index bee8aff78c..a3d2c3af63 100644 --- a/home/js/app.js +++ b/home/js/app.js @@ -104,8 +104,11 @@ app.home = AppJS.extend( /** * Add a new portlet from the context menu */ - add: function(action) { - var attrs = {id: this._create_id()}; + add: function(action, source) { + // Put it in the last row, first column, since the mouse position is unknown + var max_row = Math.max.apply(null,$j('div',this.portlet_container.div).map(function() {return $j(this).attr('data-row');})); + var attrs = {id: this._create_id(), row: max_row + 1, col: 1}; + var portlet = et2_createWidget('portlet',attrs, this.portlet_container); portlet.loadingFinished(); @@ -115,7 +118,9 @@ app.home = AppJS.extend( // Set up sorting/grid of new portlet var $portlet_container = $j(this.portlet_container.getDOMNode()); $portlet_container.data("gridster").add_widget( - portlet.getDOMNode() + portlet.getDOMNode(), + this.DEFAULT.WIDTH, this.DEFAULT.HEIGHT, + attrs.col, attrs.row ); },