Skip to content

Commit

Permalink
added onBrandClicked, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pruhsert committed Mar 21, 2017
1 parent 4075d77 commit 755e6d9
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 38 deletions.
1 change: 0 additions & 1 deletion bootstrapExtraComponentsDemo/.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<comment></comment>
<projects>
<project>resources</project>
<project>morebootstrapcomponents</project>
<project>bootstrapextracomponents</project>
</projects>
<buildSpec>
Expand Down
2 changes: 2 additions & 0 deletions bootstrapExtraComponentsDemo/forms/demoNavBar.frm
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ svyUUID:"6DC240CD-042A-4E0E-93B2-C0EF5A0ED74D",
text:"John Doe"
}
],
onBrandClicked:"FC8A259F-8EE2-4292-8F30-21E46DE57F40",
onBrandLogoClicked:"FC8A259F-8EE2-4292-8F30-21E46DE57F40",
onMenuItemClicked:"1C2DE078-10A9-418B-BD65-D909FBEB82F1",
size:{
height:55,
Expand Down
23 changes: 22 additions & 1 deletion bootstrapExtraComponentsDemo/forms/demoNavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ var searchField = 4;
*/
var invertedNavbar = 0;

/**
* @type {String}
*
* @properties={typeid:35,uuid:"C629C89F-A649-4427-8471-4465C34947D9"}
*/
var searchFieldText = "";

/**
* Called whenever a menu item is clicked or a submenu item is selected with the JSEvent and the menuItem object clicked on.
*
Expand Down Expand Up @@ -52,6 +59,7 @@ function onDataChange_inverted(oldValue, newValue, event) {
* @private
*
* @properties={typeid:24,uuid:"6C2A9AC6-8498-46A2-AA71-BE3EDDB0DD34"}
* @AllowToRunInFind
*/
function onAction_createMenu(event) {
var menuItems = [];
Expand All @@ -60,7 +68,7 @@ function onAction_createMenu(event) {
menuItems.push({itemId: '2', text: 'Invoices', tooltip: 'Invoices'});
menuItems.push({itemId: '3', text: 'Click me', displayType: 'BUTTON', tooltip: 'Button'});
menuItems.push({text: 'Payables', tooltip: 'Payables'});
menuItems.push({itemId: '5', text: 'Search account...', displayType: 'INPUT', iconName: 'glyphicon glyphicon-search', tooltip: 'Search'});
menuItems.push({itemId: '5', text: 'Search account...', displayType: 'INPUT', dataProvider: 'forms.demoNavBar.searchFieldText', iconName: 'glyphicon glyphicon-search', tooltip: 'Search'});
menuItems.push({itemId: '6', text: 'Menu', position: 'RIGHT', tooltip: 'A submenu', subMenuItems: [{itemId: '6.1', text: 'Action'}, {itemId: '6.2', text: 'More action'}, {isDivider: true}, {itemId: '6.3', text: 'Last action'}]});
menuItems.push({itemId: '7', text: 'Logged in as John Doe', tooltip: 'just text', displayType: 'TEXT', position: 'RIGHT'});

Expand Down Expand Up @@ -143,3 +151,16 @@ function onAction_createIconMenu(event) {
}
elements.navbar.setMenuItems(menuItems);
}

/**
* Called when the user clicks on the brand logo or text.
*
* @param {JSEvent} event
*
* @private
*
* @properties={typeid:24,uuid:"FC8A259F-8EE2-4292-8F30-21E46DE57F40"}
*/
function onBrandClicked(event) {
elements.lblLastClick.text = 'Brand Logo/Text clicked';
}
2 changes: 1 addition & 1 deletion bootstrapextracomponents/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-SymbolicName: bootstrapextracomponents
Bundle-Name: Bootstrap Extra Components
Bundle-Version: 1.1.0
Bundle-Version: 1.1.1
Package-Type: Web-Component

Name: badge/badge.spec
Expand Down
10 changes: 9 additions & 1 deletion bootstrapextracomponents/navbar/navbar.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
.navbar-brand>img {
.navbar-brand > img {
height: 100%;
padding: 10px 15px 10px 15px;
width: auto;
}

.navbar-brand {
cursor: default;
}

.navbar-brand.clickable {
cursor: auto;
}

nav .navbar-right .dropdown-menu {
right: auto;
}
8 changes: 4 additions & 4 deletions bootstrapextracomponents/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a ng-if="model.brandLogo != null" class="navbar-brand" href="#" style="padding: 0px;">
<a ng-if="model.brandLogo != null" svy-click="handlers.onBrandClicked($event)" class="navbar-brand {{handlers.onBrandClicked ? 'clickable' : ''}}" href="#" style="padding: 0px;">
<img class="{{model.brandLogoStyleClass}}" alt="Logo" ng-src="{{model.brandLogo}}">
</a>
<a ng-if="model.brandText" class="navbar-brand" href="#">{{model.brandText}}</a>
<a ng-if="model.brandText" svy-click="handlers.onBrandClicked($event)" class="navbar-brand {{handlers.onBrandClicked ? 'clickable' : ''}}" href="#">{{model.brandText}}</a>
</div><!-- /.navbar-header -->

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse" ng-click="navBarClicked($event, 1)" svy-rightclick="navBarRightClicked($event)">
<ul class="nav navbar-nav">
<li ng-repeat="menuItem in getLeftItems()" class="{{menuItem.menuItems ? 'dropdown' : ''}} {{menuItem.isActive ? 'active' : ''}} {{menuItem.enabled == false ? 'disabled' : ''}}">
<li ng-repeat="menuItem in model.menuItems" ng-if="menuItem.position == 'LEFT'" class="{{menuItem.menuItems ? 'dropdown' : ''}} {{menuItem.isActive ? 'active' : ''}} {{menuItem.enabled == false ? 'disabled' : ''}}">

<div ng-if="menuItem.displayType == 'BUTTON'" class="svy-navbar-button">
<a href="#" data-menu-item-id="{{menuItem.itemId}}" class="btn navbar-btn {{menuItem.styleClass ? menuItem.styleClass : 'btn-default'}}" svy-tooltip="menuItem.tooltip">
Expand Down Expand Up @@ -132,7 +132,7 @@
</li>
</ul><!-- /.navbar-nav -->
<ul class="nav navbar-nav navbar-right">
<li ng-repeat="menuItem in getRightItems()" class="svy-navbar-button {{menuItem.menuItems ? 'dropdown' : ''}} {{menuItem.isActive ? 'active' : ''}} {{menuItem.enabled == false ? 'disabled' : ''}}">
<li ng-repeat="menuItem in model.menuItems" ng-if="menuItem.position == 'RIGHT'" class="svy-navbar-button {{menuItem.menuItems ? 'dropdown' : ''}} {{menuItem.isActive ? 'active' : ''}} {{menuItem.enabled == false ? 'disabled' : ''}}">

<div ng-if="menuItem.displayType == 'BUTTON'" class="svy-navbar-button">
<a href="#" data-menu-item-id="{{menuItem.itemId}}" class="btn navbar-btn {{menuItem.styleClass ? menuItem.styleClass : 'btn-default'}}" svy-tooltip="menuItem.tooltip">
Expand Down
29 changes: 1 addition & 28 deletions bootstrapextracomponents/navbar/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,7 @@ angular.module('bootstrapextracomponentsNavbar', ['servoy']).directive('bootstra
},
link: function($scope, $element, $attrs) {

//add dummy content in designer
if ($scope.svyServoyapi.isInDesigner() && !$scope.model.menuItems) {
$http({ method: "GET", url: "/bootstrapextracomponents/navbar/navbar_demo.html" }).success(function(data) {
// $element.html(data);
}
);
}

var resolvingDisplayValue = false;

$scope.getLeftItems = function() {
return filterItems('LEFT');
}

$scope.getRightItems = function() {
return filterItems('RIGHT');
}

function filterItems(position) {
if (!$scope.model.menuItems) {
return [];
}
function filter(item) {
return item.position == position || (!item.position && position == 'LEFT');
}
return $scope.model.menuItems.filter(filter);
}

$scope.formatLabel = function(index) {
var menuItem = $scope.model.menuItems[index];
Expand Down Expand Up @@ -109,7 +83,6 @@ angular.module('bootstrapextracomponentsNavbar', ['servoy']).directive('bootstra
}

$scope.onInputChange = function(event, index) {
var itemChanged = getItem(event);
$scope.svyServoyapi.apply('menuItems[' + index + '].dataProvider');
}

Expand Down Expand Up @@ -197,7 +170,7 @@ angular.module('bootstrapextracomponentsNavbar', ['servoy']).directive('bootstra
var itemId = event.target.getAttribute('data-menu-item-id');
var itemClicked;
if (!itemId) {
console.log('navBar item "' + event.target.text + '" has no itemId');
return null;
} else {
for (var i = 0; i < $scope.model.menuItems.length; i++) {
var menuItem = $scope.model.menuItems[i];
Expand Down
7 changes: 7 additions & 0 deletions bootstrapextracomponents/navbar/navbar.spec
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
"name": "menuItem",
"type": "menuItem"
}]
},
"onBrandClicked": {
"description": "Called when the user clicks on the brand logo or text",
"parameters": [{
"name": "event",
"type": "JSEvent"
}]
}
},
"types":
Expand Down
2 changes: 1 addition & 1 deletion bootstrapextracomponents/navbar/navbar_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $scope.api.addMenuItem = function(menuItem) {
if ($scope.model.menuItems) {
$scope.model.menuItems.push(menuItem);
} else {
$scope.model.menuItems = [menuItem];
$scope.model.menuItems = [menuItem];
}
}

Expand Down
3 changes: 2 additions & 1 deletion webpackage.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"sourceUrl" : "https://github.com/Servoy/bootstrapextracomponents",
"releases" : [
{"version":"1.0.0","url":"https://github.com/Servoy/bootstrapextracomponents/releases/download/v1.0.0/bootstrapextracomponents.zip", "servoy-version":"8.1.1"},
{"version":"1.1.0","url":"https://github.com/Servoy/bootstrapextracomponents/releases/download/v1.1.0/bootstrapextracomponents.zip", "servoy-version":"8.1.1"}
{"version":"1.1.0","url":"https://github.com/Servoy/bootstrapextracomponents/releases/download/v1.1.0/bootstrapextracomponents.zip", "servoy-version":"8.1.1"},
{"version":"1.1.1","url":"https://github.com/Servoy/bootstrapextracomponents/releases/download/v1.1.1/bootstrapextracomponents.zip", "servoy-version":"8.1.1"}
]
}

0 comments on commit 755e6d9

Please sign in to comment.