Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / assets / js / src / application.js
1 // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
2 // IT'S ALL JUST JUNK FOR OUR DOCS!
3 // ++++++++++++++++++++++++++++++++++++++++++
4
5 /*!
6  * JavaScript for Bootstrap's docs (http://getbootstrap.com)
7  * Copyright 2011-2014 Twitter, Inc.
8  * Licensed under the Creative Commons Attribution 3.0 Unported License. For
9  * details, see http://creativecommons.org/licenses/by/3.0/.
10  */
11
12 /* global ZeroClipboard, addAnchors */
13
14 !function ($) {
15   'use strict';
16
17   $(function () {
18
19     // Scrollspy
20     var $window = $(window)
21     var $body   = $(document.body)
22
23     $body.scrollspy({
24       target: '.bs-docs-sidebar'
25     })
26     $window.on('load', function () {
27       $body.scrollspy('refresh')
28     })
29
30     // Kill links
31     $('.bs-docs-container [href=#]').click(function (e) {
32       e.preventDefault()
33     })
34
35     // Sidenav affixing
36     setTimeout(function () {
37       var $sideBar = $('.bs-docs-sidebar')
38
39       $sideBar.affix({
40         offset: {
41           top: function () {
42             var offsetTop      = $sideBar.offset().top
43             var sideBarMargin  = parseInt($sideBar.children(0).css('margin-top'), 10)
44             var navOuterHeight = $('.bs-docs-nav').height()
45
46             return (this.top = offsetTop - navOuterHeight - sideBarMargin)
47           },
48           bottom: function () {
49             return (this.bottom = $('.bs-docs-footer').outerHeight(true))
50           }
51         }
52       })
53     }, 100)
54
55     setTimeout(function () {
56       $('.bs-top').affix()
57     }, 100)
58
59     // theme toggler
60     ;(function () {
61       var stylesheetLink = $('#bs-theme-stylesheet')
62       var themeBtn = $('.bs-docs-theme-toggle')
63
64       var activateTheme = function () {
65         stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
66         themeBtn.text('Disable theme preview')
67         localStorage.setItem('previewTheme', true)
68       }
69
70       if (localStorage.getItem('previewTheme')) {
71         activateTheme()
72       }
73
74       themeBtn.click(function () {
75         var href = stylesheetLink.attr('href')
76         if (!href || href.indexOf('data') === 0) {
77           activateTheme()
78         } else {
79           stylesheetLink.attr('href', '')
80           themeBtn.text('Preview theme')
81           localStorage.removeItem('previewTheme')
82         }
83       })
84     })();
85
86     // Tooltip and popover demos
87     $('.tooltip-demo').tooltip({
88       selector: '[data-toggle="tooltip"]',
89       container: 'body'
90     })
91     $('.popover-demo').popover({
92       selector: '[data-toggle="popover"]',
93       container: 'body'
94     })
95
96     // Demos within modals
97     $('.tooltip-test').tooltip()
98     $('.popover-test').popover()
99
100     // Popover demos
101     $('.bs-docs-popover').popover()
102
103     // Button state demo
104     $('#loading-example-btn').on('click', function () {
105       var btn = $(this)
106       btn.button('loading')
107       setTimeout(function () {
108         btn.button('reset')
109       }, 3000)
110     })
111
112     // Modal relatedTarget demo
113     $('#exampleModal').on('show.bs.modal', function (event) {
114       var button = $(event.relatedTarget) // Button that triggered the modal
115       var recipient = button.data('whatever') // Extract info from data-* attributes
116       // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
117       // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
118       var modal = $(this)
119       modal.find('.modal-title').text('New message to ' + recipient)
120       modal.find('.modal-body input').val(recipient)
121     })
122
123     // Activate animated progress bar
124     $('.bs-docs-activate-animated-progressbar').on('click', function () {
125       $(this).siblings('.progress').find('.progress-bar-striped').toggleClass('active')
126     })
127
128     // Config ZeroClipboard
129     ZeroClipboard.config({
130       moviePath: '/assets/flash/ZeroClipboard.swf',
131       hoverClass: 'btn-clipboard-hover'
132     })
133
134     // Insert copy to clipboard button before .highlight
135     $('.highlight').each(function () {
136       var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>'
137       $(this).before(btnHtml)
138     })
139     var zeroClipboard = new ZeroClipboard($('.btn-clipboard'))
140     var htmlBridge = $('#global-zeroclipboard-html-bridge')
141
142     // Handlers for ZeroClipboard
143     zeroClipboard.on('load', function () {
144       htmlBridge
145         .data('placement', 'top')
146         .attr('title', 'Copy to clipboard')
147         .tooltip()
148     })
149
150     // Copy to clipboard
151     zeroClipboard.on('dataRequested', function (client) {
152       var highlight = $(this).parent().nextAll('.highlight').first()
153       client.setText(highlight.text())
154     })
155
156     // Notify copy success and reset tooltip title
157     zeroClipboard.on('complete', function () {
158       htmlBridge
159         .attr('title', 'Copied!')
160         .tooltip('fixTitle')
161         .tooltip('show')
162         .attr('title', 'Copy to clipboard')
163         .tooltip('fixTitle')
164     })
165
166     // Notify copy failure
167     zeroClipboard.on('noflash wrongflash', function () {
168       htmlBridge
169         .attr('title', 'Flash required')
170         .tooltip('fixTitle')
171         .tooltip('show')
172     })
173
174   })
175
176 }(jQuery)
177
178 ;(function () {
179   'use strict';
180   addAnchors('.bs-docs-container h1, .bs-docs-container h2, .bs-docs-container h3, .bs-docs-container h4, .bs-docs-container h5');
181 })();