1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-05 07:54:24 +03:00
ifhub.club/application/frontend/skin/developer/components/content/js/content.js
2014-11-03 23:48:05 +07:00

65 lines
1.6 KiB
JavaScript

/**
* Content
*
* @module ls/content
*
* @license GNU General Public License, version 2
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
* @author Denis Shakhov <denis.shakhov@gmail.com>
*/
(function($) {
"use strict";
$.widget( "livestreet.lsContent", {
/**
* Дефолтные опции
*/
options: {
// Ссылки
urls: {
add: null,
edit: null
}
},
/**
* Конструктор
*
* @constructor
* @private
*/
_create: function () {
var _this = this;
this.action = this.element.data( 'content-action' );
this.element.on( 'submit' + this.eventNamespace, this.onSubmit.bind( this ) );
},
/**
* Коллбэк вызываемый при отправке формы
*/
onSubmit: function( event ) {
this.submit();
event.preventDefault();
},
/**
* Отправка формы
*/
submit: function( params ) {
ls.ajax.submit( this.option( 'urls.' + this.action ), this.element, function( response ) {
if ( response.bStateError ) {
ls.msg.error( null, response.sMsg );
} else {
if ( response.sUrlRedirect ) {
window.location.href = response.sUrlRedirect;
}
}
}, {
params: params || {}
});
}
});
})(jQuery);