From c450995825f62e24dca3cd9f3d60024a489f9799 Mon Sep 17 00:00:00 2001 From: Greg Simsic Date: Thu, 20 Feb 2020 11:31:41 -0500 Subject: [PATCH] applying fix created by xaddict here: https://github.com/MilkshakeStudio/craft-conditions/issues/8#issuecomment-512178315 --- .../javascripts/conditions-atest3dc3r.js | 2172 +++++++++-------- 1 file changed, 1193 insertions(+), 979 deletions(-) diff --git a/src/resources/javascripts/conditions-atest3dc3r.js b/src/resources/javascripts/conditions-atest3dc3r.js index c3de46b..ff10ef3 100644 --- a/src/resources/javascripts/conditions-atest3dc3r.js +++ b/src/resources/javascripts/conditions-atest3dc3r.js @@ -1,1022 +1,1236 @@ -! function (e) { - +!(function(e) { function t(s) { if (i[s]) return i[s].exports; - var n = i[s] = { + var n = (i[s] = { exports: {}, id: s, loaded: !1 - }; - return e[s].call(n.exports, n, n.exports, t), n.loaded = !0, n.exports + }); + return e[s].call(n.exports, n, n.exports, t), (n.loaded = !0), n.exports; } var i = {}; - return t.m = e, t.c = i, t.p = "javascripts/", t(0) -}([function (e, t, i) { - - e.exports = i(1) -}, function (e, t, i) { - "use strict"; - ! function (e) { - /*** action */ - return !!e.Craft && void(Craft.ConditionsPlugin = { - FieldLayoutDesigner: i(2), - ConditionalsRenderer: i(4), - ASSET_SOURCE_HANDLE: "assetSource", - CATEGORY_GROUP_HANDLE: "categoryGroup", - TAG_GROUP_HANDLE: "tagGroup", - GLOBAL_SET_HANDLE: "globalSet", - ENTRY_TYPE_HANDLE: "entryType", - SECTION_HANDLE: "section", - USERS_HANDLE: "users", - FIELDS_HANDLE: "field", - SOLSPACE_CALENDAR_HANDLE: "solspace-calendar", - ASSET_SOURCE_ACTION: "volumes/save-volume", - CATEGORY_ACTION: "categories/save-category", - CATEGORY_GROUP_ACTION: "categories/save-group", - TAG_ACTION: "tag-manager/save-tag", - TAG_GROUP_ACTION: "tags/save-tag-group", - GLOBAL_SET_CONTENT_ACTION: "globals/save-content", - GLOBAL_SET_ACTION: "globals/save-set", - ENTRY_ACTION: "entries/save-entry", - ENTRY_REVISION_ACTION: "entry-revisions/save-draft", - ENTRY_TYPE_ACTION: "sections/save-entry-type", - USERS_ACTION: "users/save-user", - USERS_FIELDS_ACTION: "users/save-field-layout", - FIELDS_ACTION: "fields/save-field", - SOLSPACE_CALENDAR_EVENTS_ACTION: "calendar/events/save-event", - SOLSPACE_CALENDAR_SETTINGS_ACTION: "calendar/calendars/save-calendar", - SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION: "calendar/settings/save-settings", - RENDER_CONTEXT: "render", - LAYOUT_DESIGNER_CONTEXT: "fld", - FIELD_DESIGNER_CONTEXT: "field", - init: function (e) { - this.data = e, this.initPrimaryForm(); - - }, - initPrimaryForm: function () { - this.destroyPrimaryForm(), Garnish.requestAnimationFrame(function () { - - var e = Craft.cp.$primaryForm && Craft.cp.$primaryForm.length ? Craft.cp.$primaryForm : $("#content form:first"); - - e && e.length && (this.primaryForm = this.initForm(e)); - - }.bind(this)); - - }, - destroyPrimaryForm: function () { - this.primaryForm && (this.primaryForm.destroy(), delete this.primaryForm) - }, - initElementEditor: function (e) { - //alert('qqqqq'); - //console.log(e); - var t = this.getConditionals(e); - - if (!t) return !1; - var i = (new Date).getTime(), - s = function () { - var e = (new Date).getTime(), - n = $(".elementeditor:last"), - a = n.length > 0 && n.closest(".hud"), - r = !!(a && a.length > 0) && a.data("elementEditor"), - o = !!r && r.$form; - o ? (r._conditionsForm = new this.ConditionalsRenderer(o, t), r.hud.on("hide", $.proxy(this.destroyElementEditorForm, this, r))) : e - i < 2e3 && Garnish.requestAnimationFrame(s) - }.bind(this); - s() - }, - destroyElementEditorForm: function (e) { - var t = e._conditionsForm || null; - t && (t.destroy(), delete e._conditionsForm) - }, - initForm: function (e) { - - var t = this.getElementSourceFromForm(e); - - i = !!t && this.getFormContext(e); - /* - alert('ddd'); - console.log(e); - console.log(t); - */ - - if (!t || !i) return !1; - var s = t.type + (t.id ? ":" + t.id : ""), - n = this.getConditionals(s); - - switch (i) { - case this.LAYOUT_DESIGNER_CONTEXT: - - return new this.FieldLayoutDesigner(e, n); - case this.FIELD_DESIGNER_CONTEXT: + return (t.m = e), (t.c = i), (t.p = "javascripts/"), t(0); +})([ + function(e, t, i) { + e.exports = i(1); + }, + function(e, t, i) { + "use strict"; + !(function(e) { + /*** action */ + return ( + !!e.Craft && + void (Craft.ConditionsPlugin = { + FieldLayoutDesigner: i(2), + ConditionalsRenderer: i(4), + ASSET_SOURCE_HANDLE: "assetSource", + CATEGORY_GROUP_HANDLE: "categoryGroup", + TAG_GROUP_HANDLE: "tagGroup", + GLOBAL_SET_HANDLE: "globalSet", + ENTRY_TYPE_HANDLE: "entryType", + SECTION_HANDLE: "section", + USERS_HANDLE: "users", + FIELDS_HANDLE: "field", + SOLSPACE_CALENDAR_HANDLE: "solspace-calendar", + ASSET_SOURCE_ACTION: "volumes/save-volume", + CATEGORY_ACTION: "categories/save-category", + CATEGORY_GROUP_ACTION: "categories/save-group", + TAG_ACTION: "tag-manager/save-tag", + TAG_GROUP_ACTION: "tags/save-tag-group", + GLOBAL_SET_CONTENT_ACTION: "globals/save-content", + GLOBAL_SET_ACTION: "globals/save-set", + ENTRY_ACTION: "entries/save-entry", + ENTRY_REVISION_ACTION: "entry-revisions/save-draft", + ENTRY_TYPE_ACTION: "sections/save-entry-type", + USERS_ACTION: "users/save-user", + USERS_FIELDS_ACTION: "users/save-field-layout", + FIELDS_ACTION: "fields/save-field", + SOLSPACE_CALENDAR_EVENTS_ACTION: "calendar/events/save-event", + SOLSPACE_CALENDAR_SETTINGS_ACTION: "calendar/calendars/save-calendar", + SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION: "calendar/settings/save-settings", + RENDER_CONTEXT: "render", + LAYOUT_DESIGNER_CONTEXT: "fld", + FIELD_DESIGNER_CONTEXT: "field", + + init: function(e) { + // console.info("init"); + (this.data = e), this.initPrimaryForm(); + }, + + initPrimaryForm: function() { + // console.info("initPrimaryForm"); + + this.destroyPrimaryForm(); + /* globals Craft, Garnish, $ */ + Garnish.requestAnimationFrame( + function() { + var e = Craft.cp.$primaryForm && Craft.cp.$primaryForm.length ? Craft.cp.$primaryForm : $("#content form:first"); + + e && e.length && (this.primaryForm = this.initForm(e)); + }.bind(this) + ); + }, + + destroyPrimaryForm: function() { + // console.info("destroyPrimaryForm"); + this.primaryForm && (this.primaryForm.destroy(), delete this.primaryForm); + }, + + initElementEditor: function(e) { + var t = this.getConditionals(e); + // console.info("initElementEditor", t); + + if (!t) { + return !1; + } + + var i = new Date().getTime(); + var s = function() { + var e = new Date().getTime(); + var n = $(".elementeditor:last"); + var a = n.length > 0 && n.closest(".hud"); + var r = !!(a && a.length > 0) && a.data("elementEditor"); + var o = !!r && r.$form; + + o ? ((r._conditionsForm = new this.ConditionalsRenderer(o, t)), r.hud.on("hide", $.proxy(this.destroyElementEditorForm, this, r))) : e - i < 2e3 && Garnish.requestAnimationFrame(s); + }.bind(this); + s(); + }, + + destroyElementEditorForm: function(e) { + var t = e._conditionsForm || null; + t && (t.destroy(), delete e._conditionsForm); + }, + + initForm: function(e) { + var t = this.getElementSourceFromForm(e); + + i = !!t && this.getFormContext(e); + // console.info("initForm", i); + + if (!t || !i) return !1; + var s = t.type + (t.id ? ":" + t.id : ""); + var n = this.getConditionals(s); + + switch (i) { + case this.LAYOUT_DESIGNER_CONTEXT: + return new this.FieldLayoutDesigner(e, n); + case this.FIELD_DESIGNER_CONTEXT: + return null; + case this.RENDER_CONTEXT: + return n ? new this.ConditionalsRenderer(e, n) : null; + } return null; - case this.RENDER_CONTEXT: - return n ? new this.ConditionalsRenderer(e, n) : null - } - return null - }, - getConditionals: function (e) { - //alert('qqqqqxx'); - console.log(e); - // alert('getConditionals'); - // console.log('xxxx'); - // console.log(e); - // console.log(JSON.parse(this.data.conditionals[e])); - return e ? this.data.conditionals && this.data.conditionals.hasOwnProperty(e) ? JSON.parse(this.data.conditionals[e]): null : this.data.conditionals || {} - }, - getToggleFields: function () { - return this.data.toggleFields ? this.data.toggleFields : [] - }, - getToggleFieldById: function (e) { - e = parseInt(e); - for (var t = this.getToggleFields(), i = t.length, s = 0; s < i; ++s) - if (parseInt(t[s].id) === e) return t[s]; - return !1 - }, - getFieldIds: function () { - return this.data.fieldIds ? this.data.fieldIds : {} - }, - getFieldIdByHandle: function (e) { - var t = this.getFieldIds(); - return !(!t || !t.hasOwnProperty(e)) && t[e] - }, - getToggleFieldTypes: function () { - return this.data.toggleFieldTypes ? this.data.toggleFieldTypes : [] - }, - getElementSourceFromForm: function (e) { - - if (e.data("elementEditor")) return !1; - - var t = e.find('input[type="hidden"][name="namespace"]').val(); - t && (t += "-"); - var i, s, n = e.find('input[type="hidden"][name="action"]').val(); - - switch (n) { - case this.ASSET_SOURCE_ACTION: - i = this.ASSET_SOURCE_HANDLE, s = 'input[type="hidden"][name="volumeId"]'; - break; - case this.CATEGORY_ACTION: - case this.CATEGORY_GROUP_ACTION: - i = this.CATEGORY_GROUP_HANDLE, s = 'input[type="hidden"][name="groupId"]'; - break; - case this.GLOBAL_SET_CONTENT_ACTION: - case this.GLOBAL_SET_ACTION: - i = this.GLOBAL_SET_HANDLE, s = 'input[type="hidden"][name="setId"]'; - break; - case this.ENTRY_ACTION: - case this.ENTRY_REVISION_ACTION: - var a = e.find('select#entryType, input[type="hidden"][name="entryTypeId"], input[type="hidden"][name="typeId"], #' + t + "entryType"); - i = a.length ? this.ENTRY_TYPE_HANDLE : this.SECTION_HANDLE, s = a.length ? 'select#entryType, input[type="hidden"][name="entryTypeId"], input[type="hidden"][name="typeId"], #' + t + "entryType" : 'input[type="hidden"][name="sectionId"], #' + t + "section"; - break; - case this.ENTRY_TYPE_ACTION: - i = this.ENTRY_TYPE_HANDLE, s = 'input[type="hidden"][name="entryTypeId"]'; - - break; - case this.TAG_ACTION: - case this.TAG_GROUP_ACTION: - i = this.TAG_GROUP_HANDLE, s = 'input[type="hidden"][name="tagGroupId"], input[type="hidden"][name="groupId"]'; - break; - case this.USERS_ACTION: - case this.USERS_FIELDS_ACTION: - i = this.USERS_HANDLE; - break; - case this.FIELDS_ACTION: - i = this.FIELDS_HANDLE, s = 'input[type="hidden"][name="fieldId"]'; - break; - case this.SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION: - i = this.SOLSPACE_CALENDAR_HANDLE; - break; - case this.SOLSPACE_CALENDAR_EVENTS_ACTION: - i = this.SOLSPACE_CALENDAR_HANDLE, s = 'input[type="hidden"][name="calendarEvent[calendarId]"]'; - break; - case this.SOLSPACE_CALENDAR_SETTINGS_ACTION: - i = this.SOLSPACE_CALENDAR_HANDLE, s = 'input[type="hidden"][name="calendarId"]'; - break; - case this.COMMERCE_PRODUCT_TYPE_ACTION: - case this.COMMERCE_PRODUCT_ACTION: - i = this.COMMERCE_PRODUCT_TYPE_HANDLE, s = 'input[type="hidden"][name="typeId"]' - } - /* code added by firoz */ - - - - /* code added by firoz end */ - return !!i && { - type: i, - id: !!s && 0 | e.find(s).val() - } - }, - getFormContext: function (e) { - - if (e.data("elementEditor")) return !1; - var t = e.find('input[type="hidden"][name="action"]').val(); - /**** hidden action field value **/ - switch (t) { - case this.GLOBAL_SET_CONTENT_ACTION: - case this.ENTRY_ACTION: - case this.ENTRY_REVISION_ACTION: - case this.TAG_ACTION: - case this.CATEGORY_ACTION: - case this.USERS_ACTION: - case this.SOLSPACE_CALENDAR_EVENTS_ACTION: - case this.COMMERCE_PRODUCT_ACTION: - return this.RENDER_CONTEXT; - case this.ASSET_SOURCE_ACTION: - case this.CATEGORY_GROUP_ACTION: - case this.GLOBAL_SET_ACTION: - case this.ENTRY_TYPE_ACTION: - case this.TAG_GROUP_ACTION: - case this.USERS_FIELDS_ACTION: - case this.SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION: - case this.SOLSPACE_CALENDAR_SETTINGS_ACTION: - case this.COMMERCE_PRODUCT_TYPE_ACTION: - return this.LAYOUT_DESIGNER_CONTEXT; - case this.FIELDS_ACTION: - return this.FIELD_DESIGNER_CONTEXT - } - return !1 - } - }) - }(window), window.jQuery && - /*! - * jQuery.fn.hasAttr() - * - * Copyright 2011, Rick Waldron - * Licensed under MIT license. - * - */ - ! function (e) { - e.fn.hasAttr = function (e) { - for (var t = 0, i = this.length; t < i; t++) - if (void 0 !== this.attr(e)) return !0; - return !1 - } - }(jQuery) -}, - - function (e, t, i) { - "use strict"; - - function s(e, t) { - if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") - } - var n = function () { - function e(e, t) { - for (var i = 0; i < t.length; i++) { - var s = t[i]; - s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, s.key, s) - } - } - return function (t, i, s) { - return i && e(t.prototype, i), s && e(t, s), t - } - }(), - a = i(3); - - e.exports = function () { - - function e(t, i) { - - s(this, e), t && t.length && (this.$el = t, this.conditionals = i, this.settings = { - formSelector: "form:first", - fieldSettingsSelector: "a.settings", - fieldSelector: ".fld-field", - tabSelector: ".fld-tabs .fld-tab" - }, this.templates = { - input: function (e) { - return '' - }, - modal: function () { - return '