[Piwik-svn] r339 - in trunk/plugins: Dashboard/templates Home/templates
svnmaster at piwik.org
svnmaster at piwik.org
Mon Mar 10 00:05:22 CET 2008
Author: julien
Date: 2008-03-10 00:05:21 +0100 (Mon, 10 Mar 2008)
New Revision: 339
Modified:
trunk/plugins/Dashboard/templates/Dashboard.js
trunk/plugins/Dashboard/templates/header.tpl
trunk/plugins/Dashboard/templates/index.tpl
trunk/plugins/Home/templates/datatable.js
Log:
-Some refactoring on dashboard
-Fixed useless ajax request when widget is drag and dropped but dashboard layout isn't modified (that's funny how fixing a bug can sometimes be a lot simpler than explaining what it was about in the svn log...)
Modified: trunk/plugins/Dashboard/templates/Dashboard.js
===================================================================
--- trunk/plugins/Dashboard/templates/Dashboard.js 2008-03-09 22:46:50 UTC (rev 338)
+++ trunk/plugins/Dashboard/templates/Dashboard.js 2008-03-09 23:05:21 UTC (rev 339)
@@ -5,11 +5,11 @@
if(typeof dashboard_translation == "undefined")
{
var dashboard_translation = {
- titleWidgetInDashboard: 'Widget already in dashboard',
- titleClickToAdd: 'Click to add to dashboard',
- loadingPreview: 'Loading preview, please wait...',
- loadingWidget: 'Loading widget, please wait...',
- widgetNotFound: 'Widget not found'
+ titleWidgetInDashboard: 'Widget already in dashboard',
+ titleClickToAdd: 'Click to add to dashboard',
+ loadingPreview: 'Loading preview, please wait...',
+ loadingWidget: 'Loading widget, please wait...',
+ widgetNotFound: 'Widget not found'
};
}
@@ -91,8 +91,8 @@
var exist = $('.subMenuItem#'+plugin, subMenu1);
if(exist.size()==0)
{
- $('ol', self.subMenu1).append('<li class="subMenuItem" id="'+plugin+'"><span>'+plugin+'</span></li>');
- $('ul', self.subMenu2).append('<li class="subMenuItem" id="'+plugin+'"></li>');
+ $('ol', subMenu1).append('<li class="subMenuItem" id="'+plugin+'"><span>'+plugin+'</span></li>');
+ $('ul', subMenu2).append('<li class="subMenuItem" id="'+plugin+'"></li>');
}
var sm2Div = $('.subMenuItem#'+plugin, subMenu2);
@@ -183,7 +183,7 @@
//list loaded widget:
var widgets = new Array;
- $('.col').each(
+ self.dashboard.getColumns().each(
function()
{
widgets = widgets.concat(getWidgetInDom(this));
@@ -216,7 +216,7 @@
self.dashboard.addEmptyWidget(1, plugin, action, true);
- var parDiv = $('.col#1 .widgetDiv[plugin='+plugin+']'+'#'+action);
+ var parDiv = $('.widgetDiv[plugin='+plugin+']'+'#'+action, self.dashboard.getColumns()[0]);
parDiv.show();
parDiv.siblings('.widgetLoading').hide();
@@ -242,28 +242,40 @@
function dashboard()
{
this.test = new Object;
+ this.dashArea = new Object;
+ this.dashColumns = new Object;
+ this.layout = '';
}
//Prototype of the dashboard object
dashboard.prototype =
{
- init: function()
+ init: function(layout)
{
var self = this;
+ self.dashArea = $('#dashboardWidgetsArea');
+ self.dashColumns = $('.col', self.dashDom);
+ self.layout = layout;
+
//generate dashboard layout and load every displayed widgets
self.generateLayout();
//setup widget dynamic behaviour
self.setupWidgetSortable();
},
-
+
+ getColumns: function()
+ {
+ return this.dashColumns;
+ },
+
setupWidgetSortable: function()
{
var self = this;
//add a dummy item on each columns
- $('.col').each(
+ self.dashColumns.each(
function()
{
$(this).append('<div class="items dummyItem"><div class="handle dummyHandle"></div></div>');
@@ -283,7 +295,7 @@
//'|' separate columns
//'~' separate widgets
//'.' separate plugin name from action name
- var col = piwik.dashboardLayout.split('|');
+ var col = self.layout.split('|');
for(var i=0; i<col.length; i++)
{
if(col[i] != '')
@@ -309,18 +321,18 @@
if(onTop)
{
- $('.col#'+colNumber).prepend(item);
+ $(self.dashColumns[colNumber-1]).prepend(item);
}
else
{
- $('.col#'+colNumber).append(item);
+ $(self.dashColumns[colNumber-1]).append(item);
}
//find the title of the widget
var title = self.getWidgetTitle(plugin, action);
//add an handle to each items
- var widget = $('.col#'+colNumber+' .widgetDiv#'+action+'[plugin='+plugin+']').parents('.widget');
+ var widget = $('.widgetDiv#'+action+'[plugin='+plugin+']', self.dashColumns[colNumber-1]).parents('.widget');
self.addHandleToWidget(widget, title);
var button = $('.button#close', widget);
@@ -366,7 +378,7 @@
var self = this;
self.addEmptyWidget(colNumber, plugin, action, onTop);
- self.loadItem($('.items [plugin='+plugin+']#'+action).parents('.items'));
+ self.loadItem($('.items [plugin='+plugin+']#'+action, self.dashArea).parents('.items'));
},
addHandleToWidget: function(widget, title)
@@ -417,15 +429,15 @@
}
//launch 'sortable' property on every dashboard widgets
- $('.sortDiv').sortableDestroy()
- .sortable({
- items:'.items',
- hoverClass: 'hover',
- handle: '.handle',
- helper: getHelper,
- start: onStart,
- stop: onStop
- });
+ self.dashArea.sortableDestroy()
+ .sortable({
+ items:'.items',
+ hoverClass: 'hover',
+ handle: '.handle',
+ helper: getHelper,
+ start: onStart,
+ stop: onStop
+ });
},
onDeleteItem: function(target, ev)
@@ -480,7 +492,7 @@
var self = this;
var column = new Array;
//parse the dom to see how our div are sorted
- $('.sortDiv .col').each(function() {
+ self.dashColumns.each(function() {
column.push(getWidgetInDom(this));
});
@@ -500,8 +512,12 @@
layout += column[i].join('~');
layout += '|';
}
- ajaxRequest.data['layout'] = layout;
- $.ajax(ajaxRequest);
+ if(layout != self.layout)
+ {
+ self.layout = layout;
+ ajaxRequest.data['layout'] = layout;
+ $.ajax(ajaxRequest);
+ }
},
ajaxLoading: function(pluginId, actionId, callbackAfterLoaded)
@@ -560,7 +576,7 @@
blockUIConfig();
//build the dashboard...
- dash.init();
+ dash.init(piwik.dashboardLayout);
//...and the menu
menu.init();
}
Modified: trunk/plugins/Dashboard/templates/header.tpl
===================================================================
--- trunk/plugins/Dashboard/templates/header.tpl 2008-03-09 22:46:50 UTC (rev 338)
+++ trunk/plugins/Dashboard/templates/header.tpl 2008-03-09 23:05:21 UTC (rev 339)
@@ -15,5 +15,9 @@
<script type="text/javascript" src="plugins/Home/templates/calendar.js"></script>
<script type="text/javascript" src="plugins/Home/templates/date.js"></script>
+<script type="text/javascript" src="libs/jquery/jquery.blockUI.js"></script>
+<script type="text/javascript" src="libs/jquery/ui.mouse.js"></script>
+<script type="text/javascript" src="libs/jquery/ui.sortable_modif.js"></script>
+
<link rel="stylesheet" href="plugins/Home/templates/datatable.css">
<link rel="stylesheet" href="plugins/Dashboard/templates/dashboard.css">
\ No newline at end of file
Modified: trunk/plugins/Dashboard/templates/index.tpl
===================================================================
--- trunk/plugins/Dashboard/templates/index.tpl 2008-03-09 22:46:50 UTC (rev 338)
+++ trunk/plugins/Dashboard/templates/index.tpl 2008-03-09 23:05:21 UTC (rev 339)
@@ -18,7 +18,7 @@
<script type="text/javascript" src="plugins/Dashboard/templates/Dashboard.js"></script>
-<div class="sortDiv" id="dashboard">
+<div id="dashboard">
<div class="dialog" id="confirm">
<img src="themes/default/images/delete.png" style="padding: 10px; position: relative; margin-top: 10%; float: left;"/>
@@ -55,12 +55,14 @@
<div class="menuClear"> </div>
</div>
- <div class="col" id="1">
+ <div id="dashboardWidgetsArea">
+ <div class="col" id="1">
+ </div>
+
+ <div class="col" id="2">
+ </div>
+
+ <div class="col" id="3">
+ </div>
</div>
-
- <div class="col" id="2">
- </div>
-
- <div class="col" id="3">
- </div>
</div>
Modified: trunk/plugins/Home/templates/datatable.js
===================================================================
--- trunk/plugins/Home/templates/datatable.js 2008-03-09 22:46:50 UTC (rev 338)
+++ trunk/plugins/Home/templates/datatable.js 2008-03-09 23:05:21 UTC (rev 339)
@@ -6,7 +6,7 @@
var dataTable_translation = {
includeLowPop: 'Include all population',
excludeLowPop: 'Exclude low population',
- pageOf: ' of ', //1-10 _of_ 42
+ pageOf: ' of ', //like in 1-10 _of_ 42
loading: 'Loading...'
};
}
More information about the Piwik-svn
mailing list