-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No inline script No JavaScript on server side
- Loading branch information
Showing
10 changed files
with
67 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 2.4 | ||
|
||
For the GeoMapFish applications we must not anymore to add the dynamic.js in the application HTML file | ||
and the ng-app, but we needs to add the following metadata: | ||
``` | ||
<meta name="dynamicUrl" content="<application_url>/dynamic.json"> | ||
<meta name="interface" content="<interface_name>"> | ||
``` | ||
If you use the one of the abstract controllers the bootstrap will be done by `gmf/controllers/bootstrap.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
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
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
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
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 @@ | ||
/* global DocumentTouch */ | ||
|
||
import $ from 'jquery'; | ||
|
||
function bootstrap(module) { | ||
const interface_ = $('meta[name=interface]')[0].attributes.content.value; | ||
const dynamicUrl_ = $('meta[name=dynamicUrl]')[0].attributes.content.value; | ||
const dynamicUrl = `?${dynamicUrl_}interface=${interface_}&query=${encodeURIComponent(document.location.search)}`; | ||
const request = $.ajax(dynamicUrl, { | ||
'dataType': 'json', | ||
'xhrFields': { | ||
withCredentials: false | ||
} | ||
}); | ||
request.fail((jqXHR, textStatus) => { | ||
window.alert(`Failed to get the dynamic: ${textStatus}`); | ||
}); | ||
request.done((dynamic) => { | ||
if (dynamic['doRedirect']) { | ||
const small_screen = window.matchMedia ? window.matchMedia('(max-width: 1024px)') : false; | ||
if (small_screen && (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch)) { | ||
window.location = dynamic['redirectUrl']; | ||
} | ||
} | ||
|
||
for (const name in dynamic['constants']) { | ||
module.constant(name, dynamic['constants'][name]); | ||
} | ||
|
||
angular.bootstrap(document, [`App${interface_}`]); | ||
}); | ||
} | ||
|
||
export default bootstrap; |