Skip to content

Commit cc91245

Browse files
Completed the customization part
1 parent 05c7d20 commit cc91245

File tree

2 files changed

+88
-7
lines changed

2 files changed

+88
-7
lines changed

index.html

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,15 @@ <h1 id="configurations">Configurations</h1>
398398
<h1 id="templates">Customizations</h1>
399399

400400
<p>
401-
The oauth directive comes to life with customisazion in mind. You can easily define
401+
The oauth directive comes to life with customization in mind. You can easily define
402402
personalized CSS styles or create brand new templates.
403403
</p>
404404

405-
<h2>Custom CSS</h2>
405+
<h1>Custom CSS</h1>
406406

407407
<p>
408-
By default the directive is a simple link. To improve its visual style add some CSS.
408+
By default the directive is shown as a simple link. To improve its visual style
409+
add some CSS rules.
409410
</p>
410411

411412
<table class="table button">
@@ -519,13 +520,93 @@ <h2>Custom CSS</h2>
519520
</p>
520521

521522

522-
<h2>Custom Template</h2>
523+
<h1>Custom Template</h1>
523524

524525
<p>
525-
If the custom template does not fit for you, you can create a personalized one. Below you
526-
can see the default one.
526+
If the custom template does not fit for you, you can create a personalized one.
527+
Below you can see the default template used from the directive.
527528
</p>
528529

530+
<pre><code><xmp><span class="oauth">
531+
<a href="#" class="logged-out" ng-show="show=='logged-out'" ng-click="login()">Sign In</a>
532+
<a href="#" class="logged-in" ng-show="show=='logged-in'" ng-click="logout()">Logout {{profile.full_name}}</a>
533+
<a href="#" class="denied" ng-show="show=='denied'" ng-click="login()">Access denied. Try again.</a>
534+
</span></xmp></code></pre>
535+
536+
<p>
537+
To create a new one create your personalized HTML and make it interact with the oauth
538+
internal API.
539+
</p>
540+
541+
<table class="table smaller-titles">
542+
<tbody>
543+
<tr>
544+
<td class="parameter">
545+
<span>show</span>
546+
<span class="info">variable</span>
547+
</td>
548+
<td>
549+
Defines the oauth status. <br>
550+
Valid values are <code>logged-out</code>, <code>logged-in</code> and <code>denied</code>.
551+
</td>
552+
</tr>
553+
<tr>
554+
<td class="parameter">
555+
<span>login()</span>
556+
<span class="info">method</span>
557+
</td>
558+
<td>
559+
Logs in redirecting the app to the OAuth 2.0 authorization server.
560+
</td>
561+
</tr>
562+
<tr>
563+
<td class="parameter">
564+
<span>logout()</span>
565+
<span class="info">method</span>
566+
</td>
567+
<td>
568+
Logs out deleting the access token.
569+
</td>
570+
</tr>
571+
</tbody>
572+
</table>
573+
574+
<p>
575+
Suppose you defined a new template in <code>views/templates/custom.html</code>.
576+
Now you need to let the directive know about the new template. You can do it in two ways.
577+
</p>
578+
579+
<ul>
580+
<li>Setting the template attribute</li>
581+
<li>Firing the template event</li>
582+
</ul>
583+
584+
<h2>Template attribute</h2>
585+
586+
<p>
587+
Set the template path (or uri) as value for the template attribute.
588+
</p>
589+
590+
<pre><code><xmp><oauth2
591+
template="views/templates/custom.html"
592+
client-id="<client-id>"
593+
redirect-uri="<redirect-uri>"
594+
scope="<your-scope>"
595+
profile="<profile-uri>">
596+
</oauth2></xmp></code></pre>
597+
598+
<h2>Template event</h2>
599+
600+
<p>
601+
Fires the update template event passing the template path (or uri) as param.
602+
</p>
603+
604+
<pre><code><xmp>$rootScope.$broadcast('oauth:template:update', 'views/templates/custom.html');</xmp></code></pre>
605+
606+
<p>
607+
The main advantage of using the update template event is that it can change the
608+
HTML view of your directive at any moment of its life.
609+
</p>
529610

530611
</div>
531612
</section>

public/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ section:not(#top) {
3636
}
3737

3838
pre {
39+
margin: 2em 0;
3940
background: white;
4041
border-top: 1px solid #eee;
4142
border-bottom: 1px solid #eee;
@@ -281,4 +282,3 @@ table.button .title {
281282
table.button .parameter {
282283
width: 100px;
283284
}
284-

0 commit comments

Comments
 (0)