forked from crismaproject/worldstate-analysis-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2 recieve and process seamless.js events
- Loading branch information
1 parent
8732dee
commit 1d1042f
Showing
9 changed files
with
407 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
if (typeof $ === 'undefined') { | ||
var $ = jQuery; | ||
} | ||
if (typeof $ === 'undefined') { | ||
var $ = window.jQuery; | ||
} | ||
|
||
window.Drupal.behaviors.myBehavior = { | ||
attach: function (context, settings) { | ||
// Using once() to apply the mcdaIFrameBehavior effect when you want to run just one function. | ||
$(window, context).once('mcdaIFrameBehavior').each(function () { | ||
console.log('onAttach'); | ||
var connectCount = 0; | ||
// for some unknown the reason angular directive controler of the embedded child iframe | ||
// does not recieve the event when it's not fired from the onConnect method. | ||
var mcdaApp = window.seamless(document.getElementById('mcda'), | ||
{onConnect: function () { | ||
// FIXME: for some unknown reasin, onConnect is called if no child fram has activiliy connected | ||
// by invokinf seamless.connect() resulting in the onConnect function called twice! | ||
if(connectCount === 1) { | ||
var currentNodeId = window.location.pathname.split('/').pop(); | ||
mcdaApp.send({ | ||
nodeId: currentNodeId | ||
}); | ||
} else { | ||
console.log('pre/re connection #:' + connectCount); | ||
} | ||
connectCount++; | ||
}}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/scripts/directives/drupalBasedAnalysisContextProvider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
angular.module( | ||
'eu.myclimateservice.csis.scenario-analysis.directives' | ||
).directive( | ||
'drupalContextProvider', | ||
[ | ||
function () { | ||
'use strict'; | ||
|
||
var scope; | ||
|
||
scope = { | ||
'worldstates': '=', | ||
'selectedWorldstates': '=', | ||
'decisionStrategies': '=', | ||
'criteriaFunctions': '=' | ||
}; | ||
|
||
return { | ||
scope: scope, | ||
restrict: 'E', | ||
templateUrl: 'templates/drupalContextProviderTemplate.html', | ||
controller: 'eu.myclimateservice.csis.scenario-analysis.controllers.drupalContextProviderDirectiveController' | ||
}; | ||
} | ||
] | ||
); |
Oops, something went wrong.