Created
July 29, 2014 21:14
-
-
Save carolineschnapp/775a1e8ccce597a7b4a2 to your computer and use it in GitHub Desktop.
Add this to a snippet and include that snippet before the </body> tag. Adds an edit link to edit content. Only shows up if you are logged-in your store's admin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' | stylesheet_tag }} | |
<style> | |
.edit-tool { | |
float: right; | |
position: fixed; | |
right: 0; | |
top: 70px; | |
background-color: white; | |
padding: 5px 10px; | |
-webkit-box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6); | |
-moz-box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6); | |
box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6); | |
} | |
.edit-tool a { | |
color: #555; | |
cursor: pointer; | |
} | |
</style> | |
<script> | |
$(window).load(function() { | |
if ( $('#admin_bar_iframe').size() ) { | |
$('body').append('<div class="edit-tool"><a><i class="fa fa-pencil-square-o"></i> Edit this </a></div>').find('.edit-tool a').click(function(e) { | |
e.preventDefault(); | |
(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.10.1",function($,L){var s=$(location).attr("hostname"),u=$(location).attr("href")+".json";$.ajax({url:u,type:"GET",dataType:"json",success:function(o){if(o.hasOwnProperty("product")){var t=o.product.id;window.location.href="https://"+s+"/admin/products/"+t}else if(o.hasOwnProperty("collection")){var t=o.collection.id;window.location.href="https://"+s+"/admin/collections/"+t}else if(o.hasOwnProperty("page")){var t=o.page.id;window.location.href="https://"+s+"/admin/pages/"+t}else alert("Sorry, but you cannot use this here.")},error:function(){alert("This cannot be used here.")}});}); | |
}); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It no longer works on Article pages, now that the URL system has been changed.