This commit is contained in:
2020-03-27 10:13:51 +07:00
commit da1024a5b3
16614 changed files with 3274282 additions and 0 deletions

View File

@@ -0,0 +1,302 @@
yii.gii = (function ($) {
var $clipboardContainer = $("#clipboard-container"),
valueToCopy = '',
ajaxRequest = null,
onKeydown = function(e) {
var $target;
$target = $(e.target);
if ($target.is("input:visible, textarea:visible")) {
return;
}
if (typeof window.getSelection === "function" && window.getSelection().toString()) {
return;
}
if (document.selection != null && document.selection.createRange().text) {
return;
}
$clipboardContainer.empty().show();
return $("<textarea id='clipboard'></textarea>").val(valueToCopy).appendTo($clipboardContainer).focus().select();
},
onKeyup = function(e) {
if ($(e.target).is("#clipboard")) {
$("#clipboard-container").empty().hide();
}
return true;
};
var initHintBlocks = function () {
$('.hint-block').each(function () {
var $hint = $(this);
$hint.parent().find('label').addClass('help').popover({
html: true,
trigger: 'hover',
placement: 'right',
content: $hint.html()
});
});
};
var initStickyInputs = function () {
$('.sticky:not(.error)').find('input[type="text"],select,textarea').each(function () {
var value;
if (this.tagName === 'SELECT') {
value = this.options[this.selectedIndex].text;
} else if (this.tagName === 'TEXTAREA') {
value = $(this).html();
} else {
value = $(this).val();
}
if (value === '') {
value = '[empty]';
}
$(this).before('<div class="sticky-value">' + value + '</div>').hide();
});
$('.sticky-value').on('click', function () {
$(this).hide();
$(this).next().show().get(0).focus();
});
};
var fillModal = function($link, data) {
var $modal = $('#preview-modal'),
$modalBody = $modal.find('.modal-body');
if (!$link.hasClass('modal-refresh')) {
var filesSelector = 'a.' + $modal.data('action') + ':visible';
var $files = $(filesSelector);
var index = $files.filter('[href="' + $link.attr('href') + '"]').index(filesSelector);
var $prev = $files.eq(index - 1);
var $next = $files.eq((index + 1 == $files.length ? 0 : index + 1));
$modal.data('current', $files.eq(index));
$modal.find('.modal-previous').attr('href', $prev.attr('href')).data('title', $prev.data('title'));
$modal.find('.modal-next').attr('href', $next.attr('href')).data('title', $next.data('title'));
}
$modalBody.html(data);
valueToCopy = $("<div/>").html(data.replace(/(<(br[^>]*)>)/ig, '\n').replace(/&nbsp;/ig, ' ')).text().trim() + '\n';
$modal.find('.content').css('max-height', ($(window).height() - 200) + 'px');
};
var initPreviewDiffLinks = function () {
$('.preview-code, .diff-code, .modal-refresh, .modal-previous, .modal-next').on('click', function () {
if (ajaxRequest !== null) {
if ($.isFunction(ajaxRequest.abort)) {
ajaxRequest.abort();
}
}
var that = this;
var $modal = $('#preview-modal');
var $link = $(this);
$modal.find('.modal-refresh').attr('href', $link.attr('href'));
if ($link.hasClass('preview-code') || $link.hasClass('diff-code')) {
$modal.data('action', ($link.hasClass('preview-code') ? 'preview-code' : 'diff-code'))
}
$modal.find('.modal-title').text($link.data('title'));
$modal.find('.modal-body').html('Loading ...');
$modal.modal('show');
var checkbox = $('a.' + $modal.data('action') + '[href="' + $link.attr('href') + '"]').closest('tr').find('input').get(0);
var checked = false;
if (checkbox) {
checked = checkbox.checked;
$modal.find('.modal-checkbox').removeClass('disabled');
} else {
$modal.find('.modal-checkbox').addClass('disabled');
}
$modal.find('.modal-checkbox span').toggleClass('glyphicon-check', checked).toggleClass('glyphicon-unchecked', !checked);
ajaxRequest = $.ajax({
type: 'POST',
cache: false,
url: $link.prop('href'),
data: $('.default-view form').serializeArray(),
success: function (data) {
fillModal($(that), data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$modal.find('.modal-body').html('<div class="error">' + XMLHttpRequest.responseText + '</div>');
}
});
return false;
});
$('#preview-modal').on('keydown', function (e) {
if (e.keyCode === 37) {
$('.modal-previous').trigger('click');
} else if (e.keyCode === 39) {
$('.modal-next').trigger('click');
} else if (e.keyCode === 82) {
$('.modal-refresh').trigger('click');
} else if (e.keyCode === 32) {
$('.modal-checkbox').trigger('click');
}
});
$('.modal-checkbox').on('click', checkFileToggle);
};
var checkFileToggle = function () {
var $modal = $('#preview-modal');
var $checkbox = $modal.data('current').closest('tr').find('input');
var checked = !$checkbox.prop('checked');
$checkbox.trigger('click');
$modal.find('.modal-checkbox span').toggleClass('glyphicon-check', checked).toggleClass('glyphicon-unchecked', !checked);
return false;
};
var checkAllToggle = function () {
$('#check-all').prop('checked', !$('.default-view-files table .check input:enabled:not(:checked)').length);
};
var initConfirmationCheckboxes = function () {
var $checkAll = $('#check-all');
$checkAll.click(function () {
$('.default-view-files table .check input:enabled').prop('checked', this.checked);
});
$('.default-view-files table .check input').click(function () {
checkAllToggle();
});
checkAllToggle();
};
var initToggleActions = function () {
$('#action-toggle').find(':input').change(function () {
$(this).parent('label').toggleClass('active', this.checked);
var $rows = $('.' + this.value, '.default-view-files table').toggleClass('action-hidden', !this.checked);
if (this.checked) {
$rows.not('.filter-hidden').show();
} else {
$rows.hide();
}
$rows.find('.check input').attr('disabled', !this.checked);
checkAllToggle();
});
};
var initFilterRows = function () {
$('#filter-input').on('input', function () {
var that = this,
$rows = $('#files-body').find('tr');
$rows.hide().toggleClass('filter-hidden', true).filter(function () {
return $(this).text().toUpperCase().indexOf(that.value.toUpperCase()) > -1;
}).toggleClass('filter-hidden', false).not('.action-hidden').show();
$rows.find('input').each(function(){
$(this).prop('disabled', $(this).is(':hidden'));
});
});
};
$(document).on("keydown", function(e) {
if (valueToCopy && (e.ctrlKey || e.metaKey) && (e.which === 67)) {
return onKeydown(e);
}
}).on("keyup", onKeyup);
return {
autocomplete: function (counter, data) {
var datum = new Bloodhound({
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.word);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: data
});
datum.initialize();
jQuery('.typeahead-' + counter).typeahead(null, {displayKey: 'word', source: datum.ttAdapter()});
},
init: function () {
initHintBlocks();
initStickyInputs();
initPreviewDiffLinks();
initConfirmationCheckboxes();
initToggleActions();
initFilterRows();
// model generator: hide class name inputs when table name input contains *
$('#model-generator #generator-tablename').change(function () {
var show = ($(this).val().indexOf('*') === -1);
$('.field-generator-modelclass').toggle(show);
if ($('#generator-generatequery').is(':checked')) {
$('.field-generator-queryclass').toggle(show);
}
}).change();
// model generator: translate table name to model class
$('#model-generator #generator-tablename').on('blur', function () {
var tableName = $(this).val();
var tablePrefix = $(this).attr('table_prefix') || '';
if (tablePrefix.length) {
// if starts with prefix
if (tableName.slice(0, tablePrefix.length) === tablePrefix) {
// remove prefix
tableName = tableName.slice(tablePrefix.length);
}
}
if ($('#generator-modelclass').val() === '' && tableName && tableName.indexOf('*') === -1) {
var modelClass = '';
$.each(tableName.split(/\.|\_/), function() {
if(this.length>0)
modelClass+=this.substring(0,1).toUpperCase()+this.substring(1);
});
$('#generator-modelclass').val(modelClass).blur();
}
});
// model generator: translate model class to query class
$('#model-generator #generator-modelclass').on('blur', function () {
var modelClass = $(this).val();
if (modelClass !== '') {
var queryClass = $('#generator-queryclass').val();
if (queryClass === '') {
queryClass = modelClass + 'Query';
$('#generator-queryclass').val(queryClass);
}
}
});
// model generator: synchronize query namespace with model namespace
$('#model-generator #generator-ns').on('blur', function () {
var stickyValue = $('#model-generator .field-generator-queryns .sticky-value');
var input = $('#model-generator #generator-queryns');
if (stickyValue.is(':visible') || !input.is(':visible')) {
var ns = $(this).val();
stickyValue.html(ns);
input.val(ns);
}
});
// model generator: toggle query fields
$('form #generator-generatequery').change(function () {
$('form .field-generator-queryns').toggle($(this).is(':checked'));
$('form .field-generator-queryclass').toggle($(this).is(':checked'));
$('form .field-generator-querybaseclass').toggle($(this).is(':checked'));
$('#generator-queryclass').prop('disabled', $(this).is(':not(:checked)'));
}).change();
// hide message category when I18N is disabled
$('form #generator-enablei18n').change(function () {
$('form .field-generator-messagecategory').toggle($(this).is(':checked'));
}).change();
// hide Generate button if any input is changed
$('#form-fields').find('input,select,textarea').change(function () {
$('.default-view-results,.default-view-files').hide();
$('.default-view button[name="generate"]').hide();
});
$('.module-form #generator-moduleclass').change(function () {
var value = $(this).val().match(/(\w+)\\\w+$/);
var $idInput = $('#generator-moduleid');
if (value && value[1] && $idInput.val() === '') {
$idInput.val(value[1]);
}
});
}
};
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -0,0 +1,294 @@
html,
body {
height: 100%;
}
.page-container {
min-height: 100%;
}
.content-container {
padding-top: 70px;
}
.footer-fix {
height: 100px;
}
.footer {
margin-top: -60px;
border-top: 1px solid #ddd;
height: 59px;
line-height: 59px;
box-sizing: border-box;
}
.footer p {
margin: 0;
}
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
.navbar-brand {
padding: 0;
margin: 0;
}
.default-index .generator {
min-height: 200px;
margin-bottom: 20px;
}
.list-group .glyphicon {
float: right;
}
.popover {
max-width: 400px;
width: 400px;
}
.hint-block {
display: none;
}
.error-summary {
color: #a94442;
background: #fdf7f7;
border-left: 3px solid #eed3d7;
padding: 10px 20px;
margin: 0 0 15px 0;
}
.default-view .sticky-value {
padding: 6px 12px;
background: lightyellow;
white-space: pre;
word-wrap: break-word;
}
.default-view .form-group label.help {
border-bottom: 1px dashed #888;
cursor: help;
}
.default-view .modal-dialog {
width: 800px;
}
.default-view .modal-dialog .error {
color: #d9534f;
}
.default-view .modal-dialog .content {
background: #fafafa;
border-left: #eee 5px solid;
padding: 5px 10px;
overflow: auto;
}
.default-view .modal-dialog code {
background: transparent;
}
.default-view .modal-dialog .modal-copy-hint {
margin-right: 10px;
}
.default-view .modal-dialog .modal-copy-hint kbd {
margin: 0 2px;
}
.default-view-files table .action {
width: 100px;
}
.default-view-files table .check {
width: 25px;
text-align: center;
}
.default-view-results pre {
overflow: auto;
background-color: #333;
max-height: 300px;
color: white;
padding: 10px;
border-radius: 0;
white-space: nowrap;
}
.default-view-results pre .error {
background: #FFE0E1;
color: black;
padding: 1px;
}
.default-view-results .alert pre {
background: white;
}
.default-diff pre {
padding: 0;
margin: 0;
background: transparent;
border: none;
}
.default-diff pre del {
background: pink;
}
.default-diff pre ins {
background: lightgreen;
text-decoration: none;
}
.Differences {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
empty-cells: show;
}
.Differences thead {
display: none;
}
.Differences tbody th {
text-align: right;
background: #FAFAFA;
padding: 1px 2px;
border-right: 1px solid #eee;
vertical-align: top;
font-size: 13px;
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
font-weight: normal;
color: #999;
width: 5px;
}
.Differences td {
padding: 1px 2px;
font-size: 13px;
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
}
.DifferencesSideBySide .ChangeInsert td.Left {
background: #dfd;
}
.DifferencesSideBySide .ChangeInsert td.Right {
background: #cfc;
}
.DifferencesSideBySide .ChangeDelete td.Left {
background: #f88;
}
.DifferencesSideBySide .ChangeDelete td.Right {
background: #faa;
}
.DifferencesSideBySide .ChangeReplace .Left {
background: #fe9;
}
.DifferencesSideBySide .ChangeReplace .Right {
background: #fd8;
}
.Differences ins, .Differences del {
text-decoration: none;
}
.DifferencesSideBySide .ChangeReplace ins, .DifferencesSideBySide .ChangeReplace del {
background: #fc0;
}
.Differences .Skipped {
background: #f7f7f7;
}
.DifferencesInline .ChangeReplace .Left,
.DifferencesInline .ChangeDelete .Left {
background: #fdd;
}
.DifferencesInline .ChangeReplace .Right,
.DifferencesInline .ChangeInsert .Right {
background: #dfd;
}
.DifferencesInline .ChangeReplace ins {
background: #9e9;
}
.DifferencesInline .ChangeReplace del {
background: #e99;
}
.DifferencesInline th[data-line-number]:before {
content: attr(data-line-number);
}
/* additional styles for typeahead.js, adapted from http://twitter.github.io/typeahead.js/examples/ */
.twitter-typeahead {
display: block !important;
}
.tt-hint {
color: #999
}
.tt-dropdown-menu, .tt-menu {
width: 422px;
margin-top: 2px;
padding: 8px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
}
.tt-suggestion {
padding: 3px 20px;
font-size: 18px;
line-height: 24px;
}
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #0097cf;
}
.tt-suggestion p {
margin: 0;
}
#clipboard-container {
position: fixed;
left: 0;
top: 0;
width: 0;
height: 0;
z-index: 100;
/*display: none;*/
opacity: 0;
}
#clipboard {
width: 1px;
height: 1px;
padding: 0;
}