1var BlogParts = (function(){ 2 3 var $modalWindow = $(".js-blogparts-modal"); 4 var $iframe = $modalWindow.find(".js-blogpartsFrame"); 5 6 $iframe.on("load", function(){ 7 $(this).contents() 8 .find(".js-add-parts").on("click", BlogParts.addParts) 9 .find("a").on("click", function(e){ 10 // ããã°ãã¼ãã¢ã¼ãã«å ã®aã¿ã°ã¯ãªãã¯ã¯ç¡å¹ã«ãã¦ãã 11 e.preventDefault(); 12 }); 13 }); 14 15 $modalWindow.find(".modal-header a").on("click", function(e){ 16 e.preventDefault(); 17 var target = $(e.target).attr("href"); 18 $modalWindow.scrollTop( $iframe.contents().find(target).offset().top ); 19 }); 20 21 return { 22 blogpartsClass: "blogparts_element", 23 newLineClass: "newline", 24 isLastClass: "ignore", 25 openModal: function(evt){ 26 27 evt.preventDefault(); 28 29 $modalWindow 30 .on('show.bs.modal', function(){ 31 $modalWindow.css("opacity", 0); 32 }) 33 .on('shown.bs.modal', function () { 34 35 var iframeHeight = $iframe.get(0).contentWindow.document.documentElement.scrollHeight; 36 $iframe.height(iframeHeight); 37 38 var modalHeight = $modalWindow.find(".modal-header").outerHeight() + $modalWindow.find(".modal-footer").outerHeight() + $modalWindow.find(".modal-body").outerHeight(); 39 $('.modal-content').css('height', modalHeight); 40 $modalWindow.css("opacity", 1); 41 42 }); 43 44 $modalWindow.modal(); 45 $modalWindow.scrollTop(0); 46 }, 47 renderGmap: function() { 48 tinymce.dom.DomQuery.each(tinymce.activeEditor.dom.select(".js-gmap-address"), function () { 49 GMAP.render($(this)); 50 }); 51 }, 52 addParts: function(evt){ 53 var parts_html = $(evt.currentTarget).html(); 54 55 tinymce.activeEditor.execCommand("mceInsertContent", false, parts_html); 56 57 parts_html = tinymce.activeEditor.dom.get(parts_html); 58 if ( !tinymce.activeEditor.dom.getNext(parts_html, "*") ){ 59 BlogParts.appendNewParagraph(null, BlogParts.isLastClass); 60 } 61 $modalWindow.modal('hide'); 62 }, 63 addBlogpartsClass: function(){ 64 65 tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select("p"), BlogParts.blogpartsClass); 66 tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select("ul, ol"), BlogParts.blogpartsClass); 67 tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select("table"), BlogParts.blogpartsClass); 68 tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select("strong, em"), BlogParts.blogpartsClass); 69 70 tinymce.activeEditor.dom.removeClass(tinymce.activeEditor.dom.select("ul."+BlogParts.blogpartsClass+" > li, ol."+BlogParts.blogpartsClass+" > li"), BlogParts.blogpartsClass); 71 72 }, 73 formatLines: function(){ 74 75 tinymce.activeEditor.dom.removeClass( tinymce.activeEditor.dom.select("p"), BlogParts.newLineClass); 76 77 var paragraphs = tinymce.activeEditor.dom.select("p"); 78 $(paragraphs).each(function(){ 79 80 var paragraph = tinymce.activeEditor.dom.get(this); 81 var isLast = !tinymce.activeEditor.dom.getNext(paragraph, "*"); 82 83 // <br>ã ãå ¥ã£ã¦ãã¦ãããã¹ãè¦ç´ ããªã 84 var isEmpty = $(this).children("br").length > 0; 85 if (isEmpty) { 86 isEmpty = $(this).contents().filter(function(){ 87 return this.nodeType == 3; 88 }).length < 1; 89 } 90 91 if ( isLast && isEmpty ){ 92 tinymce.activeEditor.dom.addClass( paragraph, BlogParts.isLastClass); 93 } else { 94 tinymce.activeEditor.dom.removeClass( paragraph, BlogParts.isLastClass); 95 } 96 if ( isEmpty ){ 97 tinymce.activeEditor.dom.addClass( tinymce.activeEditor.dom.get(this), BlogParts.newLineClass); 98 } 99 }); 100 }, 101 appendNewParagraph: function(e, additionalClassName){ 102 103 var rootClass = "blogparts_root"; 104 var cursorClass = "cursorHere"; 105 additionalClassName = additionalClassName || ''; 106 107 var newParagraph = tinymce.activeEditor.dom.create('p', {'class': cursorClass + " " + additionalClassName}, "<br>"); 108 var currentElement = tinymce.activeEditor.selection.getNode(); 109 var parents = tinymce.activeEditor.dom.getParents(currentElement); 110 111 for (var i = 0, len = parents.length; i < len; i++) { 112 113 var $el = tinymce.activeEditor.dom.get(parents[i]); 114 115 if ( tinymce.activeEditor.dom.hasClass($el, rootClass) ){ 116 tinymce.activeEditor.dom.insertAfter(newParagraph, $el); 117 break; 118 } 119 120 if ( i === parents.length - 1 ){ 121 $el = tinymce.activeEditor.getBody(); 122 tinymce.activeEditor.dom.add($el, newParagraph); 123 } 124 } 125 126 newParagraph = tinymce.activeEditor.dom.select('p.'+cursorClass, false)[0]; 127 tinymce.activeEditor.selection.setCursorLocation(newParagraph); 128 tinymce.activeEditor.dom.removeClass(tinymce.activeEditor.dom.select('p.'+cursorClass), cursorClass); 129 130 BlogParts.formatLines(); 131 }, 132 recalculateTableWidth: function(){ 133 134 var calculateResponsiveWidth = function( $element, parentWidth ){ 135 var width = tinymce.activeEditor.dom.getSize( $element ).w; 136 return { 137 px: width, 138 percent: ( width > parentWidth ) ? 100 : width / parentWidth * 100 139 }; 140 }; 141 142 var tables = tinymce.activeEditor.dom.select("table"); 143 $(tables).each(function(){ 144 145 var $table = tinymce.activeEditor.dom.get(this); 146 147 // getParents(...)[0]ãèªåã[1]ãä¸ã¤ä¸é層ã®è¦ç´ 148 var parentWidth = $( tinymce.activeEditor.dom.getParents($table)[1]).width(); 149 var tableWidth = calculateResponsiveWidth($table, parentWidth); 150 151 var cellsInFirstRow = tinymce.activeEditor.dom.select("tr:first-child > th, td", $table); 152 $(cellsInFirstRow).each(function(){ 153 var $cell = tinymce.activeEditor.dom.get(this); 154 var cellWidth = calculateResponsiveWidth($cell, tableWidth.px); 155 tinymce.activeEditor.dom.setStyles( $cell , {'width': cellWidth.percent +'%', 'maxWidth': '100%'}); 156 }); 157 158 tinymce.activeEditor.dom.setStyles( $table , {'width': tableWidth.percent +'%', 'maxWidth': '100%'}); 159 }); 160 }, 161 resizeTitleHeight: function( context ){ 162 $("."+ BlogParts.blogpartsClass +".businessInfo.level-1", context).children(".col").children("h2").matchHeight(); 163 $("."+ BlogParts.blogpartsClass +".businessInfo.level-3 > ul", context).children("li").find("h4, h6").matchHeight(); 164 }, 165 getCodeDialogMaxWidth: function () { 166 var MIN = Math.min(window.innerWidth - 100, 800); // 800: codemirrorã®default 167 return Math.max(MIN, window.innerWidth * 0.8); 168 }, 169 getCodeDialogMaxHeight: function () { 170 var MIN = Math.min(window.innerHeight - 200, 550); // 550: codemirrorã®default 171 return Math.max(MIN, window.innerHeight * 0.8); 172 }, 173 getCursorableElement: function (firstElement) { 174 175 var $ = tinymce.dom.DomQuery; 176 var isInvalid = function (el) { 177 return ['style'].indexOf(el.nodeName.toLowerCase()) > -1; 178 } 179 180 var element = firstElement; 181 while (element) { 182 183 if (isInvalid(element)) { 184 element = element.nextSibling; 185 continue; 186 } 187 for (var i = 0; i < $(element).children().length; i++) { 188 if (isInvalid($(element).children()[i])) { 189 element = element.nextSibling; 190 continue; 191 } 192 } 193 break; 194 } 195 return element; 196 }, 197 cursorToValidElement: function (editor) { 198 var element = BlogParts.getCursorableElement($(editor.getBody()).children().first()[0]); 199 if (element) { 200 editor.selection.select(element, true); 201 } else { 202 BlogParts.appendNewParagraph(null, ''); 203 editor.selection.select(editor.getBody(), true); 204 } 205 editor.selection.collapse(false); 206 } 207 }; 208 209}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.