From 0a380aa4ba5bb2ad0a1bcfbb0a007ab22dda5dcf Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Fri, 12 Apr 2013 20:26:42 +0800 Subject: [PATCH] fix on post.html --- static/js/site.js | 71 +++++++++++++++++-------------------- templates/post.html | 13 +++---- templates/snippet/head.html | 18 ++++------ 3 files changed, 45 insertions(+), 57 deletions(-) diff --git a/static/js/site.js b/static/js/site.js index 5623172..60740f0 100644 --- a/static/js/site.js +++ b/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 加链接 @@ -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: '', + 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: '', - 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')); - } - }); - } - }); -})(); diff --git a/templates/post.html b/templates/post.html index f84e44b..e3e3d72 100644 --- a/templates/post.html +++ b/templates/post.html @@ -21,16 +21,17 @@

{{post.title}}

{%- endif %} +{%- set output = config.package.spm.output %} +{%- if output|length > 1 %} +{%- endif %}
-

{{config.package.root}}/{{config.package.name}}/{{config.package.version}}/

+

{{config.package.family}}/{{config.package.name}}/{{config.package.version}}/

这是模块的输出文件,请 require 或 seajs.use 以上 ID 来使用本文件,具体 API 请阅读文档。

{%- endblock %} diff --git a/templates/snippet/head.html b/templates/snippet/head.html index 5a48eed..5b88cc7 100644 --- a/templates/snippet/head.html +++ b/templates/snippet/head.html @@ -36,11 +36,9 @@ 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'; } @@ -48,7 +46,6 @@ 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 %} })();