Skip to content
Browse files

throttling

  • Loading branch information...
1 parent 343dfd0 commit ebdb99000a81046757728f284d23b9d0aef04669 @rocktronica committed Jan 18, 2012
Showing with 24 additions and 27 deletions.
  1. +1 −1 defaults/data.json
  2. +23 −16 js/javascript.js
  3. +0 −10 js/plugins.js
View
2 defaults/data.json
@@ -11,7 +11,7 @@
"<em>Confused? Change something in one of the textareas and watch what happens.</em>",
"Data is stored as JSON, bound to an HTML template, and styled with CSS. Changes are automatically saved locally to your browser but can also be exported for sharing.",
"Browser allowing, you can drag in <code>.JSON</code>, <code>.HMTL</code>, and <code>.CSS</code> files to be loaded respectively.",
- "Yep, this is another <a href='http://jsfiddle.net/'>jsFiddle</a> clone. But my take's less about JavaScript and more about realtime template binding. It's also mostly just for fun."
+ "Yep, this is another <a href='http://jsfiddle.net/'>jsFiddle</a> clone. But my take's less about JavaScript and more about realtime template binding. It's not a replacement for any of the others, and it's mostly just for fun."
]
},
{
View
39 js/javascript.js
@@ -3,8 +3,8 @@ document.getElementById("static").style.display = "none";
var tmpltr; // kept outside for console inspection
-// needed: debounce render
-// consider: more sensical nomenclature
+// needed: ...
+// consider: more sensical nomenclature, smarter export w/ options, draggable panes
// bugs: occasional stuck view on load, opera crappiness (maybe from Ace)
$.fn.ready(function(){
@@ -23,6 +23,10 @@ $.fn.ready(function(){
structure: "",
style: "",
editors: {},
+ throttle: {
+ // in case I add other throttlers later...
+ render: undefined
+ },
$: {
output: {
body: $("#ifrOutput").contents().find("body"),
@@ -68,20 +72,23 @@ $.fn.ready(function(){
return true;
},
renderOutput: function(sWhat){
- sWhat = sWhat || "all";
- if ((sWhat === "html") || (sWhat === "all")) {
- tmpltr.$.output.body.html(
- Mustache.to_html(tmpltr.structure, tmpltr.data)
- );
- var sTitle = tmpltr.$.output.body.find("h1:first").text().trim();
- document.title = tmpltr.appname;
- if (sTitle && sTitle !== tmpltr.appname) { document.title += " - " + sTitle; }
- }
- if ((sWhat === "style") || (sWhat === "all")) {
- tmpltr.$.output.head.html(
- $("<style />").html(tmpltr.style)
- );
- }
+ tmpltr.throttle.render = tmpltr.throttle.render || setTimeout(function(){
+ sWhat = sWhat || "all";
+ if ((sWhat === "html") || (sWhat === "all")) {
+ tmpltr.$.output.body.html(
+ Mustache.to_html(tmpltr.structure, tmpltr.data)
+ );
+ var sTitle = tmpltr.$.output.body.find("h1:first").text().trim();
+ document.title = tmpltr.appname;
+ if (sTitle && sTitle !== tmpltr.appname) { document.title += " - " + sTitle; }
+ }
+ if ((sWhat === "style") || (sWhat === "all")) {
+ tmpltr.$.output.head.html(
+ $("<style />").html(tmpltr.style)
+ );
+ }
+ tmpltr.throttle.render = undefined;
+ }, 500);
},
saveToLocal: function(){
var obj = {
View
10 js/plugins.js
@@ -13,16 +13,6 @@ f&&b.properties.push("transform","transform-origin");b.properties.sort()})();(fu
b.functions=[];b.keywords=[];var f=document.createElement("div").style,g;for(g in c){var e=c[g],i=e.property,e=g+"("+e.params+")";!a(e,i)&&a(b.prefix+e,i)&&b.functions.push(g)}for(var h in d)i=d[h],!a(h,i)&&a(b.prefix+h,i)&&b.keywords.push(h)})();(function(){function a(a){f.textContent=a+"{}";return!!f.sheet.cssRules.length}var c={":read-only":null,":read-write":null,":any-link":null,"::selection":null},d={keyframes:"name",viewport:null,document:'regexp(".")'};b.selectors=[];b.atrules=[];var f=h.appendChild(document.createElement("style")),
g;for(g in c){var e=g+(c[g]?"("+c[g]+")":"");!a(e)&&a(b.prefixSelector(e))&&b.selectors.push(g)}for(var i in d)e=i+" "+(d[i]||""),!a("@"+e)&&a("@"+b.prefix+e)&&b.atrules.push(i);h.removeChild(f)})();b.valueProperties=["transition","transition-property"];h.className+=" "+b.prefix;StyleFix.register(b.prefixCSS)}})(document.documentElement);
-/*
- * jQuery throttle / debounce - v1.1 - 3/7/2010
- * http://benalman.com/projects/jquery-throttle-debounce-plugin/
- *
- * Copyright (c) 2010 "Cowboy" Ben Alman
- * Dual licensed under the MIT and GPL licenses.
- * http://benalman.com/about/license/
- */
-(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
-
/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
* Build: http://www.modernizr.com/download/#-generatedcontent-history-localstorage-addtest-teststyles-hasevent-file_api-url_data_uri
*/

0 comments on commit ebdb990

Please sign in to comment.
Something went wrong with that request. Please try again.