mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Many fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template name="apiBoxTitle">
|
||||
<h3 id="{{id}}" class="api-title">
|
||||
<a class="name selflink" href="#{{id}}">{{{name}}}</a>
|
||||
<a class="name selflink" href="#/{{id}}">{{{name}}}</a>
|
||||
{{#if locus}}
|
||||
<span class="locus">{{locus}}</span>
|
||||
{{/if}}
|
||||
|
||||
@@ -35,7 +35,7 @@ invalidations to clients.
|
||||
|
||||
{{> principles}}
|
||||
|
||||
<h2 id="b-learning-resources">Learning Resources</h2>
|
||||
<h2 id="learning-resources">Learning Resources</h2>
|
||||
|
||||
<!-- https://github.com/blog/273-github-ribbons -->
|
||||
<a href="http://github.com/meteor/meteor"><img class="github-ribbon visible-desktop" style="position: absolute; top: 0; right: 0; border: 0;" src="/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#template name="basicCollections"}}
|
||||
|
||||
<h2 id="b-collections"><span>Collections</span></h2>
|
||||
<h2 id="collections"><span>Collections</span></h2>
|
||||
|
||||
Meteor stores data in *collections*. JavaScript objects stored in collections
|
||||
are called `documents`. To get started, declare a collection with `new
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#template name="basicEnvironment"}}
|
||||
|
||||
<h2 id="b-environment"><span>Environment</span></h2>
|
||||
<h2 id="environment"><span>Environment</span></h2>
|
||||
|
||||
{{> autoApiBox "Meteor.isClient"}}
|
||||
{{> autoApiBox "Meteor.isServer"}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{#template name="basicMethods"}}
|
||||
<h2 id="b-methods"><span>Methods</span></h2>
|
||||
<h2 id="methods"><span>Methods</span></h2>
|
||||
|
||||
Methods are server functions that can be called from the client. They are
|
||||
useful in situations where you want to do something more complicated than
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#template name="basicPubsub"}}
|
||||
|
||||
<h2 id="b-pubsub"><span>Publish and subscribe</span></h2>
|
||||
<h2 id="pubsub"><span>Publish and subscribe</span></h2>
|
||||
|
||||
Meteor servers can publish sets of documents with `Meteor.publish` and clients
|
||||
can subscribe to those publications with `Meteor.subscribe`. Any data the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#template name="basicSession"}}
|
||||
|
||||
<h2 id="b-session"><span>Session</span></h2>
|
||||
<h2 id="session"><span>Session</span></h2>
|
||||
|
||||
`Session` provides a global object on the client that you can use to
|
||||
store an arbitrary set of key-value pairs. Use it to store things like
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{{#template name="basicTemplates"}}
|
||||
|
||||
<h2 id="b-templates"><span>Templates</span></h2>
|
||||
<h2 id="templates"><span>Templates</span></h2>
|
||||
|
||||
In Meteor, you define your views in _templates_. A template is a snippet of
|
||||
HTML that can also include special pieces of code to include data and change
|
||||
which parts of the page are displayed.
|
||||
|
||||
<h3 class="api-title" id="b-defining-templates">Defining Templates in HTML</h3>
|
||||
<h3 class="api-title" id="defining-templates">Defining Templates in HTML</h3>
|
||||
|
||||
Templates are defined in '.html' files that can be located anywhere in your
|
||||
Meteor project folder except the `server`, `public`, and `private` directories.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#template name="basicTracker"}}
|
||||
|
||||
<h2 id="b-tracker"><span>Tracker</span></h2>
|
||||
<h2 id="tracker"><span>Tracker</span></h2>
|
||||
|
||||
Meteor has a simple dependency tracking system which allows it to
|
||||
automatically rerun templates and other computations whenever
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template name="basicTableOfContents">
|
||||
<div class="basic-toc">
|
||||
<section>
|
||||
<h2><a href="#b-quick-start">Quick Start</a></h2>
|
||||
<h2><a href="#b-concepts">Concepts</a></h2>
|
||||
<h2><a href="#b-learning-resources">Learning Resources</a></h2>
|
||||
<h2><a href="#quickstart">Quick Start</a></h2>
|
||||
<h2><a href="#sevenprinciples">Principles</a></h2>
|
||||
<h2><a href="#learning-resources">Learning Resources</a></h2>
|
||||
<h2>Command Line Tool</h2>
|
||||
<h2>File Structure</h2>
|
||||
<h2>Building Mobile Apps</h2>
|
||||
|
||||
@@ -1,75 +1,9 @@
|
||||
release = Meteor.release ? "0.9.4" : "(checkout)";
|
||||
|
||||
Meteor.startup(function () {
|
||||
//mixpanel tracking
|
||||
// mixpanel tracking
|
||||
mixpanel.track('docs');
|
||||
|
||||
// returns a jQuery object suitable for setting scrollTop to
|
||||
// scroll the page, either directly for via animate()
|
||||
var scroller = function() {
|
||||
return $("html, body").stop();
|
||||
};
|
||||
|
||||
var sections = [];
|
||||
_.each($('#main h1, #main h2, #main h3'), function (elt) {
|
||||
var classes = (elt.getAttribute('class') || '').split(/\s+/);
|
||||
if (_.indexOf(classes, "nosection") === -1)
|
||||
sections.push(elt);
|
||||
});
|
||||
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var classes = (sections[i].getAttribute('class') || '').split(/\s+/);
|
||||
if (_.indexOf(classes, "nosection") !== -1)
|
||||
continue;
|
||||
sections[i].prev = sections[i-1] || sections[i];
|
||||
sections[i].next = sections[i+1] || sections[i];
|
||||
$(sections[i]).waypoint({offset: 30});
|
||||
}
|
||||
var section = document.location.hash.substr(1) || sections[0].id;
|
||||
Session.set('section', section);
|
||||
if (section) {
|
||||
// WebKit will scroll down to the #id in the URL asynchronously
|
||||
// after the page is rendered, but Firefox won't.
|
||||
Meteor.setTimeout(function() {
|
||||
var elem = $('#'+section);
|
||||
if (elem.length)
|
||||
scroller().scrollTop(elem.offset().top);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var ignore_waypoints = false;
|
||||
var lastTimeout = null;
|
||||
$('h1, h2, h3').waypoint(function (evt, dir) {
|
||||
if (!ignore_waypoints) {
|
||||
var active = (dir === "up") ? this.prev : this;
|
||||
if (active.id) {
|
||||
if (lastTimeout)
|
||||
Meteor.clearTimeout(lastTimeout);
|
||||
lastTimeout = Meteor.setTimeout(function () {
|
||||
Session.set("section", active.id);
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.onhashchange = function () {
|
||||
scrollToSection(location.hash);
|
||||
};
|
||||
|
||||
var scrollToSection = function (section) {
|
||||
if (! $(section).length)
|
||||
return;
|
||||
|
||||
ignore_waypoints = true;
|
||||
Session.set("section", section.substr(1));
|
||||
scroller().animate({
|
||||
scrollTop: $(section).offset().top
|
||||
}, 500, 'swing', function () {
|
||||
window.location.hash = section;
|
||||
ignore_waypoints = false;
|
||||
});
|
||||
};
|
||||
|
||||
// Make external links open in a new tab.
|
||||
$('a:not([href^="#"])').attr('target', '_blank');
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{/if}}
|
||||
{{#if type "section"}}
|
||||
{{#nav_section}}
|
||||
<a href="#{{id}}" class="{{maybe_current}} {{style}}">
|
||||
<a href="#/{{id}}" class="{{maybe_current}} {{style}}">
|
||||
{{#if prefix}}{{prefix}}.{{/if}}{{#if instance}}<i>{{instance}}</i>.{{/if}}{{name}}
|
||||
</a>
|
||||
{{/nav_section}}
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
var ignoreWaypoints = false;
|
||||
var triggeredFromWaypoint = {};
|
||||
var ignoreWaypoints = true;
|
||||
var ignoreUrlChange = false;
|
||||
|
||||
var deHash = function (hashString) {
|
||||
return hashString.slice(1);
|
||||
};
|
||||
|
||||
// need an actual function to only debounce inside the if statement
|
||||
var actuallyUpdateUrl = _.debounce(function (el) {
|
||||
ignoreUrlChange = true;
|
||||
window.location.replace("#/" + el.id);
|
||||
}, 1000);
|
||||
|
||||
var updateUrlFromWaypoint = function (el) {
|
||||
if (! ignoreWaypoints) {
|
||||
actuallyUpdateUrl(el);
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.startup(function () {
|
||||
setTimeout(function () {
|
||||
$('.main-content [id]').waypoint(function() {
|
||||
if (! ignoreWaypoints) {
|
||||
triggeredFromWaypoint["#" + this.id] = true;
|
||||
window.location.replace("#" + this.id);
|
||||
}
|
||||
$('.main-content [id]').each(function (i, el) {
|
||||
if (! $("#nav [href='#/" + el.id + "']").get(0)) {
|
||||
// only add waypoints to things that have sidebar links
|
||||
return;
|
||||
}
|
||||
|
||||
$(el).waypoint(function() {
|
||||
updateUrlFromWaypoint(this);
|
||||
}, { context: $('.main-content') });
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
ignoreWaypoints = false;
|
||||
});
|
||||
|
||||
Tracker.autorun(function () {
|
||||
@@ -17,8 +37,8 @@ Tracker.autorun(function () {
|
||||
var current = Iron.Location.get();
|
||||
|
||||
// If the URL changes from a waypoint, do nothing
|
||||
if (triggeredFromWaypoint[current.hash]) {
|
||||
triggeredFromWaypoint[current.hash] = false;
|
||||
if (ignoreUrlChange) {
|
||||
ignoreUrlChange = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,30 +61,33 @@ Tracker.autorun(function () {
|
||||
} else {
|
||||
if (current.hash) {
|
||||
// XXX COMPAT WITH old docs
|
||||
window.location.replace("/full/");
|
||||
window.location.replace("/full/#/" + deHash(current.hash));
|
||||
} else {
|
||||
window.location.replace("/basic/");
|
||||
}
|
||||
}
|
||||
|
||||
if (current.hash) {
|
||||
console.log("scrolling!");
|
||||
Tracker.afterFlush(function () {
|
||||
setTimeout(function () {
|
||||
var targetLocation;
|
||||
|
||||
if (current.hash === "#top") {
|
||||
if (current.hash === "#/top") {
|
||||
targetLocation = 0;
|
||||
} else {
|
||||
var foundElement = $(current.hash);
|
||||
var selector = "#" + deHash(current.hash).slice(1);
|
||||
console.log(selector);
|
||||
var foundElement = $(selector);
|
||||
if (foundElement.get(0)) {
|
||||
targetLocation = $(".main-content").scrollTop() + foundElement.offset().top - $(".main-content").offset().top - 10;
|
||||
targetLocation = $(".main-content").scrollTop() + foundElement.offset().top - $(".main-content").offset().top;
|
||||
}
|
||||
}
|
||||
|
||||
ignoreWaypoints = true;
|
||||
$(".main-content").animate({
|
||||
scrollTop: targetLocation
|
||||
}, 1000, function () {
|
||||
}, 500, function () {
|
||||
ignoreWaypoints = false;
|
||||
});
|
||||
}, 0);
|
||||
|
||||
Reference in New Issue
Block a user