2014-03-06 22:55:32 +08:00
|
|
|
var Gogits = {
|
|
|
|
"PageIsSignup": false
|
|
|
|
};
|
2014-03-02 21:47:55 +08:00
|
|
|
|
2014-03-06 22:55:32 +08:00
|
|
|
(function ($) {
|
2014-03-10 16:54:52 +08:00
|
|
|
|
2014-03-02 21:47:55 +08:00
|
|
|
Gogits.showTab = function (selector, index) {
|
|
|
|
if (!index) {
|
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
$(selector).tab("show");
|
|
|
|
$(selector).find("li:eq(" + index + ") a").tab("show");
|
2014-03-06 22:55:32 +08:00
|
|
|
};
|
|
|
|
Gogits.validateForm = function (selector, options) {
|
|
|
|
var $form = $(selector);
|
|
|
|
options = options || {};
|
|
|
|
options.showErrors = function (map, list) {
|
|
|
|
var $error = $form.find('.form-error').addClass('hidden');
|
|
|
|
$('.has-error').removeClass("has-error");
|
|
|
|
$error.text(list[0].message).show().removeClass("hidden");
|
|
|
|
$(list[0].element).parents(".form-group").addClass("has-error");
|
|
|
|
};
|
|
|
|
$form.validate(options);
|
|
|
|
};
|
2014-03-10 16:54:52 +08:00
|
|
|
|
|
|
|
// ----- init elements
|
|
|
|
Gogits.initModals = function () {
|
|
|
|
var modals = $("[data-toggle=modal]");
|
|
|
|
if (modals.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$.each(modals, function (i, item) {
|
|
|
|
$(item).modal("hide");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Gogits.initTooltips = function () {
|
|
|
|
$("body").tooltip({
|
|
|
|
selector: "[data-toggle=tooltip]"
|
|
|
|
//container: "body"
|
|
|
|
});
|
|
|
|
};
|
2014-03-03 22:40:22 +08:00
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|
2014-03-06 22:55:32 +08:00
|
|
|
function initCore() {
|
2014-03-10 16:54:52 +08:00
|
|
|
Gogits.initTooltips();
|
|
|
|
Gogits.initModals();
|
2014-03-06 22:55:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function initRegister() {
|
|
|
|
$.getScript("/js/jquery.validate.min.js", function () {
|
|
|
|
Gogits.validateForm("#gogs-login-card", {
|
|
|
|
rules: {
|
|
|
|
"username": {
|
|
|
|
required: true,
|
|
|
|
minlength: 5,
|
|
|
|
maxlength: 30
|
|
|
|
},
|
|
|
|
"email": {
|
|
|
|
required: true,
|
|
|
|
email: true
|
|
|
|
},
|
|
|
|
"passwd": {
|
|
|
|
required: true,
|
|
|
|
minlength: 6,
|
|
|
|
maxlength: 30
|
|
|
|
},
|
|
|
|
"re-passwd": {
|
|
|
|
required: true,
|
|
|
|
equalTo: "input[name=passwd]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2014-03-03 22:40:22 +08:00
|
|
|
}
|