_( "#id .class:3 span" );
_(/*PATH*/); semplify the call stacks to get elements in your HTML code.
In this case i'm looking for all HTML SPAN Elements contained in the Third element identified with class "class" contained in the HTML Element identified with id "id".
Yes it's a mindblow to say but let's examine the small thing:
The HTML Involved:
<div id="id">
<div class="class"></div>
<div class="class"></div>
<div class="class"></div>
<div class="class">
<span></span>
<span></span>
<span></span>► Selected Elements
<span></span>
<span></span>
</div>
<div class="class"></div>
<div class="class"></div>
</div>
The JS Equivalent is:
document.getElementById( "id" ).getElementsByClassName( "class" ).item(3).getElementsByTagName( "span" );At the end you'll get an array of span elements. ( Selected Element )
<div>► Second parent <div>► First parent [SELECTED] <div id="idname"></div> </div> </div>with:
_( " <#idname " );What happen here!? Easy, you selected the <div id="idname"> Element with #idname BUT, using the < symbol before you'll get the PARENT of #idname typed .
_( " <<#idname " );
var el = _( " #idname " );..and you want to browse the path starting from that element, you can use this syntax:
_( el , ".classname:0" );Your saved el will be used as initial HTML element to calc the following path.
<div id="idname">► var el <div class="classname"></div>► Final Selected Element <div class="classname"></div> <div class="classname"></div> <div class="classname"></div> </div>
var el = _( " #idname " ); _( el , ".classname:0" );
_.debug(function(){ // Your code HERE });
_.debug(/*CODE*/); is a fast method wich log in your browser console almost every errors contained in your /*CODE*/.
Example:
var a = 10; _.debug(function(){ a = a / b; });b do not exist and the exception generated will be logged in your console
_.curX; // and _.curY;
Just 2 simple properties. _.curX; and _.curY; will give you the mouse coordinates in your web page DOM.
If you wish to know the coordinates of your mouse in the screen area.. use this properties:
_.scrX; // and _.scrY;
_.scrollTop( "#idname" );
With _.scrollTop( "#idname" ); you can get the space from the desired element to the top of your document page.
The path use the same system of the primary's Agile's method _( " " );
_.scrollTop( "#idname .classname:3 span:0" ); // just an example
_.scrollTo( "#idname" );
With _.scrollTo( "#idname" ); you can set the document scroll to the desired Element.
The path use the same system of the primary's Agile's Path method _( " " );
_.scrollTo( "#idname .classname:3 span:0" ); // just an example
_.scrollTo( "#idname", 100);In this case the document will be scrolled to the element "#idname" + an offset of 100 px (can be positive and negative)
var o1 = { a:0, b:{ x:false, y:"agile" } } var o2 = o1.clone();
A very critical issue in javascript is to CLONING an object (JSON) into an other var.
Let's see why (if that's new for you) using the object o1
An object var can not be cloned/copied like this
var o2 = o1;This o2 isn't a clone, it's a REFERENCE of o1
o2.a = 25;o2.a and o1.a values will BOTH change to 25.
var o = { a:0, b:{ x:false, y:"agile" } } o.assign({ b:{ x:true } });
An handy method wich update given properties to your object
In the above example the value of o.b.x has been updated to TRUE
var myArray = [9, 3, 5, 2, 4, 3, 0, 6, 8, 7]; myArray.sortNum(); // myArray is now sorted // [ 0, 2, 3, 3, 4, 5, 6, 7, 8, 9 ]
JavaScript already have an Array.sort() method. It can sort Numbers, Strings, Objects, etc..
but, if you have to sort a numeric Array you should use this my custom method wich is ~1472.5% faster.
I made this Test page to show you the differences http://jsperf.com/array-sorttest
var myArray = ["banana", "orange", "kiwi", "watermelon", "cherries"]; myArray.move(2, 0); // myArray has changed to // ["kiwi", "banana", "orange", "watermelon", "cherries"]
An handy method wich allow to change the array's elements index.
In the above example the element with index 2 has been changed to 0 setting "kiwi" as the first element of the array
var myArray = ["banana", "orange", "kiwi", "watermelon", "cherries"]; myArray.swap(2, 0); // myArray has changed to // ["kiwi", "orange", "banana", "watermelon", "cherries"]
An handy method wich allow to swap array's elements with index.
In the above example the element with index 2 has been swapped with the element 0 setting "kiwi" as the first element of the array and "banana" the third one.
_.convert( myVar );
Description HERE
_.ani.transition(1000, function(){ // your code here });
HUGE Description HERE
_.ani.range( 50, 100, 0.5 ); // return -> 75
Description HERE
_.browser();
A fast and basic way to know what browser is reading yur code.
if( _.browser() == "FF"){ // Code for FIREFOX } else if( _.browser() == "CH"){ // Code for CHROME } else if( _.browser() == "IE"){ // Code for INTERNET EXPLORERS } else{ // Code For Other Browsers }
_.isset( myVar );
This method check id the variable has been declared before.
Example 1:
if( _.isset(myVar)){ console.log("myVar Exist."); } else{ console.log("myVar has not been declared."); }
myVar has not been declared.
myVar = "something"; if( _.isset(myVar)){ console.log("myVar Exist."); } else{ console.log("myVar has not been declared."); }
myVar Exist.
var resultParams = _.filterURLparams( "par1=1&par2=2&par3=3&par4=4", [ "par2", "par4" ] ); // resultParams = "par1=1&par3=3";
Usefull if you program your website with PHP too.
_.validDate( "mm/dd/yyyy", "11/9/1950" );
Check if the date you typed in is a valid date or not.
Example:
_.validDate( "mm/dd/yyyy", "11/31/2014" );will return "FALSE" ..becouse November do not have 31 days!
_.download( "file_Name.txt", "http://www.mydomain.org/folder/file.txt" );
An easy method wich allow to trigger the download process for everiting you need to be downloaded.
_.curState;
Save the last mouse event. Try click and doubleclick on this document.
_.selectable( element, false );
Using this function allow you to block the HightLight on text of your element.
Example:
<p id="text-selectable"> Lorem ipsum dolor sit amet, consectetur adipiscing elit... </p> <p id="text-unselectable"> Lorem ipsum dolor sit amet, consectetur adipiscing elit... </p>
_.selectable( "#text-selectable", true ); _.selectable( "#text-unselectable", false );Output..
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
var os = _.offset( element ); os.x; // contain the X coordinate os.y; // contain the Y coordinate
With this method you can know the position of every elements in your DOM.
<div id="idname"> <div class="classname"></div> </div>
var os = _.offset( "#indame .classname:0" );os will contain the x / y coordinates of the element "#indame .classname:0" in the DOM.
var os = _.offset( "#indame .classname:0", true );
var os = _.offset( _PATH_ , _PARENTONLY_ );Where..:
var cloneVar = _.clone( varObject );
Description HERE
_.trigger( element, "onclick" );
Description HERE
var trackBar = _.htmlc.track( element, "myTrack" ); trackBar.value // return the trackBar
This simple method create a Track Bar wich will be resized to the element width (or height if it's a vertical trackbar).
let's analyze how it work with an example.:
#idname{ /* CSS rules */ width:250px; }
<div id="idname"></div>Our page have a div with id "idname" width width : 150px and we want to insert a trackBar in it.
var myTB = _.htmlc.track( "#idname", "myTrack" );
myTB.value; // Contain the current TrackBar Value (From 0 to 100)or, if you didn't referenced your TrackBar into a variable, the tb value can be retrived it like this:
_.htmlc.track.get( "myTrack" ).value;If you want to Set by code the value use this function:
_.htmlc.track.set( "myTrack" , 75 ); // 75 is just an example (From 0 to 100)
_.htmlc.track( "#idname", "myTrack" );you can Edit your TrackBar style with CSS using the Name you give like this.:
#agile-tb-myTrack{ } #agile-tb-myTrack-track{ } #agile-tb-myTrack-bar{ } #agile-tb-myTrack-button{ }the first id, #agile-tb-myTrack, reference the object itself.
#agile-tb-myTrack:hover #agile-tb-myTrack-button{ background: rgba(255,255,255,0.9); } #agile-tb-myTrack-track{ background:linear-gradient(90deg,#f00,#0f0); border-radius:100px; } #agile-tb-myTrack-bar{ background:transparent; } #agile-tb-myTrack-button{ width:18px; border-radius:50%; background: rgba(255,255,255,0.7); }
#agile-tb-myTrack-track{ height:10px; top:calc(50% - 5px); box-shadow: inset 0 1px #fff, inset 1px 0 #fff, inset -1px 0 #fff, 0 -1px #222, 0 1px #222, -1px 0 #222, 1px 0 #222; border-radius:2px; } #agile-tb-myTrack-bar{ background:linear-gradient(0deg,#fa0,#fe0); box-shadow:inset 0 5px rgba(255,255,255,0.5); } #agile-tb-myTrack-button{ width:18px; border-radius:50%; background: transparent; box-shadow:none; }
_.htmlc.track( "#idname", "myTrack", "v");the "v" says that the trackbar should be Vertical (the default value is "o" as hOrizontal) and finally, if you wish an inverted trackbar you can write something like this.:
_.htmlc.track( "#idname", "myTrack", true); // or _.htmlc.track( "#idname", "myTrack", "o", true);
_.htmlc.track.get( "myTrack" ).onScroll = function(tb){ // Your code HERE }The onScroll event will be called until the trackbar is being used.
_.htmlc.track.get( "myTrack" ).onChange = function(tb){ // Your code HERE }The onChange event will be called after the user released the trackbar.
var myTB = _.htmlc.track( _PATH_ , _NAME_ , _TYPE_ , _IVERTED_ );Where..:
_.css({ /* CSS rules */ });
Yes, you can Create / Insert / Edit / Delete CSS Styles and rules using this javascript function.
#idname{ color:#222; background:#fff; } .classname{ color:#a00; background:#eee; }With this function the syntax is very similar. To write the same rules you can write something like that:
_.css({ "#idname":{ color:"#222", background:"#fff" }, ".classname":{ color:"#a00", background:"#eee" } });
_.htmlc.colorPicker('myColorPicker','RGBA',function(cp){ // Your Code HERE (CallBack) // cp.value contain the selected Color value });
Ever wanted a simple portable ColorPicker ready to use? even if you're not using chrome's html5 inputs?
Here for you a small and easy ColorPicker.
(double click on the square to select your color)
_.htmlc.colorPicker('myColorPicker','RGBA');"myColorPicker" is the name