diff --git a/assets/webconfig/content/about.html b/assets/webconfig/content/about.html index bdcd157c..3d32f2b3 100644 --- a/assets/webconfig/content/about.html +++ b/assets/webconfig/content/about.html @@ -18,7 +18,7 @@ performTranslation(); var si = sysInfo.hyperion; - var libs = { "Bootstrap 3": "http://getbootstrap.com/", "JQuery": "https://jquery.com/", "Bootstrap Colorpicker": "https://itsjavi.com/bootstrap-colorpicker/", "JSON-Editor": "http://jeremydorn.com/json-editor/", "jQuery.i18n": "https://github.com/wikimedia/jquery.i18n", "metisMenu": "http://mm.onokumus.com/index.html", "download.js": "http://danml.com/download.html", "gijgo": "http://gijgo.com/" }; + var libs = { "Bootstrap 3": "http://getbootstrap.com/", "JQuery": "https://jquery.com/", "Bootstrap Colorpicker": "https://itsjavi.com/bootstrap-colorpicker/", "Bootstrap Toggle": "https://www.bootstraptoggle.com/", "JSON-Editor": "http://jeremydorn.com/json-editor/", "jQuery.i18n": "https://github.com/wikimedia/jquery.i18n", "metisMenu": "http://mm.onokumus.com/index.html", "download.js": "http://danml.com/download.html", "gijgo": "http://gijgo.com/" }; var libh = ""; var lang = []; var dcount = 0; @@ -86,4 +86,4 @@ }); removeOverlay(); - \ No newline at end of file + diff --git a/assets/webconfig/css/bootstrap-toggle.min.css b/assets/webconfig/css/bootstrap-toggle.min.css new file mode 100644 index 00000000..0d42ed09 --- /dev/null +++ b/assets/webconfig/css/bootstrap-toggle.min.css @@ -0,0 +1,28 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ +.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px} +.toggle{position:relative;overflow:hidden} +.toggle input[type=checkbox]{display:none} +.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none} +.toggle.off .toggle-group{left:-100%} +.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0} +.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0} +.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px} +.toggle.btn{min-width:59px;min-height:34px} +.toggle-on.btn{padding-right:24px} +.toggle-off.btn{padding-left:24px} +.toggle.btn-lg{min-width:79px;min-height:45px} +.toggle-on.btn-lg{padding-right:31px} +.toggle-off.btn-lg{padding-left:31px} +.toggle-handle.btn-lg{width:40px} +.toggle.btn-sm{min-width:50px;min-height:30px} +.toggle-on.btn-sm{padding-right:20px} +.toggle-off.btn-sm{padding-left:20px} +.toggle.btn-xs{min-width:35px;min-height:22px} +.toggle-on.btn-xs{padding-right:12px} +.toggle-off.btn-xs{padding-left:12px} \ No newline at end of file diff --git a/assets/webconfig/css/hyperion.css b/assets/webconfig/css/hyperion.css index d8112bf0..a51cee35 100644 --- a/assets/webconfig/css/hyperion.css +++ b/assets/webconfig/css/hyperion.css @@ -12,7 +12,6 @@ body{font-family:Roboto,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15 body{ overflow-y: scroll; } -.btn{margin: 2px 0;} /* #page-wrapper a[target=_blank]::after { content:"\f08e"; @@ -217,6 +216,8 @@ table label{margin:0} } /*simple ripple effect for li a and btn*/ +/* Breaks Bootstrap toggle; position: relative */ +/* .btn, li a{ position: relative; overflow: hidden; @@ -264,6 +265,7 @@ li a:active:after { opacity: .2; transition: 0s; } +*/ /*Bootstrap callouts*/ .bs-callout { diff --git a/assets/webconfig/index.html b/assets/webconfig/index.html index cf0f0b3e..410571e0 100644 --- a/assets/webconfig/index.html +++ b/assets/webconfig/index.html @@ -36,7 +36,6 @@ - @@ -54,6 +53,11 @@ + + + + + diff --git a/assets/webconfig/js/content_index.js b/assets/webconfig/js/content_index.js index cbb5d200..6c986298 100644 --- a/assets/webconfig/js/content_index.js +++ b/assets/webconfig/js/content_index.js @@ -221,7 +221,7 @@ $(document).ready(function () { } }); // notify the update - $(window.hyperion).trigger("components-updated"); + $(window.hyperion).trigger("components-updated", event.response.data); }); $(window.hyperion).on("cmd-instance-update", function (event) { @@ -307,4 +307,4 @@ $("#btn_darkmode").off().on("click",function(e){ location.reload(); } -}); \ No newline at end of file +}); diff --git a/assets/webconfig/js/content_remote.js b/assets/webconfig/js/content_remote.js index 39295e07..7465e8d7 100644 --- a/assets/webconfig/js/content_remote.js +++ b/assets/webconfig/js/content_remote.js @@ -1,5 +1,5 @@ $(document).ready(function() { - performTranslation(); + performTranslation(); var oldEffects = []; var cpcolor = '#B500FF'; @@ -203,7 +203,7 @@ $(document).ready(function() { } } - function updateComponents() + function initComponents() { var components = window.comps; var hyperionEnabled = true; @@ -214,32 +214,77 @@ $(document).ready(function() { } }); - // create buttons - $('#componentsbutton').html(""); - for (var idx=0; idx '+$.i18n('general_comp_'+components[idx].name)+''; + var d='' + +'' + +'   ' + +''; + $('#componentsbutton').append(d); + $(`#${comp_btn_id}`).bootstrapToggle(); + $(`#${comp_btn_id}`).bootstrapToggle(hyperionEnabled ? "enable" : "disable") + $(`#${comp_btn_id}`).change(e => { + requestSetComponentState(e.currentTarget.id.split('_').pop(), e.currentTarget.checked) + //console.log(e.currentTarget.checked) + }); } - else // already create, update state + } + } + + function updateComponent( component ) + { + if (component.name == "ALL") + { + var components = window.comps; + + hyperionEnabled = component.enabled + for (const comp of components) { - setClassByBool( $('#'+comp_btn_id) , components[idx].enabled, "btn-danger", "btn-success" ); - setClassByBool( $('#'+comp_btn_id+"_icon"), components[idx].enabled, "fa-stop" , "fa-play" ); - $('#'+comp_btn_id).attr("onclick",'requestSetComponentState(\''+comp_name+'\','+(!components[idx].enabled)+')').attr(comp_goff); + + if(comp.name === "ALL") + continue; + + const comp_btn_id = "comp_btn_"+comp.name; + + if ( !hyperionEnabled ) + { + $(`#${comp_btn_id}`).bootstrapToggle('off'); + $(`#${comp_btn_id}`).bootstrapToggle("disable"); + } + else + { + $(`#${comp_btn_id}`).bootstrapToggle("enable"); + if ( comp.enabled !== $(`#${comp_btn_id}`).prop("checked") ) + { + $(`#${comp_btn_id}`).bootstrapToggle().prop('checked', comp.enabled).change(); + } + } + } + } + else + { + const comp_btn_id = "comp_btn_"+component.name; + + //console.log ("updateComponent: ", component.name, "Current Checked: ", $(`#${comp_btn_id}`).prop("checked"), "New Checked: ", component.enabled, ); + + // In case Buttons were disabled before, status may be different to component status + if ( component.enabled != $(`#${comp_btn_id}`).prop("checked") ) + { + // console.log ("Update status to Checked = ", component.enabled); + if ( component.enabled ) + $(`#${comp_btn_id}`).bootstrapToggle("on"); + else + $(`#${comp_btn_id}`).bootstrapToggle("off"); } } } @@ -345,14 +390,18 @@ $(document).ready(function() { }); //force first update - updateComponents(); + initComponents(); updateInputSelect(); updateLedMapping(); updateVideoMode(); updateEffectlist(); // interval updates - $(window.hyperion).on("components-updated",updateComponents); + + $(window.hyperion).on('components-updated', function(e, comp){ + //console.log ("components-updated", e, comp); + updateComponent (comp); + }); $(window.hyperion).on("cmd-priorities-update", function(event){ window.serverInfo.priorities = event.response.data.priorities; diff --git a/assets/webconfig/js/lib/bootstrap-toggle.min.js b/assets/webconfig/js/lib/bootstrap-toggle.min.js new file mode 100644 index 00000000..37113200 --- /dev/null +++ b/assets/webconfig/js/lib/bootstrap-toggle.min.js @@ -0,0 +1,9 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ ++function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('