From 0c151dea6c24a6bf6c6d093537e9d1740c500e77 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Wed, 1 Jul 2015 10:20:01 +0530 Subject: [PATCH] Upgrade to release v1.7.3 --- CHANGE.md | 6 +++++- Editable.php | 1 - EditableAsset.php | 3 +-- EditablePjaxAsset.php | 3 +-- LICENSE.md | 2 +- README.md | 24 ++++++++++------------- assets/js/editable-pjax.js | 3 ++- assets/js/editable-pjax.min.js | 2 +- assets/js/editable.js | 36 ++++++++++++++++++---------------- assets/js/editable.min.js | 2 +- composer.json | 5 ++--- messages/config.php | 3 +-- 12 files changed, 44 insertions(+), 46 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index cd449b0..1acbb28 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,6 @@ version 1.7.3 ============= -**Date:** 12-May-2015 +**Date:** 01-Jul-2015 1. (enh #54): Auto guess input and set input options based on input type. 2. (enh #56): Reset/Clear help-block error messages before next validation. @@ -17,6 +17,10 @@ version 1.7.3 9. (bug #63): Fix renderActionButtons to correctly parse submit & reset button options. 10. (enh #64): Better reset of error container help-block content. 11. (enh #69): Generate default `en` message translation file. +12. (enh #70): Added default `en` translations. +13. (enh #73): Added Polish translations. +14. (enh #76): Improved Spanish translations. +15. (enh #78): Added Chinese translations. version 1.7.2 ============= diff --git a/Editable.php b/Editable.php index 7ec9b97..7eacfb6 100644 --- a/Editable.php +++ b/Editable.php @@ -1,5 +1,4 @@ diff --git a/EditableAsset.php b/EditableAsset.php index 1f9e839..05aa60e 100644 --- a/EditableAsset.php +++ b/EditableAsset.php @@ -1,5 +1,4 @@ @@ -33,4 +32,4 @@ public function init() $this->setupAssets('js', ['js/editable']); parent::init(); } -} +} \ No newline at end of file diff --git a/EditablePjaxAsset.php b/EditablePjaxAsset.php index f79424a..062a182 100644 --- a/EditablePjaxAsset.php +++ b/EditablePjaxAsset.php @@ -1,5 +1,4 @@ @@ -32,4 +31,4 @@ public function init() $this->setupAssets('js', ['js/editable-pjax']); parent::init(); } -} +} \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index 6daf043..bc02979 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -25,4 +25,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 6710c08..3d57281 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Easily set any displayed content as editable in Yii Framework 2.0. This is an en Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json. ## Demo + You can see detailed [documentation and examples](http://demos.krajee.com/editable) on usage of the extension. ## Installation @@ -44,24 +45,19 @@ You can see detailed [documentation and examples](http://demos.krajee.com/editab The preferred way to install this extension is through [composer](http://getcomposer.org/download/). -> Note: You must set the `minimum-stability` to `dev` in the **composer.json** file in your application root folder before installation of this extension OR -if your `minimum-stability` is set to `stable`, then set the following in the require section of your composer.json file - -``` - kartik-v/yii2-editable: "@dev", - kartik-v/yii2-krajee-base: "@dev" -``` +> Note: Check the [composer.json](https://github.com/kartik-v/yii2-editable/blob/master/composer.json) for this extension's requirements and dependencies. +Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json. Either run ``` -$ php composer.phar require kartik-v/yii2-editable "dev-master" +$ php composer.phar require kartik-v/yii2-editable "@dev" ``` or add ``` -"kartik-v/yii2-editable": "dev-master" +"kartik-v/yii2-editable": "@dev" ``` to the ```require``` section of your `composer.json` file. @@ -73,12 +69,12 @@ to the ```require``` section of your `composer.json` file. ```php use kartik\editable\Editable; echo Editable::widget([ - 'model'=>$model, + 'model' => $model, 'attribute' => 'rating', - 'type'=>'primary', - 'size'=>'lg', - 'inputType'=>Editable::INPUT_RATING, - 'editableValueOptions'=>['class'=>'text-success h3'] + 'type' => 'primary', + 'size'=> 'lg', + 'inputType' => Editable::INPUT_RATING, + 'editableValueOptions' => ['class' => 'text-success h3'] ]); ``` diff --git a/assets/js/editable-pjax.js b/assets/js/editable-pjax.js index 4970139..bddb222 100644 --- a/assets/js/editable-pjax.js +++ b/assets/js/editable-pjax.js @@ -11,7 +11,8 @@ * Year: 2015 * For more Yii related demos visit http://demos.krajee.com */ -var initEditablePjax; +var initEditablePjax = function() { +}; (function ($) { "use strict"; initEditablePjax = function (pjaxContainer, toggleButton, initPjaxVar) { diff --git a/assets/js/editable-pjax.min.js b/assets/js/editable-pjax.min.js index 9f00ae0..8695147 100644 --- a/assets/js/editable-pjax.min.js +++ b/assets/js/editable-pjax.min.js @@ -10,4 +10,4 @@ * Author: Kartik Visweswaran * Year: 2015 * For more Yii related demos visit http://demos.krajee.com - */var initEditablePjax;!function(o){"use strict";initEditablePjax=function(t,n,i){o("#"+t).on("pjax:complete",function(){window[i]!==!0&&(o("#"+n).on("click",function(t){t.preventDefault();var n=o(this),i=o(n.attr("data-target")),a=i.data("popover-x")&&i.hasClass("in")?"toggle":n.data();"toggle"!==a?(a.$target=n,i.popoverX(a).popoverX("show").on("hide",function(){n.focus()})):i.popoverX(a).on("hide",function(){n.focus()})}),window[i]=!0)})}}(window.jQuery); \ No newline at end of file + */var initEditablePjax=function(){};!function(o){"use strict";initEditablePjax=function(t,n,i){o("#"+t).on("pjax:complete",function(){window[i]!==!0&&(o("#"+n).on("click",function(t){t.preventDefault();var n=o(this),i=o(n.attr("data-target")),a=i.data("popover-x")&&i.hasClass("in")?"toggle":n.data();"toggle"!==a?(a.$target=n,i.popoverX(a).popoverX("show").on("hide",function(){n.focus()})):i.popoverX(a).on("hide",function(){n.focus()})}),window[i]=!0)})}}(window.jQuery); \ No newline at end of file diff --git a/assets/js/editable.js b/assets/js/editable.js index 328d17c..89867d9 100644 --- a/assets/js/editable.js +++ b/assets/js/editable.js @@ -13,6 +13,7 @@ */ (function ($) { "use strict"; + var isEmpty = function (value, trim) { return value === null || value === undefined || value.length === 0 || (trim && $.trim(value) === ''); }, @@ -20,25 +21,26 @@ $el.removeClass(css).addClass(css); }, Editable = function (element, options) { - this.$container = $(element); - this.init(options); - this.listen(); + var self = this; + self.$container = $(element); + self.init(options); + self.listen(); }; Editable.prototype = { constructor: Editable, init: function (options) { - var self = this; - self.$input = self.$container.find('.kv-editable-input'); - self.$form = self.$container.find('.kv-editable-form'); - self.$value = self.$container.find('.kv-editable-value'); - self.$close = self.$container.find('.kv-editable-close'); - self.$popover = self.$container.find('.kv-editable-popover'); - self.$inline = self.$container.find('.kv-editable-inline'); - self.$btnSubmit = self.$container.find('button.kv-editable-submit'); - self.$btnReset = self.$container.find('button.kv-editable-reset'); - self.$loading = self.$container.find('.kv-editable-loading'); - self.$target = self.$container.find(options.target); + var self = this, $el = self.$container; + self.$input = $el.find('.kv-editable-input'); + self.$form = $el.find('.kv-editable-form'); + self.$value = $el.find('.kv-editable-value'); + self.$close = $el.find('.kv-editable-close'); + self.$popover = $el.find('.kv-editable-popover'); + self.$inline = $el.find('.kv-editable-inline'); + self.$btnSubmit = $el.find('button.kv-editable-submit'); + self.$btnReset = $el.find('button.kv-editable-reset'); + self.$loading = $el.find('.kv-editable-loading'); + self.$target = $el.find(options.target); $.each(options, function (key, value) { self[key] = value; }); @@ -77,11 +79,11 @@ var self = this, $form = self.$form, $btnSubmit = self.$btnSubmit, $btnReset = self.$btnReset, $cont = $form.parent(), $el = self.$container, $popover = self.$popover, $close = self.$close, $target = self.target === '.kv-editable-button' ? self.$target : self.$value, $inline = self.$inline, - $loading = self.$loading, $input = self.$input, + $loading = self.$loading, $input = self.$input, showError, chkError = '', out = '', $parent = $input.closest('.field-' + $input.attr('id')), $parent2 = $input.closest('.kv-editable-parent'), $message = $parent.find('.help-block'), displayValueConfig = self.displayValueConfig, settings, - $hasEditable = $form.find('input[name="hasEditable"]'), showError, chkError = '', out = '', - objActiveForm = self.$form.data('yiiActiveForm'), $msgBlock = $parent2.find('.kv-help-block'), + $hasEditable = $form.find('input[name="hasEditable"]'), $msgBlock = $parent2.find('.kv-help-block'), + objActiveForm = self.$form.data('yiiActiveForm'), notActiveForm = isEmpty($parent.attr('class')) || isEmpty($message.attr('class')); showError = function (message) { if (notActiveForm) { diff --git a/assets/js/editable.min.js b/assets/js/editable.min.js index a7712c7..eeb82c0 100644 --- a/assets/js/editable.min.js +++ b/assets/js/editable.min.js @@ -10,4 +10,4 @@ * Author: Kartik Visweswaran * Year: 2015 * For more Yii related demos visit http://demos.krajee.com - */!function(e){"use strict";var t=function(t,i){return null===t||void 0===t||0===t.length||i&&""===e.trim(t)},i=function(e,t){e.removeClass(t).addClass(t)},n=function(t,i){this.$container=e(t),this.init(i),this.listen()};n.prototype={constructor:n,init:function(t){var i=this;i.$input=i.$container.find(".kv-editable-input"),i.$form=i.$container.find(".kv-editable-form"),i.$value=i.$container.find(".kv-editable-value"),i.$close=i.$container.find(".kv-editable-close"),i.$popover=i.$container.find(".kv-editable-popover"),i.$inline=i.$container.find(".kv-editable-inline"),i.$btnSubmit=i.$container.find("button.kv-editable-submit"),i.$btnReset=i.$container.find("button.kv-editable-reset"),i.$loading=i.$container.find(".kv-editable-loading"),i.$target=i.$container.find(t.target),e.each(t,function(e,t){i[e]=t}),i.asPopover=1==i.asPopover||"true"===i.asPopover},toggle:function(e,t){var n=this,o=n.$value,r=n.$inline;return t=t||"fast",e?void(n.asPopover||o.fadeOut(t,function(){r.fadeIn(t),".kv-editable-button"===n.target&&i(n.$target,"kv-inline-open")})):void(n.asPopover?n.$popover.popoverX("hide"):r.fadeOut(t,function(){o.fadeIn(t),n.$target.removeClass("kv-inline-open")}))},refreshPopover:function(){var e=this;e.asPopover&&e.$popover.popoverX("refreshPosition")},listen:function(){var n,o,r=this,a=r.$form,l=r.$btnSubmit,s=r.$btnReset,c=a.parent(),d=r.$container,v=(r.$popover,r.$close),u=".kv-editable-button"===r.target?r.$target:r.$value,f=r.$inline,p=r.$loading,h=r.$input,b=h.closest(".field-"+h.attr("id")),g=h.closest(".kv-editable-parent"),m=b.find(".help-block"),$=r.displayValueConfig,k=a.find('input[name="hasEditable"]'),y="",C="",P=r.$form.data("yiiActiveForm"),E=g.find(".kv-help-block"),j=t(b.attr("class"))||t(m.attr("class"));o=function(n){j?(t(E.attr("class"))&&(E=e(document.createElement("div")).attr({"class":"help-block kv-help-block"}).appendTo(g)),E.html(n)):(m.html(n),i(m,"kv-help-block")),i(g,"has-error"),p.hide(),c.removeClass("kv-editable-processing")},a.on("submit",function(e){e.preventDefault()}).on("keyup",function(e){13===e.which&&r.submitOnEnter&&l.trigger("click")}).on("reset",function(){setTimeout(function(){a.data("kvEditableSubmit",!1),j?(g.find(".help-block").remove(),g.removeClass("has-error")):(b.removeClass("has-error"),m.html(" ")),r.refreshPopover()},200)}),a.find("input, select").on("change",function(){r.refreshPopover(),d.trigger("editableChange",[h.val()])}),s.on("click",function(){k.val(0),setTimeout(function(){a[0].reset()},200),d.trigger("editableReset")}),v.on("click",function(){r.toggle(!1)}),u.on("click",function(){if(r.asPopover)return void r.toggle(!0);var e=!r.$inline.is(":visible");r.toggle(e)}),l.on("click",function(){var l=r.asPopover?c:f;i(l,"kv-editable-processing"),p.show(),k.val(1),a.find(".help-block").each(function(){e(this).html("")}),a.find("input, select").each(function(){e(this).trigger("change")}),n=e.extend({type:a.attr("method"),url:a.attr("action"),data:a.serialize(),dataType:"json",error:function(e,t,i){r.showAjaxErrors&&o(i),d.trigger("editableAjaxError",[e,t,i])},success:function(i){return y="",C=t(i.output)?h.val():i.output,r.refreshPopover(),t(i.message)?(t(E.attr("class"))||(b.removeClass("has-error"),E.html("").hide(),m.html("")),a.find(".help-block").each(function(){var i=e(this).text();y+=i?i.trim():"",t(y)||p.hide()}),t(y)?(p.hide(),t(C)?C=r.valueIfNull:void 0!==$[C]&&(C=$[C]),j?(g.find(".help-block").remove(),g.removeClass("has-error"),m.html(""),r.toggle(!1),r.$value.html(C)):(b.removeClass("has-error"),m.html(""),r.toggle(!1),r.$value.html(C),P&&(a.yiiActiveForm("destroy"),a.yiiActiveForm(P.attributes,P.settings))),d.trigger("editableSuccess",[h.val(),a,i])):d.trigger("editableError",[h.val(),a,i]),void l.removeClass("kv-editable-processing")):(o(i.message),void d.trigger("editableError",[h.val(),a,i]))}},r.ajaxSettings),e.ajax(n),d.trigger("editableSubmit",[h.val(),a])})}},e.fn.editable=function(t){var i=Array.apply(null,arguments);return i.shift(),this.each(function(){var o=e(this),r=o.data("editable"),a="object"==typeof t&&t;r||(r=new n(this,e.extend({},e.fn.editable.defaults,a,e(this).data())),o.data("editable",r)),"string"==typeof t&&r[t].apply(r,i)})},e.fn.editable.defaults={valueIfNull:"(not set)",placement:"right",displayValueConfig:{},ajaxSettings:{},showAjaxErrors:!0,submitOnEnter:!0,asPopover:!0},e.fn.editable.Constructor=n}(window.jQuery); \ No newline at end of file + */!function(e){"use strict";var t=function(t,i){return null===t||void 0===t||0===t.length||i&&""===e.trim(t)},i=function(e,t){e.removeClass(t).addClass(t)},n=function(t,i){var n=this;n.$container=e(t),n.init(i),n.listen()};n.prototype={constructor:n,init:function(t){var i=this,n=i.$container;i.$input=n.find(".kv-editable-input"),i.$form=n.find(".kv-editable-form"),i.$value=n.find(".kv-editable-value"),i.$close=n.find(".kv-editable-close"),i.$popover=n.find(".kv-editable-popover"),i.$inline=n.find(".kv-editable-inline"),i.$btnSubmit=n.find("button.kv-editable-submit"),i.$btnReset=n.find("button.kv-editable-reset"),i.$loading=n.find(".kv-editable-loading"),i.$target=n.find(t.target),e.each(t,function(e,t){i[e]=t}),i.asPopover=1==i.asPopover||"true"===i.asPopover},toggle:function(e,t){var n=this,o=n.$value,r=n.$inline;return t=t||"fast",e?void(n.asPopover||o.fadeOut(t,function(){r.fadeIn(t),".kv-editable-button"===n.target&&i(n.$target,"kv-inline-open")})):void(n.asPopover?n.$popover.popoverX("hide"):r.fadeOut(t,function(){o.fadeIn(t),n.$target.removeClass("kv-inline-open")}))},refreshPopover:function(){var e=this;e.asPopover&&e.$popover.popoverX("refreshPosition")},listen:function(){var n,o,r=this,a=r.$form,l=r.$btnSubmit,s=r.$btnReset,v=a.parent(),d=r.$container,c=(r.$popover,r.$close),u=".kv-editable-button"===r.target?r.$target:r.$value,f=r.$inline,p=r.$loading,h=r.$input,b="",g="",m=h.closest(".field-"+h.attr("id")),k=h.closest(".kv-editable-parent"),$=m.find(".help-block"),y=r.displayValueConfig,C=a.find('input[name="hasEditable"]'),P=k.find(".kv-help-block"),E=r.$form.data("yiiActiveForm"),j=t(m.attr("class"))||t($.attr("class"));n=function(n){j?(t(P.attr("class"))&&(P=e(document.createElement("div")).attr({"class":"help-block kv-help-block"}).appendTo(k)),P.html(n)):($.html(n),i($,"kv-help-block")),i(k,"has-error"),p.hide(),v.removeClass("kv-editable-processing")},a.on("submit",function(e){e.preventDefault()}).on("keyup",function(e){13===e.which&&r.submitOnEnter&&l.trigger("click")}).on("reset",function(){setTimeout(function(){a.data("kvEditableSubmit",!1),j?(k.find(".help-block").remove(),k.removeClass("has-error")):(m.removeClass("has-error"),$.html(" ")),r.refreshPopover()},200)}),a.find("input, select").on("change",function(){r.refreshPopover(),d.trigger("editableChange",[h.val()])}),s.on("click",function(){C.val(0),setTimeout(function(){a[0].reset()},200),d.trigger("editableReset")}),c.on("click",function(){r.toggle(!1)}),u.on("click",function(){if(r.asPopover)return void r.toggle(!0);var e=!r.$inline.is(":visible");r.toggle(e)}),l.on("click",function(){var l=r.asPopover?v:f;i(l,"kv-editable-processing"),p.show(),C.val(1),a.find(".help-block").each(function(){e(this).html("")}),a.find("input, select").each(function(){e(this).trigger("change")}),o=e.extend({type:a.attr("method"),url:a.attr("action"),data:a.serialize(),dataType:"json",error:function(e,t,i){r.showAjaxErrors&&n(i),d.trigger("editableAjaxError",[e,t,i])},success:function(i){return b="",g=t(i.output)?h.val():i.output,r.refreshPopover(),t(i.message)?(t(P.attr("class"))||(m.removeClass("has-error"),P.html("").hide(),$.html("")),a.find(".help-block").each(function(){var i=e(this).text();b+=i?i.trim():"",t(b)||p.hide()}),t(b)?(p.hide(),t(g)?g=r.valueIfNull:void 0!==y[g]&&(g=y[g]),j?(k.find(".help-block").remove(),k.removeClass("has-error"),$.html(""),r.toggle(!1),r.$value.html(g)):(m.removeClass("has-error"),$.html(""),r.toggle(!1),r.$value.html(g),E&&(a.yiiActiveForm("destroy"),a.yiiActiveForm(E.attributes,E.settings))),d.trigger("editableSuccess",[h.val(),a,i])):d.trigger("editableError",[h.val(),a,i]),void l.removeClass("kv-editable-processing")):(n(i.message),void d.trigger("editableError",[h.val(),a,i]))}},r.ajaxSettings),e.ajax(o),d.trigger("editableSubmit",[h.val(),a])})}},e.fn.editable=function(t){var i=Array.apply(null,arguments);return i.shift(),this.each(function(){var o=e(this),r=o.data("editable"),a="object"==typeof t&&t;r||(r=new n(this,e.extend({},e.fn.editable.defaults,a,e(this).data())),o.data("editable",r)),"string"==typeof t&&r[t].apply(r,i)})},e.fn.editable.defaults={valueIfNull:"(not set)",placement:"right",displayValueConfig:{},ajaxSettings:{},showAjaxErrors:!0,submitOnEnter:!0,asPopover:!0},e.fn.editable.Constructor=n}(window.jQuery); \ No newline at end of file diff --git a/composer.json b/composer.json index 48e01ce..6699123 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,9 @@ "homepage": "http://www.krajee.com/" } ], - "stability": "stable", "require": { - "kartik-v/yii2-krajee-base": "*", - "kartik-v/yii2-popover-x": "*" + "kartik-v/yii2-krajee-base": "~1.7", + "kartik-v/yii2-popover-x": "~1.3" }, "autoload": { "psr-4": { diff --git a/messages/config.php b/messages/config.php index e44efe3..8d74f82 100644 --- a/messages/config.php +++ b/messages/config.php @@ -1,5 +1,4 @@ __DIR__ . DIRECTORY_SEPARATOR . '..', @@ -49,4 +48,4 @@ // When format is "db", you may specify the following two options //'db' => 'db', //'sourceMessageTable' => '{{%source_message}}', -]; +]; \ No newline at end of file