From a021068bb61bb4d7dc637fa12321c73cbf54ddd9 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Fri, 20 Jul 2012 03:45:14 -0700 Subject: [PATCH 1/9] Create gh-pages branch via GitHub --- images/bkg.png | Bin 0 -> 4261 bytes images/blacktocat.png | Bin 0 -> 1266 bytes index.html | 37 ++++++ javascripts/main.js | 1 + params.json | 1 + stylesheets/pygment_trac.css | 68 ++++++++++ stylesheets/stylesheet.css | 247 +++++++++++++++++++++++++++++++++++ 7 files changed, 354 insertions(+) create mode 100644 images/bkg.png create mode 100644 images/blacktocat.png create mode 100644 index.html create mode 100644 javascripts/main.js create mode 100644 params.json create mode 100644 stylesheets/pygment_trac.css create mode 100644 stylesheets/stylesheet.css diff --git a/images/bkg.png b/images/bkg.png new file mode 100644 index 0000000000000000000000000000000000000000..fcebb5b22999adb792afee1f74bcf4af91db8441 GIT binary patch literal 4261 zcmai24OG(S8mBsUyM3)~ZEIE-v#qwa1Vm(_WaZcF4$Tzl!!$x9YVt?^Am9ho*2lIQ zTie~ak)qq&rWX>
8T6nEuDuzAQq;*m$U_enEjIf_wTdeFYT{JoQD5|@shXlvVcOKfW~DY zHWUE68K|@(8k4bwK`Rgy8yWEk#GD9L_Ez3j^7}+OP!vh??}-!^abRx*B0fRLq0#p- zc&ObBCW}pqaOzqkP^+4>M6iip9W9{ohX*|-IT#4SlFk8;5lDPj+g$04H80)Ze>fQtmU zOf)t&Hr5{_DrzmfV=X9R^Jv1gY;a{DLJ|X{b6Ff73t*%C5ox;tK93XuBb_-y5$ADO zHu$JaaKX?*8V8My#Q2XC*hnUa-da@jcsIz~!gzxBse!?45r=`^!TNt2HYP=5@QE9vlA}}JO%C`b0d#&5gUt*07CiBd4(jWt zLJWhZKp#6>gL!$$qVD|Wzk7)}V zkBQGx@@9q_1yr6q017Ty@?&EzVH&nI8Gv!-^x=W~}{IQz$!k{zA98=Ti? z9cVfF`8lawJL&Vf$95Qs%Nvf1vh7mQMX#$ul8xKfXp?90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000000000000000000000000000000..273d5710a2e0968d77584ad073e4a089fbfd7e68 GIT binary patch literal 1266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nA0*tB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%s|1+P|wiV z#N6CmN5ROz&_Lh7NZ-&%*U;R`*vQJjKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8EkR}&8R-I5=oVMzl_XZ^<`pZ$OmImpPA){ffi_eM3D1{oGuTzrd=COM+4n&cLd=IHa;5RX-@T zIKQ+g85kdF$}r8qu)}W=NFmTQR{lkqz(`5Vami0E%}vcK@pQ3O0?O#6WTsdd7+V+^ z8k(CJm>U_GSr{5xm>asenYlPSS~yx7IT;(l%)qAC#mvab6&Utr2Bs#4hOUN|=4MVV zCI+U?PDZXKZWgXEy`Fi+C5d^-sW5vpf%Zc6n&H)J<$fLUYiAMFhc42(*iE{-7;x0Xyc%sb>D;QCfH z^og8&1M`mKzE)l;d=qjrb~vvJSy|Mouyo1dg^ni6?thVCs0yAf`Q@5aq}s+K9`V=C z{rP`=v-NB<-^nFOYBRV_`Rx;uVYQy^)9a}ALqMd-xJi4fVcRLrrgF#H^(z_`gmYNg z8`ZC~^QU(&GySnBKw|Qotw~8oCN7?p;&T4i?d&@L$Gl%$8&-dv`S`$=`T36X{>ZDw zT=kLd?0S^caPZI_ua^-qKl~;=EWB<}?CV->TJO$Qp2Pd-+ + + + + + + + + + + Jquery-textrange by dwieeb + + + + +
+
+

Jquery-textrange

+

A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas.

+ +
+ Download as .zip + Download as .tar.gz + View on GitHub +
+
+
+ +
+
+

:o

