Permalink
Browse files

fix on post.html

  • Loading branch information...
1 parent 65a8452 commit 0a380aa4ba5bb2ad0a1bcfbb0a007ab22dda5dcf @lepture lepture committed Apr 12, 2013
Showing with 45 additions and 57 deletions.
  1. +32 −39 static/js/site.js
  2. +7 −6 templates/post.html
  3. +6 −12 templates/snippet/head.html
View
@@ -1,4 +1,5 @@
-seajs.use('jquery', function($) {
+seajs.use(['jquery', 'arale/popup/1.0.1/popup'], function($, Popup) {
+
$(function(){
$('h4 em, h3 em, h3 code, h4 code').parent().addClass('doc-api')
// 给 iframe 加链接
@@ -28,6 +29,36 @@ seajs.use('jquery', function($) {
return false
});
+ var family = $('#sidebar-wrapper h1 sup a').html();
+ if (family && Popup) {
+ var name = $('#sidebar-wrapper h1 > a').html().toLowerCase();
+ var version = $('#sidebar-wrapper .version a').html();
+ new Popup({
+ trigger: '#sidebar-wrapper h1 > a',
+ template: '<div class="popup-install">spm install '
+ +family+'/'+name+'@'+version+'</div>',
+ align: {
+ baseXY: [0, '100%+5']
+ }
+ });
+ }
+
+ // output card
+ if ($('#module-output')[0] && Popup) {
+ new Popup({
+ trigger: '#module-output li a',
+ element: '#output-card',
+ effect: 'fade',
+ beforeShow: function() {
+ var file = this.activeTrigger.data('file');
+ file = file.replace('./', '').replace('.js', '');
+ this.element.find('#output-file').html(file)
+ .attr('href', this.activeTrigger.attr('href'));
+ }
+ });
+ }
+
+
// google analytics
var project = $('#sidebar-wrapper h1 > a').text();
$('#footer-wrapper a').click(function() {
@@ -46,41 +77,3 @@ seajs.use('jquery', function($) {
_gaq.push(['_trackEvent', 'Link', 'Issue', project]);
});
});
-
-(function() {
- var temp = document.domain.split('.');
- if (!isNaN(temp[temp.length - 1])) {
- return;
- }
- seajs.use(['$', 'arale/popup/1.0.1/popup'], function($, Popup) {
- // spm install message
- var root = $('#sidebar-wrapper h1 sup a').html();
- if (root && Popup) {
- var name = $('#sidebar-wrapper h1 > a').html().toLowerCase();
- var version = $('#sidebar-wrapper .version a').html();
- new Popup({
- trigger: '#sidebar-wrapper h1 > a',
- template: '<div class="popup-install">spm install '
- +root+'.'+name+'@'+version+'</div>',
- align: {
- baseXY: [0, '100%+5']
- }
- });
- }
-
- // output card
- if ($('#module-output')[0] && Popup) {
- new Popup({
- trigger: '#module-output li a',
- element: '#output-card',
- effect: 'fade',
- beforeShow: function() {
- var file = this.activeTrigger.data('file');
- file = file.replace('./', '').replace('.js', '');
- this.element.find('#output-file').html(file)
- .attr('href', this.activeTrigger.attr('href'));
- }
- });
- }
- });
-})();
View
@@ -21,16 +21,17 @@ <h1 class="entry-title">{{post.title}}</h1>
</ol>
{%- endif %}
+{%- set output = config.package.spm.output %}
+{%- if output|length > 1 %}
<ul id="module-output">
- {%- if config.package.output|length > 1 %}
- <li class="module-multiable" title="本组件共有{{config.package.output|length}}个子模块">多模块</li>
- {%- for value in config.package.output %}
- <li><a data-file="{{loop.key}}" href="{{content_url('dist/')}}{{loop.key}}">■</a></li>
+ <li class="module-multiable" title="本组件共有{{output|length}}个子模块">多模块</li>
+ {%- for value in output %}
+ <li><a data-file="{{value}}" href="{{content_url('dist/')}}{{value}}">■</a></li>
{%- endfor %}
- {%- endif %}
</ul>
+{%- endif %}
<div id="output-card">
- <h3>{{config.package.root}}/{{config.package.name}}/{{config.package.version}}/<a target="_blank" id="output-file"></a></h3>
+ <h3>{{config.package.family}}/{{config.package.name}}/{{config.package.version}}/<a target="_blank" id="output-file"></a></h3>
<p>这是模块的输出文件,请 require 或 seajs.use 以上 ID 来使用本文件,具体 API 请阅读文档。</p>
</div>
{%- endblock %}
@@ -36,19 +36,16 @@
var query = location.search;
var srcdir = 'src';
- var srccss = {{src.css|json_encode}};
if (query.indexOf('dist') > 0) {
srcdir = 'dist';
- srccss = {{dist.css|json_encode}};
} else if (query.indexOf('cov') > 0) {
srcdir = 'src-cov';
}
seajs.config({
alias: {
"$": 'jquery/jquery/1.7.2/jquery',
- "$-debug": 'jquery/jquery/1.7.2/jquery-debug',
jquery: 'jquery/jquery/1.7.2/jquery',
"jquery-debug": 'jquery/jquery/1.7.2/jquery-debug',
mocha: "gallery/mocha/1.9.0/mocha",
@@ -67,10 +64,6 @@
}}
});
- for (var i = 0; i < srccss.length; i++) {
- seajs.use(seajs.resolve('{{content_url('')}}/' + srcdir + '/' + srccss[i]));
- }
-
function resolve(file) {
if (query.indexOf('debug') > 0) {
if (file.indexOf('-debug') === -1) {
@@ -90,11 +83,12 @@
seajs.config({ alias: {{pkg.spm.devAlias|clean_alias|json_encode}}});
{%- endif %}
- {%- for value in src.alias %}
- seajs.config({alias: {
- "{{loop.key}}": resolve("{{value}}")
- }});
- {%- endfor %}
+ seajs.config({alias: {
+ "$-debug": 'jquery/jquery/1.7.2/jquery-debug'
+ {%- for value in src.alias %}
+ ,"{{loop.key}}": resolve("{{value}}")
+ {%- endfor %}
+ }});
{%- endif %}
})();
</script>

0 comments on commit 0a380aa

Please sign in to comment.