123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <!-- Basic Uppy styles -->
- <link rel="stylesheet" href="/uppy/uppy.min.css">
- <div class="DashboardOptions">
- <input type="checkbox" id="opts-DashboardInline" checked/><label for="opts-DashboardInline">Display inline</label>
- <input type="checkbox" id="opts-autoProceed" checked/><label for="opts-autoProceed">Autoproceed</label>
- <input type="checkbox" id="opts-restrictions" checked/><label for="opts-restrictions">Restrictions</label>
- <input type="checkbox" id="opts-Webcam" checked/><label for="opts-Webcam">Webcam</label>
- <input type="checkbox" id="opts-GoogleDrive" checked/><label for="opts-GoogleDrive">Google Drive</label>
- <input type="checkbox" id="opts-Dropbox" checked/><label for="opts-Dropbox">Dropbox</label>
- <input type="checkbox" id="opts-Instagram" checked/><label for="opts-Instagram">Instagram</label>
- </div>
- <!-- Modal trigger -->
- <button class="UppyModalOpenerBtn">Open Uppy Dashboard Modal</button>
- <div class="DashboardContainer"></div>
- <script>
- function isObjEmpty (obj) {
- return Object.keys(obj).length === 0 && obj.constructor === Object
- }
- var optionInputs = {
- DashboardInline: document.querySelector('#opts-DashboardInline'),
- Webcam: document.querySelector('#opts-Webcam'),
- GoogleDrive: document.querySelector('#opts-GoogleDrive'),
- Dropbox: document.querySelector('#opts-Dropbox'),
- Instagram: document.querySelector('#opts-Instagram'),
- autoProceed: document.querySelector('#opts-autoProceed'),
- restrictions: document.querySelector('#opts-restrictions')
- }
- var defaultOpts = {
- DashboardInline: true,
- Webcam: true,
- GoogleDrive: true,
- Instagram: true,
- Dropbox: false,
- autoProceed: false,
- restrictions: false
- }
- // try to get options from localStorage, if its empty, set to defaultOpts
- window.uppyOptions2 = JSON.parse(localStorage.getItem('uppyOptions2')) || {}
- if (isObjEmpty(window.uppyOptions2)) {
- window.uppyOptions2 = defaultOpts
- localStorage.setItem('uppyOptions2', JSON.stringify(window.uppyOptions2))
- }
- function toggleModalBtn () {
- var btn = document.querySelector('.UppyModalOpenerBtn')
- window.uppyOptions2.DashboardInline
- ? btn.style.display = 'none'
- : btn.style.display = 'block'
- }
- // Map input state to options
- Object.keys(optionInputs).forEach(function (item) {
- optionInputs[item].checked = window.uppyOptions2[item]
- })
- // When input value changes, update options
- Object.keys(optionInputs).forEach(function (item) {
- optionInputs[item].addEventListener('change', function () {
- window.uppyOptions2[item] = optionInputs[item].checked
- localStorage.setItem('uppyOptions', JSON.stringify(window.uppyOptions))
- toggleModalBtn()
- window.uppyInit()
- })
- })
- toggleModalBtn()
- </script>
|