/*! * medium-editor-insert-plugin v0.3.2 - jQuery insert plugin for MediumEditor * * https://github.com/orthes/medium-editor-insert-plugin * * Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk) * Released under the MIT license */ !function(a){a.fn.mediumInsert.registerAddon("tables",{defaults:{defaultRows:2,defaultCols:2},init:function(b){this.options=a.extend(this.defaults,b),this.$el=a.fn.mediumInsert.insert.$el,this.setTableButtonEvents()},insertButton:function(a){var b="Table";return("fontawesome"===a||"object"==typeof a&&a.fontawesome)&&(b=''),"object"==typeof a&&a.table&&(b=a.table),'"},add:function(b){a.fn.mediumInsert.insert.deselect();var c='
';a(c).appendTo(b.prev()),this.updateDemoTable(),setTimeout(function(){b.prev().find("input").focus()},50),a.fn.mediumInsert.insert.deselect(),this.currentPlaceholder=b},setTableButtonEvents:function(){var b=this;a(document).on("keyup","input.mediumInsert-tableRows, input.mediumInsert-tableCols",function(){b.updateDemoTable()}),a(document).on("click",function(c){0===a(c.target).parents(".mediumInsert-buttons").length&&b.removeToolbar()}),a(document).on("click","button.mediumInsert-tableReadyButton",function(){b.setEnterActionEvents(),b.removeToolbar()})},getDimensions:function(){return{rows:parseFloat(a("input.mediumInsert-tableRows").val())||1,cols:parseFloat(a("input.mediumInsert-tableCols").val())||1}},buildTable:function(b){var c,d,e,f=this.getDimensions(),g=a(b);for(c=0;c"),d=0;d");g.append(e)}},updateDemoTable:function(){var b=a("table.mediumInsert-demoTable");b.empty(),this.buildTable(b)},setEnterActionEvents:function(){var b=this;if(a.fn.mediumInsert.settings.enabled===!1)return!1;var c=a('');b.buildTable(c),b.currentPlaceholder.append(c),b.currentPlaceholder.closest("[data-medium-element]").trigger("keyup").trigger("input")},removeToolbar:function(){a(".mediumInsert-tableDemoBox").remove()}})}(jQuery);