1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-08 09:24:25 +03:00
ifhub.club/application/frontend/common/js/captcha.js

66 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-07-03 07:36:17 +03:00
/**
* Каптча
*
* @module ls/captcha
*
* @license GNU General Public License, version 2
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
* @author Denis Shakhov <denis.shakhov@gmail.com>
2013-07-03 07:36:17 +03:00
*/
var ls = ls || {};
ls.captcha = (function ($) {
"use strict";
/**
* jQuery объект каптчи
*
* @private
*/
var _oCaptcha = null;
2013-07-03 07:36:17 +03:00
/**
* Дефолтные опции
*
* @private
2013-07-03 07:36:17 +03:00
*/
var _defaults = {
// Селекторы
2013-07-09 11:40:06 +03:00
selectors: {
captcha: '.js-form-auth-captcha'
}
2013-07-03 07:36:17 +03:00
};
/**
* Инициализация
*
* @param {Object} options Опции
2013-07-03 07:36:17 +03:00
*/
this.init = function(options) {
this.options = $.extend({}, _defaults, options);
2013-07-03 07:36:17 +03:00
_oCaptcha = $(this.options.selectors.captcha);
2013-07-03 07:36:17 +03:00
// Обновляем каптчу при клике на нее
_oCaptcha.on('click', function () {
this.update();
2013-07-03 07:36:17 +03:00
}.bind(this));
};
/**
* Получает url каптчи
*/
this.getUrl = function () {
2013-08-08 14:00:37 +03:00
return PATH_FRAMEWORK_LIBS_VENDOR + '/kcaptcha/index.php?' + SESSION_NAME + '=' + SESSION_ID + '&n=' + Math.random();
2013-07-03 07:36:17 +03:00
};
/**
* Обновляет каптчу
*/
this.update = function () {
_oCaptcha.css('background-image', 'url(' + this.getUrl() + ')');
2013-07-03 07:36:17 +03:00
};
return this;
}).call(ls.captcha || {}, jQuery);