summaryrefslogtreecommitdiffstats
path: root/templates/content/js/com.cnprog.utils.js
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-01-24 19:53:24 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-01-24 20:03:45 -0500
commitad2e22b999b3b795f60e0f95abcaf3b339567294 (patch)
treeebea9e231463d878ff869e4a74ecd4620e743a95 /templates/content/js/com.cnprog.utils.js
parentc4da893b2e28dbd2a04f8c6f61c52936119b1148 (diff)
downloadaskbot-ad2e22b999b3b795f60e0f95abcaf3b339567294.tar.gz
askbot-ad2e22b999b3b795f60e0f95abcaf3b339567294.tar.bz2
askbot-ad2e22b999b3b795f60e0f95abcaf3b339567294.zip
recaptcha for conventional registration\n\
simpler email subscription form at registration\n\ fixed urls in rss feed\n\ added experimental remote password login api (cleartext password for remote site entered locally)\n\ included example for Mediawiki Authentication plugin\n\ very simple message to everyone management command
Diffstat (limited to 'templates/content/js/com.cnprog.utils.js')
-rw-r--r--templates/content/js/com.cnprog.utils.js51
1 files changed, 28 insertions, 23 deletions
diff --git a/templates/content/js/com.cnprog.utils.js b/templates/content/js/com.cnprog.utils.js
index b19b6773..4c3aafba 100644
--- a/templates/content/js/com.cnprog.utils.js
+++ b/templates/content/js/com.cnprog.utils.js
@@ -1,6 +1,7 @@
+//var $, scriptUrl;
var showMessage = function(object, msg) {
- var div = $('<div class="vote-notification"><h3>' + msg + '</h3>('
- + $.i18n._('click to close') + ')</div>');
+ var div = $('<div class="vote-notification"><h3>' + msg + '</h3>(' +
+ $.i18n._('click to close') + ')</div>');
div.click(function(event) {
$(".vote-notification").fadeOut("fast", function() { $(this).remove(); });
@@ -35,18 +36,30 @@ var notify = function() {
} ();
function appendLoader(containerSelector) {
- $(containerSelector).append('<img class="ajax-loader" '
- +'src="' + scriptUrl + 'content/images/indicator.gif" title="'
- +$.i18n._('loading...')
- +'" alt="'
- +$.i18n._('loading...')
- +'" />');
+ $(containerSelector).append('<img class="ajax-loader" ' +
+ 'src="' + scriptUrl + 'content/images/indicator.gif" title="' +
+ $.i18n._('loading...') +
+ '" alt="' +
+ $.i18n._('loading...') +
+ '" />');
}
function removeLoader() {
$("img.ajax-loader").remove();
}
+function setSubmitButtonDisabled(formSelector, isDisabled) {
+ $(formSelector).find("input[type='submit']").attr("disabled", isDisabled ? "true" : "");
+}
+
+function enableSubmitButton(formSelector) {
+ setSubmitButtonDisabled(formSelector, false);
+}
+
+function disableSubmitButton(formSelector) {
+ setSubmitButtonDisabled(formSelector, true);
+}
+
function setupFormValidation(formSelector, validationRules, validationMessages, onSubmitCallback) {
enableSubmitButton(formSelector);
$(formSelector).validate({
@@ -56,7 +69,7 @@ function setupFormValidation(formSelector, validationRules, validationMessages,
errorClass: "form-error",
errorPlacement: function(error, element) {
var span = element.next().find("span.form-error");
- if (span.length == 0) {
+ if (span.length === 0) {
span = element.parent().find("span.form-error");
}
span.replaceWith(error);
@@ -64,24 +77,16 @@ function setupFormValidation(formSelector, validationRules, validationMessages,
submitHandler: function(form) {
disableSubmitButton(formSelector);
- if (onSubmitCallback)
+ if (onSubmitCallback){
onSubmitCallback();
- else
+ }
+ else{
form.submit();
+ }
}
});
}
-function enableSubmitButton(formSelector) {
- setSubmitButtonDisabled(formSelector, false);
-}
-function disableSubmitButton(formSelector) {
- setSubmitButtonDisabled(formSelector, true);
-}
-function setSubmitButtonDisabled(formSelector, isDisabled) {
- $(formSelector).find("input[type='submit']").attr("disabled", isDisabled ? "true" : "");
-}
-
var CPValidator = function(){
return {
getQuestionFormRules : function(){
@@ -108,11 +113,11 @@ var CPValidator = function(){
},
text: {
required: " " + $.i18n._('content cannot be empty'),
- minlength: jQuery.format(' ' + $.i18n._('content minchars'))
+ minlength: $.format(' ' + $.i18n._('content minchars'))
},
title: {
required: " " + $.i18n._('please enter title'),
- minlength: jQuery.format(' ' + $.i18n._('title minchars'))
+ minlength: $.format(' ' + $.i18n._('title minchars'))
}
};
}