Skip to content

Commit

Permalink
TreeView, Core, Dom
Browse files Browse the repository at this point in the history
TreeView
 - Reverted buggy fix to ContextMenu positioning.
   Bug committed in 863891f.

Dom
 - Added missing type checking of function arguments.

Core
 - Clean up - removed old notes/comments.
  • Loading branch information
Jemt committed Jan 16, 2016
1 parent ef97a7d commit 37c5f97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Controls/TreeView/TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Fit.Controls.TreeView = function(ctlId)
if (ev.keyCode === 93 || (Fit.Events.GetModifierKeys().Shift === true && ev.keyCode === 121)) // Context menu button or Shift+F10
{
var label = node.GetDomElement().querySelector("span");
var pos = Fit.Dom.GetPosition(label, true); // True argument = get position relative to viewport rather than document
var pos = Fit.Dom.GetPosition(label);

pos.X = pos.X + label.offsetWidth - 10;
pos.Y = pos.Y + label.offsetHeight - 5;
Expand Down
34 changes: 0 additions & 34 deletions Core/Core.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
// Get most recent version from GitHub: https://github.com/Jemt/Fit.UI

// TODO (entire framework):
// - Use of ev.keyCode is deprecated and must be replaced !
// Consider implementing Fit.Events.GetKeyCode(ev)
// Search and replace .keyCode, .charCode, and .which
// - Get rid of Fit.Validation.ExpectStringValue(..) - do not mix type checking and value validation!
// - Perhaps Fit.Core.Extend should be replaced by inheritance using prototyping.
// - Fit.Validation.ExpectDomElement(..) is sometimes too vague, e.g. when expecting HTMLInputElement
// Use Fit.Validation.ExpectInstance(elm, HTMLInputElement) instead !
// - ControlBase.Value should always "communicate" using strings.
// Individual controls could simply implement their own value getter/setter.
// Using specialized return values would require the programmer to know about
// the design of the Control anyways, so a specialized function is alright.
// - Consistency in event handlers - always pass Sender and EventArgs.
// EventArgs allows us to add more information later.
// - Search and replace elm.appendChild(c) and elm.removeChild(c)
// with Fit.Dom.Add(elm, c) and Fit.dom.Remove(c) for consistency
// - Replace "inherit" and "inherting" with "extend" and "extending"
// since its closer to extending/mixins rather than inheritance/prototyping.
// - Replace "firering" with correct word; "firing"
// - Create HttpRequest interface and have Request and DotNetRequest extend from it
// - Create WebServiceControl base class, have WSListView, WSTreeView, and WSDropDown extend from it
// - Type checking (Fit.Validation) has cross frame issues. Passing objects between frames
// breaks instanceof because frames do not share the same prototypes. Interesting article:
// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray
// - Fit.Events.AddMutationObserver <= Should use native browser mutation observer if available
// - ControlBase._internal.Data(..): Setter should force IE8 to repaint by adding and removing
// a fake CSS class on element returned by GetDomElement(). TreeView manually calls a
// repaint() function that does exactly that, but currently not all data-attributes can
// reliably be used with CSS selectors with IE8 since the browser do not repaint as expected.
// Investigate whether this will work with TreeView, and if possible get rid of repaint() function
// within TreeView.

/// <container name="Fit.Core">
/// Core features extending the capabilities of native JS
/// </container>
Expand Down
14 changes: 14 additions & 0 deletions Core/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Fit.Dom = {};
/// </function>
Fit.Dom.AddClass = function(elm, cls)
{
Fit.Validation.ExpectDomElement(elm);
Fit.Validation.ExpectStringValue(cls);

if (Fit.Dom.HasClass(elm, cls) === false)
elm.className += ((elm.className !== "") ? " " : "") + cls;
}
Expand All @@ -25,6 +28,9 @@ Fit.Dom.AddClass = function(elm, cls)
/// </function>
Fit.Dom.RemoveClass = function(elm, cls)
{
Fit.Validation.ExpectDomElement(elm);
Fit.Validation.ExpectStringValue(cls);

var arr = elm.className.split(" ");
var newCls = "";

Expand All @@ -44,6 +50,9 @@ Fit.Dom.RemoveClass = function(elm, cls)
/// </function>
Fit.Dom.HasClass = function(elm, cls)
{
Fit.Validation.ExpectDomElement(elm);
Fit.Validation.ExpectStringValue(cls);

var arr = elm.className.split(" ");
var found = false;

Expand All @@ -69,6 +78,9 @@ Fit.Dom.HasClass = function(elm, cls)
/// </function>
Fit.Dom.GetComputedStyle = function(elm, style)
{
Fit.Validation.ExpectDomElement(elm);
Fit.Validation.ExpectStringValue(style);

var res = null;

if (window.getComputedStyle)
Expand Down Expand Up @@ -309,6 +321,8 @@ Fit.Dom.Text = function(elm, value)
/// </function>
Fit.Dom.GetIndex = function(elm)
{
Fit.Validation.ExpectDomElement(elm);

if (!elm.parentElement)
return -1;

Expand Down

0 comments on commit 37c5f97

Please sign in to comment.