codemirror2 is in, all javascript is back and functional
Oleg
committed Jun 03, 2011
commit 9cc2d2f94c5797de9007f2b79019555eaa848775
Showing 10
changed files with
116 additions
and 36 deletions
app/assets/javascripts/comfortable_mexican_sofa/application.js
+11
-32
| @@ | @@ -1,6 +1,7 @@ |
| //= require comfortable_mexican_sofa/jquery.js | |
| //= require comfortable_mexican_sofa/jquery_ui.js | |
| //= require comfortable_mexican_sofa/rails.js | |
| + | //= require comfortable_mexican_sofa/codemirror/codemirror.js |
| $.CMS = function(){ | |
| var current_path = window.location.pathname; | |
| @@ | @@ -11,13 +12,13 @@ $.CMS = function(){ |
| $.CMS.tree_methods(); | |
| $.CMS.load_page_blocks(); | |
| $.CMS.enable_rich_text(); | |
| - | // $.CMS.enable_codemirror(); |
| + | $.CMS.enable_codemirror(); |
| $.CMS.enable_date_picker(); | |
| $.CMS.enable_sortable_list(); | |
| if($('form.new_cms_page, form.edit_cms_page').get(0)) $.CMS.enable_page_save_form(); | |
| if($('#mirrors').get(0)) $.CMS.enable_mirrors_widget(); | |
| if($('#page_save').get(0)) $.CMS.enable_page_save_widget(); | |
| - | // if($('#uploader_button').get(0)) $.CMS.enable_uploader(); |
| + | if($('#uploader_button').get(0)) $.CMS.enable_uploader(); |
| }); | |
| return { | |
| @@ | @@ -70,42 +71,20 @@ $.CMS = function(){ |
| }) | |
| }); | |
| }, | |
| - | |
| + | |
| enable_rich_text: function(){ | |
| $('textarea.rich_text').wymeditor(cms_wym_options); | |
| }, | |
| - | |
| + | |
| enable_codemirror: function(){ | |
| $('textarea.code').each(function(i, element){ | |
| + | var mode = 'htmlmixed'; |
| + | if ($(element).hasClass('css')) mode = 'css'; |
| + | if ($(element).hasClass('js')) mode = 'javascript'; |
| CodeMirror.fromTextArea(element, { | |
| - | basefiles: [ |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/codemirror_base.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_xml.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_css.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_js.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_html_mixed.js" |
| - | ], |
| - | stylesheet: "/javascripts/comfortable_mexican_sofa/codemirror/codemirror.css" |
| - | }); |
| - | }); |
| - | |
| - | $('textarea.code_css').each(function(i, element){ |
| - | CodeMirror.fromTextArea(element, { |
| - | basefiles: [ |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/codemirror_base.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_css.js" |
| - | ], |
| - | stylesheet: "/javascripts/comfortable_mexican_sofa/codemirror/codemirror.css" |
| - | }); |
| - | }); |
| - | |
| - | $('textarea.code_js').each(function(i, element){ |
| - | CodeMirror.fromTextArea(element, { |
| - | basefiles: [ |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/codemirror_base.js", |
| - | "/javascripts/comfortable_mexican_sofa/codemirror/parse_js.js" |
| - | ], |
| - | stylesheet: "/javascripts/comfortable_mexican_sofa/codemirror/codemirror.css" |
| + | htmlMode: true, |
| + | mode: mode, |
| + | tabMode: 'indent' |
| }); | |
| }); | |
| }, | |
app/assets/javascripts/comfortable_mexican_sofa/codemirror/codemirror.js
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | var CodeMirror=function(){function D(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function C(a,b){if(!b)return a?a.length:0;if(!a)return b.length;for(var c=a.length,d=b.length;c>=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function B(a){return a.replace(/[<>&]/g,function(a){return a=="&"?"&":a=="<"?"<":">"})}function A(a){return{line:a.line,ch:a.ch}}function z(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function y(a,b){return a.line==b.line&&a.ch==b.ch}function x(a){return a.textContent||a.innerText||a.nodeValue||""}function w(a,b){var c=a.ownerDocument.body,d=0,e=0,f=!1;for(var g=a;g;g=g.offsetParent)d+=g.offsetLeft,e+=g.offsetTop,g==c&&(f=!0);var h=b&&f?null:c;for(var g=a.parentNode;g!=h;g=g.parentNode)g.scrollLeft!=null&&(d-=g.scrollLeft,e-=g.scrollTop);return{left:d,top:e}}function v(a,b){b==null&&(b=a.search(/[^\s\u00a0]/),b==-1&&(b=a.length));for(var c=0,d=0;c<b;++c)a.charAt(c)=="\t"?d+=r-d%r:++d;return d}function n(){this.id=null}function m(a,b,c,d){function e(a){c(new l(a||window.event))}if(typeof a.addEventListener=="function"){a.addEventListener(b,e,!1);if(d)return function(){a.removeEventListener(b,e,!1)}}else{a.attachEvent("on"+b,e);if(d)return function(){a.detachEvent("on"+b,e)}}}function l(a){this.e=a}function k(a){a.stop||(a.stop=j);return a}function j(){this.preventDefault?(this.preventDefault(),this.stopPropagation()):(this.returnValue=!1,this.cancelBubble=!0)}function i(){this.time=0,this.done=[],this.undone=[]}function h(a,b,c,d){for(var e=0,f=0,g=0;f<b;e+=2){var h=c[e],i=f+h.length;g==0?(i>a&&d.push(h.slice(a-f,Math.min(h.length,b-f)),c[e+1]),i>=a&&(g=1)):g==1&&(i>b?d.push(h.slice(0,b-f),c[e+1]):d.push(h,c[e+1])),f=i}}function g(a,b){this.styles=b||[a,null],this.stateAfter=null,this.text=a,this.marked=this.gutterMarker=this.className=null}function f(a){this.pos=this.start=0,this.string=a}function e(a,b,c){return a.startState?a.startState(b,c):!0}function d(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function a(b,c){function cL(a,b,c){this.atOccurrence=!1,c==null&&(c=typeof a=="string"&&a==a.toLowerCase()),b&&typeof b=="object"?b=ca(b):b={line:0,ch:0},this.pos={from:b,to:b};if(typeof a!="string")this.matches=function(b,c){if(b){var d=U[c.line].text.slice(0,c.ch),e=d.match(a),f=0;while(e){var g=d.indexOf(e[0]);f+=g,d=d.slice(g+1);var h=d.match(a);if(h)e=h;else break;f++}}else var d=U[c.line].text.slice(c.ch),e=d.match(a),f=e&&c.ch+d.indexOf(e[0]);if(e)return{from:{line:c.line,ch:f},to:{line:c.line,ch:f+e[0].length},match:e}};else{c&&(a=a.toLowerCase());var d=c?function(a){return a.toLowerCase()}:function(a){return a},e=a.split("\n");e.length==1?this.matches=function(b,c){var e=d(U[c.line].text),f=a.length,g;if(b?c.ch>=f&&(g=e.lastIndexOf(a,c.ch-f))!=-1:(g=e.indexOf(a,c.ch))!=-1)return{from:{line:c.line,ch:g},to:{line:c.line,ch:g+f}}}:this.matches=function(a,b){var c=b.line,f=a?e.length-1:0,g=e[f],h=d(U[c].text),i=a?h.indexOf(g)+g.length:h.lastIndexOf(g);if(!(a?i>=b.ch||i!=g.length:i<=b.ch||i!=h.length-g.length))for(;;){if(a?!c:c==U.length-1)return;h=d(U[c+=a?-1:1].text),g=e[a?--f:++f];if(f>0&&f<e.length-1){if(h!=g)return;continue}var j=a?h.lastIndexOf(g):h.indexOf(g)+g.length;if(a?j!=h.length-g.length:j!=g.length)return;var k={line:b.line,ch:i},l={line:c,ch:j};return{from:a?l:k,to:a?k:l}}}}}function cK(a){return function(){cJ++||cH();try{var b=a.apply(this,arguments)}finally{--cJ||cI()}return b}}function cI(){var a=!1;bd&&(a=!bQ()),bb.length?bT(bb):bd&&bX(),a&&bQ(),bd&&cA(),!be&&(ba===!0||ba!==!1&&bd)&&bO(),bd&&f.matchBrackets&&setTimeout(cK(function(){bk&&(bk(),bk=null),cC(!1)}),20);var b=bc;bd&&f.onCursorActivity&&f.onCursorActivity(bp),b&&f.onChange&&bp&&f.onChange(bp,b)}function cH(){ba=null,bb=[],bc=bd=!1}function cG(a){!V.length||R.set(a,cK(cF))}function cF(){var a=+(new Date)+f.workTime,b=!1;while(V.length){if(!U[bf].stateAfter)var c=bf;else var c=V.pop();if(c>=U.length)continue;b=!0;var g=cD(c),h=g&&U[g-1].stateAfter;h?h=d(T,h):h=e(T);var i=0;for(var j=g,k=U.length;j<k;++j){var l=U[j],m=l.stateAfter;if(+(new Date)>a){V.push(j),cG(f.workDelay),bb.push({from:c,to:j});return}var n=l.highlight(T,h);l.stateAfter=d(T,h);if(n||!m)i=0;else if(++i>3)break}bb.push({from:c,to:j})}b&&f.onHighlightComplete&&f.onHighlightComplete(bp)}function cE(a){var b=cD(a),c=b&&U[b-1].stateAfter;c?c=d(T,c):c=e(T);for(var f=b;f<a;++f){var g=U[f];g.highlight(T,c),g.stateAfter=d(T,c)}U[a].stateAfter||V.push(a);return c}function cD(a){var b,c;for(var d=a,e=a-40;d>e;--d){if(d==0)return 0;var f=U[d-1];if(f.stateAfter)return d;var g=f.indentation();if(c==null||b>g)c=d,b=g}return c}function cC(a){function p(a,b,c){if(!!a.text){var d=a.styles,e=g?0:a.text.length-1,f;for(var i=g?0:d.length-2,j=g?d.length:-2;i!=j;i+=2*h){var k=d[i];if(d[i+1]!=null&&d[i+1]!=m){e+=h*k.length;continue}for(var l=g?0:k.length-1,p=g?k.length:-1;l!=p;l+=h,e+=h)if(e>=b&&e<c&&o.test(f=k.charAt(l))){var q=cB[f];if(q.charAt(1)==">"==g)n.push(f);else{if(n.pop()!=q.charAt(0))return{pos:e,match:!1};if(!n.length)return{pos:e,match:!0}}}}}}var b=Y.inverted?Y.from:Y.to,c=U[b.line],d=b.ch-1,e=d>=0&&cB[c.text.charAt(d)]||cB[c.text.charAt(++d)];if(!!e){var f=e.charAt(0),g=e.charAt(1)==">",h=g?1:-1,i=c.styles;for(var j=d+1,k=0,l=i.length;k<l;k+=2)if((j-=i[k].length)<=0){var m=i[k+1];break}var n=[c.text.charAt(d)],o=/[(){}[\]]/;for(var k=b.line,l=g?Math.min(k+50,U.length):Math.max(-1,k-50);k!=l;k+=h){var c=U[k],q=k==b.line,r=p(c,q&&g?d+1:0,q&&!g?d:c.text.length);if(r){var m=r.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",s=cl({line:b.line,ch:d},{line:b.line,ch:d+1},m),t=cl({line:k,ch:r.pos},{line:k,ch:r.pos+1},m),u=cK(function(){s(),t()});a?setTimeout(u,800):bk=u;break}}}}function cA(){clearInterval(S);var a=!0;O.style.visibility="",S=setInterval(function(){O.style.visibility=(a=!a)?"":"hidden"},650)}function cz(a){function e(){B.value!=d&&cK(bG)(B.value,"end"),B.style.cssText=c,be=!1,bO(),bL()}var b=cy(a);if(!!b&&!window.opera){(y(Y.from,Y.to)||z(b,Y.from)||!z(b,Y.to))&&b$(b.line,b.ch);var c=B.style.cssText;B.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(a.pageY()-1)+"px; left: "+(a.pageX()-1)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden;";var d=B.value=bJ();bP(),G(B,0,B.value.length),be=!0;if(p){a.stop();var f=m(window,"mouseup",function(){f(),setTimeout(e,20)},!0)}else setTimeout(e,50)}}function cy(a,b){var c=w(H,!0),d=a.e.clientX,e=a.e.clientY;if(!b&&(d-c.left>H.clientWidth||e-c.top>H.clientHeight))return null;var f=w(N,!0),g=bf+Math.floor((e-f.top)/cv());return ca({line:g,ch:cs(b_(g),d-f.left)})}function cx(){return N.offsetLeft}function cw(){return N.offsetTop}function cv(){var a=P.childNodes.length;if(a)return P.offsetHeight/a||1;J.innerHTML="<pre>x</pre>";return J.firstChild.offsetHeight||1}function cu(a){var b=ct(a,!0),c=w(N);return{x:c.left+b.x,y:c.top+b.y,yBot:c.top+b.yBot}}function ct(a,b){var c=cv(),d=a.line-(b?bf:0);return{x:cr(a.line,a.ch),y:d*c,yBot:(d+1)*c}}function cs(a,b){function e(a){J.innerHTML="<pre><span>"+c.getHTML(null,null,!1,a)+"</span></pre>";return J.firstChild.firstChild.offsetWidth}if(b<=0)return 0;var c=U[a],d=c.text,f=0,g=0,h=d.length,i,j=Math.min(h,Math.ceil(b/cq("x")));for(;;){var k=e(j);if(k<=b&&j<h)j=Math.min(h,Math.ceil(j*1.2));else{i=k,h=j;break}}if(b>i)return h;j=Math.floor(h*.8),k=e(j),k<b&&(f=j,g=k);for(;;){if(h-f<=1)return i-b>b-g?f:h;var l=Math.ceil((f+h)/2),m=e(l);m>b?(h=l,i=m):(f=l,g=m)}}function cr(a,b){if(b==0)return 0;J.innerHTML="<pre><span>"+U[a].getHTML(null,null,!1,b)+"</span></pre>";return J.firstChild.firstChild.offsetWidth}function cq(a){J.innerHTML="<pre><span>x</span></pre>",J.firstChild.firstChild.firstChild.nodeValue=a;return J.firstChild.firstChild.offsetWidth||10}function cp(a){if(typeof a=="number"){var b=a;a=U[a];if(!a)return null}else{var b=D(U,a);if(b==-1)return null}var c=a.gutterMarker;return{line:b,text:a.text,markerText:c&&c.text,markerClass:c&&c.style}}function co(a,b){if(typeof a=="number"){var c=a;a=U[b_(a)]}else{var c=D(U,a);if(c==-1)return null}a.className!=b&&(a.className=b,bb.push({from:c,to:c+1}));return a}function cn(a){typeof a=="number"&&(a=U[b_(a)]),a.gutterMarker=null,bW()}function cm(a,b,c){typeof a=="number"&&(a=U[b_(a)]),a.gutterMarker={text:b,style:c},bW();return a}function cl(a,b,c){function e(a,b,c,e){var a=U[a],f=a.addMark(b,c,e);f.line=a,d.push(f)}a=ca(a),b=ca(b);var d=[];if(a.line==b.line)e(a.line,a.ch,b.ch,c);else{e(a.line,a.ch,null,c);for(var f=a.line+1,g=b.line;f<g;++f)e(f,0,null,c);e(b.line,0,b.ch,c)}bb.push({from:a.line,to:b.line+1});return function(){var a,b;for(var c=0;c<d.length;++c){var e=d[c],f=D(U,e.line);e.line.removeMark(e),f>-1&&(a==null&&(a=f),b=f)}a!=null&&bb.push({from:a,to:b+1})}}function ck(){var a=f.gutter||f.lineNumbers;L.style.display=a?"":"none",a?bW():P.parentNode.style.marginLeft=0}function cj(){T=a.getMode(f,f.mode);for(var b=0,c=U.length;b<c;++b)U[b].stateAfter=null;V=[0],cG()}function ci(a,b){if(b=="smart")if(!T.indent)b="prev";else var c=cE(a);var d=U[a],e=d.indentation(),g=d.text.match(/^\s*/)[0],h;b=="prev"?a?h=U[a-1].indentation():h=0:b=="smart"?h=T.indent(c,d.text.slice(g.length)):b=="add"?h=e+f.indentUnit:b=="subtract"&&(h=e-f.indentUnit),h=Math.max(0,h);var i=h-e;if(!i){if(Y.from.line!=a&&Y.to.line!=a)return;var j=g}else{var j="",k=0;if(f.indentWithTabs)for(var l=Math.floor(h/r);l;--l)k+=r,j+="\t";while(k<h)++k,j+=" "}bF(j,{line:a,ch:0},{line:a,ch:g.length})}function ch(a){Z=null;switch(f.tabMode){case"default":return!1;case"indent":for(var b=Y.from.line,c=Y.to.line;b<=c;++b)ci(b,"smart");break;case"classic":if(y(Y.from,Y.to)){a?ci(Y.from.line,"smart"):bG("\t","end");break};case"shift":for(var b=Y.from.line,c=Y.to.line;b<=c;++b)ci(b,a?"subtract":"add")}return!0}function cg(){bG("\n","end"),f.enterMode!="flat"&&ci(Y.from.line,f.enterMode=="keep"?"prev":"smart")}function cf(a){bY({line:a,ch:0},{line:a,ch:U[a].text.length})}function ce(a){var b=U[a.line].text,c=a.ch,d=a.ch;while(c>0&&/\w/.test(b.charAt(c-1)))--c;while(d<b.length&&/\w/.test(b.charAt(d)))++d;bY({line:a.line,ch:c},{line:a.line,ch:d})}function cd(){var a=U.length-1;bZ({line:0,ch:0},{line:a,ch:U[a].text.length})}function cc(a){var b=a?{line:0,ch:0}:{line:U.length-1,ch:U[U.length-1].text.length};bY(b,b)}function cb(a){var b=Math.floor(H.clientHeight/cv()),c=Y.inverted?Y.from:Y.to;b$(c.line+Math.max(b-1,1)*(a?1:-1),c.ch,!0)}function ca(a){if(a.line<0)return{line:0,ch:0};if(a.line>=U.length)return{line:U.length-1,ch:U[U.length-1].text.length};var b=a.ch,c=U[a.line].text.length;return b==null||b>c?{line:a.line,ch:c}:b<0?{line:a.line,ch:0}:a}function b_(a){return Math.max(0,Math.min(a,U.length-1))}function b$(a,b,c){var d=ca({line:a,ch:b||0});(c?bY:bZ)(d,d)}function bZ(a,b,c,d){if(!y(Y.from,a)||!y(Y.to,b)){if(z(b,a)){var e=b;b=a,a=e}var f=y(Y.to,b),g=y(Y.from,a);y(a,b)?Y.inverted=!1:f&&!g?Y.inverted=!0:g&&!f&&(Y.inverted=!1),c==null&&(c=Y.from.line,d=Y.to.line),y(a,b)?y(Y.from,Y.to)||bb.push({from:c,to:d+1}):y(Y.from,Y.to)?bb.push({from:a.line,to:b.line+1}):(y(a,Y.from)||(a.line<c?bb.push({from:a.line,to:Math.min(b.line,c)+1}):bb.push({from:c,to:Math.min(d,a.line)+1})),y(b,Y.to)||(b.line<d?bb.push({from:Math.max(c,a.line),to:d+1}):bb.push({from:Math.max(a.line,d),to:b.line+1}))),Y.from=a,Y.to=b,bd=!0}}function bY(a,b){var c=Z&&ca(Z);c&&(z(c,a)?a=c:z(b,c)&&(b=c)),bZ(a,b)}function bX(){var a=Y.inverted?Y.from:Y.to,b=cv(),c=cr(a.line,a.ch)+"px",d=(a.line-bf)*b+"px";v.style.top=a.line*b-H.scrollTop+"px",y(Y.from,Y.to)?(O.style.top=d,O.style.left=c,O.style.display=""):O.style.display="none"}function bW(){if(!!f.gutter||!!f.lineNumbers){var a=K.offsetHeight,b=H.clientHeight;L.style.height=(a-b<2?b:a)+"px";var c=[];for(var d=bf;d<bg;++d){var e=U[d].gutterMarker,g=f.lineNumbers?d+f.firstLineNumber:null;e&&e.text?g=e.text.replace("%N%",g!=null?g:""):g==null&&(g="\u00a0"),c.push(e&&e.style?'<pre class="'+e.style+'">':"<pre>",g,"</pre>")}L.style.display="none",M.innerHTML=c.join("");var h=String(U.length).length,i=M.firstChild,j=x(i),k="";while(j.length+k.length<h)k+="\u00a0";k&&i.insertBefore(l.createTextNode(k),i.firstChild),L.style.display="",N.style.marginLeft=L.offsetWidth+"px"}}function bV(a){var b=Y.from.line,c=Y.to.line,d=0,e=o&&l.createElement("div");for(var f=0,g=a.length;f<g;++f){var h=a[f],i=h.to-h.from-h.domSize,j=P.childNodes[h.domStart+h.domSize+d]||null;if(o)for(var k=Math.max(-i,h.domSize);k>0;--k)P.removeChild(j?j.previousSibling:P.lastChild);else if(i){for(var k=Math.max(0,i);k>0;--k)P.insertBefore(l.createElement("pre"),j);for(var k=Math.max(0,-i);k>0;--k)P.removeChild(j?j.previousSibling:P.lastChild)}var m=P.childNodes[h.domStart+d],n=b<h.from&&c>=h.from;for(var k=h.from;k<h.to;++k){var p=null,q=null;n?(p=0,c==k&&(n=!1,q=Y.to.ch)):b==k&&(c==k?(p=Y.from.ch,q=Y.to.ch):(n=!0,p=Y.from.ch)),o?(e.innerHTML=U[k].getHTML(p,q,!0),P.insertBefore(e.firstChild,j)):(m.innerHTML=U[k].getHTML(p,q,!1),m.className=U[k].className||"",m=m.nextSibling)}d+=i}}function bU(a,b){var c=[],d={line:a,ch:0},e=z(Y.from,d)&&!z(Y.to,d);for(var f=a;f<b;++f){var g=null,h=null;e?(g=0,Y.to.line==f&&(e=!1,h=Y.to.ch)):Y.from.line==f&&(Y.to.line==f?(g=Y.from.ch,h=Y.to.ch):(e=!0,g=Y.from.ch)),c.push(U[f].getHTML(g,h,!0))}P.innerHTML=c.join("")}function bT(a){if(!H.clientWidth)bf=bg=0;else{var b=a===!0?[]:[{from:bf,to:bg,domStart:0}];for(var c=0,d=a.length||0;c<d;++c){var e=a[c],f=[],g=e.diff||0;for(var h=0,i=b.length;h<i;++h){var j=b[h];e.to<=j.from?f.push({from:j.from+g,to:j.to+g,domStart:j.domStart}):j.to<=e.from?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from,domStart:j.domStart}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g,domStart:j.domStart+(e.to-j.from)}))}b=f}var k=bS(),l=Math.min(bf,Math.max(k.from-3,0)),m=Math.min(U.length,Math.max(bg,k.to+3)),n=[],o=0,p=bg-bf,q=l,r=0;for(var c=0,d=b.length;c<d;++c){var j=b[c];if(j.to<=l)continue;if(j.from>=m)break;if(j.domStart>o||j.from>q)n.push({from:q,to:j.from,domSize:j.domStart-o,domStart:o}),r+=j.from-q;q=j.to,o=j.domStart+(j.to-j.from)}if(o!=p||q!=m)r+=Math.abs(m-q),n.push({from:q,to:m,domSize:p-o,domStart:o});if(!n.length)return;P.style.display="none",r>(k.to-k.from)*.3?bU(l=Math.max(k.from-10,0),m=Math.min(k.to+7,U.length)):bV(n),P.style.display="";var s=l!=bf||m!=bg||bh!=H.clientHeight;bf=l,bg=m,K.style.top=l*cv()+"px",s&&(bh=H.clientHeight,I.style.height=U.length*cv()+2*cw()+"px",bW());var t=cq(bl);N.style.width=t>H.clientWidth?t+"px":"";if(P.childNodes.length!=bg-bf)throw new Error("BAD PATCH! "+JSON.stringify(n)+" size="+(bg-bf)+" nodes="+P.childNodes.length);bX()}}function bS(){var a=cv(),b=H.scrollTop-cw();return{from:Math.min(U.length,Math.max(0,Math.floor(b/a))),to:Math.min(U.length,Math.ceil((b+H.clientHeight)/a))}}function bR(a,b,c,d){var e=cx(),g=cw(),h=cv();b+=g,d+=g,a+=e,c+=e;var i=H.clientHeight,j=H.scrollTop,k=!1,l=!0;b<j?(H.scrollTop=Math.max(0,b-2*h),k=!0):d>j+i&&(H.scrollTop=d+h-i,k=!0);var m=H.clientWidth,n=H.scrollLeft;a<n?(a<50&&(a=0),H.scrollLeft=Math.max(0,a-10),k=!0):c>m+n&&(H.scrollLeft=c+10-m,k=!0,c>I.clientWidth&&(l=!1)),k&&f.onScroll&&f.onScroll(bp);return l}function bQ(){var a=ct(Y.inverted?Y.from:Y.to);return bR(a.x,a.y,a.x,a.yBot)}function bP(){f.readOnly!="nocursor"&&B.focus()}function bO(){var a=[],b=Math.max(0,Y.from.line-1),c=Math.min(U.length,Y.to.line+2);for(var d=b;d<c;++d)a.push(U[d].text);a=B.value=a.join(q);var e=Y.from.ch,f=Y.to.ch;for(var d=b;d<Y.from.line;++d)e+=q.length+U[d].text.length;for(var d=b;d<Y.to.line;++d)f+=q.length+U[d].text.length;bj={text:a,from:b,to:c,start:e,end:f},G(B,e,$?e:f)}function bN(){function g(a,c){var d=0;for(;;){var e=b.indexOf("\n",d);if(e==-1||(b.charAt(e-1)=="\r"?e-1:e)>=a)return{line:c,ch:a-d};++c,d=e+1}}if(!be){var a=!1,b=B.value,c=F(B);if(!c)return!1;var a=bj.text!=b,d=$,e=a||c.start!=bj.start||c.end!=(d?bj.start:bj.end);if(!e&&!d)return!1;if(a){Z=$=null;if(f.readOnly){ba=!0;return"changed"}}var h=g(c.start,bj.from),i=g(c.end,bj.from);if(d){h=c.start==d.anchor?i:h,i=Z?Y.to:c.start==d.anchor?h:i;if(!z(h,i)){$=null,Y.inverted=!1;var j=h;h=i,i=j}}h.line==i.line&&h.line==Y.from.line&&h.line==Y.to.line&&!Z&&(ba=!1);if(a){var k=0,l=b.length,m=Math.min(l,bj.text.length),n,o=bj.from,p=-1;while(k<m&&(n=b.charAt(k))==bj.text.charAt(k))++k,n=="\n"&&(o++,p=k);var q=p>-1?k-p:k,r=bj.to-1,s=bj.text.length;for(;;){n=bj.text.charAt(s),n=="\n"&&r--;if(b.charAt(l)!=n){++l,++s;break}if(s<=k||l<=k)break;--l,--s}var p=bj.text.lastIndexOf("\n",s-1),t=p==-1?s:s-p-1;bA({line:o,ch:q},{line:r,ch:t},E(b.slice(k,l)),h,i);if(o!=r||h.line!=o)ba=!0}else bZ(h,i);bj.text=b,bj.start=c.start,bj.end=c.end;return a?"changed":e?"moved":!1}}function bM(a){function c(){cH();var d=bN();d=="moved"&&a&&(t[a]=!0),!d&&!b?(b=!0,Q.set(80,c)):(bK=!1,bL()),cI()}var b=!1;bK=!0,Q.set(20,c)}function bL(){bK||Q.set(2e3,function(){cH(),bN(),X&&bL(),cI()})}function bJ(){return bI(Y.from,Y.to)}function bI(a,b){var c=a.line,d=b.line;if(c==d)return U[c].text.slice(a.ch,b.ch);var e=[U[c].text.slice(a.ch)];for(var f=c+1;f<d;++f)e.push(U[f].text);e.push(U[d].text.slice(0,b.ch));return e.join("\n")}function bH(a,b,c,d){var e=a.length==1?a[0].length+b.ch:a[a.length-1].length,f=d({line:b.line+a.length-1,ch:e});bA(b,c,a,f.from,f.to)}function bG(a,b){bH(E(a),Y.from,Y.to,function(a){return b=="end"?{from:a,to:a}:b=="start"?{from:Y.from,to:Y.from}:{from:Y.from,to:a}})}function bF(a,b,c){function d(d){if(z(d,b))return d;if(!z(c,d))return e;var f=d.line+a.length-(c.line-b.line)-1,g=d.ch;d.line==c.line&&(g+=a[a.length-1].length-(c.ch-(c.line==b.line?b.ch:0)));return{line:f,ch:g}}b=ca(b),c?c=ca(c):c=b,a=E(a);var e;bH(a,b,c,function(a){e=a;return{from:d(Y.from),to:d(Y.to)}});return e}function bE(a,b,c,d,e){function s(a){return a<=Math.min(b.line,b.line+q)?a:a+q}var f=!1,h=bl.length;for(var i=a.line;i<b.line;++i)if(U[i].text.length==h){f=!0;break}var j=b.line-a.line,k=U[a.line],l=U[b.line];if(k==l)if(c.length==1)k.replace(a.ch,b.ch,c[0]);else{l=k.split(b.ch,c[c.length-1]);var m=[a.line+1,j];k.replace(a.ch,k.text.length,c[0]);for(var i=1,n=c.length-1;i<n;++i)m.push(new g(c[i]));m.push(l),U.splice.apply(U,m)}else if(c.length==1)k.replace(a.ch,k.text.length,c[0]+l.text.slice(b.ch)),U.splice(a.line+1,j);else{var m=[a.line+1,j-1];k.replace(a.ch,k.text.length,c[0]),l.replace(0,b.ch,c[c.length-1]);for(var i=1,n=c.length-1;i<n;++i)m.push(new g(c[i]));U.splice.apply(U,m)}for(var i=a.line,n=i+c.length;i<n;++i){var o=U[i].text;o.length>h&&(bl=o,h=o.length,f=!1)}if(f){h=0;for(var i=0,n=U.length;i<n;++i){var o=U[i].text;o.length>h&&(h=o.length,bl=o)}}var p=[],q=c.length-j-1;for(var i=0,o=V.length;i<o;++i){var r=V[i];r<a.line?p.push(r):r>b.line&&p.push(r+q)}c.length&&p.push(a.line),V=p,cG(100),bb.push({from:a.line,to:b.line+1,diff:q}),bc={from:a,to:b,text:c},bZ(d,e,s(Y.from.line),s(Y.to.line)),I.style.height=U.length*cv()+2*cw()+"px"}function bD(){bB(W.undone,W.done)}function bC(){bB(W.done,W.undone)}function bB(a,b){var c=a.pop();if(c){var d=[],e=c.start+c.added;for(var f=c.start;f<e;++f)d.push(U[f].text);b.push({start:c.start,added:c.old.length,old:d});var g=ca({line:c.start+c.old.length-1,ch:C(d[d.length-1],c.old[c.old.length-1])});bE({line:c.start,ch:0},{line:e-1,ch:U[e-1].text.length},c.old,g,g)}}function bA(a,b,c,d,e){if(W){var g=[];for(var h=a.line,i=b.line+1;h<i;++h)g.push(U[h].text);W.addChange(a.line,c.length,g);while(W.done.length>f.undoDepth)W.done.shift()}bE(a,b,c,d,e)}function bz(){X&&f.onBlur&&f.onBlur(bp),clearInterval(S),Z=null,X=!1,u.className=u.className.replace(" CodeMirror-focused","")}function by(){f.readOnly!="nocursor"&&(!X&&f.onFocus&&f.onFocus(bp),X=!0,bL(),u.className.search(/\bCodeMirror-focused\b/)==-1&&(u.className+=" CodeMirror-focused"),cA())}function bx(a){if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e))){if(f.electricChars&&T.electricChars){var b=String.fromCharCode(a.e.charCode==null?a.e.keyCode:a.e.charCode);T.electricChars.indexOf(b)>-1&&setTimeout(cK(function(){ci(Y.to.line,"smart")}),50)}var c=a.e.keyCode;c==13?(f.readOnly||cg(),a.stop()):!a.e.ctrlKey&&!a.e.altKey&&!a.e.metaKey&&c==9&&f.tabMode!="default"?a.stop():bM(bi)}}function bw(a){if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e)))$&&($=null,ba=!0),a.e.keyCode==16&&(Z=null)}function bv(a){X||by();var b=a.e.keyCode,c=(s?a.e.metaKey:a.e.ctrlKey)&&!a.e.altKey,d=a.e.ctrlKey||a.e.altKey||a.e.metaKey;b==16||a.e.shiftKey?Z=Z||(Y.inverted?Y.to:Y.from):Z=null;if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e))){if(b==33||b==34){cb(b==34);return a.stop()}if(c&&(b==36||b==35||s&&(b==38||b==40))){cc(b==36||b==38);return a.stop()}if(c&&b==65){cd();return a.stop()}if(!f.readOnly){if(!d&&b==13)return;if(!d&&b==9&&ch(a.e.shiftKey))return a.stop();if(c&&b==90){bC();return a.stop()}if(c&&(a.e.shiftKey&&b==90||b==89)){bD();return a.stop()}}bi=(c?"c":"")+b;if(Y.inverted&&t.hasOwnProperty(bi)){var e=F(B);e&&($={anchor:e.start},G(B,e.start,e.start))}bM(bi)}}function bu(a){var b=cy(a,!0),c=a.e.dataTransfer.files;if(!!b&&!f.readOnly)if(c&&c.length&&window.FileReader&&window.File){var d=c.length,e=Array(d),g=0;for(var h=0;h<d;++h)i(c[h],h);function i(a,c){var f=new FileReader;f.onload=function(){e[c]=f.result,++g==d&&bF(e.join(""),ca(b),ca(b))},f.readAsText(a)}}else try{var e=a.e.dataTransfer.getData("Text");e&&bF(e,b,b)}catch(a){}}function bt(a){var b=cy(a);!b||(ce(b),a.stop(),_=+(new Date))}function bs(a){function i(a){var b=cy(a,!0);if(b&&!y(b,e)){X||by(),e=b,bY(d,b),ba=!1;var c=bS();if(b.line>=c.to||b.line<c.from)g=setTimeout(cK(function(){i(a)}),150)}}function h(){bP(),ba=!0,j(),k()}var b=_;_=null;for(var c=a.target();c!=u;c=c.parentNode)if(c.parentNode==M){f.onGutterClick&&f.onGutterClick(bp,D(M.childNodes,c)+bf);return a.stop()}p&&a.button()==3&&cz(a);if(a.button()==1){var d=cy(a),e=d,g;if(!d){a.target()==H&&a.stop();return}X||by(),a.stop();if(b&&+(new Date)-b<400)return cf(d.line);b$(d.line,d.ch,!0);var j=m(l,"mousemove",cK(function(a){clearTimeout(g),a.stop(),i(a)}),!0),k=m(l,"mouseup",cK(function(a){clearTimeout(g);var b=cy(a);b&&bY(d,b),a.stop(),h()}),!0)}}function br(a){var b=[];for(var c=0,d=U.length;c<d;++c)b.push(U[c].text);return b.join("\n")}function bq(a){W=null;var b={line:0,ch:0};bA(b,{line:U.length-1,ch:U[U.length-1].text.length},E(a),b,b),W=new i}function bo(a){return a>=0&&a<U.length}var f={},h=a.defaults;for(var j in h)h.hasOwnProperty(j)&&(f[j]=(c&&c.hasOwnProperty(j)?c:h)[j]);var l=f.document,u=l.createElement("div");u.className="CodeMirror",u.innerHTML='<div style="overflow: hidden; position: relative; width: 1px; height: 0px;"><textarea style="position: absolute; width: 2px;" wrap="off"></textarea></div><div class="CodeMirror-scroll"><div style="position: relative"><div style="position: absolute; height: 0; width: 0; overflow: hidden;"></div><div style="position: relative"><div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div><div class="CodeMirror-lines"><div style="position: relative"><pre class="CodeMirror-cursor"> </pre><div></div></div></div></div></div></div>',b.appendChild?b.appendChild(u):b(u);var v=u.firstChild,B=v.firstChild,H=u.lastChild,I=H.firstChild,J=I.firstChild,K=J.nextSibling,L=K.firstChild,M=L.firstChild,N=L.nextSibling.firstChild,O=N.firstChild,P=O.nextSibling;f.tabindex!=null&&(B.tabindex=f.tabindex),!f.gutter&&!f.lineNumbers&&(L.style.display="none");var Q=new n,R=new n,S,T,U=[new g("")],V,W=new i,X;cj();var Y={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},Z,$,_,ba,bb,bc,bd,be,bf=0,bg=0,bh=0,bi=null,bj,bk,bl="";cK(function(){bq(f.value||""),ba=!1})(),setTimeout(bO,20),m(H,"mousedown",cK(bs)),p||m(H,"contextmenu",cK(cz)),m(I,"dblclick",cK(bt)),m(H,"scroll",function(){bT([]),f.onScroll&&f.onScroll(bp)}),m(window,"resize",function(){bT(!0)}),m(B,"keyup",cK(bw)),m(B,"keydown",cK(bv)),m(B,"keypress",cK(bx)),m(B,"focus",by),m(B,"blur",bz),m(H,"dragenter",function(a){a.stop()}),m(H,"dragover",function(a){a.stop()}),m(H,"drop",cK(bu)),m(H,"paste",function(){bP(),bM()}),m(B,"paste",function(){bM()}),m(B,"cut",function(){bM()});var bm;try{bm=l.activeElement==B}catch(bn){}bm?by():bz();var bp={getValue:br,setValue:cK(bq),getSelection:bJ,replaceSelection:cK(bG),focus:function(){bP(),by(),bM()},setOption:function(a,b){f[a]=b,a=="lineNumbers"||a=="gutter"?ck():a=="mode"||a=="indentUnit"?cj():a=="readOnly"&&b=="nocursor"&&B.blur()},getOption:function(a){return f[a]},undo:cK(bC),redo:cK(bD),indentLine:cK(function(a){bo(a)&&ci(a,"smart")}),historySize:function(){return{undo:W.done.length,redo:W.undone.length}},matchBrackets:cK(function(){cC(!0)}),getTokenAt:function(a){a=ca(a);return U[a.line].getTokenAt(T,cE(a.line),a.ch)},cursorCoords:function(a){a==null&&(a=Y.inverted);return cu(a?Y.from:Y.to)},charCoords:function(a){return cu(ca(a))},coordsChar:function(a){var b=w(N),c=b_(Math.min(U.length-1,bf+Math.floor((a.y-b.top)/cv())));return ca({line:c,ch:cs(b_(c),a.x-b.left)})},getSearchCursor:function(a,b,c){return new cL(a,b,c)},markText:cK(function(a,b,c){return cK(cl(a,b,c))}),setMarker:cm,clearMarker:cn,setLineClass:cK(co),lineInfo:cp,addWidget:function(a,b,c){var a=ct(ca(a),!0);b.style.top=bf*cv()+a.yBot+cw()+"px",b.style.left=a.x+cx()+"px",I.appendChild(b),c&&bR(a.x,a.yBot,a.x+b.offsetWidth,a.yBot+b.offsetHeight)},lineCount:function(){return U.length},getCursor:function(a){a==null&&(a=Y.inverted);return A(a?Y.from:Y.to)},somethingSelected:function(){return!y(Y.from,Y.to)},setCursor:cK(function(a,b){b==null&&typeof a.line=="number"?b$(a.line,a.ch):b$(a,b)}),setSelection:cK(function(a,b){bZ(ca(a),ca(b||a))}),getLine:function(a){if(bo(a))return U[a].text},setLine:cK(function(a,b){bo(a)&&bF(b,{line:a,ch:0},{line:a,ch:U[a].text.length})}),removeLine:cK(function(a){bo(a)&&bF("",{line:a,ch:0},ca({line:a+1,ch:0}))}),replaceRange:cK(bF),getRange:function(a,b){return bI(ca(a),ca(b))},operation:function(a){return cK(a)()},refresh:function(){bT(!0)},getInputField:function(){return B},getWrapperElement:function(){return u}},bK=!1,cB={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},cJ=0;cL.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function d(a){var c={line:a,ch:0};b.pos={from:c,to:c},b.atOccurrence=!1;return!1}var b=this,c=ca(a?this.pos.from:this.pos.to);for(;;){if(this.pos=this.matches(a,c)){this.atOccurrence=!0;return this.pos.match||!0}if(a){if(!c.line)return d(0);c={line:c.line-1,ch:U[c.line-1].text.length}}else{if(c.line==U.length-1)return d(U.length);c={line:c.line+1,ch:0}}}},from:function(){if(this.atOccurrence)return A(this.pos.from)},to:function(){if(this.atOccurrence)return A(this.pos.to)}};return bp}a.defaults={value:"",mode:null,indentUnit:2,indentWithTabs:!1,tabMode:"classic",enterMode:"indent",electricChars:!0,onKeyEvent:null,lineNumbers:!1,gutter:!1,firstLineNumber:1,readOnly:!1,onChange:null,onCursorActivity:null,onGutterClick:null,onHighlightComplete:null,onFocus:null,onBlur:null,onScroll:null,matchBrackets:!1,workTime:100,workDelay:200,undoDepth:40,tabindex:null,document:window.document};var b={},c={};a.defineMode=function(c,d){!a.defaults.mode&&c!="null"&&(a.defaults.mode=c),b[c]=d},a.defineMIME=function(a,b){c[a]=b},a.getMode=function(d,e){typeof e=="string"&&c.hasOwnProperty(e)&&(e=c[e]);if(typeof e=="string")var f=e,g={};else if(e!=null)var f=e.name,g=e;var h=b[f];if(!h){window.console&&console.warn("No mode "+f+" found, falling back to plain text.");return a.getMode(d,"text/plain")}return h(d,g||{})},a.listModes=function(){var a=[];for(var c in b)b.propertyIsEnumerable(c)&&a.push(c);return a},a.listMIMEs=function(){var a=[];for(var b in c)c.propertyIsEnumerable(b)&&a.push(b);return a},a.fromTextArea=function(b,c){function d(){b.value=h.getValue()}c||(c={}),c.value=b.value,!c.tabindex&&b.tabindex&&(c.tabindex=b.tabindex);if(b.form){var e=m(b.form,"submit",d,!0);if(typeof b.form.submit=="function"){var f=b.form.submit;function g(){d(),b.form.submit=f,b.form.submit(),b.form.submit=g}b.form.submit=g}}b.style.display="none";var h=a(function(a){b.parentNode.insertBefore(a,b.nextSibling)},c);h.save=d,h.toTextArea=function(){d(),b.parentNode.removeChild(h.getWrapperElement()),b.style.display="",b.form&&(e(),typeof b.form.submit=="function"&&(b.form.submit=f))};return h},a.startState=e,a.copyState=d,f.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=this.string.charAt(this.pos);if(typeof a=="string")var c=b==a;else var c=b&&(a.test?a.test(b):a(b));if(c){++this.pos;return b}},eatWhile:function(a){var b=this.start;while(this.eat(a));return this.pos>b},eatSpace:function(){var a=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);if(b>-1){this.pos=b;return!0}},backUp:function(a){this.pos-=a},column:function(){return v(this.string,this.start)},indentation:function(){return v(this.string)},match:function(a,b,c){if(typeof a!="string"){var e=this.string.slice(this.pos).match(a);e&&b!==!1&&(this.pos+=e[0].length);return e}function d(a){return c?a.toLowerCase():a}if(d(this.string).indexOf(d(a),this.pos)==this.pos){b!==!1&&(this.pos+=a.length);return!0}},current:function(){return this.string.slice(this.start,this.pos)}},a.StringStream=f,g.prototype={replace:function(a,b,c){var d=[],e=this.marked;h(0,a,this.styles,d),c&&d.push(c,null),h(b,this.text.length,this.styles,d),this.styles=d,this.text=this.text.slice(0,a)+c+this.text.slice(b),this.stateAfter=null;if(e){var f=c.length-(b-a),g=this.text.length;function i(a){return a<=Math.min(b,b+f)?a:a+f}for(var j=0;j<e.length;++j){var k=e[j],l=!1;k.from>=g?l=!0:(k.from=i(k.from),k.to!=null&&(k.to=i(k.to)));if(l||k.from>=k.to)e.splice(j,1),j--}}},split:function(a,b){var c=[b,null];h(a,this.text.length,this.styles,c);return new g(b+this.text.slice(a),c)},addMark:function(a,b,c){var d=this.marked,e={from:a,to:b,style:c};this.marked==null&&(this.marked=[]),this.marked.push(e),this.marked.sort(function(a,b){return a.from-b.from});return e},removeMark:function(a){var b=this.marked;if(!!b)for(var c=0;c<b.length;++c)if(b[c]==a){b.splice(c,1);break}},highlight:function(a,b){var c=new f(this.text),d=this.styles,e=0,g=!1,h=d[0],i;this.text==""&&a.blankLine&&a.blankLine(b);while(!c.eol()){var j=a.token(c,b),k=this.text.slice(c.start,c.pos);c.start=c.pos,e&&d[e-1]==j?d[e-2]+=k:k&&(!g&&(d[e+1]!=j||e&&d[e-2]!=i)&&(g=!0),d[e++]=k,d[e++]=j,i=h,h=d[e]);if(c.pos>5e3){d[e++]=this.text.slice(c.pos),d[e++]=null;break}}d.length!=e&&(d.length=e,g=!0),e&&d[e-2]!=i&&(g=!0);return g||d.length<5&&this.text.length<10},getTokenAt:function(a,b,c){var d=this.text,e=new f(d);while(e.pos<c&&!e.eol()){e.start=e.pos;var g=a.token(e,b)}return{start:e.start,end:e.pos,string:e.current(),className:g||null,state:b}},indentation:function(){return v(this.text)},getHTML:function(a,b,c,d){function f(a,b){!a||(b?e.push('<span class="',b,'">',B(a),"</span>"):e.push(B(a)))}var e=[];c&&e.push(this.className?'<pre class="'+this.className+'">':"<pre>");var g=this.styles,h=this.text,i=this.marked;a==b&&(a=null);var j=h.length;d!=null&&(j=Math.min(d,j));if(!h&&d==null)f(" ",a!=null&&b==null?"CodeMirror-selected":null);else if(!i&&a==null)for(var k=0,l=0;l<j;k+=2){var m=g[k],n=m.length;l+n>j&&(m=m.slice(0,j-l)),l+=n,f(m,g[k+1])}else{var o=0,k=0,p="",q,r=0,s=-1,t=null;function u(){i&&(s+=1,t=s<i.length?i[s]:null)}u();while(o<j){var v=j,w="";if(a!=null)if(a>o)v=a;else if(b==null||b>o)w=" CodeMirror-selected",b!=null&&(v=Math.min(v,b));while(t&&t.to!=null&&t.to<=o)u();t&&(t.from>o?v=Math.min(v,t.from):(w+=" "+t.style,t.to!=null&&(v=Math.min(v,t.to))));for(;;){var x=o+p.length,y=q;w&&(y=q?q+w:w),f(x>v?p.slice(0,v-o):p,y);if(x>=v){p=p.slice(v-o),o=v;break}o=x,p=g[k++],q=g[k++]}}a!=null&&b==null&&f(" ","CodeMirror-selected")}c&&e.push("</pre>");return e.join("")}},i.prototype={addChange:function(a,b,c){this.undone.length=0;var d=+(new Date),e=this.done[this.done.length-1];if(d-this.time>400||!e||e.start>a+b||e.start+e.added<a-e.added+e.old.length)this.done.push({start:a,added:b,old:c});else{var f=0;if(a<e.start){for(var g=e.start-a-1;g>=0;--g)e.old.unshift(c[g]);e.added+=e.start-a,e.start=a}else e.start<a&&(f=a-e.start,b+=f);for(var g=e.added-f,h=c.length;g<h;++g)e.old.push(c[g]);e.added<b&&(e.added=b)}this.time=d}},l.prototype={stop:function(){j.call(this.e)},target:function(){return this.e.target||this.e.srcElement},button:function(){if(this.e.which)return this.e.which;if(this.e.button&1)return 1;if(this.e.button&2)return 3;if(this.e.button&4)return 2},pageX:function(){if(this.e.pageX!=null)return this.e.pageX;var a=this.target().ownerDocument;return this.e.clientX+a.body.scrollLeft+a.documentElement.scrollLeft},pageY:function(){if(this.e.pageY!=null)return this.e.pageY;var a=this.target().ownerDocument;return this.e.clientY+a.body.scrollTop+a.documentElement.scrollTop}},n.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}};var o=function(){var a=document.createElement("pre");a.innerHTML=" ";return!a.innerHTML}(),p=/gecko\/\d{7}/i.test(navigator.userAgent),q="\n";(function(){var a=document.createElement("textarea");a.value="foo\nbar",a.value.indexOf("\r")>-1&&(q="\r\n")})();var r=8,s=/Mac/.test(navigator.platform),t={};for(var u=35;u<=40;++u)t[u]=t["c"+u]=!0;a.htmlEscape=B;if("\n\nb".split(/\n/).length!=3)var E=function(a){var b=0,c,d=[];while((c=a.indexOf("\n",b))>-1)d.push(a.slice(b,a.charAt(c-1)=="\r"?c-1:c)),b=c+1;d.push(a.slice(b));return d};else var E=function(a){return a.split(/\r?\n/)};a.splitLines=E;if(window.getSelection)var F=function(a){try{return{start:a.selectionStart,end:a.selectionEnd}}catch(b){return null}},G=function(a,b,c){try{a.setSelectionRange(b,c)}catch(d){}};else var F=function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){return null}if(!b||b.parentElement()!=a)return null;var d=a.value,e=d.length,f=a.createTextRange();f.moveToBookmark(b.getBookmark());var g=a.createTextRange();g.collapse(!1);if(f.compareEndPoints("StartToEnd",g)>-1)return{start:e,end:e};var h=-f.moveStart("character",-e);for(var i=d.indexOf("\r");i>-1&&i<h;i=d.indexOf("\r",i+1),h++);if(f.compareEndPoints("EndToEnd",g)>-1)return{start:h,end:e};var j=-f.moveEnd("character",-e);for(var i=d.indexOf("\r");i>-1&&i<j;i=d.indexOf("\r",i+1),j++);return{start:h,end:j}},G=function(a,b,c){var d=a.createTextRange();d.collapse(!0);var e=d.duplicate(),f=0,g=a.value;for(var h=g.indexOf("\n");h>-1&&h<b;h=g.indexOf("\n",h+1))++f;d.move("character",b-f);for(;h>-1&&h<c;h=g.indexOf("\n",h+1))++f;e.move("character",c-f),d.setEndPoint("EndToEnd",e),d.select()};a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");return a}();CodeMirror.overlayParser=function(a,b,c){return{startState:function(){return{base:CodeMirror.startState(a),overlay:CodeMirror.startState(b),basePos:0,baseCur:null,overlayPos:0,overlayCur:null}},copyState:function(c){return{base:CodeMirror.copyState(a,c.base),overlay:CodeMirror.copyState(b,c.overlay),basePos:c.basePos,baseCur:null,overlayPos:c.overlayPos,overlayCur:null}},token:function(d,e){d.start==e.basePos&&(e.baseCur=a.token(d,e.base),e.basePos=d.pos),d.start==e.overlayPos&&(d.pos=d.start,e.overlayCur=b.token(d,e.overlay),e.overlayPos=d.pos),d.pos=Math.min(e.basePos,e.overlayPos),d.eol()&&(e.basePos=e.overlayPos=0);if(e.overlayCur==null)return e.baseCur;return e.baseCur!=null&&c?e.baseCur+" "+e.overlayCur:e.overlayCur},indent:function(b,c){return a.indent(b.base,c)},electricChars:a.electricChars}},CodeMirror.runMode=function(a,b,c){var d=CodeMirror.getMode({indentUnit:2},b),e=c.nodeType==1;if(e){var f=c,g=[];c=function(a,b){a=="\n"?g.push("<br>"):b?g.push('<span class="'+CodeMirror.htmlEscape(b)+'">'+CodeMirror.htmlEscape(a)+"</span>"):g.push(CodeMirror.htmlEscape(a))}}var h=CodeMirror.splitLines(a),i=CodeMirror.startState(d);for(var j=0,k=h.length;j<k;++j){j&&c("\n");var l=new CodeMirror.StringStream(h[j]);while(!l.eol()){var m=d.token(l,i);c(l.current(),m),l.start=l.pos}}e&&(f.innerHTML=g.join(""))},CodeMirror.defineMode("javascript",function(a,b){function R(a,b){if(a=="variable"){v(b);return u()}}function Q(a,b){if(a=="variable"){v(b);return u(Q)}if(a=="(")return u(z(")"),x,I(R,")"),A,C,y)}function P(a){a!=")"&&u(D)}function O(a,b){if(a==";")return u(P);if(b=="in")return u(D);return u(D,B(";"),P)}function N(a,b){if(b=="in")return u(D);return u(E,O)}function M(a){if(a=="var")return u(K,O);if(a==";")return t(O);if(a=="variable")return u(N);return t(O)}function L(a,b){if(b=="=")return u(D,L);if(a==",")return u(K)}function K(a,b){if(a=="variable"){v(b);return u(L)}return u()}function J(a){if(a=="}")return u();return t(C,J)}function I(a,b){function c(d){if(d==",")return u(a,c);if(d==b)return u();return u(B(b))}return function(d){return d==b?u():t(a,c)}}function H(a){a=="variable"&&(s.marked="js-property");if(o.hasOwnProperty(a))return u(B(":"),D)}function G(a){if(a=="variable"){s.marked="js-property";return u()}}function F(a){if(a==":")return u(A,C);return t(E,B(";"),A)}function E(a,b){if(a=="operator"&&/\+\+|--/.test(b))return u(E);if(a=="operator")return u(D);if(a!=";"){if(a=="(")return u(z(")"),I(D,")"),A,E);if(a==".")return u(G,E);if(a=="[")return u(z("]"),D,B("]"),A,E)}}function D(a){if(o.hasOwnProperty(a))return u(E);if(a=="function")return u(Q);if(a=="keyword c")return u(D);if(a=="(")return u(z(")"),D,B(")"),A,E);if(a=="operator")return u(D);if(a=="[")return u(z("]"),I(D,"]"),A,E);if(a=="{")return u(z("}"),I(H,"}"),A,E);return u()}function C(a){if(a=="var")return u(z("vardef"),K,B(";"),A);if(a=="keyword a")return u(z("form"),D,C,A);if(a=="keyword b")return u(z("form"),C,A);if(a=="{")return u(z("}"),J,A);if(a==";")return u();if(a=="function")return u(Q);if(a=="for")return u(z("form"),B("("),z(")"),M,B(")"),A,C,A);if(a=="variable")return u(z("stat"),F);if(a=="switch")return u(z("form"),D,z("}","switch"),B("{"),J,A,A);if(a=="case")return u(D,B(":"));if(a=="default")return u(B(":"));if(a=="catch")return u(z("form"),x,B("("),R,B(")"),C,A,y);return t(z("stat"),D,B(";"),A)}function B(a){return function(b){return b==a?u():a==";"?t():u(arguments.callee)}}function A(){var a=s.state;a.lexical.prev&&(a.lexical.type==")"&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function z(a,b){var c=function(){var c=s.state;c.lexical=new p(c.indented,s.stream.column(),a,null,c.lexical,b)};c.lex=!0;return c}function y(){s.state.localVars=s.state.context.vars,s.state.context=s.state.context.prev}function x(){s.state.context||(s.state.localVars=w),s.state.context={prev:s.state.context,vars:s.state.localVars}}function v(a){var b=s.state;if(b.context){s.marked="js-variabledef";for(var c=b.localVars;c;c=c.next)if(c.name==a)return;b.localVars={name:a,next:b.localVars}}}function u(){t.apply(null,arguments);return!0}function t(){for(var a=arguments.length-1;a>=0;a--)s.cc.push(arguments[a])}function r(a,b,c,e,f){var g=a.cc;s.state=a,s.stream=f,s.marked=null,s.cc=g,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);for(;;){var h=g.length?g.pop():d?D:C;if(h(c,e)){while(g.length&&g[g.length-1].lex)g.pop()();if(s.marked)return s.marked;if(c=="variable"&&q(a,e))return"js-localvariable";return b}}}function q(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0}function p(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,d!=null&&(this.align=d)}function n(a,b){var c=!1,d;while(d=a.next()){if(d=="/"&&c){b.tokenize=l;break}c=d=="*"}return k("comment","js-comment")}function m(a){return function(b,c){h(b,a)||(c.tokenize=l);return k("string","js-string")}}function l(a,b){var c=a.next();if(c=='"'||c=="'")return g(a,b,m(c));if(/[\[\]{}\(\),;\:\.]/.test(c))return k(c);if(c=="0"&&a.eat(/x/i)){a.eatWhile(/[\da-f]/i);return k("number","js-atom")}if(/\d/.test(c)){a.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);return k("number","js-atom")}if(c=="/"){if(a.eat("*"))return g(a,b,n);if(a.eat("/")){a.skipToEnd();return k("comment","js-comment")}if(b.reAllowed){h(a,"/"),a.eatWhile(/[gimy]/);return k("regexp","js-string")}a.eatWhile(f);return k("operator",null,a.current())}if(f.test(c)){a.eatWhile(f);return k("operator",null,a.current())}a.eatWhile(/[\w\$_]/);var d=a.current(),i=e.propertyIsEnumerable(d)&&e[d];return i?k(i.type,i.style,d):k("variable","js-variable",d)}function k(a,b,c){i=a,j=c;return b}function h(a,b){var c=!1,d;while((d=a.next())!=null){if(d==b&&!c)return!1;c=!c&&d=="\\"}return c}function g(a,b,c){b.tokenize=c;return c(a,b)}var c=a.indentUnit,d=b.json,e=function(){function a(a){return{type:a,style:"js-keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"js-atom"};return{"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"var":a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,"undefined":f,NaN:f,Infinity:f}}(),f=/[+\-*&%=<>!?|]/,i,j,o={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},s={state:null,column:null,marked:null,cc:null},w={name:"this",next:{name:"arguments"}};A.lex=!0;return{startState:function(a){return{tokenize:l,reAllowed:!0,cc:[],lexical:new p((a||0)-c,0,"block",!1),localVars:null,context:null,indented:0}},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation());if(a.eatSpace())return null;var c=b.tokenize(a,b);if(i=="comment")return c;b.reAllowed=i=="operator"||i=="keyword c"||i.match(/^[\[{}\(,;:]$/);return r(b,c,i,j,a)},indent:function(a,b){if(a.tokenize!=l)return 0;var d=b&&b.charAt(0),e=a.lexical,f=e.type,g=d==f;return f=="vardef"?e.indented+4:f=="form"&&d=="{"?e.indented:f=="stat"||f=="form"?e.indented+c:e.info=="switch"&&!g?e.indented+(/^(?:case|default)\b/.test(b)?c:2*c):e.align?e.column+(g?0:1):e.indented+(g?0:c)},electricChars:":{}"}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}),CodeMirror.defineMode("xml",function(a,b){function v(a){if(a=="xml-word"&&d.allowUnquoted){m="xml-attribute";return o()}if(a=="xml-attribute")return o();return n()}function u(a){if(a=="xml-word"){m="xml-attname";return o(u)}if(a=="equals")return o(v,u);return n()}function t(a){if(a=="endTag")return o();return n()}function s(a){return function(b){if(b=="selfcloseTag"||b=="endTag"&&d.autoSelfClosers.hasOwnProperty(l.tagName.toLowerCase()))return o();if(b=="endTag"){p(l.tagName,a);return o()}return o()}}function r(a){if(a=="openTag"){l.tagName=f;return o(u,s(l.startOfLine))}if(a=="closeTag"){q();return o(t)}if(a=="xml-cdata"){(!l.context||l.context.name!="!cdata")&&p("!cdata"),l.tokenize==h&&q();return o()}return o()}function q(){l.context&&(l.context=l.context.prev)}function p(a,b){var c=d.doNotIndent.hasOwnProperty(a)||l.context&&l.context.noIndent;l.context={prev:l.context,tagName:a,indent:l.indented,startOfLine:b,noIndent:c}}function o(){n.apply(null,arguments);return!0}function n(){for(var a=arguments.length-1;a>=0;a--)l.cc.push(arguments[a])}function k(a,b){return function(c,d){while(!c.eol()){if(c.match(b)){d.tokenize=h;break}c.next()}return a}}function j(a){return function(b,c){while(!b.eol())if(b.next()==a){c.tokenize=i;break}return"xml-attribute"}}function i(a,b){var c=a.next();if(c==">"||c=="/"&&a.eat(">")){b.tokenize=h,g=c==">"?"endTag":"selfcloseTag";return"xml-tag"}if(c=="="){g="equals";return null}if(/[\'\"]/.test(c)){b.tokenize=j(c);return b.tokenize(a,b)}a.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);return"xml-word"}function h(a,b){function c(c){b.tokenize=c;return c(a,b)}var d=a.next();if(d=="<"){if(a.eat("!")){if(a.eat("["))return a.match("CDATA[")?c(k("xml-cdata","]]>")):null;if(a.match("--"))return c(k("xml-comment","-->"));if(a.match("DOCTYPE")){a.eatWhile(/[\w\._\-]/);return c(k("xml-doctype",">"))}return null}if(a.eat("?")){a.eatWhile(/[\w\._\-]/),b.tokenize=k("xml-processing","?>");return"xml-processing"}g=a.eat("/")?"closeTag":"openTag",a.eatSpace(),f="";var e;while(e=a.eat(/[^\s\u00a0=<>\"\'\/?]/))f+=e;b.tokenize=i;return"xml-tag"}if(d=="&"){a.eatWhile(/[^;]/),a.eat(";");return"xml-entity"}a.eatWhile(/[^&<]/);return null}var c=a.indentUnit,d=b.htmlMode?{autoSelfClosers:{br:!0,img:!0,hr:!0,link:!0,input:!0,meta:!0,col:!0,frame:!0,base:!0,area:!0},doNotIndent:{pre:!0,"!cdata":!0},allowUnquoted:!0}:{autoSelfClosers:{},doNotIndent:{"!cdata":!0},allowUnquoted:!1},e=b.alignCDATA,f,g,l,m;return{startState:function(){return{tokenize:h,cc:[],indented:0,startOfLine:!0,tagName:null,context:null}},token:function(a,b){a.sol()&&(b.startOfLine=!0,b.indented=a.indentation());if(a.eatSpace())return null;m=g=f=null;var c=b.tokenize(a,b);if((c||g)&&c!="xml-comment"){l=b;for(;;){var d=b.cc.pop()||r;if(d(g||c))break}}b.startOfLine=!1;return m||c},indent:function(a,b){var d=a.context;if(d&&d.noIndent)return 0;if(e&&/<!\[CDATA\[/.test(b))return 0;d&&/^<\//.test(b)&&(d=d.prev);while(d&&!d.startOfLine)d=d.prev;return d?d.indent+c:0},electricChars:"/"}}),CodeMirror.defineMIME("application/xml","xml"),CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0}),CodeMirror.defineMode("css",function(a){function h(a){return function(b,c){var f=!1,g;while((g=b.next())!=null){if(g==a&&!f)break;f=!f&&g=="\\"}f||(c.tokenize=e);return d("css-string","string")}}function g(a,b){var c=0,f;while((f=a.next())!=null){if(c>=2&&f==">"){b.tokenize=e;break}c=f=="-"?c+1:0}return d("css-comment","comment")}function f(a,b){var c=!1,f;while((f=a.next())!=null){if(c&&f=="/"){b.tokenize=e;break}c=f=="*"}return d("css-comment","comment")}function e(a,b){var c=a.next();if(c=="@"){a.eatWhile(/\w/);return d("css-at",a.current())}if(c=="/"&&a.eat("*")){b.tokenize=f;return f(a,b)}if(c=="<"&&a.eat("!")){b.tokenize=g;return g(a,b)}if(c=="=")d(null,"compare");else{if(c!="~"&&c!="|"||!a.eat("=")){if(c=='"'||c=="'"){b.tokenize=h(c);return b.tokenize(a,b)}if(c=="#"){a.eatWhile(/\w/);return d("css-selector","hash")}if(c=="!"){a.match(/^\s*\w*/);return d("css-important","important")}if(/\d/.test(c)){a.eatWhile(/[\w.%]/);return d("css-unit","unit")}if(/[,.+>*\/]/.test(c))return d(null,"select-op");if(/[;{}:\[\]]/.test(c))return d(null,c);a.eatWhile(/[\w\\\-_]/);return d("css-identifier","identifier")}return d(null,"compare")}}function d(a,b){c=b;return a}var b=a.indentUnit,c;return{startState:function(a){return{tokenize:e,baseIndent:a||0,stack:[]}},token:function(a,b){if(a.eatSpace())return null;var d=b.tokenize(a,b),e=b.stack[b.stack.length-1];if(c=="hash"&&e=="rule")d="css-colorcode";else if(d=="css-identifier")if(e=="rule")d="css-value";else if(!e||e=="@media{")d="css-selector";e=="rule"&&/^[\{\};]$/.test(c)&&b.stack.pop(),c=="{"?e=="@media"?b.stack[b.stack.length-1]="@media{":b.stack.push("{"):c=="}"?b.stack.pop():c=="@media"?b.stack.push("@media"):e!="rule"&&e!="@media"&&c!="comment"&&b.stack.push("rule");return d},indent:function(a,c){var d=a.stack.length;/^\}/.test(c)&&(d-=a.stack[a.stack.length-1]=="rule"?2:1);return a.baseIndent+d*b},electricChars:"}"}}),CodeMirror.defineMIME("text/css","css"),CodeMirror.defineMode("htmlmixed",function(a,b){function i(a,b){if(a.match(/^<\/\s*style\s*>/i,!1)){b.token=f,b.localState=null;return f(a,b)}return g(a,/<\/\s*style\s*>/,e.token(a,b.localState))}function h(a,b){if(a.match(/^<\/\s*script\s*>/i,!1)){b.token=f,b.curState=null;return f(a,b)}return g(a,/<\/\s*script\s*>/,d.token(a,b.localState))}function g(a,b,c){var d=a.current(),e=d.search(b);e>-1&&a.backUp(d.length-e);return c}function f(a,b){var f=c.token(a,b.htmlState);f=="xml-tag"&&a.current()==">"&&b.htmlState.context&&(/^script$/i.test(b.htmlState.context.tagName)?(b.token=h,b.localState=d.startState(c.indent(b.htmlState,""))):/^style$/i.test(b.htmlState.context.tagName)&&(b.token=i,b.localState=e.startState(c.indent(b.htmlState,""))));return f}var c=CodeMirror.getMode(a,{name:"xml",htmlMode:!0}),d=CodeMirror.getMode(a,"javascript"),e=CodeMirror.getMode(a,"css");return{startState:function(){var a=c.startState();return{token:f,localState:null,htmlState:a}},copyState:function(a){if(a.localState)var b=CodeMirror.copyState(a.token==i?e:d,a.localState);return{token:a.token,localState:b,htmlState:CodeMirror.copyState(c,a.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(a,b){return a.token==f||/^\s*<\//.test(b)?c.indent(a.htmlState,b):a.token==h?d.indent(a.localState,b):e.indent(a.localState,b)},electricChars:"/{}:"}}),CodeMirror.defineMIME("text/html","htmlmixed") |
| \ No newline at end of file | |
app/assets/javascripts/comfortable_mexican_sofa/plupload/plupload.html5.js
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | (function(g,j,h,d){var f;if(g.Uint8Array&&g.ArrayBuffer&&!XMLHttpRequest.prototype.sendAsBinary){XMLHttpRequest.prototype.sendAsBinary=function(o){var m=new Uint8Array(o.length);for(var n=0;n<o.length;n++){m[n]=(o.charCodeAt(n)&255)}this.send(m.buffer)}}function l(n,o){var m;if("FileReader" in g){m=new FileReader();m.readAsDataURL(n);m.onload=function(){o(m.result)}}else{return o(n.getAsDataURL())}}function k(n,o){var m;if("FileReader" in g){m=new FileReader();m.readAsBinaryString(n);m.onload=function(){o(m.result)}}else{return o(n.getAsBinary())}}function c(q,o,r,t){var n,p,m,s;l(q,function(u){n=j.createElement("canvas");n.style.display="none";j.body.appendChild(n);p=n.getContext("2d");m=new Image();m.onerror=m.onabort=function(){t({success:false})};m.onload=function(){var z,v,x,w,y;if(!o.width){o.width=m.width}if(!o.height){o.height=m.height}s=Math.min(o.width/m.width,o.height/m.height);if(s<1||(s===1&&r==="image/jpeg")){z=Math.round(m.width*s);v=Math.round(m.height*s);n.width=z;n.height=v;p.drawImage(m,0,0,z,v);if(r==="image/jpeg"){w=new e(atob(u.substring(u.indexOf("base64,")+7)));if(w.headers&&w.headers.length){y=new a();if(y.init(w.get("exif")[0])){y.setExif("PixelXDimension",z);y.setExif("PixelYDimension",v);w.set("exif",y.getBinary())}}if(o.quality){try{u=n.toDataURL(r,o.quality/100)}catch(A){u=n.toDataURL(r)}}}else{u=n.toDataURL(r)}u=u.substring(u.indexOf("base64,")+7);u=atob(u);if(w.headers&&w.headers.length){u=w.restore(u);w.purge()}n.parentNode.removeChild(n);t({success:true,data:u})}else{t({success:false})}};m.src=u})}h.runtimes.Html5=h.addRuntime("html5",{getFeatures:function(){var r,n,q,o,m,p=g;n=q=o=m=false;if(p.XMLHttpRequest){r=new XMLHttpRequest();q=!!r.upload;n=!!(r.sendAsBinary||r.upload)}if(n){o=!!(File&&(File.prototype.getAsDataURL||p.FileReader)&&r.sendAsBinary);m=!!(File&&File.prototype.slice)}f=navigator.userAgent.indexOf("Safari")>0&&navigator.vendor.indexOf("Apple")!==-1;return{html5:n,dragdrop:p.mozInnerScreenX!==d||m||f,jpgresize:o,pngresize:o,multipart:o||!!p.FileReader||!!p.FormData,progress:q,chunks:m||o,canOpenDialog:navigator.userAgent.indexOf("WebKit")!==-1}},init:function(p,q){var m={},n;function o(v){var t,s,u=[],w,r={};for(s=0;s<v.length;s++){t=v[s];if(r[t.name]){continue}r[t.name]=true;w=h.guid();m[w]=t;u.push(new h.File(w,t.fileName,t.fileSize||t.size))}if(u.length){p.trigger("FilesAdded",u)}}n=this.getFeatures();if(!n.html5){q({success:false});return}p.bind("Init",function(v){var F,E,B=[],u,C,s=v.settings.filters,t,A,r=j.body,D;F=j.createElement("div");F.id=v.id+"_html5_container";h.extend(F.style,{position:"absolute",background:p.settings.shim_bgcolor||"transparent",width:"100px",height:"100px",overflow:"hidden",zIndex:99999,opacity:p.settings.shim_bgcolor?"":0});F.className="plupload html5";if(p.settings.container){r=j.getElementById(p.settings.container);if(h.getStyle(r,"position")==="static"){r.style.position="relative"}}r.appendChild(F);no_type_restriction:for(u=0;u<s.length;u++){t=s[u].extensions.split(/,/);for(C=0;C<t.length;C++){if(t[C]==="*"){B=[];break no_type_restriction}A=h.mimeTypes[t[C]];if(A){B.push(A)}}}F.innerHTML='<input id="'+p.id+'_html5" style="width:100%;height:100%;font-size:99px" type="file" accept="'+B.join(",")+'" '+(p.settings.multi_selection?'multiple="multiple"':"")+" />";D=j.getElementById(p.id+"_html5");D.onchange=function(){o(this.files);this.value=""};E=j.getElementById(v.settings.browse_button);if(E){var x=v.settings.browse_button_hover,z=v.settings.browse_button_active,w=v.features.canOpenDialog?E:F;if(x){h.addEvent(w,"mouseover",function(){h.addClass(E,x)},v.id);h.addEvent(w,"mouseout",function(){h.removeClass(E,x)},v.id)}if(z){h.addEvent(w,"mousedown",function(){h.addClass(E,z)},v.id);h.addEvent(j.body,"mouseup",function(){h.removeClass(E,z)},v.id)}if(v.features.canOpenDialog){h.addEvent(E,"click",function(y){j.getElementById(v.id+"_html5").click();y.preventDefault()},v.id)}}});p.bind("PostInit",function(){var r=j.getElementById(p.settings.drop_element);if(r){if(f){h.addEvent(r,"dragenter",function(v){var u,s,t;u=j.getElementById(p.id+"_drop");if(!u){u=j.createElement("input");u.setAttribute("type","file");u.setAttribute("id",p.id+"_drop");u.setAttribute("multiple","multiple");h.addEvent(u,"change",function(){o(this.files);h.removeEvent(u,"change",p.id);u.parentNode.removeChild(u)},p.id);r.appendChild(u)}s=h.getPos(r,j.getElementById(p.settings.container));t=h.getSize(r);if(h.getStyle(r,"position")==="static"){h.extend(r.style,{position:"relative"})}h.extend(u.style,{position:"absolute",display:"block",top:0,left:0,width:t.w+"px",height:t.h+"px",opacity:0})},p.id);return}h.addEvent(r,"dragover",function(s){s.preventDefault()},p.id);h.addEvent(r,"drop",function(t){var s=t.dataTransfer;if(s&&s.files){o(s.files)}t.preventDefault()},p.id)}});p.bind("Refresh",function(r){var s,u,v,w,t;s=j.getElementById(p.settings.browse_button);if(s){u=h.getPos(s,j.getElementById(r.settings.container));v=h.getSize(s);w=j.getElementById(p.id+"_html5_container");h.extend(w.style,{top:u.y+"px",left:u.x+"px",width:v.w+"px",height:v.h+"px"});if(p.features.canOpenDialog){t=parseInt(s.parentNode.style.zIndex,10);if(isNaN(t)){t=0}h.extend(s.style,{zIndex:t});if(h.getStyle(s,"position")==="static"){h.extend(s.style,{position:"relative"})}h.extend(w.style,{zIndex:t-1})}}});p.bind("UploadFile",function(r,t){var u=r.settings,w,s;function v(x){var A=0,z=0;function y(){var H=x,O,P,K,L,M=0,D="----pluploadboundary"+h.guid(),G,I,E,F="--",N="\r\n",J="",C,B=r.settings.url;if(t.status==h.DONE||t.status==h.FAILED||r.state==h.STOPPED){return}L={name:t.target_name||t.name};if(u.chunk_size&&n.chunks){G=u.chunk_size;K=Math.ceil(t.size/G);I=Math.min(G,t.size-(A*G));if(typeof(x)=="string"){H=x.substring(A*G,A*G+I)}else{H=x.slice(A*G,I)}L.chunk=A;L.chunks=K}else{I=t.size}O=new XMLHttpRequest();P=O.upload;if(P){P.onprogress=function(Q){t.loaded=Math.min(t.size,z+Q.loaded-M);r.trigger("UploadProgress",t)}}if(!r.settings.multipart||!n.multipart){B=h.buildUrl(r.settings.url,L)}else{L.name=t.target_name||t.name}O.open("post",B,true);O.onreadystatechange=function(){var Q,S;if(O.readyState==4){try{Q=O.status}catch(R){Q=0}if(Q>=400){r.trigger("Error",{code:h.HTTP_ERROR,message:h.translate("HTTP Error."),file:t,status:Q})}else{if(K){S={chunk:A,chunks:K,response:O.responseText,status:Q};r.trigger("ChunkUploaded",t,S);z+=I;if(S.cancelled){t.status=h.FAILED;return}t.loaded=Math.min(t.size,(A+1)*G)}else{t.loaded=t.size}r.trigger("UploadProgress",t);if(!K||++A>=K){t.status=h.DONE;r.trigger("FileUploaded",t,{response:O.responseText,status:Q});w=x=m[t.id]=null}else{y()}}O=H=E=J=null}};h.each(r.settings.headers,function(R,Q){O.setRequestHeader(Q,R)});if(r.settings.multipart&&n.multipart){if(!O.sendAsBinary){E=new FormData();h.each(h.extend(L,r.settings.multipart_params),function(R,Q){E.append(Q,R)});E.append(r.settings.file_data_name,H);O.send(E);return}O.setRequestHeader("Content-Type","multipart/form-data; boundary="+D);h.each(h.extend(L,r.settings.multipart_params),function(R,Q){J+=F+D+N+'Content-Disposition: form-data; name="'+Q+'"'+N+N;J+=unescape(encodeURIComponent(R))+N});C=h.mimeTypes[t.name.replace(/^.+\.([^.]+)/,"$1").toLowerCase()]||"application/octet-stream";J+=F+D+N+'Content-Disposition: form-data; name="'+r.settings.file_data_name+'"; filename="'+unescape(encodeURIComponent(t.name))+'"'+N+"Content-Type: "+C+N+N+H+N+F+D+F+N;M=J.length-H.length;H=J}else{O.setRequestHeader("Content-Type","application/octet-stream")}if(O.sendAsBinary){O.sendAsBinary(H)}else{O.send(H)}}y()}w=m[t.id];s=r.settings.resize;if(n.jpgresize){if(s&&/\.(png|jpg|jpeg)$/i.test(t.name)){c(w,s,/\.png$/i.test(t.name)?"image/png":"image/jpeg",function(x){if(x.success){t.size=x.data.length;v(x.data)}else{k(w,v)}})}else{k(w,v)}}else{v(w)}});p.bind("Destroy",function(r){var t,u,s=j.body,v={inputContainer:r.id+"_html5_container",inputFile:r.id+"_html5",browseButton:r.settings.browse_button,dropElm:r.settings.drop_element};for(t in v){u=j.getElementById(v[t]);if(u){h.removeAllEvents(u,r.id)}}h.removeAllEvents(j.body,r.id);if(r.settings.container){s=j.getElementById(r.settings.container)}s.removeChild(j.getElementById(v.inputContainer))});q({success:true})}});function b(){var p=false,n;function q(s,u){var r=p?0:-8*(u-1),v=0,t;for(t=0;t<u;t++){v|=(n.charCodeAt(s+t)<<Math.abs(r+t*8))}return v}function m(t,r,s){var s=arguments.length===3?s:n.length-r-1;n=n.substr(0,r)+t+n.substr(s+r)}function o(s,t,v){var w="",r=p?0:-8*(v-1),u;for(u=0;u<v;u++){w+=String.fromCharCode((t>>Math.abs(r+u*8))&255)}m(w,s,v)}return{II:function(r){if(r===d){return p}else{p=r}},init:function(r){p=false;n=r},SEGMENT:function(r,t,s){switch(arguments.length){case 1:return n.substr(r,n.length-r-1);case 2:return n.substr(r,t);case 3:m(s,r,t);break;default:return n}},BYTE:function(r){return q(r,1)},SHORT:function(r){return q(r,2)},LONG:function(r,s){if(s===d){return q(r,4)}else{o(r,s,4)}},SLONG:function(r){var s=q(r,4);return(s>2147483647?s-4294967296:s)},STRING:function(r,s){var t="";for(s+=r;r<s;r++){t+=String.fromCharCode(q(r,1))}return t}}}function e(r){var t={65505:{app:"EXIF",name:"APP1",signature:"Exif\0"},65506:{app:"ICC",name:"APP2",signature:"ICC_PROFILE\0"},65517:{app:"IPTC",name:"APP13",signature:"Photoshop 3.0\0"}},s=[],q,m,o=d,p=0,n;q=new b();q.init(r);if(q.SHORT(0)!==65496){return}m=2;n=Math.min(1048576,r.length);while(m<=n){o=q.SHORT(m);if(o>=65488&&o<=65495){m+=2;continue}if(o===65498||o===65497){break}p=q.SHORT(m+2)+2;if(t[o]&&q.STRING(m+4,t[o].signature.length)===t[o].signature){s.push({hex:o,app:t[o].app.toUpperCase(),name:t[o].name.toUpperCase(),start:m,length:p,segment:q.SEGMENT(m,p)})}m+=p}q.init(null);return{headers:s,restore:function(w){q.init(w);if(q.SHORT(0)!==65496){return false}m=q.SHORT(2)==65504?4+q.SHORT(4):2;for(var v=0,u=s.length;v<u;v++){q.SEGMENT(m,0,s[v].segment);m+=s[v].length}return q.SEGMENT()},get:function(w){var x=[];for(var v=0,u=s.length;v<u;v++){if(s[v].app===w.toUpperCase()){x.push(s[v].segment)}}return x},set:function(x,w){var y=[];if(typeof(w)==="string"){y.push(w)}else{y=w}for(var v=ii=0,u=s.length;v<u;v++){if(s[v].app===x.toUpperCase()){s[v].segment=y[ii];s[v].length=y[ii].length;ii++}if(ii>=y.length){break}}},purge:function(){s=[];q.init(null)}}}function a(){var p,m,n={},s;p=new b();m={tiff:{274:"Orientation",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"}};s={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire.",1:"Flash fired.",5:"Strobe return light not detected.",7:"Strobe return light detected.",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}};function o(t,B){var v=p.SHORT(t),y,E,F,A,z,u,w,C,D=[],x={};for(y=0;y<v;y++){w=u=t+12*y+2;F=B[p.SHORT(w)];if(F===d){continue}A=p.SHORT(w+=2);z=p.LONG(w+=2);w+=4;D=[];switch(A){case 1:case 7:if(z>4){w=p.LONG(w)+n.tiffHeader}for(E=0;E<z;E++){D[E]=p.BYTE(w+E)}break;case 2:if(z>4){w=p.LONG(w)+n.tiffHeader}x[F]=p.STRING(w,z-1);continue;case 3:if(z>2){w=p.LONG(w)+n.tiffHeader}for(E=0;E<z;E++){D[E]=p.SHORT(w+E*2)}break;case 4:if(z>1){w=p.LONG(w)+n.tiffHeader}for(E=0;E<z;E++){D[E]=p.LONG(w+E*4)}break;case 5:w=p.LONG(w)+n.tiffHeader;for(E=0;E<z;E++){D[E]=p.LONG(w+E*4)/p.LONG(w+E*4+4)}break;case 9:w=p.LONG(w)+n.tiffHeader;for(E=0;E<z;E++){D[E]=p.SLONG(w+E*4)}break;case 10:w=p.LONG(w)+n.tiffHeader;for(E=0;E<z;E++){D[E]=p.SLONG(w+E*4)/p.SLONG(w+E*4+4)}break;default:continue}C=(z==1?D[0]:D);if(s.hasOwnProperty(F)&&typeof C!="object"){x[F]=s[F][C]}else{x[F]=C}}return x}function r(){var u=d,t=n.tiffHeader;p.II(p.SHORT(t)==18761);if(p.SHORT(t+=2)!==42){return false}n.IFD0=n.tiffHeader+p.LONG(t+=2);u=o(n.IFD0,m.tiff);n.exifIFD=("ExifIFDPointer" in u?n.tiffHeader+u.ExifIFDPointer:d);n.gpsIFD=("GPSInfoIFDPointer" in u?n.tiffHeader+u.GPSInfoIFDPointer:d);return true}function q(v,t,y){var A,x,w,z=0;if(typeof(t)==="string"){var u=m[v.toLowerCase()];for(hex in u){if(u[hex]===t){t=hex;break}}}A=n[v.toLowerCase()+"IFD"];x=p.SHORT(A);for(i=0;i<x;i++){w=A+12*i+2;if(p.SHORT(w)==t){z=w+8;break}}if(!z){return false}p.LONG(z,y);return true}return{init:function(t){n={tiffHeader:10};if(t===d||!t.length){return false}p.init(t);if(p.SHORT(0)===65505&&p.STRING(4,5).toUpperCase()==="EXIF\0"){return r()}return false},EXIF:function(){var t;t=o(n.exifIFD,m.exif);t.ExifVersion=String.fromCharCode(t.ExifVersion[0],t.ExifVersion[1],t.ExifVersion[2],t.ExifVersion[3]);return t},GPS:function(){var t;t=o(n.gpsIFD,m.gps);t.GPSVersionID=t.GPSVersionID.join(".");return t},setExif:function(t,u){if(t!=="PixelXDimension"&&t!=="PixelYDimension"){return false}return q("exif",t,u)},getBinary:function(){return p.SEGMENT()}}}})(window,document,plupload); |
| \ No newline at end of file | |
app/assets/javascripts/comfortable_mexican_sofa/plupload/plupload.js
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | /*1.4.3.2*/ |
| + | (function(){var f=0,k=[],m={},i={},a={"<":"lt",">":"gt","&":"amp",'"':"quot","'":"#39"},l=/[<>&\"\']/g,b,c=window.setTimeout,d={},e;function h(){this.returnValue=false}function j(){this.cancelBubble=true}(function(n){var o=n.split(/,/),p,r,q;for(p=0;p<o.length;p+=2){q=o[p+1].split(/ /);for(r=0;r<q.length;r++){i[q[r]]=o[p]}}})("application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb,application/vnd.ms-powerpoint,ppt pps pot,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats,docx pptx xlsx,audio/mpeg,mpga mpega mp2 mp3,audio/x-wav,wav,audio/mp4,m4a,image/bmp,bmp,image/gif,gif,image/jpeg,jpeg jpg jpe,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/html,htm html xhtml,text/rtf,rtf,video/mpeg,mpeg mpg mpe,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/vnd.rn-realvideo,rv,text/plain,asc txt text diff log,application/octet-stream,exe");var g={VERSION:"1.4.3.2",STOPPED:1,STARTED:2,QUEUED:1,UPLOADING:2,FAILED:4,DONE:5,GENERIC_ERROR:-100,HTTP_ERROR:-200,IO_ERROR:-300,SECURITY_ERROR:-400,INIT_ERROR:-500,FILE_SIZE_ERROR:-600,FILE_EXTENSION_ERROR:-601,IMAGE_FORMAT_ERROR:-700,IMAGE_MEMORY_ERROR:-701,IMAGE_DIMENSIONS_ERROR:-702,mimeTypes:i,extend:function(n){g.each(arguments,function(o,p){if(p>0){g.each(o,function(r,q){n[q]=r})}});return n},cleanName:function(n){var o,p;p=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"];for(o=0;o<p.length;o+=2){n=n.replace(p[o],p[o+1])}n=n.replace(/\s+/g,"_");n=n.replace(/[^a-z0-9_\-\.]+/gi,"");return n},addRuntime:function(n,o){o.name=n;k[n]=o;k.push(o);return o},guid:function(){var n=new Date().getTime().toString(32),o;for(o=0;o<5;o++){n+=Math.floor(Math.random()*65535).toString(32)}return(g.guidPrefix||"p")+n+(f++).toString(32)},buildUrl:function(o,n){var p="";g.each(n,function(r,q){p+=(p?"&":"")+encodeURIComponent(q)+"="+encodeURIComponent(r)});if(p){o+=(o.indexOf("?")>0?"&":"?")+p}return o},each:function(q,r){var p,o,n;if(q){p=q.length;if(p===b){for(o in q){if(q.hasOwnProperty(o)){if(r(q[o],o)===false){return}}}}else{for(n=0;n<p;n++){if(r(q[n],n)===false){return}}}}},formatSize:function(n){if(n===b||/\D/.test(n)){return g.translate("N/A")}if(n>1073741824){return Math.round(n/1073741824,1)+" GB"}if(n>1048576){return Math.round(n/1048576,1)+" MB"}if(n>1024){return Math.round(n/1024,1)+" KB"}return n+" b"},getPos:function(o,s){var t=0,r=0,v,u=document,p,q;o=o;s=s||u.body;function n(B){var z,A,w=0,C=0;if(B){A=B.getBoundingClientRect();z=u.compatMode==="CSS1Compat"?u.documentElement:u.body;w=A.left+z.scrollLeft;C=A.top+z.scrollTop}return{x:w,y:C}}if(o&&o.getBoundingClientRect&&(navigator.userAgent.indexOf("MSIE")>0&&u.documentMode!==8)){p=n(o);q=n(s);return{x:p.x-q.x,y:p.y-q.y}}v=o;while(v&&v!=s&&v.nodeType){t+=v.offsetLeft||0;r+=v.offsetTop||0;v=v.offsetParent}v=o.parentNode;while(v&&v!=s&&v.nodeType){t-=v.scrollLeft||0;r-=v.scrollTop||0;v=v.parentNode}return{x:t,y:r}},getSize:function(n){return{w:n.offsetWidth||n.clientWidth,h:n.offsetHeight||n.clientHeight}},parseSize:function(n){var o;if(typeof(n)=="string"){n=/^([0-9]+)([mgk]+)$/.exec(n.toLowerCase().replace(/[^0-9mkg]/g,""));o=n[2];n=+n[1];if(o=="g"){n*=1073741824}if(o=="m"){n*=1048576}if(o=="k"){n*=1024}}return n},xmlEncode:function(n){return n?(""+n).replace(l,function(o){return a[o]?"&"+a[o]+";":o}):n},toArray:function(p){var o,n=[];for(o=0;o<p.length;o++){n[o]=p[o]}return n},addI18n:function(n){return g.extend(m,n)},translate:function(n){return m[n]||n},isEmptyObj:function(n){if(n===b){return true}for(var o in n){return false}return true},hasClass:function(p,o){var n;if(p.className==""){return false}n=new RegExp("(^|\\s+)"+o+"(\\s+|$)");return n.test(p.className)},addClass:function(o,n){if(!g.hasClass(o,n)){o.className=o.className==""?n:o.className.replace(/\s+$/,"")+" "+n}},removeClass:function(p,o){var n=new RegExp("(^|\\s+)"+o+"(\\s+|$)");p.className=p.className.replace(n,function(r,q,s){return q===" "&&s===" "?" ":""})},getStyle:function(o,n){if(o.currentStyle){return o.currentStyle[n]}else{if(window.getComputedStyle){return window.getComputedStyle(o,null)[n]}}},addEvent:function(s,n,t){var r,q,p,o;o=arguments[3];n=n.toLowerCase();if(e===b){e="Plupload_"+g.guid()}if(s.attachEvent){r=function(){var u=window.event;if(!u.target){u.target=u.srcElement}u.preventDefault=h;u.stopPropagation=j;t(u)};s.attachEvent("on"+n,r)}else{if(s.addEventListener){r=t;s.addEventListener(n,r,false)}}if(s[e]===b){s[e]=g.guid()}if(!d.hasOwnProperty(s[e])){d[s[e]]={}}q=d[s[e]];if(!q.hasOwnProperty(n)){q[n]=[]}q[n].push({func:r,orig:t,key:o})},removeEvent:function(s,n){var q,t,p;if(typeof(arguments[2])=="function"){t=arguments[2]}else{p=arguments[2]}n=n.toLowerCase();if(s[e]&&d[s[e]]&&d[s[e]][n]){q=d[s[e]][n]}else{return}for(var o=q.length-1;o>=0;o--){if(q[o].key===p||q[o].orig===t){if(s.detachEvent){s.detachEvent("on"+n,q[o].func)}else{if(s.removeEventListener){s.removeEventListener(n,q[o].func,false)}}q[o].orig=null;q[o].func=null;q.splice(o,1);if(t!==b){break}}}if(!q.length){delete d[s[e]][n]}if(g.isEmptyObj(d[s[e]])){delete d[s[e]];try{delete s[e]}catch(r){s[e]=b}}},removeAllEvents:function(o){var n=arguments[1];if(o[e]===b||!o[e]){return}g.each(d[o[e]],function(q,p){g.removeEvent(o,p,n)})}};g.Uploader=function(q){var o={},t,s=[],p;t=new g.QueueProgress();q=g.extend({chunk_size:0,multipart:true,multi_selection:true,file_data_name:"file",filters:[]},q);function r(){var v,w=0,u;if(this.state==g.STARTED){for(u=0;u<s.length;u++){if(!v&&s[u].status==g.QUEUED){v=s[u];v.status=g.UPLOADING;this.trigger("BeforeUpload",v);this.trigger("UploadFile",v)}else{w++}}if(w==s.length){this.trigger("UploadComplete",s);this.stop()}}}function n(){var v,u;t.reset();for(v=0;v<s.length;v++){u=s[v];if(u.size!==b){t.size+=u.size;t.loaded+=u.loaded}else{t.size=b}if(u.status==g.DONE){t.uploaded++}else{if(u.status==g.FAILED){t.failed++}else{t.queued++}}}if(t.size===b){t.percent=s.length>0?Math.ceil(t.uploaded/s.length*100):0}else{t.bytesPerSec=Math.ceil(t.loaded/((+new Date()-p||1)/1000));t.percent=t.size>0?Math.ceil(t.loaded/t.size*100):0}}g.extend(this,{state:g.STOPPED,runtime:"",features:{},files:s,settings:q,total:t,id:g.guid(),init:function(){var z=this,A,w,v,y=0,x;if(typeof(q.preinit)=="function"){q.preinit(z)}else{g.each(q.preinit,function(C,B){z.bind(B,C)})}q.page_url=q.page_url||document.location.pathname.replace(/\/[^\/]+$/g,"/");if(!/^(\w+:\/\/|\/)/.test(q.url)){q.url=q.page_url+q.url}q.chunk_size=g.parseSize(q.chunk_size);q.max_file_size=g.parseSize(q.max_file_size);z.bind("FilesAdded",function(B,E){var D,C,G=0,H,F=q.filters;if(F&&F.length){H=[];g.each(F,function(I){g.each(I.extensions.split(/,/),function(J){if(/^\s*\*\s*$/.test(J)){H.push("\\.*")}else{H.push("\\."+J.replace(new RegExp("["+("/^$.*+?|()[]{}\\".replace(/./g,"\\$&"))+"]","g"),"\\$&"))}})});H=new RegExp(H.join("|")+"$","i")}for(D=0;D<E.length;D++){C=E[D];C.loaded=0;C.percent=0;C.status=g.QUEUED;if(H&&!H.test(C.name)){B.trigger("Error",{code:g.FILE_EXTENSION_ERROR,message:g.translate("File extension error."),file:C});continue}if(C.size!==b&&C.size>q.max_file_size){B.trigger("Error",{code:g.FILE_SIZE_ERROR,message:g.translate("File size error."),file:C});continue}s.push(C);G++}if(G){c(function(){z.trigger("QueueChanged");z.refresh()},1)}else{return false}});if(q.unique_names){z.bind("UploadFile",function(B,C){var E=C.name.match(/\.([^.]+)$/),D="tmp";if(E){D=E[1]}C.target_name=C.id+"."+D})}z.bind("UploadProgress",function(B,C){C.percent=C.size>0?Math.ceil(C.loaded/C.size*100):100;n()});z.bind("StateChanged",function(B){if(B.state==g.STARTED){p=(+new Date())}else{if(B.state==g.STOPPED){for(A=B.files.length-1;A>=0;A--){if(B.files[A].status==g.UPLOADING){B.files[A].status=g.QUEUED;n()}}}}});z.bind("QueueChanged",n);z.bind("Error",function(B,C){if(C.file){C.file.status=g.FAILED;n();if(B.state==g.STARTED){c(function(){r.call(z)},1)}}});z.bind("FileUploaded",function(B,C){C.status=g.DONE;C.loaded=C.size;B.trigger("UploadProgress",C);c(function(){r.call(z)},1)});if(q.runtimes){w=[];x=q.runtimes.split(/\s?,\s?/);for(A=0;A<x.length;A++){if(k[x[A]]){w.push(k[x[A]])}}}else{w=k}function u(){var E=w[y++],D,B,C;if(E){D=E.getFeatures();B=z.settings.required_features;if(B){B=B.split(",");for(C=0;C<B.length;C++){if(!D[B[C]]){u();return}}}E.init(z,function(F){if(F&&F.success){z.features=D;z.runtime=E.name;z.trigger("Init",{runtime:E.name});z.trigger("PostInit");z.refresh()}else{u()}})}else{z.trigger("Error",{code:g.INIT_ERROR,message:g.translate("Init error.")})}}u();if(typeof(q.init)=="function"){q.init(z)}else{g.each(q.init,function(C,B){z.bind(B,C)})}},refresh:function(){this.trigger("Refresh")},start:function(){if(this.state!=g.STARTED){this.state=g.STARTED;this.trigger("StateChanged");r.call(this)}},stop:function(){if(this.state!=g.STOPPED){this.state=g.STOPPED;this.trigger("StateChanged")}},getFile:function(v){var u;for(u=s.length-1;u>=0;u--){if(s[u].id===v){return s[u]}}},removeFile:function(v){var u;for(u=s.length-1;u>=0;u--){if(s[u].id===v.id){return this.splice(u,1)[0]}}},splice:function(w,u){var v;v=s.splice(w===b?0:w,u===b?s.length:u);this.trigger("FilesRemoved",v);this.trigger("QueueChanged");return v},trigger:function(v){var x=o[v.toLowerCase()],w,u;if(x){u=Array.prototype.slice.call(arguments);u[0]=this;for(w=0;w<x.length;w++){if(x[w].func.apply(x[w].scope,u)===false){return false}}}return true},bind:function(u,w,v){var x;u=u.toLowerCase();x=o[u]||[];x.push({func:w,scope:v||this});o[u]=x},unbind:function(u){u=u.toLowerCase();var x=o[u],v,w=arguments[1];if(x){if(w!==b){for(v=x.length-1;v>=0;v--){if(x[v].func===w){x.splice(v,1);break}}}else{x=[]}if(!x.length){delete o[u]}}},unbindAll:function(){var u=this;g.each(o,function(w,v){u.unbind(v)})},destroy:function(){this.trigger("Destroy");this.unbindAll()}})};g.File=function(q,o,p){var n=this;n.id=q;n.name=o;n.size=p;n.loaded=0;n.percent=0;n.status=0};g.Runtime=function(){this.getFeatures=function(){};this.init=function(n,o){}};g.QueueProgress=function(){var n=this;n.size=0;n.loaded=0;n.uploaded=0;n.failed=0;n.queued=0;n.percent=0;n.bytesPerSec=0;n.reset=function(){n.size=n.loaded=n.uploaded=n.failed=n.queued=n.percent=n.bytesPerSec=0}};g.runtimes={};window.plupload=g})(); |
| \ No newline at end of file | |
app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js
+7
-1
| @@ | @@ -61,7 +61,7 @@ var cms_wym_options = { |
| + '</ul>', | |
| htmlHtml: '<div class="wym_html">' | |
| - | + '<textarea class="wym_html_val code"></textarea>' |
| + | + '<textarea class="wym_html_val"></textarea>' |
| + '</div>', | |
| dialogLinkHtml: '<form id="wym_dialog_form">' | |
| @@ | @@ -328,3 +328,9 @@ WYMeditor.PROCESS_DIALOG_PASTE = function(wym, data) { |
| wym.paste(data['paste']); | |
| } | |
| + | WYMeditor.editor.prototype.xhtml = function() { |
| + | var html = this.parser.parse(this.html()); |
| + | var reg = /(>)(<)(\/*)/g; |
| + | html = html.replace(reg, '$1\r\n$2$3'); |
| + | return html; |
| + | }; |
| \ No newline at end of file | |
app/assets/stylesheets/comfortable_mexican_sofa/application.css
+1
-0
| @@ | @@ -5,4 +5,5 @@ |
| = require comfortable_mexican_sofa/form.css | |
| = require comfortable_mexican_sofa/content.css | |
| = require comfortable_mexican_sofa/widgets.css | |
| + | = require comfortable_mexican_sofa/codemirror.css |
| */ | |
| \ No newline at end of file | |
app/assets/stylesheets/comfortable_mexican_sofa/codemirror.css
+84
-0
| @@ | @@ -0,0 +1,84 @@ |
| + | .CodeMirror { |
| + | overflow: auto; |
| + | height: 300px; |
| + | background-color: #fff; |
| + | line-height: 1em; |
| + | font-family: 'Courier New', Courier, monospace; |
| + | } |
| + | .CodeMirror-scroll { |
| + | min-height: 300px; |
| + | } |
| + | .CodeMirror-gutter { |
| + | position: absolute; left: 0; top: 0; |
| + | background-color: #f7f7f7; |
| + | border-right: 1px solid #eee; |
| + | min-width: 2em; |
| + | height: 100%; |
| + | } |
| + | .CodeMirror-gutter-text { |
| + | color: #aaa; |
| + | text-align: right; |
| + | padding: .4em .2em .4em .4em; |
| + | } |
| + | .CodeMirror-lines { |
| + | padding: .4em; |
| + | } |
| + | |
| + | .CodeMirror pre { |
| + | -moz-border-radius: 0; |
| + | -webkit-border-radius: 0; |
| + | -o-border-radius: 0; |
| + | border-radius: 0; |
| + | border-width: 0; margin: 0; padding: 0; background: transparent; |
| + | font-family: inherit; |
| + | } |
| + | |
| + | .CodeMirror textarea { |
| + | font-family: monospace !important; |
| + | } |
| + | |
| + | .CodeMirror-cursor { |
| + | z-index: 10; |
| + | position: absolute; |
| + | visibility: hidden; |
| + | border-left: 1px solid black !important; |
| + | } |
| + | .CodeMirror-focused .CodeMirror-cursor { |
| + | visibility: visible; |
| + | } |
| + | |
| + | span.CodeMirror-selected { |
| + | background: #ccc !important; |
| + | color: HighlightText !important; |
| + | } |
| + | .CodeMirror-focused span.CodeMirror-selected { |
| + | background: Highlight !important; |
| + | } |
| + | |
| + | .CodeMirror-matchingbracket {color: #0f0 !important;} |
| + | .CodeMirror-nonmatchingbracket {color: #f22 !important;} |
| + | |
| + | span.xml-tag {color: #a0b;} |
| + | span.xml-attribute {color: #281;} |
| + | span.xml-attname {color: #00f;} |
| + | span.xml-comment {color: #a70;} |
| + | span.xml-cdata {color: #48a;} |
| + | span.xml-processing {color: #999;} |
| + | span.xml-entity {color: #a22;} |
| + | |
| + | span.css-at {color: #708;} |
| + | span.css-unit {color: #281;} |
| + | span.css-value {color: #708;} |
| + | span.css-identifier {color: black;} |
| + | span.css-selector {color: #11B;} |
| + | span.css-important {color: #00F;} |
| + | span.css-colorcode {color: #299;} |
| + | span.css-comment {color: #A70;} |
| + | span.css-string {color: #A22;} |
| + | |
| + | span.js-keyword {color: #90b;} |
| + | span.js-atom {color: #291;} |
| + | span.js-variabledef {color: #00f;} |
| + | span.js-localvariable {color: #049;} |
| + | span.js-comment {color: #a70;} |
| + | span.js-string {color: #a22;} |
| \ No newline at end of file | |
app/views/cms_admin/layouts/_form.html.erb
+2
-2
| @@ | @@ -12,8 +12,8 @@ |
| <% end %> | |
| <%= form.text_area :content, :class => 'code' %> | |
| - | <%= form.text_area :css, :class => 'code_css' %> |
| - | <%= form.text_area :js, :class => 'code_js' %> |
| + | <%= form.text_area :css, :class => 'code css' %> |
| + | <%= form.text_area :js, :class => 'code js' %> |
| <%= form.simple_field nil, nil, :class => 'submit_element' do %> | |
| <%= form.submit @cms_layout.new_record?? 'Create Layout' : 'Update Layout', :disable_builder => true %> | |
app/views/layouts/cms_admin/_head.html.erb
+4
-0
| @@ | @@ -7,9 +7,13 @@ |
| <%= stylesheet_link_tag 'comfortable_mexican_sofa/application' %> | |
| <%= javascript_include_tag 'comfortable_mexican_sofa/application' %> | |
| + | |
| <%= javascript_include_tag 'comfortable_mexican_sofa/wymeditor/jquery.wymeditor.pack.js' %> | |
| <%= javascript_include_tag 'comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js' %> | |
| + | <%= javascript_include_tag 'comfortable_mexican_sofa/plupload/plupload.js' %> |
| + | <%= javascript_include_tag 'comfortable_mexican_sofa/plupload/plupload.html5.js' %> |
| + | |
| <%= yield :head %> | |
| <%= cms_hook :html_head %> | |
| </head> | |
| \ No newline at end of file | |
config/application.rb
+3
-1
| @@ | @@ -42,7 +42,9 @@ module ComfortableMexicanSofa |
| config.filter_parameters += [:password] | |
| # Enable the asset pipeline | |
| - | config.assets.enabled = true |
| + | if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1 |
| + | config.assets.enabled = true |
| + | end |
| config.session_store :cookie_store, :key => '_comfortable_mexican_sofa_session' | |
| config.secret_token = 'e0fef4ab56c1cacd8845864fe2cb2a27f5caad72823419f87b2774785187090a654b83229bf9cef70ce475a83bfa561dbbaa2015788181ea837c456964c1e0f6' | |