Permalink
Browse files

Add the chrome control

  • Loading branch information...
RainerAtSpirit committed Sep 7, 2012
1 parent 1755f52 commit df8de9a1644fc75fbfa9289d1a9440b04bcbcf9a
Showing with 71 additions and 5 deletions.
  1. +1 −0 ToDoMVCWeb/ToDoMVCWeb.csproj
  2. +4 −1 ToDoMVCWeb/index.html
  3. +2 −0 ToDoMVCWeb/js/libs/jquery-1.8.1.min.js
  4. +64 −4 ToDoMVCWeb/js/main.js
@@ -54,6 +54,7 @@
<Content Include="js\config\global.js" />
<Content Include="js\extends\handlers.js" />
<Content Include="js\extends\native.js" />
<Content Include="js\libs\jquery-1.8.1.min.js" />
<Content Include="js\libs\knockout-2.1.0.debug.js" />
<Content Include="js\libs\knockout-2.1.0.js" />
<Content Include="js\main.js" />
View
@@ -11,7 +11,10 @@
<![endif]-->
<script data-main="js/main" src="../../../assets/require.min.js"></script>
</head>
<body>
<body style="display: none">
<!-- Chrome control placeholder -->
<div id="chrome_ctrl_placeholder"></div>
<section id="todoapp">
<header id="header">
<h1>todos</h1>

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -3,22 +3,82 @@
// Require.js allows us to configure shortcut alias
require.config({
paths: {
knockout: 'libs/knockout-2.1.0'
// Try loading from CDN first
jquery: [
'//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min',
'libs/jquery-1.8.1.min'],
knockout: [
'//ajax.aspnetcdn.com/ajax/knockout/knockout-2.1.0',
'libs/knockout-2.1.0']
}
});
require([
'jquery',
'knockout',
'config/global',
'viewmodels/todo',
'extends/handlers',
'extends/native'
], function(ko, g, TodoViewModel){
], function($, ko, g, TodoViewModel){
'use strict';
// var app_view = new AppView();
// check local storage for todos
var todos = ko.utils.parseJson( localStorage.getItem( g.localStorageItem ) );
var todos = ko.utils.parseJson(localStorage.getItem(g.localStorageItem));
var params = getParams(),
hostweburl = params.SPHostUrl,
appweburl = params.SPAppWebUrl;
// Load the js file and continue to the success handler
$.getScript(hostweburl + "/_layouts/15/SP.UI.Controls.js", renderChrome)
//Function to prepare the options and render the control
function renderChrome() {
// The Help, Account and Contact pages receive the
// same query string parameters as the main page
var options = {
"appIconUrl": "images/AppIcon.png",
"appTitle": "Chromecontrol-Crossdomain",
"appHelpPageUrl": "Help.html?"
+ document.URL.split("?")[1],
"settingsLinks": [
{
"linkUrl": "Account.html?"
+ document.URL.split("?")[1],
"displayName": "Account settings"
},
{
"linkUrl": "Contact.html?"
+ document.URL.split("?")[1],
"displayName": "Contact us"
}
]
};
var nav = new SP.UI.Controls.Navigation(
"chrome_ctrl_placeholder",
options
);
nav.setVisible(true);
$('#chromeControl_stylesheet').on('load', function (event) {
$('body').show();
})
}
// Returning the params object
function getParams() {
var params = {};
location.search.split('?')[1].split('&').forEach(function (param) {
var key = param.split('=')[0],
val = decodeURIComponent(param.split('=')[1]);
params[key] = val;
});
return params;
}
// bind a new instance of our view model to the page
ko.applyBindings( new TodoViewModel( todos || [] ) );

0 comments on commit df8de9a

Please sign in to comment.