Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteeb89f6

Browse files
committed
Change the publish button to replace itself with a link to the flattened document.
This provides a UI surface to publish things like the section index at the same time.
1 parenta0e7798 commiteeb89f6

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

‎publish.html‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
limitations under the License.
1414
-->
1515

16-
<!-- This element creates a button that creates a standalone HTML version of
17-
the current page in a new window so you can save it.
18-
This will only work with the ShadowDOM polyfill, since you can't create
19-
ShadowDOM without script.
16+
<!-- This element creates a button that creates a link to a standalone HTML
17+
version of the current page.
18+
19+
This will only work with the ShadowDOM polyfill, but we'll eventually
20+
implement support for native ShadowDOM.
2021
2122
If the 'source' attribute is present, a "Sources at ..." comment
2223
will appear at the top of the result document.
@@ -26,7 +27,12 @@
2627
<style>
2728
:host {display: block;}
2829
</style>
29-
<buttonon-click="{{publish}}">Publish to new window</button>
30+
<templateif="{{ !flattenedBlob }}">
31+
<buttonon-click="{{publish}}"disabled?="{{ publishing }}">Publish</button>
32+
</template>
33+
<templateif="{{ flattenedBlob }}">
34+
<ahref="{{ flattenedBlob }}">Flattened document</a>
35+
</template>
3036
</template>
3137
<scriptsrc="publish.js"></script>
3238
</polymer-element>

‎publish.js‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,28 @@ limitations under the License.
140140
}
141141

142142
Polymer('cxx-publish-button',{
143+
publishing:false,
144+
flattenedBlob:null,
143145
publish:function(){
146+
if(this.publishing){
147+
return;
148+
}
149+
this.publishing=true;
144150
varcopyPromise=cloneStaticAndInline(document);
145151
varsource='';
146152
if(this.source){
147-
varsource='<!-- Sources at '+this.source+' -->\n';
153+
source='<!-- Sources at '+this.source+' -->\n';
148154
}
149155
copyPromise.then(function(copy){
150156
varpublished=newBlob(['<!DOCTYPE html>\n',
151157
source,
152158
copy.documentElement.outerHTML],
153159
{type:'text/html'});
154-
window.open(URL.createObjectURL(published),'_blank');
155-
});
156-
}
160+
this.flattenedBlob=URL.createObjectURL(published);
161+
}.bind(this)).catch(function(e){
162+
console.error(e);
163+
this.publishing=false;
164+
}.bind(this));
165+
},
157166
});
158167
})();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp