With the launch of version 3.0 of Fork CMS, I included some JS improvements. The adjustments made were mostly for consistency and performance reasons. Feel free to contribute at http://github.com/forkcms/forkcms
‣ Declared outside a function, with or without the var keyword ‣ Declared inside a function, without the var keyword, but only once the function is called Scope: global Variables
we're in the global scope, outside any function jsFrontend.faq.feedback = { init: function() { // variables var number = 3; // local (we're already inside this anonymous function) result = 100; // global once this function is called var $header = $('#header'); // local (we're already inside this anonymous function) $navigation = $('#navigation'); // global once this function is called // bind click event $header.on('click', function() { var color = 'blue'; // local endResult = 'green'; // global once this function is called var $body = $('body'); // local $frame = $('#frame'); // global once this function is called number++; // this variable is declared outside of this function's scope, // so changes will affect not only this function's scope, // but the declaring function's scope // which means that this variable is "re-used" every time }); } }
live and delegate ‣ Better HTML5 support (footer, header, section, ...) ‣ event.layerX and event.layerY ‣ $.isNaN() replaced with $.isNumeric() Changes jQuery 1.7
live and delegate ‣ Better HTML5 support (footer, header, section, ...) ‣ event.layerX and event.layerY ‣ $.isNaN() replaced with $.isNumeric() ‣ $.event.proxy() use $.proxy() instead Changes jQuery 1.7