⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTotalWidth(el){ | |
var width = el.width(); | |
var padding = parseInt(el.css("padding-left"), 10) + parseInt(el.css("padding-right"), 10); | |
var margin = parseInt(el.css("margin-left"), 10) + parseInt(el.css("margin-right"), 10); | |
var border = parseInt(el.css("borderLeftWidth"), 10) + parseInt(el.css("borderRightWidth"), 10); | |
return width + padding + margin + border; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Responsive score table | |
*/ | |
.clearfix:before, | |
.clearfix:after { content: " "; display: table; } | |
.clearfix:after { clear: both; } | |
* { box-sizing: border-box; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* app template | |
*/ | |
var app = {} | |
app.settings = { | |
init_msg : "Thanks Kostas.\nYou are awesome!" | |
} | |
app.consolefix = function(){ | |
var self = this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Short-circuit evaluation AKA lazy assignment | |
*/ | |
var a; | |
var b = null; | |
var c = undefined; | |
var d = 4; | |
var e = 'five'; | |
var f = a || b || c || d || e; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set value of a var based on condition | |
*/ | |
var enabled = (true) ? "YES" : "NO" // YES | |
var status = (enabled == "YES") ? "ENABLED" : "DISABLED" // ENABLED |
Some times we want to get data from a function that isn't ready on time, and it's response is delayed. Those functions are called Asynchronous.
var profile = $.get('http://graph.facebook.com/kapenekos',
function(response){
console.log(response)
return response
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A faster javascript loop | |
*/ | |
var fruits = ['orange', 'apple', 'banana', 'pear', 'peach', 'cherry']; | |
var i = fruits.length; | |
while(i--) { | |
console.log(fruits[i]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple javascript function template; | |
*/ | |
// Define the function | |
var functionName = function(args){ | |
var options; | |
var exec; | |
if (typeof arguments[0] == "object") { | |
options = arguments[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple javascript app template; | |
*/ | |
// assuming your app is called app | |
var app = { | |
settings: { | |
example : true, | |
example2: '' | |
}, | |
myfunction: function(){ |