var EXPO = EXPO || {}; //isolated namespace EXPO.exposition = EXPO.exposition || {}; if (EXPO.exposition.list){ console.warn('WARNING: EXPO.place.object is already defined!'); }else { EXPO.exposition.list = (function () { // dependencies var com = EXPO.common; // variables var that = {}, 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.opt = {}; //свойства по умолчанию //private $(function () { }); // methods //инициализация общих свойств that.init = function (options) { $.extend(this.opt, options); this.notes = []; var self = this; $('.'+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; }); com.opt.addCalendarText = this.opt.addCalendarText; com.opt.removeCalendarText = this.opt.removeCalendarText; }; return that; }()); }