var EXPO = EXPO || {}; //isolated namespace if (EXPO.index) { console.warn('WARNING: EXPO.eventsFeed is already defined!'); } else { EXPO.index = (function () { // variables var that = {}; //default module setting that.opt = {}; //dependence's var com = EXPO.common; //private var Note = function (it, opt) { this.opt = opt; this.DOMthis = it; this.DOMbutton = it.querySelector('.'+opt.buttonClass); this.DOMinput = it.querySelector('.'+opt.inputClass); this.inputName = this.DOMinput.getAttribute('name'); this.url = this.DOMbutton.getAttribute('href'); this._controller(); }; Note.prototype = { _init: function () { }, _controller: function () { var self = this; $(this.DOMinput).on('blur', function () { self.send(); }); $(this.DOMbutton).on('click', function () { return false; }); }, send: function () { var data = {}, response, self = this, handler = function (data) { if (data.success){ console.log('ok'); $(self.DOMbutton).addClass('active'); }else{ console.log('data not send'); } }; data[this.inputName] = this.DOMinput.value; response = com.getRequest(data,this.url,handler); } }; /////////////////////////// //инициализация общих свойств that.init = function (options) { // settings extending $.extend(this.opt, options); // begin of initialization var self = this; this.notes = []; $('.'+this.opt.note.wrapClass).each(function () { var note = new Note(this,self.opt.note); self.notes.push(note); }); $('.'+this.opt.note.wrapDisabledClass).on('click', function () { $.fancybox.open('#pw-login'); return false; }); }; return that; }()); }