Skip to content

Commit

Permalink
fix on post.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 12, 2013
1 parent 65a8452 commit 0a380aa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 57 deletions.
71 changes: 32 additions & 39 deletions static/js/site.js
@@ -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 加链接
Expand Down Expand Up @@ -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() {
Expand All @@ -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'));
}
});
}
});
})();
13 changes: 7 additions & 6 deletions templates/post.html
Expand Up @@ -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 %}
18 changes: 6 additions & 12 deletions templates/snippet/head.html
Expand Up @@ -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",
Expand All @@ -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) {
Expand All @@ -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.