Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
Added Formatter option
Browse files Browse the repository at this point in the history
  • Loading branch information
higoka committed Jun 11, 2017
1 parent e1b3cf8 commit 89e032a
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 5 deletions.
2 changes: 1 addition & 1 deletion create.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

$creator->pushFormatter(new ArcturusFormatter());

$creator->run('arcturus', $_POST);
$creator->run($_POST['formatter'], $_POST);
1 change: 1 addition & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import url('https://fonts.googleapis.com/css?family=Roboto:400,500');
@import url('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
@import url('select.min.css');

html, body {
font-family: 'Roboto', sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion css/main.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions css/select.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.nice-select {
width: 100%;-webkit-tap-highlight-color: transparent;
background-color: #FAFAFA;
border-radius: 3px;
border: solid 1px #EEEEEE;
box-sizing: border-box;
clear: both;
cursor: pointer;
display: block;
float: left;
font-size: 12px;
font-weight: 400;
letter-spacing: 0.04em;
font-family: 'Roboto', sans-serif;
outline: none;
padding: 10px;
position: relative;
text-align: left !important;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
}

.nice-select:after {
border-bottom: 3px solid #EEEEEE;
border-right: 3px solid #EEEEEE;
content: '';
display: block;
height: 5px;
margin-top: -4px;
pointer-events: none;
position: absolute;
right: 12px;
top: 50%;
-webkit-transform-origin: 66% 66%;
-ms-transform-origin: 66% 66%;
transform-origin: 66% 66%;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: all 0.15s ease-in-out;
transition: all 0.15s ease-in-out;
width: 5px; }
.nice-select.open:after {
-webkit-transform: rotate(-135deg);
-ms-transform: rotate(-135deg);
transform: rotate(-135deg); }
.nice-select.open .list {
opacity: 1;
pointer-events: auto;
-webkit-transform: scale(1) translateY(0);
-ms-transform: scale(1) translateY(0);
transform: scale(1) translateY(0); }

.nice-select .list {
background-color: #FAFAFA;
border: 1px solid #EEEEEE;width: calc(100% + 2px);
border-radius: 3px;
box-sizing: border-box;
margin-top: 5px;
opacity: 0;
overflow: hidden;
padding: 0;
pointer-events: none;
position: absolute;
top: 100%;
left: -1px;
-webkit-transform-origin: 50% 0;
-ms-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-transform: scale(0.75) translateY(-21px);
-ms-transform: scale(0.75) translateY(-21px);
transform: scale(0.75) translateY(-21px);
-webkit-transition: all 0.2s cubic-bezier(0.5, 0, 0, 1.25), opacity 0.15s ease-out;
transition: all 0.2s cubic-bezier(0.5, 0, 0, 1.25), opacity 0.15s ease-out;
z-index: 9; }
.nice-select .list:hover .option:not(:hover) {
background-color: transparent !important; }
.nice-select .option {
cursor: pointer;
font-weight: 400;
list-style: none;
outline: none;
padding: 10px;
text-align: left;
-webkit-transition: all 0.2s;
transition: all 0.2s; }
.nice-select .option:hover, .nice-select .option.focus, .nice-select .option.selected.focus {
background-color: #EEEEEE; }
.nice-select .option.selected {
font-weight: bold; }
.nice-select .option.disabled {
background-color: transparent;
color: #999;
cursor: default; }

.no-csspointerevents .nice-select .list {
display: none; }

.no-csspointerevents .nice-select.open .list {
display: block; }
1 change: 1 addition & 0 deletions css/select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ <h2>SQL Creator</h2>
</div>
<form action="create.php" method="post">
<div class="grid_12">
<h3>General</h3>
<h3>Formatter</h3>
<select name="formatter">
<option value="arcturus">Arcturus</option>
</select>
</div>


<div class="grid_12">
<h3 style="margin-top: 50px;">General</h3>
</div>
<div class="grid_4">
<p>SWF</p>
Expand Down Expand Up @@ -126,6 +134,7 @@ <h3>furnidata.xml</h3>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="js/select.min.js"></script>
<script src="js/main.min.js"></script>
</body>
</html>
6 changes: 5 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
$(document).ready(function () {
$('select').niceSelect();
});

function create() {
var input = $('form').find('input');
var input = $('form').find('input, select');

$.post('create.php', input.serialize(), function (data) {
var data = $.parseJSON(data);
Expand Down
2 changes: 1 addition & 1 deletion js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

190 changes: 190 additions & 0 deletions js/select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/* jQuery Nice Select - v1.1.0
https://github.com/hernansartorio/jquery-nice-select
Made by Hernán Sartorio */

(function($) {

$.fn.niceSelect = function(method) {

// Methods
if (typeof method == 'string') {
if (method == 'update') {
this.each(function() {
var $select = $(this);
var $dropdown = $(this).next('.nice-select');
var open = $dropdown.hasClass('open');

if ($dropdown.length) {
$dropdown.remove();
create_nice_select($select);

if (open) {
$select.next().trigger('click');
}
}
});
} else if (method == 'destroy') {
this.each(function() {
var $select = $(this);
var $dropdown = $(this).next('.nice-select');

if ($dropdown.length) {
$dropdown.remove();
$select.css('display', '');
}
});
if ($('.nice-select').length == 0) {
$(document).off('.nice_select');
}
} else {
console.log('Method "' + method + '" does not exist.')
}
return this;
}

// Hide native select
this.hide();

// Create custom markup
this.each(function() {
var $select = $(this);

if (!$select.next().hasClass('nice-select')) {
create_nice_select($select);
}
});

function create_nice_select($select) {
$select.after($('<div></div>')
.addClass('nice-select')
.addClass($select.attr('class') || '')
.addClass($select.attr('disabled') ? 'disabled' : '')
.attr('tabindex', $select.attr('disabled') ? null : '0')
.html('<span class="current"></span><ul class="list"></ul>')
);

var $dropdown = $select.next();
var $options = $select.find('option');
var $selected = $select.find('option:selected');

$dropdown.find('.current').html($selected.data('display') || $selected.text());

$options.each(function(i) {
var $option = $(this);
var display = $option.data('display');

$dropdown.find('ul').append($('<li></li>')
.attr('data-value', $option.val())
.attr('data-display', (display || null))
.addClass('option' +
($option.is(':selected') ? ' selected' : '') +
($option.is(':disabled') ? ' disabled' : ''))
.html($option.text())
);
});
}

/* Event listeners */

// Unbind existing events in case that the plugin has been initialized before
$(document).off('.nice_select');

// Open/close
$(document).on('click.nice_select', '.nice-select', function(event) {
var $dropdown = $(this);

$('.nice-select').not($dropdown).removeClass('open');
$dropdown.toggleClass('open');

if ($dropdown.hasClass('open')) {
$dropdown.find('.option');
$dropdown.find('.focus').removeClass('focus');
$dropdown.find('.selected').addClass('focus');
} else {
$dropdown.focus();
}
});

// Close when clicking outside
$(document).on('click.nice_select', function(event) {
if ($(event.target).closest('.nice-select').length === 0) {
$('.nice-select').removeClass('open').find('.option');
}
});

// Option click
$(document).on('click.nice_select', '.nice-select .option:not(.disabled)', function(event) {
var $option = $(this);
var $dropdown = $option.closest('.nice-select');

$dropdown.find('.selected').removeClass('selected');
$option.addClass('selected');

var text = $option.data('display') || $option.text();
$dropdown.find('.current').text(text);

$dropdown.prev('select').val($option.data('value')).trigger('change');
});

// Keyboard events
$(document).on('keydown.nice_select', '.nice-select', function(event) {
var $dropdown = $(this);
var $focused_option = $($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));

// Space or Enter
if (event.keyCode == 32 || event.keyCode == 13) {
if ($dropdown.hasClass('open')) {
$focused_option.trigger('click');
} else {
$dropdown.trigger('click');
}
return false;
// Down
} else if (event.keyCode == 40) {
if (!$dropdown.hasClass('open')) {
$dropdown.trigger('click');
} else {
var $next = $focused_option.nextAll('.option:not(.disabled)').first();
if ($next.length > 0) {
$dropdown.find('.focus').removeClass('focus');
$next.addClass('focus');
}
}
return false;
// Up
} else if (event.keyCode == 38) {
if (!$dropdown.hasClass('open')) {
$dropdown.trigger('click');
} else {
var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
if ($prev.length > 0) {
$dropdown.find('.focus').removeClass('focus');
$prev.addClass('focus');
}
}
return false;
// Esc
} else if (event.keyCode == 27) {
if ($dropdown.hasClass('open')) {
$dropdown.trigger('click');
}
// Tab
} else if (event.keyCode == 9) {
if ($dropdown.hasClass('open')) {
return false;
}
}
});

// Detect CSS pointer-events support, for IE <= 10. From Modernizr.
var style = document.createElement('a').style;
style.cssText = 'pointer-events:auto';
if (style.pointerEvents !== 'auto') {
$('html').addClass('no-csspointerevents');
}

return this;

};

}(jQuery));
1 change: 1 addition & 0 deletions js/select.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89e032a

Please sign in to comment.