Skateside
Privileged
-
Joined
-
Last visited
Reputation Activity
-
Skateside got a reaction from BrowserBugs in CSS Issue - Only First Media Query WorkingI wonder if that's a carriage return ...
You see, when typewriters existed, "new line" and "carriage return" were two commands. When hitting the "enter" key, some operating systems sent both commands to properly emulate the experience. This is why the symbol on the "Return" key is ...
... oh, yeah, solutions ...
Dude, this is Prepros. It compiles files such as LESS, SASS, JavaScript, Coffeescript ... more useful is the fact that it can compress CSS files and watch your folder (so saving in Dreamweaver will automatically compress your file). The minified file wouldn't have that weird character in it (would load faster too because it's a smaller file). To top it all off, Prepros is free. Might be worth a shot.
-
Skateside got a reaction from Demonolith in HTML5 Anchor - Name tag doesn't pass W3C ValidatorTry removing that "scripts/smooth.pack.js" script. I think it's trying to do the job and possibly causing issues. You can find plugins that do the same job and probably work better, if you need the animation at all.
-
Skateside got a reaction from rbrtsmith in Video slider scaling problems - CSSOnly thing to add to what rbrtsmith said is that the padding should be 56.25% for 16:9 videos (9 / 16 = 0.5625, x 100 = 56.25) and 75% for 4:3 videos (3 / 4 = 0.75, x 100 = 75) although 16:9 is the most common aspect ratio online.
-
Skateside got a reaction from Lyndsey in JavaScript variable scoping -- keeping the global cleanLike any other design pattern, the IIFE has its pro's and con's. There's no reason they can't be nested, but frequently it's unnecessary. In terms of working with multiple devs, the issue that the pattern you displayed (other than the SyntaxError - I'll get to that) is that many people will be trying to modify the same code. That will cause headaches at best and merge collisions at worst.
A better solution would be to collate multiple files all referencing a common namespace. Each developer would work in his or her own file, and an IIFE for each part of the code would keep scope contained. It would look something like this:
// Base file var MYAPP = {}; // Dev 1's file MYAPP.module1 = (function () { return { }; }()); // Dev 2's file MYAPP.module2 = (function () { return { }; }());
Modules would either be started manually or using some kind of autoloader. This pattern gained popularity when it got the name The Yahoo Module Pattern and it's still widely used today.
Now - that SyntaxError I mentioned. Your first line looks like this:
var App = (function($, d, w, 'undefined'){ The string 'undefined' should be an argument name. The first line should look like this:
var App = (function($, d, w, undefined){ It's worth pointing out that in 5 or 6 years of professional JavaScript writing, I have never seen anyone write var undefined = true;
-
Skateside got a reaction from rbrtsmith in JavaScript variable scoping -- keeping the global cleanLike any other design pattern, the IIFE has its pro's and con's. There's no reason they can't be nested, but frequently it's unnecessary. In terms of working with multiple devs, the issue that the pattern you displayed (other than the SyntaxError - I'll get to that) is that many people will be trying to modify the same code. That will cause headaches at best and merge collisions at worst.
A better solution would be to collate multiple files all referencing a common namespace. Each developer would work in his or her own file, and an IIFE for each part of the code would keep scope contained. It would look something like this:
// Base file var MYAPP = {}; // Dev 1's file MYAPP.module1 = (function () { return { }; }()); // Dev 2's file MYAPP.module2 = (function () { return { }; }());
Modules would either be started manually or using some kind of autoloader. This pattern gained popularity when it got the name The Yahoo Module Pattern and it's still widely used today.
Now - that SyntaxError I mentioned. Your first line looks like this:
var App = (function($, d, w, 'undefined'){ The string 'undefined' should be an argument name. The first line should look like this:
var App = (function($, d, w, undefined){ It's worth pointing out that in 5 or 6 years of professional JavaScript writing, I have never seen anyone write var undefined = true;
-
Skateside got a reaction from Wynn in JavaScript variable scoping -- keeping the global cleanLike any other design pattern, the IIFE has its pro's and con's. There's no reason they can't be nested, but frequently it's unnecessary. In terms of working with multiple devs, the issue that the pattern you displayed (other than the SyntaxError - I'll get to that) is that many people will be trying to modify the same code. That will cause headaches at best and merge collisions at worst.
A better solution would be to collate multiple files all referencing a common namespace. Each developer would work in his or her own file, and an IIFE for each part of the code would keep scope contained. It would look something like this:
// Base file var MYAPP = {}; // Dev 1's file MYAPP.module1 = (function () { return { }; }()); // Dev 2's file MYAPP.module2 = (function () { return { }; }());
Modules would either be started manually or using some kind of autoloader. This pattern gained popularity when it got the name The Yahoo Module Pattern and it's still widely used today.
Now - that SyntaxError I mentioned. Your first line looks like this:
var App = (function($, d, w, 'undefined'){ The string 'undefined' should be an argument name. The first line should look like this:
var App = (function($, d, w, undefined){ It's worth pointing out that in 5 or 6 years of professional JavaScript writing, I have never seen anyone write var undefined = true;
-
Skateside got a reaction from welshhuw in Using :after isn't workingHave you tried putting position: relative; on #masthead nav?
I'll try reading your post fully first ...
Your problem is your clear fix, .container:after, .row:after, this has visibility:hidden on it, causing the :after on #masthead nav to be invisible. Try creating another element around your nav and putting the container class on that.
-
Skateside got a reaction from teodora in Using :after isn't workingHave you tried putting position: relative; on #masthead nav?
I'll try reading your post fully first ...
Your problem is your clear fix, .container:after, .row:after, this has visibility:hidden on it, causing the :after on #masthead nav to be invisible. Try creating another element around your nav and putting the container class on that.
-
Skateside got a reaction from heydanreeves in Noob alert! - selecting a certain <a> tag in a listJust to provide a difference of opinion here, I almost never use IDs any more (even for JavaScript). I prefer using classes because it makes the CSS more modular and easier to work with owing to the smaller specificity. Having read up on SMACSS, I live the idea of sub-classing my modules and that's much harder with IDs.
I'm not saying that IDs are bad things, just that there are those of us out there who chose not to use them.
-
Skateside got a reaction from Nillervision in What is object oriented programming?I know this may seem petty, but we have a convention in JavaScript when it comes to using constructor functions like the one in your example - we always write them with a leading capital letter and train ourselves to see a leading capital and instinctively write new. This helps us get around issues that are caused with implied globals and a default context.
The following piece of code is perfectly valid JavaScript and will run without errors (unless you've got "Strict mode" enabled):
// Forgot to write "new" var poster = forumMember('Nillervision', 'learning', 'confused');In this situation, this will refer to window, our global scope, rather than an instance. Therefore, your properties and methods become global variables. Calling that function again will update those global variables and cause huge amounts of confusion when poster.name and poster1.name are both "Skateside".
Other than that, everything you're saying is correct. You can also set methods and properties using the prototype property of a function, so instead of constantly re-making your revealProperties method, you can simply create it once using the style below:
function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype.revealProperties = function () { return this.name + ' ' + this.intention + ' ' + this.mood; };I you have a lot of methods to create, you can also set prototype to be an object literal with all your methods defined therein. This next snippit does exactly the same as the one just above:function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype = { revealProperties: function () { return this.name + ' ' + this.intention + ' ' + this.mood; } }; -
Skateside got a reaction from andy9l in What is object oriented programming?I know this may seem petty, but we have a convention in JavaScript when it comes to using constructor functions like the one in your example - we always write them with a leading capital letter and train ourselves to see a leading capital and instinctively write new. This helps us get around issues that are caused with implied globals and a default context.
The following piece of code is perfectly valid JavaScript and will run without errors (unless you've got "Strict mode" enabled):
// Forgot to write "new" var poster = forumMember('Nillervision', 'learning', 'confused');In this situation, this will refer to window, our global scope, rather than an instance. Therefore, your properties and methods become global variables. Calling that function again will update those global variables and cause huge amounts of confusion when poster.name and poster1.name are both "Skateside".
Other than that, everything you're saying is correct. You can also set methods and properties using the prototype property of a function, so instead of constantly re-making your revealProperties method, you can simply create it once using the style below:
function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype.revealProperties = function () { return this.name + ' ' + this.intention + ' ' + this.mood; };I you have a lot of methods to create, you can also set prototype to be an object literal with all your methods defined therein. This next snippit does exactly the same as the one just above:function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype = { revealProperties: function () { return this.name + ' ' + this.intention + ' ' + this.mood; } }; -
Skateside got a reaction from Lyndsey in What is object oriented programming?I know this may seem petty, but we have a convention in JavaScript when it comes to using constructor functions like the one in your example - we always write them with a leading capital letter and train ourselves to see a leading capital and instinctively write new. This helps us get around issues that are caused with implied globals and a default context.
The following piece of code is perfectly valid JavaScript and will run without errors (unless you've got "Strict mode" enabled):
// Forgot to write "new" var poster = forumMember('Nillervision', 'learning', 'confused');In this situation, this will refer to window, our global scope, rather than an instance. Therefore, your properties and methods become global variables. Calling that function again will update those global variables and cause huge amounts of confusion when poster.name and poster1.name are both "Skateside".
Other than that, everything you're saying is correct. You can also set methods and properties using the prototype property of a function, so instead of constantly re-making your revealProperties method, you can simply create it once using the style below:
function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype.revealProperties = function () { return this.name + ' ' + this.intention + ' ' + this.mood; };I you have a lot of methods to create, you can also set prototype to be an object literal with all your methods defined therein. This next snippit does exactly the same as the one just above:function ForumMember (name, intention, mood) { this.name = name; this.intention = intention; this.mood = mood; } ForumMember.prototype = { revealProperties: function () { return this.name + ' ' + this.intention + ' ' + this.mood; } }; -
Skateside got a reaction from Lyndsey in What is object oriented programming?I'm still learning this myself so my description may be a little ropy but hopefully it should help.
Object Oriented Programming is the process of creating objects that handle specific tasks in your application. It's generally seen as the way forward for a couple of important reasons. It separates the interface (the method names) from the implementation (what the methods actually do) - for example, a method called "hide" will clearly make something invisible, but whether that's done by setting "display:none;", "clip:rect(1px, 1px, 1px, 1px);position:absolute;" or even removing the element entirely is up to the programmer.
The other key point is code re-use. When you have two elements that do essentially the same thing, but one has a couple of differences, an object-orientated style will allow you to create an object for the first, sub-class and expand it for the second. Instead of re-writing code you've already figured out, or passing in booleans all the time, you've got an easy-to-follow chunk of code. This also helps with any debugging as solving a bug in the parent object usually fixes it in the children too.
The book that got me thinking along these lines in JavaScript was Pro JavaScript Design Patterns - it's full of examples of object orientated JavaScript with the added bonus of describing a few of the design patterns that OOP lends itself to and examples of when to use them.
-
Skateside got a reaction from Nillervision in What is object oriented programming?I'm still learning this myself so my description may be a little ropy but hopefully it should help.
Object Oriented Programming is the process of creating objects that handle specific tasks in your application. It's generally seen as the way forward for a couple of important reasons. It separates the interface (the method names) from the implementation (what the methods actually do) - for example, a method called "hide" will clearly make something invisible, but whether that's done by setting "display:none;", "clip:rect(1px, 1px, 1px, 1px);position:absolute;" or even removing the element entirely is up to the programmer.
The other key point is code re-use. When you have two elements that do essentially the same thing, but one has a couple of differences, an object-orientated style will allow you to create an object for the first, sub-class and expand it for the second. Instead of re-writing code you've already figured out, or passing in booleans all the time, you've got an easy-to-follow chunk of code. This also helps with any debugging as solving a bug in the parent object usually fixes it in the children too.
The book that got me thinking along these lines in JavaScript was Pro JavaScript Design Patterns - it's full of examples of object orientated JavaScript with the added bonus of describing a few of the design patterns that OOP lends itself to and examples of when to use them.
-
Skateside got a reaction from ELITE in ajax count files in directoryif (Array.isArray(data.files)) { data.files.forEach(function (file) { console.log(file); }); } Essentially, that's how you want to do it.
-
Skateside got a reaction from wellerweb in Javascript: Textarea maxlength and carrying over extra charactersWhat you essentially need to do is put together a string with that combination of values, check it's length and if it's too long, populate a second string with the extra bit before reducing the size of the first string.
I've put together an example showing how to do this, feel free to use it: Skateside's example
-
Skateside got a reaction from JackDanielTracy in How to handle bad feedbackSo a bunch of creative Irish guys got bored of clients giving them really retarded feedback. Instead of moaning about it, they made posters, sold them and donated the proceeds to a children's charity.
Check it out
-
Skateside got a reaction from Barth in Mastering JavascriptDownvote! Dislike!
... we need a button for that ...
Pure Javascript is far more versatile than jQuery, jQuery is pretty limited to the browser whereas Javascript is appearing in browsers, serves, TVs, mobile phones, Windows 8 ... there's no reason to limit yourself to a browser-based library like that.
Back to the question at hand, there are a few good books I can recommend (all with handy links to Amazon). Each of them generally keep away from code examples using libraries and their advice can be used on any platform.
Javascript: The Good Parts by Douglas Crockford - this is a must read generally. Crockford defines a sub-set of Javascript that stays away from the language's more esoteric or confusing elements. Having read this book (and cyber-stalked Doug through YUI theatre), I found my code less confusing to other people (including myself) and better laid out. I can read old code much better now than I could in years gone by.
Pro Javascript Design Patterns by Ross Harmes and Dustin Diaz - this was the book that got me thinking along object oriented lines and finally understanding that programming concept. The book goes through classic programing patterns and just knowing about those helped me code in a more logical way, opening up inheritance to me for the first time.
Maintainable Javascript by Nicholas C Zakas - I'm only part way through this book and already it's helped me make my code more maintainable. This has the advantage of making more sense in the future as well as maintaining large applications. This book also has some great advice about coding Javascript in a team.
I hope that helps
-
Skateside got a reaction from Jock in Mastering JavascriptDownvote! Dislike!
... we need a button for that ...
Pure Javascript is far more versatile than jQuery, jQuery is pretty limited to the browser whereas Javascript is appearing in browsers, serves, TVs, mobile phones, Windows 8 ... there's no reason to limit yourself to a browser-based library like that.
Back to the question at hand, there are a few good books I can recommend (all with handy links to Amazon). Each of them generally keep away from code examples using libraries and their advice can be used on any platform.
Javascript: The Good Parts by Douglas Crockford - this is a must read generally. Crockford defines a sub-set of Javascript that stays away from the language's more esoteric or confusing elements. Having read this book (and cyber-stalked Doug through YUI theatre), I found my code less confusing to other people (including myself) and better laid out. I can read old code much better now than I could in years gone by.
Pro Javascript Design Patterns by Ross Harmes and Dustin Diaz - this was the book that got me thinking along object oriented lines and finally understanding that programming concept. The book goes through classic programing patterns and just knowing about those helped me code in a more logical way, opening up inheritance to me for the first time.
Maintainable Javascript by Nicholas C Zakas - I'm only part way through this book and already it's helped me make my code more maintainable. This has the advantage of making more sense in the future as well as maintaining large applications. This book also has some great advice about coding Javascript in a team.
I hope that helps
-
Skateside got a reaction from Hostwinds in How to handle bad feedbackSo a bunch of creative Irish guys got bored of clients giving them really retarded feedback. Instead of moaning about it, they made posters, sold them and donated the proceeds to a children's charity.
Check it out
-
Skateside reacted to Renaissance-Design in WaterMark TextBox With CSS3 ?Placeholder is the way to go because it's forward-compatible. Polyfill for older browsers with Javascript.
-
Skateside got a reaction from zed in PHP create PDFYup, completely possible. PHP has in-built functions for doing such things, but personally I prefer using FPDF to generate it. It's a little verbose but very easy to add extras to it.
Check it out: FPDF
-
Skateside got a reaction from Renaissance-Design in if JS is disabled use this stylesheet.A pretty common tactic that's around these days is the change the class on the <html> element:
<!-- In your HTML --> <html class="no-js"> // In your Javascript document.documentElement.className = 'js';
Now any rule that starts with .no-js won't be seen if the user has Javascript enabled
-
Skateside reacted to evu in CSS Challengehttp://jsfiddle.net/K5nFM/1/
This?
~evu.
eD: To get it working in IE7 you'll need something like http://ie7-js.googlecode.com/svn/test/index.html
-
Skateside got a reaction from Renaissance-Design in CSS ChallengeI've got a fun little challenge for everyone here. Those who frequent the IRC will know that I've been playing with slanted headings. These have now evolved into wrap-around headings; currently they look like this fiddle: Skateside's awesome fiddle.
Here's the challenge: can anyone think of a way to make the slant stretch to the full height when that heading double-lines?
The only rule is that you're not allowed to add any more elements (except a rogue <br> for testing). It should degrade in older browsers (I won't insist that it has to work perfectly in IE7, although you'll be hailed as a CSS god if you can pull it off). The background of the <body> tag can change or even be patterned, the background of the <article> will always be a solid colour (although if you can successfully render this on any background, more CSS god-like recognition will be heading your way)
Nothing to win here except bragging rights. Wanna play?