diff --git a/README.md b/README.md index cb4cba35e..ce5e787eb 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ For styling the content in frontend (where it will be read only without editing - **uploadFile**: (function ($placeholder, file, that)) function uploading an image to a server - **deleteFile**: (function (file, that)) function deleting an image from a server - **embeds**: - - **urlPlaceholder**: (string) placeholder displayed when entering URL to embed. Default: *type or paste url here* + - **urlPlaceholder**: (string) placeholder displayed when entering URL to embed. Default: *Paste or type a link* - **oembedProxy**: (string) URL to oEmbed proxy endpoint, such as Iframely, Embedly or your own. You are welcome to use "http://medium.iframe.ly/api/oembed?iframe=1" for your dev and testing needs, courtesy of [Iframely](https://iframely.com). Default: none, which will make the plugin use pre-defined set of embed rules without making server calls. - **tables**: - **defaultRows**: (integer) default number of rows. Default: *2* diff --git a/dist/css/medium-editor-insert-plugin.css b/dist/css/medium-editor-insert-plugin.css index b1716ebe7..5e3e32f14 100644 --- a/dist/css/medium-editor-insert-plugin.css +++ b/dist/css/medium-editor-insert-plugin.css @@ -194,9 +194,7 @@ background-color: #fff; } .mediumInsert .mediumInsert-embedsWire { position: absolute; - bottom: 24px; left: 50%; - width: 500px; text-align: center; } .mediumInsert .mediumInsert-embedsBox { position: relative; diff --git a/dist/css/medium-editor-insert-plugin.min.css b/dist/css/medium-editor-insert-plugin.min.css index 648b1ec95..a9066a6e5 100644 --- a/dist/css/medium-editor-insert-plugin.min.css +++ b/dist/css/medium-editor-insert-plugin.min.css @@ -7,4 +7,4 @@ * Released under the MIT license */ -.mediumInsert{margin:-1em 0}.mediumInsert figure{margin:0;display:inline-block}.mediumInsert img{max-width:100%}.mediumInsert .mediumInsert-embeds{text-align:center;padding:15px}.mediumInsert .mediumInsert-embeds iframe,.mediumInsert .mediumInsert-embeds div{margin:0 auto!important}.mediumInsert .mediumInsert-images{margin-right:10px;width:20%}.mediumInsert .mediumInsert-images img{margin-top:1em;margin-bottom:10px;vertical-align:top}.mediumInsert .mediumInsert-images:first-child{margin-right:0;width:auto}.mediumInsert .mediumInsert-images:first-child:after{content:"\a";white-space:pre}.mediumInsert .mediumInsert-maps{padding:10px;background:#ccc}.mediumInsert table.mediumInsert-table{border-top:2px solid #333;border-left:2px solid #333;width:90%;margin:30px auto}.mediumInsert table.mediumInsert-table td{border-right:2px solid #333;border-bottom:2px solid #333;padding:12px}.mediumInsert.small{float:left;margin-right:30px}.medium-editor-insert-plugin .clearfix:before,.medium-editor-insert-plugin:before,.medium-editor-insert-plugin .clearfix:after,.medium-editor-insert-plugin:after{content:" ";display:table}.medium-editor-insert-plugin .clearfix:after,.medium-editor-insert-plugin:after{clear:both}.medium-editor-insert-plugin img{max-width:100%}.medium-editor-insert-plugin q,.medium-editor-insert-plugin blockquote{display:block;margin-top:1em;margin-bottom:1em;border-left:5px solid #efefef;padding-left:20px;margin-left:-25px}.medium-editor-insert-plugin [draggable]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.medium-editor-insert-plugin[contenteditable],.medium-editor-insert-plugin [contenteditable]{outline:0 solid transparent}.medium-editor-insert-plugin[contenteditable]:focus,.medium-editor-insert-plugin [contenteditable]:focus{outline:0 solid transparent}.medium-editor-insert-plugin *{-moz-box-sizing:content-box;box-sizing:content-box}.medium-editor-insert-plugin p{margin:1em 0}.medium-editor-insert-plugin progress{display:block;margin:1em auto}.medium-editor-insert-plugin .hide{display:none!important}.medium-editor-insert-plugin.hover .mediumInsert-placeholder{min-height:14px;border:1px dashed #ddd;margin-top:-1px;margin-bottom:-1px}.medium-editor-insert-plugin.medium-editor-placeholder{padding-bottom:0!important;min-height:58px}.medium-editor-insert-plugin.medium-editor-placeholder:after{content:attr(data-placeholder)!important;top:1em}.mediumInsert{position:relative;margin-left:-40px!important;min-height:18px}.mediumInsert.small{width:calc(33.33% + 40px)}.mediumInsert .mediumInsert-buttonsShow{opacity:0;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-transition:all .08s cubic-bezier(.2,.3,.25,.9);transition:all .08s cubic-bezier(.2,.3,.25,.9);display:block;width:18px;height:18px;margin-top:-5px;border-radius:10px;border:2px solid;font-size:18px;line-height:18px;text-align:center;text-decoration:none!important}.mediumInsert .mediumInsert-buttonsShow:after{left:auto;right:100%;top:50%;margin-top:-4px}.mediumInsert .mediumInsert-buttons{position:absolute;width:40px;bottom:0;left:0;color:#ddd;font-size:.9em}.mediumInsert .mediumInsert-buttons a{text-decoration:underline;cursor:pointer}.mediumInsert .mediumInsert-buttons a.active{font-weight:700}.mediumInsert ul.mediumInsert-buttonsOptions{margin:0;padding:0;list-style:none;display:none;position:absolute;z-index:2;left:40px;top:-10px;border-radius:5px}.mediumInsert ul.mediumInsert-buttonsOptions button{min-height:auto;height:auto;padding:5px;border-left:none;float:none}.mediumInsert ul.mediumInsert-buttonsOptions button .fa{font-size:20px}.mediumInsert .mediumInsert-placeholder{position:relative;margin-left:40px;text-align:center}.mediumInsert .mediumInsert-images a{position:absolute;top:1em;width:30px;height:30px;background-color:#3b3b3b;background-repeat:no-repeat;background-position:center center;cursor:pointer}.mediumInsert .mediumInsert-imageRemove{right:0;background-image:url(../images/remove.png)}.mediumInsert .mediumInsert-imageResizeSmaller,.mediumInsert .mediumInsert-imageResizeBigger{right:31px;background-image:url(../images/resize-smaller.png)}.mediumInsert .mediumInsert-imageResizeBigger{background-image:url(../images/resize-bigger.png)}.mediumInsert .mediumInsert-error{background-color:#f2dede;border:1px solid #ebccd1;color:#a94442;padding:15px}.mediumInsert .mediumInsert-embedsPlaceholder{position:relative;padding:24px;height:160px;text-align:center;background-color:#fff}.mediumInsert .mediumInsert-embedsWire{position:absolute;bottom:24px;left:50%;width:500px;text-align:center}.mediumInsert .mediumInsert-embedsBox{position:relative;left:-250px}.mediumInsert .mediumInsert-embedsBox input[type="text"]{margin:0 auto;padding:10px;width:330px;border:solid 3px #ccc;font-size:1em;font-family:Arial,sans-serif;color:#aaa}.mediumInsert .mediumInsert-embedsBox input[type="text"]:focus{border:solid 1px #EEA34A}.mediumInsert .mediumInsert-embedsBox input::-webkit-input-placeholder{color:#aaa}.mediumInsert .mediumInsert-embedsBox button{border:solid 1px #2fbbfc;padding:11px 30px;font-family:Arial,sans-serif;font-size:1.2em;color:#fff;cursor:pointer;background-color:#2fbbfc}.mediumInsert .mediumInsert-embedsImage{font-size:100px;color:#999}.mediumInsert.hover .mediumInsert-placeholder{background:#f0f0f0}.mediumInsert:hover .mediumInsert-buttonsShow{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);opacity:1}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox{background-color:#fff;border:2px solid #333;display:inline-block;z-index:50;position:relative}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox label,.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox button{color:#333;text-transform:capitalize}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox button.mediumInsert-tableReadyButton{background-color:#fff;border:1px solid #333}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox input.mediumInsert-tableCols,.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox input.mediumInsert-tableRows{width:50px;display:block;height:initial;background-color:inherit;border:1px solid #333;color:#333;margin:0 auto;text-align:center}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table{margin:10px}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table td{text-align:center}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table.mediumInsert-demoTable{border-top:2px solid #333;border-left:2px solid #333;height:100px;width:100px}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table.mediumInsert-demoTable td{border-bottom:2px solid #333;border-right:2px solid #333} \ No newline at end of file +.mediumInsert{margin:-1em 0}.mediumInsert figure{margin:0;display:inline-block}.mediumInsert img{max-width:100%}.mediumInsert .mediumInsert-embeds{text-align:center;padding:15px}.mediumInsert .mediumInsert-embeds iframe,.mediumInsert .mediumInsert-embeds div{margin:0 auto!important}.mediumInsert .mediumInsert-images{margin-right:10px;width:20%}.mediumInsert .mediumInsert-images img{margin-top:1em;margin-bottom:10px;vertical-align:top}.mediumInsert .mediumInsert-images:first-child{margin-right:0;width:auto}.mediumInsert .mediumInsert-images:first-child:after{content:"\a";white-space:pre}.mediumInsert .mediumInsert-maps{padding:10px;background:#ccc}.mediumInsert table.mediumInsert-table{border-top:2px solid #333;border-left:2px solid #333;width:90%;margin:30px auto}.mediumInsert table.mediumInsert-table td{border-right:2px solid #333;border-bottom:2px solid #333;padding:12px}.mediumInsert.small{float:left;margin-right:30px}.medium-editor-insert-plugin .clearfix:before,.medium-editor-insert-plugin:before,.medium-editor-insert-plugin .clearfix:after,.medium-editor-insert-plugin:after{content:" ";display:table}.medium-editor-insert-plugin .clearfix:after,.medium-editor-insert-plugin:after{clear:both}.medium-editor-insert-plugin img{max-width:100%}.medium-editor-insert-plugin q,.medium-editor-insert-plugin blockquote{display:block;margin-top:1em;margin-bottom:1em;border-left:5px solid #efefef;padding-left:20px;margin-left:-25px}.medium-editor-insert-plugin [draggable]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.medium-editor-insert-plugin[contenteditable],.medium-editor-insert-plugin [contenteditable]{outline:0 solid transparent}.medium-editor-insert-plugin[contenteditable]:focus,.medium-editor-insert-plugin [contenteditable]:focus{outline:0 solid transparent}.medium-editor-insert-plugin *{-moz-box-sizing:content-box;box-sizing:content-box}.medium-editor-insert-plugin p{margin:1em 0}.medium-editor-insert-plugin progress{display:block;margin:1em auto}.medium-editor-insert-plugin .hide{display:none!important}.medium-editor-insert-plugin.hover .mediumInsert-placeholder{min-height:14px;border:1px dashed #ddd;margin-top:-1px;margin-bottom:-1px}.medium-editor-insert-plugin.medium-editor-placeholder{padding-bottom:0!important;min-height:58px}.medium-editor-insert-plugin.medium-editor-placeholder:after{content:attr(data-placeholder)!important;top:1em}.mediumInsert{position:relative;margin-left:-40px!important;min-height:18px}.mediumInsert.small{width:calc(33.33% + 40px)}.mediumInsert .mediumInsert-buttonsShow{opacity:0;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-transition:all .08s cubic-bezier(.2,.3,.25,.9);transition:all .08s cubic-bezier(.2,.3,.25,.9);display:block;width:18px;height:18px;margin-top:-5px;border-radius:10px;border:2px solid;font-size:18px;line-height:18px;text-align:center;text-decoration:none!important}.mediumInsert .mediumInsert-buttonsShow:after{left:auto;right:100%;top:50%;margin-top:-4px}.mediumInsert .mediumInsert-buttons{position:absolute;width:40px;bottom:0;left:0;color:#ddd;font-size:.9em}.mediumInsert .mediumInsert-buttons a{text-decoration:underline;cursor:pointer}.mediumInsert .mediumInsert-buttons a.active{font-weight:700}.mediumInsert ul.mediumInsert-buttonsOptions{margin:0;padding:0;list-style:none;display:none;position:absolute;z-index:2;left:40px;top:-10px;border-radius:5px}.mediumInsert ul.mediumInsert-buttonsOptions button{min-height:auto;height:auto;padding:5px;border-left:none;float:none}.mediumInsert ul.mediumInsert-buttonsOptions button .fa{font-size:20px}.mediumInsert .mediumInsert-placeholder{position:relative;margin-left:40px;text-align:center}.mediumInsert .mediumInsert-images a{position:absolute;top:1em;width:30px;height:30px;background-color:#3b3b3b;background-repeat:no-repeat;background-position:center center;cursor:pointer}.mediumInsert .mediumInsert-imageRemove{right:0;background-image:url(../images/remove.png)}.mediumInsert .mediumInsert-imageResizeSmaller,.mediumInsert .mediumInsert-imageResizeBigger{right:31px;background-image:url(../images/resize-smaller.png)}.mediumInsert .mediumInsert-imageResizeBigger{background-image:url(../images/resize-bigger.png)}.mediumInsert .mediumInsert-error{background-color:#f2dede;border:1px solid #ebccd1;color:#a94442;padding:15px}.mediumInsert .mediumInsert-embedsPlaceholder{position:relative;padding:24px;height:160px;text-align:center;background-color:#fff}.mediumInsert .mediumInsert-embedsWire{position:absolute;left:50%;text-align:center}.mediumInsert .mediumInsert-embedsBox{position:relative;left:-250px}.mediumInsert .mediumInsert-embedsBox input[type="text"]{margin:0 auto;padding:10px;width:330px;border:solid 3px #ccc;font-size:1em;font-family:Arial,sans-serif;color:#aaa}.mediumInsert .mediumInsert-embedsBox input[type="text"]:focus{border:solid 1px #EEA34A}.mediumInsert .mediumInsert-embedsBox input::-webkit-input-placeholder{color:#aaa}.mediumInsert .mediumInsert-embedsBox button{border:solid 1px #2fbbfc;padding:11px 30px;font-family:Arial,sans-serif;font-size:1.2em;color:#fff;cursor:pointer;background-color:#2fbbfc}.mediumInsert .mediumInsert-embedsImage{font-size:100px;color:#999}.mediumInsert.hover .mediumInsert-placeholder{background:#f0f0f0}.mediumInsert:hover .mediumInsert-buttonsShow{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);opacity:1}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox{background-color:#fff;border:2px solid #333;display:inline-block;z-index:50;position:relative}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox label,.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox button{color:#333;text-transform:capitalize}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox button.mediumInsert-tableReadyButton{background-color:#fff;border:1px solid #333}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox input.mediumInsert-tableCols,.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox input.mediumInsert-tableRows{width:50px;display:block;height:initial;background-color:inherit;border:1px solid #333;color:#333;margin:0 auto;text-align:center}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table{margin:10px}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table td{text-align:center}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table.mediumInsert-demoTable{border-top:2px solid #333;border-left:2px solid #333;height:100px;width:100px}.mediumInsert .medium-editor-toolbar-form-anchor.mediumInsert-tableDemoBox table.mediumInsert-demoTable td{border-bottom:2px solid #333;border-right:2px solid #333} \ No newline at end of file diff --git a/dist/js/addons/medium-editor-insert-embeds.js b/dist/js/addons/medium-editor-insert-embeds.js index f5ebe4459..452f9c8f2 100644 --- a/dist/js/addons/medium-editor-insert-embeds.js +++ b/dist/js/addons/medium-editor-insert-embeds.js @@ -16,7 +16,7 @@ */ default: { - urlPlaceholder: 'type or paste url here' + urlPlaceholder: 'Paste or type a link' //,oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1' }, @@ -48,7 +48,7 @@ $.fn.mediumInsert.insert.deselect(); - var formHtml = '
'; + var formHtml = '
'; $(formHtml).appendTo($placeholder.prev()); setTimeout(function () { $placeholder.prev().find('input').focus(); diff --git a/dist/js/addons/medium-editor-insert-embeds.min.js b/dist/js/addons/medium-editor-insert-embeds.min.js index 86d5182dd..ed388d8f0 100644 --- a/dist/js/addons/medium-editor-insert-embeds.min.js +++ b/dist/js/addons/medium-editor-insert-embeds.min.js @@ -7,4 +7,4 @@ * Released under the MIT license */ -!function(a){a.fn.mediumInsert.registerAddon("embeds",{"default":{urlPlaceholder:"type or paste url here"},init:function(b){this.options=a.extend(this.default,b),this.$el=a.fn.mediumInsert.insert.$el,this.setEmbedButtonEvents(),this.preparePreviousEmbeds()},insertButton:function(a){var b="Embed";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect();var c='
';a(c).appendTo(b.prev()),setTimeout(function(){b.prev().find("input").focus()},50),a.fn.mediumInsert.insert.deselect(),this.currentPlaceholder=b,a(".mediumInsert-embedsText").focus()},preparePreviousEmbeds:function(){this.$el.find(".mediumInsert-embeds").each(function(){var b=a(this).parent();b.html('
'+b.html()+"
")})},setEmbedButtonEvents:function(){var b=this;a(document).on("keypress","input.mediumInsert-embedsText",function(a){(a.which&&13==a.which||a.keyCode&&13==a.keyCode)&&(b.setEnterActionEvents(),b.removeToolbar())}),this.$el.on("blur",".mediumInsert-embedsText",function(){b.removeToolbar()})},setEnterActionEvents:function(){function b(b){return b?(b=a('
').append(b),c.currentPlaceholder.append(b),c.currentPlaceholder.closest("[data-medium-element]").trigger("keyup").trigger("input"),void 0):(alert("Incorrect URL format specified"),!1)}var c=this;if(a.fn.mediumInsert.settings.enabled===!1)return!1;var d=a("input.mediumInsert-embedsText").val();if(!d)return!1;if(!this.options.oembedProxy){var e=c.convertUrlToEmbedTag(d);return b(e)}c.getOEmbedHTML(d,function(a,c){var d=!a&&c&&c.html;c&&!c.html&&"photo"===c.type&&c.url&&(d=''),b(d)})},removeToolbar:function(){a(".mediumInsert-embedsWire").remove()},getOEmbedHTML:function(b,c){a.ajax({url:this.options.oembedProxy,dataType:"json",data:{url:b},success:function(a,b,d){c(null,a,d)},error:function(a,b,d){var e=function(){try{return JSON.parse(a.responseText)}catch(b){}}();c(e&&e.error||a.status||d.message,e,a)}})},convertUrlToEmbedTag:function(a){var b=a.replace(/\n?/g,"").replace(/^((http(s)?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|v\/)?)([a-zA-Z0-9-_]+)(.*)?$/,'
').replace(/http:\/\/vimeo\.com\/(\d+)$/,'').replace(/http:\/\/instagram\.com\/p\/(.+)\/?$/,'');return/<("[^"]*"|'[^']*'|[^'">])*>/.test(b)?b:!1}})}(jQuery); \ No newline at end of file +!function(a){a.fn.mediumInsert.registerAddon("embeds",{"default":{urlPlaceholder:"Paste or type a link"},init:function(b){this.options=a.extend(this.default,b),this.$el=a.fn.mediumInsert.insert.$el,this.setEmbedButtonEvents(),this.preparePreviousEmbeds()},insertButton:function(a){var b="Embed";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect();var c='
';a(c).appendTo(b.prev()),setTimeout(function(){b.prev().find("input").focus()},50),a.fn.mediumInsert.insert.deselect(),this.currentPlaceholder=b,a(".mediumInsert-embedsText").focus()},preparePreviousEmbeds:function(){this.$el.find(".mediumInsert-embeds").each(function(){var b=a(this).parent();b.html('
'+b.html()+"
")})},setEmbedButtonEvents:function(){var b=this;a(document).on("keypress","input.mediumInsert-embedsText",function(a){(a.which&&13==a.which||a.keyCode&&13==a.keyCode)&&(b.setEnterActionEvents(),b.removeToolbar())}),this.$el.on("blur",".mediumInsert-embedsText",function(){b.removeToolbar()})},setEnterActionEvents:function(){function b(b){return b?(b=a('
').append(b),c.currentPlaceholder.append(b),c.currentPlaceholder.closest("[data-medium-element]").trigger("keyup").trigger("input"),void 0):(alert("Incorrect URL format specified"),!1)}var c=this;if(a.fn.mediumInsert.settings.enabled===!1)return!1;var d=a("input.mediumInsert-embedsText").val();if(!d)return!1;if(!this.options.oembedProxy){var e=c.convertUrlToEmbedTag(d);return b(e)}c.getOEmbedHTML(d,function(a,c){var d=!a&&c&&c.html;c&&!c.html&&"photo"===c.type&&c.url&&(d=''),b(d)})},removeToolbar:function(){a(".mediumInsert-embedsWire").remove()},getOEmbedHTML:function(b,c){a.ajax({url:this.options.oembedProxy,dataType:"json",data:{url:b},success:function(a,b,d){c(null,a,d)},error:function(a,b,d){var e=function(){try{return JSON.parse(a.responseText)}catch(b){}}();c(e&&e.error||a.status||d.message,e,a)}})},convertUrlToEmbedTag:function(a){var b=a.replace(/\n?/g,"").replace(/^((http(s)?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|v\/)?)([a-zA-Z0-9-_]+)(.*)?$/,'
').replace(/http:\/\/vimeo\.com\/(\d+)$/,'').replace(/http:\/\/instagram\.com\/p\/(.+)\/?$/,'');return/<("[^"]*"|'[^']*'|[^'">])*>/.test(b)?b:!1}})}(jQuery); \ No newline at end of file diff --git a/dist/js/medium-editor-insert-plugin.all.js b/dist/js/medium-editor-insert-plugin.all.js index 80308d026..f746812ff 100644 --- a/dist/js/medium-editor-insert-plugin.all.js +++ b/dist/js/medium-editor-insert-plugin.all.js @@ -475,7 +475,7 @@ */ default: { - urlPlaceholder: 'type or paste url here' + urlPlaceholder: 'Paste or type a link' //,oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1' }, @@ -507,7 +507,7 @@ $.fn.mediumInsert.insert.deselect(); - var formHtml = '
'; + var formHtml = '
'; $(formHtml).appendTo($placeholder.prev()); setTimeout(function () { $placeholder.prev().find('input').focus(); diff --git a/dist/js/medium-editor-insert-plugin.all.min.js b/dist/js/medium-editor-insert-plugin.all.min.js index 2be5f239a..70985f0e5 100644 --- a/dist/js/medium-editor-insert-plugin.all.min.js +++ b/dist/js/medium-editor-insert-plugin.all.min.js @@ -7,4 +7,4 @@ * Released under the MIT license */ -!function(a){var b={};MediumEditor&&"function"==typeof MediumEditor&&(MediumEditor.prototype.serialize=function(){var b,c,d,e,f,g,h,i,j={};for(b=0;bb&&(b=c)}),b},getButtons:function(c){var d=a.fn.mediumInsert.settings.editor,e=d&&d.options?d.options.buttonLabels:"",f='
+
")},setPlaceholders:function(){var b=this,c=a.fn.mediumInsert.insert.$el,d=a.fn.mediumInsert.settings.editor,e=(d&&d.options?d.options.buttonLabels:"",this.getButtons());return e===!1?!1:(e='
'+e+'
',c.is(":empty")&&c.html("


"),void c.keyup(function(){var d,f=c.children(":last");(""===c.html()||"
"===c.html())&&c.html("


"),f.hasClass("mediumInsert")&&f.find(".mediumInsert-placeholder").children().length>0&&c.append("


"),this.isFirefox&&a(".mediumInsert .mediumInsert-placeholder:empty",c).each(function(){a(this).parent().remove()}),d=b.getMaxId()+1;var g="p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote";c.children(g).each(function(){a(this).next().hasClass("mediumInsert")===!1&&(a(this).after(e),a(this).next(".mediumInsert").attr("id","mediumInsert-"+d)),d++})}).keyup())},setEvents:function(){var c=this,d=a.fn.mediumInsert.insert.$el;d.on("selectstart",".mediumInsert",function(a){return a.preventDefault(),!1}),d.on("blur",function(){var b,c=a(this).clone();c.find(".mediumInsert").remove(),b=c.html().replace(/^\s+|\s+$/g,""),(""===b||"


"===b)&&a(this).addClass("medium-editor-placeholder")}),d.on("keypress",function(a){if(c.isFirefox&&13===a.keyCode){d.contents().each(function(){return function(a,b){return"#text"===b.nodeName?(document.execCommand("insertHTML",!1,"

"+b.data+"

"),b.remove()):void 0}}(this));var b=d.find("p").last();b.text().length>0&&b.find("br").remove()}}),d.on("keydown",function(a){return navigator.userAgent.match(/chrome/i)&&(d.children().last().removeClass("hide"),(a.ctrlKey||a.metaKey)&&65===a.which)?(a.preventDefault(),0===d.find("p").text().trim().length?!1:(d.children().last().addClass("hide"),document.execCommand("selectAll",!1,null))):void 0}),d.on("click",".mediumInsert-buttons a.mediumInsert-buttonsShow",function(){var b=a(this).siblings(".mediumInsert-buttonsOptions"),d=a(this).parent().siblings(".mediumInsert-placeholder");a(this).hasClass("active")?(a(this).removeClass("active"),b.hide(),a("a",b).show()):(a(this).addClass("active"),b.show(),a("a",b).each(function(){var c=a(this).attr("class").split("action-")[1],e=c.split("-")[0];a(".mediumInsert-"+e,d).length>0&&a("a:not(.action-"+c+")",b).hide()})),c.deselect()}),d.on("mouseleave",".mediumInsert",function(){a("a.mediumInsert-buttonsShow",this).removeClass("active"),a(".mediumInsert-buttonsOptions",this).hide()}),d.on("click",".mediumInsert-buttons .mediumInsert-action",function(c){c.preventDefault();var d=a(this).data("addon"),e=a(this).data("action"),f=a(this).parents(".mediumInsert-buttons").siblings(".mediumInsert-placeholder");b[d]&&b[d][e]&&b[d][e](f),a(this).parents(".mediumInsert").mouseleave()})}}}(jQuery),function(a){a.fn.mediumInsert.registerAddon("embeds",{"default":{urlPlaceholder:"type or paste url here"},init:function(b){this.options=a.extend(this.default,b),this.$el=a.fn.mediumInsert.insert.$el,this.setEmbedButtonEvents(),this.preparePreviousEmbeds()},insertButton:function(a){var b="Embed";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect();var c='
';a(c).appendTo(b.prev()),setTimeout(function(){b.prev().find("input").focus()},50),a.fn.mediumInsert.insert.deselect(),this.currentPlaceholder=b,a(".mediumInsert-embedsText").focus()},preparePreviousEmbeds:function(){this.$el.find(".mediumInsert-embeds").each(function(){var b=a(this).parent();b.html('
'+b.html()+"
")})},setEmbedButtonEvents:function(){var b=this;a(document).on("keypress","input.mediumInsert-embedsText",function(a){(a.which&&13==a.which||a.keyCode&&13==a.keyCode)&&(b.setEnterActionEvents(),b.removeToolbar())}),this.$el.on("blur",".mediumInsert-embedsText",function(){b.removeToolbar()})},setEnterActionEvents:function(){function b(b){return b?(b=a('
').append(b),c.currentPlaceholder.append(b),c.currentPlaceholder.closest("[data-medium-element]").trigger("keyup").trigger("input"),void 0):(alert("Incorrect URL format specified"),!1)}var c=this;if(a.fn.mediumInsert.settings.enabled===!1)return!1;var d=a("input.mediumInsert-embedsText").val();if(!d)return!1;if(!this.options.oembedProxy){var e=c.convertUrlToEmbedTag(d);return b(e)}c.getOEmbedHTML(d,function(a,c){var d=!a&&c&&c.html;c&&!c.html&&"photo"===c.type&&c.url&&(d=''),b(d)})},removeToolbar:function(){a(".mediumInsert-embedsWire").remove()},getOEmbedHTML:function(b,c){a.ajax({url:this.options.oembedProxy,dataType:"json",data:{url:b},success:function(a,b,d){c(null,a,d)},error:function(a,b,d){var e=function(){try{return JSON.parse(a.responseText)}catch(b){}}();c(e&&e.error||a.status||d.message,e,a)}})},convertUrlToEmbedTag:function(a){var b=a.replace(/\n?/g,"").replace(/^((http(s)?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|v\/)?)([a-zA-Z0-9-_]+)(.*)?$/,'
').replace(/http:\/\/vimeo\.com\/(\d+)$/,'').replace(/http:\/\/instagram\.com\/p\/(.+)\/?$/,'');return/<("[^"]*"|'[^']*'|[^'">])*>/.test(b)?b:!1}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("images",{"default":{useDragAndDrop:!0,imagesUploadScript:"upload.php",imagesDeleteScript:"delete.php",formatData:function(a){var b=new FormData;return b.append("file",a),b},uploadFile:function(b,c,d){a.ajax({type:"post",url:d.options.imagesUploadScript,xhr:function(){var a=new XMLHttpRequest;return a.upload.onprogress=d.updateProgressBar,a},cache:!1,contentType:!1,complete:function(a){d.uploadCompleted(a,b)},processData:!1,data:d.options.formatData(c)})},deleteFile:function(b,c){a.ajax({type:"post",url:c.options.imagesDeleteScript,data:{file:b}})}},init:function(b){b&&b.$el&&(this.$el=b.$el),this.options=a.extend(this.default,b),this.setImageEvents(),this.options.useDragAndDrop===!0&&this.setDragAndDropEvents(),this.preparePreviousImages()},insertButton:function(a){var b="Img";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},preparePreviousImages:function(){this.$el.find(".mediumInsert-images").each(function(){var b=a(this).parent();b.html(a.fn.mediumInsert.insert.getButtons("images")+'
'+b.html()+"
")})},add:function(b){var c,d,e=this;return c=a('').click(),c.change(function(){d=this.files,e.uploadFiles(b,d,e)}),a.fn.mediumInsert.insert.deselect(),c},updateProgressBar:function(b){var c,d=a(".progress:first",this.$el);b.lengthComputable&&(c=b.loaded/b.total*100,c=c?c:0,d.attr("value",c),d.html(c))},uploadCompleted:function(b,c){var d,e=a(".progress:first",c);e.attr("value",100),e.html(100),b.responseText?(e.before('
'),d=e.siblings("img"),d.load(function(){d.parent().mouseleave().mouseenter()})):(e.before('
There was a problem uploading the file.
'),setTimeout(function(){a(".mediumInsert-error:first",c).fadeOut(function(){a(this).remove()})},3e3)),e.remove(),c.closest("[data-medium-element]").trigger("keyup").trigger("input")},uploadFile:function(a,b,c){return c.options.uploadFile(a,b,c)},uploadFiles:function(a,b,c){for(var d={"image/png":!0,"image/jpeg":!0,"image/gif":!0},e=0;e0'),c.uploadFile(a,f,c))}},deleteFile:function(a,b){return b.options.deleteFile(a,b)},setImageEvents:function(){var b=this;this.$el.on("mouseenter",".mediumInsert-images",function(){var b,c,d=a("img",this);a.fn.mediumInsert.settings.enabled!==!1&&d.length>0&&(a(this).append(''),a(this).append(a(this).parent().parent().hasClass("small")?'':''),b=d.position().top+parseInt(d.css("margin-top"),10),c=d.position().left+d.width()-30,a(".mediumInsert-imageRemove",this).css({right:"auto",top:b,left:c}),a(".mediumInsert-imageResizeBigger, .mediumInsert-imageResizeSmaller",this).css({right:"auto",top:b,left:c-31}))}),this.$el.on("mouseleave",".mediumInsert-images",function(){a(".mediumInsert-imageRemove, .mediumInsert-imageResizeSmaller, .mediumInsert-imageResizeBigger",this).remove()}),this.$el.on("click",".mediumInsert-imageResizeSmaller",function(){a(this).parent().parent().parent().addClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageResizeBigger",function(){a(this).parent().parent().parent().removeClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageRemove",function(){var c=a(this).siblings("img").attr("src");0===a(this).parent().siblings().length&&a(this).parent().parent().parent().removeClass("small"),a(this).parent().remove(),b.deleteFile(c,b),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")})},setDragAndDropEvents:function(){var b,c,d=this,e=!1,f=!1;a(document).on("dragover","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.addClass("hover")}),a(document).on("dragend","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.removeClass("hover")}),this.$el.on("dragover",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).addClass("hover"),a(this).attr("contenteditable",!0))}),this.$el.on("dragleave",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),a(this).attr("contenteditable",!1))}),this.$el.on("dragstart",".mediumInsert .mediumInsert-images img",function(){a.fn.mediumInsert.settings.enabled!==!1&&(b=a(this).parent().index(),c=a(this).parent().parent().parent().attr("id"))}),this.$el.on("dragend",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&e===!0&&(0===a(b.originalEvent.target.parentNode).siblings().length&&a(b.originalEvent.target.parentNode).parent().parent().removeClass("small"),a(b.originalEvent.target.parentNode).mouseleave(),a(b.originalEvent.target.parentNode).remove(),e=!1,f=!1,d.$el.closest("[data-medium-element]").trigger("keyup").trigger("input"))}),this.$el.on("dragover",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&b.preventDefault()}),this.$el.on("drop",".mediumInsert .mediumInsert-images img",function(){var e,g,h;if(a.fn.mediumInsert.settings.enabled!==!1){if(c!==a(this).parent().parent().parent().attr("id"))return f=!1,void(b=c=null);e=parseInt(b,10),g=a(this).parent().parent().find(".mediumInsert-images:nth-child("+(e+1)+")"),h=a(this).parent().index(),h>e?g.insertAfter(a(this).parent()):e>h&&g.insertBefore(a(this).parent()),g.mouseleave(),f=!0,b=null,d.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}}),this.$el.on("drop",".mediumInsert",function(b){var c;b.preventDefault(),a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),d.$el.removeClass("hover"),a(this).attr("contenteditable",!1),c=b.originalEvent.dataTransfer.files,c.length>0?d.uploadFiles(a(".mediumInsert-placeholder",this),c,d):f===!0?f=!1:(a(".mediumInsert-placeholder",this).append('
'+b.originalEvent.dataTransfer.getData("text/html")+"
"),a("meta",this).remove(),e=!0))})}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("maps",{init:function(){this.$el=a.fn.mediumInsert.insert.$el},insertButton:function(a){var b="Map";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect(),b.append('
Map - Coming soon...
')}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("tables",{"default":{defaultRows:2,defaultCols:2},init:function(b){this.options=a.extend(this.default,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=''),'"},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); \ No newline at end of file +!function(a){var b={};MediumEditor&&"function"==typeof MediumEditor&&(MediumEditor.prototype.serialize=function(){var b,c,d,e,f,g,h,i,j={};for(b=0;bb&&(b=c)}),b},getButtons:function(c){var d=a.fn.mediumInsert.settings.editor,e=d&&d.options?d.options.buttonLabels:"",f='
+
    ';return 0===Object.keys(a.fn.mediumInsert.settings.addons).length?!1:("undefined"==typeof c?a.each(a.fn.mediumInsert.settings.addons,function(a){f+="
  • "+b[a].insertButton(e)+"
  • "}):f+="
  • "+b[c].insertButton(e)+"
  • ",f+="
")},setPlaceholders:function(){var b=this,c=a.fn.mediumInsert.insert.$el,d=a.fn.mediumInsert.settings.editor,e=(d&&d.options?d.options.buttonLabels:"",this.getButtons());return e===!1?!1:(e='
'+e+'
',c.is(":empty")&&c.html("


"),void c.keyup(function(){var d,f=c.children(":last");(""===c.html()||"
"===c.html())&&c.html("


"),f.hasClass("mediumInsert")&&f.find(".mediumInsert-placeholder").children().length>0&&c.append("


"),this.isFirefox&&a(".mediumInsert .mediumInsert-placeholder:empty",c).each(function(){a(this).parent().remove()}),d=b.getMaxId()+1;var g="p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote";c.children(g).each(function(){a(this).next().hasClass("mediumInsert")===!1&&(a(this).after(e),a(this).next(".mediumInsert").attr("id","mediumInsert-"+d)),d++})}).keyup())},setEvents:function(){var c=this,d=a.fn.mediumInsert.insert.$el;d.on("selectstart",".mediumInsert",function(a){return a.preventDefault(),!1}),d.on("blur",function(){var b,c=a(this).clone();c.find(".mediumInsert").remove(),b=c.html().replace(/^\s+|\s+$/g,""),(""===b||"


"===b)&&a(this).addClass("medium-editor-placeholder")}),d.on("keypress",function(a){if(c.isFirefox&&13===a.keyCode){d.contents().each(function(){return function(a,b){return"#text"===b.nodeName?(document.execCommand("insertHTML",!1,"

"+b.data+"

"),b.remove()):void 0}}(this));var b=d.find("p").last();b.text().length>0&&b.find("br").remove()}}),d.on("keydown",function(a){return navigator.userAgent.match(/chrome/i)&&(d.children().last().removeClass("hide"),(a.ctrlKey||a.metaKey)&&65===a.which)?(a.preventDefault(),0===d.find("p").text().trim().length?!1:(d.children().last().addClass("hide"),document.execCommand("selectAll",!1,null))):void 0}),d.on("click",".mediumInsert-buttons a.mediumInsert-buttonsShow",function(){var b=a(this).siblings(".mediumInsert-buttonsOptions"),d=a(this).parent().siblings(".mediumInsert-placeholder");a(this).hasClass("active")?(a(this).removeClass("active"),b.hide(),a("a",b).show()):(a(this).addClass("active"),b.show(),a("a",b).each(function(){var c=a(this).attr("class").split("action-")[1],e=c.split("-")[0];a(".mediumInsert-"+e,d).length>0&&a("a:not(.action-"+c+")",b).hide()})),c.deselect()}),d.on("mouseleave",".mediumInsert",function(){a("a.mediumInsert-buttonsShow",this).removeClass("active"),a(".mediumInsert-buttonsOptions",this).hide()}),d.on("click",".mediumInsert-buttons .mediumInsert-action",function(c){c.preventDefault();var d=a(this).data("addon"),e=a(this).data("action"),f=a(this).parents(".mediumInsert-buttons").siblings(".mediumInsert-placeholder");b[d]&&b[d][e]&&b[d][e](f),a(this).parents(".mediumInsert").mouseleave()})}}}(jQuery),function(a){a.fn.mediumInsert.registerAddon("embeds",{"default":{urlPlaceholder:"Paste or type a link"},init:function(b){this.options=a.extend(this.default,b),this.$el=a.fn.mediumInsert.insert.$el,this.setEmbedButtonEvents(),this.preparePreviousEmbeds()},insertButton:function(a){var b="Embed";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect();var c='
';a(c).appendTo(b.prev()),setTimeout(function(){b.prev().find("input").focus()},50),a.fn.mediumInsert.insert.deselect(),this.currentPlaceholder=b,a(".mediumInsert-embedsText").focus()},preparePreviousEmbeds:function(){this.$el.find(".mediumInsert-embeds").each(function(){var b=a(this).parent();b.html('
'+b.html()+"
")})},setEmbedButtonEvents:function(){var b=this;a(document).on("keypress","input.mediumInsert-embedsText",function(a){(a.which&&13==a.which||a.keyCode&&13==a.keyCode)&&(b.setEnterActionEvents(),b.removeToolbar())}),this.$el.on("blur",".mediumInsert-embedsText",function(){b.removeToolbar()})},setEnterActionEvents:function(){function b(b){return b?(b=a('
').append(b),c.currentPlaceholder.append(b),c.currentPlaceholder.closest("[data-medium-element]").trigger("keyup").trigger("input"),void 0):(alert("Incorrect URL format specified"),!1)}var c=this;if(a.fn.mediumInsert.settings.enabled===!1)return!1;var d=a("input.mediumInsert-embedsText").val();if(!d)return!1;if(!this.options.oembedProxy){var e=c.convertUrlToEmbedTag(d);return b(e)}c.getOEmbedHTML(d,function(a,c){var d=!a&&c&&c.html;c&&!c.html&&"photo"===c.type&&c.url&&(d=''),b(d)})},removeToolbar:function(){a(".mediumInsert-embedsWire").remove()},getOEmbedHTML:function(b,c){a.ajax({url:this.options.oembedProxy,dataType:"json",data:{url:b},success:function(a,b,d){c(null,a,d)},error:function(a,b,d){var e=function(){try{return JSON.parse(a.responseText)}catch(b){}}();c(e&&e.error||a.status||d.message,e,a)}})},convertUrlToEmbedTag:function(a){var b=a.replace(/\n?/g,"").replace(/^((http(s)?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|v\/)?)([a-zA-Z0-9-_]+)(.*)?$/,'
').replace(/http:\/\/vimeo\.com\/(\d+)$/,'').replace(/http:\/\/instagram\.com\/p\/(.+)\/?$/,'');return/<("[^"]*"|'[^']*'|[^'">])*>/.test(b)?b:!1}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("images",{"default":{useDragAndDrop:!0,imagesUploadScript:"upload.php",imagesDeleteScript:"delete.php",formatData:function(a){var b=new FormData;return b.append("file",a),b},uploadFile:function(b,c,d){a.ajax({type:"post",url:d.options.imagesUploadScript,xhr:function(){var a=new XMLHttpRequest;return a.upload.onprogress=d.updateProgressBar,a},cache:!1,contentType:!1,complete:function(a){d.uploadCompleted(a,b)},processData:!1,data:d.options.formatData(c)})},deleteFile:function(b,c){a.ajax({type:"post",url:c.options.imagesDeleteScript,data:{file:b}})}},init:function(b){b&&b.$el&&(this.$el=b.$el),this.options=a.extend(this.default,b),this.setImageEvents(),this.options.useDragAndDrop===!0&&this.setDragAndDropEvents(),this.preparePreviousImages()},insertButton:function(a){var b="Img";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},preparePreviousImages:function(){this.$el.find(".mediumInsert-images").each(function(){var b=a(this).parent();b.html(a.fn.mediumInsert.insert.getButtons("images")+'
'+b.html()+"
")})},add:function(b){var c,d,e=this;return c=a('').click(),c.change(function(){d=this.files,e.uploadFiles(b,d,e)}),a.fn.mediumInsert.insert.deselect(),c},updateProgressBar:function(b){var c,d=a(".progress:first",this.$el);b.lengthComputable&&(c=b.loaded/b.total*100,c=c?c:0,d.attr("value",c),d.html(c))},uploadCompleted:function(b,c){var d,e=a(".progress:first",c);e.attr("value",100),e.html(100),b.responseText?(e.before('
'),d=e.siblings("img"),d.load(function(){d.parent().mouseleave().mouseenter()})):(e.before('
There was a problem uploading the file.
'),setTimeout(function(){a(".mediumInsert-error:first",c).fadeOut(function(){a(this).remove()})},3e3)),e.remove(),c.closest("[data-medium-element]").trigger("keyup").trigger("input")},uploadFile:function(a,b,c){return c.options.uploadFile(a,b,c)},uploadFiles:function(a,b,c){for(var d={"image/png":!0,"image/jpeg":!0,"image/gif":!0},e=0;e0'),c.uploadFile(a,f,c))}},deleteFile:function(a,b){return b.options.deleteFile(a,b)},setImageEvents:function(){var b=this;this.$el.on("mouseenter",".mediumInsert-images",function(){var b,c,d=a("img",this);a.fn.mediumInsert.settings.enabled!==!1&&d.length>0&&(a(this).append(''),a(this).append(a(this).parent().parent().hasClass("small")?'':''),b=d.position().top+parseInt(d.css("margin-top"),10),c=d.position().left+d.width()-30,a(".mediumInsert-imageRemove",this).css({right:"auto",top:b,left:c}),a(".mediumInsert-imageResizeBigger, .mediumInsert-imageResizeSmaller",this).css({right:"auto",top:b,left:c-31}))}),this.$el.on("mouseleave",".mediumInsert-images",function(){a(".mediumInsert-imageRemove, .mediumInsert-imageResizeSmaller, .mediumInsert-imageResizeBigger",this).remove()}),this.$el.on("click",".mediumInsert-imageResizeSmaller",function(){a(this).parent().parent().parent().addClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageResizeBigger",function(){a(this).parent().parent().parent().removeClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageRemove",function(){var c=a(this).siblings("img").attr("src");0===a(this).parent().siblings().length&&a(this).parent().parent().parent().removeClass("small"),a(this).parent().remove(),b.deleteFile(c,b),a.fn.mediumInsert.insert.deselect(),b.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")})},setDragAndDropEvents:function(){var b,c,d=this,e=!1,f=!1;a(document).on("dragover","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.addClass("hover")}),a(document).on("dragend","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.removeClass("hover")}),this.$el.on("dragover",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).addClass("hover"),a(this).attr("contenteditable",!0))}),this.$el.on("dragleave",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),a(this).attr("contenteditable",!1))}),this.$el.on("dragstart",".mediumInsert .mediumInsert-images img",function(){a.fn.mediumInsert.settings.enabled!==!1&&(b=a(this).parent().index(),c=a(this).parent().parent().parent().attr("id"))}),this.$el.on("dragend",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&e===!0&&(0===a(b.originalEvent.target.parentNode).siblings().length&&a(b.originalEvent.target.parentNode).parent().parent().removeClass("small"),a(b.originalEvent.target.parentNode).mouseleave(),a(b.originalEvent.target.parentNode).remove(),e=!1,f=!1,d.$el.closest("[data-medium-element]").trigger("keyup").trigger("input"))}),this.$el.on("dragover",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&b.preventDefault()}),this.$el.on("drop",".mediumInsert .mediumInsert-images img",function(){var e,g,h;if(a.fn.mediumInsert.settings.enabled!==!1){if(c!==a(this).parent().parent().parent().attr("id"))return f=!1,void(b=c=null);e=parseInt(b,10),g=a(this).parent().parent().find(".mediumInsert-images:nth-child("+(e+1)+")"),h=a(this).parent().index(),h>e?g.insertAfter(a(this).parent()):e>h&&g.insertBefore(a(this).parent()),g.mouseleave(),f=!0,b=null,d.$el.closest("[data-medium-element]").trigger("keyup").trigger("input")}}),this.$el.on("drop",".mediumInsert",function(b){var c;b.preventDefault(),a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),d.$el.removeClass("hover"),a(this).attr("contenteditable",!1),c=b.originalEvent.dataTransfer.files,c.length>0?d.uploadFiles(a(".mediumInsert-placeholder",this),c,d):f===!0?f=!1:(a(".mediumInsert-placeholder",this).append('
'+b.originalEvent.dataTransfer.getData("text/html")+"
"),a("meta",this).remove(),e=!0))})}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("maps",{init:function(){this.$el=a.fn.mediumInsert.insert.$el},insertButton:function(a){var b="Map";return("fontawesome"==a||"object"==typeof a&&a.fontawesome)&&(b=''),'"},add:function(b){a.fn.mediumInsert.insert.deselect(),b.append('
Map - Coming soon...
')}})}(jQuery),function(a){a.fn.mediumInsert.registerAddon("tables",{"default":{defaultRows:2,defaultCols:2},init:function(b){this.options=a.extend(this.default,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=''),'"},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); \ No newline at end of file diff --git a/src/js/medium-editor-insert-embeds.js b/src/js/medium-editor-insert-embeds.js index e344841e3..24586a0ae 100644 --- a/src/js/medium-editor-insert-embeds.js +++ b/src/js/medium-editor-insert-embeds.js @@ -7,7 +7,7 @@ */ default: { - urlPlaceholder: 'type or paste url here' + urlPlaceholder: 'Paste or type a link' //,oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1' }, @@ -39,7 +39,7 @@ $.fn.mediumInsert.insert.deselect(); - var formHtml = '
'; + var formHtml = '
'; $(formHtml).appendTo($placeholder.prev()); setTimeout(function () { $placeholder.prev().find('input').focus(); diff --git a/src/sass/medium-editor-insert-plugin.scss b/src/sass/medium-editor-insert-plugin.scss index dcf2ea4f2..1fafa2e5b 100644 --- a/src/sass/medium-editor-insert-plugin.scss +++ b/src/sass/medium-editor-insert-plugin.scss @@ -174,9 +174,9 @@ .mediumInsert-embedsWire { position: absolute; - bottom: 24px; + //bottom: 24px; left: 50%; - width: 500px; + //width: 500px; text-align: center; } .mediumInsert-embedsBox {