-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
45 additions
and
64 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
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 |
---|---|---|
@@ -1,12 +1,43 @@ | ||
<div xmlns="http://www.w3.org/1999/xhtml" data-template="app:line-wrap"> | ||
<div xmlns="http://www.w3.org/1999/xhtml"> | ||
<h2 data-template="lang:translate">XML-Preview</h2> | ||
<div class="custom-control custom-switch line-wrap-toggle"> | ||
<input class="custom-control-input" type="checkbox" id="linewrap-switch" checked="checked"/> | ||
<label class="custom-control-label" for="linewrap-switch"><span data-template="lang:translate">linewrap</span> </label> | ||
<input class="custom-control-input" type="checkbox" id="line-wrap" checked="checked" data-template="app:init-custom-switch"/> | ||
<label class="custom-control-label" for="line-wrap"><span data-template="lang:translate">linewrap</span> </label> | ||
</div> | ||
<pre class="prettyprint" data-template="app:set-line-wrap"><code class="language-xml" data-template="app:xml-prettify"><![CDATA[<element xmlns="http://bla.org"><foo>some text</foo></element>]]></code></pre> | ||
<script type="text/javascript"> | ||
prettyPrint(); | ||
init_line_wrap_toggle(); | ||
function defer(method) { | ||
if (window.jQuery) { | ||
method(); | ||
} else { | ||
setTimeout(function() { defer(method) }, 50); | ||
} | ||
} | ||
|
||
function init_line_wrap_toggle() { | ||
let pre = $('.line-wrap-toggle ~ pre'), | ||
input = $('.line-wrap-toggle input'), | ||
endpoint_url = $('#settings').attr('data-api-base') + '/application/preferences'; | ||
|
||
// set listener for toggle | ||
input.change( | ||
function(a,b) { | ||
pre.toggleClass('line-wrap'); | ||
// update session | ||
data = { [this.getAttribute('id')]: this.checked }; | ||
fetch(endpoint_url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
} | ||
) | ||
prettyPrint(); | ||
} | ||
|
||
defer(init_line_wrap_toggle); | ||
</script> | ||
</div> | ||
</div> |
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