Changeset 389
- Timestamp:
- 2015-03-14 13:31:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/AltUI/J_ALTUI_uimgr.js ¶
r388 r389 1579 1579 function _initCustomPages( custompages ) { 1580 1580 }; 1581 1581 1582 1582 //------------------------------------------------------------ 1583 1583 // CUSTOM PAGE MENU … … 1586 1586 var startpos = null; 1587 1587 var _widgetOnCanvasDraggableOptions = { 1588 //grid: [ 5,5 ],1588 grid: [ 5,5 ], 1589 1589 // helper: "clone", 1590 1590 revert: "invalid", 1591 snap: true,1592 snapMode: "inner",1593 snapTolerance: 20,1591 // snap: true, 1592 // snapMode: "inner", 1593 // snapTolerance: 20, 1594 1594 start: function(event, ui) { 1595 1595 startpos = ui.position; … … 1717 1717 }; 1718 1718 1719 function _widgetDialogAddCheck(dialog,name, value) 1720 { 1721 var propertyline = ""; 1722 // propertyline += "<div class='checkbox'>"; 1723 propertyline +="<label class='checkbox-inline'>"; 1724 propertyline +=(" <input type='checkbox' id='altui-widget-"+name+"' " + ( (value==true) ? 'checked' : '') +" value='"+value+"' title='check to invert status value'>"+name); 1725 propertyline +="</label>"; 1726 // propertyline += "</div>"; 1727 $(dialog).find("form").append(propertyline); 1728 }; 1729 1719 1730 function _widgetDialogAddLine(dialog, name, value) 1720 1731 { 1732 value = value ||''; 1721 1733 var propertyline = ""; 1722 1734 propertyline += "<div class='form-group'>"; … … 1798 1810 }; 1799 1811 1800 function _widgetDialogAddActions(id, dialog,widget,actiondescriptor, cbfunc)1812 function _widgetDialogAddActions(id, dialog,widget,actiondescriptor,label, cbfunc) 1801 1813 { 1802 1814 // callback when select of actions is changed … … 1834 1846 var propertyline = ""; 1835 1847 propertyline += "<div class='form-group'>"; 1836 propertyline += " <label for='"+id+"'> Action</label>";1848 propertyline += " <label for='"+id+"'>"+label+"</label>"; 1837 1849 propertyline += result; 1838 1850 propertyline += "</div>"; … … 1949 1961 var dialog = _widgetCreatePropertyDialog('UPnP Action Properties'); 1950 1962 _widgetDialogAddDevices( dialog , widget, function() { 1951 _widgetDialogAddActions("altui-widget-action",dialog, widget, widget.properties, function() {1963 _widgetDialogAddActions("altui-widget-action",dialog, widget, widget.properties, 'Action', function() { 1952 1964 // run the show 1953 1965 $('div#dialogModal').modal(); … … 1984 1996 _widgetDialogAddDevices( dialog , widget, function() { 1985 1997 _widgetDialogAddVariables(dialog, widget, function() { 1998 _widgetDialogAddCheck(dialog,'Inverted',widget.properties.inverted); 1986 1999 _widgetDialogAddLine(dialog,'OffLabel', widget.properties.labels[0]); 1987 _widgetDialogAddActions("altui-widget-action-o n",dialog, widget, widget.properties.action_off, function() {2000 _widgetDialogAddActions("altui-widget-action-off",dialog, widget, widget.properties.action_off, 'Action to switch OFF', function() { 1988 2001 _widgetDialogAddLine(dialog,'OnLabel', widget.properties.labels[1]); 1989 _widgetDialogAddActions("altui-widget-action-o ff",dialog, widget, widget.properties.action_on, function() {2002 _widgetDialogAddActions("altui-widget-action-on",dialog, widget, widget.properties.action_on, 'Action to switch ON', function() { 1990 2003 // run the show 1991 2004 $('div#dialogModal').modal(); … … 2000 2013 // save for real this time 2001 2014 real_widget.properties.deviceid = widget.properties.deviceid; 2015 real_widget.properties.inverted = $("#altui-widget-Inverted").is(':checked'); 2002 2016 2003 2017 var states = VeraBox.getStates( widget.properties.deviceid ); … … 2035 2049 // clone for temporary storage 2036 2050 var widget = $.extend( true, {}, real_widget ); 2037 var dialog = _widgetCreatePropertyDialog(' OnOff Button Properties');2051 var dialog = _widgetCreatePropertyDialog('Device Icon Properties'); 2038 2052 2039 2053 _widgetDialogAddDevices( dialog , widget, function() { … … 2126 2140 }; 2127 2141 2142 2143 // ------------------------------------------ 2144 // public Callback 2145 // ------------------------------------------ 2146 function _onoffOnClick(widgetid) { 2147 // find the widget 2148 var pagename = _getActivePageName(); 2149 var page = PageManager.getPageFromName( pagename ); 2150 var widget=PageManager.getWidgetByID( page, widgetid ); 2151 // find the device 2152 var device= VeraBox.getDeviceByID( widget.properties.deviceid); 2153 // trigger the right action 2154 var status = VeraBox.getStatus(widget.properties.deviceid, widget.properties.service, widget.properties.variable); 2155 if ((status==undefined) || (status==false) || (status=='0') ) 2156 status = 0; 2157 else if ((status=='true') || (status=='1') || (status>=1)) 2158 status = 1; 2159 var actiondescriptor = (status==1) ? widget.properties.action_off : widget.properties.action_on; 2160 if (widget.properties.inverted) 2161 status = 1-status; 2162 UPnPHelper.UPnPAction( widget.properties.deviceid, actiondescriptor.service, actiondescriptor.action, actiondescriptor.params); 2163 }; 2128 2164 2129 2165 // ------------------------------------------ … … 2232 2268 html: _toolHtml(onoffGlyph,"Multi State"), 2233 2269 property: _onPropertyOnOffButton, 2234 widgetdisplay: function(widget,bEdit) { 2235 var status = 0; 2236 return "<button {3} id='{0}' type='button' style='color:{7};' class='{1} btn btn-default' aria-label='Run Scene' onclick='UPnPHelper.UPnPAction( {0}, \"{4}\", \"{5}\", {6} )' >{2}</button>".format( 2270 widgetdisplay: function(widget,bEdit) { 2271 var status=0; 2272 if (widget.properties.deviceid>0) 2273 { 2274 status = VeraBox.getStatus(widget.properties.deviceid, widget.properties.service, widget.properties.variable); 2275 if ((status==undefined) || (status==false) || (status=='0') ) 2276 status = 0; 2277 else if ((status=='true') || (status=='1') || (status>=1)) 2278 status = 1; 2279 if (widget.properties.inverted==true) 2280 status = 1-status; 2281 } 2282 return "<button {3} id='{0}' type='button' style='color:{4};' class='{1} btn btn-default' aria-label='Run Scene' onclick='UIManager.onoffOnClick( {5})' >{2}</button>".format( 2237 2283 widget.properties.deviceid, // id 2238 2284 'altui-widget-2statebtn', // class 2239 2285 onoffGlyph, // content 2240 2286 (bEdit==true)?'disabled':'', // editmode 2241 widget.properties.service, // action service 2242 widget.properties.action, // action name 2243 JSON.stringify(widget.properties.params), // action parameter 2244 (status==0) ? 'red' : 'green' // status & color of button 2287 // widget.properties.service, // action service 2288 // widget.properties.action, // action name 2289 // JSON.stringify(widget.properties.params), // action parameter 2290 (status==0) ? 'red' : 'green', // status & color of button 2291 widget.id 2245 2292 ); 2246 2293 }, … … 2249 2296 service:'', // display state service 2250 2297 variable:'', // display state variable 2298 inverted:0, // inverted to that onstate is value 0 2251 2299 labels: [], // 0:onlabel , 1:offlabel 2252 2300 action_off: { … … 2290 2338 }; 2291 2339 2340 function _getActivePageName() { 2341 var pagename = $("#altui-page-tabs li.active").prop('id'); 2342 return pagename.substring( "altui-page-".length); 2343 }; 2344 2292 2345 function _createPageTabsHtml( bEditMode ) { 2293 2346 var actions = ""; … … 2365 2418 stoprefreshModes : _stoprefreshModes, 2366 2419 refreshModes : _refreshModes, 2420 2421 // custom panel widget callbacks 2422 onoffOnClick : _onoffOnClick, 2367 2423 2368 2424 //drawing functions … … 3063 3119 3064 3120 pageEditPages: function () 3065 { 3066 function _getActivePageName() { 3067 var pagename = $("#altui-page-tabs li.active").prop('id'); 3068 return pagename.substring( "altui-page-".length); 3069 }; 3070 3121 { 3071 3122 function _pagePageProperty(pagename) { 3072 3123 var propertyline = ""; … … 3277 3328 $(".altui-leftnav .altui-widget").draggable({ 3278 3329 // containment: ".altui-custompage-canvas", 3279 //grid: [ 5,5 ],3330 grid: [ 5,5 ], 3280 3331 helper: "clone", 3281 3332 cursorAt: { left: 5 }, 3282 snap: true,3283 snapMode: "inner",3284 snapTolerance: 20,3333 // snap: true, 3334 // snapMode: "inner", 3335 // snapTolerance: 20, 3285 3336 revert: "invalid" 3286 3337 }); … … 3305 3356 var widgetid = $(this).prop('id'); 3306 3357 var widget=PageManager.getWidgetByID( page, widgetid ); 3358 // apply defaults 3359 widget.properties = $.extend(true,{}, tool.properties, widget.properties); 3307 3360 (tool.property)( widget ); 3308 3361 }
Note: See TracChangeset
for help on using the changeset viewer.