You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.1 KiB
100 lines
3.1 KiB
12 years ago
|
yii.gii = (function ($) {
|
||
12 years ago
|
var isActive = $('.default-view').length > 0;
|
||
|
|
||
|
var initHintBlocks = function () {
|
||
|
$('.hint-block').each(function () {
|
||
|
var $hint = $(this);
|
||
12 years ago
|
$hint.parent().find('label').addClass('help').popover({
|
||
12 years ago
|
html: true,
|
||
12 years ago
|
trigger: 'hover',
|
||
12 years ago
|
placement: 'right',
|
||
|
content: $hint.html()
|
||
12 years ago
|
});
|
||
12 years ago
|
});
|
||
|
};
|
||
12 years ago
|
|
||
12 years ago
|
var initStickyInputs = function () {
|
||
11 years ago
|
$('.sticky:not(.error)').find('input[type="text"],select,textarea').each(function () {
|
||
12 years ago
|
var value;
|
||
12 years ago
|
if (this.tagName === 'SELECT') {
|
||
12 years ago
|
value = this.options[this.selectedIndex].text;
|
||
12 years ago
|
} else if (this.tagName === 'TEXTAREA') {
|
||
12 years ago
|
value = $(this).html();
|
||
|
} else {
|
||
|
value = $(this).val();
|
||
|
}
|
||
12 years ago
|
if (value === '') {
|
||
12 years ago
|
value = '[empty]';
|
||
|
}
|
||
|
$(this).before('<div class="sticky-value">' + value + '</div>').hide();
|
||
|
});
|
||
12 years ago
|
$('.sticky-value').on('click', function () {
|
||
12 years ago
|
$(this).hide();
|
||
|
$(this).next().show().get(0).focus();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var initPreviewDiffLinks = function () {
|
||
|
$('.preview-code,.diff-code').on('click', function () {
|
||
|
var $modal = $('#preview-modal');
|
||
|
var $link = $(this);
|
||
|
$modal.find('.modal-title').text($link.data('title'));
|
||
|
$modal.find('.modal-body').html('Loading ...');
|
||
|
$modal.modal('show');
|
||
|
$.ajax({
|
||
|
type: 'POST',
|
||
|
cache: false,
|
||
|
url: $link.prop('href'),
|
||
|
data: $('.default-view form').serializeArray(),
|
||
|
success: function (data) {
|
||
|
$modal.find('.modal-body').html(data);
|
||
|
$modal.find('.content').css('max-height', ($(window).height() - 200) + 'px');
|
||
|
},
|
||
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||
12 years ago
|
$modal.find('.modal-body').html('<div class="error">' + XMLHttpRequest.responseText + '</div>');
|
||
12 years ago
|
}
|
||
12 years ago
|
});
|
||
12 years ago
|
return false;
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var initConfirmationCheckboxes = function () {
|
||
|
var $checkAll = $('#check-all');
|
||
|
$checkAll.click(function () {
|
||
|
$('.default-view-files table .check input').prop('checked', this.checked);
|
||
|
});
|
||
|
$('.default-view-files table .check input').click(function () {
|
||
|
$checkAll.prop('checked', !$('.default-view-files table .check input:not(:checked)').length);
|
||
|
});
|
||
|
$checkAll.prop('checked', !$('.default-view-files table .check input:not(:checked)').length);
|
||
|
};
|
||
|
|
||
|
return {
|
||
|
init: function () {
|
||
|
initHintBlocks();
|
||
|
initStickyInputs();
|
||
|
initPreviewDiffLinks();
|
||
|
initConfirmationCheckboxes();
|
||
|
|
||
11 years ago
|
// model generator: hide class name input when table name input contains *
|
||
|
$('#model-generator #generator-tablename').on('change', function () {
|
||
|
$('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1);
|
||
|
}).change();
|
||
|
|
||
12 years ago
|
// hide Generate button if any input is changed
|
||
|
$('.default-view .form-group input,select,textarea').change(function () {
|
||
12 years ago
|
$('.default-view-results,.default-view-files').hide();
|
||
|
$('.default-view button[name="generate"]').hide();
|
||
12 years ago
|
});
|
||
12 years ago
|
|
||
|
$('.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]);
|
||
|
}
|
||
|
});
|
||
12 years ago
|
}
|
||
|
};
|
||
|
})(jQuery);
|