{ "version": 3, "file": "scripts-bundle.js", "sources": [ "src/simply-app/js/general/global-variables.js", "src/simply-app/js/general/routes-and-redirects.js", "src/simply-app/js/general/deep-links.js", "src/simply-app/js/general/utility-functions.js", "src/simply-app/js/selectors-creator/selectors-creator.js" ], "names": [], "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA;;ACAA;;ACAA;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "sourcesContent": [ "/*====================================================================\n= Global variables, environment variables etc. =\n====================================================================*/\n\n//var API_HOST = 'https://api.example.com';\n//API_HOST = 'http://localhost:4000'; //comment before merge!!!!!!!!!!\n//PROD_ROOT_DOMAIN defined on top of index.html\n\n\n/*===== End of Global variables, environment variables etc. ======*/\n\n\n/////////////////////////////////", "", "", "// Utility functions specific to the app not to framework", "function newSelectorsCreatorSlotData(id, relationship) {\n return {\n id: id,\n relationship: relationship || '',\n tag: \"any\",\n filters: [\n newSelectorsCreatorFilter(\"0\", 'text'),\n ]\n };\n}\n\nfunction newSelectorsCreatorFilter(id, type) {\n return {\n id: id,\n type: type || 'attribute',\n attribute: {\n name: \"data-testid\",\n value: \"example\",\n operator: \"is\",\n },\n text: {\n value: \"Example\",\n }\n };\n}\n\n//init with just one slot\nvar selectorsCreatorSlots = [\n newSelectorsCreatorSlotData('0'),\n];\nbindSelectorsCreatorSlot(selectorsCreatorSlots[0]);\n\n\nfunction bindSelectorsCreatorSlot(slotData) {\n State.set('slot-'+slotData.id+'__tag', slotData.tag);\n State.set('slot-'+slotData.id+'__relationship', slotData.relationship);\n //TODO filters for each\n $.each(slotData.filters, function(index, value) {\n bindSelectorsCreatorFilter(slotData.id, value);\n });\n\n State.onChange('slot-'+slotData.id+'__tag', function(value) {\n slotData.tag = value;\n getSelectorFromAllSlots();\n });\n\n State.onChange('slot-'+slotData.id+'__relationship', function(value) {\n slotData.relationship = value;\n getSelectorFromAllSlots();\n });\n}\n\nfunction bindSelectorsCreatorFilter(slotId, filterData) {\n State.set('slot-'+slotId+'__filter-'+filterData.id+'__type', filterData.type);\n State.set('slot-'+slotId+'__filter-'+filterData.id+'__text__value', filterData.text.value);\n State.set('slot-'+slotId+'__filter-'+filterData.id+'__attribute__name', filterData.attribute.name);\n State.set('slot-'+slotId+'__filter-'+filterData.id+'__attribute__value', filterData.attribute.value);\n State.set('slot-'+slotId+'__filter-'+filterData.id+'__attribute__operator', filterData.attribute.operator);\n \n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__type', function(value) {\n var thisFilter = $('[js-selectors-creator-slot=\"'+slotId+'\"').find('[js-selectors-creator-filter-row=\"'+filterData.id+'\"]');\n thisFilter.find('[js-selectors-creator-field-for-attr]').isShownWhen(value === 'attribute');\n thisFilter.find('[js-selectors-creator-field-for-text]').isShownWhen(value === 'text');\n });\n\n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__type', function(value) {\n filterData.type = value;\n getSelectorFromAllSlots();\n delay(250, function() {\n if ($(window).width() > 1023) { //on mobile devices autofocus doesn't work well\n if (value === 'attribute') {\n $('[simply-text-input=\"slot-'+slotId+'__filter-'+filterData.id+'__attribute__name\"]').focus().select();\n } else if (value === 'text') {\n $('[simply-text-input=\"slot-'+slotId+'__filter-'+filterData.id+'__text__value\"]').focus().select();\n }\n }\n });\n });\n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__text__value', function(value) {\n filterData.text.value = value;\n getSelectorFromAllSlots();\n });\n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__attribute__name', function(value) {\n filterData.attribute.name = value;\n getSelectorFromAllSlots();\n });\n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__attribute__value', function(value) {\n filterData.attribute.value = value;\n getSelectorFromAllSlots();\n });\n State.onChange('slot-'+slotId+'__filter-'+filterData.id+'__attribute__operator', function(value) {\n filterData.attribute.operator = value;\n getSelectorFromAllSlots();\n delay(250, function() {\n if ($(window).width() > 1023) { //on mobile devices autofocus doesn't work well\n $('[simply-text-input=\"slot-'+slotId+'__filter-'+filterData.id+'__attribute__value\"]').focus().select();\n }\n });\n });\n\n State.retriggerOnParamChange('slot-'+slotId+'__filter-'+filterData.id+'__type');\n //State.retriggerOnParamChange('slot-'+slotId+'__filter-'+filterData.id+'__attribute__operator');\n}\n\nfunction addAnotherSelectorsCreatorSlot() {\n //add new slot to array with new random id\n var newSlotData = newSelectorsCreatorSlotData(newId(6), 'ancestor');\n selectorsCreatorSlots.push(newSlotData);\n //append new template in HTML by duplicating the last\n //update attributes in the HTML to match the new id\n var clone = $('[js-selectors-creator-slot-template]').clone();\n //get the template and clean it up\n clone.removeAttr('js-selectors-creator-slot-template');\n var templateHtml = clone.html();\n var newHtml = templateHtml.replaceAll('simply-binded', '').replaceAll('simply-binded=\"\"', '');\n newHtml = newHtml.replaceAll('tooltipstered', '').replaceAll('tooltipstered=\"\"', '');\n //update the template with new IDs of slots\n newHtml = newHtml.replaceAll('slot-1', 'slot-'+newSlotData.id);\n clone.html(newHtml);\n clone.attr('js-selectors-creator-slot', newSlotData.id);\n console.log(newSlotData);\n clone.appendTo('[js-selectors-slots-list]');\n clone.removeClass('is-hidden');\n //bind this new slot to state //reattach bindings & tooltips\n initSimplyTooltipster(clone);\n bindSimplySelectDropdownsToStateBasedOnItsAttributes();\n bindSimplyTextInputFieldsToStateBasedOnItsAttributes();\n bindSelectorsCreatorSlot(newSlotData);\n getSelectorFromAllSlots();\n}\n\nfunction removeSelectorsCreatorSlot(slotId) {\n //find by id and remove from array\n selectorsCreatorSlots = selectorsCreatorSlots.filter(item => item.id !== slotId);\n console.log(selectorsCreatorSlots);\n //find by id and remove from DOM\n $('[js-selectors-creator-slot=\"'+slotId+'\"]').remove();\n getSelectorFromAllSlots();\n}\n\nfunction addAnotherSelectorsCreatorFilter(slotId) {\n //add new filter to array with random id\n var newFilter = newSelectorsCreatorFilter(newId(6));\n\n selectorsCreatorSlots.find(x => x.id === slotId).filters.push(newFilter);\n console.log(selectorsCreatorSlots);\n \n //append new template in HTML by duplicating from template\n var clone = $('[js-selectors-creator-slot-template]').find('[js-selectors-creator-filter-row]').clone();\n var thisSlot = $('[js-selectors-creator-slot=\"'+slotId+'\"]');\n //TODO clean up template and add its IDs\n var templateHtml = clone.html();\n var newHtml = templateHtml.replaceAll('simply-binded', '').replaceAll('simply-binded=\"\"', '');\n newHtml = newHtml.replaceAll('tooltipstered', '').replaceAll('tooltipstered=\"\"', '');\n //update the template with new IDs of slots\n newHtml = newHtml.replaceAll('slot-1', 'slot-'+slotId);\n //update the template with new IDs of filters\n newHtml = newHtml.replaceAll('filter-0', 'filter-'+newFilter.id);\n clone.html(newHtml);\n clone.attr('js-selectors-creator-filter-row', newFilter.id);\n thisSlot.find('[js-selectors-creator-filter-rows]').append(clone);\n //TODO bind the new filter to state\n initSimplyTooltipster(clone);\n bindSimplySelectDropdownsToStateBasedOnItsAttributes();\n bindSimplyTextInputFieldsToStateBasedOnItsAttributes();\n bindSelectorsCreatorFilter(slotId, newFilter);\n getSelectorFromAllSlots();\n}\n\nfunction removeSelectorsCreatorFilter(slotId, filterId) {\n //find by id and remove from array\n slot = selectorsCreatorSlots.find(x => x.id === slotId);\n slot.filters = slot.filters.filter(item => item.id !== filterId);\n console.log(selectorsCreatorSlots);\n //find by id and remove from DOM\n $('[js-selectors-creator-slot=\"'+slotId+'\"]').find('[js-selectors-creator-filter-row=\"'+filterId+'\"]').remove();\n getSelectorFromAllSlots();\n}\n\n$.On('click', '[js-add-another-filter-in-slot]', function() {\n var slotId = $(this).closest('[js-selectors-creator-slot]').attr('js-selectors-creator-slot');\n addAnotherSelectorsCreatorFilter(slotId);\n});\n\n$.On('click', '[js-selectors-creator-add-more-slots]', function() {\n addAnotherSelectorsCreatorSlot();\n});\n\n$.On('click', '[js-selectors-creator-remove-slot]', function() {\n var thisSlot = $(this).closest('[js-selectors-creator-slot]');\n var thisSlotId = thisSlot.attr('js-selectors-creator-slot');\n removeSelectorsCreatorSlot(thisSlotId);\n});\n\n$.On('click', '[js-selectors-creator-remove-filter]', function() {\n var thisFilter = $(this).closest('[js-selectors-creator-filter-row]');\n var thisFilterId = thisFilter.attr('js-selectors-creator-filter-row');\n var thisSlot = $(this).closest('[js-selectors-creator-slot]');\n var thisSlotId = thisSlot.attr('js-selectors-creator-slot');\n removeSelectorsCreatorFilter(thisSlotId, thisFilterId);\n});\n\n$.On('click', '[js-copy-selector-result-to-clipboard]', function() {\n var textToCopy = $('[js-selector-result-text]').text();\n var thisButton = $(this);\n navigator.clipboard.writeText(textToCopy).then(\n function() {\n /* clipboard successfully set */\n //TODO copying success message\n //window.alert('Copied '+textToCopy); \n thisButton.addClass('is-with-success');\n thisButton.find('[js-bem-button-hide-when-success-flashing]').isHidden();\n thisButton.find('[js-bem-button-success-inner]').isShown();\n delay(1500, function() {\n thisButton.removeClass('is-with-success');\n thisButton.find('[js-bem-button-hide-when-success-flashing]').isShown();\n thisButton.find('[js-bem-button-success-inner]').isHidden();\n });\n }, \n function() {\n /* clipboard write failed */\n window.alert('Opps! Your browser does not support copying to clipboard via \"Clipboard API\"');\n }\n );\n});\n\nfunction getSelectorFromAllSlots() {\n //WIP\n\n var result = [];\n\n $.each(selectorsCreatorSlots, function(index, value) {\n if (index === 0) {\n result.push(\"//\");\n } else {\n result.push('/');\n }\n\n if (isNotEmpty(value.relationship)) {\n result.push(value.relationship+\"::\");\n }\n\n if (value.tag === \"any\") {\n result.push('*');\n } else {\n result.push(value.tag);\n }\n\n if (value.filters.length > 0) {\n\n\n $.each(value.filters, function(filterIndex, filterValue) {\n \n result.push(\"[\");\n \n if (filterValue.type === 'text') {\n result.push('contains(text(), \"');\n result.push(filterValue.text.value);\n result.push('\")');\n }\n\n if (filterValue.type === 'attribute') {\n if (filterValue.attribute.operator === 'is') {\n result.push('@');\n result.push(filterValue.attribute.name);\n result.push('=\"');\n result.push(filterValue.attribute.value);\n result.push('\"');\n }\n if (filterValue.attribute.operator === 'contains') {\n result.push('contains(@');\n result.push(filterValue.attribute.name);\n result.push(' ,\"');\n result.push(filterValue.attribute.value);\n result.push('\")');\n }\n } \n\n result.push(\"]\");\n\n });\n\n }\n\n });\n\n $('[js-selector-result-text]').text(result.join(''));\n\n return result.join('');\n}\n" ] }