1/** 2 * @namespace WPGMZA 3 * @module GenericModal 4 * @requires WPGMZA.EventDispatcher 5 */ 6jQuery(function($) { 7 WPGMZA.GenericModal = function(element, complete, cancel){ 8 this.element = $(element); 9 10 this._onComplete = complete ? complete : false; 11 this._onCancel = cancel ? cancel : false; 12 13 this.bindEvents(); 14 } 15 16 WPGMZA.extend(WPGMZA.GenericModal, WPGMZA.EventDispatcher); 17 18 WPGMZA.GenericModal.createInstance = function(element, complete, cancel) { 19 if(WPGMZA.isProVersion()){ 20 return new WPGMZA.ProGenericModal(element, complete, cancel); 21 } 22 return new WPGMZA.GenericModal(element, complete, cancel); 23 } 24 25 WPGMZA.GenericModal.prototype.bindEvents = function(){ 26 const self = this; 27 this.element.on('click', '.wpgmza-button', function(){ 28 const action = $(this).data('action'); 29 if(action === 'complete'){ 30 self.onComplete(); 31 } else { 32 self.onCancel(); 33 } 34 }); 35 } 36 37 WPGMZA.GenericModal.prototype.getData = function(){ 38 const data = {}; 39 this.element.find('input,select').each(function(){ 40 if($(this).data('ajax-name')){ 41 data[$(this).data('ajax-name')] = $(this).val(); 42 } 43 }); 44 45 return data; 46 } 47 48 WPGMZA.GenericModal.prototype.onComplete = function(){ 49 this.hide(); 50 if(typeof this._onComplete === 'function'){ 51 this._onComplete(this.getData()); 52 } 53 } 54 55 WPGMZA.GenericModal.prototype.onCancel = function(){ 56 this.hide(); 57 if(typeof this._onCancel === 'function'){ 58 this._onCancel(); 59 } 60 } 61 62 WPGMZA.GenericModal.prototype.show = function(complete, cancel){ 63 /* Support hotswapping */ 64 this._onComplete = complete ? complete : this._onComplete; 65 this._onCancel = cancel ? cancel : this._onCancel; 66 67 this.element.addClass('pending'); 68 } 69 70 WPGMZA.GenericModal.prototype.hide = function(){ 71 this.element.removeClass('pending'); 72 } 73 74 75});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.