Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks #18

Closed
Jayin opened this issue Jun 30, 2015 · 0 comments
Closed

Hooks #18

Jayin opened this issue Jun 30, 2015 · 0 comments
Labels
Milestone

Comments

@Jayin
Copy link
Owner

Jayin commented Jun 30, 2015

有时候我们需要根据用户的特定需求,可能需要定制一下silentor,提供一些hooks便于定制开发,而不是改源代码.

例如: 用户加载完main-page 的内容后(主页有可能是索引页,因而不显示评论),需要决定是否显示评论框.

Hooks

  • sidebar-page
    • 加载sidebar-page前 before-load-sidebar-page
    • 加载sidebar-page后 loaded-sidebar-page
  • main-page
    • 加载main-page 前 before-load-main-page
    • 加载main-page 后 loaded-main-page
  • main-page-footer
    • 加载main-page-footer前 before-load-main-page-footer
    • 加载main-page-footer后 loaded-main-page-footer
  • 找不到404 page-not-found, 额外传入的data:
    • data.selector 要加载的selector
    • data.path: md路径(加载页路径)

Usage

src/extension/pluginName/main.js

;(function($) {
    'use strict';
    $(window).on('loaded-sidebar-page', function() {
       // console.log('loaded-sidebar-page')
    });
    $(window).on('loaded-main-page', function() {
      // your code
    });
    $(window).on('loaded-main-page-footer', function() {
        // console.log('loaded-main-page-footer')
    });

    $(window).on('page-not-found', function(evt, data){
        // console.log('page-not-found')
    });

    $(window).on('before-load-sidebar-page', function(evt, data){
        // console.log('before-load-sidebar-page')
    });
    $(window).on('before-load-main-page', function(evt, data){
        // console.log('before-load-main-page')
    });
    $(window).on('before-load-main-page-footer', function(evt, data){
        // console.log('before-load-main-page-footer')
    });
    //。。。。。。
})(jQuery);
@Jayin Jayin added the feature label Jun 30, 2015
@Jayin Jayin added this to the 1.6.0 milestone Jun 30, 2015
@Jayin Jayin closed this as completed in 7b1b626 Jul 3, 2015
@Jayin Jayin reopened this Jul 5, 2015
@Jayin Jayin closed this as completed in 7948cd0 Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant