Skip to content
This repository
Browse code

Upgrade entwine to latest

Fixes issue where inspector used document.write
  • Loading branch information...
commit 915ae1a9663dd170f7340f1bc7196bb9a2db6877 1 parent f79d2df
Hamish Friedlander authored August 16, 2012
2  thirdparty/jquery-entwine/.piston.yml
@@ -3,6 +3,6 @@ repository_url: https://github.com/hafriedlander/jquery.entwine.git
3 3
 format: 1
4 4
 handler: 
5 5
   branch: master
6  
-  commit: ca22d2b88771cf3c65e65288c4991050a42883a3
  6
+  commit: 21af92dbad424148af6dd7ea310ab7344fcf7015
7 7
 repository_class: Piston::Git::Repository
8 8
 lock: false
2  thirdparty/jquery-entwine/spec/SpecRunner.html
@@ -12,7 +12,7 @@
12 12
 
13 13
 	<script type="text/javascript">
14 14
 		versionarg = window.location.search.match(/version=([^&]+)/);
15  
-		jQueryVersion = versionarg ? versionarg[1] : '1.7.2';
  15
+		jQueryVersion = versionarg ? versionarg[1] : '1.8.0';
16 16
 		jQuerySource = 'local';
17 17
 
18 18
 		var jQuery;
