$.fn.rotate = function(rot) { return this.css('-webkit-transform', 'rotate(' + rot + 'deg)') .css('-moz-transform', 'rotate(' + rot + 'deg') .css('-o-transform', 'rotate(' + rot + 'deg') .css('-ms-transform', 'rotate(' + rot + 'deg') .css('transform', 'rotate(' + rot + 'deg'); }; $.fn.offsetFrom = function(el) { var offset = this.offset(); var otherOffset = $(el).offset(); return {top: offset.top - otherOffset.top, left: offset.left - otherOffset.left}; } $.fn.offsetCentre = function() { var offset = this.offset(); return {top: offset.top + this.height() / 2, left: offset.left + this.width() / 2}; } function getURLParameter(name) { return decodeURIComponent((location.search.match(RegExp("[?|&]"+name+'=(.+?)(&|$)'))||[,null])[1]); } $(function() { // Instructions (function() { var cookieName = 'hideinstructions'; function showInstructions() { $.cookie(cookieName, null); $('#instructions').show(); $('#showinstructions').hide(); } function hideInstructions() { $.cookie(cookieName, 1, { expires: 365 }); $('#instructions').hide(); $('#showinstructions').show(); } $('#hideinstructions').click(hideInstructions); $('#showinstructions').click(showInstructions); if ($.cookie(cookieName)) { hideInstructions(); } })(); // Saving (function() { function saveLayout() { _gaq.push(['_trackEvent', 'General', 'Save']); layout.notes = $('#notecontent').val(); $('#save_inprogress').show(); $('#save_done').hide(); $('#savecontainer').show(); $('#save_error').hide(); $.ajax({ type: 'POST', url: 'res/data/layouts/new', data: {layout: JSON.stringify(layout)}, success: function(res) { window.location.hash = res; var url = window.location.href; $('#link').children().remove(); $('').attr('href', url).text(url).appendTo($('#link')); $('#save_inprogress').hide(); $('#save_done').show(); }, error: function(xhr, status, error) { $('#save_error').text('Save failed! Server said: ' + error).show(); } }); } function closeSave() { $('#savecontainer').hide(); } $('#savelayout').click(saveLayout); $('#savemask').click(closeSave); $('#saveclose').click(closeSave); })(); // Layout picker (function() { $.each(levels, function(key) { var name = this.name; name && $('