rails-uikit-sass 2.27.2

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