Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from deepwinter/master

Please bring lattice-resources up to date with mine
  • Loading branch information...
commit 0fdf505c0b9e9eac718a5b61964fefa3ebce5350 2 parents c72b992 + 7cbbe52
Thiago de Mello Bueno authored
213 css/navigation.css
View
@@ -0,0 +1,213 @@
+/*Navigation*/
+
+#navigation{
+ height: 27em;
+ width: 100%;
+ clear: both;
+}
+
+#navigation .container{
+ height:24em;
+ overflow:hidden;
+ border-top:1px #ccc solid;
+ border-bottom:1px #ccc solid;
+ background: #f8f8f8 url( ../images/navContainer_bg.gif );
+}
+
+#navigation .grid_2,
+#navigation .grid_3,
+#navigation .grid_4{
+ margin: 0 0 0 0;
+}
+
+#navigation .panes{
+ height: 100%;
+ position: relative;
+}
+
+#navigation .pane{
+ height: 100%;
+ width: 300px;
+ margin: 0 0 0 0;
+ padding: 0 0 0 0;
+ float: left;
+ background: #f8f8f8 url( ../images/nav_bg.gif ) repeat-y;
+}
+
+#navigation .pane.dark{
+ background: #313232 url( ../images/nav_bg_dark.gif ) repeat-y;
+}
+
+#navigation ul.nodes{
+ list-style: none;
+ overflow: auto;
+ height: 100%;
+}
+
+#navigation .node,
+.tierMethodsDrawer .addableObjects li{
+ line-height: 2;
+ height: 2em;
+ padding: .25em 0;
+ border-bottom:1px #cdf solid;
+ font-size: 1.125em;
+ /*width: 100%;*/
+}
+
+
+#navigation .node.active,
+#navigation .node:hover,
+#navigation .node:hover h5,
+#navigation .node.active h5,
+.addableObjects li:hover{
+ cursor: pointer;
+ background-color: #0af;
+ color:#fff;
+}
+
+#navigation .node h5{
+ font-size: .875em;
+ line-height:1.2em;
+ margin: 0 0 0 0;
+ padding:.5em 0 .5em 2.5em;
+ float: left;
+ background-image: url( ../images/icon_leaf.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+
+#navigation .node .methods{
+ float: right;
+ padding: 0 .5em 0 0;
+}
+
+#navigation a.icon{
+ text-indent: -3000px;
+ display:block;
+ float:left;
+ width: 12px;
+ height: 12px;
+ margin:.5em .25em;
+}
+
+#navigation .node.active h5,
+#navigation .node:hover h5{
+ background-image: url( ../images/icon_leaf_hover.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+#navigation .node.category h5{
+ background-image: url( ../images/icon_category.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+#navigation .node.category.active h5,
+#navigation .node.category:hover h5{
+ background-image: url( ../images/icon_category_hover.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+#navigation .node.module h5{
+ background-image: url( ../images/icon_module.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+#navigation .node.module.active h5,
+#navigation .node.module:hover h5{
+ background-image: url( ../images/icon_module_hover.png );
+ background-position: 1em .5em;
+ background-repeat: no-repeat;
+}
+
+#navigation .node a.removeNode{
+ background-image: url(../images/icon_delete.png);
+}
+
+#navigation .node:hover a.removeNode,
+#navigation .node.active a.removeNode{
+ background-image: url(../images/icon_delete_hover.png);
+}
+
+#navigation .node a.togglePublish{
+ background-image: url(../images/icon_unpublished.png);
+}
+
+#navigation .node a.published{
+ background-image: url(../images/icon_published.png);
+}
+
+#navigation .node.active a,
+#navigation .node:hover a{
+ background-image: url(../images/icon_unpublished_hover.png);
+}
+
+#navigation .node.active a.published,
+#navigation .node:hover a.published{
+ background-image: url(../images/icon_published_hover.png);
+}
+
+.tierMethodsDrawer{
+ position: absolute;
+ width: 300px;
+ font-size: 12px;
+ top: 25.45em;
+ z-index: 1000;
+ background: url( ../images/navBgDark.png );
+ color: #fff;
+}
+
+.tierMethodsDrawer .titleBar{
+ padding: .25em 0 .25em 1em;
+}
+
+.tierMethodsDrawer h5.title{
+ font-size: 12px;
+ line-height: 2;
+ cursor: pointer;
+ color: #ccc;
+ width: 265px;
+ float: left;
+ font-family: Georgia;
+ font-style: italic;
+}
+
+.tierMethodsDrawer .icon.close{
+ width: 12px;
+ height: 12px;
+ float: right;
+ display: block;
+ text-indent: -1000px;
+ position: relative;
+ background-image: url(../images/icon_delete_hover.png );
+}
+
+.tierMethodsDrawer ul{
+ overflow: auto;
+ border-top: 1px #303030 solid;
+}
+
+.tierMethodsDrawer li{
+ border-bottom: 1px #303030 solid !important;
+ padding: .25em .5em;
+ cursor: pointer;
+}
+
+.tierMethodsDrawer li:hover{
+ background: #333;
+}
+
+.tierMethodsDrawer .addableObjects h5{
+ font-size: 12px;
+ line-height: 2;
+ color: #6c6c6c;
+ padding-left: 1em;
+}
+
+.tierMethodsDrawer .addableObjects li:hover h5{
+ color: #eee;
+}
BIN  images/bg_util.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/categoryBreadcrumb.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_aux.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_aux_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_category.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_category_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_leaf.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_leaf_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_module.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_module_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_published.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_published_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_spinner.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_unpublished.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_unpublished_hover.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/icon_utility_spinner.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/navBgDark.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/navContainer_bg.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/nav_bg
View
Binary file not shown
BIN  images/nav_bg.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2  js/LatticeModules.js
View
@@ -36,7 +36,7 @@ lattice.modules.Module = new Class({
getUploaderSWFUrl : function(){
- return "lattice/lattice/views/thirdparty/digitarald/fancyupload/Swiff.Uploader3.swf";
+ return "modules/lattice/views/thirdparty/digitarald/fancyupload/Swiff.Uploader3.swf";
},
getClearFieldURL: function(){
535 js/navigation.js
View
@@ -0,0 +1,535 @@
+if( !lattice.modules.navigation ) lattice.modules.navigation = {};
+
+lattice.modules.navigation.Navigation = new Class({
+
+ Extends: lattice.LatticeObject,
+ Implements: [ Events, Options ],
+ rootId: 0,
+ dataSource: null,
+ nodeData: {},
+ breadCrumbs: null,
+ tiers: [],
+ numberOfVisiblePanes: 3,
+ options: {
+ addObjectPosition: 'bottom'
+ },
+
+ getNodeIdFromElement: function( anElement ){
+ var id;
+ if( anElement.get( 'id' ) && anElement.get( 'id' ).split( '_' ) ){
+ id = anElement.get("id").split( "_" )[ anElement.get("id").split( "_" ).length - 1 ];
+ }else{
+ id = null;
+ }
+ return id;
+ },
+ getNodeFromSlug: function(slug){
+ this.nodeData.each( function( aNode ){
+ return ( aNode.slug == slug )? aNode.id : false;
+ });
+ },
+ getNodeTypeFromId: function( nodeId ){ return this.nodeData[ nodeId ].nodeType; },
+ getContentTypeFromId: function( nodeId ){ return this.nodeData[ nodeId ].contentType; },
+ getNodeTitleFromId: function( nodeId ){ if( this.nodeData[ nodeId ] ){ return this.nodeData[ nodeId ].title; }else{ return null; } },
+ getSlugFromId: function( nodeId ){ return this.nodeData[ nodeId ].slug; },
+ getNodeById: function( nodeId ){ return this.nodeData[ nodeId ]; },
+ getUserLevel: function(){ return this.userLevel; },
+ getPanes: function(){ return this.container.getElements('.pane'); },
+ getPaneTemplate: function(){ return this.navPaneTemplate.clone(); },
+ getVisibleTiers: function(){
+ var visibleTiers = [];
+ this.getPanes().each( function( aPane ){
+ visibleTiers.push( aPane.retrieve('tier') );
+ });
+ return visibleTiers;
+ },
+
+ onAppStateChanged: function( appState ){
+// lattice.log( 'lattice.modules.navigation.Navigation.appStateChanged', appState );
+ },
+
+ onObjectNameChanged: function( objId, response ){
+ if( this.nodeData[ objId ] ){
+ this.nodeData[ objId ].title = name;
+ $( 'node_' + objId ).getElement( "h5" ).set( 'text', response.value );
+ }
+ },
+
+ onNodeClicked: function( nodeId, tier ){
+ var paneIndex, node;
+ this.clearPendingTierRequest();
+ node = this.nodeData[ nodeId ];
+ paneIndex = ( this.getVisibleTiers().indexOf( tier ) > 0 )? this.getVisibleTiers().indexOf( tier ) : 0;
+// lattice.log( "onNodeClicked ", nodeId, tier );
+ this.detachTiers( paneIndex + 1 );
+ this.removeCrumbs( paneIndex + 1 );
+ this.breadCrumbs.addCrumb( { label: node.title, tier: tier, nodeData: node } );
+
+ this.marshal.onNodeSelected( nodeId );
+ if( this.getNodeTypeFromId( nodeId ) == 'object' ) this.requestTier( nodeId, tier );
+ },
+
+ onCrumbClicked: function( crumbData ){
+ var paneIndex, node, tier, slug;
+ this.clearPendingTierRequest();
+ tier = crumbData.tier;
+ node = crumbData.nodeData;
+ paneIndex = ( this.getVisibleTiers().indexOf( tier ) > 0 )? this.getVisibleTiers().indexOf( crumbData.tier ) : 0;
+ // lattice.log( "prepareTier ", tier, paneIndex, node );
+ this.detachTiers( paneIndex + 1 );
+ this.removeCrumbs( paneIndex + 1 );
+ if( node ){
+ this.breadCrumbs.addCrumb( { label: node.title, tier: tier, nodeData: node } );
+ // lattice.log( "onCrumbClicked", node, node.id, tier );
+ if( node.objectType == 'object' ) this.requestTier( node.id, tier );
+ if( this.getNodeTypeFromId( node.id ) == 'object' ){
+ this.marshal.onNodeSelected( node.id );
+ }else{
+ this.slideToCurrentTier( null );
+ this.marshal.clearPage();
+ }
+ if( this.getNodeTypeFromId( node.id ) == 'object' ) this.requestTier( node.id, tier );
+ }else{
+ this.slideToCurrentTier( null );
+ this.getVisibleTiers().each( function( pane ){
+ pane.setActiveNode( null );
+ });
+ this.marshal.clearPage();
+ }
+ },
+
+ clearPendingTierRequest: function(){
+ if( this.pendingPane ){
+ this.pendingPane.get('spinner').hide();
+ this.pendingPane.destroy();
+ }
+ this.marshal.clearPendingTierRequest();
+ },
+
+ requestTier: function( nodeId, parentTier, deepLink ){
+ // lattice.log( 'requestTier', nodeId, parentTier, deepLink );
+ cached = ( this.tiers[ nodeId ] && !deepLink )? true : false;
+ if( cached ){
+ console.group();
+ // lattice.log( "cached: ", cached );
+ this.renderPane( this.tiers[ nodeId ] );
+ }else{
+ this.pendingPane = this.addPane();
+ this.dataSource.requestTier( nodeId, deepLink, function( json ){
+ this.requestTierResponse( json, nodeId, this.pendingPane );
+ }.bind( this ) );
+ }
+ },
+
+ initialize: function( element, marshal, options ){
+ this.setOptions( options );
+ this.parent( element, marshal, options );
+ lattice.historyManager.addListener( this );
+
+ this.addEvent( 'appstatechanged', function( appState ){
+ this.onAppStateChanged( appState );
+ }.bind( this ) );
+
+ this.dataSource = ( !this.options.dataSource )? this.marshal : this.options.dataSource;
+ this.dataSource.addListener( this );
+ this.addEvent( 'objectnamechanged', this.onObjectNameChanged.bind( this ) );
+
+ this.navPaneTemplate = this.element.getElement( ".pane" ).dispose();
+ this.container = this.element.getElement( ".panes" );
+
+ this.container.empty();
+ this.instanceName = this.element.get("id");
+ this.breadCrumbs = new lattice.ui.navigation.BreadCrumbTrail( this.element.getElement( ".breadCrumb" ), this.onCrumbClicked.bind( this ) );
+ this.rootId = this.dataSource.getRootNodeId();
+ this.userLevel = ( Cookie.read( 'userLevel' ) )? Cookie.read( 'userLevel' ) : "superuser";
+ // lattice.log( "/////////////////////////////////" );
+ // lattice.log( "rootId:", this.rootId );
+ // lattice.log( "userLevel:", this.userLevel );
+ // lattice.log( "appState:", lattice.historyManager.getAppState() );
+ // lattice.log( "/////////////////////////////////" );
+ var deepLink = ( lattice.historyManager.getAppState().slug )? lattice.historyManager.getAppState().slug : null;
+ this.breadCrumbs.addCrumb( { label: '/' } );
+ this.requestTier( this.rootId, null, deepLink );
+ if( deepLink ) this.marshal.onNodeSelected( deepLink );
+ },
+
+ addPane: function(){
+ var newPane, elementDimensions;
+ newPane = this.getPaneTemplate().clone();
+ elementDimensions = this.container.getDimensions();
+ this.element.getElement( ".panes" ).adopt( newPane );
+ // this.container.setStyle( "width", elementDimensions.width + newPane.getDimensions().width );
+ newPane.get( "spinner" ).show( true );
+ return newPane;
+ },
+
+ saveTierSort: function( order, nodeId ){ this.dataSource.saveTierSortRequest( order, nodeId ); },
+
+ requestTierResponse: function( json, tierId, containerPane ){
+ this.pendingPane = null;
+ nodes = json.response.data.tier.nodes;
+ this.processNodeData( nodes, json.response.data.tier.html, tierId, containerPane );
+ },
+
+ processNodeData: function( nodes, html, tierId, containerPane ){
+ nodes.each( function( node ){
+ this.nodeData[ node.id ] = node;
+ if( node.tier ){
+ this.breadCrumbs.addCrumb( { label: node.title, tier: tier, nodeData: node } );
+ this.processNodeData( node.tier.nodes, node.tier.html, node.id, this.addPane() );
+ }
+ }, this );
+// lattice.log( 'processNodeData creating new tier with id', tierId );
+ var tier = new lattice.modules.navigation.Tier( this, html, tierId );
+ this.tiers[ tierId ] = tier;
+ this.renderPane( tier, containerPane, tierId );
+ },
+
+ renderPane: function( aTier, newPane ){
+ var nodeId, navSlideFx, nodeTitle;
+ if( !newPane ) newPane = this.addPane();
+ newPane.unspin();
+ aTier.attachToPane( newPane );
+ aTier.render();
+ this.slideToCurrentTier( newPane );
+ },
+
+ slideToCurrentTier: function( target ){
+ if( !target || this.getPanes().indexOf( target ) < this.numberOfVisiblePanes ){
+ navSlideFx = new Fx.Scroll( this.element.getElement( ".container" ) ).toLeft();
+ }else{
+ navSlideFx = new Fx.Scroll( this.element.getElement( ".container" ) ).start( target.getCoordinates().left - target.getCoordinates().width - this.element.getElement('.container').getCoordinates().left , 0 );//toRight( target );
+ }
+ },
+
+ detachTiers: function( startIndex, endIndex ){
+ var visibleTiers, tiersToDetach;
+ visibleTiers = this.getVisibleTiers();
+ if( startIndex < 0 ) startIndex = 0;
+ if( !endIndex ) endIndex = visibleTiers.length;
+ var tiersToDetach = visibleTiers.filter( function( aTier, i ){
+ if( i >= startIndex && i < endIndex ) return aTier;
+ });
+ tiersToDetach.each( function( aTier ){ aTier.detach(); });
+ },
+
+ removeCrumbs: function( startIndex, endIndex ){
+ var crumbs, crumbsToRemove;
+ crumbs = this.breadCrumbs.getCrumbs();
+ if( startIndex < 0 ) startIndex = 0;
+ if( !endIndex ) endIndex = crumbs.length;
+ var crumbsToRemove = crumbs.filter( function( aCrumb, i ){
+ if( i >= startIndex && i < endIndex ) return aCrumb;
+ });
+ this.breadCrumbs.removeCrumbs( crumbsToRemove );
+ },
+
+ addObject: function( parentId, templateId, nodeProperties, tierInstance ){
+ this.dataSource.addObjectRequest( parentId, templateId, nodeProperties, function( json ){ this.onAddObjectResponse( json, parentId, tierInstance ); }.bind( this ) );
+ },
+
+ onAddObjectResponse: function( json, parentId, tierInstance ){
+ lattice.log( "onAddObjectResponse", json );
+ this.nodeData[ json.response.data.id ] = json.response.data;
+ var newNode = json.response.html.toElement();
+ tierInstance.adoptNode( newNode );
+ tierInstance.onObjectAdded( newNode );
+
+ },
+
+ removeObject: function( nodeId, tier ){
+ var title, paneIndex;
+ title = this.getNodeTitleFromId(nodeId);
+ this.nodeData[ nodeId ] = null;
+ delete this.nodeData[ nodeId ];
+ this.dataSource.removeObjectRequest( nodeId );
+ console.log( "removeObject", nodeId, this.toString() );
+ if( nodeId == this.dataSource.getObjectId() ){
+ lattice.historyManager.changeState( "slug", null );
+ // this.breadCrumbs.removeCrumbByLabel( title );
+ paneIndex = this.getVisibleTiers().indexOf( tier );
+ this.detachTiers( paneIndex + 1 );
+ this.removeCrumbs( paneIndex + 1 );
+ this.marshal.clearPageContent();
+ }
+ },
+
+ togglePublishedStatus: function( nodeId ){
+ this.nodeData[ nodeId ].published = !this.nodeData[ nodeId ].published;
+ this.dataSource.togglePublishedStatusRequest( nodeId );
+ }
+
+});
+
+lattice.modules.navigation.Tier = new Class({
+
+ Implements: [ Options, Events ],
+ nodes: null,
+ element: null,
+ nodeElement: null,
+ html: null,
+ parentId: null,
+ activeNode: null,
+ drawer: null,
+ sortableList: null,
+
+ options: {
+ addPosition: 'bottom',
+ allowChildSort: true
+ },
+
+ getActiveNode: function(){ return this.activeNode; },
+
+ setActiveNode: function( el ){
+ if( this.activeNode )this.deindicateNode( this.activeNode );
+ if( el ){
+ this.activeNode = el;
+ this.indicateNode( el );
+ }
+ },
+
+ getActiveNodeId: function(){
+ return this.getNodeIdFromElement( this.activeNode );
+ },
+
+ initialize: function( aMarshal, html, nodeId ){
+ this.marshal = aMarshal;
+ this.html = html;
+// lattice.log( 'Tier.initialize.id', nodeId );
+ this.id = nodeId;
+ },
+
+ toString: function(){
+ return "[ Object, lattice.LatticeObject, lattice.modules.navigation.Tier ]"
+ },
+
+ attachToPane: function( pane ){
+ pane.store( "tier", this );
+ this.options = Object.merge( this.options, pane.getOptionsFromClassName() );
+ this.element = pane;
+ this.spinner = new Spinner( this.element );
+ },
+
+ render: function( e ){
+ lattice.util.stopEvent( e );
+ if( this.element.get('html') != this.html ) this.element.set( 'html', this.html );
+ this.nodeElement = this.element.getElement( ".nodes" );
+ if( this.options.allowChildSort ) this.makeSortable();
+ this.nodes = this.element.getElements(".node");
+ this.nodes.each( function( aNodeElement ){
+ this.initNode( aNodeElement );
+ }, this );
+ this.drawer = this.element.getElement( '.tierMethodsDrawer' );
+ if( this.drawer ){
+ this.drawer.set( "morph", {
+ duration: 200,
+ transition: Fx.Transitions.Quad.easeInOut
+ });
+ this.drawer.getElement( '.close' ).addClass( 'hidden' );
+ this.drawer.setStyle( 'height', 'auto' );
+ this.drawer.getElement( 'ul.addableObjects' ).setStyle( 'height', 'auto' );
+ this.drawer.getElement( '.close' ).addEvent( 'click', this.render.bindWithEvent( this ) );
+ if( !this.drawer.retrieve( 'initTop' ) ) this.drawer.store( "initTop", this.drawer.getStyle( "top" ) );
+ this.drawer.setStyle( 'top', this.drawer.retrieve( 'initTop' ) );
+ var addObjectLinks = this.drawer.getElements( "li" );
+ // wire addobject links
+ addObjectLinks.each( function( aLink ){
+ aLink.addEvent( "click", this.onAddObjectClicked.bindWithEvent( this, aLink ) );
+ }, this );
+ if( this.marshal.getUserLevel() == 'superuser' && addObjectLinks.length > 5 ){
+ // this.element.removeClass( "dark" );
+ this.drawer.getElement( ".close" ).addClass("hidden");
+ this.drawer.setStyle( 'top', this.drawer.retrieve( 'initTop' ) );
+ this.drawer.addEvent( 'click', this.renderAddObjectSelection.bindWithEvent( this, addObjectLinks ) );
+ }else{
+ this.drawer.addEvent( 'mouseenter', this.onDrawerMouseEnter.bindWithEvent( this ) );
+ this.drawer.addEvent( 'mouseleave', this.onDrawerMouseLeave.bindWithEvent( this ) );
+ }
+ // make nodes element shorter by the height of the addableObjects title height
+ if( this.nodeElement.getDimensions().height >= this.element.getDimensions().height ){
+ this.nodeElement.setStyle( 'height', this.element.getSize().y - this.drawer.getElement( "div.titleBar" ).getDimensions().height );
+ }
+ }
+ },
+
+ renderAddObjectSelection: function( e, addObjectLinks ){
+ lattice.util.stopEvent( e );
+ this.nodeElement.addClass( 'hidden' );
+ this.drawer.setStyle( 'height', '100%' );
+ this.drawer.getElement( '.close' ).removeClass( 'hidden' );
+ var h = this.element.getSize().y - this.drawer.getElement( "div.titleBar" ).getSize().y;
+ this.drawer.getElement( 'ul.addableObjects' ).setStyle( 'height', h );
+ this.drawer.morph( { 'top': 0 } );
+ },
+
+ detach: function(){
+ this.element.unspin();
+ this.setActiveNode( null );
+ this.html = this.element.get('html') // might as well for parity;
+ this.element = this.element.dispose();
+ },
+
+ adoptNode: function( newNode ){
+ if( this.options.addPosition == "top" ){
+ this.nodeElement.grab( newNode, 'top' );
+ }else{
+ if( this.nodeElement.getElement( ".module" ) ){
+ this.nodeElement.getElement( ".module" ).grab( newNode, 'before' );
+ }else{
+ this.nodeElement.grab( newNode, 'bottom' );
+ }
+ }
+ this.html = this.element.get( "html" );
+ this.initNode( newNode );
+ },
+
+ initNode: function( aNodeElement ){
+ var togglePublishedStatusElement, removeNodeElement;
+ togglePublishedStatusElement = aNodeElement.getElement(".togglePublishedStatus");
+ node = this.marshal.getNodeById( this.marshal.getNodeIdFromElement( aNodeElement ) );
+ removeNodeElement = aNodeElement.getElement(".removeNode");
+ aNodeElement.store( "options", aNodeElement.getOptionsFromClassName() );
+ aNodeElement.addEvent( "click", this.onNodeClicked.bindWithEvent( this, aNodeElement ) );
+ if( togglePublishedStatusElement ) togglePublishedStatusElement.addEvent( "click", this.onTogglePublishedStatusClicked.bindWithEvent( this, aNodeElement ) );
+
+ if( node && node.tier ){ this.setActiveNode( aNodeElement ) }
+
+ if( removeNodeElement ) removeNodeElement.addEvent( "click", this.onRemoveNodeClicked.bindWithEvent( this, aNodeElement ) );
+ },
+
+ indicateNode: function( nodeElement ){
+ nodeElement.addClass( "active");
+ },
+
+ deindicateNode: function( nodeElement ){
+ nodeElement.removeClass("active");
+ },
+
+/* Section: Event Handlers */
+
+ onMouseEnter: function( e, nodeElement ){
+ lattice.util.stopEvent( e );
+ this.indicateNode( aNodeElement );
+ },
+
+ onMouseLeave: function( e, nodeElement ){
+ lattice.util.stopEvent( e );
+ if( this.activeNode != nodeElement ) this.deindicateNode( nodeElement );
+ },
+
+ onNodeClicked: function( e, el ){
+ var nodeId, slug;
+ lattice.util.stopEvent( e );
+ nodeId = this.marshal.getNodeIdFromElement( el );
+ slug = this.marshal.getSlugFromId( nodeId );
+ this.setActiveNode( el );
+ lattice.historyManager.changeState( "slug", slug );
+ this.marshal.onNodeClicked( nodeId, this );
+ },
+
+ onRemoveNodeClicked: function( e, nodeElement ){
+ lattice.util.stopEvent( e );
+ var confirmation = confirm( "Are you sure you want to remove " + nodeElement.getElement("h5").get("text") + " ?" );
+ if( !confirmation ) return;
+ var nodeId = this.marshal.getNodeIdFromElement( nodeElement );
+ nodeElement.destroy();
+ nodeElement = null;
+ this.html = this.element.get("html");
+ console.log("onRemoveNodeClicked", nodeElement );
+ this.removeObject( nodeId );
+ },
+
+ removeObject: function( nodeId ){
+ console.log( "removeObject", nodeId, this.toString() );
+ this.marshal.removeObject( nodeId, this );
+ },
+
+ onTogglePublishedStatusClicked: function( e, nodeElement ){
+ lattice.util.stopEvent( e );
+ var nodeId, togglePublishedStatusLink;
+ nodeId = this.marshal.getNodeIdFromElement( nodeElement );
+ togglePublishedStatusLink = nodeElement.getElement( ".togglePublishedStatus" );
+ if( togglePublishedStatusLink.hasClass( "published" ) ){
+ togglePublishedStatusLink.removeClass( "published" );
+ togglePublishedStatusLink.set( 'title', 'publish' );
+ }else{
+ togglePublishedStatusLink.addClass( "published" );
+ togglePublishedStatusLink.set( 'title', 'unpublish' );
+ }
+ this.marshal.togglePublishedStatus( nodeId );
+ },
+
+ onDrawerMouseEnter: function( e ){
+ var top = this.element.getSize().y - this.drawer.getSize().y;
+ this.drawer.morph( { 'top': top } );
+ },
+
+ onDrawerMouseLeave: function( e ){
+ var top = this.nodeElement.getSize().y - this.drawer.getElement( "h5" ).getSize().y;
+ this.drawer.morph( { 'top': this.drawer.retrieve( "initTop" ) } );
+ },
+
+ onAddObjectClicked: function( e, addObjectButton ){
+ lattice.util.stopEvent( e );
+ var templateId = lattice.util.getValueFromClassName( "objectTypeId", addObjectButton.get("class") );
+ var addText = addObjectButton.get( 'text' );
+ var nodeTitle = prompt( "What would you like to name this" + addText.substr( addText.lastIndexOf( " " ), addText.length ).toLowerCase() );
+ if( !nodeTitle ) return;
+ this.spinner.show( true );
+ this.render();
+ this.marshal.addObject( this.id, templateId, { title: nodeTitle }, this );
+ },
+
+ onObjectAdded: function( aNode ){
+ console.log( "onObjectAdded", aNode );
+ if( this.options.allowChildSort && this.sortableList ){
+// console.log( "onObjectAdded", this.options.allowChildSort, this.sortableList, this.sortableListElement, aNode )
+ this.sortableList.addItems( aNode );
+ }
+ this.spinner.hide();
+ },
+
+ makeSortable: function(){
+ this.sortableListElement = this.nodeElement;
+ if( this.sortableList) this.removeSortable( this.sortableList );
+ this.sortableList = null;
+ this.sortableList = new lattice.ui.Sortable( this.sortableListElement, this, this.sortableListElement );
+ this.oldSort = this.serialize();
+ },
+
+ removeSortable: function( aSortable ){
+ aSortable.detach();
+ delete aSortable;
+ aSortable = null;
+ },
+
+ onOrderChanged: function(){
+ var newOrder = this.serialize();
+ clearInterval( this.submitDelay );
+ this.submitDelay = this.submitSortOrder.periodical( 1000, this, newOrder );
+ newOrder = null;
+ },
+
+ submitSortOrder: function( newOrder ){
+ if( this.options.allowChildSort && this.oldSort != newOrder ){
+ clearInterval( this.submitDelay );
+ this.submitDelay = null;
+ this.marshal.saveTierSort( newOrder, this.id );
+ this.oldSort = newOrder;
+ }
+ },
+
+ serialize:function(){
+ var sortArray, children, nodeId;
+ sortArray = [];
+ children = this.sortableListElement.getChildren("li");
+ children.each( function ( anItem ){
+ nodeId = this.marshal.getNodeIdFromElement( anItem );
+ if( nodeId && nodeId.isNumeric() ){
+ sortArray.push( nodeId );
+ }
+ }, this );
+ return sortArray.join( ',' );
+ }
+
+});
14 js/navigationDataSourceInterface.js
View
@@ -0,0 +1,14 @@
+if( !lattice.modules.navigation ) lattice.modules.navigation = {};
+/*
+ Interface NavDataSource
+ See MopCore Class.Mutators.Interface...
+ Interface for objects holding a nav, throws errors if interface not implemented.
+*/
+lattice.modules.navigation.NavigationDataSource = new Interface( "NavigationDataSource", {
+ requestTier: function( parentId, callback ){},
+ onNodeSelected: function( nodeId, callback ){},
+ saveTierSortRequest: function( parentId, serializedIds, callback ){},
+ removeObjectRequest: function( nodeId, callback ){},
+ togglePublishedStatusRequest: function( nodeId, callback ){},
+ getRootNodeId: function(){},
+});
52 js/usermanagement.js
View
@@ -0,0 +1,52 @@
+lattice.modules.UserManagement = new Class({
+
+ Extends: lattice.modules.LatticeList,
+
+ controller: null,
+
+ /* Section: Constructor */
+
+ initialize: function( anElement, aMarshal, options ){
+ this.parent( anElement, aMarshal, options );
+ var elementClass = anElement.get( 'class' );
+ this.controller = lattice.util.getValueFromClassName( "controller", elementClass );
+ },
+
+ /* Section: Getters & Setters */
+
+ getSaveFieldURL: function( itemObjectId ){
+ var url = lattice.util.getBaseURL() +"ajax/data/"+this.controller+"/savefield/" + itemObjectId;
+ return url;
+ },
+
+ getAddObjectURL: function(){
+ return lattice.util.getBaseURL() + "ajax/html/"+this.controller+"/addObject/";
+ },
+
+ getRemoveObjectURL: function( itemId ){
+ return lattice.util.getBaseURL() + "ajax/data/"+this.controller+"/removeObject/" + itemId;
+ },
+
+ getSubmitSortOrderURL: function(){
+ return lattice.util.getBaseURL() + "ajax/data/"+this.controller+"/saveSortOrder/";
+ },
+
+ /* Section: Methods */
+
+ toString: function(){
+ return "[ Object, lattice.LatticeObject, lattice.modules.List, lattice.modules.LatticeList, lattice.modules.Usermanagement ]";
+ }
+
+});
+
+if( !lattice.util.hasDOMReadyFired() ){
+ window.addEvent( 'domready', function(){
+ lattice.util.DOMReadyHasFired();
+ //self instantiates only first instance
+ lattice.UserManagement = new lattice.modules.UserManagement( $$( ".classPath-lattice_modules_UserManagement" )[0] );
+ lattice.modalManager = new lattice.ui.ModalManager();
+ var doAuthTimeout = lattice.util.getValueFromClassName( 'loginTimeout', $(document).getElement("body").get("class") );
+ if( doAuthTimeout && doAuthTimeout != "0" ) lattice.loginMonitor = new lattice.util.LoginMonitor();
+ })
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.