hyperion.ng/assets/webconfig/js/lib/dialog.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

"undefined"==typeof gj&&(gj={}),gj.widget=function(){var a=this;a.xhr=null,a.generateGUID=function(){function a(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}},gj.widget.prototype.init=function(a,b){var c,d,e;d=$.extend(!0,{},this.getHTMLConfig()||{}),$.extend(!0,d,a||{}),e=this.getConfig(d,b),this.attr("data-guid",e.guid),this.data(e);for(c in e)gj[b].events.hasOwnProperty(c)&&(this.on(c,e[c]),delete e[c]);for(plugin in gj[b].plugins)gj[b].plugins.hasOwnProperty(plugin)&&gj[b].plugins[plugin].configure(this,e,d);return this},gj.widget.prototype.getConfig=function(a,b){var c,d,e;c=$.extend(!0,{},gj[b].config.base),d=a.uiLibrary||c.uiLibrary,gj[b].config[d]&&$.extend(!0,c,gj[b].config[d]);for(e in gj[b].plugins)gj[b].plugins.hasOwnProperty(e)&&($.extend(!0,c,gj[b].plugins[e].config.base),gj[b].plugins[e].config[d]&&$.extend(!0,c,gj[b].plugins[e].config[d]));return $.extend(!0,c,a),c.guid||(c.guid=this.generateGUID()),c},gj.widget.prototype.getHTMLConfig=function(){var a=this.data(),b=this[0].attributes;return b.width&&(a.width=b.width.nodeValue),b.height&&(a.height=b.height.nodeValue),b.align&&(a.align=b.align.nodeValue),a&&a.source&&(a.dataSource=a.source,delete a.source),a},gj.widget.prototype.createDoneHandler=function(){var a=this;return function(b){"string"==typeof b&&JSON&&(b=JSON.parse(b)),gj[a.data("type")].methods.render(a,b)}},gj.widget.prototype.createErrorHandler=function(){return function(a){a&&a.statusText&&"abort"!==a.statusText&&alert(a)}},gj.widget.prototype.reload=function(a){var b,c,d=this.data();return void 0===d.dataSource&&gj[this.data("type")].methods.useHtmlDataSource(this,d),$.extend(d.params,a),$.isArray(d.dataSource)?(c=gj[this.data("type")].methods.filter(this),gj[this.data("type")].methods.render(this,c)):"string"==typeof d.dataSource?(b={url:d.dataSource,data:d.params},this.xhr&&this.xhr.abort(),this.xhr=$.ajax(b).done(this.createDoneHandler()).fail(this.createErrorHandler())):"object"==typeof d.dataSource&&(d.dataSource.data||(d.dataSource.data={}),$.extend(d.dataSource.data,d.params),b=$.extend(!0,{},d.dataSource),"json"===b.dataType&&"object"==typeof b.data&&(b.data=JSON.stringify(b.data)),b.success||(b.success=this.createDoneHandler()),b.error||(b.error=this.createErrorHandler()),this.xhr&&this.xhr.abort(),this.xhr=$.ajax(b)),this},gj.documentManager={events:{},subscribeForEvent:function(a,b,c){if(gj.documentManager.events[a]&&0!==gj.documentManager.events[a].length){if(gj.documentManager.events[a][b])throw"Event "+a+" for widget with guid='"+b+"' is already attached.";gj.documentManager.events[a].push({widgetId:b,callback:c})}else gj.documentManager.events[a]=[{widgetId:b,callback:c}],$(document).on(a,gj.documentManager.executeCallbacks)},executeCallbacks:function(a){var b=gj.documentManager.events[a.type];if(b)for(var c=0;c<b.length;c++)b[c].callback(a)},unsubscribeForEvent:function(a,b){var c=!1,d=gj.documentManager.events[a];if(d)for(var e=0;e<d.length;e++)d[e].widgetId===b&&(d.splice(e,1),c=!0,0===d.length&&($(document).off(a),delete gj.documentManager.events[a]));if(!c)throw'The "'+a+'" for widget with guid="'+b+"\" can't be removed."}},"undefined"==typeof gj.dialog&&(gj.dialog={plugins:{}}),gj.dialog.config={base:{autoOpen:!0,closeOnEscape:!0,closeButtonInHeader:!0,draggable:!0,height:"auto",minHeight:void 0,maxHeight:void 0,width:300,minWidth:void 0,maxWidth:void 0,modal:!1,resizable:!1,title:"Dialog",uiLibrary:void 0,style:{modal:"gj-modal",content:"gj-content",header:"gj-header",headerTitle:"gj-title gj-unselectable",headerCloseButton:"gj-close",body:"gj-body",footer:"gj-dialog-footer gj-footer"}},bootstrap:{style:{modal:"modal",content:"modal-content",header:"modal-header",headerTitle:"modal-title",headerCloseButton:"close",body:"modal-body",footer:"gj-dialog-footer modal-footer"}},jqueryui:{style:{modal:"gj-modal",content:"ui-widget ui-widget-content gj-dialog-content",header:"gj-dialog-ui-header ui-widget-header",headerTitle:"gj-dialog-ui-title",headerCloseButton:"gj-dialog-ui-close ui-button ui-