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

feat(load): add a javascript load queue #159

Merged
merged 3 commits into from
Jan 21, 2017
Merged

feat(load): add a javascript load queue #159

merged 3 commits into from
Jan 21, 2017

Conversation

cubesky
Copy link
Collaborator

@cubesky cubesky commented Jan 19, 2017

What kind of change does this PR introduce? (check one with "x")

  • Bug fix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

Description

Add a javascript load queue.
You can use queue.offer(function(){ }); to add a function to load queue and it will automatic called when document DOM finished loading.
You can also use this in head.yml to use this queue.
Now, Bing background and Comment (Disque/Duoshuo) loading using this load queue.


Verification steps

No verification steps.

load a javascript load queue
@cubesky
Copy link
Collaborator Author

cubesky commented Jan 19, 2017

Use lazyload for background image. Now, background image will be shown when the image finished download. This will avoid viewer looking for a picture is downloading in progress.

@Halyul
Copy link
Contributor

Halyul commented Jan 20, 2017

顺带把图库的修复了啊🌚🌚

<% if(theme.background.bing.enable) { %>
<script type="text/javascript">
queue.offer(function(){
$('body').attr("data-original","https://api.i-meto.com/bing?<%= theme.background.bing.parameter %>");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use single quotes inside JavaScript code
  • Please put a space after comma



function offer(element) {
if(this.debug) console.log("Offered a Queued Function.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please user single quote inside JavaScript code (change it for entire file)
  • Please surround if statement with brackets even for one line, and display it in several lines (change it for entire file)

}

function execNext() {
var nextfunc=this.poll();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please surround = by space


function execNext() {
var nextfunc=this.poll();
if(nextfunc != undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use strict equality

@@ -84,6 +84,8 @@
<%- css("css/style.min") %>
<%- partial("_partial/config_css") %>
<%- js("js/jquery.min") %>
<%- js("js/queue") %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use single quotes inside JavaScript code (change it for the entire stack of import)

@@ -15,18 +15,20 @@
<% if(theme.comment.use == "duoshuo") { %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use strict equality
  • Please use single quotes in JavaScript code

@cubesky
Copy link
Collaborator Author

cubesky commented Jan 20, 2017

Ok, I will fix it as soon as possible.

@cubesky
Copy link
Collaborator Author

cubesky commented Jan 21, 2017

@pidupuis I fixed it. Please review.

@pidupuis pidupuis merged commit e6f6cef into canary Jan 21, 2017
@pidupuis pidupuis deleted the feat/load_queue branch January 21, 2017 14:40
@iblh iblh mentioned this pull request Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants