mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
8a794039cf
* update
* update
* update
* .
* .
* .
* update
* .
* .
* .
* .
* update
* .
* update
* .
* update
* update
* update
* update
* update
* update
* .
* update
* update
* update
* .
* .
* .
* Revert "."
This reverts commit 4dd6404b32
.
* update
* .
* .
* .
* .
* .
* .
* .
* .
* .
* .
* .
* ...
* .
* .
* .
* .
* .
* .
* .
* .
* .
* update
* update
* update
* remove svg and pic
* colorpicker imgs to base64 to prevent delayed load if not cached
* fix json2python func
* update swirl with rgba
* add double swirl, tune default val in schema, update explanation
* adjust swirl.py
* FileObserver for config checks with timer as fallback (#4)
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"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()},a.mouseX=function(a){if(a){if(a.pageX)return a.pageX;if(a.clientX)return a.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);if(a.touches&&a.touches.length)return a.touches[0].pageX;if(a.changedTouches&&a.changedTouches.length)return a.changedTouches[0].pageX;if(a.originalEvent&&a.originalEvent.touches&&a.originalEvent.touches.length)return a.originalEvent.touches[0].pageX;if(a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches.length)return a.originalEvent.touches[0].pageX}return null},a.mouseY=function(a){if(a){if(a.pageY)return a.pageY;if(a.clientY)return a.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);if(a.touches&&a.touches.length)return a.touches[0].pageY;if(a.changedTouches&&a.changedTouches.length)return a.changedTouches[0].pageY;if(a.originalEvent&&a.originalEvent.touches&&a.originalEvent.touches.length)return a.originalEvent.touches[0].pageY;if(a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches.length)return a.originalEvent.touches[0].pageY}return null}},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,f;c=$.extend(!0,{},gj[b].config.base),d=a.hasOwnProperty("uiLibrary")?a.uiLibrary:c.uiLibrary,gj[b].config[d]&&$.extend(!0,c,gj[b].config[d]),e=a.hasOwnProperty("iconsLibrary")?a.iconsLibrary:c.iconsLibrary,gj[b].config[e]&&$.extend(!0,c,gj[b].config[e]);for(f in gj[b].plugins)gj[b].plugins.hasOwnProperty(f)&&($.extend(!0,c,gj[b].plugins[f].config.base),gj[b].plugins[f].config[d]&&$.extend(!0,c,gj[b].plugins[f].config[d]),gj[b].plugins[f].config[e]&&$.extend(!0,c,gj[b].plugins[f].config[e]));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.statusText)}},gj.widget.prototype.reload=function(a){var b,c,d=this.data(),e=this.data("type");return void 0===d.dataSource&&gj[e].methods.useHtmlDataSource(this,d),$.extend(d.params,a),$.isArray(d.dataSource)?(c=gj[e].methods.filter(this),gj[e].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:{},messages:[]}),gj.dialog.messages["en-us"]={Close:"Close",DefaultTitle:"Dialog"},gj.dialog.config={base:{autoOpen:!0,closeOnEscape:!0,closeButtonInHeader:!0,draggable:!0,height:"auto",locale:"en-us",minHeight:void 0,maxHeight:void 0,width:300,minWidth:void 0,maxWidth:void 0,modal:!1,resizable:!1,title:void 0,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-widget ui-state-default ui-corner-all",body:"gj-dialog-ui-body",footer:"gj-dialog-footer"}},materialdesign:{style:{modal:"gj-modal",content:"mdl-dialog gj-dialog-mdl-content",header:"",headerTitle:"mdl-dialog__title gj-unselectable",headerCloseButton:"gj-dialog-mdl-close",body:"mdl-dialog__content",footer:"gj-dialog-footer"}}},gj.dialog.events={initialized:function(a){a.trigger("initialized")},opening:function(a){a.trigger("opening")},opened:function(a){a.trigger("opened")},closing:function(a){a.trigger("closing")},closed:function(a){a.trigger("closed")},drag:function(a){a.trigger("drag")},dragStart:function(a){a.trigger("dragStart")},dragStop:function(a){a.trigger("dragStop")},resize:function(a){a.trigger("resize")},resizeStart:function(a){a.trigger("resizeStart")},resizeStop:function(a){a.trigger("resizeStop")}},gj.dialog.methods={init:function(a){return this.attr("data-type","dialog"),gj.widget.prototype.init.call(this,a,"dialog"),gj.dialog.methods.localization(this),gj.dialog.methods.initialize(this),gj.dialog.events.initialized(this),this},localization:function(a){var b=a.data();"undefined"==typeof b.title&&(b.title=gj.dialog.messages[b.locale].DefaultTitle)},getHTMLConfig:function(){var a=gj.widget.prototype.getHTMLConfig.call(this),b=this[0].attributes;return b.title&&(a.title=b.title.nodeValue),a},initialize:function(a){var b,c,d=a.data();a.addClass(d.style.content),gj.dialog.methods.setSize(a),d.closeOnEscape&&$(document).keyup(function(b){27===b.keyCode&&a.close()}),c=a.children('div[data-role="body"]'),0===c.length?(c=$('<div data-role="body"/>').addClass(d.style.body),a.wrapInner(c)):c.addClass(d.style.body),b=gj.dialog.methods.renderHeader(a),a.children('div[data-role="footer"]').addClass(d.style.footer),a.find('[data-role="close"]').on("click",function(){a.close()}),d.draggable&&$.fn.draggable&&gj.dialog.methods.draggable(a,b),d.resizable&&$.fn.draggable&&gj.dialog.methods.resizable(a),gj.dialog.methods.setPosition(a),d.modal&&a.wrapAll('<div data-role="modal" class="'+d.style.modal+'"/>'),d.autoOpen&&a.open()},setSize:function(a){var b=a.data();b.width&&a.css("width",b.width),b.height&&a.css("height",b.height)},renderHeader:function(a){var b,c,d,e=a.data();return b=a.children('div[data-role="header"]'),0===b.length&&(b=$('<div data-role="header" />'),a.prepend(b)),b.addClass(e.style.header),c=b.find('[data-role="title"]'),0===c.length&&(c=$('<h4 data-role="title"><i class="fa fa-fw fa-television"></i>'+e.title+"</h4>"),b.append(c)),c.addClass(e.style.headerTitle),d=b.find('[data-role="close"]'),0===d.length&&e.closeButtonInHeader?(d=$('<button type="button" data-role="close" title="'+gj.dialog.messages[e.locale].Close+'"><span>×</span></button>'),d.addClass(e.style.headerCloseButton),b.prepend(d)):d.length>0&&e.closeButtonInHeader===!1?d.hide():d.addClass(e.style.headerCloseButton),b},setPosition:function(a){var b=$(window).width()/2-a.width()/2,c=$(window).height()/2-a.height()/2;a.css("position","absolute"),a.css("left",b>0?b:0),a.css("top",c>0?c:0)},draggable:function(a,b){a.appendTo("body"),b.addClass("gj-draggable"),a.draggable({handle:b,start:function(){a.addClass("gj-unselectable"),gj.dialog.events.dragStart(a)},stop:function(){a.removeClass("gj-unselectable"),gj.dialog.events.dragStop(a)}})},resizable:function(a){var b={drag:gj.dialog.methods.resize,start:function(){a.addClass("gj-unselectable"),gj.dialog.events.resizeStart(a)},stop:function(){this.removeAttribute("style"),a.removeClass("gj-unselectable"),gj.dialog.events.resizeStop(a)}};a.append($('<div class="gj-resizable-handle gj-resizable-n"></div>').draggable($.extend(!0,{horizontal:!1},b))),a.append($('<div class="gj-resizable-handle gj-resizable-e"></div>').draggable($.extend(!0,{vertical:!1},b))),a.append($('<div class="gj-resizable-handle gj-resizable-s"></div>').draggable($.extend(!0,{horizontal:!1},b))),a.append($('<div class="gj-resizable-handle gj-resizable-w"></div>').draggable($.extend(!0,{vertical:!1},b))),a.append($('<div class="gj-resizable-handle gj-resizable-ne"></div>').draggable($.extend(!0,{},b))),a.append($('<div class="gj-resizable-handle gj-resizable-nw"></div>').draggable($.extend(!0,{},b))),a.append($('<div class="gj-resizable-handle gj-resizable-sw"></div>').draggable($.extend(!0,{},b))),a.append($('<div class="gj-resizable-handle gj-resizable-se"></div>').draggable($.extend(!0,{},b)))},resize:function(a,b){var c,d,e,f,g,h,i,j=!1;return c=$(this),d=c.parent(),e=d.data(),c.hasClass("gj-resizable-n")?(f=d.height()-b.top,h=d.offset().top+b.top):c.hasClass("gj-resizable-e")?g=d.width()+b.left:c.hasClass("gj-resizable-s")?f=d.height()+b.top:c.hasClass("gj-resizable-w")?(g=d.width()-b.left,i=d.offset().left+b.left):c.hasClass("gj-resizable-ne")?(f=d.height()-b.top,h=d.offset().top+b.top,g=d.width()+b.left):c.hasClass("gj-resizable-nw")?(f=d.height()-b.top,h=d.offset().top+b.top,g=d.width()-b.left,i=d.offset().left+b.left):c.hasClass("gj-resizable-se")?(f=d.height()+b.top,g=d.width()+b.left):c.hasClass("gj-resizable-sw")&&(f=d.height()+b.top,g=d.width()-b.left,i=d.offset().left+b.left),f&&(!e.minHeight||f>=e.minHeight)&&(!e.maxHeight||f<=e.maxHeight)&&(d.height(f),h&&d.css("top",h),j=!0),g&&(!e.minWidth||g>=e.minWidth)&&(!e.maxWidth||g<=e.maxWidth)&&(d.width(g),i&&d.css("left",i),j=!0),j&&gj.dialog.events.resize(d),j},open:function(a){var b;return gj.dialog.events.opening(a),a.css("display","block"),a.closest('div[data-role="modal"]').css("display","block"),b=a.children('div[data-role="footer"]'),b.length&&b.outerHeight()&&a.children('div[data-role="body"]').css("margin-bottom",b.outerHeight()),gj.dialog.events.opened(a),a},close:function(a){return a.is(":visible")&&(gj.dialog.events.closing(a),a.css("display","none"),a.closest('div[data-role="modal"]').css("display","none"),gj.dialog.events.closed(a)),a},isOpen:function(a){return a.is(":visible")},destroy:function(a,b){var c=a.data();return c&&(b===!1?a.remove():(a.close(),a.off(),a.removeData(),a.removeAttr("data-type"),a.removeClass(c.style.content),a.find('[data-role="header"]').removeClass(c.style.header),a.find('[data-role="title"]').removeClass(c.style.headerTitle),a.find('[data-role="close"]').remove(),a.find('[data-role="body"]').removeClass(c.style.body),a.find('[data-role="footer"]').removeClass(c.style.footer))),a}},gj.dialog.widget=function(a,b){var c=this,d=gj.dialog.methods;return c.open=function(){return d.open(this)},c.close=function(){return d.close(this)},c.isOpen=function(){return d.isOpen(this)},c.destroy=function(a){return d.destroy(this,a)},$.extend(a,c),"dialog"!==a.attr("data-type")&&d.init.apply(a,b),a},gj.dialog.widget.prototype=new gj.widget,gj.dialog.widget.constructor=gj.dialog.widget,gj.dialog.widget.prototype.getHTMLConfig=gj.dialog.methods.getHTMLConfig,function(a){a.fn.dialog=function(a){var b;if(this&&this.length){if("object"!=typeof a&&a){if(b=new gj.dialog.widget(this,null),b[a])return b[a].apply(this,Array.prototype.slice.call(arguments,1));throw"Method "+a+" does not exist."}return new gj.dialog.widget(this,arguments)}}}(jQuery); |