From 122838b85e6f49a59e498955f6c5d391c3d6c65e Mon Sep 17 00:00:00 2001 From: "M. Mikkel Rummelhoff" Date: Wed, 25 May 2016 16:39:29 +0200 Subject: [PATCH] Fixes issue #23 --- README.md | 6 +- reasons/ReasonsPlugin.php | 170 +++++++++++++----- ..._000000_reasons_addFieldLayoutIdColumn.php | 128 +++++++------ reasons/models/Reasons_ConditionalsModel.php | 30 ++-- .../records/Reasons_ConditionalsRecord.php | 69 +++---- ...8c6.js => reasons-6124c2e40a6cb71616a5.js} | 2 +- reasons/resources/rev-manifest.json | 4 +- ...-2b40a218fb.css => reasons-a008e38a64.css} | 0 reasons/services/ReasonsService.php | 103 ++++++----- releases.json | 112 ++++++------ source/javascripts/modules/render.js | 34 ++-- 11 files changed, 387 insertions(+), 271 deletions(-) rename reasons/resources/javascripts/{reasons-b9a200fb5cd8a5dc68c6.js => reasons-6124c2e40a6cb71616a5.js} (91%) rename reasons/resources/stylesheets/{reasons-2b40a218fb.css => reasons-a008e38a64.css} (100%) diff --git a/README.md b/README.md index 6bef315..70308c6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Reasons v. 1.0.3 for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square) +# Reasons v. 1.0.4 for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square) _Supercharge your field layouts with conditionals._ @@ -94,6 +94,10 @@ Please report any bugs, feature requests or other issues [here](https://github.c ### Changelog +#### 1.0.4 (05.25.2016) + +* [Fixed] Fixes a rare issue where Reasons would hide fields inside Matrix blocks + #### 1.0.3 (03.02.2016) * [Fixed] Fixed an issue where conditionals would not work in Live Preview diff --git a/reasons/ReasonsPlugin.php b/reasons/ReasonsPlugin.php index 8136ed6..82109b6 100644 --- a/reasons/ReasonsPlugin.php +++ b/reasons/ReasonsPlugin.php @@ -11,75 +11,115 @@ * @link https://github.com/mmikkel/Reasons-Craft */ +/** + * Class ReasonsPlugin + * @package Craft + */ class ReasonsPlugin extends BasePlugin { - protected $_version = '1.0.3', - $_schemaVersion = '1.1', - $_developer = 'Mats Mikkel Rummelhoff', - $_developerUrl = 'http://mmikkel.no', - $_pluginName = 'Reasons', - $_pluginUrl = 'https://github.com/mmikkel/Reasons-Craft', - $_releaseFeedUrl = 'https://raw.githubusercontent.com/mmikkel/Reasons-Craft/master/releases.json', - $_documentationUrl = 'https://github.com/mmikkel/Reasons-Craft/blob/master/README.md', - $_description = 'Adds conditionals to field layouts.', - $_minVersion = '2.5'; - + protected $_version = '1.0.4', + $_schemaVersion = '1.1', + $_developer = 'Mats Mikkel Rummelhoff', + $_developerUrl = 'http://mmikkel.no', + $_pluginName = 'Reasons', + $_pluginUrl = 'https://github.com/mmikkel/Reasons-Craft', + $_releaseFeedUrl = 'https://raw.githubusercontent.com/mmikkel/Reasons-Craft/master/releases.json', + $_documentationUrl = 'https://github.com/mmikkel/Reasons-Craft/blob/master/README.md', + $_description = 'Adds conditionals to field layouts.', + $_minVersion = '2.5'; + + /** + * @return string + */ public function getName() { return $this->_pluginName; } + /** + * @return string + */ public function getVersion() { return $this->_version; } + /** + * @return string + */ public function getSchemaVersion() { return $this->_schemaVersion; } + /** + * @return string + */ public function getDeveloper() { return $this->_developer; } + /** + * @return string + */ public function getDeveloperUrl() { return $this->_developerUrl; } + /** + * @return string + */ public function getPluginUrl() { return $this->_pluginUrl; } + /** + * @return string + */ public function getReleaseFeedUrl() { return $this->_releaseFeedUrl; } + /** + * @return string + */ public function getDescription() { return $this->_description; } + /** + * @return string + */ public function getDocumentationUrl() { return $this->_documentationUrl; } + /** + * @return string + */ public function getCraftRequiredVersion() { return $this->_minVersion; } + /** + * @return mixed + */ public function isCraftRequiredVersion() { return version_compare(craft()->getVersion(), $this->getCraftRequiredVersion(), '>='); } + /** + * @return bool + */ public function onBeforeInstall() { if (!$this->isCraftRequiredVersion()) { @@ -88,17 +128,23 @@ public function onBeforeInstall() } } + /** + * + */ public function onBeforeUninstall() { craft()->fileCache->delete($this->getCacheKey()); } + /** + * @return bool + */ public function init() { parent::init(); - if(!craft()->request->isCpRequest() || craft()->isConsole()) { + if (!craft()->request->isCpRequest() || craft()->isConsole()) { return false; } @@ -114,12 +160,12 @@ public function init() } else { $this->includeResources(); - + craft()->templates->includeJs('if (window.Craft && window.Craft.ReasonsPlugin) { - Craft.ReasonsPlugin.init('.$this->getData().'); + Craft.ReasonsPlugin.init(' . $this->getData() . '); }'); - - craft()->on('fields.saveFieldLayout', array($this,'onSaveFieldLayout')); + + craft()->on('fields.saveFieldLayout', array($this, 'onSaveFieldLayout')); } @@ -129,73 +175,74 @@ public function init() * Protected methods * */ + /** + * @return bool + */ protected function ajaxInit() { - if (!craft()->request->isPostRequest()) - { + if (!craft()->request->isPostRequest()) { return false; } $segments = craft()->request->segments; - $actionSegment = $segments[count($segments)-1]; + $actionSegment = $segments[count($segments) - 1]; - switch ($actionSegment) - { + switch ($actionSegment) { case 'switchEntryType' : - + craft()->templates->includeJs('Craft.ReasonsPlugin.initPrimaryForm();'); break; case 'getEditorHtml' : - + $elementId = (int)craft()->request->getPost('elementId'); $element = $elementId ? craft()->elements->getElementById($elementId) : null; $elementType = $element ? $element->elementType : craft()->request->getPost('elementType'); $attributes = craft()->request->getPost('attributes'); - + $conditionalsKey = null; switch ($elementType) { - + case ElementType::Entry : if ($element) { - $conditionalsKey = 'entryType:'.$element->type->id; + $conditionalsKey = 'entryType:' . $element->type->id; } else if (isset($attributes['typeId'])) { - $conditionalsKey = 'entryType:'.$attributes['typeId']; + $conditionalsKey = 'entryType:' . $attributes['typeId']; } else if (isset($attributes['sectionId'])) { $entryTypes = craft()->sections->getEntryTypesBySectionId((int)$attributes['sectionId']); $entryType = $entryTypes ? array_shift($entryTypes) : false; - $conditionalsKey = $entryType ? 'entryType:'.$entryType->id : null; + $conditionalsKey = $entryType ? 'entryType:' . $entryType->id : null; } break; case ElementType::GlobalSet : - $conditionalsKey = $element ? 'globalSet:'.$element->id : null; + $conditionalsKey = $element ? 'globalSet:' . $element->id : null; break; case ElementType::Asset : - $conditionalsKey = $element ? 'assetSource:'.$element->source->id : null; + $conditionalsKey = $element ? 'assetSource:' . $element->source->id : null; break; case ElementType::Category : - $conditionalsKey = $element ? 'categoryGroup:'.$element->group->id : null; + $conditionalsKey = $element ? 'categoryGroup:' . $element->group->id : null; break; case ElementType::Tag : - $conditionalsKey = $element ? 'tagGroup:'.$element->group->id : null; + $conditionalsKey = $element ? 'tagGroup:' . $element->group->id : null; break; case ElementType::User : $conditionalsKey = 'users'; break; - } + } if ($conditionalsKey) { - craft()->templates->includeJs('Craft.ReasonsPlugin.initElementEditor("'.$conditionalsKey.'");'); + craft()->templates->includeJs('Craft.ReasonsPlugin.initElementEditor("' . $conditionalsKey . '");'); } break; @@ -204,6 +251,9 @@ protected function ajaxInit() } + /** + * + */ protected function includeResources() { $cssFile = 'stylesheets/reasons.css'; @@ -213,6 +263,9 @@ protected function includeResources() craft()->templates->includeJsResource('reasons/' . ($manifest ? $manifest->$jsFile : $jsFile)); } + /** + * @return string + */ protected function getData() { if (!$data = craft()->fileCache->get($this->getCacheKey())) { @@ -227,6 +280,9 @@ protected function getData() return json_encode($data); } + /** + * @return array + */ protected function getConditionals() { @@ -238,33 +294,33 @@ protected function getConditionals() if ($entryTypeRecords) { foreach ($entryTypeRecords as $entryTypeRecord) { $entryType = EntryTypeModel::populateModel($entryTypeRecord); - $sources['entryType:'.$entryType->id] = $entryType->fieldLayoutId; - $sources['section:'.$entryType->sectionId] = $entryType->fieldLayoutId; + $sources['entryType:' . $entryType->id] = $entryType->fieldLayoutId; + $sources['section:' . $entryType->sectionId] = $entryType->fieldLayoutId; } } // Category groups $allCategoryGroups = craft()->categories->getAllGroups(); foreach ($allCategoryGroups as $categoryGroup) { - $sources['categoryGroup:'.$categoryGroup->id] = $categoryGroup->fieldLayoutId; + $sources['categoryGroup:' . $categoryGroup->id] = $categoryGroup->fieldLayoutId; } // Tag groups $allTagGroups = craft()->tags->getAllTagGroups(); foreach ($allTagGroups as $tagGroup) { - $sources['tagGroup:'.$tagGroup->id] = $tagGroup->fieldLayoutId; + $sources['tagGroup:' . $tagGroup->id] = $tagGroup->fieldLayoutId; } // Asset sources $allAssetSources = craft()->assetSources->getAllSources(); foreach ($allAssetSources as $assetSource) { - $sources['assetSource:'.$assetSource->id] = $assetSource->fieldLayoutId; + $sources['assetSource:' . $assetSource->id] = $assetSource->fieldLayoutId; } // Global sets $allGlobalSets = craft()->globals->getAllSets(); foreach ($allGlobalSets as $globalSet) { - $sources['globalSet:'.$globalSet->id] = $globalSet->fieldLayoutId; + $sources['globalSet:' . $globalSet->id] = $globalSet->fieldLayoutId; } // Matrix blocks @@ -272,7 +328,7 @@ protected function getConditionals() if ($matrixBlockTypeRecords) { foreach ($matrixBlockTypeRecords as $matrixBlockTypeRecord) { $matrixBlockType = MatrixBlockTypeModel::populateModel($matrixBlockTypeRecord); - $sources['matrixBlockType:'.$matrixBlockType->id] = $matrixBlockType->fieldLayoutId; + $sources['matrixBlockType:' . $matrixBlockType->id] = $matrixBlockType->fieldLayoutId; } } @@ -289,15 +345,15 @@ protected function getConditionals() foreach ($conditionalsRecords as $conditionalsRecord) { $conditionalsModel = Reasons_ConditionalsModel::populateModel($conditionalsRecord); if ($conditionalsModel->conditionals && $conditionalsModel->conditionals != '') { - $conditionals['fieldLayout:'.$conditionalsModel->fieldLayoutId] = $conditionalsModel->conditionals; + $conditionals['fieldLayout:' . $conditionalsModel->fieldLayoutId] = $conditionalsModel->conditionals; } } } // Map conditionals to sources foreach ($sources as $sourceId => $fieldLayoutId) { - if (isset($conditionals['fieldLayout:'.$fieldLayoutId])) { - $r[$sourceId] = $conditionals['fieldLayout:'.$fieldLayoutId]; + if (isset($conditionals['fieldLayout:' . $fieldLayoutId])) { + $r[$sourceId] = $conditionals['fieldLayout:' . $fieldLayoutId]; } } @@ -305,6 +361,9 @@ protected function getConditionals() } + /** + * @return array + */ protected function getToggleFieldTypes() { return array( @@ -323,12 +382,15 @@ protected function getToggleFieldTypes() * Returns all toggleable fields * */ + /** + * @return array + */ protected function getToggleFields() { $toggleFieldTypes = $this->getToggleFieldTypes(); $toggleFields = array(); $fields = craft()->fields->getAllFields(); - foreach($fields as $field){ + foreach ($fields as $field) { $fieldType = $field->getFieldType(); $classHandle = $fieldType && is_object($fieldType) && $fieldType->classHandle ? $fieldType->classHandle : false; if (!$classHandle) { @@ -347,31 +409,43 @@ protected function getToggleFields() return $toggleFields; } + /** + * @return array + */ protected function getFieldIds() { $handles = array(); $fields = craft()->fields->getAllFields(); - foreach ($fields as $field){ + foreach ($fields as $field) { $handles[$field->handle] = $field->id; } return $handles; } + /** + * @return bool|mixed + */ protected function getRevisionManifest() { - $manifestPath = craft()->path->getPluginsPath().'/reasons/resources/rev-manifest.json'; + $manifestPath = craft()->path->getPluginsPath() . '/reasons/resources/rev-manifest.json'; return (IOHelper::fileExists($manifestPath) && $manifest = IOHelper::getFileContents($manifestPath)) ? json_decode($manifest) : false; } + /** + * @return string + */ protected function getCacheKey() { - return $this->_pluginName.'_'.$this->_version.'_'.$this->_schemaVersion; + return $this->_pluginName . '_' . $this->_version . '_' . $this->_schemaVersion; } /* * Event handlers * */ + /** + * @param Event $e + */ public function onSaveFieldLayout(Event $e) { $conditionals = craft()->request->getPost('_reasons'); diff --git a/reasons/migrations/m160117_000000_reasons_addFieldLayoutIdColumn.php b/reasons/migrations/m160117_000000_reasons_addFieldLayoutIdColumn.php index ba2d556..9d3361a 100644 --- a/reasons/migrations/m160117_000000_reasons_addFieldLayoutIdColumn.php +++ b/reasons/migrations/m160117_000000_reasons_addFieldLayoutIdColumn.php @@ -1,81 +1,79 @@ - * @package Reasons - * @since Craft 2.3 - * @copyright Copyright (c) 2015, Mats Mikkel Rummelhoff - * @license http://opensource.org/licenses/mit-license.php MIT License - * @link https://github.com/mmikkel/Reasons-Craft - */ + /** + * Reasons by Mats Mikkel Rummelhoff + * + * @author Mats Mikkel Rummelhoff + * @package Reasons + * @since Craft 2.3 + * @copyright Copyright (c) 2015, Mats Mikkel Rummelhoff + * @license http://opensource.org/licenses/mit-license.php MIT License + * @link https://github.com/mmikkel/Reasons-Craft + */ /** * The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName */ class m160117_000000_reasons_addFieldLayoutIdColumn extends BaseMigration { - /** - * Any migration code in here is wrapped inside of a transaction. - * - * @return bool - */ - public function safeUp() - { + /** + * Any migration code in here is wrapped inside of a transaction. + * + * @return bool + */ + public function safeUp() + { + + /* + * Craft 2.5+ required – abort migration if not, making it possible to roll back to 2.3 or 2.4 + * + */ + if (!version_compare(craft()->getVersion(), '2.5', '>=')) { + throw new Exception(Craft::t('Reasons 1.0 requires Craft 2.5 or newer and is unable to complete this update. Please restore Reasons to v. 0.2.2 or older, or update your Craft install.')); + return false; + } - /* - * Craft 2.5+ required – abort migration if not, making it possible to roll back to 2.3 or 2.4 - * - */ - if (!version_compare(craft()->getVersion(), '2.5', '>=')) { - throw new Exception(Craft::t('Reasons 1.0 requires Craft 2.5 or newer and is unable to complete this update. Please restore Reasons to v. 0.2.2 or older, or update your Craft install.')); - return false; - } + $table = 'reasons'; - $table = 'reasons'; + /* + * Add FK fieldLayoutId column + * + */ + $this->addColumnAfter($table, 'fieldLayoutId', ColumnType::Int, 'id'); + $this->addForeignKey($table, 'fieldLayoutId', 'fieldlayouts', 'id', 'CASCADE', 'CASCADE'); - /* - * Add FK fieldLayoutId column - * - */ - $this->addColumnAfter($table, 'fieldLayoutId', ColumnType::Int, 'id'); - $this->addForeignKey($table, 'fieldLayoutId', 'fieldlayouts', 'id', 'CASCADE', 'CASCADE'); + /* + * Set fieldLayoutId for existing rows + * + */ + $entryTypeRecords = EntryTypeRecord::model()->findAll(); + if ($entryTypeRecords) { + $entryTypes = EntryTypeModel::populateModels($entryTypeRecords); + foreach ($entryTypes as $entryType) { + if (!isset($entryType->fieldLayoutId) || !$entryType->fieldLayoutId) continue; + $this->update($table, array( + 'fieldLayoutId' => $entryType->fieldLayoutId, + ), 'typeId=:typeId', array( + ':typeId' => $entryType->id, + )); + } + } - /* - * Set fieldLayoutId for existing rows - * - */ - $entryTypeRecords = EntryTypeRecord::model()->findAll(); - if ($entryTypeRecords) - { - $entryTypes = EntryTypeModel::populateModels($entryTypeRecords); - foreach ($entryTypes as $entryType) - { - if (!isset($entryType->fieldLayoutId) || !$entryType->fieldLayoutId) continue; - $this->update($table, array( - 'fieldLayoutId' => $entryType->fieldLayoutId, - ), 'typeId=:typeId', array( - ':typeId' => $entryType->id, - )); - } - } - - /* - * Delete typeId column - * - */ - $this->dropForeignKey($table, 'typeId'); - $this->dropColumn($table, 'typeId'); + /* + * Delete typeId column + * + */ + $this->dropForeignKey($table, 'typeId'); + $this->dropColumn($table, 'typeId'); - /* - * Delete sectionId column - * - */ - $this->dropForeignKey($table, 'sectionId'); - $this->dropColumn($table, 'sectionId'); + /* + * Delete sectionId column + * + */ + $this->dropForeignKey($table, 'sectionId'); + $this->dropColumn($table, 'sectionId'); - return true; + return true; - } + } } diff --git a/reasons/models/Reasons_ConditionalsModel.php b/reasons/models/Reasons_ConditionalsModel.php index f1d9f80..f795e03 100644 --- a/reasons/models/Reasons_ConditionalsModel.php +++ b/reasons/models/Reasons_ConditionalsModel.php @@ -11,20 +11,24 @@ * @link https://github.com/mmikkel/Reasons-Craft */ +/** + * Class Reasons_ConditionalsModel + * @package Craft + */ class Reasons_ConditionalsModel extends BaseModel { - /** - * @access protected - * @return array - */ - protected function defineAttributes() - { - return array( - 'id' => AttributeType::Number, - 'fieldLayoutId' => AttributeType::Number, - 'conditionals' => AttributeType::Mixed, - ); - } + /** + * @access protected + * @return array + */ + protected function defineAttributes() + { + return array( + 'id' => AttributeType::Number, + 'fieldLayoutId' => AttributeType::Number, + 'conditionals' => AttributeType::Mixed, + ); + } -} \ No newline at end of file +} diff --git a/reasons/records/Reasons_ConditionalsRecord.php b/reasons/records/Reasons_ConditionalsRecord.php index 6a2edce..c0d7aa8 100644 --- a/reasons/records/Reasons_ConditionalsRecord.php +++ b/reasons/records/Reasons_ConditionalsRecord.php @@ -11,39 +11,46 @@ * @link https://github.com/mmikkel/Reasons-Craft */ +/** + * Class Reasons_ConditionalsRecord + * @package Craft + */ class Reasons_ConditionalsRecord extends BaseRecord { - public function getTableName() - { - return 'reasons'; - } + /** + * @return string + */ + public function getTableName() + { + return 'reasons'; + } - /** - * @access protected - * @return array - */ - protected function defineAttributes() - { - return array( - 'fieldLayoutId' => AttributeType::Number, - 'conditionals' => AttributeType::Mixed, - ); - } + /** + * @access protected + * @return array + */ + protected function defineAttributes() + { + return array( + 'fieldLayoutId' => AttributeType::Number, + 'conditionals' => AttributeType::Mixed, + ); + } - /** - * @access public - * @return array - */ - public function defineRelations() - { - return array( - 'fieldLayout' => array( - static::BELONGS_TO, - 'FieldLayoutRecord', - 'fieldLayoutId', - 'onDelete' => static::CASCADE, - ), - ); - } + /** + * @access public + * @return array + */ + public function defineRelations() + { + return array( + 'fieldLayout' => array( + static::BELONGS_TO, + 'FieldLayoutRecord', + 'fieldLayoutId', + 'onDelete' => static::CASCADE, + ), + ); + } -} \ No newline at end of file +} diff --git a/reasons/resources/javascripts/reasons-b9a200fb5cd8a5dc68c6.js b/reasons/resources/javascripts/reasons-6124c2e40a6cb71616a5.js similarity index 91% rename from reasons/resources/javascripts/reasons-b9a200fb5cd8a5dc68c6.js rename to reasons/resources/javascripts/reasons-6124c2e40a6cb71616a5.js index 97c7f5c..a6ba65e 100644 --- a/reasons/resources/javascripts/reasons-b9a200fb5cd8a5dc68c6.js +++ b/reasons/resources/javascripts/reasons-6124c2e40a6cb71616a5.js @@ -1 +1 @@ -!function(e){function t(s){if(i[s])return i[s].exports;var n=i[s]={exports:{},id:s,loaded:!1};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){return e.Craft?void(Craft.ReasonsPlugin={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",ASSET_SOURCE_ACTION:"assetSources/saveSource",CATEGORY_ACTION:"categories/saveCategory",CATEGORY_GROUP_ACTION:"categories/saveGroup",TAG_ACTION:"tagManager/saveTag",TAG_GROUP_ACTION:"tags/saveTagGroup",GLOBAL_SET_CONTENT_ACTION:"globals/saveContent",GLOBAL_SET_ACTION:"globals/saveSet",ENTRY_ACTION:"entries/saveEntry",ENTRY_TYPE_ACTION:"sections/saveEntryType",USERS_ACTION:"users/saveUser",USERS_FIELDS_ACTION:"users/saveFieldLayout",FIELDS_ACTION:"fields/saveField",RENDER_CONTEXT:"render",LAYOUT_DESIGNER_CONTEXT:"fld",FIELD_DESIGNER_CONTEXT:"field",init:function(e){this.data=e,this.initPrimaryForm()},initPrimaryForm:function(){this.destroyPrimaryForm(),Craft.cp.$primaryForm&&(this.primaryForm=this.initForm(Craft.cp.$primaryForm))},destroyPrimaryForm:function(){this.primaryForm&&(this.primaryForm.destroy(),delete this.primaryForm)},initElementEditor:function(e){var t=this.getConditionals(e);if(!t)return!1;var i=(new Date).getTime(),s=$.proxy(function(){var e=(new Date).getTime(),n=$(".elementeditor:last"),a=n.length>0?n.closest(".hud"):!1,r=a&&a.length>0?a.data("elementEditor"):!1,o=r?r.$form:!1;o?(r._reasonsForm=new this.ConditionalsRenderer(o,t),r.hud.on("hide",$.proxy(this.destroyElementEditorForm,this,r))):2e3>e-i&&Garnish.requestAnimationFrame(s)},this);s()},destroyElementEditorForm:function(e){var t=e._reasonsForm||null;t&&(t.destroy(),delete e._reasonsForm)},initForm:function(e){var t=this.getElementSourceFromForm(e),i=t?this.getFormContext(e):!1;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 null;case this.RENDER_CONTEXT:return n?new this.ConditionalsRenderer(e,n):null}return null},getConditionals:function(e){return e?this.data.conditionals&&this.data.conditionals.hasOwnProperty(e)?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;i>s;++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]:!1},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="sourceId"]';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: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"]'}return i?{type:i,id:s?0|e.find(s).val():!1}:!1},getFormContext:function(e){if(e.data("elementEditor"))return!1;var t=e.find('input[type="hidden"][name="action"]').val();switch(t){case this.GLOBAL_SET_CONTENT_ACTION:case this.ENTRY_ACTION:case this.TAG_ACTION:case this.CATEGORY_ACTION:case this.USERS_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:return this.LAYOUT_DESIGNER_CONTEXT;case this.FIELDS_ACTION:return this.FIELD_DESIGNER_CONTEXT}return!1}}):!1}(window)},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'},modal:function(){return'