Skip to content

Commit

Permalink
Merge pull request #180 from MadainCorp/bash
Browse files Browse the repository at this point in the history
breadcrumbs support in developer plugin tester
  • Loading branch information
DanielHindi committed Jan 20, 2016
2 parents ecc4cdd + 1bc4479 commit 81cb640
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
29 changes: 29 additions & 0 deletions pluginTester/pages/controllers/shellCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ $app.controller('shellCtrl', ['$scope', '$routeParams','$sce', '$http', function
};
$scope.currentUser = window.currentUser;

if(postMaster.widgetPluginAPI.history.historyItems.length == 0) {
postMaster.widgetPluginAPI.history.historyItems.push({ label: 'Plugin', source: 'control' });
if(!$scope.$$phase) $scope.$apply();
}
postMaster.widgetPluginAPI.history.onUpdate(function(data){
if(data.historyItems) {
for(var i = 0; i < data.historyItems.length; i++) {
data.historyItems[i].title = decodeURIComponent(data.historyItems[i].title);
}
$scope.breadcrumbs = data.historyItems.slice(0);
}
else {
$scope.breadcrumbs = [];
}
if(!$scope.$$phase) $scope.$apply();
});
postMaster.widgetPluginAPI.history.onPop(function(data) {
if(data.popTriggered) {
return;
}
var packet = new Packet(null, "history.triggerOnPop", JSON.parse(angular.toJson(data.poppedItem)));
postMaster.controlPluginAPI.sendMessage(null, packet);
data.popTriggered = true;
});
$scope.popHistoryItem = function (event, breadcrumb) {
postMaster.widgetPluginAPI.history.pop(breadcrumb);
};


$scope.loadFrames = function (pluginFolder, config) {
var root = '../plugins/';
$scope.widgetSrc = root + pluginFolder + '/widget/index.html';
Expand Down
8 changes: 8 additions & 0 deletions pluginTester/pages/templates/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ <h4 class="margin-zero">Plugin</h4>
<a href="#/logout" ng-show="currentUser" class="pull-right">Logout</a>
</div>
<div class="layout padded clearfix">
<div class="item clearfix row">
<ol class="breadcrumb labels col-md-12 padding-right-zero pull-left">
<li ng-repeat="breadcrumb in breadcrumbs" ng-class="{'active':$last}">
<a ng-if="!$last" href="" ng-click="popHistoryItem($event, breadcrumb)">{{breadcrumb.label}}</a>
<span class="ellipsis" ng-if="$last" ng-bind="breadcrumb.label"></span>
</li>
</ol>
</div>
<ul class="nav nav-tabs nav-justified">
<li ng-if="contentSrc">
<a id="btnLoadContent" class="active" ng-click="loadIFrame('content',$event)">Content</a>
Expand Down
1 change: 1 addition & 0 deletions pluginTester/scripts/loadScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function _ScriptLoader(){
, this.domain + "app/scripts/framework/pluginAPI/pluginInstanceAPI.js"
, this.domain + "scripts/framework/pluginAPI/pluginInstanceLibAPI.js"
, this.domain + "app/scripts/framework/pluginAPI/deviceAPI.js"
, this.domain + "app/scripts/framework/pluginAPI/historyAPI.js"
, this.domain + "app/scripts/framework/pluginAPI/pluginAPI.js"
, this.domain + "app/scripts/framework/pluginAPI/geoAPI.js"
, this.domain + "app/pages/controllers/authCtrl.js"
Expand Down
3 changes: 0 additions & 3 deletions pluginTester/scripts/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ postMaster.controlPluginAPI.tag = 'controlPluginAPI';
console.log('analytics mock track view [' + viewName + ']', metadata);
};

postMaster.widgetPluginAPI.navigation.navigateBack = function(){
alert('default back behaviour');
};

///override the authAPI.getCurrentUser to return CP loggedIn user
var oldFN = authAPI.getCurrentUser;
Expand Down

0 comments on commit 81cb640

Please sign in to comment.