Permalink
Browse files

NO CONFLICT!

  • Loading branch information...
1 parent d0bc173 commit c2ac076826fe1c952ab0c5df6ab1173ef0734763 @nakajima committed Jun 20, 2010
View
1 app/models/bookmarklet.rb
@@ -23,6 +23,7 @@ def code
wrapped_code = <<-JS
window.setTimeout(function() {
+ jQuery.noConflict();
#{self[:code]}
}, 10);
JS
View
11 app/views/bookmarklets/edit.html.erb
@@ -29,10 +29,15 @@
</p>
</div>
- <p id="inject-label">
- <%= f.check_box :jquery %>
+ <div id="inject-label">
+ <%= f.check_box :jquery, :onchange => '$("jquery-warning").toggle()' %>
<%= f.label :jquery, 'Inject jQuery <span>Allows you to use jQuery in your bookmarklet, even if it is not loaded on the page.', :id => 'inject-label' %>
- </p>
+ <p id="jquery-warning" style="display:none;">
+ jQuery will automatically be set to <code>noConflict</code> mode,
+ meaning any references to <code>$</code> must be replaced by
+ <code>jQuery</code>.
+ </p>
+ </div>
<p class="last">
<%= f.submit 'Save Bookmarklet', :disable_with => "Saving Bookmarklet..." %> or <%= link_to 'Back', @bookmarklet %>
View
11 app/views/bookmarklets/new.html.erb
@@ -29,10 +29,15 @@
</p>
</div>
- <p id="inject-label">
- <%= f.check_box :jquery %>
+ <div id="inject-label">
+ <%= f.check_box :jquery, :onchange => '$("jquery-warning").toggle()' %>
<%= f.label :jquery, 'Inject jQuery <span>Allows you to use jQuery in your bookmarklet, even if it is not loaded on the page.', :id => 'inject-label' %>
- </p>
+ <p id="jquery-warning" style="display:none;">
+ jQuery will automatically be set to <code>noConflict</code> mode,
+ meaning any references to <code>$</code> must be replaced by
+ <code>jQuery</code>.
+ </p>
+ </div>
<p class="last">
<%= f.submit 'Create Bookmarklet', :disable_with => "Creating Bookmarklet..." %> or <%= link_to 'Back', bookmarklets_path %>
View
15 public/stylesheets/styles.css
@@ -60,7 +60,7 @@ input[type="checkbox"] {
textarea {
width: 800px;
height: 100px;
- font-family: Bitstream Vera Sans Mono, Courier, monospace;
+ font-family: Bitstream Vera Sans Mono, Monaco, Courier, monospace;
margin-bottom: 2em;
padding: 10px;
font-size: 14px;
@@ -74,6 +74,19 @@ textarea {
color: #aaa;
}
+#jquery-warning {
+ background: #ffc;
+ padding: 6px;
+ width: 810px;
+ margin-top: 10px;
+ border: 1px solid #fc0;
+}
+
+#jquery-warning code {
+ font-family: Bitstream Vera Sans Mono, Monaco, Courier, monospace;
+ background: #ffe;
+}
+
#info p {
width: 400px;
float: left;

0 comments on commit c2ac076

Please sign in to comment.