Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" />
    <title>Espresso </title>
</head>
<body>
    <div class="container">
        <div id="app">
            <form action="#">
                <add-condition v-for="n in count" :key="n.id"></add-condition>
                <button class="button is-small is-rounded is-info is-pulled-right" v-on:click.stop="addCondition">Add Condition</button>
                <button class="button is-link" v-on:click.stop="addCondition">Submit</button>
            </form>
        </div>
    </div><!-- /.container -->

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
</body>
</html>
              
            
!

CSS

              
                body {
  background: #ffffff;
  text-align: center;
}

.container {
  max-width: 800px;
  margin: 40px auto 100px;
}

.add-property {
  padding: 10px;
  border: 1px dashed gray;
  border-radius: 5px;
  margin: 0 0px 10px;
  margin-bottom: 20px;
  overflow: hidden;
}

.add-property .delete {
  position: absolute;
  right: 40px;
}

.add-condition {
  overflow: hidden;
  padding: 20px;
  border: 1px dashed gray;
  margin-bottom: 20px;
}

.columns {
  padding: 15px;
  border: 1px dashed skyblue;
  border-radius: 3px;
  margin-bottom: 20px;
}


              
            
!

JS

              
                Vue.component('add-rule', {
	data: function(){
		return {
			criteriaType : '',
			fieldName : '',
			rule: {
				query: '',
				operator: '',
				value: '',
			},
			operator : '',
			operators: [],
			criteria: [
				{
					name: 'Select',
					value: ''
				},
				{
					name: 'Timezone',
					value: 'timezone',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'Language',
					value: 'language',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'Platform',
					value: 'platform',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'Browser',
					value: 'browser',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'OS',
					value: 'os',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'Country',
					value: 'country',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'State',
					value: 'state',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'City',
					value: 'city',
					type: 'select',
					operator: ['is','is not'],
				},
				{
					name: 'Useragent',
					value: 'useragent',
					type: 'text',
					operator: ['contains','doesn\'t contain'],
				},
				{
					name: 'Referrer',
					value: 'HTTP_REFERRER',
					type: 'text',
					operator: ['contains','doesn\'t contain'],
				},
				{
					name: 'Subscription Date',
					value: 'subscribed_on',
					type: 'date',
					operator: ['on', 'before', 'after', 'between'],
				},
				{
					name: 'Take',
					value: 'take',
					type: 'text',
					operator: ['=='],
				},
				{
					name: 'Geolocation',
					lat: 26,
					lng: 79,
					radius: 100, //km
					type: 'text',
					operator: ['=='],
				}
			],

			browser: ['Chrome', 'Firefox', 'Safari'],
			os: ['Mac OS', 'Windows', 'Linux', 'Android'],
			timezone: ['Asia', 'Europe', 'Austrialia', 'America'],
			language: ['English', 'Hindi', 'Spanish', 'German'],
			platform: ['Desktop', 'Tablet', 'Mobile'],
			country: ['India', 'Germany', 'USA'],
			state: ['UP', 'Texas', 'KA'],
			city: ['Orai', 'London', 'New York'],
			selectTwo: [],
			textValue: '',
		}
	},

	template: `
		<div class="columns add-property">
			<a class="delete is-small is-pulled-right" v-on:click="$emit(\'remove\', $event)"></a>
			<div class="column">
				<div class="select is-rounded">
				  <select v-on:change="onCriteriaChange">
				    <option v-for="criteria in criteria" v-bind:value="criteria.value + '-' + criteria.type + '-' + criteria.operator">{{ criteria.name }}</option>
				  </select>
				</div>
			</div>

			<div class="column">
				<template v-if="criteriaType == 'select' || criteriaType == 'text'">
					<div class="select is-rounded">
					  <select v-bind:name="operator" v-on:change="onOperatorChange">
					    <option v-for="operator in operators" v-bind:value="operator">{{ operator }}</option>
					  </select>
					</div>
				</template>
			</div>

			<div class="column">
				<template v-if="criteriaType == 'select'">
					<div class="select is-rounded">
					  <select v-bind:name="fieldName" v-on:change="onSelectValue">
					    <option v-for="option in selectTwo" v-bind:value="option">{{ option }}</option>
					  </select>
					</div>
				</template>

				<template v-else-if="criteriaType == 'text'">
					<input class="input is-rounded" type="text" v-bind:name="fieldName" v-on:blur="onTextValue">
				</template>
			</div>
		</div>
	`,

	methods: {
		onCriteriaChange(e){
			if(e.target.value != ''){
				var type = e.target.value.split('-')[1];
				console.log(e.target.value.split('-'));
				if(type == 'select'){
					this.rule.operator = '';
					this.rule.value = '';
					this.selectTwo = this[e.target.value.split('-')[0]];
					this.criteriaType = 'select';
					this.fieldName = e.target.value.split('-')[0].toLowerCase().trim();
					this.operators = e.target.value.split('-')[2].split(',');
					this.rule.query = this.fieldName;
					this.rule.operator = this.operators[0];
					this.rule.value = this.selectTwo[0];
				}else if(type == 'text'){
					this.criteriaType = 'text';
					this.rule.operator = '';
					this.rule.value = '';
					this.fieldName = e.target.value.split('-')[0].toLowerCase().trim();
					this.operators = e.target.value.split('-')[2].split(',');
					this.rule.query = this.fieldName;
					this.rule.operator = this.operators[0];
					this.rule.value = this.selectTwo[0];
				}
			}
		},

		onOperatorChange(e){
			this.rule.operator = e.target.value;
		},

		onSelectValue(e){
			this.rule.value = e.target.value;
		},

		onTextValue(e){
			this.rule.value = e.target.value;
			console.log(e.target.value);
			console.log(e);
		},

		removeRule(index){
			console.log(index);
			console.log(this);
		}
	},

	computed: {
    	arrayLength: function () {
      		if(this.selectTwo.length > 0){
      			return false;
      		}else{
      			return true;
      		}
    	},
  	}
});

Vue.component('add-property', {
	template: `
		<div class="add-condition">
			<add-rule v-model="row.name" v-for="(row, index) in rows" :key="index + 1" v-on:remove="removeThisRow(index)"></add-rule>
			<button class="button is-small is-rounded is-info is-pulled-right" v-on:click.stop="addRule">Add Rule</button>
		</div>
	`,

	data: function () {
	    return {
	    	count: 1,
	    	rows: []
	    }
	},

	methods: {
		addRule(event){
			this.count += 1;
			this.rows.push({
				name: '',
			});
			event.preventDefault();
		},
		removeThisRow(index){
			console.log(index);
			console.log(this.rows);
			this.rows.splice(index, 1);
		}
	}
});

Vue.component('add-condition', {
	template: `
		<div>
			<add-property v-for="(n, index) in count" :key="index + 1"></add-property>
		</div>
	`,

	data: function () {
	    return {
	    	count: 1
	    }
	},

	methods: {
		addRule(){
			this.count += 1;
		}
	}
});

new Vue({
	el: '#app',

	data: {
		count: 1,
	},

	methods: {
		addCondition(event){
			this.count += 1;
			event.preventDefault();
		}
	},
});
              
            
!
999px

Console