Skip to content

Commit d6dec80

Browse files
committed
Make the code compatible with following version of OS
1 parent 807a9f7 commit d6dec80

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

OpenSilver.Samples.TelerikUI/OpenSilver.Samples.TelerikUI.Browser/Interop/UnmarshalledJavaScriptExecutionHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@ public object ExecuteJavaScriptWithResult(string javaScriptToExecute)
2323
{
2424
return _runtime.InvokeUnmarshalled<string, object>(MethodName, javaScriptToExecute);
2525
}
26+
27+
public TResult InvokeUnmarshalled<T0, TResult>(string identifier, T0 arg0)
28+
{
29+
return _runtime.InvokeUnmarshalled<T0, TResult>(identifier, arg0);
30+
}
2631
}
2732
}

OpenSilver.Samples.TelerikUI/OpenSilver.Samples.TelerikUI/MainPage.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void ViewSourceCode(UIElement controlThatDisplaysTheSourceCode)
9898
RowThatContainsThePage.Height = new GridLength(0.5d, GridUnitType.Star);
9999
RowThatContainsTheGridSplitter.Height = new GridLength(5d);
100100
RowThatContainsTheSourceCodePane.Height = new GridLength(0.5d, GridUnitType.Star);
101-
GridSplitter1.ResizeDirection = GridSplitter.GridResizeDirection.Rows;
102101
GridSplitter1.Visibility = Visibility.Visible;
103102
SourceCodePane.Visibility = Visibility.Visible;
104103
}

OpenSilver.Samples.TelerikUI/OpenSilver.Samples.TelerikUI/Other/Internal/MasonryPanelWithProgressiveLoading.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Windows.Controls;
77
using System.Windows;
8+
using System.Collections.Specialized;
89

