public static void LayoutFillHeight(jQueryObject element) { var h = LayoutFillHeightValue(element); string n = h + "px"; if (element.GetCSS("height") != n) element.CSS("height", n); }
public static void LayoutFillHeight(jQueryObject element) { var h = LayoutFillHeightValue(element); string n = h + "px"; if (element.GetCSS("height") != n) element.CSS("height", n); }
/// <summary>Constructor.</summary> public AddPackageView() { // Create buttons. addButton = CreateButton(StringLibrary.Add); cancelButton = CreateButton(StringLibrary.Cancel); // Load the HTML content. RetrieveHtml(ContentUrl, delegate { // Setup children. divInnerSlide = jQuery.Select(CssSelectors.AddPackageInnerSlide); offLeft = divInnerSlide.GetCSS(Css.Left); InitializeTextboxes(); // Insert buttons. addButton.CreateView().Insert(CssSelectors.AddPackageBtnAdd, InsertMode.Replace); cancelButton.CreateView().Insert(CssSelectors.AddPackageBtnCancel, InsertMode.Replace); // Wire up events. Keyboard.Keydown += OnKeydown; // Finish up. isInitialized = true; UpdateState(); SlideOn(null); }); }
public static int LayoutFillHeightValue(jQueryObject element) { var h = 0; element.Parent() .Children() .Not(element) .Each((i, e) => { var q = J(e); if (q.Is(":visible")) { h += q.GetOuterHeight(true); } }); h = element.Parent().GetHeight() - h; if (element.GetCSS("box-sizing") != "border-box") { h = h - (element.GetOuterHeight(true) - element.GetHeight()); } return(h); }
public static int LayoutFillHeightValue(jQueryObject element) { var h = 0; element.Parent() .Children() .Not(element) .Each((i, e) => { var q = J(e); if (q.Is(":visible")) h += q.GetOuterHeight(true); }); h = element.Parent().GetHeight() - h; if (element.GetCSS("box-sizing") != "border-box") h = h - (element.GetOuterHeight(true) - element.GetHeight()); return h; }
private static bool GetCssSize(jQueryObject element, string name, out int size) { size = 0; var cssSize = element.GetCSS(name); if (!Script.IsValue(cssSize)) { return(false); } if (!cssSize.EndsWith("px")) { return(false); } cssSize = cssSize.Substr(0, cssSize.Length - 2); if (!Int32.TryParse(cssSize, out size) || size == 0) { return(false); } return(true); }
private static int GetBorderEdge(jQueryObject element, Edge edge) { if (Script.IsNullOrUndefined(element)) return 0; string value = element.GetCSS(string.Format("border-{0}-width", edge.ToString().ToLocaleLowerCase())); if (string.IsNullOrEmpty(value)) return 0; if (!value.EndsWith(Px)) return 0; return Int32.Parse(value); }
/// <summary>Retrieves whether the element has a position value.</summary> /// <param name="element">The element to examine.</param> public static bool HasPosition(jQueryObject element) { return Script.IsNullOrUndefined(element) ? false : element.GetCSS(Position) != string.Empty; }
/// <summary>Determines whether the element is visible (has any display value other than 'None').</summary> /// <param name="element">The element to display.</param> public static bool IsVisible(jQueryObject element) { return Script.IsNullOrUndefined(element) ? false : element.GetCSS(Display).ToLowerCase() != None; }
private static DimensionsAndPadding GetDimensionsAndPadding(jQueryObject element) { DimensionsAndPadding d = new DimensionsAndPadding(); if (Type.HasMethod(typeof(Window), "getComputedStyle")) { Object computedStyle = Type.InvokeMethod(typeof(Window), "getComputedStyle", element[0], null); if (Type.HasField(computedStyle, "width")) { d.ClientWidth = Number.Parse((string)Type.GetField(computedStyle, "width")); d.ClientHeight = Number.Parse((string)Type.GetField(computedStyle, "height")); d.PaddingTop = Number.Parse((string)Type.GetField(computedStyle, "paddingTop")); d.PaddingRight = Number.Parse((string)Type.GetField(computedStyle, "paddingRight")); d.PaddingBottom = Number.Parse((string)Type.GetField(computedStyle, "paddingBottom")); d.PaddingLeft = Number.Parse((string)Type.GetField(computedStyle, "paddingLeft")); } else { d.ClientWidth = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "width")); d.ClientHeight = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "height")); d.PaddingTop = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "padding-top")); d.PaddingRight = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "padding-right")); d.PaddingBottom = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "padding-bottom")); d.PaddingLeft = Number.Parse((string)Type.InvokeMethod(computedStyle, "getPropertyValue", "padding-left")); } d.ClientWidth += d.PaddingLeft + d.PaddingRight; d.ClientHeight += d.PaddingTop + d.PaddingBottom; return d; } else { // gather parent padding d.ClientWidth = element.GetInnerWidth(); d.ClientHeight = element.GetInnerHeight(); d.PaddingTop = Number.Parse(element.GetCSS("padding-top")); d.PaddingRight = Number.Parse(element.GetCSS("padding-right")); d.PaddingBottom = Number.Parse(element.GetCSS("padding-bottom")); d.PaddingLeft = Number.Parse(element.GetCSS("padding-left")); return d; } }
public static jQueryObject ScrollPagerPlugin(ScrollPagerPluginOptions customOptions) { ScrollPagerPluginOptions defaultOptions = new ScrollPagerPluginOptions(); defaultOptions.pageSize = 10; defaultOptions.currentPage = 1; defaultOptions.holder = ".listcontainer"; defaultOptions.viewport = ""; defaultOptions.pageHeight = 23; defaultOptions.onPageChanged = null; defaultOptions.container = "#listcontainerdiv"; ScrollPagerPluginOptions options = jQuery.ExtendObject <ScrollPagerPluginOptions>(new ScrollPagerPluginOptions(), defaultOptions, customOptions); return(jQuery.Current.Each(delegate(int i, Element element) { jQueryObject selector = jQuery.This; int pageCounter = 1; PositionInfo iPosition = new PositionInfo(); MouseInfo iMouse = new MouseInfo(); Number candidatePageIndex = 0; //this goes through every item in the selector .Children() .Each(delegate(int ic, Element elc) { if (ic < pageCounter * options.pageSize && ic >= (pageCounter - 1) * options.pageSize) { jQuery.This.AddClass("page" + pageCounter); } else { jQuery.This.AddClass("page" + (pageCounter + 1)); pageCounter++; } }); //set and default the slider item height int contHeight = jQuery.Select(options.container).GetHeight(); int sliderItemHeight = contHeight; //show/hide the appropriate regions selector.Children().Hide(); jQuery.Select(".page" + options.currentPage).Show(); //more than one page? if (pageCounter > 1) { //calculate the slider item height sliderItemHeight = (contHeight / pageCounter); //Build pager navigation string pageNav = "<UL class=scrollbar sizcache='4' sizset='13'>"; for (i = 1; i <= pageCounter; i++) { if (i == options.currentPage) { pageNav += "<LI class='currentPage pageItem' sizcache='4' sizset='13'><A class='sliderPage' href='#' rel='" + i + "'></A>"; } else { pageNav += "<LI class='pageNav" + i + " pageItem' sizcache='4' sizset='14'><A class='sliderPage' href='#' rel='" + i + "'></A>"; } } //Create slider item string sliderItem = "<LI class='thumb' sizcache='4' sizset='13' style='top:" + (options.currentPage - 1) * sliderItemHeight + "; height:" + (sliderItemHeight - 3) + "'><A class='sliderThumb' href='#' rel='" + i + "'></A>"; pageNav += sliderItem; pageNav += "</LI></UL>"; if (options.holder == "") { selector.After(pageNav); } else { jQuery.Select(options.holder).Append(pageNav); } //Apply the slider item height jQuery.Select(".pageItem").Height(sliderItemHeight); } jQueryObject oTrack = jQuery.Select(".scrollbar"); jQueryObject oThumb = jQuery.Select(".thumb"); //jQueryObject oViewPort = jQuery.Select(options.viewport); Number maxPos = (oTrack.GetHeight() - oThumb.GetHeight()); jQueryObject pageItemCollection = jQuery.Select(".pageItem a"); Action <jQueryObject> selectPageItem = delegate(jQueryObject pageItem) { string clickedLink = pageItem.GetAttribute("rel"); options.onPageChanged.Invoke(pageItem, new SelectedPageEventArgs(int.Parse(clickedLink))); options.currentPage = int.Parse(clickedLink); //remove current current (!) page jQuery.Select("li.currentPage").RemoveClass("currentPage"); //Add current page highlighting pageItem.Parent("li").AddClass("currentPage"); //hide and show relevant links selector.Children().Hide(); selector.Find(".page" + clickedLink).Show(); }; //Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem) jQueryEventHandler selectPageItemHandler = delegate(jQueryEvent pageItemClickedEvent) { //grab the REL attribute jQueryObject pageItem = jQuery.FromElement(pageItemClickedEvent.CurrentTarget); selectPageItem(pageItem); }; //pager navigation behaviour pageItemCollection.Live("click", selectPageItemHandler); jQueryEventHandler wheel = delegate(jQueryEvent oEvent) { }; jQueryEventHandler drag = delegate(jQueryEvent oEvent) { Number candidatePos = Math.Max(0, (iPosition.Start + ((oEvent.PageY) - iMouse.Start))); iPosition.Now = (candidatePos > maxPos) ? maxPos : candidatePos; candidatePageIndex = Math.Round(iPosition.Now / oThumb.GetHeight()); oThumb.CSS("top", iPosition.Now.ToString());; }; jQueryEventHandler end = null; end = delegate(jQueryEvent oEvent) { jQuery.Document.Unbind("mousemove", drag); jQuery.Document.Unbind("mouseup", end); oThumb.Die("mouseup", end); selectPageItem(jQuery.FromElement(pageItemCollection[candidatePageIndex])); }; jQueryEventHandler start = delegate(jQueryEvent oEvent) { iMouse.Start = oEvent.PageY; string oThumbDir = oThumb.GetCSS("top"); iPosition.Start = (oThumbDir == "auto") ? 0 : int.Parse(oThumbDir); jQuery.Document.Bind("mousemove", drag); jQuery.Document.Bind("mouseup", end); oThumb.Live("mouseup", end); }; Action setEvents = delegate() { oThumb.Live("mousedown", start); oTrack.Live("mouseup", drag); //if (options.scroll != null) //{ // oViewPort[0].AddEventListener("DOMMouseScroll", wheel, false); // oViewPort[0].AddEventListener("mousewheel", wheel, false); //} //else if (options.scroll != null) //{ // oViewPort[0].OnMouseWheel = wheel; //} }; setEvents.Invoke(); })); }