|
From: <pe...@us...> - 2012-09-25 14:30:48
|
Revision: 1019
http://openautomation.svn.sourceforge.net/openautomation/?rev=1019&view=rev
Author: peuter
Date: 2012-09-25 14:30:37 +0000 (Tue, 25 Sep 2012)
Log Message:
-----------
* refactoring of navbar activation handling: all navbars in the current page tree should be visible now no matter which pages you visited in the past
* added scope-attribute to navbars which controls the inheritance level of navbars
scope="0" => no inheritance at all, the navbar in only visibly on the page it is defined for
scope="1" => the navbar is visible on the page is is defined for and the direct child-pages
...
default value scope="-1" => full inheritance (behaviour as it is currently implemented)
Modified Paths:
--------------
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/structure/pure/navbar.js
CometVisu/trunk/visu/visu_config.xsd
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-09-25 12:25:11 UTC (rev 1018)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-09-25 14:30:37 UTC (rev 1019)
@@ -47,7 +47,7 @@
for( key in json ) {
$.event.trigger( '_' + key, json[key] );
}
-}
+};
visu.user = 'demo_user'; // example for setting a user
var configSuffix;
@@ -314,14 +314,14 @@
setup_page(xml);
}
}
- }
+ };
js.onload = function () {
pluginsToLoad -= 1;
if (pluginsToLoad <= 0) {
setup_page(xml);
}
- }
+ };
} );
// then the mappings
@@ -451,11 +451,6 @@
}
if ($.getUrlVar('startpage')) {
- // show the global navbars
- $('#id_0_top_navbar').addClass('navbarActive');
- $('#id_0_right_navbar').addClass('navbarActive');
- $('#id_0_bottom_navbar').addClass('navbarActive');
- $('#id_0_left_navbar').addClass('navbarActive');
scrollToPage( 'id_'+$.getUrlVar('startpage'), 0 );
} else {
scrollToPage( 'id_0', 0 ); // simple solution to show page name on top at start
@@ -474,7 +469,7 @@
// browser back button takes back to the last page
scrollToPage(lastpage,0,true);
}
- }
+ };
$('embed').each( function () {
this.onload = function(){
@@ -680,10 +675,11 @@
main_scroll.seekTo( page, speed ); // scroll to it
// show the navbars for this page
- $('#'+page_id+'_top_navbar').addClass('navbarActive');
+ /*$('#'+page_id+'_top_navbar').addClass('navbarActive');
$('#'+page_id+'_right_navbar').addClass('navbarActive');
$('#'+page_id+'_bottom_navbar').addClass('navbarActive');
- $('#'+page_id+'_left_navbar').addClass('navbarActive');
+ $('#'+page_id+'_left_navbar').addClass('navbarActive');*/
+ initializeNavbars(page_id);
var pagedivs=$('div', '#'+page_id);
for( var i = 0; i<pagedivs.length; i++) { // check for inline diagrams & refresh
@@ -792,7 +788,7 @@
* This creates though some "flickering" so we avoid to use it on images,
* internal iframes and others
*/
- var parenthost = window.location.protocol + "//" + window.location.host
+ var parenthost = window.location.protocol + "//" + window.location.host;
if (target.nodeName == "IFRAME" && src.indexOf(parenthost) != 0) {
target.src = '';
setTimeout( function () {
@@ -1113,6 +1109,69 @@
}
}
+/**
+ * traverse down the page tree from root page id_0 -> .. -> page_id
+ * activate all navbars in that path
+ * deactivate all others
+ * @param page_id
+ */
+function initializeNavbars(page_id) {
+ removeInactiveNavbars(page_id);
+ var tree = [$('#id_0').get(0)];
+ if (page_id!="id_0") {
+ var parts = page_id.split("_");
+ parts = parts.slice(2,parts.length);
+ for (var i=0; i<parts.length; i++) {
+ var item = $('#id_0_'+parts.slice(0,i+1).join('_')+".page",'#pages');
+ if (item.size()==1) {
+ tree.push(item.get(0));
+ }
+ }
+ }
+ var level = 1;
+ $(tree).each(function (i) {
+ var id = $(this).attr('id');
+ var topNav = $('#'+id+'_top_navbar');
+ var rightNav = $('#'+id+'_right_navbar');
+ var bottomNav = $('#'+id+'_bottom_navbar');
+ var leftNav = $('#'+id+'_left_navbar');
+ //console.log(tree.length+"-"+level+"<="+topNav.data('scope'));
+ if (topNav.size()>0) {
+ if (topNav.data('scope')==undefined || topNav.data('scope')<0 || tree.length-level<=topNav.data('scope')) {
+ topNav.addClass('navbarActive');
+ }
+ else {
+ topNav.removeClass('navbarActive');
+ }
+ }
+ if (rightNav.size()>0) {
+ if (rightNav.data('scope')==undefined || rightNav.data('scope')<0 || tree.length-level<=rightNav.data('scope')) {
+ rightNav.addClass('navbarActive');
+ }
+ else {
+ rightNav.removeClass('navbarActive');
+ }
+ }
+ if (bottomNav.size()>0) {
+ if (bottomNav.data('scope')==undefined || bottomNav.data('scope')<0 || tree.length-level<=bottomNav.data('scope')) {
+ bottomNav.addClass('navbarActive');
+ }
+ else {
+ bottomNav.removeClass('navbarActive');
+ }
+ }
+ if (leftNav.size()>0) {
+ if (leftNav.data('scope')==undefined || leftNav.data('scope')<0 || tree.length-level<=leftNav.data('scope')) {
+ leftNav.addClass('navbarActive');
+ }
+ else {
+ leftNav.removeClass('navbarActive');
+ }
+ }
+ level++;
+ });
+}
+
function removeInactiveNavbars(page_id) {
// remove all navbars that do not belong to this page
$('.navbar.navbarActive').each(function(i) {
Modified: CometVisu/trunk/visu/structure/pure/navbar.js
===================================================================
--- CometVisu/trunk/visu/structure/pure/navbar.js 2012-09-25 12:25:11 UTC (rev 1018)
+++ CometVisu/trunk/visu/structure/pure/navbar.js 2012-09-25 14:30:37 UTC (rev 1019)
@@ -21,15 +21,16 @@
var childs = $n.children();
var id = path.split('_'); id.pop();
var position = $n.attr('position') || 'left';
+ var scope = $n.attr('scope') || -1;
var container = $( '<div class="navbar clearfix" id="' + id.join('_')+'_'+ position + '_navbar" />' );
if( $n.attr('name') ) container.append( '<h2 ' + hstyle + '>' + $n.attr('name') + '</h2>' );
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
} );
-
+ container.data('scope',scope);
var dynamic = $n.attr('dynamic') == 'true' ? true : false;
- var size = $n.attr('width') || 300;
+ var size = $n.attr('width') || 300;
switch( position )
{
case 'top':
Modified: CometVisu/trunk/visu/visu_config.xsd
===================================================================
--- CometVisu/trunk/visu/visu_config.xsd 2012-09-25 12:25:11 UTC (rev 1018)
+++ CometVisu/trunk/visu/visu_config.xsd 2012-09-25 14:30:37 UTC (rev 1019)
@@ -324,6 +324,7 @@
<xsd:attribute name="position" type="navbarPositionType" use="required" />
<xsd:attribute name="dynamic" type="true_false" use="optional" />
<xsd:attribute name="width" type="xsd:string" use="optional" />
+ <xsd:attribute name="scope" type="xsd:decimal" use="optional" />
</xsd:complexType>
<!-- more fun part - all widgets - if you add a new widget, you need to define it here -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|