uikit2-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/uikit2/rails.rb +8 -0
- data/lib/uikit2/rails/version.rb +5 -0
- data/uikit2-rails.gemspec +25 -0
- data/vendor/assets/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/javascripts/uikit.js +3537 -0
- data/vendor/assets/javascripts/uikit/components/accordion.js +172 -0
- data/vendor/assets/javascripts/uikit/components/accordion.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/autocomplete.js +334 -0
- data/vendor/assets/javascripts/uikit/components/autocomplete.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/datepicker.js +3166 -0
- data/vendor/assets/javascripts/uikit/components/datepicker.min.js +3 -0
- data/vendor/assets/javascripts/uikit/components/form-password.js +67 -0
- data/vendor/assets/javascripts/uikit/components/form-password.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/form-select.js +70 -0
- data/vendor/assets/javascripts/uikit/components/form-select.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/grid.js +523 -0
- data/vendor/assets/javascripts/uikit/components/grid.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/htmleditor.js +623 -0
- data/vendor/assets/javascripts/uikit/components/htmleditor.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/lightbox.js +555 -0
- data/vendor/assets/javascripts/uikit/components/lightbox.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/nestable.js +638 -0
- data/vendor/assets/javascripts/uikit/components/nestable.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/notify.js +189 -0
- data/vendor/assets/javascripts/uikit/components/notify.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/pagination.js +147 -0
- data/vendor/assets/javascripts/uikit/components/pagination.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/parallax.js +417 -0
- data/vendor/assets/javascripts/uikit/components/parallax.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/search.js +92 -0
- data/vendor/assets/javascripts/uikit/components/search.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/slider.js +520 -0
- data/vendor/assets/javascripts/uikit/components/slider.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/slideset.js +502 -0
- data/vendor/assets/javascripts/uikit/components/slideset.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/slideshow-fx.js +375 -0
- data/vendor/assets/javascripts/uikit/components/slideshow-fx.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/slideshow.js +545 -0
- data/vendor/assets/javascripts/uikit/components/slideshow.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/sortable.js +664 -0
- data/vendor/assets/javascripts/uikit/components/sortable.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/sticky.js +349 -0
- data/vendor/assets/javascripts/uikit/components/sticky.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/timepicker.js +192 -0
- data/vendor/assets/javascripts/uikit/components/timepicker.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/tooltip.js +234 -0
- data/vendor/assets/javascripts/uikit/components/tooltip.min.js +2 -0
- data/vendor/assets/javascripts/uikit/components/upload.js +260 -0
- data/vendor/assets/javascripts/uikit/components/upload.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/alert.js +66 -0
- data/vendor/assets/javascripts/uikit/core/alert.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/button.js +157 -0
- data/vendor/assets/javascripts/uikit/core/button.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/core.js +725 -0
- data/vendor/assets/javascripts/uikit/core/core.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/cover.js +95 -0
- data/vendor/assets/javascripts/uikit/core/cover.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/dropdown.js +421 -0
- data/vendor/assets/javascripts/uikit/core/dropdown.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/grid.js +114 -0
- data/vendor/assets/javascripts/uikit/core/grid.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/modal.js +372 -0
- data/vendor/assets/javascripts/uikit/core/modal.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/nav.js +136 -0
- data/vendor/assets/javascripts/uikit/core/nav.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/offcanvas.js +180 -0
- data/vendor/assets/javascripts/uikit/core/offcanvas.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/scrollspy.js +208 -0
- data/vendor/assets/javascripts/uikit/core/scrollspy.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/smooth-scroll.js +62 -0
- data/vendor/assets/javascripts/uikit/core/smooth-scroll.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/switcher.js +304 -0
- data/vendor/assets/javascripts/uikit/core/switcher.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/tab.js +165 -0
- data/vendor/assets/javascripts/uikit/core/tab.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/toggle.js +120 -0
- data/vendor/assets/javascripts/uikit/core/toggle.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/touch.js +173 -0
- data/vendor/assets/javascripts/uikit/core/touch.min.js +2 -0
- data/vendor/assets/javascripts/uikit/core/utility.js +239 -0
- data/vendor/assets/javascripts/uikit/core/utility.min.js +2 -0
- data/vendor/assets/stylesheets/uikit.almost-flat.css +8551 -0
- data/vendor/assets/stylesheets/uikit.css +8252 -0
- data/vendor/assets/stylesheets/uikit.gradient.css +8614 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.almost-flat.css +39 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.css +37 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.gradient.css +39 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.almost-flat.css +52 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.css +50 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.gradient.css +52 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.almost-flat.css +129 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.css +123 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.gradient.css +139 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.almost-flat.css +128 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.css +124 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.gradient.css +128 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.almost-flat.css +78 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.css +78 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.gradient.css +78 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.almost-flat.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.gradient.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.almost-flat.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.gradient.css +34 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.almost-flat.css +35 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.css +35 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.gradient.css +35 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.almost-flat.css +222 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.css +164 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.gradient.css +229 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.almost-flat.css +135 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.css +132 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.gradient.css +139 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/notify.almost-flat.css +98 -0
- data/vendor/assets/stylesheets/uikit/components/notify.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/notify.css +92 -0
- data/vendor/assets/stylesheets/uikit/components/notify.gradient.css +98 -0
- data/vendor/assets/stylesheets/uikit/components/notify.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/notify.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.almost-flat.css +29 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.css +29 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.gradient.css +29 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/progress.almost-flat.css +104 -0
- data/vendor/assets/stylesheets/uikit/components/progress.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/progress.css +94 -0
- data/vendor/assets/stylesheets/uikit/components/progress.gradient.css +112 -0
- data/vendor/assets/stylesheets/uikit/components/progress.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/progress.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/search.almost-flat.css +191 -0
- data/vendor/assets/stylesheets/uikit/components/search.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/search.css +189 -0
- data/vendor/assets/stylesheets/uikit/components/search.gradient.css +191 -0
- data/vendor/assets/stylesheets/uikit/components/search.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/search.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.almost-flat.css +98 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.css +98 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.gradient.css +98 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slider.almost-flat.css +85 -0
- data/vendor/assets/stylesheets/uikit/components/slider.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slider.css +85 -0
- data/vendor/assets/stylesheets/uikit/components/slider.gradient.css +85 -0
- data/vendor/assets/stylesheets/uikit/components/slider.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slider.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.almost-flat.css +140 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.css +140 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.gradient.css +140 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.almost-flat.css +62 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.css +62 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.gradient.css +62 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.almost-flat.css +31 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.css +31 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.gradient.css +31 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.almost-flat.css +118 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.css +116 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.gradient.css +118 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/upload.almost-flat.css +10 -0
- data/vendor/assets/stylesheets/uikit/components/upload.almost-flat.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/upload.css +10 -0
- data/vendor/assets/stylesheets/uikit/components/upload.gradient.css +10 -0
- data/vendor/assets/stylesheets/uikit/components/upload.gradient.min.css +2 -0
- data/vendor/assets/stylesheets/uikit/components/upload.min.css +2 -0
- metadata +295 -0
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! UIkit 2.22.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-grid",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";function i(t){return e(t)}t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).data("ukFilter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.updateLayout()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.updateLayout()}),t.$html.on("changed.uk.dom",function(){i.updateLayout()}),this.options.filter!==!1?this.filter(this.options.filter):this.updateLayout()},_prepareElements:function(){var t,i=this.element.children(":not([data-grid-prepared])");i.length&&(t={position:"absolute","box-sizing":"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-left"]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-left",-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},updateLayout:function(e){this._prepareElements(),e=e||this.element.children(":visible");var n,r,o,a,s,d,h,u,l=e,f=this.element.width()+2*this.gutterh+2,c=0,p=0,g=[];this.trigger("beforeupdate.uk.grid",[l]),l.each(function(){for(u=i(this),n=t.$(this),r=u.outerWidth,o=u.outerHeight,c=0,p=0,s=0,h=g.length;h>s;s++)a=g[s],c<=a.aX&&(c=a.aX),c+r>f&&(c=0),p<=a.aY&&(p=a.aY);g.push({ele:n,top:p,left:c,width:r,height:o,aY:p+o,aX:c+r})});var m,v=0;for(s=0,h=g.length;h>s;s++){for(a=g[s],p=0,d=0;s>d;d++)m=g[d],a.left<m.aX&&m.left+1<a.aX&&(p=m.aY);a.top=p,a.aY=p+a.height,v=Math.max(v,a.aY)}v-=this.gutterv,this.options.animation?(this.element.stop().animate({height:v},100),g.forEach(function(t){t.ele.stop().animate({top:t.top,left:t.left,opacity:1},this.options.duration)}.bind(this))):(this.element.css("height",v),g.forEach(function(t){t.ele.css({top:t.top,left:t.left,opacity:1})}.bind(this))),setTimeout(function(){t.$doc.trigger("scrolling.uk.document")},2*this.options.duration*(this.options.animation?1:0)),this.trigger("afterupdate.uk.grid",[l])},filter:function(i){this.currentfilter=i,i=i||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()}));var e=this,n=this.element.children(),r={visible:[],hidden:[]};n.each(function(){var e=t.$(this),n=e.attr("data-uk-filter"),o=i.length?!1:!0;n&&(n=n.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){n.indexOf(t)>-1&&(o=!0)})),r[o?"visible":"hidden"].push(e)}),r.hidden=t.$(r.hidden).map(function(){return this[0]}),r.visible=t.$(r.visible).map(function(){return this[0]}),r.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),r.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.updateLayout(r.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,r){return n=t.$(n),r=t.$(r),(r.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.updateLayout(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}});var e=function(){function t(t){if(t){if("string"==typeof u[t])return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var i,e=0,n=h.length;n>e;e++)if(i=h[e]+t,"string"==typeof u[i])return i}}function i(t){var i=parseFloat(t),e=-1===t.indexOf("%")&&!isNaN(i);return e&&i}function e(){}function n(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0,e=f.length;e>i;i++){var n=f[i];t[n]=0}return t}function r(){if(!c){c=!0;var e=window.getComputedStyle;if(a=function(){var t=e?function(t){return e(t,null)}:function(t){return t.currentStyle};return function(i){var e=t(i);return e||l("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}}(),s=t("boxSizing")){var n=document.createElement("div");n.style.width="200px",n.style.padding="1px 2px 3px 4px",n.style.borderStyle="solid",n.style.borderWidth="1px 2px 3px 4px",n.style[s]="border-box";var r=document.body||document.documentElement;r.appendChild(n);var o=a(n);d=200===i(o.width),r.removeChild(n)}}}function o(t){if(r(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var e=a(t);if("none"===e.display)return n();var o={};o.width=t.offsetWidth,o.height=t.offsetHeight;for(var h=o.isBorderBox=!(!s||!e[s]||"border-box"!==e[s]),u=0,l=f.length;l>u;u++){var c=f[u],p=e[c],g=parseFloat(p);o[c]=isNaN(g)?0:g}var m=o.paddingLeft+o.paddingRight,v=o.paddingTop+o.paddingBottom,b=o.marginLeft+o.marginRight,y=o.marginTop+o.marginBottom,k=o.borderLeftWidth+o.borderRightWidth,w=o.borderTopWidth+o.borderBottomWidth,x=h&&d,W=i(e.width);W!==!1&&(o.width=W+(x?0:m+k));var L=i(e.height);return L!==!1&&(o.height=L+(x?0:v+w)),o.innerWidth=o.width-(m+k),o.innerHeight=o.height-(v+w),o.outerWidth=o.width+b,o.outerHeight=o.height+y,o}}var a,s,d,h="Webkit Moz ms Ms O".split(" "),u=document.documentElement.style,l="undefined"==typeof console?e:function(t){console.error(t)},f=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],c=!1;return o}()});
|
@@ -0,0 +1,623 @@
|
|
1
|
+
/*! UIkit 2.22.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(addon) {
|
3
|
+
|
4
|
+
var component;
|
5
|
+
|
6
|
+
if (window.UIkit) {
|
7
|
+
component = addon(UIkit);
|
8
|
+
}
|
9
|
+
|
10
|
+
if (typeof define == "function" && define.amd) {
|
11
|
+
define("uikit-htmleditor", ["uikit"], function(){
|
12
|
+
return component || addon(UIkit);
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
})(function(UI) {
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
var editors = [];
|
21
|
+
|
22
|
+
UI.component('htmleditor', {
|
23
|
+
|
24
|
+
defaults: {
|
25
|
+
iframe : false,
|
26
|
+
mode : 'split',
|
27
|
+
markdown : false,
|
28
|
+
autocomplete : true,
|
29
|
+
height : 500,
|
30
|
+
maxsplitsize : 1000,
|
31
|
+
codemirror : { mode: 'htmlmixed', lineWrapping: true, dragDrop: false, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: {completionSingle:false} },
|
32
|
+
toolbar : [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ],
|
33
|
+
lblPreview : 'Preview',
|
34
|
+
lblCodeview : 'HTML',
|
35
|
+
lblMarkedview: 'Markdown'
|
36
|
+
},
|
37
|
+
|
38
|
+
boot: function() {
|
39
|
+
|
40
|
+
// init code
|
41
|
+
UI.ready(function(context) {
|
42
|
+
|
43
|
+
UI.$('textarea[data-uk-htmleditor]', context).each(function() {
|
44
|
+
|
45
|
+
var editor = UI.$(this);
|
46
|
+
|
47
|
+
if (!editor.data('htmleditor')) {
|
48
|
+
UI.htmleditor(editor, UI.Utils.options(editor.attr('data-uk-htmleditor')));
|
49
|
+
}
|
50
|
+
});
|
51
|
+
});
|
52
|
+
},
|
53
|
+
|
54
|
+
init: function() {
|
55
|
+
|
56
|
+
var $this = this, tpl = UI.components.htmleditor.template;
|
57
|
+
|
58
|
+
this.CodeMirror = this.options.CodeMirror || CodeMirror;
|
59
|
+
this.buttons = {};
|
60
|
+
|
61
|
+
tpl = tpl.replace(/\{:lblPreview}/g, this.options.lblPreview);
|
62
|
+
tpl = tpl.replace(/\{:lblCodeview}/g, this.options.lblCodeview);
|
63
|
+
|
64
|
+
this.htmleditor = UI.$(tpl);
|
65
|
+
this.content = this.htmleditor.find('.uk-htmleditor-content');
|
66
|
+
this.toolbar = this.htmleditor.find('.uk-htmleditor-toolbar');
|
67
|
+
this.preview = this.htmleditor.find('.uk-htmleditor-preview').children().eq(0);
|
68
|
+
this.code = this.htmleditor.find('.uk-htmleditor-code');
|
69
|
+
|
70
|
+
this.element.before(this.htmleditor).appendTo(this.code);
|
71
|
+
this.editor = this.CodeMirror.fromTextArea(this.element[0], this.options.codemirror);
|
72
|
+
this.editor.htmleditor = this;
|
73
|
+
this.editor.on('change', UI.Utils.debounce(function() { $this.render(); }, 150));
|
74
|
+
this.editor.on('change', function() {
|
75
|
+
$this.editor.save();
|
76
|
+
$this.element.trigger('input');
|
77
|
+
});
|
78
|
+
this.code.find('.CodeMirror').css('height', this.options.height);
|
79
|
+
|
80
|
+
// iframe mode?
|
81
|
+
if (this.options.iframe) {
|
82
|
+
|
83
|
+
this.iframe = UI.$('<iframe class="uk-htmleditor-iframe" frameborder="0" scrolling="auto" height="100" width="100%"></iframe>');
|
84
|
+
this.preview.append(this.iframe);
|
85
|
+
|
86
|
+
// must open and close document object to start using it!
|
87
|
+
this.iframe[0].contentWindow.document.open();
|
88
|
+
this.iframe[0].contentWindow.document.close();
|
89
|
+
|
90
|
+
this.preview.container = UI.$(this.iframe[0].contentWindow.document).find('body');
|
91
|
+
|
92
|
+
// append custom stylesheet
|
93
|
+
if (typeof(this.options.iframe) === 'string') {
|
94
|
+
this.preview.container.parent().append('<link rel="stylesheet" href="'+this.options.iframe+'">');
|
95
|
+
}
|
96
|
+
|
97
|
+
} else {
|
98
|
+
this.preview.container = this.preview;
|
99
|
+
}
|
100
|
+
|
101
|
+
UI.$win.on('resize load', UI.Utils.debounce(function() { $this.fit(); }, 200));
|
102
|
+
|
103
|
+
var previewContainer = this.iframe ? this.preview.container:$this.preview.parent(),
|
104
|
+
codeContent = this.code.find('.CodeMirror-sizer'),
|
105
|
+
codeScroll = this.code.find('.CodeMirror-scroll').on('scroll', UI.Utils.debounce(function() {
|
106
|
+
|
107
|
+
if ($this.htmleditor.attr('data-mode') == 'tab') return;
|
108
|
+
|
109
|
+
// calc position
|
110
|
+
var codeHeight = codeContent.height() - codeScroll.height(),
|
111
|
+
previewHeight = previewContainer[0].scrollHeight - ($this.iframe ? $this.iframe.height() : previewContainer.height()),
|
112
|
+
ratio = previewHeight / codeHeight,
|
113
|
+
previewPosition = codeScroll.scrollTop() * ratio;
|
114
|
+
|
115
|
+
// apply new scroll
|
116
|
+
previewContainer.scrollTop(previewPosition);
|
117
|
+
|
118
|
+
}, 10));
|
119
|
+
|
120
|
+
this.htmleditor.on('click', '.uk-htmleditor-button-code, .uk-htmleditor-button-preview', function(e) {
|
121
|
+
|
122
|
+
e.preventDefault();
|
123
|
+
|
124
|
+
if ($this.htmleditor.attr('data-mode') == 'tab') {
|
125
|
+
|
126
|
+
$this.htmleditor.find('.uk-htmleditor-button-code, .uk-htmleditor-button-preview').removeClass('uk-active').filter(this).addClass('uk-active');
|
127
|
+
|
128
|
+
$this.activetab = UI.$(this).hasClass('uk-htmleditor-button-code') ? 'code' : 'preview';
|
129
|
+
$this.htmleditor.attr('data-active-tab', $this.activetab);
|
130
|
+
$this.editor.refresh();
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
// toolbar actions
|
135
|
+
this.htmleditor.on('click', 'a[data-htmleditor-button]', function() {
|
136
|
+
|
137
|
+
if (!$this.code.is(':visible')) return;
|
138
|
+
|
139
|
+
$this.trigger('action.' + UI.$(this).data('htmleditor-button'), [$this.editor]);
|
140
|
+
});
|
141
|
+
|
142
|
+
this.preview.parent().css('height', this.code.height());
|
143
|
+
|
144
|
+
// autocomplete
|
145
|
+
if (this.options.autocomplete && this.CodeMirror.showHint && this.CodeMirror.hint && this.CodeMirror.hint.html) {
|
146
|
+
|
147
|
+
this.editor.on('inputRead', UI.Utils.debounce(function() {
|
148
|
+
var doc = $this.editor.getDoc(), POS = doc.getCursor(), mode = $this.CodeMirror.innerMode($this.editor.getMode(), $this.editor.getTokenAt(POS).state).mode.name;
|
149
|
+
|
150
|
+
if (mode == 'xml') { //html depends on xml
|
151
|
+
|
152
|
+
var cur = $this.editor.getCursor(), token = $this.editor.getTokenAt(cur);
|
153
|
+
|
154
|
+
if (token.string.charAt(0) == '<' || token.type == 'attribute') {
|
155
|
+
$this.CodeMirror.showHint($this.editor, $this.CodeMirror.hint.html, { completeSingle: false });
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}, 100));
|
159
|
+
}
|
160
|
+
|
161
|
+
this.debouncedRedraw = UI.Utils.debounce(function () { $this.redraw(); }, 5);
|
162
|
+
|
163
|
+
this.on('init.uk.component', function() {
|
164
|
+
$this.debouncedRedraw();
|
165
|
+
});
|
166
|
+
|
167
|
+
this.element.attr('data-uk-check-display', 1).on('display.uk.check', function(e) {
|
168
|
+
if (this.htmleditor.is(":visible")) this.fit();
|
169
|
+
}.bind(this));
|
170
|
+
|
171
|
+
editors.push(this);
|
172
|
+
},
|
173
|
+
|
174
|
+
addButton: function(name, button) {
|
175
|
+
this.buttons[name] = button;
|
176
|
+
},
|
177
|
+
|
178
|
+
addButtons: function(buttons) {
|
179
|
+
UI.$.extend(this.buttons, buttons);
|
180
|
+
},
|
181
|
+
|
182
|
+
replaceInPreview: function(regexp, callback) {
|
183
|
+
|
184
|
+
var editor = this.editor, results = [], value = editor.getValue(), offset = -1, index = 0;
|
185
|
+
|
186
|
+
this.currentvalue = this.currentvalue.replace(regexp, function() {
|
187
|
+
|
188
|
+
offset = value.indexOf(arguments[0], ++offset);
|
189
|
+
|
190
|
+
var match = {
|
191
|
+
matches: arguments,
|
192
|
+
from : translateOffset(offset),
|
193
|
+
to : translateOffset(offset + arguments[0].length),
|
194
|
+
replace: function(value) {
|
195
|
+
editor.replaceRange(value, match.from, match.to);
|
196
|
+
},
|
197
|
+
inRange: function(cursor) {
|
198
|
+
|
199
|
+
if (cursor.line === match.from.line && cursor.line === match.to.line) {
|
200
|
+
return cursor.ch >= match.from.ch && cursor.ch < match.to.ch;
|
201
|
+
}
|
202
|
+
|
203
|
+
return (cursor.line === match.from.line && cursor.ch >= match.from.ch) ||
|
204
|
+
(cursor.line > match.from.line && cursor.line < match.to.line) ||
|
205
|
+
(cursor.line === match.to.line && cursor.ch < match.to.ch);
|
206
|
+
}
|
207
|
+
};
|
208
|
+
|
209
|
+
var result = callback(match, index);
|
210
|
+
|
211
|
+
if (!result) {
|
212
|
+
return arguments[0];
|
213
|
+
}
|
214
|
+
|
215
|
+
index++;
|
216
|
+
|
217
|
+
results.push(match);
|
218
|
+
return result;
|
219
|
+
});
|
220
|
+
|
221
|
+
function translateOffset(offset) {
|
222
|
+
var result = editor.getValue().substring(0, offset).split('\n');
|
223
|
+
return { line: result.length - 1, ch: result[result.length - 1].length }
|
224
|
+
}
|
225
|
+
|
226
|
+
return results;
|
227
|
+
},
|
228
|
+
|
229
|
+
_buildtoolbar: function() {
|
230
|
+
|
231
|
+
if (!(this.options.toolbar && this.options.toolbar.length)) return;
|
232
|
+
|
233
|
+
var $this = this, bar = [];
|
234
|
+
|
235
|
+
this.toolbar.empty();
|
236
|
+
|
237
|
+
this.options.toolbar.forEach(function(button) {
|
238
|
+
if (!$this.buttons[button]) return;
|
239
|
+
|
240
|
+
var title = $this.buttons[button].title ? $this.buttons[button].title : button;
|
241
|
+
|
242
|
+
bar.push('<li><a data-htmleditor-button="'+button+'" title="'+title+'" data-uk-tooltip>'+$this.buttons[button].label+'</a></li>');
|
243
|
+
});
|
244
|
+
|
245
|
+
this.toolbar.html(bar.join('\n'));
|
246
|
+
},
|
247
|
+
|
248
|
+
fit: function() {
|
249
|
+
|
250
|
+
var mode = this.options.mode;
|
251
|
+
|
252
|
+
if (mode == 'split' && this.htmleditor.width() < this.options.maxsplitsize) {
|
253
|
+
mode = 'tab';
|
254
|
+
}
|
255
|
+
|
256
|
+
if (mode == 'tab') {
|
257
|
+
if (!this.activetab) {
|
258
|
+
this.activetab = 'code';
|
259
|
+
this.htmleditor.attr('data-active-tab', this.activetab);
|
260
|
+
}
|
261
|
+
|
262
|
+
this.htmleditor.find('.uk-htmleditor-button-code, .uk-htmleditor-button-preview').removeClass('uk-active')
|
263
|
+
.filter(this.activetab == 'code' ? '.uk-htmleditor-button-code' : '.uk-htmleditor-button-preview')
|
264
|
+
.addClass('uk-active');
|
265
|
+
}
|
266
|
+
|
267
|
+
this.editor.refresh();
|
268
|
+
this.preview.parent().css('height', this.code.height());
|
269
|
+
|
270
|
+
this.htmleditor.attr('data-mode', mode);
|
271
|
+
},
|
272
|
+
|
273
|
+
redraw: function() {
|
274
|
+
this._buildtoolbar();
|
275
|
+
this.render();
|
276
|
+
this.fit();
|
277
|
+
},
|
278
|
+
|
279
|
+
getMode: function() {
|
280
|
+
return this.editor.getOption('mode');
|
281
|
+
},
|
282
|
+
|
283
|
+
getCursorMode: function() {
|
284
|
+
var param = { mode: 'html'};
|
285
|
+
this.trigger('cursorMode', [param]);
|
286
|
+
return param.mode;
|
287
|
+
},
|
288
|
+
|
289
|
+
render: function() {
|
290
|
+
|
291
|
+
this.currentvalue = this.editor.getValue();
|
292
|
+
|
293
|
+
// empty code
|
294
|
+
if (!this.currentvalue) {
|
295
|
+
|
296
|
+
this.element.val('');
|
297
|
+
this.preview.container.html('');
|
298
|
+
|
299
|
+
return;
|
300
|
+
}
|
301
|
+
|
302
|
+
this.trigger('render', [this]);
|
303
|
+
this.trigger('renderLate', [this]);
|
304
|
+
|
305
|
+
this.preview.container.html(this.currentvalue);
|
306
|
+
},
|
307
|
+
|
308
|
+
addShortcut: function(name, callback) {
|
309
|
+
var map = {};
|
310
|
+
if (!UI.$.isArray(name)) {
|
311
|
+
name = [name];
|
312
|
+
}
|
313
|
+
|
314
|
+
name.forEach(function(key) {
|
315
|
+
map[key] = callback;
|
316
|
+
});
|
317
|
+
|
318
|
+
this.editor.addKeyMap(map);
|
319
|
+
|
320
|
+
return map;
|
321
|
+
},
|
322
|
+
|
323
|
+
addShortcutAction: function(action, shortcuts) {
|
324
|
+
var editor = this;
|
325
|
+
this.addShortcut(shortcuts, function() {
|
326
|
+
editor.element.trigger('action.' + action, [editor.editor]);
|
327
|
+
});
|
328
|
+
},
|
329
|
+
|
330
|
+
replaceSelection: function(replace) {
|
331
|
+
|
332
|
+
var text = this.editor.getSelection();
|
333
|
+
|
334
|
+
if (!text.length) {
|
335
|
+
|
336
|
+
var cur = this.editor.getCursor(),
|
337
|
+
curLine = this.editor.getLine(cur.line),
|
338
|
+
start = cur.ch,
|
339
|
+
end = start;
|
340
|
+
|
341
|
+
while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end;
|
342
|
+
while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start;
|
343
|
+
|
344
|
+
var curWord = start != end && curLine.slice(start, end);
|
345
|
+
|
346
|
+
if (curWord) {
|
347
|
+
this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end });
|
348
|
+
text = curWord;
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
var html = replace.replace('$1', text);
|
353
|
+
|
354
|
+
this.editor.replaceSelection(html, 'end');
|
355
|
+
this.editor.focus();
|
356
|
+
},
|
357
|
+
|
358
|
+
replaceLine: function(replace) {
|
359
|
+
var pos = this.editor.getDoc().getCursor(),
|
360
|
+
text = this.editor.getLine(pos.line),
|
361
|
+
html = replace.replace('$1', text);
|
362
|
+
|
363
|
+
this.editor.replaceRange(html , { line: pos.line, ch: 0 }, { line: pos.line, ch: text.length });
|
364
|
+
this.editor.setCursor({ line: pos.line, ch: html.length });
|
365
|
+
this.editor.focus();
|
366
|
+
},
|
367
|
+
|
368
|
+
save: function() {
|
369
|
+
this.editor.save();
|
370
|
+
}
|
371
|
+
});
|
372
|
+
|
373
|
+
|
374
|
+
UI.components.htmleditor.template = [
|
375
|
+
'<div class="uk-htmleditor uk-clearfix" data-mode="split">',
|
376
|
+
'<div class="uk-htmleditor-navbar">',
|
377
|
+
'<ul class="uk-htmleditor-navbar-nav uk-htmleditor-toolbar"></ul>',
|
378
|
+
'<div class="uk-htmleditor-navbar-flip">',
|
379
|
+
'<ul class="uk-htmleditor-navbar-nav">',
|
380
|
+
'<li class="uk-htmleditor-button-code"><a>{:lblCodeview}</a></li>',
|
381
|
+
'<li class="uk-htmleditor-button-preview"><a>{:lblPreview}</a></li>',
|
382
|
+
'<li><a data-htmleditor-button="fullscreen"><i class="uk-icon-expand"></i></a></li>',
|
383
|
+
'</ul>',
|
384
|
+
'</div>',
|
385
|
+
'</div>',
|
386
|
+
'<div class="uk-htmleditor-content">',
|
387
|
+
'<div class="uk-htmleditor-code"></div>',
|
388
|
+
'<div class="uk-htmleditor-preview"><div></div></div>',
|
389
|
+
'</div>',
|
390
|
+
'</div>'
|
391
|
+
].join('');
|
392
|
+
|
393
|
+
|
394
|
+
UI.plugin('htmleditor', 'base', {
|
395
|
+
|
396
|
+
init: function(editor) {
|
397
|
+
|
398
|
+
editor.addButtons({
|
399
|
+
|
400
|
+
fullscreen: {
|
401
|
+
title : 'Fullscreen',
|
402
|
+
label : '<i class="uk-icon-expand"></i>'
|
403
|
+
},
|
404
|
+
bold : {
|
405
|
+
title : 'Bold',
|
406
|
+
label : '<i class="uk-icon-bold"></i>'
|
407
|
+
},
|
408
|
+
italic : {
|
409
|
+
title : 'Italic',
|
410
|
+
label : '<i class="uk-icon-italic"></i>'
|
411
|
+
},
|
412
|
+
strike : {
|
413
|
+
title : 'Strikethrough',
|
414
|
+
label : '<i class="uk-icon-strikethrough"></i>'
|
415
|
+
},
|
416
|
+
blockquote : {
|
417
|
+
title : 'Blockquote',
|
418
|
+
label : '<i class="uk-icon-quote-right"></i>'
|
419
|
+
},
|
420
|
+
link : {
|
421
|
+
title : 'Link',
|
422
|
+
label : '<i class="uk-icon-link"></i>'
|
423
|
+
},
|
424
|
+
image : {
|
425
|
+
title : 'Image',
|
426
|
+
label : '<i class="uk-icon-picture-o"></i>'
|
427
|
+
},
|
428
|
+
listUl : {
|
429
|
+
title : 'Unordered List',
|
430
|
+
label : '<i class="uk-icon-list-ul"></i>'
|
431
|
+
},
|
432
|
+
listOl : {
|
433
|
+
title : 'Ordered List',
|
434
|
+
label : '<i class="uk-icon-list-ol"></i>'
|
435
|
+
}
|
436
|
+
|
437
|
+
});
|
438
|
+
|
439
|
+
addAction('bold', '<strong>$1</strong>');
|
440
|
+
addAction('italic', '<em>$1</em>');
|
441
|
+
addAction('strike', '<del>$1</del>');
|
442
|
+
addAction('blockquote', '<blockquote><p>$1</p></blockquote>', 'replaceLine');
|
443
|
+
addAction('link', '<a href="http://">$1</a>');
|
444
|
+
addAction('image', '<img src="http://" alt="$1">');
|
445
|
+
|
446
|
+
var listfn = function() {
|
447
|
+
if (editor.getCursorMode() == 'html') {
|
448
|
+
|
449
|
+
var cm = editor.editor,
|
450
|
+
pos = cm.getDoc().getCursor(true),
|
451
|
+
posend = cm.getDoc().getCursor(false);
|
452
|
+
|
453
|
+
for (var i=pos.line; i<(posend.line+1);i++) {
|
454
|
+
cm.replaceRange('<li>'+cm.getLine(i)+'</li>', { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
|
455
|
+
}
|
456
|
+
|
457
|
+
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
|
458
|
+
cm.focus();
|
459
|
+
}
|
460
|
+
};
|
461
|
+
|
462
|
+
editor.on('action.listUl', function() {
|
463
|
+
listfn();
|
464
|
+
});
|
465
|
+
|
466
|
+
editor.on('action.listOl', function() {
|
467
|
+
listfn();
|
468
|
+
});
|
469
|
+
|
470
|
+
editor.htmleditor.on('click', 'a[data-htmleditor-button="fullscreen"]', function() {
|
471
|
+
editor.htmleditor.toggleClass('uk-htmleditor-fullscreen');
|
472
|
+
|
473
|
+
var wrap = editor.editor.getWrapperElement();
|
474
|
+
|
475
|
+
if (editor.htmleditor.hasClass('uk-htmleditor-fullscreen')) {
|
476
|
+
|
477
|
+
editor.editor.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: wrap.style.width, height: wrap.style.height};
|
478
|
+
wrap.style.width = '';
|
479
|
+
wrap.style.height = editor.content.height()+'px';
|
480
|
+
document.documentElement.style.overflow = 'hidden';
|
481
|
+
|
482
|
+
} else {
|
483
|
+
|
484
|
+
document.documentElement.style.overflow = '';
|
485
|
+
var info = editor.editor.state.fullScreenRestore;
|
486
|
+
wrap.style.width = info.width; wrap.style.height = info.height;
|
487
|
+
window.scrollTo(info.scrollLeft, info.scrollTop);
|
488
|
+
}
|
489
|
+
|
490
|
+
setTimeout(function() {
|
491
|
+
editor.fit();
|
492
|
+
UI.$win.trigger('resize');
|
493
|
+
}, 50);
|
494
|
+
});
|
495
|
+
|
496
|
+
editor.addShortcut(['Ctrl-S', 'Cmd-S'], function() { editor.element.trigger('htmleditor-save', [editor]); });
|
497
|
+
editor.addShortcutAction('bold', ['Ctrl-B', 'Cmd-B']);
|
498
|
+
|
499
|
+
function addAction(name, replace, mode) {
|
500
|
+
editor.on('action.'+name, function() {
|
501
|
+
if (editor.getCursorMode() == 'html') {
|
502
|
+
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace);
|
503
|
+
}
|
504
|
+
});
|
505
|
+
}
|
506
|
+
}
|
507
|
+
});
|
508
|
+
|
509
|
+
UI.plugin('htmleditor', 'markdown', {
|
510
|
+
|
511
|
+
init: function(editor) {
|
512
|
+
|
513
|
+
var parser = editor.options.mdparser || marked || null;
|
514
|
+
|
515
|
+
if (!parser) return;
|
516
|
+
|
517
|
+
if (editor.options.markdown) {
|
518
|
+
enableMarkdown();
|
519
|
+
}
|
520
|
+
|
521
|
+
addAction('bold', '**$1**');
|
522
|
+
addAction('italic', '*$1*');
|
523
|
+
addAction('strike', '~~$1~~');
|
524
|
+
addAction('blockquote', '> $1', 'replaceLine');
|
525
|
+
addAction('link', '[$1](http://)');
|
526
|
+
addAction('image', '![$1](http://)');
|
527
|
+
|
528
|
+
editor.on('action.listUl', function() {
|
529
|
+
|
530
|
+
if (editor.getCursorMode() == 'markdown') {
|
531
|
+
|
532
|
+
var cm = editor.editor,
|
533
|
+
pos = cm.getDoc().getCursor(true),
|
534
|
+
posend = cm.getDoc().getCursor(false);
|
535
|
+
|
536
|
+
for (var i=pos.line; i<(posend.line+1);i++) {
|
537
|
+
cm.replaceRange('* '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
|
538
|
+
}
|
539
|
+
|
540
|
+
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
|
541
|
+
cm.focus();
|
542
|
+
}
|
543
|
+
});
|
544
|
+
|
545
|
+
editor.on('action.listOl', function() {
|
546
|
+
|
547
|
+
if (editor.getCursorMode() == 'markdown') {
|
548
|
+
|
549
|
+
var cm = editor.editor,
|
550
|
+
pos = cm.getDoc().getCursor(true),
|
551
|
+
posend = cm.getDoc().getCursor(false),
|
552
|
+
prefix = 1;
|
553
|
+
|
554
|
+
if (pos.line > 0) {
|
555
|
+
var prevline = cm.getLine(pos.line-1), matches;
|
556
|
+
|
557
|
+
if(matches = prevline.match(/^(\d+)\./)) {
|
558
|
+
prefix = Number(matches[1])+1;
|
559
|
+
}
|
560
|
+
}
|
561
|
+
|
562
|
+
for (var i=pos.line; i<(posend.line+1);i++) {
|
563
|
+
cm.replaceRange(prefix+'. '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
|
564
|
+
prefix++;
|
565
|
+
}
|
566
|
+
|
567
|
+
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
|
568
|
+
cm.focus();
|
569
|
+
}
|
570
|
+
});
|
571
|
+
|
572
|
+
editor.on('renderLate', function() {
|
573
|
+
if (editor.editor.options.mode == 'gfm') {
|
574
|
+
editor.currentvalue = parser(editor.currentvalue);
|
575
|
+
}
|
576
|
+
});
|
577
|
+
|
578
|
+
editor.on('cursorMode', function(e, param) {
|
579
|
+
if (editor.editor.options.mode == 'gfm') {
|
580
|
+
var pos = editor.editor.getDoc().getCursor();
|
581
|
+
if (!editor.editor.getTokenAt(pos).state.base.htmlState) {
|
582
|
+
param.mode = 'markdown';
|
583
|
+
}
|
584
|
+
}
|
585
|
+
});
|
586
|
+
|
587
|
+
UI.$.extend(editor, {
|
588
|
+
|
589
|
+
enableMarkdown: function() {
|
590
|
+
enableMarkdown();
|
591
|
+
this.render();
|
592
|
+
},
|
593
|
+
disableMarkdown: function() {
|
594
|
+
this.editor.setOption('mode', 'htmlmixed');
|
595
|
+
this.htmleditor.find('.uk-htmleditor-button-code a').html(this.options.lblCodeview);
|
596
|
+
this.render();
|
597
|
+
}
|
598
|
+
|
599
|
+
});
|
600
|
+
|
601
|
+
// switch markdown mode on event
|
602
|
+
editor.on({
|
603
|
+
enableMarkdown : function() { editor.enableMarkdown(); },
|
604
|
+
disableMarkdown : function() { editor.disableMarkdown(); }
|
605
|
+
});
|
606
|
+
|
607
|
+
function enableMarkdown() {
|
608
|
+
editor.editor.setOption('mode', 'gfm');
|
609
|
+
editor.htmleditor.find('.uk-htmleditor-button-code a').html(editor.options.lblMarkedview);
|
610
|
+
}
|
611
|
+
|
612
|
+
function addAction(name, replace, mode) {
|
613
|
+
editor.on('action.'+name, function() {
|
614
|
+
if (editor.getCursorMode() == 'markdown') {
|
615
|
+
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace);
|
616
|
+
}
|
617
|
+
});
|
618
|
+
}
|
619
|
+
}
|
620
|
+
});
|
621
|
+
|
622
|
+
return UI.htmleditor;
|
623
|
+
});
|