torba-rails 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +24 -2
  5. data/CHANGELOG.md +7 -0
  6. data/CONTRIBUTING.md +7 -1
  7. data/README.md +1 -1
  8. data/Rakefile +9 -17
  9. data/lib/torba/rails.rb +7 -3
  10. data/test/3.2/Gemfile +2 -1
  11. data/test/3.2/Torbafile +1 -0
  12. data/test/3.2/app/assets/javascripts/application.js +1 -0
  13. data/test/3.2/app/assets/stylesheets/application.scss +1 -0
  14. data/test/3.2/bin/rails +1 -0
  15. data/test/4.1/Gemfile +2 -1
  16. data/test/4.1/Torbafile +1 -0
  17. data/test/4.1/app/assets/javascripts/application.js +1 -0
  18. data/test/4.1/app/assets/stylesheets/application.scss +1 -0
  19. data/test/4.2/Gemfile +2 -1
  20. data/test/4.2/Torbafile +1 -0
  21. data/test/4.2/app/assets/javascripts/application.js +1 -0
  22. data/test/4.2/app/assets/stylesheets/application.scss +1 -0
  23. data/test/5.0/Gemfile +2 -1
  24. data/test/5.0/Torbafile +1 -0
  25. data/test/5.0/app/assets/javascripts/application.js +1 -0
  26. data/test/5.0/app/assets/stylesheets/application.scss +1 -0
  27. data/test/5.1/.gitignore +14 -0
  28. data/test/5.1/Gemfile +11 -0
  29. data/test/5.1/Rakefile +6 -0
  30. data/test/5.1/Torbafile +1 -0
  31. data/test/5.1/app/assets/config/manifest.js +3 -0
  32. data/test/5.1/app/assets/javascripts/application.js +1 -0
  33. data/test/5.1/app/assets/stylesheets/application.scss +1 -0
  34. data/test/5.1/app/controllers/application_controller.rb +3 -0
  35. data/test/5.1/app/helpers/application_helper.rb +2 -0
  36. data/test/5.1/app/views/layouts/application.html.erb +14 -0
  37. data/test/5.1/bin/rails +4 -0
  38. data/test/5.1/config.ru +5 -0
  39. data/test/5.1/config/application.rb +23 -0
  40. data/test/5.1/config/boot.rb +3 -0
  41. data/test/5.1/config/environment.rb +5 -0
  42. data/test/5.1/config/environments/development.rb +46 -0
  43. data/test/5.1/config/environments/production.rb +79 -0
  44. data/test/5.1/config/environments/test.rb +36 -0
  45. data/test/5.1/config/initializers/application_controller_renderer.rb +8 -0
  46. data/test/5.1/config/initializers/assets.rb +12 -0
  47. data/test/5.1/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/5.1/config/initializers/cookies_serializer.rb +5 -0
  49. data/test/5.1/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/5.1/config/initializers/inflections.rb +16 -0
  51. data/test/5.1/config/initializers/mime_types.rb +4 -0
  52. data/test/5.1/config/initializers/wrap_parameters.rb +9 -0
  53. data/test/5.1/config/locales/en.yml +33 -0
  54. data/test/5.1/config/routes.rb +3 -0
  55. data/test/5.1/config/secrets.yml +32 -0
  56. data/test/acceptance_test.rb +6 -1
  57. data/test/compiled_assets/3.2/{application-406b208e73b83fe37135274c5157c8e3.css → application-%2A.css} +0 -0
  58. data/test/compiled_assets/3.2/application-%2A.js +1 -0
  59. data/test/compiled_assets/3.2/trumbowyg/{icons-0b2826fbd974348c269c2b8017a14314.png → icons-%3F%3F%5B%5E-%5D%2A.png} +0 -0
  60. data/test/compiled_assets/3.2/trumbowyg/{icons-2x-cc69d8bc62651602e75c2f7097cf5187.png → icons-2x-%2A.png} +0 -0
  61. data/test/compiled_assets/4.1/{application-b93806e6555eb26989308c4d06311423.css → application-%2A.css} +0 -0
  62. data/test/compiled_assets/4.1/application-%2A.js +1 -0
  63. data/test/compiled_assets/4.1/trumbowyg/{icons-60fe5a8fdf8b247fe07ca2454df66f80.png → icons-%3F%3F%5B%5E-%5D%2A.png} +0 -0
  64. data/test/compiled_assets/4.1/trumbowyg/{icons-2x-0977e4f2195ed320a8dcc57e194af523.png → icons-2x-%2A.png} +0 -0
  65. data/test/compiled_assets/4.2+/{application-7cdb22c682ee9bf44774492034be6952becd2c75184c101017152af1476b12a8.css → application-%2A.css} +0 -0
  66. data/test/compiled_assets/4.2+/application-%2A.js +1 -0
  67. data/test/compiled_assets/4.2+/trumbowyg/{icons-efc940454e4e764063875def5c909a2f9c8b2c4d2a41c6a98dc41fb111868f1f.png → icons-%3F%3F%5B%5E-%5D%2A.png} +0 -0
  68. data/test/compiled_assets/4.2+/trumbowyg/{icons-2x-39fe92cd396082eb94f0c92103537209ba97ffa3079377bbe55fea857abe5341.png → icons-2x-%2A.png} +0 -0
  69. data/test/environment.rb +6 -0
  70. data/test/rake_injector/lib/rake_injector.rb +6 -0
  71. data/test/rake_injector/rake_injector.gemspec +13 -0
  72. data/test/test_helper.rb +1 -0
  73. data/torba-rails.gemspec +2 -2
  74. metadata +94 -38
  75. data/test/3.2/Gemfile.lock +0 -116
  76. data/test/3.2/Torbafile +0 -8
  77. data/test/3.2/app/assets/javascripts/application.js +0 -2
  78. data/test/3.2/app/assets/stylesheets/application.scss +0 -6
  79. data/test/3.2/bin/rails +0 -6
  80. data/test/4.1/Gemfile.lock +0 -113
  81. data/test/4.1/Torbafile +0 -8
  82. data/test/4.1/app/assets/javascripts/application.js +0 -2
  83. data/test/4.1/app/assets/stylesheets/application.scss +0 -6
  84. data/test/4.2/Gemfile.lock +0 -128
  85. data/test/4.2/Torbafile +0 -8
  86. data/test/4.2/app/assets/javascripts/application.js +0 -2
  87. data/test/4.2/app/assets/stylesheets/application.scss +0 -6
  88. data/test/5.0/Gemfile.lock +0 -138
  89. data/test/5.0/Torbafile +0 -8
  90. data/test/5.0/app/assets/javascripts/application.js +0 -2
  91. data/test/5.0/app/assets/stylesheets/application.scss +0 -6
  92. data/test/compiled_assets/3.2/application-32cc93d3c658f24842cdb4028d7f6a6a.js +0 -1
  93. data/test/compiled_assets/4.1/application-959396ba4d98dd11cf6ac10b43f7fa97.js +0 -1
  94. data/test/compiled_assets/4.2+/application-c7e50f0b91ececdd620e1c86789b65677d9bbe0f35ab4717a9a522e6c89a56f9.js +0 -1
