');\n\t\t\t\t// var $selectorText = $('
Text ');\n\t\t\t\t// var $selectorBack = $('
Highlight ');\n\n\t\t\t\t// $selector.append($selectorText);\n\t\t\t\t// $selector.append($selectorBack);\n\n\t\t\t\t// $dropdown.append($selector);\n\n\t\t\t\tthis.fontcolor.buildPicker($dropdown, 'textcolor', colors);\n\t\t\t\t// this.fontcolor.buildPicker($dropdown, 'backcolor', colors);\n\n\t\t\t\t// $selectorText.on('mousedown', function(e)\n\t\t\t\t// {\n\t\t\t\t// \t\te.preventDefault();\n\n // $dropdown.find('.re-dropdown-box-selector-font').css('background', 'none');\n\t\t\t\t// \t\t$dropdown.find('.re-dropdown-box-backcolor').hide();\n\t\t\t\t// \t\t$dropdown.find('.re-dropdown-box-textcolor').show();\n\n\t\t\t\t// \t\t$(this).css('background', '#eee');\n\t\t\t\t// });\n\n\t\t\t\t// $selectorBack.on('mousedown', function(e)\n\t\t\t\t// {\n\t\t\t\t// \t\te.preventDefault();\n // e.stopPropagation();\n // console.log('e back click', e)\n\n // $dropdown.find('.re-dropdown-box-selector-font').css('background', 'none');\n\t\t\t\t// \t\t$dropdown.find('.re-dropdown-box-textcolor').hide();\n\t\t\t\t// \t\t$dropdown.find('.re-dropdown-box-backcolor').show();\n\n\t\t\t\t// \t\t$(this).css('background', '#eee');\n\t\t\t\t// });\n\n\t\t\t},\n\t\t\tbuildPicker: function($dropdown, name, colors)\n\t\t\t{\n var $box = $('
');\n\t\t\t\tvar rule = (name == 'backcolor') ? 'background-color' : 'color';\n\t\t\t\tvar len = colors.length;\n\t\t\t\tvar self = this;\n\t\t\t\tvar func = function(e)\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tself.fontcolor.set($(this).data('rule'), $(this).attr('rel'));\n\t\t\t\t};\n\n $swatchpadding = $('
');\n\n\t\t\t\tfor (var z = 0; z < len; z++)\n\t\t\t\t{\n\t\t\t\t\tvar color = colors[z];\n\n\t\t\t\t\tvar $swatch = $('
');\n\t\t\t\t\t$swatch.css('background-color', color);\n\t\t\t\t\t$swatch.on('click touch', func);\n\n\t\t\t\t\t$swatchpadding.append($swatch);\n\t\t\t\t}\n\n $box.append($swatchpadding);\n\n\t\t\t\tvar $elNone = $('
').html(this.lang.get('none'));\n\t\t\t\t$elNone.on('mousedown', $.proxy(function(e)\n\t\t\t\t{\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tthis.fontcolor.remove(rule);\n\n\t\t\t\t}, this));\n\n\t\t\t\t$box.append($elNone);\n\t\t\t\t$dropdown.append($box);\n\n\t\t\t\tif (name == 'backcolor')\n\t\t\t\t{\n $box.hide();\n\t\t\t\t}\n\t\t\t},\n\t\t\tset: function(rule, type)\n\t\t\t{\n\t\t\t\tthis.inline.format('span', 'style', rule + ': ' + type + ';');\n\t\t\t\t// this.dropdown.hide();\n\t\t\t},\n\t\t\tremove: function(rule)\n\t\t\t{\n try {\n this.inline.removeStyleRule(rule);\n } catch (e) {\n\n }\n\n\t\t\t\t// this.dropdown.hide();\n\t\t\t}\n\t\t};\n\t};\n})(jQuery);","(function($)\n{\n\t$.Redactor.prototype.imagelinks = function()\n\t{\n\t\treturn {\n\t\t\tinit: function()\n\t\t\t{\n\t\t\t\tif (!this.opts.definedLinks)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.modal.addCallback('imageEdit', $.proxy(this.imagelinks.load, this));\n\t\t\t},\n\t\t\tload: function()\n\t\t\t{\n\t\t\t\tvar $section = $('
');\n\t\t\t\tvar $select = $('
');\n\n\t\t\t\t$section.append($select);\n\t\t\t\tthis.modal.getModal().prepend($section);\n\n\t\t\t\tthis.imagelinks.storage = {};\n\n\t\t\t\tvar url = (this.opts.definedLinks) ? this.opts.definedLinks : this.opts.definedLinks;\n\t\t\t\t$.getJSON(url, $.proxy(function(data)\n\t\t\t\t{\n var $selected = $('#redactor-image-link').val();\n\n\t\t\t\t\t$.each(data, $.proxy(function(key, val)\n\t\t\t\t\t{\n\t\t\t\t\t\tthis.imagelinks.storage[key] = val;\n\n\t\t\t\t\t\tif(val.url === $selected) {\n $select.append($('
').val(key).html(val.name));\n }\n else {\n $select.append($(' ').val(key).html(val.name));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}, this));\n\n\t\t\t\t\t$select.on('change', $.proxy(this.imagelinks.select, this));\n\n $('#redactor-defined-links').selectize({});\n\n\t\t\t\t}, this));\n\n\t\t\t},\n\t\t\tselect: function(e)\n\t\t\t{\n\t\t\t\tvar key = $(e.target).val();\n\t\t\t\tvar name = '', url = '';\n\t\t\t\tif (key !== 0)\n\t\t\t\t{\n\t\t\t\t\tname = this.imagelinks.storage[key].name;\n\t\t\t\t\turl = this.imagelinks.storage[key].url;\n\t\t\t\t}\n\n\t\t\t\t$('#redactor-image-link').val(url);\n\t\t\t}\n\t\t};\n\t};\n})(jQuery);","// // ============================================================\n// //\n// // Vanilla Color Picker v 0.1.8\n// //\n// // http://github.com/miroshko/vanilla-color-picker\n// //\n// // This project is licensed under the terms of the MIT license.\n// //\n// // ============================================================\n// !function(e){function t(e,t,i){var n=i?\"vanilla-color-picker-single-color-picked\":\"\"\n// return'
'}function i(){if(!document.getElementById(\"vanilla-color-picker-style\")){var t=document.createElement(\"style\")\n// t.setAttribute(\"type\",\"text/css\"),t.setAttribute(\"id\",\"vanilla-color-picker-style\"),t.innerHTML=l\n// var i=e.document.head.children[0]\n// i?e.document.head.insertBefore(t,i):e.document.head.appendChild(t)}}function n(){this.subscribers={},this.on=function(e,t){return this.subscribers[e]=this.subscribers[e]||[],this.subscribers[e].push(t),this},this.emit=function(e){var t=arguments;(this.subscribers[e]||[]).forEach(function(e){e.apply(null,Array.prototype.splice.call(t,1))})}}function s(e,i,s){n.apply(this),this.targetElem=e,this.elem=null\n// var o=this\n// this._initialize=function(){this._createPickerElement(),this._positionPickerElement(),this._addEventListeners()},this.destroy=function(){try{this.elem.parentNode.removeChild(this.elem)}catch(e){}},this._positionPickerElement=function(){var e=this.targetElem.offsetLeft,t=this.targetElem.offsetTop,i=this.targetElem.offsetHeight\n// this.elem.style.left=e+\"px\",this.elem.style.top=t+i+\"px\"},this._onFocusLost=function(){setTimeout(function(){o.elem.contains(document.activeElement)?document.activeElement.addEventListener(\"blur\",o._onFocusLost):o.emit(\"lostFocus\")},1)},this._createPickerElement=function(){this.elem=document.createElement(\"div\"),this.elem.classList.add(\"vanilla-color-picker\"),s&&this.elem.classList.add(s)\n// for(var e=i.indexOf(this.targetElem.dataset.vanillaPickerColor),n=0;n-1?e:0\n// this.elem.children[r].focus(),this.elem.children[r].addEventListener(\"blur\",o._onFocusLost)},this._addEventListeners=function(){var e=this\n// this.elem.addEventListener(\"click\",function(t){t.target.classList.contains(\"vanilla-color-picker-single-color\")&&e.emit(\"colorChosen\",t.target.dataset.color)}),this.elem.addEventListener(\"keydown\",function(t){var i=13,n=27,s=t.which||t.keyCode\n// s==i&&e.emit(\"colorChosen\",t.target.dataset.color),s==n&&e.emit(\"lostFocus\")})},this._initialize()}function o(e){n.apply(this),this.set=this.emit,this.colors=c,this.className=\"\",this.elem=e,this.currentPicker=null\n// var t=this\n// this._initialize=function(){this._addEventListeners()},this._addEventListeners=function(){this.elem.addEventListener(\"click\",this.openPicker),this.elem.addEventListener(\"focus\",this.openPicker),this.on(\"customColors\",function(e){if(!(e instanceof Array))throw new Error(\"Colors must be an array\")\n// t.colors=e}),this.on(\"defaultColor\",function(e){t.elem.dataset.vanillaPickerColor||(t._updateElemState(e),t.emit(\"colorChosen\",e,t.elem))}),this.on(\"className\",function(e){t.className=e})},this._updateElemState=function(e){this.elem.dataset.vanillaPickerColor=e,this.elem.value=e},this.destroyPicker=function(){t.currentPicker&&(t.currentPicker.destroy(),t.currentPicker=null,t.emit(\"pickerClosed\"))},this.openPicker=function(){t.currentPicker||(t.currentPicker=new s(t.elem,t.colors,t.className),t.currentPicker.on(\"colorChosen\",function(e){t._updateElemState(e),t.destroyPicker(),t.emit(\"colorChosen\",e,t.elem)}),t.currentPicker.on(\"lostFocus\",function(){t.emit(\"lostFocus\"),t.destroyPicker()}),t.emit(\"pickerCreated\"))},this._initialize()}function r(e,t){return i(),new o(e,t)}var l=\".vanilla-color-picker { display: inline-block; position: absolute; z-index: 100; padding: 5px; background-color: #fff; box-shadow: 1px 1px 2px 1px rgba(0,0,0,0.3) } .vanilla-color-picker-single-color { display: inline-block; width: 20px; height: 20px; margin: 1px; border-radius: 2px; }\",c=[\"red\",\"yellow\",\"green\"]\n// e.define&&e.define.amd?define([],function(){return r}):e.vanillaColorPicker=r}(this||window);\n\n\n\n\n// // // Allow style attributes on text elements to not be stripped out by statamic's sanitizer!\n// Statamic.bard.sanitizer = {\n// tags: {\n// p: { style: true },\n// br: {},\n// b: { style: true },\n// span: { style: true },\n// strong: { style: true },\n// i: { style: true },\n// strike: {},\n// blockquote: {},\n// code: {},\n// ol: { style: true },\n// ul: { style: true },\n// li: { style: true },\n// a: { href: true, target: true, rel: true },\n// h1: { style: true },\n// h2: { style: true },\n// h3: { style: true },\n// h4: { style: true },\n// h5: { style: true },\n// h6: { style: true },\n// u: { style: true },\n// sup: {},\n// sub: {},\n// hr: {},\n// table: {},\n// thead: {},\n// tbody: {},\n// tr: {},\n// td: {},\n// }\n// };\n\n\n// // // Adaptation of this plugin https://github.com/jsiebern/scribe-plugin-span-style\n\n// const scribeInlineColorStyle = function (styleName = 'color') {\n\n// return function(scribe) {\n// var spanStyleCommand = new scribe.api.SimpleCommand(styleName);\n// spanStyleCommand.nodeName = 'SPAN';\n\n// var clearChildStyles = function(root) {\n// if (typeof root === 'undefined' || typeof root.childNodes === 'undefined' || typeof root.nodeType === 'undefined' || root.nodeType === 3) return;\n\n// for (var i in root.childNodes) {\n// clearChildStyles(root.childNodes[i]);\n// }\n\n// root.style[styleName] = '';\n// if (root.nodeName === 'SPAN') {\n// if (!root.getAttribute('style')) {\n// scribe.node.unwrap(root.parentNode, root);\n// }\n// }\n// };\n\n// var nextNode = function(node) {\n// if (node.hasChildNodes()) {\n// return node.firstChild;\n// }\n// else {\n// while (node && !node.nextSibling) {\n// node = node.parentNode;\n// }\n// if (!node) {\n// return null;\n// }\n// return node.nextSibling;\n// }\n// };\n\n// var getRangeSelectedNodes = function(range) {\n// var node = range.startContainer;\n// var endNode = range.endContainer;\n\n// if (node === endNode) {\n// return [node];\n// }\n\n// var rangeNodes = [];\n// while (node && node !== endNode) {\n// rangeNodes.push(node = nextNode(node));\n// }\n\n// node = range.startContainer;\n// while (node && node !== range.commonAncestorContainer) {\n// rangeNodes.unshift(node);\n// node = node.parentNode;\n// }\n\n// return rangeNodes;\n// };\n\n// var getLogicalCombinations = function(fragments) {\n// var p = [];\n// for (var i=0;i -1) {\n// clearChildStyles(root);\n// root.style[styleName] = value;\n// }\n// else if (root.childNodes) {\n// for (var i in root.childNodes) {\n// styleLogicalFragments(root.childNodes[i], fragments, value);\n// }\n// }\n// };\n\n// var normalizeNodes = function(root) {\n// if (typeof root === 'undefined' || root.nodeType === 3 || typeof root.nodeType === 'undefined') return;\n\n// if (root.childNodes) {\n// for (var i in root.childNodes) {\n// normalizeNodes(root.childNodes[i]);\n// }\n// }\n\n// root.normalize();\n// };\n\n// var createSubRange = function(node, start, end) {\n// var subRange = document.createRange();\n// subRange.setStart(node, start);\n// subRange.setEnd(node, end);\n\n// return subRange;\n// };\n\n// spanStyleCommand.execute = function(value) {\n// console.log('executing command', value);\n// var selection = new scribe.api.Selection();\n// var range = selection.range;\n\n// if (typeof value.range !== 'undefined') {\n// // Sometimes a click on the firing element (button etc.) causes the selection to lose focus\n// // If needed a range from the original selection can be passed alongside the value\n// range = value.range;\n// value = value.value;\n// }\n\n// if (range.collapsed) {\n// // Trying to style a collapsed range makes no sense\n// return;\n// }\n\n// scribe.transactionManager.run(function() {\n// var nodes = getRangeSelectedNodes(range);\n\n// if (nodes.length === 1) {\n// var node = nodes[0];\n// var parent = node.parentNode;\n// if (node.nodeType === 3) {\n// if (parent.textContent === range.startContainer.textContent.substr(range.startOffset,range.endOffset)) {\n// clearChildStyles(parent);\n// parent.style[styleName] = value;\n// }\n// else {\n// var span = document.createElement('span');\n// span.style[styleName] = value;\n\n// range.surroundContents(span);\n// }\n// }\n// }\n// else {\n// var startOffset = range.startOffset;\n// var startContainer = range.startContainer;\n// var endOffset = range.endOffset;\n// var endContainer = range.endContainer;\n\n// var fragments = [];\n// for (var i in nodes) {\n// var node = nodes[i];\n// if (node.nodeType === 3) {\n// if (node === range.startContainer) {\n// fragments.push(node.textContent.substr(range.startOffset));\n// }\n// else if (node === range.endContainer) {\n// fragments.push(node.textContent.substr(0,range.endOffset));\n// }\n// else {\n// fragments.push(node.textContent);\n// }\n// }\n// }\n// fragments = getLogicalCombinations(fragments);\n\n// if (scribe.el.childNodes) {\n// for (var i in scribe.el.childNodes) {\n// var rootNode = scribe.el.childNodes[i];\n// styleLogicalFragments(rootNode, fragments, value);\n// }\n// }\n\n// if (startOffset > 0) {\n// var parent = startContainer.parentNode;\n// if (parent.innerText === startContainer.textContent.substr(startOffset)) {\n// clearChildStyles(parent);\n// parent.style[styleName] = value;\n// }\n// else {\n// var subRange = createSubRange(startContainer, startOffset, startContainer.textContent.length);\n\n// var span = document.createElement('span');\n// span.style[styleName] = value;\n\n// subRange.surroundContents(span);\n// }\n// }\n\n// if (endOffset < endContainer.textContent.length) {\n// var parent = endContainer.parentNode;\n// if (parent.innerText === endContainer.textContent.substr(0,endOffset)) {\n// clearChildStyles(parent);\n// parent.style[styleName] = value;\n// }\n// else {\n// var subRange = createSubRange(endContainer, 0, endOffset);\n\n// var span = document.createElement('span');\n// span.style[styleName] = value;\n\n// subRange.surroundContents(span);\n// }\n// }\n\n// }\n\n// if (scribe.el.childNodes) {\n// normalizeNodes(scribe.el);\n// }\n// });\n// };\n\n// spanStyleCommand.queryEnabled = function () {\n// return true;\n// };\n\n// scribe.commands[styleName] = spanStyleCommand;\n// };\n// };\n\n// Statamic.bard.plugins.push(scribeInlineColorStyle);\n\n// (function () {\n\n// var scribePluginColourPicker = function () {\n\n// var scribeRef = null;\n// var selection = null;\n// var picker = null;\n// // var pickerVisible = false;\n\n// var createPicker = function (selection) {\n\n// var picker = vanillaColorPicker(document.querySelector('.bard-toolbar>button[data-original-title=\"Color\"]'));\n// var pickerColors = [\n// '#5D5D5D', '#000000', '#8D85C9', '#022169', '#26458B', '#008996', '#FF7F2E', '#B51783'\n// ];\n\n// picker.set('customColors', pickerColors);\n\n// picker.on('colorChosen', function (color) {\n\n// var selection = new scribeRef.api.Selection();\n// selection.selectMarkers();\n// scribeRef.el.focus();\n\n// setTimeout(function(){\n// var colCommand = scribeRef.getCommand('color');\n// console.log('colCommand', color, selection);\n// colCommand.execute(color);\n// // colCommand.execute({\n// // value: color,\n// // range: selection.range,\n// // });\n\n// selection.selection.removeAllRanges();\n// selection.removeMarkers();\n// }, 10);\n// });\n// }\n\n// return function (scribe) {\n\n// // keep a reference to scribe so we can access in helper functions ^^\n// scribeRef = scribe;\n\n// var togglePickerCommand = new scribe.api.SimpleCommand('showcolorpicker');\n\n// togglePickerCommand.execute = function () {\n\n// var selection = new scribe.api.Selection();\n// selection.placeMarkers();\n// // Hack to avoid loosing the markers within applyFormatters\n// scribe._skipFormatters = true;\n\n// createPicker();\n// };\n\n// togglePickerCommand.queryEnabled = function () {\n// return true;\n// };\n\n// // togglePickerCommand.queryState = function () {\n// // // var activeCommand = (someCommandEnabled() ? firstActiveCommand() : null) || commands[0];\n\n// // // // set the text for the dropdown element to the active command\n// // // // command title text is comming from the actual element inside the dropdown\n// // // activeCommandElement.textContent = activeCommand.title;\n// // // there is no active/inactive state for the dropdown\n// // // so always return false\n// // return true;\n// // };\n\n// scribe.commands.showcolorpicker = togglePickerCommand;\n// };\n// };\n\n// Statamic.bard.plugins.push(scribePluginColourPicker);\n\n// const colorHandler = function (buttons) {\n// buttons.push({\n// text: 'Color',\n// command: 'showcolorpicker',\n// icon: 'paint-brush',\n// });\n// };\n\n// Statamic.bard.buttons.push(colorHandler);\n// }());","(function () {\n\n var scribePluginTabIndent = function () {\n\n return function (scribe) {\n scribe.el.addEventListener('keydown', function (event) {\n // tab pressed\n if (event.keyCode === 9) {\n event.preventDefault();\n\n // check if current selection is inside a list\n var listActive =\n scribe.getCommand('insertUnorderedList').queryState() ||\n scribe.getCommand('insertOrderedList').queryState();\n\n if (event.shiftKey) {\n // when shift is also pressed do an outdent\n scribe.getCommand('outdent').execute();\n } else if (listActive) {\n // when we are in a list indent it by one\n scribe.getCommand('indent').execute();\n }\n }\n });\n };\n };\n\n Statamic.bard.plugins.push(scribePluginTabIndent);\n\n}());","// Statamic.bard.sanitizer = {\n// tags: {\n// p: { style: true },\n// br: {},\n// b: {},\n// span: { style: true },\n// strong: {},\n// i: {},\n// strike: {},\n// blockquote: {},\n// code: {},\n// ol: {},\n// ul: {},\n// li: {},\n// a: { href: true, target: true, rel: true },\n// h1: {},\n// h2: {},\n// h3: {},\n// h4: {},\n// h5: {},\n// h6: {},\n// u: {},\n// sup: {},\n// sub: {},\n// hr: {},\n// table: {},\n// thead: {},\n// tbody: {},\n// tr: {},\n// td: {},\n// }\n// };\n\n// (function () {\n\n// var TABLE_HEADER_PLACEHOLDER = '';\n// var ROW_HEADER_PLACEHOLDER = '';\n// var ROW_HEADER_PLACEHOLDER_ENCODED = '<row header>'; // for html string replace\n\n// var TableUtils = {\n\n// createTableCell: function(nodeName, nodeText) {\n// nodeName = nodeName || 'td';\n// var tableCell = document.createElement(nodeName);\n\n// if (nodeText) {\n// var textNode = document.createTextNode(nodeText);\n// tableCell.appendChild(textNode);\n// }\n\n// return tableCell;\n// },\n\n// createTableRow: function(columnCount, nodeName, nodeText, hasRowHeader) {\n// var isRowHeader;\n// var node;\n// var text;\n// var tableRow = document.createElement('tr');\n\n// for (var i = 0; i < columnCount; i++) {\n// isRowHeader = false;\n// node = nodeName || 'td';\n// text = nodeText || '';\n\n// if (i === 0 && hasRowHeader) {\n// // use row header placeholder\n// isRowHeader = true;\n// node = 'th';\n// text = ROW_HEADER_PLACEHOLDER;\n// }\n\n// tableRow.appendChild(TableUtils.createTableCell(node, text));\n// }\n\n// return tableRow;\n// },\n\n// createTable: function(rowCount, columnCount) {\n// var table = document.createElement('table');\n// var tableBody = document.createElement('tbody');\n\n// for (var i = 0; i < rowCount; i++) {\n// tableBody.appendChild(TableUtils.createTableRow(columnCount, null, null, true));\n// }\n\n// table.appendChild(tableBody);\n// this.insertHeader(table);\n\n// return table;\n// },\n\n// getTableBody: function(table) {\n// var nodes = table.childNodes;\n\n// for (var i = 0; i < nodes.length; i++) {\n// var node = nodes[i];\n// if (node.nodeName === 'TBODY') {\n// return node;\n// }\n// }\n\n// return null;\n// },\n\n// hasHeader: function(table) {\n// var nodes = table.childNodes;\n\n// for (var i = 0; i < nodes.length; i++) {\n// var node = nodes[i];\n// if (node.nodeName === 'THEAD') {\n// return true;\n// }\n// }\n\n// return false;\n// },\n\n// hasRowHeaders: function(table) {\n// var body = TableUtils.getTableBody(table);\n// var nodes = body.childNodes;\n\n// // find first body row with a TH cell\n// for (var i = 0; i < nodes.length; i++) {\n// var node = nodes[i];\n\n// if (node.childNodes[0].nodeName === 'TH') {\n// return true;\n// }\n// }\n\n// return false;\n// },\n\n// hasCaption: function(table) {\n// var nodes = table.childNodes;\n\n// // is always the first child\n// if (nodes[0]) {\n// return nodes[0].nodeName === 'CAPTION';\n// }\n\n// return false;\n// },\n\n// getCaption: function(table) {\n// var caption = TableUtils.getFirstTypeOfNode(table, 'CAPTION');\n\n// return caption ? caption.textContent : '';\n// },\n\n// getColumnCount: function(table) {\n// var rows = TableUtils.getAllRows(table);\n// var maxLength = 0;\n\n// for (var i = 0; i < rows.length; i++) {\n// var rowColumns = rows[i].childNodes.length;\n\n// if (rowColumns > maxLength) {\n// maxLength = rowColumns;\n// }\n// }\n// return maxLength;\n// },\n\n// getBodyRowCount: function(table) {\n// var body = TableUtils.getTableBody(table);\n// return body.childNodes.length;\n// },\n\n// getAllRows: function(table) {\n// var rows = [];\n// var tableNodes = table.childNodes;\n// for (var i = 0; i < tableNodes.length; i++) {\n// var tableNode = tableNodes[i];\n// Array.prototype.push.apply(rows, Array.prototype.slice.call(tableNode.childNodes));\n// }\n\n// return rows;\n// },\n\n// getFirstTypeOfNode: function(parent, nodeName) {\n// var child = parent.childNodes;\n// for (var i = 0; i < child.length; i++) {\n// if (child[i].nodeName === nodeName) {\n// return child[i];\n// }\n// }\n\n// return null;\n// },\n\n// // Finder operations\n\n// findTable: function(scribe, el) {\n// while (el && el !== scribe.el && el.nodeName !== 'TABLE') {\n// el = el.parentNode;\n// }\n\n// if (el && el.nodeName !== 'TABLE') {\n// el = null;\n// }\n\n// return el;\n// },\n\n// findTableCell: function(scribe, el) {\n// while (el && el !== scribe.el && (el.nodeName !== 'TD' && el.nodeName !== 'TH')) {\n// el = el.parentNode;\n// }\n\n// if (el && (el.nodeName !== 'TD' && el.nodeName !== 'TH')) {\n// el = null;\n// }\n\n// return el;\n// },\n\n// findCellPosition: function(table, targetTableCell) {\n// var rows = TableUtils.getAllRows(table);\n// var position = {\n// rowIndex: -1,\n// columnIndex: -1\n// };\n\n// rows.every(function(row, rowIndex) {\n// var cells = Array.prototype.slice.call(row.childNodes);\n\n// cells.every(function(cell, columnIndex) {\n// if (cell === targetTableCell) {\n// position = {\n// rowIndex: rowIndex,\n// columnIndex: columnIndex\n// };\n\n// return false;\n// }\n\n// return true;\n// });\n\n// if (position.rowIndex !== -1) {\n// return false;\n// }\n\n// return true;\n// });\n\n// return position;\n// },\n\n// // Row operations\n\n// insertRow: function(scribe, table, rowIndex) {\n// var columnCount = TableUtils.getColumnCount(table);\n// var body = TableUtils.getTableBody(table);\n// var hasRowHeaders = TableUtils.hasRowHeaders(table);\n// var rowAtIndex = body.childNodes[rowIndex];\n// var newRow = TableUtils.createTableRow(columnCount, null, null, hasRowHeaders);\n\n// scribe.transactionManager.run(function() {\n// body.insertBefore(newRow, rowAtIndex);\n// this.select(scribe, newRow.childNodes[0]);\n// }.bind(this));\n// },\n\n// removeRow: function(scribe, table, rowIndex) {\n// if (this.getBodyRowCount(table) === 1) {\n// this.removeTable(scribe, table);\n// return;\n// }\n\n// var body = TableUtils.getTableBody(table);\n// var rowAtIndex = body.childNodes[rowIndex];\n\n// scribe.transactionManager.run(function() {\n// body.removeChild(rowAtIndex);\n\n// if (rowIndex >= TableUtils.getBodyRowCount(table)) {\n// rowIndex --;\n// }\n\n// this.select(scribe, body.childNodes[rowIndex].childNodes[0]);\n// }.bind(this));\n// },\n\n// // Column operations\n\n// insertColumn: function(scribe, table, columnIndex) {\n// var rows = TableUtils.getAllRows(table);\n// var hasHeader = TableUtils.hasHeader(table);\n// var hasRowHeaders = TableUtils.hasRowHeaders(table);\n// var cellName;\n// var cellText;\n\n// scribe.transactionManager.run(function() {\n// rows.forEach(function(row, idx) {\n// if (idx === 0 && hasHeader) {\n// cellText = TABLE_HEADER_PLACEHOLDER;\n// } else {\n// cellText = '';\n// }\n\n// cellName = hasRowHeaders ? row.childNodes[1].nodeName : row.childNodes[0].nodeName\n\n// var cell = TableUtils.createTableCell(cellName, cellText);\n// row.insertBefore(cell, row.childNodes[columnIndex]);\n// });\n\n// // Find a cell to select\n// for (var i = 0; i < rows.length; i++) {\n// var row = rows[i];\n\n// if (row.childNodes.length > columnIndex) {\n// this.select(scribe, row.childNodes[columnIndex]);\n// break;\n// }\n// }\n// }.bind(this));\n// },\n\n// // TODO Support the removal of columns at the header and footer\n// removeColumn: function(scribe, table, columnIndex) {\n// var columnCount = this.getColumnCount(table);\n// var body = TableUtils.getTableBody(table);\n// var rows = TableUtils.getAllRows(table);\n\n// if (columnCount === 1) {\n// this.removeTable(scribe, table);\n// return;\n// }\n\n// scribe.transactionManager.run(function() {\n// rows.forEach(function(row) {\n// row.removeChild(row.childNodes[columnIndex]);\n// });\n\n// this.select(scribe, body.childNodes[0].childNodes[0]);\n// }.bind(this));\n// },\n\n// insertHeader: function(table) {\n// var tableHead = document.createElement('thead');\n// tableHead.appendChild(TableUtils.createTableRow(\n// TableUtils.getColumnCount(table), 'th', TABLE_HEADER_PLACEHOLDER)\n// );\n\n// table.insertBefore(tableHead, table.childNodes[0]);\n// },\n\n// insertFooter: function(table) {\n// var tableFoot = document.createElement('tfoot');\n// tableFoot.appendChild(TableUtils.createTableRow(TableUtils.getColumnCount(table)));\n\n// table.appendChild(tableFoot);\n// },\n\n// removeHeader: function(scribe, table) {\n// var header = TableUtils.getFirstTypeOfNode(table, 'THEAD');\n\n// scribe.transactionManager.run(function() {\n// table.removeChild(header);\n// }.bind(this));\n// },\n\n// removeFooter: function(scribe, table) {\n// var footer = TableUtils.getFirstTypeOfNode(table, 'TFOOT');\n\n// scribe.transactionManager.run(function() {\n// table.removeChild(footer);\n// }.bind(this));\n// },\n\n// removeRowHeaders: function(scribe, table) {\n// if (TableUtils.hasRowHeaders(table)) {\n// var body = TableUtils.getTableBody(table);\n// var rows = body.childNodes;\n\n// for (var i = 0; i < rows.length; i++) {\n// var row = rows[i];\n// var headerCell = row.childNodes[0];\n\n// // replace TH with TD and remove placeholder\n// headerCell.outerHTML = headerCell.outerHTML\n// .replace('', ' ')\n// .replace('', ' ')\n// .replace(ROW_HEADER_PLACEHOLDER_ENCODED, '');\n// }\n// }\n// },\n\n// insertCaption: function(scribe, table) {\n// var tableCaption = document.createElement('caption');\n// var existingCaption = TableUtils.hasCaption(table) ? TableUtils.getCaption(table) : '';\n// var captionText = window.prompt(\n// 'Enter a descriptive caption for this table',\n// existingCaption\n// );\n\n// if (existingCaption) {\n// TableUtils.removeCaption(scribe, table);\n// }\n\n// var textNode = document.createTextNode(captionText);\n\n// tableCaption.appendChild(textNode);\n// table.insertBefore(tableCaption, table.childNodes[0]);\n// },\n\n// removeCaption: function(scribe, table) {\n// var caption = TableUtils.getFirstTypeOfNode(table, 'CAPTION');\n\n// scribe.transactionManager.run(function() {\n// table.removeChild(caption);\n// }.bind(this));\n// },\n\n// // Table operations\n\n// removeTable: function(scribe, table) {\n// scribe.transactionManager.run(function() {\n// scribe.el.removeChild(table);\n// this.select(scribe, scribe.el.childNodes[0]);\n// }.bind(this));\n// },\n\n// select: function(scribe, el) {\n// var selection = new scribe.api.Selection();\n// selection.range.setStart(el, 0);\n// selection.range.collapse(true);\n\n// selection.selection.removeAllRanges();\n// selection.selection.addRange(selection.range);\n// }\n\n// };\n\n// // Actions supported by the context menu\n// var TABLE_ACTIONS = [\n// {\n// text: 'Insert row above',\n// run: function(scribe, table, tableCell, action, cellPosition) {\n// var rowIndex = cellPosition.rowIndex;\n\n// if (TableUtils.hasHeader(table)) {\n// rowIndex = rowIndex - 1; // account for header\n// }\n\n// TableUtils.insertRow(scribe, table, rowIndex);\n// },\n// test: function(table, tableCell) { return tableCell.parentNode.parentNode.nodeName === 'TBODY' }\n// },\n// {\n// text: 'Insert row below',\n// run: function(scribe, table, tableCell, action, cellPosition) {\n// var rowIndex = cellPosition.rowIndex + 1;\n\n// if (TableUtils.hasHeader(table)) {\n// rowIndex = rowIndex - 1; // account for header\n// }\n\n// TableUtils.insertRow(scribe, table, rowIndex);\n// },\n// test: function(table, tableCell) { return tableCell.parentNode.parentNode.nodeName === 'TBODY' }\n// },\n// {\n// text: 'Insert column left',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertColumn(scribe, table, cellPosition.columnIndex) }\n// },\n// {\n// text: 'Insert column right',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertColumn(scribe, table, cellPosition.columnIndex + 1) }\n// },\n// {\n// text: 'Insert header',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertHeader(table) },\n// test: function(table, tableCell) { return TableUtils.getFirstTypeOfNode(table, 'THEAD') === null }\n// },\n// {\n// text: 'Remove header',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeHeader(scribe, table) },\n// test: function(table, tableCell) { return tableCell.parentNode.parentNode.nodeName === 'THEAD' }\n// },\n// {\n// text: 'Remove row headers',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeRowHeaders(scribe, table) },\n// test: function(table, tableCell) { return TableUtils.hasRowHeaders(table) }\n// },\n// {\n// text: 'Delete row',\n// run: function(scribe, table, tableCell, action, cellPosition) {\n// var rowIndex = cellPosition.rowIndex;\n\n// if (TableUtils.hasHeader(table)) {\n// rowIndex = rowIndex - 1; // account for header\n// }\n\n// TableUtils.removeRow(scribe, table, rowIndex)\n// },\n// test: function(table, tableCell) { return tableCell.parentNode.parentNode.nodeName === 'TBODY' }\n// },\n// {\n// text: 'Delete column',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeColumn(scribe, table, cellPosition.columnIndex) }\n// },\n// {\n// text: 'Delete table',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeTable(scribe, table) }\n// },\n// {\n// text: 'Insert caption',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertCaption(scribe, table) },\n// test: function(table, tableCell) { return !TableUtils.hasCaption(table) }\n// },\n// {\n// text: 'Edit caption',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertCaption(scribe, table) },\n// test: function(table, tableCell) { return TableUtils.hasCaption(table) }\n// },\n// {\n// text: 'Remove caption',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeCaption(scribe, table) },\n// test: function(table, tableCell) { return TableUtils.hasCaption(table) }\n// },\n// {\n// text: 'Insert footer',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.insertFooter(table) },\n// test: function(table, tableCell) { return TableUtils.getFirstTypeOfNode(table, 'TFOOT') === null }\n// },\n// {\n// text: 'Delete footer',\n// run: function(scribe, table, tableCell, action, cellPosition) { TableUtils.removeFooter(scribe, table) },\n// test: function(table, tableCell) { return tableCell.parentNode.parentNode.nodeName === 'TFOOT' }\n// },\n// ];\n\n// var CONTEXT_MENU_CLASS = 'scribe-table-context-menu';\n// var CONTEXT_MENU_ACTION_CLASS = 'scribe-table-context-menu-action';\n\n// var getOffset = function(el) {\n// var top = 0;\n// var left = 0;\n\n// while (el) {\n// top += el.offsetTop;\n// left += el.offsetLeft;\n\n// if (el !== document.body) {\n// top -= el.scrollTop;\n// }\n\n// el = el.offsetParent;\n// }\n\n// return {\n// top: top,\n// left: left\n// };\n// };\n\n// var TableContextMenu = function(scribe) {\n\n// /**\n// * Show right click context menu.\n// * @param {HTMLElement} table Table element\n// * @param {HTMLElement} tableCell Target cell of the right click.\n// */\n// this.show = function(table, tableCell) {\n// this.hide();\n\n// var menu = document.createElement('div');\n// var offset = getOffset(tableCell);\n\n// menu.className = CONTEXT_MENU_CLASS;\n// menu.style.top = offset.top + 20 + 'px';\n// menu.style.left = offset.left + 20 + 'px';\n\n// var cellPosition = TableUtils.findCellPosition(table, tableCell);\n\n// TABLE_ACTIONS.forEach(function(action) {\n// // only render menu items that are actionable at the\n// // current state of the table\n// if (action.test && !action.test(table, tableCell)) {\n// return;\n// }\n\n// var option = document.createElement('div');\n// option.className = CONTEXT_MENU_ACTION_CLASS;\n// option.textContent = action.text;\n\n// option.addEventListener('click', function(event) {\n// event.preventDefault();\n// event.stopPropagation();\n// action.run(scribe, table, tableCell, action, cellPosition);\n// this.hide();\n// }.bind(this));\n\n// menu.appendChild(option);\n// }.bind(this));\n\n// document.body.appendChild(menu);\n\n// document.addEventListener('click', function(event) {\n// // ignore right click from the contextmenu event.\n// if (event.which !== 3) {\n// this.hide();\n// }\n// }.bind(this));\n// };\n\n// /**\n// * Hide right click context menu.\n// */\n// this.hide = function() {\n// var menu = document.getElementsByClassName(CONTEXT_MENU_CLASS)[0];\n// if (menu) {\n// menu.parentNode.removeChild(menu);\n// }\n\n// document.removeEventListener('click', this.hide);\n// };\n\n// return this;\n// };\n\n// var scribeTablePlugin = function () {\n\n// return function(scribe) {\n\n// var tableCommand = new scribe.api.Command('insertTable');\n// var contextMenu = new TableContextMenu(scribe);\n\n// tableCommand.nodeName = 'TABLE';\n\n// tableCommand.execute = function() {\n// var tableElement = TableUtils.createTable(3, 3);\n\n// scribe.transactionManager.run(function() {\n// var selection = new scribe.api.Selection();\n\n// var el = findBlockContainer(selection.range.endContainer);\n// var nextElement = el.nextSibling;\n\n// if (nextElement) {\n// // TODO Fix this\n// scribe.el.insertBefore(tableElement, nextElement);\n// } else {\n// scribe.el.appendChild(tableElement);\n// scribe.el.appendChild(document.createElement('p'));\n// }\n\n// var body = tableElement.childNodes[0];\n// var firstRow = body.childNodes[0];\n// var firstCell = firstRow.childNodes[0];\n\n// TableUtils.select(scribe, firstCell);\n// });\n// };\n\n// tableCommand.queryState = function() {\n// var selection = new scribe.api.Selection();\n// return selection.getContaining(function(node) {\n// return (node.nodeName === this.nodeName);\n// }.bind(this));\n// };\n\n// tableCommand.queryEnabled = function() {\n// return true;\n// };\n\n// /**\n// * Find block container for the given element.\n// * @param {HTMLElement} el\n// */\n// function findBlockContainer(el) {\n// while (el && !scribe.element.isBlockElement(el)) {\n// el = el.parentNode;\n// }\n\n// return el;\n// }\n\n// /**\n// * Handle right click inside the scribe editor.\n// */\n// function handleRightClick(event) {\n// event.preventDefault();\n// var target = event.target || event.toElement;\n\n// console.log('right click!', target);\n\n// if (!target) {\n// return;\n// }\n\n// var tableCell = TableUtils.findTableCell(scribe, target);\n// var table = TableUtils.findTable(scribe, tableCell);\n\n// if (table) {\n// event.preventDefault();\n// event.stopPropagation();\n// contextMenu.show(table, tableCell);\n// }\n// }\n\n// scribe.el.addEventListener('contextmenu', handleRightClick);\n\n// console.log('scribe.commands', scribe);\n// scribe.commands.table = tableCommand;\n// };\n// };\n\n// Statamic.bard.plugins.push(scribeTablePlugin);\n\n// var handler = function (buttons) {\n// buttons.push({\n// text: 'Table', // Tooltip text when you hover the button\n// command: 'table', // The command you defined in your Scribe plugin\n// html: 'Table ', // Either the html contents of the button...\n// // icon: 'header', // ...or you can specify a font awesome icon name.\n// });\n// };\n\n// Statamic.bard.buttons.push(handler);\n\n// }());","(function($)\n{\n\t$.Redactor.prototype.table = function()\n\t{\n\t\treturn {\n\t\t\tlangs: {\n\t\t\t\ten: {\n\t\t\t\t\t\"table\": \"Table\",\n\t\t\t\t\t\"insert-table\": \"Insert table\",\n\t\t\t\t\t\"insert-row-above\": \"Insert row above\",\n\t\t\t\t\t\"insert-row-below\": \"Insert row below\",\n\t\t\t\t\t\"insert-column-left\": \"Insert column left\",\n\t\t\t\t\t\"insert-column-right\": \"Insert column right\",\n\t\t\t\t\t\"add-head\": \"Add head\",\n\t\t\t\t\t\"delete-head\": \"Delete head\",\n\t\t\t\t\t\"delete-column\": \"Delete column\",\n\t\t\t\t\t\"delete-row\": \"Delete row\",\n\t\t\t\t\t\"delete-table\": \"Delete table\"\n\t\t\t\t}\n\t\t\t},\n\t\t\tinit: function()\n\t\t\t{\n\t\t\t\tvar dropdown = {};\n\n\t\t\t\tdropdown.insert_table = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('insert-table'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.insert,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tin: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.insert_row_above = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('insert-row-above'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.addRowAbove,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.insert_row_below = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('insert-row-below'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.addRowBelow,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.insert_column_left = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('insert-column-left'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.addColumnLeft,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.insert_column_right = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('insert-column-right'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.addColumnRight,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.add_head = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('add-head'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.addHead,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.delete_head = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('delete-head'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.deleteHead,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.delete_column = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('delete-column'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.deleteColumn,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.delete_row = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('delete-row'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.deleteRow,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\tdropdown.delete_table = {\n\t\t\t\t\t\t\t\t\ttitle: this.lang.get('delete-table'),\n\t\t\t\t\t\t\t\t\tfunc: this.table.deleteTable,\n\t\t\t\t\t\t\t\t\tobserve: {\n\t\t\t\t\t\t\t\t\t\telement: 'table',\n\t\t\t\t\t\t\t\t\t\tout: {\n\t\t\t\t\t\t\t\t\t\t\tattr: {\n\t\t\t\t\t\t\t\t\t\t\t\t'class': 'redactor-dropdown-link-inactive',\n\t\t\t\t\t\t\t\t\t\t\t\t'aria-disabled': true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\n\t\t\t\tvar button = this.button.addBefore('link', 'table', this.lang.get('table'));\n\t\t\t\tthis.button.addDropdown(button, dropdown);\n\t\t\t},\n\t\t\tinsert: function()\n\t\t\t{\n\t\t\t\tif (this.table.getTable())\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.placeholder.hide();\n\n\t\t\t\tvar rows = 2;\n\t\t\t\tvar columns = 3;\n\t\t\t\tvar $tableBox = $('');\n\t\t\t\tvar $table = $('
');\n\n\n\t\t\t\tfor (var i = 0; i < rows; i++)\n\t\t\t\t{\n\t\t\t\t\tvar $row = $('
');\n\n\t\t\t\t\tfor (var z = 0; z < columns; z++)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar $column = $('' + this.opts.invisibleSpace + ' ');\n\n\t\t\t\t\t\t// set the focus to the first td\n\t\t\t\t\t\tif (i === 0 && z === 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$column.append(this.marker.get());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$($row).append($column);\n\t\t\t\t\t}\n\n\t\t\t\t\t$table.append($row);\n\t\t\t\t}\n\n\t\t\t\t$tableBox.append($table);\n\t\t\t\tvar html = $tableBox.html();\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tvar current = this.selection.current();\n\t\t\t\tif ($(current).closest('li').length !== 0)\n\t\t\t\t{\n\t\t\t\t\t$(current).closest('ul, ol').first().after(html);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthis.air.collapsed();\n\t\t\t\t\tthis.insert.html(html);\n\t\t\t\t}\n\n\t\t\t\tthis.selection.restore();\n\t\t\t\tthis.core.callback('insertedTable', $table);\n\t\t\t},\n\t\t\tgetTable: function()\n\t\t\t{\n\t\t\t\tvar $table = $(this.selection.current()).closest('table');\n\n\t\t\t\tif (!this.utils.isRedactorParent($table))\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ($table.size() === 0)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn $table;\n\t\t\t},\n\t\t\trestoreAfterDelete: function($table)\n\t\t\t{\n\t\t\t\tthis.selection.restore();\n\t\t\t\t$table.find('span.redactor-selection-marker').remove();\n\n\t\t\t},\n\t\t\tdeleteTable: function()\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.buffer.set();\n\n\n\t\t\t\tvar $next = $table.next();\n\t\t\t\tif (!this.opts.linebreaks && $next.length !== 0)\n\t\t\t\t{\n\t\t\t\t\tthis.caret.start($next);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthis.caret.after($table);\n\t\t\t\t}\n\n\n\t\t\t\t$table.remove();\n\n\n\t\t\t},\n\t\t\tdeleteRow: function()\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar $current = $(this.selection.current());\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tvar $current_tr = $current.closest('tr');\n\t\t\t\tvar $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next();\n\t\t\t\tif ($focus_tr.length)\n\t\t\t\t{\n\t\t\t\t\tvar $focus_td = $focus_tr.children('td, th').first();\n\t\t\t\t\tif ($focus_td.length)\n\t\t\t\t\t{\n\t\t\t\t\t\t$focus_td.prepend(this.marker.get());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t$current_tr.remove();\n\t\t\t\tthis.table.restoreAfterDelete($table);\n\t\t\t},\n\t\t\tdeleteColumn: function()\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tvar $current = $(this.selection.current());\n\t\t\t\tvar $current_td = $current.closest('td, th');\n\t\t\t\tvar index = $current_td[0].cellIndex;\n\n\t\t\t\t$table.find('tr').each($.proxy(function(i, elem)\n\t\t\t\t{\n\t\t\t\t\tvar $elem = $(elem);\n\t\t\t\t\tvar focusIndex = index - 1 < 0 ? index + 1 : index - 1;\n\t\t\t\t\tif (i === 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t$elem.find('td, th').eq(focusIndex).prepend(this.marker.get());\n\t\t\t\t\t}\n\n\t\t\t\t\t$elem.find('td, th').eq(index).remove();\n\n\t\t\t\t}, this));\n\n\t\t\t\tthis.table.restoreAfterDelete($table);\n\t\t\t},\n\t\t\taddHead: function()\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tif ($table.find('thead').size() !== 0)\n\t\t\t\t{\n\t\t\t\t\tthis.table.deleteHead();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar tr = $table.find('tr').first().clone();\n\t\t\t\ttr.find('td').replaceWith($.proxy(function()\n\t\t\t\t{\n\t\t\t\t\treturn $('').html(this.opts.invisibleSpace);\n\t\t\t\t}, this));\n\n\t\t\t\t$thead = $(' ').append(tr);\n\t\t\t\t$table.prepend($thead);\n\n\n\n\t\t\t},\n\t\t\tdeleteHead: function()\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar $thead = $table.find('thead');\n\t\t\t\tif ($thead.size() === 0)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\t$thead.remove();\n\n\t\t\t},\n\t\t\taddRowAbove: function()\n\t\t\t{\n\t\t\t\tthis.table.addRow('before');\n\t\t\t},\n\t\t\taddRowBelow: function()\n\t\t\t{\n\t\t\t\tthis.table.addRow('after');\n\t\t\t},\n\t\t\taddColumnLeft: function()\n\t\t\t{\n\t\t\t\tthis.table.addColumn('before');\n\t\t\t},\n\t\t\taddColumnRight: function()\n\t\t\t{\n\t\t\t\tthis.table.addColumn('after');\n\t\t\t},\n\t\t\taddRow: function(type)\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tvar $current = $(this.selection.current());\n\t\t\t\tvar $current_tr = $current.closest('tr');\n\t\t\t\tvar new_tr = $current_tr.clone();\n\n\t\t\t\tnew_tr.find('th').replaceWith(function()\n\t\t\t\t{\n\t\t\t\t\tvar $td = $(' ');\n\t\t\t\t\t$td[0].attributes = this.attributes;\n\n\t\t\t\t\treturn $td.append($(this).contents());\n\t\t\t\t});\n\n\t\t\t\tnew_tr.find('td').html(this.opts.invisibleSpace);\n\n\t\t\t\tif (type === 'after')\n\t\t\t\t{\n\t\t\t\t\t$current_tr.after(new_tr);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t$current_tr.before(new_tr);\n\t\t\t\t}\n\n\n\t\t\t},\n\t\t\taddColumn: function (type)\n\t\t\t{\n\t\t\t\tvar $table = this.table.getTable();\n\t\t\t\tif (!$table)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar index = 0;\n\t\t\t\tvar current = $(this.selection.current());\n\n\t\t\t\tthis.buffer.set();\n\n\t\t\t\tvar $current_tr = current.closest('tr');\n\t\t\t\tvar $current_td = current.closest('td, th');\n\n\t\t\t\t$current_tr.find('td, th').each($.proxy(function(i, elem)\n\t\t\t\t{\n\t\t\t\t\tif ($(elem)[0] === $current_td[0])\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t}\n\n\t\t\t\t}, this));\n\n\t\t\t\t$table.find('tr').each($.proxy(function(i, elem)\n\t\t\t\t{\n\t\t\t\t\tvar $current = $(elem).find('td, th').eq(index);\n\n\t\t\t\t\tvar td = $current.clone();\n\t\t\t\t\ttd.html(this.opts.invisibleSpace);\n\n\t\t\t\t\tif (type === 'after')\n\t\t\t\t\t{\n\t\t\t\t\t\t$current.after(td);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t$current.before(td);\n\t\t\t\t\t}\n\n\t\t\t\t}, this));\n\n\n\t\t\t}\n\t\t};\n\t};\n})(jQuery);",""]}