From f92698ee66612567a7c7a570cdc4dabdef888b2b Mon Sep 17 00:00:00 2001 From: Bruno Meilick Date: Wed, 12 Apr 2017 11:41:37 +0200 Subject: [PATCH] fixes js error Signed-off-by: Bruno Meilick --- fields/opener/assets/js/script.coffee | 2 +- fields/opener/assets/js/script.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fields/opener/assets/js/script.coffee b/fields/opener/assets/js/script.coffee index 0334fa4..6e8515e 100644 --- a/fields/opener/assets/js/script.coffee +++ b/fields/opener/assets/js/script.coffee @@ -33,7 +33,7 @@ Opener = ($, $field) -> this.hasError = (error, msg) -> if msg == undefined or msg.trim().length == 0 msg = self.l.error - if msg == undefined or msgtrim().length == 0 + if msg == undefined or msg.trim().length == 0 msg = error self.$button.addClass('btn-negative') diff --git a/fields/opener/assets/js/script.js b/fields/opener/assets/js/script.js index a2fb25f..44e7279 100644 --- a/fields/opener/assets/js/script.js +++ b/fields/opener/assets/js/script.js @@ -1 +1 @@ -(function(){var t;t=function($,t){var e;return e=this,this.$field=t,this.$opener=t.find(".opener-button"),this.$button=t.find(".opener-button a"),this.$copy=t.find(".opener-button .copy"),this.$text=t.find(".opener-button a span"),this.$download=t.find(".opener-button a.opener-download"),this.useDownloadLink=this.$opener.hasClass("download"),this.refresh=this.$opener.hasClass("refresh"),this.delay=parseInt(this.$opener.attr("data-delay")),this.jsoncode=String(this.$opener.attr("data-jsoncode")),this.jsonmessage=String(this.$opener.attr("data-jsonmessage")),this.jsonfileurl=String(this.$opener.attr("data-jsonfileurl")),this.l={default:this.$text.attr("data-textdefault"),progress:this.$text.attr("data-textprogress"),success:this.$text.attr("data-textsuccess"),error:this.$text.attr("data-texterror")},this.parseResult=function(t){200===t[this.jsoncode]?e.hasSuccess(t[this.jsonmessage],t[this.jsonfileurl]):e.hasError(t.error,t[this.jsonmessage])},this.hasError=function(t,n){void 0!==n&&0!==n.trim().length||(n=e.l.error),void 0!==n&&0!==msgtrim().length||(n=t),e.$button.addClass("btn-negative").children("span").text(n),setTimeout(function(){return e.$button.removeClass("btn-negative"),e.$button.children("span").text(e.l.default),e.$download.attr("href",""),e.$download.attr("download","")},e.delay)},this.hasSuccess=function(t,n){var o;void 0!==t&&0!==t.trim().length||(t=e.l.success),e.$button.addClass("btn-positive"),e.$button.children("span").text(t),void 0!==n&&n.trim().length>0&&(e.useDownloadLink?(o=n.split("/").pop(),e.$download.attr("href",n),e.$download.attr("download",o),e.$download[0].click()):window.open(n)),setTimeout(function(){if(e.$button.removeClass("btn-positive"),e.$button.children("span").text(e.l.default),e.$download.attr("href",""),e.$download.attr("download",""),e.refresh)return window.location.reload(!0)},e.delay)},this.init=function(){},this.copyToClipboard=function(t){var e,n,o,s,a,r,i,d;d="_hiddenCopyText_",o="INPUT"===t.tagName||"TEXTAREA"===t.tagName,a=void 0,s=void 0,o?(i=t,a=t.selectionStart,s=t.selectionEnd):(i=document.getElementById(d),i||(i=document.createElement("textarea"),i.style.position="absolute",i.style.left="-9999px",i.style.top="0",i.id=d,document.body.appendChild(i)),i.textContent=t.textContent),e=document.activeElement,i.focus(),i.setSelectionRange(0,i.value.length),r=void 0;try{r=document.execCommand("copy")}catch(t){n=t,r=!1}return e&&"function"==typeof e.focus&&e.focus(),o?t.setSelectionRange(a,s):i.textContent="",r},this.$field.find("a.opener").click(function(t){var n;t.preventDefault(),e.$opener.hasClass("no-ajax")?window.open(e.$button.attr("href")):e.$opener.hasClass("copy-clipboard")?(e.$copy.removeClass("jquery-hide"),e.copyToClipboard(e.$copy.get(0))?e.hasSuccess():(e.hasError(),window.open(e.$button.attr("href"))),e.$copy.addClass("jquery-hide")):(n=$(this).attr("name"),$.fn.OpenerAjax(e,$(this).attr("href")+"/panel:1"))}),this.init()},function($){$.fn.OpenerAjax=function(t,e){void 0!==t.$field&&(t.$field.hasClass("ajax")||(t.$field.addClass("ajax"),document.body.style.cursor="wait",t.$button.children("span").text(t.l.progress),$.ajax({url:e,type:"GET",success:function(e){return t.parseResult(e)},error:function(e,n,o){return t.hasError(n+o)},complete:function(){return t.$field.removeClass("ajax"),document.body.style.cursor="default"}})))},$.fn.opener=function(){return new t($,this)}}(jQuery)}).call(this); \ No newline at end of file +(function(){var t;t=function($,t){var e;return e=this,this.$field=t,this.$opener=t.find(".opener-button"),this.$button=t.find(".opener-button a"),this.$copy=t.find(".opener-button .copy"),this.$text=t.find(".opener-button a span"),this.$download=t.find(".opener-button a.opener-download"),this.useDownloadLink=this.$opener.hasClass("download"),this.refresh=this.$opener.hasClass("refresh"),this.delay=parseInt(this.$opener.attr("data-delay")),this.jsoncode=String(this.$opener.attr("data-jsoncode")),this.jsonmessage=String(this.$opener.attr("data-jsonmessage")),this.jsonfileurl=String(this.$opener.attr("data-jsonfileurl")),this.l={default:this.$text.attr("data-textdefault"),progress:this.$text.attr("data-textprogress"),success:this.$text.attr("data-textsuccess"),error:this.$text.attr("data-texterror")},this.parseResult=function(t){200===t[this.jsoncode]?e.hasSuccess(t[this.jsonmessage],t[this.jsonfileurl]):e.hasError(t.error,t[this.jsonmessage])},this.hasError=function(t,n){void 0!==n&&0!==n.trim().length||(n=e.l.error),void 0!==n&&0!==n.trim().length||(n=t),e.$button.addClass("btn-negative").children("span").text(n),setTimeout(function(){return e.$button.removeClass("btn-negative"),e.$button.children("span").text(e.l.default),e.$download.attr("href",""),e.$download.attr("download","")},e.delay)},this.hasSuccess=function(t,n){var o;void 0!==t&&0!==t.trim().length||(t=e.l.success),e.$button.addClass("btn-positive"),e.$button.children("span").text(t),void 0!==n&&n.trim().length>0&&(e.useDownloadLink?(o=n.split("/").pop(),e.$download.attr("href",n),e.$download.attr("download",o),e.$download[0].click()):window.open(n)),setTimeout(function(){if(e.$button.removeClass("btn-positive"),e.$button.children("span").text(e.l.default),e.$download.attr("href",""),e.$download.attr("download",""),e.refresh)return window.location.reload(!0)},e.delay)},this.init=function(){},this.copyToClipboard=function(t){var e,n,o,s,a,r,i,d;d="_hiddenCopyText_",o="INPUT"===t.tagName||"TEXTAREA"===t.tagName,a=void 0,s=void 0,o?(i=t,a=t.selectionStart,s=t.selectionEnd):(i=document.getElementById(d),i||(i=document.createElement("textarea"),i.style.position="absolute",i.style.left="-9999px",i.style.top="0",i.id=d,document.body.appendChild(i)),i.textContent=t.textContent),e=document.activeElement,i.focus(),i.setSelectionRange(0,i.value.length),r=void 0;try{r=document.execCommand("copy")}catch(t){n=t,r=!1}return e&&"function"==typeof e.focus&&e.focus(),o?t.setSelectionRange(a,s):i.textContent="",r},this.$field.find("a.opener").click(function(t){var n;t.preventDefault(),e.$opener.hasClass("no-ajax")?window.open(e.$button.attr("href")):e.$opener.hasClass("copy-clipboard")?(e.$copy.removeClass("jquery-hide"),e.copyToClipboard(e.$copy.get(0))?e.hasSuccess():(e.hasError(),window.open(e.$button.attr("href"))),e.$copy.addClass("jquery-hide")):(n=$(this).attr("name"),$.fn.OpenerAjax(e,$(this).attr("href")+"/panel:1"))}),this.init()},function($){$.fn.OpenerAjax=function(t,e){void 0!==t.$field&&(t.$field.hasClass("ajax")||(t.$field.addClass("ajax"),document.body.style.cursor="wait",t.$button.children("span").text(t.l.progress),$.ajax({url:e,type:"GET",success:function(e){return t.parseResult(e)},error:function(e,n,o){return t.hasError(n+o)},complete:function(){return t.$field.removeClass("ajax"),document.body.style.cursor="default"}})))},$.fn.opener=function(){return new t($,this)}}(jQuery)}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index f2137c0..d89b89f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kirby-opener", "description": "Kirby Opener is a Kirby CMS Panel Field button that allows you to use placeholders to create dynamic urls which are called with and without ajax response or start downloads.", - "version": "0.8.0", + "version": "0.8.1", "author": "Bruno Meilick", "type": "kirby-plugin", "license": "Commercial"