aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/js/editor.js
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2014-12-22 14:33:01 +0100
committerThomas Citharel <tcit@tcit.fr>2014-12-22 14:33:01 +0100
commitf3917b1ee4bba812e82da57dd181f50d62926db4 (patch)
treecb4b04931e97e4a69500bf9d7aa5c21985cab59e /docs/js/editor.js
parent311baf86befde0557faea614ca4d13bb2bd2cc66 (diff)
parent9254b6cf460edec3a59e9ccc19873481a1d19c90 (diff)
downloadwallabag-f3917b1ee4bba812e82da57dd181f50d62926db4.tar.gz
wallabag-f3917b1ee4bba812e82da57dd181f50d62926db4.tar.zst
wallabag-f3917b1ee4bba812e82da57dd181f50d62926db4.zip
Merge branch 'dev' into randomarticle
Diffstat (limited to 'docs/js/editor.js')
-rw-r--r--docs/js/editor.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/docs/js/editor.js b/docs/js/editor.js
new file mode 100644
index 00000000..9209d59c
--- /dev/null
+++ b/docs/js/editor.js
@@ -0,0 +1,53 @@
1$(document).ready(function() {
2 var markdown_editor = $("#markdown_editor"),
3 save_editor = $(".save_editor"),
4 editor = $(".editor");
5
6 $("#editThis").click(function() {
7 editor.css({"display":"block"});
8 markdown_editor.autosize().val();
9 });
10
11 $(".closeEditor").click(function() {
12 editor.css({"display":"none"});
13 });
14
15 save_editor.click(function() {
16 var original_text = save_editor.text();
17 save_editor.text("Saving...").addClass("disabled");
18
19 $.post(window.location.href, {markdown: markdown_editor.val(), method: 'DauxEdit' }, function() {
20 save_editor.text("Done! Reloading page in 5 seconds. You can cancel it with ESC key");
21
22 var timeout = setTimeout(function() {
23 location.reload()
24 }, 5000); // lie
25
26 $(document).keyup(function(e) {
27 if (e.keyCode == 27) { // esc key
28 clearTimeout(timeout);
29 save_editor.text("Page reload cancelled");
30 setTimeout(function() {
31 save_editor.text(original_text).removeClass('disabled');
32 }, 2000);
33 }
34 });
35 }).fail(function() {
36 save_editor.removeClass('disabled').addClass("btn-danger").text("Failed :( - try checking your read/write permissions");
37 setTimeout(function() {
38 save_editor.text(original_text).removeClass('btn-danger');
39 },5000);
40 });
41 });
42});
43
44
45
46
47/*!
48 Autosize v1.18.4 - 2014-01-11
49 Automatically adjust textarea height based on user input.
50 (c) 2014 Jack Moore - http://www.jacklmoore.com/autosize
51 license: http://www.opensource.org/licenses/mit-license.php
52*/
53!function(a){var b,c={className:"autosizejs",append:"",callback:!1,resizeDelay:10,placeholder:!0},d='<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',e=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],f=a(d).data("autosize",!0)[0];f.style.lineHeight="99px","99px"===a(f).css("lineHeight")&&e.push("lineHeight"),f.style.lineHeight="",a.fn.autosize=function(d){return this.length?(d=a.extend({},c,d||{}),f.parentNode!==document.body&&a(document.body).append(f),this.each(function(){function c(){var b,c=window.getComputedStyle?window.getComputedStyle(m,null):!1;c?(b=m.getBoundingClientRect().width,0===b&&(b=parseInt(c.width,10)),a.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(a,d){b-=parseInt(c[d],10)})):b=Math.max(n.width(),0),f.style.width=b+"px"}function g(){var g={};if(b=m,f.className=d.className,j=parseInt(n.css("maxHeight"),10),a.each(e,function(a,b){g[b]=n.css(b)}),a(f).css(g),c(),window.chrome){var h=m.style.width;m.style.width="0px";{m.offsetWidth}m.style.width=h}}function h(){var e,h;b!==m?g():c(),f.value=!m.value&&d.placeholder?(a(m).attr("placeholder")||"")+d.append:m.value+d.append,f.style.overflowY=m.style.overflowY,h=parseInt(m.style.height,10),f.scrollTop=0,f.scrollTop=9e4,e=f.scrollTop,j&&e>j?(m.style.overflowY="scroll",e=j):(m.style.overflowY="hidden",k>e&&(e=k)),e+=o,h!==e&&(m.style.height=e+"px",p&&d.callback.call(m,m))}function i(){clearTimeout(l),l=setTimeout(function(){var a=n.width();a!==r&&(r=a,h())},parseInt(d.resizeDelay,10))}var j,k,l,m=this,n=a(m),o=0,p=a.isFunction(d.callback),q={height:m.style.height,overflow:m.style.overflow,overflowY:m.style.overflowY,wordWrap:m.style.wordWrap,resize:m.style.resize},r=n.width();n.data("autosize")||(n.data("autosize",!0),("border-box"===n.css("box-sizing")||"border-box"===n.css("-moz-box-sizing")||"border-box"===n.css("-webkit-box-sizing"))&&(o=n.outerHeight()-n.height()),k=Math.max(parseInt(n.css("minHeight"),10)-o||0,n.height()),n.css({overflow:"hidden",overflowY:"hidden",wordWrap:"break-word",resize:"none"===n.css("resize")||"vertical"===n.css("resize")?"none":"horizontal"}),"onpropertychange"in m?"oninput"in m?n.on("input.autosize keyup.autosize",h):n.on("propertychange.autosize",function(){"value"===event.propertyName&&h()}):n.on("input.autosize",h),d.resizeDelay!==!1&&a(window).on("resize.autosize",i),n.on("autosize.resize",h),n.on("autosize.resizeIncludeStyle",function(){b=null,h()}),n.on("autosize.destroy",function(){b=null,clearTimeout(l),a(window).off("resize",i),n.off("autosize").off(".autosize").css(q).removeData("autosize")}),h())})):this}}(window.jQuery||window.$);