Kaynağa Gözat

[ide] Faster css live reload

Clément Espeute 7 ay önce
ebeveyn
işleme
ddb36843c7
2 değiştirilmiş dosya ile 21 ekleme ve 7 silme
  1. 13 7
      bin/app.html
  2. 8 0
      hide/Ide.hx

+ 13 - 7
bin/app.html

@@ -137,13 +137,19 @@
 	if (file == null)
 		return;
 	var ext = file.split(".").pop().toLowerCase();
-	if( ext != "js" && ext != "css" ) return;
-	if (timer != 0)
-		clearTimeout(timer);
-	timer = setTimeout(function() {
-		reloadWatcher.close();
-		hide.Ide.inst.reload();
-	}, 1000);
+	if( ext == "js")
+	{
+		if (timer != 0)
+			clearTimeout(timer);
+		timer = setTimeout(function() {
+			reloadWatcher.close();
+			hide.Ide.inst.reload();
+		}, 1000);
+	}
+
+	if (ext == "css") {
+		hide.Ide.inst.reloadCss();
+	};
   });
 </script>
 

+ 8 - 0
hide/Ide.hx

@@ -793,6 +793,14 @@ class Ide extends hide.tools.IdeData {
 		js.Browser.location.reload();
 	}
 
+	public function reloadCss() {
+		var css = new js.jquery.JQuery('link[type="text/css"]');
+		css.each(function(i, e) : Void {
+			var link : js.html.LinkElement = cast e;
+			link.href = link.href + "?" + haxe.Timer.stamp();
+		});
+	}
+
 	public function getCDBContent<T>( sheetName : String ) : Array<T> {
 		for( s in database.sheets )
 			if( s.name == sheetName ) {