1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | $(function(){
|
11 |
|
12 | var style =
|
13 | { 'position':'fixed',
|
14 | 'z-index':'9999999',
|
15 | 'opacity':'0.5',
|
16 | 'font-family': '"Helvetica Neue",Tahoma,Arial,sans-serif',
|
17 | 'font-weight': '400',
|
18 | 'font-size': '18px',
|
19 | 'line-height': '20px',
|
20 | 'height':'21px',
|
21 | 'top':'0',
|
22 | 'right':'0',
|
23 | 'background-color':'#555',
|
24 | 'color':'#fff',
|
25 | 'border-bottom-left-radius':'10px',
|
26 | 'text-align':'right',
|
27 | 'padding':'0 2px 0 5px',
|
28 | 'cursor':'pointer' };
|
29 |
|
30 | var $b;
|
31 |
|
32 | if (window.parent.location !== window.location) {
|
33 |
|
34 | $.pubEditor = true;
|
35 | $b = $('<div class="pub-button" title="Close editor">Close</div>').css(style);
|
36 | $('body').prepend($b);
|
37 | $b.on('click', function(){
|
38 | var contentHref = location.pathname + location.search + location.hash;
|
39 | var staticRoot = window.generator && window.generator.opts.staticRoot;
|
40 | if (staticRoot && contentHref.slice(0, staticRoot.length) !== staticRoot) {
|
41 | contentHref = staticRoot + contentHref;
|
42 | }
|
43 | window.parent.location = contentHref;
|
44 | });
|
45 | }
|
46 | else {
|
47 | $.pubEditor = false;
|
48 |
|
49 |
|
50 | $b = $('<div class="pub-button" title="Edit">Edit</div>').css(style);
|
51 | $('body').prepend($b);
|
52 | $b.on('click', function(){
|
53 | var pubRef = window.pubRef || {};
|
54 | var contentHref = (pubRef.href || location.pathname) + location.search + location.hash;
|
55 | var editorHref = (pubRef.relPath || '') + '/pub/?page=' + encodeURIComponent(contentHref);
|
56 | location = editorHref;
|
57 | });
|
58 | }
|
59 |
|
60 | });
|