]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - docs/js/editor.js
1 $(document
).ready(function() {
2 var markdown_editor
= $("#markdown_editor"),
3 save_editor
= $(".save_editor"),
6 $("#editThis").click(function() {
7 editor
.css({"display":"block"});
8 markdown_editor
.autosize().val();
11 $(".closeEditor").click(function() {
12 editor
.css({"display":"none"});
15 save_editor
.click(function() {
16 var original_text
= save_editor
.text();
17 save_editor
.text("Saving...").addClass("disabled");
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");
22 var timeout
= setTimeout(function() {
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');
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');
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
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
.$);