@@ -1,8 +0,0 @@
1
- gh_release "trumbowyg",
2
- source: "torba-rb/Trumbowyg",
3
- tag: "1.1.6",
4
- import: %w[
5
- dist/trumbowyg.js
6
- dist/ui/trumbowyg.css
7
- dist/ui/images/
8
- ]
@@ -1,2 +0,0 @@
1
- //= require trumbowyg/trumbowyg
2
- //= require_tree .
@@ -1,6 +0,0 @@
1
- /*
2
- *= require_self
3
- *= require_tree .
4
- */
5
-
6
- @import "trumbowyg/trumbowyg";
@@ -1 +0,0 @@
1
- jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",insertVideo:"Insert Video",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",fullscreen:"fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",invalidUrl:"Invalid URL",required:"Required",description:"Description",title:"Title",text:"Text"}},opts:{},btnsGrps:{design:["bold","italic","underline","strikethrough"],semantic:["strong","em","del"],justify:["justifyLeft","justifyCenter","justifyRight","justifyFull"],lists:["unorderedList","orderedList"]}},function(e,t,n,o){"use strict";n.fn.trumbowyg=function(e,t){if(e===Object(e)||!e)return this.each(function(){n(this).data("trumbowyg")||n(this).data("trumbowyg",new i(this,e))});if(1===this.length)try{var o=n(this).data("trumbowyg");switch(e){case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveSelection":return o.saveSelection();case"getSelection":return o.selection;case"getSelectedText":return o.selection+"";case"restoreSelection":return o.restoreSelection();case"destroy":return o.destroy();case"empty":return o.empty();case"lang":return o.lang;case"duration":return o.o.duration;case"html":return o.html(t)}}catch(r){}return!1};var i=function(e,o){var i=this;i.doc=e.ownerDocument||t,i.$e=n(e),i.$creator=n(e),o=n.extend(!0,{},o,n.trumbowyg.opts),"undefined"==typeof o.lang||"undefined"==typeof n.trumbowyg.langs[o.lang]?i.lang=n.trumbowyg.langs.en:i.lang=n.extend(!0,{},n.trumbowyg.langs.en,n.trumbowyg.langs[o.lang]),i.o=n.extend(!0,{},{lang:"en",dir:"ltr",duration:200,mobile:!1,tablet:!0,closable:!1,fullscreenable:!0,fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,prefix:"trumbowyg-",convertLink:!0,semantic:!1,resetCss:!1,btns:["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.design,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"],btnsAdd:[],btnsDef:{viewHTML:{func:"toggle"},p:{func:"formatBlock"},blockquote:{func:"formatBlock"},h1:{func:"formatBlock",title:i.lang.header+" 1"},h2:{func:"formatBlock",title:i.lang.header+" 2"},h3:{func:"formatBlock",title:i.lang.header+" 3"},h4:{func:"formatBlock",title:i.lang.header+" 4"},bold:{},italic:{},underline:{},strikethrough:{},strong:{func:"bold"},em:{func:"italic"},del:{func:"strikethrough"},createLink:{},unlink:{},insertImage:{},justifyLeft:{},justifyCenter:{},justifyRight:{},justifyFull:{},unorderedList:{func:"insertUnorderedList"},orderedList:{func:"insertOrderedList"},horizontalRule:{func:"insertHorizontalRule"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"]},link:{dropdown:["createLink","unlink"]}}},o),i.o.semantic&&!o.btns?i.o.btns=["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.semantic,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"]:o&&o.btns&&(i.o.btns=o.btns),i.init()};i.prototype={init:function(){var e=this;return e.height=e.$e.css("height"),e.isEnabled()?void e.buildEditor(!0):(e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),void e.buildOverlay())},buildEditor:function(e){var t=this,o=t.o.prefix,i="";if(e!==!0)t.$box=n("<div/>",{"class":o+"box "+o+t.o.lang+" trumbowyg"}),t.isTextarea=!0,t.$e.is("textarea")?t.$editor=n("<div/>"):(t.$editor=t.$e,t.$e=t.buildTextarea().val(t.$e.val()),t.isTextarea=!1),t.$creator.is("[placeholder]")&&t.$editor.attr("placeholder",t.$creator.attr("placeholder")),t.$e.hide().addClass(o+"textarea"),t.isTextarea?(i=t.$e.val(),t.$box.insertAfter(t.$e).append(t.$editor).append(t.$e)):(i=t.$editor.html(),t.$box.insertAfter(t.$editor).append(t.$e).append(t.$editor),t.syncCode()),t.$editor.addClass(o+"editor").attr("contenteditable",!0).attr("dir",t.lang._dir||t.o.dir).html(i),t.o.resetCss&&t.$editor.addClass(o+"reset-css"),t.o.autogrow||n.each([t.$editor,t.$e],function(e,n){n.css({height:t.height,overflow:"auto"})}),t.o.semantic&&(t.$editor.html(t.$editor.html().replace("<br>","</p><p>").replace("&nbsp;","")),t.semanticCode()),t.$editor.on("dblclick","img",function(e){var o=n(this);t.openModalInsert(t.lang.insertImage,{url:{label:"URL",value:o.attr("src"),required:!0},alt:{label:"description",value:o.attr("alt")}},function(e){o.attr({src:e.url,alt:e.alt})}),e.stopPropagation()}).on("keyup",function(e){t.semanticCode(!1,13===e.which)}).on("focus",function(){t.$creator.trigger("tbwfocus")}).on("blur",function(){t.syncCode(),t.$creator.trigger("tbwblur")});else if(!t.$e.is("textarea")){var r=t.buildTextarea().val(t.$e.val());t.$e.hide().after(r)}},buildTextarea:function(){return n("<textarea/>",{name:this.$e.attr("id"),height:this.height})},buildBtnPane:function(){var t=this,i=t.o.prefix;if(t.o.btns!==!1){t.$btnPane=n("<ul/>",{"class":i+"button-pane"}),n.each(t.o.btns.concat(t.o.btnsAdd),function(e,r){try{var a=r.split("btnGrp-");a[1]!==o&&(r=n.trumbowyg.btnsGrps[a[1]])}catch(s){}n.isArray(r)||(r=[r]),n.each(r,function(e,o){try{var r=n("<li/>");"|"===o?r.addClass(i+"separator"):t.isSupportedBtn(o)&&r.append(t.buildBtn(o)),t.$btnPane.append(r)}catch(a){}})});var r=n("<li/>",{"class":i+"not-disable "+i+"buttons-right"});t.o.fullscreenable&&r.append(t.buildRightBtn("fullscreen").on("click",function(){var o=i+"fullscreen";t.$box.toggleClass(o),t.$box.hasClass(o)?(n("body").css("overflow","hidden"),n.each([t.$editor,t.$e],function(){n(this).css({height:"calc(100% - 35px)",overflow:"auto"})}),t.$btnPane.css("width","100%")):(n("body").css("overflow","auto"),t.$box.removeAttr("style"),t.o.autogrow||n.each([t.$editor,t.$e],function(){n(this).css("height",t.height)})),n(e).trigger("scroll")})),t.o.closable&&r.append(t.buildRightBtn("close").on("click",function(){t.$box.hasClass(i+"fullscreen")&&n("body").css("overflow","auto"),t.destroy()})),r.not(":empty")&&t.$btnPane.append(r),t.$box.prepend(t.$btnPane)}},buildBtn:function(e){var t=this,o=t.o.prefix,i=t.o.btnsDef[e],r=i.dropdown,a=t.lang[e]||e,s=n("<button/>",{type:"button","class":o+e+"-button"+(i.ico?" "+o+i.ico+"-button":""),text:i.text||i.title||a,title:i.title||i.text||a,mousedown:function(a){return r&&!t.$box.find("."+e+"-"+o+"dropdown").is(":hidden")||n("body",t.doc).trigger("mousedown"),!t.$btnPane.hasClass(o+"disable")||n(this).hasClass(o+"active")||n(this).parent().hasClass(o+"not-disable")?(t.execCmd((r?"dropdown":!1)||i.func||e,i.param||e),a.stopPropagation(),void a.preventDefault()):!1}});if(r){s.addClass(o+"open-dropdown");var l=o+"dropdown",d=n("<div/>",{"class":e+"-"+l+" "+l+" "+o+"fixed-top"});n.each(r,function(e,n){t.o.btnsDef[n]&&t.isSupportedBtn(n)&&d.append(t.buildSubBtn(n))}),t.$box.append(d.hide())}return s},buildSubBtn:function(e){var t=this,o=t.o.btnsDef[e];return n("<button/>",{type:"button",text:o.text||o.title||t.lang[e]||e,style:o.style||null,mousedown:function(i){n("body",t.doc).trigger("mousedown"),t.execCmd(o.func||e,o.param||e),i.stopPropagation()}})},buildRightBtn:function(e){return n("<button/>",{type:"button","class":this.o.prefix+e+"-button",title:this.lang[e],text:this.lang[e]})},isSupportedBtn:function(e){var t=this.o.btnsDef[e];return"function"!=typeof t.isSupported||t.isSupported()},buildOverlay:function(){var e=this;return e.$overlay=n("<div/>",{"class":e.o.prefix+"overlay"}).css({top:e.$btnPane.outerHeight(),height:parseInt(e.$editor.outerHeight())+1+"px"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var t=this;n(e).trigger("scroll"),t.$overlay.fadeIn(t.o.duration),t.$box.addClass(t.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(e.o.duration/4),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var t=this,o=t.o.fixedFullWidth;t.o.fixedBtnPane&&(t.isFixed=!1,n(e).on("scroll resize",function(){if(t.$box){t.syncCode();var i=n(e).scrollTop(),r=t.$box.offset().top+1,a=i-r>0&&i-r-parseInt(t.height)<0,s=t.$btnPane,l=s.css("height"),d=s.outerHeight();a?(t.isFixed||(t.isFixed=!0,s.css({position:"fixed",top:0,left:o?"0":"auto",zIndex:7}),n([t.$editor,t.$e]).css({marginTop:l})),s.css({width:o?"100%":parseInt(t.$box.css("width"))-1+"px"}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:o?"fixed":"absolute",top:o?d:parseInt(d)+(i-r)+"px",zIndex:15})):t.isFixed&&(t.isFixed=!1,s.removeAttr("style"),n([t.$editor,t.$e]).css({marginTop:0}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:"absolute",top:d}))}}))},destroy:function(){var e=this,t=e.o.prefix,n=e.height,o=e.html();e.isTextarea?e.$box.after(e.$e.css({height:n}).val(o).removeClass(t+"textarea").show()):e.$box.after(e.$editor.css({height:n}).removeClass(t+"editor").removeAttr("contenteditable").html(o).show()),e.$box.remove(),e.$creator.removeData("trumbowyg")},empty:function(){this.$e.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.semanticCode(!1,!0),e.$editor.toggle(),e.$e.toggle(),e.$btnPane.toggleClass(t+"disable"),e.$btnPane.find("."+t+"viewHTML-button").toggleClass(t+"active")},dropdown:function(t){var o=this,i=o.doc,r=o.o.prefix,a=o.$box.find("."+t+"-"+r+"dropdown"),s=o.$btnPane.find("."+r+t+"-button");if(a.is(":hidden")){var l=s.offset().left;s.addClass(r+"active"),a.css({position:"absolute",top:o.$btnPane.outerHeight(),left:o.o.fixedFullWidth&&o.isFixed?l+"px":l-o.$btnPane.offset().left+"px"}).show(),n(e).trigger("scroll"),n("body",i).on("mousedown",function(){n("."+r+"dropdown",i).hide(),n("."+r+"active",i).removeClass(r+"active"),n("body",i).off("mousedown")})}else n("body",i).trigger("mousedown")},html:function(e){var t=this;return e?(t.$e.val(e),t.syncCode(!0),t):t.$e.val()},syncCode:function(e){var t=this;!e&&t.$editor.is(":visible")?t.$e.val(t.$editor.html()):t.$editor.html(t.$e.val()),t.o.autogrow&&(t.height=t.$editor.css("height"),t.$e.css({height:t.height}))},semanticCode:function(e,t){var o=this;o.syncCode(e),o.o.semantic&&(o.semanticTag("b","strong"),o.semanticTag("i","em"),o.semanticTag("strike","del"),t&&(o.$editor.contents().filter(function(){return 3===this.nodeType&&n.trim(this.nodeValue).length>0}).wrap("<p></p>").end().filter("br").remove(),o.saveSelection(),o.semanticTag("div","p"),o.restoreSelection()),o.$e.val(o.$editor.html()))},semanticTag:function(e,t){n(e,this.$editor).each(function(){n(this).replaceWith(function(){return"<"+t+">"+n(this).html()+"</"+t+">"})})},createLink:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.createLink,{url:{label:"URL",value:"http://",required:!0},title:{label:e.lang.title,value:e.selection},text:{label:e.lang.text,value:e.selection}},function(t){e.execCmd("createLink",t.url);var o=n('a[href="'+t.url+'"]:not([title])',e.$box);return t.text.length>0&&o.text(t.text),t.title.length>0&&o.attr("title",t.title),!0})},insertImage:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.insertImage,{url:{label:"URL",value:"http://",required:!0},alt:{label:e.lang.description,value:e.selection}},function(t){return e.execCmd("insertImage",t.url),n('img[src="'+t.url+'"]:not([alt])',e.$box).attr("alt",t.alt),!0})},execCmd:function(e,t){var n=this;"dropdown"!=e&&n.$editor.focus();try{n[e](t)}catch(o){try{e(t,n)}catch(i){"insertHorizontalRule"==e?t=null:"formatBlock"==e&&(-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0)&&(t="<"+t+">"),n.doc.execCommand(e,!1,t)}}n.syncCode()},openModal:function(t,o){var i=this,r=i.o.prefix;if(n("."+r+"modal-box",i.$box).size()>0)return!1;i.saveSelection(),i.showOverlay(),i.$btnPane.addClass(r+"disable");var a=n("<div/>",{"class":r+"modal "+r+"fixed-top"}).css({top:parseInt(i.$btnPane.css("height"))+1+"px"}).appendTo(i.$box);i.$overlay.one("click",function(e){e.preventDefault(),a.trigger(r+"cancel")});var s=n("<form/>",{action:"",html:o}).on("submit",function(e){e.preventDefault(),a.trigger(r+"confirm")}).on("reset",function(e){e.preventDefault(),a.trigger(r+"cancel")}),l=n("<div/>",{"class":r+"modal-box",html:s}).css({top:"-"+parseInt(i.$btnPane.outerHeight())+"px",opacity:0}).appendTo(a).animate({top:0,opacity:1},i.o.duration/2);return n("<span/>",{text:t,"class":r+"modal-title"}).prependTo(l),l.find("input:first").focus(),i.buildModalBtn("submit",l),i.buildModalBtn("reset",l),n(e).trigger("scroll"),a},buildModalBtn:function(e,t){var o=this,i=o.o.prefix;return n("<button/>",{"class":i+"modal-button "+i+"modal-"+e,type:e,text:o.lang[e]||e}).appendTo(t.find("form"))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var o=n("."+t+"modal-box",e.$box);o.animate({top:"-"+o.css("height")},e.o.duration/2,function(){n(this).parent().remove(),e.hideOverlay()})},openModalInsert:function(e,t,i){var r=this,a=r.o.prefix,s=r.lang,l="";for(var d in t){var c=t[d],u=c.label===o?s[d]?s[d]:d:s[c.label]?s[c.label]:c.label;c.name===o&&(c.name=d),c.pattern||"url"!==d||(c.pattern=/^(http|https):\/\/([\w~#!:.?+=&%@!\-\/]+)$/,c.patternError=s.invalidUrl),l+='<label><input type="'+(c.type||"text")+'" name="'+c.name+'" value="'+(c.value||"")+'"><span class="'+a+'input-infos"><span>'+u+"</span></span></label>"}return r.openModal(e,l).on(a+"confirm",function(){var e=n(this).find("form"),o=!0,s={};for(var l in t){var d=n('input[name="'+l+'"]',e);s[l]=n.trim(d.val()),t[l].required&&""===s[l]?(o=!1,r.addErrorOnModalField(d,r.lang.required)):t[l].pattern&&!t[l].pattern.test(s[l])&&(o=!1,r.addErrorOnModalField(d,t[l].patternError))}o&&(r.restoreSelection(),i(s,t)&&(r.syncCode(),r.closeModal(),n(this).off(a+"confirm")))}).one(a+"cancel",function(){n(this).off(a+"confirm"),r.closeModal(),r.restoreSelection()})},addErrorOnModalField:function(e,t){var o=this.o.prefix,i=e.parent();e.on("change keyup",function(){i.removeClass(o+"input-error")}),i.addClass(o+"input-error").find("input+span").append(n("<span/>",{"class":o+"msg-error",text:t}))},saveSelection:function(){var t=this,n=t.doc;if(t.selection=null,e.getSelection){var o=e.getSelection();o.getRangeAt&&o.rangeCount&&(t.selection=o.getRangeAt(0))}else n.selection&&n.selection.createRange&&(t.selection=n.selection.createRange())},restoreSelection:function(){var t=this,n=t.selection;if(n)if(e.getSelection){var o=e.getSelection();o.removeAllRanges(),o.addRange(n)}else t.doc.selection&&n.select&&n.select()},isEnabled:function(){var e=new RegExp("(iPad|webOS)"),t=new RegExp("(iPhone|iPod|Android|BlackBerry|Windows Phone|ZuneWP7)"),n=navigator.userAgent;return this.o.tablet===!0&&e.test(n)||this.o.mobile===!0&&t.test(n)}}}(window,document,jQuery);
@@ -1 +0,0 @@
1
- jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",insertVideo:"Insert Video",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",fullscreen:"fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",invalidUrl:"Invalid URL",required:"Required",description:"Description",title:"Title",text:"Text"}},opts:{},btnsGrps:{design:["bold","italic","underline","strikethrough"],semantic:["strong","em","del"],justify:["justifyLeft","justifyCenter","justifyRight","justifyFull"],lists:["unorderedList","orderedList"]}},function(e,t,n,o){"use strict";n.fn.trumbowyg=function(e,t){if(e===Object(e)||!e)return this.each(function(){n(this).data("trumbowyg")||n(this).data("trumbowyg",new i(this,e))});if(1===this.length)try{var o=n(this).data("trumbowyg");switch(e){case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveSelection":return o.saveSelection();case"getSelection":return o.selection;case"getSelectedText":return o.selection+"";case"restoreSelection":return o.restoreSelection();case"destroy":return o.destroy();case"empty":return o.empty();case"lang":return o.lang;case"duration":return o.o.duration;case"html":return o.html(t)}}catch(r){}return!1};var i=function(e,o){var i=this;i.doc=e.ownerDocument||t,i.$e=n(e),i.$creator=n(e),o=n.extend(!0,{},o,n.trumbowyg.opts),"undefined"==typeof o.lang||"undefined"==typeof n.trumbowyg.langs[o.lang]?i.lang=n.trumbowyg.langs.en:i.lang=n.extend(!0,{},n.trumbowyg.langs.en,n.trumbowyg.langs[o.lang]),i.o=n.extend(!0,{},{lang:"en",dir:"ltr",duration:200,mobile:!1,tablet:!0,closable:!1,fullscreenable:!0,fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,prefix:"trumbowyg-",convertLink:!0,semantic:!1,resetCss:!1,btns:["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.design,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"],btnsAdd:[],btnsDef:{viewHTML:{func:"toggle"},p:{func:"formatBlock"},blockquote:{func:"formatBlock"},h1:{func:"formatBlock",title:i.lang.header+" 1"},h2:{func:"formatBlock",title:i.lang.header+" 2"},h3:{func:"formatBlock",title:i.lang.header+" 3"},h4:{func:"formatBlock",title:i.lang.header+" 4"},bold:{},italic:{},underline:{},strikethrough:{},strong:{func:"bold"},em:{func:"italic"},del:{func:"strikethrough"},createLink:{},unlink:{},insertImage:{},justifyLeft:{},justifyCenter:{},justifyRight:{},justifyFull:{},unorderedList:{func:"insertUnorderedList"},orderedList:{func:"insertOrderedList"},horizontalRule:{func:"insertHorizontalRule"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"]},link:{dropdown:["createLink","unlink"]}}},o),i.o.semantic&&!o.btns?i.o.btns=["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.semantic,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"]:o&&o.btns&&(i.o.btns=o.btns),i.init()};i.prototype={init:function(){var e=this;return e.height=e.$e.css("height"),e.isEnabled()?void e.buildEditor(!0):(e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),void e.buildOverlay())},buildEditor:function(e){var t=this,o=t.o.prefix,i="";if(e!==!0)t.$box=n("<div/>",{"class":o+"box "+o+t.o.lang+" trumbowyg"}),t.isTextarea=!0,t.$e.is("textarea")?t.$editor=n("<div/>"):(t.$editor=t.$e,t.$e=t.buildTextarea().val(t.$e.val()),t.isTextarea=!1),t.$creator.is("[placeholder]")&&t.$editor.attr("placeholder",t.$creator.attr("placeholder")),t.$e.hide().addClass(o+"textarea"),t.isTextarea?(i=t.$e.val(),t.$box.insertAfter(t.$e).append(t.$editor).append(t.$e)):(i=t.$editor.html(),t.$box.insertAfter(t.$editor).append(t.$e).append(t.$editor),t.syncCode()),t.$editor.addClass(o+"editor").attr("contenteditable",!0).attr("dir",t.lang._dir||t.o.dir).html(i),t.o.resetCss&&t.$editor.addClass(o+"reset-css"),t.o.autogrow||n.each([t.$editor,t.$e],function(e,n){n.css({height:t.height,overflow:"auto"})}),t.o.semantic&&(t.$editor.html(t.$editor.html().replace("<br>","</p><p>").replace("&nbsp;","")),t.semanticCode()),t.$editor.on("dblclick","img",function(e){var o=n(this);t.openModalInsert(t.lang.insertImage,{url:{label:"URL",value:o.attr("src"),required:!0},alt:{label:"description",value:o.attr("alt")}},function(e){o.attr({src:e.url,alt:e.alt})}),e.stopPropagation()}).on("keyup",function(e){t.semanticCode(!1,13===e.which)}).on("focus",function(){t.$creator.trigger("tbwfocus")}).on("blur",function(){t.syncCode(),t.$creator.trigger("tbwblur")});else if(!t.$e.is("textarea")){var r=t.buildTextarea().val(t.$e.val());t.$e.hide().after(r)}},buildTextarea:function(){return n("<textarea/>",{name:this.$e.attr("id"),height:this.height})},buildBtnPane:function(){var t=this,i=t.o.prefix;if(t.o.btns!==!1){t.$btnPane=n("<ul/>",{"class":i+"button-pane"}),n.each(t.o.btns.concat(t.o.btnsAdd),function(e,r){try{var a=r.split("btnGrp-");a[1]!==o&&(r=n.trumbowyg.btnsGrps[a[1]])}catch(s){}n.isArray(r)||(r=[r]),n.each(r,function(e,o){try{var r=n("<li/>");"|"===o?r.addClass(i+"separator"):t.isSupportedBtn(o)&&r.append(t.buildBtn(o)),t.$btnPane.append(r)}catch(a){}})});var r=n("<li/>",{"class":i+"not-disable "+i+"buttons-right"});t.o.fullscreenable&&r.append(t.buildRightBtn("fullscreen").on("click",function(){var o=i+"fullscreen";t.$box.toggleClass(o),t.$box.hasClass(o)?(n("body").css("overflow","hidden"),n.each([t.$editor,t.$e],function(){n(this).css({height:"calc(100% - 35px)",overflow:"auto"})}),t.$btnPane.css("width","100%")):(n("body").css("overflow","auto"),t.$box.removeAttr("style"),t.o.autogrow||n.each([t.$editor,t.$e],function(){n(this).css("height",t.height)})),n(e).trigger("scroll")})),t.o.closable&&r.append(t.buildRightBtn("close").on("click",function(){t.$box.hasClass(i+"fullscreen")&&n("body").css("overflow","auto"),t.destroy()})),r.not(":empty")&&t.$btnPane.append(r),t.$box.prepend(t.$btnPane)}},buildBtn:function(e){var t=this,o=t.o.prefix,i=t.o.btnsDef[e],r=i.dropdown,a=t.lang[e]||e,s=n("<button/>",{type:"button","class":o+e+"-button"+(i.ico?" "+o+i.ico+"-button":""),text:i.text||i.title||a,title:i.title||i.text||a,mousedown:function(a){return r&&!t.$box.find("."+e+"-"+o+"dropdown").is(":hidden")||n("body",t.doc).trigger("mousedown"),!t.$btnPane.hasClass(o+"disable")||n(this).hasClass(o+"active")||n(this).parent().hasClass(o+"not-disable")?(t.execCmd((r?"dropdown":!1)||i.func||e,i.param||e),a.stopPropagation(),void a.preventDefault()):!1}});if(r){s.addClass(o+"open-dropdown");var l=o+"dropdown",d=n("<div/>",{"class":e+"-"+l+" "+l+" "+o+"fixed-top"});n.each(r,function(e,n){t.o.btnsDef[n]&&t.isSupportedBtn(n)&&d.append(t.buildSubBtn(n))}),t.$box.append(d.hide())}return s},buildSubBtn:function(e){var t=this,o=t.o.btnsDef[e];return n("<button/>",{type:"button",text:o.text||o.title||t.lang[e]||e,style:o.style||null,mousedown:function(i){n("body",t.doc).trigger("mousedown"),t.execCmd(o.func||e,o.param||e),i.stopPropagation()}})},buildRightBtn:function(e){return n("<button/>",{type:"button","class":this.o.prefix+e+"-button",title:this.lang[e],text:this.lang[e]})},isSupportedBtn:function(e){var t=this.o.btnsDef[e];return"function"!=typeof t.isSupported||t.isSupported()},buildOverlay:function(){var e=this;return e.$overlay=n("<div/>",{"class":e.o.prefix+"overlay"}).css({top:e.$btnPane.outerHeight(),height:parseInt(e.$editor.outerHeight())+1+"px"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var t=this;n(e).trigger("scroll"),t.$overlay.fadeIn(t.o.duration),t.$box.addClass(t.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(e.o.duration/4),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var t=this,o=t.o.fixedFullWidth;t.o.fixedBtnPane&&(t.isFixed=!1,n(e).on("scroll resize",function(){if(t.$box){t.syncCode();var i=n(e).scrollTop(),r=t.$box.offset().top+1,a=i-r>0&&i-r-parseInt(t.height)<0,s=t.$btnPane,l=s.css("height"),d=s.outerHeight();a?(t.isFixed||(t.isFixed=!0,s.css({position:"fixed",top:0,left:o?"0":"auto",zIndex:7}),n([t.$editor,t.$e]).css({marginTop:l})),s.css({width:o?"100%":parseInt(t.$box.css("width"))-1+"px"}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:o?"fixed":"absolute",top:o?d:parseInt(d)+(i-r)+"px",zIndex:15})):t.isFixed&&(t.isFixed=!1,s.removeAttr("style"),n([t.$editor,t.$e]).css({marginTop:0}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:"absolute",top:d}))}}))},destroy:function(){var e=this,t=e.o.prefix,n=e.height,o=e.html();e.isTextarea?e.$box.after(e.$e.css({height:n}).val(o).removeClass(t+"textarea").show()):e.$box.after(e.$editor.css({height:n}).removeClass(t+"editor").removeAttr("contenteditable").html(o).show()),e.$box.remove(),e.$creator.removeData("trumbowyg")},empty:function(){this.$e.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.semanticCode(!1,!0),e.$editor.toggle(),e.$e.toggle(),e.$btnPane.toggleClass(t+"disable"),e.$btnPane.find("."+t+"viewHTML-button").toggleClass(t+"active")},dropdown:function(t){var o=this,i=o.doc,r=o.o.prefix,a=o.$box.find("."+t+"-"+r+"dropdown"),s=o.$btnPane.find("."+r+t+"-button");if(a.is(":hidden")){var l=s.offset().left;s.addClass(r+"active"),a.css({position:"absolute",top:o.$btnPane.outerHeight(),left:o.o.fixedFullWidth&&o.isFixed?l+"px":l-o.$btnPane.offset().left+"px"}).show(),n(e).trigger("scroll"),n("body",i).on("mousedown",function(){n("."+r+"dropdown",i).hide(),n("."+r+"active",i).removeClass(r+"active"),n("body",i).off("mousedown")})}else n("body",i).trigger("mousedown")},html:function(e){var t=this;return e?(t.$e.val(e),t.syncCode(!0),t):t.$e.val()},syncCode:function(e){var t=this;!e&&t.$editor.is(":visible")?t.$e.val(t.$editor.html()):t.$editor.html(t.$e.val()),t.o.autogrow&&(t.height=t.$editor.css("height"),t.$e.css({height:t.height}))},semanticCode:function(e,t){var o=this;o.syncCode(e),o.o.semantic&&(o.semanticTag("b","strong"),o.semanticTag("i","em"),o.semanticTag("strike","del"),t&&(o.$editor.contents().filter(function(){return 3===this.nodeType&&n.trim(this.nodeValue).length>0}).wrap("<p></p>").end().filter("br").remove(),o.saveSelection(),o.semanticTag("div","p"),o.restoreSelection()),o.$e.val(o.$editor.html()))},semanticTag:function(e,t){n(e,this.$editor).each(function(){n(this).replaceWith(function(){return"<"+t+">"+n(this).html()+"</"+t+">"})})},createLink:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.createLink,{url:{label:"URL",value:"http://",required:!0},title:{label:e.lang.title,value:e.selection},text:{label:e.lang.text,value:e.selection}},function(t){e.execCmd("createLink",t.url);var o=n('a[href="'+t.url+'"]:not([title])',e.$box);return t.text.length>0&&o.text(t.text),t.title.length>0&&o.attr("title",t.title),!0})},insertImage:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.insertImage,{url:{label:"URL",value:"http://",required:!0},alt:{label:e.lang.description,value:e.selection}},function(t){return e.execCmd("insertImage",t.url),n('img[src="'+t.url+'"]:not([alt])',e.$box).attr("alt",t.alt),!0})},execCmd:function(e,t){var n=this;"dropdown"!=e&&n.$editor.focus();try{n[e](t)}catch(o){try{e(t,n)}catch(i){"insertHorizontalRule"==e?t=null:"formatBlock"==e&&(-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0)&&(t="<"+t+">"),n.doc.execCommand(e,!1,t)}}n.syncCode()},openModal:function(t,o){var i=this,r=i.o.prefix;if(n("."+r+"modal-box",i.$box).size()>0)return!1;i.saveSelection(),i.showOverlay(),i.$btnPane.addClass(r+"disable");var a=n("<div/>",{"class":r+"modal "+r+"fixed-top"}).css({top:parseInt(i.$btnPane.css("height"))+1+"px"}).appendTo(i.$box);i.$overlay.one("click",function(e){e.preventDefault(),a.trigger(r+"cancel")});var s=n("<form/>",{action:"",html:o}).on("submit",function(e){e.preventDefault(),a.trigger(r+"confirm")}).on("reset",function(e){e.preventDefault(),a.trigger(r+"cancel")}),l=n("<div/>",{"class":r+"modal-box",html:s}).css({top:"-"+parseInt(i.$btnPane.outerHeight())+"px",opacity:0}).appendTo(a).animate({top:0,opacity:1},i.o.duration/2);return n("<span/>",{text:t,"class":r+"modal-title"}).prependTo(l),l.find("input:first").focus(),i.buildModalBtn("submit",l),i.buildModalBtn("reset",l),n(e).trigger("scroll"),a},buildModalBtn:function(e,t){var o=this,i=o.o.prefix;return n("<button/>",{"class":i+"modal-button "+i+"modal-"+e,type:e,text:o.lang[e]||e}).appendTo(t.find("form"))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var o=n("."+t+"modal-box",e.$box);o.animate({top:"-"+o.css("height")},e.o.duration/2,function(){n(this).parent().remove(),e.hideOverlay()})},openModalInsert:function(e,t,i){var r=this,a=r.o.prefix,s=r.lang,l="";for(var d in t){var c=t[d],u=c.label===o?s[d]?s[d]:d:s[c.label]?s[c.label]:c.label;c.name===o&&(c.name=d),c.pattern||"url"!==d||(c.pattern=/^(http|https):\/\/([\w~#!:.?+=&%@!\-\/]+)$/,c.patternError=s.invalidUrl),l+='<label><input type="'+(c.type||"text")+'" name="'+c.name+'" value="'+(c.value||"")+'"><span class="'+a+'input-infos"><span>'+u+"</span></span></label>"}return r.openModal(e,l).on(a+"confirm",function(){var e=n(this).find("form"),o=!0,s={};for(var l in t){var d=n('input[name="'+l+'"]',e);s[l]=n.trim(d.val()),t[l].required&&""===s[l]?(o=!1,r.addErrorOnModalField(d,r.lang.required)):t[l].pattern&&!t[l].pattern.test(s[l])&&(o=!1,r.addErrorOnModalField(d,t[l].patternError))}o&&(r.restoreSelection(),i(s,t)&&(r.syncCode(),r.closeModal(),n(this).off(a+"confirm")))}).one(a+"cancel",function(){n(this).off(a+"confirm"),r.closeModal(),r.restoreSelection()})},addErrorOnModalField:function(e,t){var o=this.o.prefix,i=e.parent();e.on("change keyup",function(){i.removeClass(o+"input-error")}),i.addClass(o+"input-error").find("input+span").append(n("<span/>",{"class":o+"msg-error",text:t}))},saveSelection:function(){var t=this,n=t.doc;if(t.selection=null,e.getSelection){var o=e.getSelection();o.getRangeAt&&o.rangeCount&&(t.selection=o.getRangeAt(0))}else n.selection&&n.selection.createRange&&(t.selection=n.selection.createRange())},restoreSelection:function(){var t=this,n=t.selection;if(n)if(e.getSelection){var o=e.getSelection();o.removeAllRanges(),o.addRange(n)}else t.doc.selection&&n.select&&n.select()},isEnabled:function(){var e=new RegExp("(iPad|webOS)"),t=new RegExp("(iPhone|iPod|Android|BlackBerry|Windows Phone|ZuneWP7)"),n=navigator.userAgent;return this.o.tablet===!0&&e.test(n)||this.o.mobile===!0&&t.test(n)}}}(window,document,jQuery);
@@ -1 +0,0 @@
1
- jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",insertVideo:"Insert Video",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",fullscreen:"fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",invalidUrl:"Invalid URL",required:"Required",description:"Description",title:"Title",text:"Text"}},opts:{},btnsGrps:{design:["bold","italic","underline","strikethrough"],semantic:["strong","em","del"],justify:["justifyLeft","justifyCenter","justifyRight","justifyFull"],lists:["unorderedList","orderedList"]}},function(e,t,n,o){"use strict";n.fn.trumbowyg=function(e,t){if(e===Object(e)||!e)return this.each(function(){n(this).data("trumbowyg")||n(this).data("trumbowyg",new i(this,e))});if(1===this.length)try{var o=n(this).data("trumbowyg");switch(e){case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveSelection":return o.saveSelection();case"getSelection":return o.selection;case"getSelectedText":return o.selection+"";case"restoreSelection":return o.restoreSelection();case"destroy":return o.destroy();case"empty":return o.empty();case"lang":return o.lang;case"duration":return o.o.duration;case"html":return o.html(t)}}catch(r){}return!1};var i=function(e,o){var i=this;i.doc=e.ownerDocument||t,i.$e=n(e),i.$creator=n(e),o=n.extend(!0,{},o,n.trumbowyg.opts),"undefined"==typeof o.lang||"undefined"==typeof n.trumbowyg.langs[o.lang]?i.lang=n.trumbowyg.langs.en:i.lang=n.extend(!0,{},n.trumbowyg.langs.en,n.trumbowyg.langs[o.lang]),i.o=n.extend(!0,{},{lang:"en",dir:"ltr",duration:200,mobile:!1,tablet:!0,closable:!1,fullscreenable:!0,fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,prefix:"trumbowyg-",convertLink:!0,semantic:!1,resetCss:!1,btns:["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.design,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"],btnsAdd:[],btnsDef:{viewHTML:{func:"toggle"},p:{func:"formatBlock"},blockquote:{func:"formatBlock"},h1:{func:"formatBlock",title:i.lang.header+" 1"},h2:{func:"formatBlock",title:i.lang.header+" 2"},h3:{func:"formatBlock",title:i.lang.header+" 3"},h4:{func:"formatBlock",title:i.lang.header+" 4"},bold:{},italic:{},underline:{},strikethrough:{},strong:{func:"bold"},em:{func:"italic"},del:{func:"strikethrough"},createLink:{},unlink:{},insertImage:{},justifyLeft:{},justifyCenter:{},justifyRight:{},justifyFull:{},unorderedList:{func:"insertUnorderedList"},orderedList:{func:"insertOrderedList"},horizontalRule:{func:"insertHorizontalRule"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"]},link:{dropdown:["createLink","unlink"]}}},o),i.o.semantic&&!o.btns?i.o.btns=["viewHTML","|","formatting","|",n.trumbowyg.btnsGrps.semantic,"|","link","|","insertImage","|",n.trumbowyg.btnsGrps.justify,"|",n.trumbowyg.btnsGrps.lists,"|","horizontalRule"]:o&&o.btns&&(i.o.btns=o.btns),i.init()};i.prototype={init:function(){var e=this;return e.height=e.$e.css("height"),e.isEnabled()?void e.buildEditor(!0):(e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),void e.buildOverlay())},buildEditor:function(e){var t=this,o=t.o.prefix,i="";if(e!==!0)t.$box=n("<div/>",{"class":o+"box "+o+t.o.lang+" trumbowyg"}),t.isTextarea=!0,t.$e.is("textarea")?t.$editor=n("<div/>"):(t.$editor=t.$e,t.$e=t.buildTextarea().val(t.$e.val()),t.isTextarea=!1),t.$creator.is("[placeholder]")&&t.$editor.attr("placeholder",t.$creator.attr("placeholder")),t.$e.hide().addClass(o+"textarea"),t.isTextarea?(i=t.$e.val(),t.$box.insertAfter(t.$e).append(t.$editor).append(t.$e)):(i=t.$editor.html(),t.$box.insertAfter(t.$editor).append(t.$e).append(t.$editor),t.syncCode()),t.$editor.addClass(o+"editor").attr("contenteditable",!0).attr("dir",t.lang._dir||t.o.dir).html(i),t.o.resetCss&&t.$editor.addClass(o+"reset-css"),t.o.autogrow||n.each([t.$editor,t.$e],function(e,n){n.css({height:t.height,overflow:"auto"})}),t.o.semantic&&(t.$editor.html(t.$editor.html().replace("<br>","</p><p>").replace("&nbsp;","")),t.semanticCode()),t.$editor.on("dblclick","img",function(e){var o=n(this);t.openModalInsert(t.lang.insertImage,{url:{label:"URL",value:o.attr("src"),required:!0},alt:{label:"description",value:o.attr("alt")}},function(e){o.attr({src:e.url,alt:e.alt})}),e.stopPropagation()}).on("keyup",function(e){t.semanticCode(!1,13===e.which)}).on("focus",function(){t.$creator.trigger("tbwfocus")}).on("blur",function(){t.syncCode(),t.$creator.trigger("tbwblur")});else if(!t.$e.is("textarea")){var r=t.buildTextarea().val(t.$e.val());t.$e.hide().after(r)}},buildTextarea:function(){return n("<textarea/>",{name:this.$e.attr("id"),height:this.height})},buildBtnPane:function(){var t=this,i=t.o.prefix;if(t.o.btns!==!1){t.$btnPane=n("<ul/>",{"class":i+"button-pane"}),n.each(t.o.btns.concat(t.o.btnsAdd),function(e,r){try{var a=r.split("btnGrp-");a[1]!==o&&(r=n.trumbowyg.btnsGrps[a[1]])}catch(s){}n.isArray(r)||(r=[r]),n.each(r,function(e,o){try{var r=n("<li/>");"|"===o?r.addClass(i+"separator"):t.isSupportedBtn(o)&&r.append(t.buildBtn(o)),t.$btnPane.append(r)}catch(a){}})});var r=n("<li/>",{"class":i+"not-disable "+i+"buttons-right"});t.o.fullscreenable&&r.append(t.buildRightBtn("fullscreen").on("click",function(){var o=i+"fullscreen";t.$box.toggleClass(o),t.$box.hasClass(o)?(n("body").css("overflow","hidden"),n.each([t.$editor,t.$e],function(){n(this).css({height:"calc(100% - 35px)",overflow:"auto"})}),t.$btnPane.css("width","100%")):(n("body").css("overflow","auto"),t.$box.removeAttr("style"),t.o.autogrow||n.each([t.$editor,t.$e],function(){n(this).css("height",t.height)})),n(e).trigger("scroll")})),t.o.closable&&r.append(t.buildRightBtn("close").on("click",function(){t.$box.hasClass(i+"fullscreen")&&n("body").css("overflow","auto"),t.destroy()})),r.not(":empty")&&t.$btnPane.append(r),t.$box.prepend(t.$btnPane)}},buildBtn:function(e){var t=this,o=t.o.prefix,i=t.o.btnsDef[e],r=i.dropdown,a=t.lang[e]||e,s=n("<button/>",{type:"button","class":o+e+"-button"+(i.ico?" "+o+i.ico+"-button":""),text:i.text||i.title||a,title:i.title||i.text||a,mousedown:function(a){return r&&!t.$box.find("."+e+"-"+o+"dropdown").is(":hidden")||n("body",t.doc).trigger("mousedown"),!t.$btnPane.hasClass(o+"disable")||n(this).hasClass(o+"active")||n(this).parent().hasClass(o+"not-disable")?(t.execCmd((r?"dropdown":!1)||i.func||e,i.param||e),a.stopPropagation(),void a.preventDefault()):!1}});if(r){s.addClass(o+"open-dropdown");var l=o+"dropdown",d=n("<div/>",{"class":e+"-"+l+" "+l+" "+o+"fixed-top"});n.each(r,function(e,n){t.o.btnsDef[n]&&t.isSupportedBtn(n)&&d.append(t.buildSubBtn(n))}),t.$box.append(d.hide())}return s},buildSubBtn:function(e){var t=this,o=t.o.btnsDef[e];return n("<button/>",{type:"button",text:o.text||o.title||t.lang[e]||e,style:o.style||null,mousedown:function(i){n("body",t.doc).trigger("mousedown"),t.execCmd(o.func||e,o.param||e),i.stopPropagation()}})},buildRightBtn:function(e){return n("<button/>",{type:"button","class":this.o.prefix+e+"-button",title:this.lang[e],text:this.lang[e]})},isSupportedBtn:function(e){var t=this.o.btnsDef[e];return"function"!=typeof t.isSupported||t.isSupported()},buildOverlay:function(){var e=this;return e.$overlay=n("<div/>",{"class":e.o.prefix+"overlay"}).css({top:e.$btnPane.outerHeight(),height:parseInt(e.$editor.outerHeight())+1+"px"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var t=this;n(e).trigger("scroll"),t.$overlay.fadeIn(t.o.duration),t.$box.addClass(t.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(e.o.duration/4),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var t=this,o=t.o.fixedFullWidth;t.o.fixedBtnPane&&(t.isFixed=!1,n(e).on("scroll resize",function(){if(t.$box){t.syncCode();var i=n(e).scrollTop(),r=t.$box.offset().top+1,a=i-r>0&&i-r-parseInt(t.height)<0,s=t.$btnPane,l=s.css("height"),d=s.outerHeight();a?(t.isFixed||(t.isFixed=!0,s.css({position:"fixed",top:0,left:o?"0":"auto",zIndex:7}),n([t.$editor,t.$e]).css({marginTop:l})),s.css({width:o?"100%":parseInt(t.$box.css("width"))-1+"px"}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:o?"fixed":"absolute",top:o?d:parseInt(d)+(i-r)+"px",zIndex:15})):t.isFixed&&(t.isFixed=!1,s.removeAttr("style"),n([t.$editor,t.$e]).css({marginTop:0}),n("."+t.o.prefix+"fixed-top",t.$box).css({position:"absolute",top:d}))}}))},destroy:function(){var e=this,t=e.o.prefix,n=e.height,o=e.html();e.isTextarea?e.$box.after(e.$e.css({height:n}).val(o).removeClass(t+"textarea").show()):e.$box.after(e.$editor.css({height:n}).removeClass(t+"editor").removeAttr("contenteditable").html(o).show()),e.$box.remove(),e.$creator.removeData("trumbowyg")},empty:function(){this.$e.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.semanticCode(!1,!0),e.$editor.toggle(),e.$e.toggle(),e.$btnPane.toggleClass(t+"disable"),e.$btnPane.find("."+t+"viewHTML-button").toggleClass(t+"active")},dropdown:function(t){var o=this,i=o.doc,r=o.o.prefix,a=o.$box.find("."+t+"-"+r+"dropdown"),s=o.$btnPane.find("."+r+t+"-button");if(a.is(":hidden")){var l=s.offset().left;s.addClass(r+"active"),a.css({position:"absolute",top:o.$btnPane.outerHeight(),left:o.o.fixedFullWidth&&o.isFixed?l+"px":l-o.$btnPane.offset().left+"px"}).show(),n(e).trigger("scroll"),n("body",i).on("mousedown",function(){n("."+r+"dropdown",i).hide(),n("."+r+"active",i).removeClass(r+"active"),n("body",i).off("mousedown")})}else n("body",i).trigger("mousedown")},html:function(e){var t=this;return e?(t.$e.val(e),t.syncCode(!0),t):t.$e.val()},syncCode:function(e){var t=this;!e&&t.$editor.is(":visible")?t.$e.val(t.$editor.html()):t.$editor.html(t.$e.val()),t.o.autogrow&&(t.height=t.$editor.css("height"),t.$e.css({height:t.height}))},semanticCode:function(e,t){var o=this;o.syncCode(e),o.o.semantic&&(o.semanticTag("b","strong"),o.semanticTag("i","em"),o.semanticTag("strike","del"),t&&(o.$editor.contents().filter(function(){return 3===this.nodeType&&n.trim(this.nodeValue).length>0}).wrap("<p></p>").end().filter("br").remove(),o.saveSelection(),o.semanticTag("div","p"),o.restoreSelection()),o.$e.val(o.$editor.html()))},semanticTag:function(e,t){n(e,this.$editor).each(function(){n(this).replaceWith(function(){return"<"+t+">"+n(this).html()+"</"+t+">"})})},createLink:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.createLink,{url:{label:"URL",value:"http://",required:!0},title:{label:e.lang.title,value:e.selection},text:{label:e.lang.text,value:e.selection}},function(t){e.execCmd("createLink",t.url);var o=n('a[href="'+t.url+'"]:not([title])',e.$box);return t.text.length>0&&o.text(t.text),t.title.length>0&&o.attr("title",t.title),!0})},insertImage:function(){var e=this;e.saveSelection(),e.openModalInsert(e.lang.insertImage,{url:{label:"URL",value:"http://",required:!0},alt:{label:e.lang.description,value:e.selection}},function(t){return e.execCmd("insertImage",t.url),n('img[src="'+t.url+'"]:not([alt])',e.$box).attr("alt",t.alt),!0})},execCmd:function(e,t){var n=this;"dropdown"!=e&&n.$editor.focus();try{n[e](t)}catch(o){try{e(t,n)}catch(i){"insertHorizontalRule"==e?t=null:"formatBlock"==e&&(-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0)&&(t="<"+t+">"),n.doc.execCommand(e,!1,t)}}n.syncCode()},openModal:function(t,o){var i=this,r=i.o.prefix;if(n("."+r+"modal-box",i.$box).size()>0)return!1;i.saveSelection(),i.showOverlay(),i.$btnPane.addClass(r+"disable");var a=n("<div/>",{"class":r+"modal "+r+"fixed-top"}).css({top:parseInt(i.$btnPane.css("height"))+1+"px"}).appendTo(i.$box);i.$overlay.one("click",function(e){e.preventDefault(),a.trigger(r+"cancel")});var s=n("<form/>",{action:"",html:o}).on("submit",function(e){e.preventDefault(),a.trigger(r+"confirm")}).on("reset",function(e){e.preventDefault(),a.trigger(r+"cancel")}),l=n("<div/>",{"class":r+"modal-box",html:s}).css({top:"-"+parseInt(i.$btnPane.outerHeight())+"px",opacity:0}).appendTo(a).animate({top:0,opacity:1},i.o.duration/2);return n("<span/>",{text:t,"class":r+"modal-title"}).prependTo(l),l.find("input:first").focus(),i.buildModalBtn("submit",l),i.buildModalBtn("reset",l),n(e).trigger("scroll"),a},buildModalBtn:function(e,t){var o=this,i=o.o.prefix;return n("<button/>",{"class":i+"modal-button "+i+"modal-"+e,type:e,text:o.lang[e]||e}).appendTo(t.find("form"))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var o=n("."+t+"modal-box",e.$box);o.animate({top:"-"+o.css("height")},e.o.duration/2,function(){n(this).parent().remove(),e.hideOverlay()})},openModalInsert:function(e,t,i){var r=this,a=r.o.prefix,s=r.lang,l="";for(var d in t){var c=t[d],u=c.label===o?s[d]?s[d]:d:s[c.label]?s[c.label]:c.label;c.name===o&&(c.name=d),c.pattern||"url"!==d||(c.pattern=/^(http|https):\/\/([\w~#!:.?+=&%@!\-\/]+)$/,c.patternError=s.invalidUrl),l+='<label><input type="'+(c.type||"text")+'" name="'+c.name+'" value="'+(c.value||"")+'"><span class="'+a+'input-infos"><span>'+u+"</span></span></label>"}return r.openModal(e,l).on(a+"confirm",function(){var e=n(this).find("form"),o=!0,s={};for(var l in t){var d=n('input[name="'+l+'"]',e);s[l]=n.trim(d.val()),t[l].required&&""===s[l]?(o=!1,r.addErrorOnModalField(d,r.lang.required)):t[l].pattern&&!t[l].pattern.test(s[l])&&(o=!1,r.addErrorOnModalField(d,t[l].patternError))}o&&(r.restoreSelection(),i(s,t)&&(r.syncCode(),r.closeModal(),n(this).off(a+"confirm")))}).one(a+"cancel",function(){n(this).off(a+"confirm"),r.closeModal(),r.restoreSelection()})},addErrorOnModalField:function(e,t){var o=this.o.prefix,i=e.parent();e.on("change keyup",function(){i.removeClass(o+"input-error")}),i.addClass(o+"input-error").find("input+span").append(n("<span/>",{"class":o+"msg-error",text:t}))},saveSelection:function(){var t=this,n=t.doc;if(t.selection=null,e.getSelection){var o=e.getSelection();o.getRangeAt&&o.rangeCount&&(t.selection=o.getRangeAt(0))}else n.selection&&n.selection.createRange&&(t.selection=n.selection.createRange())},restoreSelection:function(){var t=this,n=t.selection;if(n)if(e.getSelection){var o=e.getSelection();o.removeAllRanges(),o.addRange(n)}else t.doc.selection&&n.select&&n.select()},isEnabled:function(){var e=new RegExp("(iPad|webOS)"),t=new RegExp("(iPhone|iPod|Android|BlackBerry|Windows Phone|ZuneWP7)"),n=navigator.userAgent;return this.o.tablet===!0&&e.test(n)||this.o.mobile===!0&&t.test(n)}}}(window,document,jQuery);