2  thirdparty/jquery-entwine/spec/spec.entwine.addrem.js
@@ -94,12 +94,10 @@ describe('Entwine', function(){
94 94
 
95 95
 				$('#a,#b').entwine({
96 96
 					onadd: function(){
97  
-						console.debug('added', this);
98 97
 						added.push(this.attr('id'));
99 98
 						sequence.push(this.attr('id'));
100 99
 					},
101 100
 					onremove: function(){
102  
-						console.debug('added', this);
103 101
 						removed.push(this.attr('id'));
104 102
 						sequence.push(this.attr('id'));
105 103
 					}
94  thirdparty/jquery-entwine/src/jquery.entwine.inspector.js
... ...
@@ -1,30 +1,39 @@
1 1
 
2  
-document.write([
3  
-'<style type="text/css">',
4  
-	'#entwine-inspector { position: fixed; z-index: 1000001; left: 0; right: 0; height: 400px; background: white; -webkit-box-shadow: 0 5px 40px 0 black; -moz-box-shadow: 0 5px 40px 0 black; }',
5  
-	'#entwine-inspector li { list-style: none; margin: 2px 0; padding: 2px 0; }',
6  
-	'#entwine-inspector li:hover { background: #eee; }',
7  
-	'#entwine-inspector li.selected { background: #ddd; }',
8  
-
9  
-	'#ei-columns { overflow: hidden; display: -webkit-box; display: -moz-box; width: 100%; height: 380px; }',
10  
-
11  
-	'.ei-column { height: 380px; width: 1px; -webkit-box-flex: 1; -moz-box-flex: 1; }',
12  
-	'#entwine-inspector .ei-column h1 { display: block; margin: 0; padding: 5px 2px; height: 20px; text-align: center; background: #444; color: #eee; font-size: 14px; font-weight: bold; }',
13  
-	'#entwine-inspector .ei-column ul { overflow-y: scroll; height: 350px; }',
14  
-
15  
-	'#ei-options { overflow: hidden; height: 20px; background: #444; color: #eee; }',
16  
-	'#ei-options label { padding-right: 5px; border-right: 1px solid #eee; }',
17  
-
18  
-	'.ei-entwined:hover, .ei-selected { background: rgba(128,0,0,0.2); }',
19  
-	'.ei-hovernode { position: absolute; z-index: 1000000; background: rgba(0,0,0,0.3); border: 1px solid white; outline: 1px solid white; }',
20  
-
21  
-	'#ei-selectors li { color: #aaa; display: none; }',
22  
-	'#ei-selectors li.matching, #entwine-inspector.show-unmatched #ei-selectors li { display: block; }',
23  
-	'#ei-selectors li.matching { color: black; }',
24  
-'</style>'
25  
-].join("\n"));
26  
-
27 2
 jQuery(function($){
  3
+	// Create a new style element
  4
+	var styleEl = document.createElement('style');
  5
+	styleEl.setAttribute('type', 'text/css');
  6
+	(document.head || document.getElementsByTagName('head')[0]).appendChild(styleEl);
  7
+
  8
+	var inspectorCSS = [
  9
+		'#entwine-inspector { position: fixed; z-index: 1000001; left: 0; right: 0; height: 400px; background: white; -webkit-box-shadow: 0 5px 40px 0 black; -moz-box-shadow: 0 5px 40px 0 black; }',
  10
+		'#entwine-inspector li { list-style: none; margin: 2px 0; padding: 2px 0; }',
  11
+		'#entwine-inspector li:hover { background: #eee; }',
  12
+		'#entwine-inspector li.selected { background: #ddd; }',
  13
+
  14
+		'#ei-columns { overflow: hidden; display: -webkit-box; display: -moz-box; width: 100%; height: 380px; }',
  15
+
  16
+		'.ei-column { height: 380px; width: 1px; -webkit-box-flex: 1; -moz-box-flex: 1; }',
  17
+		'#entwine-inspector .ei-column h1 { display: block; margin: 0; padding: 5px 2px; height: 20px; text-align: center; background: #444; color: #eee; font-size: 14px; font-weight: bold; }',
  18
+		'#entwine-inspector .ei-column ul { overflow-y: scroll; height: 350px; }',
  19
+
  20
+		'#ei-options { overflow: hidden; height: 20px; background: #444; color: #eee; }',
  21
+		'#ei-options label { padding-right: 5px; border-right: 1px solid #eee; }',
  22
+
  23
+		'.ei-entwined:hover, .ei-selected { background: rgba(128,0,0,0.2); }',
  24
+		'.ei-hovernode { position: absolute; z-index: 1000000; background: rgba(0,0,0,0.3); border: 1px solid white; outline: 1px solid white; }',
  25
+
  26
+		'#ei-selectors li { color: #aaa; display: none; }',
  27
+		'#ei-selectors li.matching, #entwine-inspector.show-unmatched #ei-selectors li { display: block; }',
  28
+		'#ei-selectors li.matching { color: black; }'
  29
+	].join("\n");
  30
+
  31
+	// Set the style element to style up the inspector panel
  32
+	if(styleEl.styleSheet){
  33
+		styleEl.styleSheet.cssText = inspectorCSS;
  34
+	}else{
  35
+		styleEl.appendChild(document.createTextNode(inspectorCSS));
  36
+	}
28 37
 
29 38
 	var inspectorPanel = $('<div id="entwine-inspector" class="show-unmatched"></div>').appendTo('body');
30 39
 	var columnHolder = $('<div id="ei-columns"></div>').appendTo(inspectorPanel);
@@ -79,6 +88,22 @@ jQuery(function($){
79 88
 		});
80 89
 	};
81 90
 
  91
+	var dumpElement = function(el) {
  92
+		var frag = document.createDocumentFragment();
  93
+		var div = document.createElement('div'); frag.appendChild(div);
  94
+
  95
+		var clone = el.cloneNode(false); $(clone).removeClass('ei-entwined').removeAttr('style');
  96
+
  97
+		var i = clone.attributes.length;
  98
+		while (i--) {
  99
+			var attr = clone.attributes.item(i);
  100
+			if (attr.name != 'class' && attr.name != 'id' && attr.value.length > 20) attr.value = attr.value.substr(0, 18)+'..'+attr.value.substr(-2);
  101
+		}
  102
+
  103
+		div.appendChild(clone);
  104
+		return div.innerHTML;
  105
+	};
  106
+
82 107
 	var displaydetails = function(e){
83 108
 		e.preventDefault(); e.stopPropagation();
84 109
 
@@ -99,18 +124,7 @@ jQuery(function($){
99 124
 			var target = $(this);
100 125
 
101 126
 			var li = $('<li></li>');
102  
-			var clone = $(this.cloneNode(false)); clone.removeClass('ei-entwined'); clone.removeAttr('style');
103  
-
104  
-
105  
-			var i = clone[0].attributes.length;
106  
-			while (i--) {
107  
-				var attr = clone[0].attributes.item(i);
108  
-				if (attr.name != 'class' && attr.name != 'id' && attr.value.length > 20) attr.value = attr.value.substr(0, 18)+'..'+attr.value.substr(-2);
109  
-			}
110  
-
111  
-			li.append(clone);
112  
-
113  
-			li.text(li.html()).attr('data-id', ++ctr).data('el', target).prependTo(lists.elements);
  127
+			li.text(dumpElement(this)).attr('data-id', ++ctr).data('el', target).prependTo(lists.elements);
114 128
 
115 129
 			var namespaces = $('<ul data-element="'+ctr+'"></ul>').appendTo(columns.namespaces);
116 130
 
@@ -206,21 +220,21 @@ jQuery(function($){
206 220
 
207 221
 		$('.ei-selected').removeClass('ei-selected');
208 222
 
209  
-		activatelist('#ei-namespaces ul[data-element='+id+']');
  223
+		activatelist('#ei-namespaces ul[data-element="'+id+'"]');
210 224
 	});
211 225
 
212 226
 	$('#ei-namespaces > ul > li').live('click', function(e){
213 227
 		var target = $(e.target), namespace = target.attr('data-namespace');
214 228
 		target.addClass('selected').siblings().removeClass('selected');
215 229
 
216  
-		activatelist('#ei-methods ul[data-namespace='+namespace+']');
  230
+		activatelist('#ei-methods ul[data-namespace="'+namespace+'"]');
217 231
 	});
218 232
 
219 233
 	$('#ei-methods > ul > li').live('click', function(e){
220 234
 		var target = $(e.target), method = target.attr('data-method');
221 235
 		target.addClass('selected').siblings().removeClass('selected');
222 236
 
223  
-		activatelist('#ei-selectors ul[data-method='+method+']');
  237
+		activatelist('#ei-selectors ul[data-method="'+method+'"]');
224 238
 	});
225 239
 
226 240
 });
7,739  thirdparty/jquery-entwine/vendor/jquery-1.7.2.js → thirdparty/jquery-entwine/vendor/jquery-1.8.0.js
3781 additions, 3958 deletions not shown

0 notes on commit 915ae1a

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