2
0
Fork 0
es5-ff-spa-loader/example/app_server/www_static/js/example-app.js

57 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2015-12-23 00:16:54 +00:00
'use strict';
document.title = 'FFSpaLoader Example';
2016-01-14 21:42:13 +00:00
var serverUrl = window.FFServerUrl;
console.log('FFExample provided serverUrl \"'+serverUrl+'\"');
2015-12-23 00:16:54 +00:00
// TODO for 0.4.0
2016-03-14 00:50:47 +00:00
//var tplCache = FFSpaLoader.factory.cache.websql({table: 'angular_tpl'});
//tplCache.cacheOpen(function(err) {
// tplCache.cacheSetValue('key123','value456',function(err) {
// console.log('FFExample local value cached');
// });
//});
var moduleTpl = angular.module('app-tpl', []);
moduleTpl.run(["$templateCache", function($templateCache) {
var tpl = '';
tpl += '<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">\n';
tpl += ' <div class="navbar-header">\n';
tpl += ' <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">\n';
tpl += ' <span class="sr-only">Toggle navigation</span>\n';
tpl += ' <span class="icon-bar"></span>\n';
tpl += ' <span class="icon-bar"></span>\n';
tpl += ' <span class="icon-bar"></span>\n';
tpl += ' </button>\n';
tpl += ' <a class="navbar-brand" ng-click="goLink(\'/example-ui/\')">Home</a>\n';
tpl += ' <a class="navbar-brand" ng-click="goLink(\'/example-ui/foo\')">Foo</a>\n';
tpl += ' <a class="navbar-brand" ng-click="goLink(\'/example-ui/bar\')">Bar</a>\n';
tpl += ' </div>\n';
tpl += '</nav>\n';
$templateCache.put('/example-ui/thtml/header', tpl);
$templateCache.put('/example-ui/thtml/footer', '<nav class="navbar">\n<div class="navbar-footer">\nExample footer\n</div>\n</nav>\n');
}]);
2015-12-23 00:16:54 +00:00
$(document.createElement('div')).attr('id', 'wrapper').appendTo($('body'));
$(document.createElement('div')).attr('ng-controller', 'ApplicationController').attr('ng-include', '\'/example-ui/thtml/header\'').appendTo($('#wrapper'));
2015-12-23 00:16:54 +00:00
$(document.createElement('div')).attr('id', 'page-wrapper').appendTo($('#wrapper'));
$(document.createElement('div')).attr('id', 'container-fluid').attr('ng-view', '').appendTo($('#page-wrapper'));
$(document.createElement('div')).attr('ng-include', '\'/example-ui/thtml/footer\'').appendTo($('body'));
2015-12-23 00:16:54 +00:00
var pageRouteInit = [];
var exampleUI = angular.module('exampleUI', ['app-tpl','ngRoute']).config(
2016-01-14 23:36:10 +00:00
['$routeProvider','$locationProvider','$sceDelegateProvider', function
($routeProvider , $locationProvider , $sceDelegateProvider) {
pageRouteInit.forEach(function(init) { init($routeProvider, $locationProvider); });
$sceDelegateProvider.resourceUrlWhitelist(['self',serverUrl+'/**']);
$routeProvider.otherwise({ redirectTo: '/example-ui' });
$locationProvider.html5Mode({requireBase: false});
2016-01-14 21:42:13 +00:00
}]);
2015-12-23 00:16:54 +00:00
2016-01-14 23:36:10 +00:00
exampleUI.controller('ApplicationController',function($scope,$http,$location) {
$scope.goLink = function ( path ) {
$location.path( path );
2016-01-14 23:36:10 +00:00
};
});