This repository has been archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(source-snippets): add source-snippets service to toggle visibili…
…ty of javascript and typescript examples
- Loading branch information
Philipp Burgmer
committed
Jul 28, 2015
1 parent
c8b098d
commit 65e46dc
Showing
3 changed files
with
80 additions
and
8 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,55 @@ | ||
'use strict'; | ||
|
||
angular.module('w11k.slides').config(function (slidesConfig) { | ||
slidesConfig.shortcuts = slidesConfig.shortcuts || {}; | ||
|
||
slidesConfig.shortcuts['76'] = ['SourceSnippets', function (SourceSnippets) { | ||
SourceSnippets.toggle(); | ||
}]; | ||
}); | ||
|
||
angular.module('w11k.slides').run(function (SourceSnippets) { | ||
// just for eager creation | ||
SourceSnippets.init(); | ||
}); | ||
|
||
angular.module('w11k.slides').service('SourceSnippets', function ($rootScope) { | ||
var states = { | ||
'jsOnly': { | ||
js: true, | ||
ts: false, | ||
next: 'tsOnly' | ||
}, | ||
'tsOnly': { | ||
js: false, | ||
ts: true, | ||
next: 'jsAndTs' | ||
}, | ||
'jsAndTs': { | ||
js: true, | ||
ts: true, | ||
next: 'jsOnly' | ||
} | ||
}; | ||
|
||
var currentState = states.jsOnly; | ||
|
||
$rootScope.$on('src-js-current', function (event, callback) { | ||
callback(currentState.js); | ||
}); | ||
|
||
$rootScope.$on('src-ts-current', function (event, callback) { | ||
callback(currentState.ts); | ||
}); | ||
|
||
this.toggle = function () { | ||
currentState = states[currentState.next]; | ||
|
||
$rootScope.$broadcast('src-js', currentState.js); | ||
$rootScope.$broadcast('src-ts', currentState.ts); | ||
}; | ||
|
||
this.init = function () { | ||
// nothing to do here at the moment | ||
}; | ||
}); |
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