/** * Based on the tables plugin for tinyMCE developed by Moxiecode Systems AB * Released under LGPL License. * * License: http://tinymce.moxiecode.com/license * Contributing: http://tinymce.moxiecode.com/contributing */ var annoTable; (function($){ var inputs = {}, ed; annoTable = { keySensitivity: 100, textarea: function() { return edCanvas; }, init : function() { inputs.dialog = $('#anno-popup-table'); inputs.submit = $('#anno-table-submit'); inputs.dialog.keydown( annoTable.keydown ); inputs.dialog.keyup( annoTable.keyup ); inputs.submit.click( function(e){ annoTable.update(); e.preventDefault(); }); $('#anno-table-cancel').click(annoTable.close); inputs.dialog.bind('wpdialogbeforeopen', annoTable.beforeOpen); inputs.dialog.bind('wpdialogclose', annoTable.onClose); }, beforeOpen : function() { annoTable.range = null; if ( ! annoTable.isMCE() && document.selection ) { annoTable.textarea().focus(); annoTable.range = document.selection.createRange(); } }, isMCE : function() { return true; // Unlikely a non mce context }, close : function() { var ed = tinymce.activeEditor; ed.windowManager.close(); inputs.dialog.find('input:not(.button),textarea').val(''); ed.focus(); }, onClose: function() { if ( ! annoTable.isMCE() ) { annoTable.textarea().focus(); if ( annoTable.range ) { annoTable.range.moveToBookmark( annoTable.range.getBookmark() ); annoTable.range.select(); } } }, update : function() { var ed = tinymce.activeEditor, e, b, html = ''; var formObj = $('#anno-tinymce-table-form'); cols = $('input[name$="cols"]', formObj).val(); rows = $('input[name$="rows"]', formObj).val(); label = $('input[name$="label"]', formObj).val(); caption = $('textarea[name$="caption"]', formObj).val(); html += '