From ae6205525a1fdbe4022f269f8d73d6442bc4920d Mon Sep 17 00:00:00 2001 From: jian weng Date: Wed, 16 May 2018 16:17:59 +0800 Subject: [PATCH] Fix init version form bug --- .../publish2/assets/javascripts/publish2.js | 2 +- .../assets/javascripts/publish2/publish2.js | 16 +++++++++++++--- .../assets/javascripts/publish2_inline_edit.js | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/views/themes/publish2/assets/javascripts/publish2.js b/views/themes/publish2/assets/javascripts/publish2.js index 20ae90a..17d15da 100644 --- a/views/themes/publish2/assets/javascripts/publish2.js +++ b/views/themes/publish2/assets/javascripts/publish2.js @@ -1 +1 @@ -"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"===("undefined"==typeof exports?"undefined":_typeof(exports))?require("jquery"):jQuery)}(function(e){function t(i,n){this.$element=e(i),this.options=e.extend({},t.DEFAULTS,e.isPlainObject(n)&&n),this.init()}var i=e(document),n="qor.publish2";return t.prototype={constructor:t,init:function(){this.actionType=this.options.element,this.bind(),this.initActionTemplate()},bind:function(){i.on("click.qor.publish2",".qor-publish2__version",this.loadPublishVersion.bind(this)).on("change.qor.publish2",".qor-pulish2__action-input",this.action.bind(this)).on("qor.selectone.selected qor.selectone.unselected",".qor-pulish2__eventid",this.eventidChanged.bind(this)).on("added.qor.replicator.publish2",this.replicatorAdded.bind(this))},unbind:function(){i.off("click.qor.publish2",".qor-publish2__version").off("change.qor.publish2",".qor-pulish2__action-input").off("qor.selectone.selected qor.selectone.unselected",".qor-pulish2__eventid").off("added.qor.replicator.publish2")},initActionTemplate:function(){e(".qor-pulish2__action").closest(".qor-slideout").length||e(".qor-pulish2__action").prependTo(e(".mdl-layout__content .qor-page__body form").first()).show(),t.initSharedVersion()},replicatorAdded:function(e,i){t.generateSharedVersionLabel(i)},action:function(t){var i=e(t.target),n="checkbox"==i.prop("type"),o=i.val(),r=e(this.actionType[i.data().actionType]),s=r.closest("label");r.length&&(n?(r.prop("checked",i.is(":checked")),i.is(":checked")?s.addClass("is-checked"):s.removeClass("is-checked")):r.val(o))},eventidChanged:function(t,i){i?e(".qor-pulish2__eventid-input").val(i.primaryKey):e(".qor-pulish2__eventid-input").val(""),this.updateDate(i,t.target),e(".qor-pulish2__eventid-input").trigger("change")},updateDate:function(t,i){var n=e(i).closest(".qor-pulish2__action"),o=n.find(".qor-pulish2__action-start"),r=n.find(".qor-pulish2__action-end"),s=n.find(".qor-action__picker-button"),a=s.parent().find("input");t?(o.val(t.ScheduledStartAt),r.val(t.ScheduledEndAt),s.hide(),a.attr("disabled",!0)):(s.show(),a.attr("disabled",!1).closest(".is-disabled").removeClass("is-disabled")),o.trigger("change"),r.trigger("change")},loadPublishVersion:function(t){var i,n=e(t.target).parent("a"),o=n.data().versionUrl,r=n.closest("table"),s=n.closest("tr"),a=s.find("td").length,l=r.hasClass("qor-table--medialibrary"),d=e(''),c=e('
');if(s.hasClass("is-showing"))return e(".qor-table__inner-list").remove(),r.find("tr").removeClass("is-showing"),!1;if(e(".qor-table__inner-list").remove(),e("table tr").removeClass("is-showing"),s.addClass("is-showing"),l){var h=r.find(">tbody>tr"),u=parseInt(r.width()/217),p=h.index(s)+1,f=Math.ceil(h.length/u),b=Math.ceil(p/u);s=e(h.get(u*b-1)),s.length||(s=h.last()),d=e(''),f>1&&d.width(217*u-16)}return s.after(d),i=e(".qor-table__inner-list").find("td"),c.appendTo(i).trigger("enable"),o&&e.get(o,function(t){e(".qor-table__inner-block").html(t).trigger("enable")}),!1},destroy:function(){this.unbind(),this.$element.removeData(n)}},t.generateSharedVersionLabel=function(t){var i=e('[name="shared-version-checkbox"]').html(),n=e('input[name$="ShareableVersion"]'),o={},r=void 0;t&&(n=t.find('input[name$="ShareableVersion"]')),n.each(function(){var t=e(this),n=t.closest(".qor-fieldset"),s=void 0;n.hasClass("qor-fieldset--new")||(r=(Math.random()+1).toString(36).substring(7),o.id=["ShareableVersion",r].join("_"),s=e(window.Mustache.render(i,o)),s.find("input").on("click.qor.publish2",function(){e(this).is(":checked")?t.val("true"):t.val("")}),"true"==t.val()&&s.find("input").prop("checked",!0),s.prependTo(n).trigger("enable"),t.closest(".qor-field").hide())})},t.initSharedVersion=function(){e(".qor-pulish2__action").length&&t.generateSharedVersionLabel()},e.fn.qorSliderAfterShow=e.fn.qorSliderAfterShow||{},e.fn.qorSliderAfterShow.initSharedVersion=t.initSharedVersion,e.fn.qorSliderAfterShow.initPublishForm=function(){var i=e(".qor-pulish2__action"),n=i.find("[data-action-type]"),o=e(".qor-slideout__body form"),r=e(".qor-bottomsheets__body form"),s=t.ELEMENT;i.length&&(r.length?i.prependTo(r.first()):o.length&&i.prependTo(o.first())),i.length&&n.length&&(n.each(function(){var t=e(this);e(s[t.data("actionType")]).closest(".qor-form-section").hide()}),e(".qor-pulish2__action-input").trigger("change.qor.publish2"))},t.DEFAULTS={},t.ELEMENT={scheduledstart:'[name="QorResource.ScheduledStartAt"]',scheduledend:'[name="QorResource.ScheduledEndAt"]',publishready:'[name="QorResource.PublishReady"]',versionname:'[name="QorResource.VersionName"]',eventid:'[name="QorResource.ScheduledEventID"]'},t.plugin=function(i){return this.each(function(){var o,r=e(this),s=r.data(n);if(!s){if(/destroy/.test(i))return;r.data(n,s=new t(this,i))}"string"==typeof i&&e.isFunction(o=s[i])&&o.apply(s)})},e(function(){var i={};i.element=t.ELEMENT,e(document).on("disable.qor.publish2",function(i){t.plugin.call(e(".qor-theme-publish2",i.target),"destroy")}).on("enable.qor.publish2",function(n){t.plugin.call(e(".qor-theme-publish2",n.target),i)}).triggerHandler("enable.qor.publish2")}),t}); \ No newline at end of file +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?e(require("jquery")):e(jQuery)}(function(b){var e=b(document),o="qor.publish2",i="enable."+o,s="click."+o,d="change."+o,t="qor.selectone.selected qor.selectone.unselected",n="added.qor.replicator.publish2",a="ShareableVersion",r=".qor-publish2__version",g="qor-table__inner-list",m="qor-table__inner-block",v="."+g,l=".qor-pulish2__eventid",c=".qor-pulish2__eventid-input",h=".qor-pulish2__action",u=".qor-pulish2__action-input",y="is-showing";function f(e,t){this.$element=b(e),this.options=b.extend({},f.DEFAULTS,b.isPlainObject(t)&&t),this.init()}return f.prototype={constructor:f,init:function(){this.actionType=this.options.element,this.bind(),this.initActionTemplate()},bind:function(){e.on(s,r,this.loadPublishVersion.bind(this)).on(d,u,this.action.bind(this)).on(t,l,this.eventidChanged.bind(this)).on(n,this.replicatorAdded.bind(this))},unbind:function(){e.off(s,r).off(d,u).off(t,l).off(n)},initActionTemplate:function(){b(h).closest(".qor-slideout").length||b(h).prependTo(b(".mdl-layout__content .qor-page__body form").first()).show(),f.initSharedVersion()},replicatorAdded:function(e,t){f.generateSharedVersionLabel(t)},action:function(e){var t=b(e.target),n="checkbox"==t.prop("type"),i=t.val(),o=b(this.actionType[t.data().actionType]),r=o.closest("label");o.length&&(n?(o.prop("checked",t.is(":checked")),t.is(":checked")?r.addClass("is-checked"):r.removeClass("is-checked")):o.val(i))},eventidChanged:function(e,t){t?b(c).val(t.primaryKey):b(c).val(""),this.updateDate(t,e.target),b(c).trigger("change")},updateDate:function(e,t){var n=b(t).closest(h),i=n.find(".qor-pulish2__action-start"),o=n.find(".qor-pulish2__action-end"),r=n.find(".qor-action__picker-button"),s=r.parent().find("input");e?(i.val(e.ScheduledStartAt),o.val(e.ScheduledEndAt),r.hide(),s.attr("disabled",!0)):(r.show(),s.attr("disabled",!1).closest(".is-disabled").removeClass("is-disabled")),i.trigger("change"),o.trigger("change")},loadPublishVersion:function(e){var t,n=b(e.target).parent("a"),i=n.data().versionUrl,o=n.closest("table"),r=n.closest("tr"),s=r.find("td").length,a=o.hasClass("qor-table--medialibrary"),d=b(''),l=b('
');if(r.hasClass(y))return b(v).remove(),o.find("tr").removeClass(y),!1;if(b(v).remove(),b("table tr").removeClass(y),r.addClass(y),a){var c=o.find(">tbody>tr"),h=parseInt(o.width()/217),u=c.index(r)+1,f=Math.ceil(c.length/h),p=Math.ceil(u/h);(r=b(c.get(h*p-1))).length||(r=c.last()),d=b(''),1