+
+
+ + + + \ No newline at end of file diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 0000000..d8135d3 --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1 @@ +console.log('This would be the main JS file.'); diff --git a/params.json b/params.json new file mode 100644 index 0000000..745dc72 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"body":":o","name":"Jquery-textrange","google":"","note":"Don't delete this file! It's used internally to help with page regeneration.","tagline":"A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas."} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..d1df6a2 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,68 @@ +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #CBDFFF } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 0000000..a54a639 --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,247 @@ +body { + margin: 0; + padding: 0; + background: #151515 url("../images/bkg.png") 0 0; + color: #eaeaea; + font: 16px; + line-height: 1.5; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; +} + +/* General & 'Reset' Stuff */ + +.container { + width: 90%; + max-width: 600px; + margin: 0 auto; +} + +section { + display: block; + margin: 0 0 20px 0; +} + +h1, h2, h3, h4, h5, h6 { + margin: 0 0 20px; +} + +li { + line-height: 1.4 ; +} + +/* Header,
+ header - container + h1 - project name + h2 - project description +*/ + +header { + background: rgba(0, 0, 0, 0.1); + width: 100%; + border-bottom: 1px dashed #b5e853; + padding: 20px 0; + margin: 0 0 40px 0; +} + +header h1 { + font-size: 30px; + line-height: 1.5; + margin: 0 0 0 -40px; + font-weight: bold; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + color: #b5e853; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), + 0 0 5px rgba(181, 232, 83, 0.1), + 0 0 10px rgba(181, 232, 83, 0.1); + letter-spacing: -1px; + -webkit-font-smoothing: antialiased; +} + +header h1:before { + content: "./ "; + font-size: 24px; +} + +header h2 { + font-size: 18px; + font-weight: 300; + color: #666; +} + +#downloads .btn { + display: inline-block; + text-align: center; + margin: 0; +} + +/* Main Content +*/ + +#main_content { + width: 100%; + -webkit-font-smoothing: antialiased; +} +section img { + max-width: 100% +} + +h1, h2, h3, h4, h5, h6 { + font-weight: normal; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + color: #b5e853; + letter-spacing: -0.03em; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), + 0 0 5px rgba(181, 232, 83, 0.1), + 0 0 10px rgba(181, 232, 83, 0.1); +} + +#main_content h1 { + font-size: 30px; +} + +#main_content h2 { + font-size: 24px; +} + +#main_content h3 { + font-size: 18px; +} + +#main_content h4 { + font-size: 14px; +} + +#main_content h5 { + font-size: 12px; + text-transform: uppercase; + margin: 0 0 5px 0; +} + +#main_content h6 { + font-size: 12px; + text-transform: uppercase; + color: #999; + margin: 0 0 5px 0; +} + +dt { + font-style: italic; + font-weight: bold; +} + +ul li { + list-style: none; +} + +ul li:before { + content: ">>"; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + font-size: 13px; + color: #b5e853; + margin-left: -37px; + margin-right: 21px; + line-height: 16px; +} + +blockquote { + color: #aaa; + padding-left: 10px; + border-left: 1px dotted #666; +} + +pre { + background: rgba(0, 0, 0, 0.9); + border: 1px solid rgba(255, 255, 255, 0.15); + padding: 10px; + font-size: 14px; + color: #b5e853; + border-radius: 2px; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + text-wrap: normal; + overflow: auto; + overflow-y: hidden; +} + +table { + width: 100%; + margin: 0 0 20px 0; +} + +th { + text-align: left; + border-bottom: 1px dashed #b5e853; + padding: 5px 10px; +} + +td { + padding: 5px 10px; +} + +hr { + height: 0; + border: 0; + border-bottom: 1px dashed #b5e853; + color: #b5e853; +} + +/* Buttons +*/ + +.btn { + display: inline-block; + background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.3), rgba(35, 35, 35, 0.3) 50%, rgba(10, 10, 10, 0.3) 50%, rgba(0, 0, 0, 0.3)); + padding: 8px 18px; + border-radius: 50px; + border: 2px solid rgba(0, 0, 0, 0.7); + border-bottom: 2px solid rgba(0, 0, 0, 0.7); + border-top: 2px solid rgba(0, 0, 0, 1); + color: rgba(255, 255, 255, 0.8); + font-family: Helvetica, Arial, sans-serif; + font-weight: bold; + font-size: 13px; + text-decoration: none; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.btn:hover { + background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.6), rgba(35, 35, 35, 0.6) 50%, rgba(10, 10, 10, 0.8) 50%, rgba(0, 0, 0, 0.8)); +} + +.btn .icon { + display: inline-block; + width: 16px; + height: 16px; + margin: 1px 8px 0 0; + float: left; +} + +.btn-github .icon { + opacity: 0.6; + background: url("../images/blacktocat.png") 0 0 no-repeat; +} + +/* Links + a, a:hover, a:visited +*/ + +a { + color: #63c0f5; + text-shadow: 0 0 5px rgba(104, 182, 255, 0.5); +} + +/* Clearfix */ + +.cf:before, .cf:after { + content:""; + display:table; +} + +.cf:after { + clear:both; +} + +.cf { + zoom:1; +} \ No newline at end of file From 49536ff874d6373a3565e32b0029ddd1b6daabe2 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Tue, 24 Jul 2012 17:40:35 -0500 Subject: [PATCH 2/9] Adding a live demonstration for the plugin. --- images/bkg.png | Bin 4261 -> 0 bytes images/blacktocat.png | Bin 1266 -> 0 bytes index.html | 143 +++++++++++++++----- javascripts/main.js | 1 - jquery-textrange.js | 178 +++++++++++++++++++++++++ params.json | 1 - stylesheets/pygment_trac.css | 68 ---------- stylesheets/stylesheet.css | 247 ----------------------------------- 8 files changed, 285 insertions(+), 353 deletions(-) delete mode 100644 images/bkg.png delete mode 100644 images/blacktocat.png delete mode 100644 javascripts/main.js create mode 100644 jquery-textrange.js delete mode 100644 params.json delete mode 100644 stylesheets/pygment_trac.css delete mode 100644 stylesheets/stylesheet.css diff --git a/images/bkg.png b/images/bkg.png deleted file mode 100644 index fcebb5b22999adb792afee1f74bcf4af91db8441..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4261 zcmai24OG(S8mBsUyM3)~ZEIE-v#qwa1Vm(_WaZcF4$Tzl!!$x9YVt?^Am9ho*2lIQ zTie~ak)qq&rWX>
8T6nEuDuzAQq;*m$U_enEjIf_wTdeFYT{JoQD5|@shXlvVcOKfW~DY zHWUE68K|@(8k4bwK`Rgy8yWEk#GD9L_Ez3j^7}+OP!vh??}-!^abRx*B0fRLq0#p- zc&ObBCW}pqaOzqkP^+4>M6iip9W9{ohX*|-IT#4SlFk8;5lDPj+g$04H80)Ze>fQtmU zOf)t&Hr5{_DrzmfV=X9R^Jv1gY;a{DLJ|X{b6Ff73t*%C5ox;tK93XuBb_-y5$ADO zHu$JaaKX?*8V8My#Q2XC*hnUa-da@jcsIz~!gzxBse!?45r=`^!TNt2HYP=5@QE9vlA}}JO%C`b0d#&5gUt*07CiBd4(jWt zLJWhZKp#6>gL!$$qVD|Wzk7)}V zkBQGx@@9q_1yr6q017Ty@?&EzVH&nI8Gv!-^x=W~}{IQz$!k{zA98=Ti? z9cVfF`8lawJL&Vf$95Qs%Nvf1vh7mQMX#$ul8xKfXp?90UsgyjF)tIRCdvlh?KrbH zv$~{=QZbg@;?kDY?!_;sOnP!E$WC_y*L!11kJ$Bv5P=FueEclp=B)kG%NZ+7YOGoP zR-EH7=(Ixzm4*4r!U~*|*f}&ewbAzZg$rV7yy&TpH)pNSQqOg{CC4>}G40e2em2s* zKCkIZr2DpNqSZ@AS6<r{w4k}39fVJzZXAy0G=<@V(rsuz5bVoeL zq+fMF{HYOh*>$N+ro3`@%}CQfL>5o_WPYe}`@$iaZYz~6GhYY36SpGGi3vX>Q!if_ zW9q{cdi5&xHzBM2OL>Yxeo@({8F}vGo)?H9zB*<}?_KK~<>Ca;lrUut0s0QfGvOOQ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`|fgO;#gLyBgiBOG!z#3@XkTfXu8c}+PK=2_c1mzO*scsQco@tHBs5OfZs z$8NNh_v)za2hh3d!{9GC=2^!u6$x6F3k_b)0HLi@ubw9%xBZ3Ommvims*{jB*0zSC zJ49_LfLb#7dYNlHqdQGMY}V}ji|0&vzYZYi^bR?WnGau-m&DBM#vB>^$Z&(5&gG#x zJ`xV$h>ipCjn@`3+01KQ+utac5>+Ws#n+nJvi`lWegz$?!qujlbLb{{(_)p_l1Z+( zdM>W^kZsfPn#(4ql5bnklzKaa<0rGFtTg%OA`UEQ^d?dB*OsH>X49VdUT_o$9aG z(}gb@7Cr`Hs63<)5A`v?_ZO{2SSk(Pn(=X6CD$kn#!}jpA*1r znIIiHD1w-ri((t~C+02VllSc(UOupDpVZpg9ztUa>vrG-d~*-Ew3l)s6YthL%Ht*{ ze%1=aHvnw3uQBA!TwFcao}XkUs49=`tQ%O)vYY}elzL*VuTX(=8u_V>j)}r>S4Uh~ zh>GVehE`=Smd4(neDmas=pLEo)|t(XUs77pn;QoN(54u9Jv>@Lm8^V);kZT#8jv3` z&GiE#r51T-G5W5_uCs-YQIy9$Bn^A%)S!H7$u7ib&EeDgKaH>T|KlJnIXy|Wao30c E2cLQQbpQYW diff --git a/images/blacktocat.png b/images/blacktocat.png deleted file mode 100644 index 273d5710a2e0968d77584ad073e4a089fbfd7e68..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nA0*tB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%s|1+P|wiV z#N6CmN5ROz&_Lh7NZ-&%*U;R`*vQJjKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8EkR}&8R-I5=oVMzl_XZ^<`pZ$OmImpPA){ffi_eM3D1{oGuTzrd=COM+4n&cLd=IHa;5RX-@T zIKQ+g85kdF$}r8qu)}W=NFmTQR{lkqz(`5Vami0E%}vcK@pQ3O0?O#6WTsdd7+V+^ z8k(CJm>U_GSr{5xm>asenYlPSS~yx7IT;(l%)qAC#mvab6&Utr2Bs#4hOUN|=4MVV zCI+U?PDZXKZWgXEy`Fi+C5d^-sW5vpf%Zc6n&H)J<$fLUYiAMFhc42(*iE{-7;x0Xyc%sb>D;QCfH z^og8&1M`mKzE)l;d=qjrb~vvJSy|Mouyo1dg^ni6?thVCs0yAf`Q@5aq}s+K9`V=C z{rP`=v-NB<-^nFOYBRV_`Rx;uVYQy^)9a}ALqMd-xJi4fVcRLrrgF#H^(z_`gmYNg z8`ZC~^QU(&GySnBKw|Qotw~8oCN7?p;&T4i?d&@L$Gl%$8&-dv`S`$=`T36X{>ZDw zT=kLd?0S^caPZI_ua^-qKl~;=EWB<}?CV->TJO$Qp2Pd-+ + - - - - - - - - - Jquery-textrange by dwieeb - - - - -
-
-

Jquery-textrange

-

A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas.

- -
- Download as .zip - Download as .tar.gz - View on GitHub -
-
-
- -
-
-

:o

-
-
- - - - \ No newline at end of file + + +jquery-textrange + + + + + + +

jquery-textrange

+created by Daniel Imhoff +See the wiki for all features and documentation. +
+ +
+
+Object returned: + +{ +position: 0, +start: 0, +end: 0, +length: 0, +text: "" +} + + +
+
+Select a substring starting at and ending at +
+
+Replace the selected text with: +
+ + + diff --git a/javascripts/main.js b/javascripts/main.js deleted file mode 100644 index d8135d3..0000000 --- a/javascripts/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log('This would be the main JS file.'); diff --git a/jquery-textrange.js b/jquery-textrange.js new file mode 100644 index 0000000..715c1f7 --- /dev/null +++ b/jquery-textrange.js @@ -0,0 +1,178 @@ +/** + * jquery-textrange + * A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas. + * + * (c) 2012 Daniel Imhoff - danielimhoff.com + */ +(function($) { + var browserType; + + var textrange = { + /** + * $().textrange() or $().textrange('get') + * Retrieves an object containing the start and end location of the text range, the length of the range and the + * substring of the range. + * + * @param (optional) property + * @return An object of properties including position, start, end, length, and text or a specific property. + */ + get: function(property) { + return _textrange[browserType].get.apply(this, [property]); + }, + + /** + * $().textrange('set') + * Sets the selected text of an object by specifying the start and end of the selection. + * + * @param start The starting position of the selection, or the position of the cursor, if end is not given. + * @param (optional) end The ending position of the selection. + */ + set: function(start, end) { + if(typeof start === 'undefined') { + start = 0; + } + else if(start === 'all') { + start = 0; + end = 'end'; + } + + if(typeof end === 'undefined') { + end = start; + } + else if(end === 'end') { + end = this.val().length; + } + + _textrange[browserType].set.apply(this, [start, end]); + + return this; + }, + + /** + * $().textrange('replace') + * Replaces the selected text in the input field or textarea with text. + * + * @param text The text to replace the selection with. + */ + replace: function(text) { + _textrange[browserType].replace.apply(this, [text]); + + return this; + }, + + /** + * Alias for $().textrange('replace') + */ + insert: function(text) { + return this.textrange('replace', text); + } + }; + + var _textrange = { + xul: { + get: function(property) { + var props = { + position: this[0].selectionStart, + start: this[0].selectionStart, + end: this[0].selectionEnd, + length: this[0].selectionEnd - this[0].selectionStart, + text: this.val().substring(this[0].selectionStart, this[0].selectionEnd) + }; + + return typeof property === 'undefined' ? props : props[property]; + }, + + set: function(start, end) { + this[0].selectionStart = start; + this[0].selectionEnd = end; + }, + + replace: function(text) { + var start = this[0].selectionStart; + this.val(this.val().substring(0, this[0].selectionStart) + text + this.val().substring(this[0].selectionEnd, this.val().length)); + this[0].selectionStart = start; + this[0].selectionEnd = start + text.length; + } + }, + + msie: { + get: function(property) { + this[0].focus(); + + var range = document.selection.createRange(); + + if(typeof range === 'undefined') { + return { + position: 0, + start: 0, + end: this[0].val().length, + length: this[0].val().length, + text: this.val() + }; + } + + var rangetext = this[0].createTextRange(); + var rangetextcopy = rangetext.duplicate(); + + rangetext.moveToBookmark(range.getBookmark()); + rangetextcopy.setEndPoint('EndToStart', rangetext); + + return { + position: rangetextcopy.text.length, + start: rangetextcopy.text.length, + end: rangetextcopy.text.length + range.text.length, + length: range.text.length, + text: range.text + }; + }, + + set: function(start, end) { + this[0].focus(); + + var range = this[0].createTextRange(); + + if(typeof range === 'undefined') { + return this; + } + + if(typeof start !== 'undefined') { + range.moveStart('character', start); + range.collapse(); + } + + if(typeof end !== 'undefined') { + range.moveEnd('character', end - start); + } + + range.select(); + }, + + replace: function(text) { + this[0].focus(); + + document.selection.createRange().text = text; + } + } + }; + + $.fn.textrange = function(method) { + if(typeof browserType === 'undefined') { + browserType = 'selectionStart' in this[0] ? 'xul' : document.selection ? 'msie' : 'unknown'; + } + + // I don't know how to support this browser. :c + if(browserType === 'unknown') { + return this; + } + + if(typeof method === 'undefined' || typeof method !== 'string') { + return textrange.get.apply(this); + } + else if(typeof textrange[method] === 'function') { + return textrange[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } + else { + $.error("Method " + method + " does not exist in jQuery.textrange"); + } + }; +})(jQuery); \ No newline at end of file diff --git a/params.json b/params.json deleted file mode 100644 index 745dc72..0000000 --- a/params.json +++ /dev/null @@ -1 +0,0 @@ -{"body":":o","name":"Jquery-textrange","google":"","note":"Don't delete this file! It's used internally to help with page regeneration.","tagline":"A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas."} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css deleted file mode 100644 index d1df6a2..0000000 --- a/stylesheets/pygment_trac.css +++ /dev/null @@ -1,68 +0,0 @@ -.highlight .c { color: #999988; font-style: italic } /* Comment */ -.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ -.highlight .k { font-weight: bold } /* Keyword */ -.highlight .o { font-weight: bold } /* Operator */ -.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ -.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ -.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #aa0000 } /* Generic.Error */ -.highlight .gh { color: #999999 } /* Generic.Heading */ -.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ -.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ -.highlight .go { color: #888888 } /* Generic.Output */ -.highlight .gp { color: #555555 } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ -.highlight .gt { color: #aa0000 } /* Generic.Traceback */ -.highlight .kc { font-weight: bold } /* Keyword.Constant */ -.highlight .kd { font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ -.highlight .kr { font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ -.highlight .m { color: #009999 } /* Literal.Number */ -.highlight .s { color: #d14 } /* Literal.String */ -.highlight .na { color: #008080 } /* Name.Attribute */ -.highlight .nb { color: #0086B3 } /* Name.Builtin */ -.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ -.highlight .no { color: #008080 } /* Name.Constant */ -.highlight .ni { color: #800080 } /* Name.Entity */ -.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ -.highlight .nn { color: #555555 } /* Name.Namespace */ -.highlight .nt { color: #CBDFFF } /* Name.Tag */ -.highlight .nv { color: #008080 } /* Name.Variable */ -.highlight .ow { font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #009999 } /* Literal.Number.Float */ -.highlight .mh { color: #009999 } /* Literal.Number.Hex */ -.highlight .mi { color: #009999 } /* Literal.Number.Integer */ -.highlight .mo { color: #009999 } /* Literal.Number.Oct */ -.highlight .sb { color: #d14 } /* Literal.String.Backtick */ -.highlight .sc { color: #d14 } /* Literal.String.Char */ -.highlight .sd { color: #d14 } /* Literal.String.Doc */ -.highlight .s2 { color: #d14 } /* Literal.String.Double */ -.highlight .se { color: #d14 } /* Literal.String.Escape */ -.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ -.highlight .si { color: #d14 } /* Literal.String.Interpol */ -.highlight .sx { color: #d14 } /* Literal.String.Other */ -.highlight .sr { color: #009926 } /* Literal.String.Regex */ -.highlight .s1 { color: #d14 } /* Literal.String.Single */ -.highlight .ss { color: #990073 } /* Literal.String.Symbol */ -.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #008080 } /* Name.Variable.Class */ -.highlight .vg { color: #008080 } /* Name.Variable.Global */ -.highlight .vi { color: #008080 } /* Name.Variable.Instance */ -.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ - -.type-csharp .highlight .k { color: #0000FF } -.type-csharp .highlight .kt { color: #0000FF } -.type-csharp .highlight .nf { color: #000000; font-weight: normal } -.type-csharp .highlight .nc { color: #2B91AF } -.type-csharp .highlight .nn { color: #000000 } -.type-csharp .highlight .s { color: #A31515 } -.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css deleted file mode 100644 index a54a639..0000000 --- a/stylesheets/stylesheet.css +++ /dev/null @@ -1,247 +0,0 @@ -body { - margin: 0; - padding: 0; - background: #151515 url("../images/bkg.png") 0 0; - color: #eaeaea; - font: 16px; - line-height: 1.5; - font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; -} - -/* General & 'Reset' Stuff */ - -.container { - width: 90%; - max-width: 600px; - margin: 0 auto; -} - -section { - display: block; - margin: 0 0 20px 0; -} - -h1, h2, h3, h4, h5, h6 { - margin: 0 0 20px; -} - -li { - line-height: 1.4 ; -} - -/* Header,
- header - container - h1 - project name - h2 - project description -*/ - -header { - background: rgba(0, 0, 0, 0.1); - width: 100%; - border-bottom: 1px dashed #b5e853; - padding: 20px 0; - margin: 0 0 40px 0; -} - -header h1 { - font-size: 30px; - line-height: 1.5; - margin: 0 0 0 -40px; - font-weight: bold; - font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; - color: #b5e853; - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), - 0 0 5px rgba(181, 232, 83, 0.1), - 0 0 10px rgba(181, 232, 83, 0.1); - letter-spacing: -1px; - -webkit-font-smoothing: antialiased; -} - -header h1:before { - content: "./ "; - font-size: 24px; -} - -header h2 { - font-size: 18px; - font-weight: 300; - color: #666; -} - -#downloads .btn { - display: inline-block; - text-align: center; - margin: 0; -} - -/* Main Content -*/ - -#main_content { - width: 100%; - -webkit-font-smoothing: antialiased; -} -section img { - max-width: 100% -} - -h1, h2, h3, h4, h5, h6 { - font-weight: normal; - font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; - color: #b5e853; - letter-spacing: -0.03em; - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), - 0 0 5px rgba(181, 232, 83, 0.1), - 0 0 10px rgba(181, 232, 83, 0.1); -} - -#main_content h1 { - font-size: 30px; -} - -#main_content h2 { - font-size: 24px; -} - -#main_content h3 { - font-size: 18px; -} - -#main_content h4 { - font-size: 14px; -} - -#main_content h5 { - font-size: 12px; - text-transform: uppercase; - margin: 0 0 5px 0; -} - -#main_content h6 { - font-size: 12px; - text-transform: uppercase; - color: #999; - margin: 0 0 5px 0; -} - -dt { - font-style: italic; - font-weight: bold; -} - -ul li { - list-style: none; -} - -ul li:before { - content: ">>"; - font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; - font-size: 13px; - color: #b5e853; - margin-left: -37px; - margin-right: 21px; - line-height: 16px; -} - -blockquote { - color: #aaa; - padding-left: 10px; - border-left: 1px dotted #666; -} - -pre { - background: rgba(0, 0, 0, 0.9); - border: 1px solid rgba(255, 255, 255, 0.15); - padding: 10px; - font-size: 14px; - color: #b5e853; - border-radius: 2px; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - text-wrap: normal; - overflow: auto; - overflow-y: hidden; -} - -table { - width: 100%; - margin: 0 0 20px 0; -} - -th { - text-align: left; - border-bottom: 1px dashed #b5e853; - padding: 5px 10px; -} - -td { - padding: 5px 10px; -} - -hr { - height: 0; - border: 0; - border-bottom: 1px dashed #b5e853; - color: #b5e853; -} - -/* Buttons -*/ - -.btn { - display: inline-block; - background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.3), rgba(35, 35, 35, 0.3) 50%, rgba(10, 10, 10, 0.3) 50%, rgba(0, 0, 0, 0.3)); - padding: 8px 18px; - border-radius: 50px; - border: 2px solid rgba(0, 0, 0, 0.7); - border-bottom: 2px solid rgba(0, 0, 0, 0.7); - border-top: 2px solid rgba(0, 0, 0, 1); - color: rgba(255, 255, 255, 0.8); - font-family: Helvetica, Arial, sans-serif; - font-weight: bold; - font-size: 13px; - text-decoration: none; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); -} - -.btn:hover { - background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.6), rgba(35, 35, 35, 0.6) 50%, rgba(10, 10, 10, 0.8) 50%, rgba(0, 0, 0, 0.8)); -} - -.btn .icon { - display: inline-block; - width: 16px; - height: 16px; - margin: 1px 8px 0 0; - float: left; -} - -.btn-github .icon { - opacity: 0.6; - background: url("../images/blacktocat.png") 0 0 no-repeat; -} - -/* Links - a, a:hover, a:visited -*/ - -a { - color: #63c0f5; - text-shadow: 0 0 5px rgba(104, 182, 255, 0.5); -} - -/* Clearfix */ - -.cf:before, .cf:after { - content:""; - display:table; -} - -.cf:after { - clear:both; -} - -.cf { - zoom:1; -} \ No newline at end of file From eb45ec66bbb3b515d59d10ba3cc30d78bf6b9d70 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Fri, 7 Jun 2013 19:13:53 -0500 Subject: [PATCH 3/9] updating for new set method parameters --- index.html | 65 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 29f4174..f7a7ceb 100644 --- a/index.html +++ b/index.html @@ -27,46 +27,47 @@ @@ -94,7 +95,7 @@

jquery-textrange
-Select a substring starting at and ending at +Select a substring starting at with a length of
Replace the selected text with: From b22ba355d32379c2c248368eef40885c03413ea9 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Fri, 7 Jun 2013 19:15:44 -0500 Subject: [PATCH 4/9] updating plugin file --- jquery-textrange.js | 374 ++++++++++++++++++++++++-------------------- 1 file changed, 202 insertions(+), 172 deletions(-) diff --git a/jquery-textrange.js b/jquery-textrange.js index 715c1f7..7d21a4e 100644 --- a/jquery-textrange.js +++ b/jquery-textrange.js @@ -1,178 +1,208 @@ /** * jquery-textrange * A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas. + * See the [wiki](https://github.com/dwieeb/jquery-textrange/wiki) for usage and examples. * - * (c) 2012 Daniel Imhoff - danielimhoff.com + * (c) 2013 Daniel Imhoff - danielimhoff.com */ (function($) { - var browserType; - - var textrange = { - /** - * $().textrange() or $().textrange('get') - * Retrieves an object containing the start and end location of the text range, the length of the range and the - * substring of the range. - * - * @param (optional) property - * @return An object of properties including position, start, end, length, and text or a specific property. - */ - get: function(property) { - return _textrange[browserType].get.apply(this, [property]); - }, - - /** - * $().textrange('set') - * Sets the selected text of an object by specifying the start and end of the selection. - * - * @param start The starting position of the selection, or the position of the cursor, if end is not given. - * @param (optional) end The ending position of the selection. - */ - set: function(start, end) { - if(typeof start === 'undefined') { - start = 0; - } - else if(start === 'all') { - start = 0; - end = 'end'; - } - - if(typeof end === 'undefined') { - end = start; - } - else if(end === 'end') { - end = this.val().length; - } - - _textrange[browserType].set.apply(this, [start, end]); - - return this; - }, - - /** - * $().textrange('replace') - * Replaces the selected text in the input field or textarea with text. - * - * @param text The text to replace the selection with. - */ - replace: function(text) { - _textrange[browserType].replace.apply(this, [text]); - - return this; - }, - - /** - * Alias for $().textrange('replace') - */ - insert: function(text) { - return this.textrange('replace', text); - } - }; - - var _textrange = { - xul: { - get: function(property) { - var props = { - position: this[0].selectionStart, - start: this[0].selectionStart, - end: this[0].selectionEnd, - length: this[0].selectionEnd - this[0].selectionStart, - text: this.val().substring(this[0].selectionStart, this[0].selectionEnd) - }; - - return typeof property === 'undefined' ? props : props[property]; - }, - - set: function(start, end) { - this[0].selectionStart = start; - this[0].selectionEnd = end; - }, - - replace: function(text) { - var start = this[0].selectionStart; - this.val(this.val().substring(0, this[0].selectionStart) + text + this.val().substring(this[0].selectionEnd, this.val().length)); - this[0].selectionStart = start; - this[0].selectionEnd = start + text.length; - } - }, - - msie: { - get: function(property) { - this[0].focus(); - - var range = document.selection.createRange(); - - if(typeof range === 'undefined') { - return { - position: 0, - start: 0, - end: this[0].val().length, - length: this[0].val().length, - text: this.val() - }; - } - - var rangetext = this[0].createTextRange(); - var rangetextcopy = rangetext.duplicate(); - - rangetext.moveToBookmark(range.getBookmark()); - rangetextcopy.setEndPoint('EndToStart', rangetext); - - return { - position: rangetextcopy.text.length, - start: rangetextcopy.text.length, - end: rangetextcopy.text.length + range.text.length, - length: range.text.length, - text: range.text - }; - }, - - set: function(start, end) { - this[0].focus(); - - var range = this[0].createTextRange(); - - if(typeof range === 'undefined') { - return this; - } - - if(typeof start !== 'undefined') { - range.moveStart('character', start); - range.collapse(); - } - - if(typeof end !== 'undefined') { - range.moveEnd('character', end - start); - } - - range.select(); - }, - - replace: function(text) { - this[0].focus(); - - document.selection.createRange().text = text; - } - } - }; - - $.fn.textrange = function(method) { - if(typeof browserType === 'undefined') { - browserType = 'selectionStart' in this[0] ? 'xul' : document.selection ? 'msie' : 'unknown'; - } - - // I don't know how to support this browser. :c - if(browserType === 'unknown') { - return this; - } - - if(typeof method === 'undefined' || typeof method !== 'string') { - return textrange.get.apply(this); - } - else if(typeof textrange[method] === 'function') { - return textrange[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } - else { - $.error("Method " + method + " does not exist in jQuery.textrange"); - } - }; -})(jQuery); \ No newline at end of file + var browserType, + + textrange = { + + /** + * $().textrange() or $().textrange('get') + * + * Retrieves an object containing the start and end location of the text range, the length of the range and the + * substring of the range. + * + * @param (optional) property + * @return An object of properties including position, start, end, length, and text or a specific property. + */ + get: function(property) { + return _textrange[browserType].get.apply(this, [property]); + }, + + /** + * $().textrange('set') + * + * Sets the selected text of an object by specifying the start and length of the selection. + * + * The start and length parameters are identical to PHP's substr() function with the following changes: + * - excluding start will select all the text in the field. + * - passing 0 for length will set the cursor at start. See $().textrange('setcursor') + * + * @param (optional) start + * @param (optional) length + * + * @see http://php.net/manual/en/function.substr.php + */ + set: function(start, length) { + var s = parseInt(start), + l = parseInt(length), + e; + + if (typeof start === 'undefined') { + s = 0; + } + else if (start < 0) { + s = this.val().length + s; + } + + if (typeof length === 'undefined') { + e = this.val().length; + } + else if (length >= 0) { + e = s + l; + } + else { + e = this.val().length + l; + } + + _textrange[browserType].set.apply(this, [s, e]); + + return this; + }, + + /** + * $().textrange('setcursor') + * + * Sets the cursor at a position of the text field. + * + * @param position + */ + setcursor: function(position) { + return this.textrange('set', position, 0); + }, + + /** + * $().textrange('replace') + * Replaces the selected text in the input field or textarea with text. + * + * @param text The text to replace the selection with. + */ + replace: function(text) { + _textrange[browserType].replace.apply(this, [text]); + + return this; + }, + + /** + * Alias for $().textrange('replace') + */ + insert: function(text) { + return this.textrange('replace', text); + } + }, + + _textrange = { + xul: { + get: function(property) { + this[0].focus(); + var props = { + position: this[0].selectionStart, + start: this[0].selectionStart, + end: this[0].selectionEnd, + length: this[0].selectionEnd - this[0].selectionStart, + text: this.val().substring(this[0].selectionStart, this[0].selectionEnd) + }; + + return typeof property === 'undefined' ? props : props[property]; + }, + + set: function(start, end) { + this[0].focus(); + this[0].selectionStart = start; + this[0].selectionEnd = end; + }, + + replace: function(text) { + this[0].focus(); + var start = this[0].selectionStart; + this.val(this.val().substring(0, this[0].selectionStart) + text + this.val().substring(this[0].selectionEnd, this.val().length)); + this[0].selectionStart = start; + this[0].selectionEnd = start + text.length; + } + }, + + msie: { + get: function(property) { + this[0].focus(); + + var range = document.selection.createRange(); + + if (typeof range === 'undefined') { + return { + position: 0, + start: 0, + end: this[0].val().length, + length: this[0].val().length, + text: this.val() + }; + } + + var rangetext = this[0].createTextRange(); + var rangetextcopy = rangetext.duplicate(); + + rangetext.moveToBookmark(range.getBookmark()); + rangetextcopy.setEndPoint('EndToStart', rangetext); + + return { + position: rangetextcopy.text.length, + start: rangetextcopy.text.length, + end: rangetextcopy.text.length + range.text.length, + length: range.text.length, + text: range.text + }; + }, + + set: function(start, end) { + this[0].focus(); + + var range = this[0].createTextRange(); + + if (typeof range === 'undefined') { + return this; + } + + if (typeof start !== 'undefined') { + range.moveStart('character', start); + range.collapse(); + } + + if (typeof end !== 'undefined') { + range.moveEnd('character', end - start); + } + + range.select(); + }, + + replace: function(text) { + this[0].focus(); + + document.selection.createRange().text = text; + } + } + }; + + $.fn.textrange = function(method) { + if (typeof browserType === 'undefined') { + browserType = 'selectionStart' in this[0] ? 'xul' : document.selection ? 'msie' : 'unknown'; + } + + // I don't know how to support this browser. :c + if (browserType === 'unknown') { + return this; + } + + if (typeof method === 'undefined' || typeof method !== 'string') { + return textrange.get.apply(this); + } + else if (typeof textrange[method] === 'function') { + return textrange[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } + else { + $.error("Method " + method + " does not exist in jQuery.textrange"); + } + }; +})(jQuery); From c506d452006f96683f832b2890c156b88dc79590 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Wed, 13 Aug 2014 23:18:52 -0500 Subject: [PATCH 5/9] updating gh-pages with current files --- index.html | 14 +++++-------- jquery-textrange.js | 50 ++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index f7a7ceb..a9ac206 100644 --- a/index.html +++ b/index.html @@ -21,9 +21,6 @@ #info .property { margin-left:30px; } #textarea { display:block; width:300px; height:90px; } #char-start, #char-end { width:40px; } -#links { width:580px; text-align:center; } -#links a { display:inline-block; background:#000; border-radius: 40px; margin:0 10px; padding:10px 20px; } -#links a:hover, #links a:active, #links a:focus { background:#fa4500; } + body, h1 { margin:0; } @@ -74,8 +74,8 @@

jquery-textrange

-created by Daniel Imhoff -See the readme for all features and documentation. +created by Daniel Imhoff +See README.md for all features and documentation.