//------------------------------------ function MagicInput(options, data, callback){ this.data = data; this.options = options; this._callback = callback; } MagicInput.prototype.toString = function(){ return 'This is MagicInput object'; } MagicInput.prototype.callback = function(){ this._callback.apply(this, arguments); } MagicInput.instance = function(el, data, callback){ // var options = $(el).mapAttributes('mi-', true); el = $(el); var options = {}; options['action'] = el.attr('mi-action'); options['title'] = el.attr('mi-title'); options['iface'] = el.attr('mi-iface'); options['data'] = el.attr('mi-data'); try{ $.extend(data, options.data ? $.parseJSON(options.data) : {}); delete options.data; options.iface = 'mi' + options.iface.substring(0,1).toUpperCase() + options.iface.substring(1); return input = new window[options.iface](options, data, callback); }catch(e){ console.log('MagicInput::instance ' + e); throw e; } } //------------------------------------ function miNone(options, callback){ miNote.superclass.constructor.apply(this, arguments); this.callback(); } extend(miNone, MagicInput); miNone.prototype.toString = function(){ return 'This is miNone object'; } //------------------------------------ function miNote(options, callback){ miNote.superclass.constructor.apply(this, arguments); if(confirm('Eniieuciaaou "'+this.options.title+'" nae?an?')){ this.callback() } } extend(miNote, MagicInput); miNote.prototype.toString = function(){ return 'This is miNote object'; } //------------------------------------ function miDialog(options, data, callback, content, dialogOptions){ miDialog.superclass.constructor.apply(this, arguments); var mi = this; this.dialog = content.dialog($.extend({},{ title: this.options.title, resizable: false, minHeight: 20, dialogClass: 'sand-style mi-container', beforeClose: function(e, ui){ var tmp = true; if(1 * $(this).attr('submit')){ mi._collect.call(mi); if(tmp = mi._validation.call(mi)){ return true; } } $(this).attr('submit', 0); return tmp; }, close: function(e, ui){ if(1 * $(this).attr('submit')){ mi.callback(); } mi.destroy(); } }, dialogOptions)) .on('click','.dialog-submit',function(){ $(this).closest('.ui-dialog-content').attr('submit', 1).dialog('close') }) } extend(miDialog, MagicInput); miDialog.prototype.toString = function(){ return 'This is ABSTRACT miDialog object'; } miDialog.prototype.destroy = function(){ this.dialog.dialog('destroy').remove(); } miDialog._oneInput = function(p){ var i = $('').attr('name',p.name); if(p.grabber){ h[p.grabber].set(i); }else{ i.select(); } return $('
') .append('') .append($('').append(i)); } miDialog.prototype._collect = function(){ var mi = this; this.dialog.find('[name]').each(function(){ var el = $(this); if(el.is('input[type="checkbox"]')){ mi.data[el.attr('name')] = ~~el.is(':checked'); return; } mi.data[el.attr('name')] = el.val(); }) } miDialog.prototype._validation = function(){ return true; } function miUser(options, data, callback){ var mi = this; miUser.superclass.constructor.call(this, options, data, callback, $('