910
namespace OpenSilver.Samples.TelerikUI
1011
{
@@ -14,21 +15,37 @@ namespace OpenSilver.Samples.TelerikUI
1415
/// </summary>
1516
public class MasonryPanelWithProgressiveLoading : Panel
1617
{
17-
object _wall = null;
18-
1918
/// <summary>
2019
/// Initializes a new instance of MasonryPanel class.
2120
/// </summary>
2221
public MasonryPanelWithProgressiveLoading() : base()
2322
{
2423
base.EnableProgressiveRendering = true;
24+
//ProgressiveRenderingChunkSize = 1;
25+
Children.CollectionChanged += OnChildrenCollectionChanged;
26+
}
27+
28+
private void OnChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
29+
{
30+
if (args.Action == NotifyCollectionChangedAction.Add)
31+
{
32+
foreach (var child in args.NewItems.OfType<FrameworkElement>())
33+
{
34+
child.Loaded += OnChildLoaded;
35+
}
36+
}
37+
}
38+
39+
private void OnChildLoaded(object sender, RoutedEventArgs e)
40+
{
41+
UpdateMasonryPanel();
2542
}
2643

2744
void UpdateMasonryPanel()
2845
{
2946
object thisDiv = CSHTML5.Interop.GetDiv(this);
3047

31-
_wall = CSHTML5.Interop.ExecuteJavaScript(@"
48+
CSHTML5.Interop.ExecuteJavaScript(@"
3249
(function() { //we make this a function so that we can get a return type
3350
var thisInnerDiv = $0.children[0]; //this is the div that contains all the children.
3451
@@ -64,10 +81,5 @@ static MasonryPanelWithProgressiveLoading()
6481
*/
6582
(function(e,t){""use strict"";function i(e){return new RegExp(""(^|\\s+)""+e+""(\\s+|$$)"")}function d(e,t,n){if(n.indexOf(""%"")===-1)return n;var r=e.style,i=r.width,s;return r.width=n,s=t.width,r.width=i,s}function v(e,t,n){var r=t!==""height"",i=r?e.offsetWidth:e.offsetHeight,s=r?""Left"":""Top"",o=r?""Right"":""Bottom"",u=f(e),a=parseFloat(u[""padding""+s])||0,l=parseFloat(u[""padding""+o])||0,c=parseFloat(u[""border""+s+""Width""])||0,h=parseFloat(u[""border""+o+""Width""])||0,v=u[""margin""+s],m=u[""margin""+o],g,y;p||(v=d(e,u,v),m=d(e,u,m)),g=parseFloat(v)||0,y=parseFloat(m)||0;if(i>0)n?i+=g+y:i-=a+l+c+h;else{i=u[t];if(i<0||i===null)i=e.style[t]||0;i=parseFloat(i)||0,n&&(i+=a+l+g+y+c+h)}return i}function m(t,n,r){t.addEventListener?t.addEventListener(n,r,!1):t.attachEvent&&(t[""e""+n+r]=r,t[n+r]=function(){t[""e""+n+r](e.event)},t.attachEvent(""on""+n,t[n+r]))}function g(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&(e.detachEvent(""on""+t,e[t+n]),e[t+n]=null,e[""e""+t+n]=null)}function y(e,t){if(!e)return;this.element=e,this.options={};for(var n in y.defaults)this.options[n]=y.defaults[n];for(n in t)this.options[n]=t[n];this._create(),this.build()}var n=e.document,r=""classList""in n.createElement(""div""),s=r?function(e,t){return e.classList.contains(t)}:function(e,t){return i(t).test(e.className)},o=r?function(e,t){e.classList.add(t)}:function(e,t){s(e,t)||(e.className=e.className+"" ""+t)},u=r?function(e,t){e.classList.remove(t)}:function(e,t){e.className=e.className.replace(i(t),"" "")},a=n.defaultView,f=a&&a.getComputedStyle?function(e){return a.getComputedStyle(e,null)}:function(e){return e.currentStyle},l=n.getElementsByTagName(""body"")[0],c=n.createElement(""div""),h=l||n.createElement(""body"");c.style.marginTop=""1%"",h.appendChild(c);var p=f(c).marginTop!==""1%"";h.removeChild(c);var b=[""position"",""height""];y.defaults={isResizable:!0,gutterWidth:0,isRTL:!1,isFitWidth:!1},y.prototype={_getBricks:function(e){var t;for(var n=0,r=e.length;n<r;n++)t=e[n],t.style.position=""absolute"",o(t,""masonry-brick""),this.bricks.push(t)},_create:function(){this.reloadItems();var t=this.element.style;this._originalStyle={};for(var n=0,r=b.length;n<r;n++){var i=b[n];this._originalStyle[i]=t[i]||""""}this.element.style.position=""relative"",this.horizontalDirection=this.options.isRTL?""right"":""left"",this.offset={};var s=f(this.element),u=this.options.isRTL?""paddingRight"":""paddingLeft"";this.offset.y=parseFloat(s.paddingTop)||0,this.offset.x=parseFloat(s[u])||0,this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth==""function"";var a=this;setTimeout(function(){o(a.element,""masonry"")}),this.options.isResizable&&m(e,""resize"",function(){a._handleResize()})},build:function(e){this._getColumns(),this._reLayout(e)},_getColumns:function(){var e=this.options.isFitWidth?this.element.parentNode:this.element,t=v(e,""width"");this.columnWidth=this.isFluid?this.options.columnWidth(t):this.options.columnWidth||v(this.bricks[0],""width"",!0)||t,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((t+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},reloadItems:function(){this.bricks=[],this._getBricks(this.element.children)},_reLayout:function(e){var t=this.cols;this.colYs=[];while(t--)this.colYs.push(0);this.layout(this.bricks,e)},layout:function(e,t){if(!e||!e.length)return;var n,r,i,s,o,u,a;for(var f=0,l=e.length;f<l;f++){n=e[f];if(n.nodeType!==1)continue;r=Math.ceil(v(n,""width"",!0)/this.columnWidth),r=Math.min(r,this.cols);if(r===1)a=this.colYs;else{i=this.cols+1-r,a=[];for(u=0;u<i;u++)o=this.colYs.slice(u,u+r),a[u]=Math.max.apply(Math,o)}var c=Math.min.apply(Math,a);for(var h=0,p=a.length;h<p;h++)if(a[h]===c)break;n.style.top=c+this.offset.y+""px"",n.style[this.horizontalDirection]=this.columnWidth*h+this.offset.x+""px"";var d=c+v(n,""height"",!0),m=this.cols+1-p;for(u=0;u<m;u++)this.colYs[h+u]=d}var g={};this.element.style.height=Math.max.apply(Math,this.colYs)+""px"";if(this.options.isFitWidth){var y=0;f=this.cols;while(--f){if(this.colYs[f]!==0)break;y++}this.element.style.width=(this.cols-y)*this.columnWidth-this.options.gutterWidth+""px""}t&&t.call(e)},_handleResize:function(){function t(){e.resize(),e._resizeTimeout=null}var e=this;this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(t,100)},resize:function(){var e=this.cols;this._getColumns(),(this.isFluid||this.cols!==e)&&this._reLayout()},reload:function(e){this.reloadItems(),this.build(e)},appended:function(e,t,n){var r=this,i=function(){r._appended(e,n)};if(t){var s=v(this.element,""height"")+""px"";for(var o=0,u=e.length;o<u;o++)e[o].style.top=s;setTimeout(i,1)}else i()},_appended:function(e,t){this._getBricks(e),this.layout(e,t)},destroy:function(){var t;for(var n=0,r=this.bricks.length;n<r;n++)t=this.bricks[n],t.style.position="""",t.style.top="""",t.style.left="""",u(t,""masonry-brick"");var i=this.element.style;r=b.length;for(n=0;n<r;n++){var s=b[n];i[s]=this._originalStyle[s]}u(this.element,""masonry""),this.resizeHandler&&g(e,""resize"",this.resizeHandler)}},y.getWH=v,e.Masonry=y})(window);");
6683
}
67-
68-
protected override void INTERNAL_OnChildProgressivelyLoaded()
69-
{
70-
UpdateMasonryPanel();
71-
}
7284
}
7385
}

0 commit comments

Comments
 (0)