Compare commits

..

10 Commits

Author SHA1 Message Date
Maxime Thirouin
aa294a3a1a 0.1.2 2014-04-03 07:08:47 +02:00
Maxime Thirouin
71fcd4b24b v0.1.2 2014-04-03 07:08:47 +02:00
Maxime Thirouin
31d0232ef4 Update Changelog 2014-04-03 07:07:46 +02:00
Maxime Thirouin
e09c164491 Update gulpfile from my boilerplate & relocate pjax.js into src folder 2014-04-03 07:07:34 +02:00
Maxime Thirouin
4a3ba25547 Make <html> attributes available 2014-04-03 06:53:41 +02:00
Maxime Thirouin
bdf2394907 0.1.1 2014-04-02 10:51:29 +02:00
Maxime Thirouin
84400bb61d v0.1.1 2014-04-02 10:51:23 +02:00
Maxime Thirouin
7a3a69b54b hr in README before Changelog 2014-04-02 10:51:05 +02:00
Maxime Thirouin
9849ac60d2 Safer UMD wrapper 2014-04-02 10:50:51 +02:00
Maxime Thirouin
e891de30cc v0.1.0 2014-03-24 08:56:23 +01:00
6 changed files with 73 additions and 16 deletions

View File

@@ -1,5 +1,14 @@
# Changelog
## 0.1.2 - 2014-04-03
- pjax.js relocated in `src/`
- <html> attributes of pjaxified document are now available
## 0.1.1 - 2014-04-02
- Safer UMD wrapper (fix concat issue)
## 0.1.0 - 2014-03-24
Initial release

View File

@@ -470,6 +470,8 @@ new Pjax()
document.addEventListener("pjax:success", whenContainerReady)
```
---
## [Changelog](CHANGELOG.md)
## Contributing

View File

@@ -1,12 +1,12 @@
{
"name": "pjax",
"main": "pjax.js",
"version": "0.0.0",
"version": "0.1.2",
"description": "Boost browsing experience using Ajax navigation (+ Push state)",
"main": "src/pjax.js",
"homepage": "https://github.com/MoOx/pjax",
"authors": [
"Maxime Thirouin <m@moox.io>"
],
"description": "Boost browsing experience using Ajax navigation (+ Push state)",
"moduleType": [
"amd",
"globals",

View File

@@ -1,31 +1,56 @@
///
var pkg = require("./package.json")
, gulp = require("gulp")
, plumber = require("gulp-plumber")
///
// Lint JS
// JS Lint
///
var jshint = require("gulp-jshint")
, jsFiles = [".jshintrc", "*.json", "*.js"]
, jsonFiles = [".jshintrc", "*.json"]
, jsFiles = ["*.js", "src/**/*.js"]
gulp.task("scripts.lint", function() {
gulp.src(jsFiles)
gulp.src([].concat(jsonFiles).concat(jsFiles))
.pipe(plumber())
.pipe(jshint(".jshintrc"))
.pipe(jshint.reporter("jshint-stylish"))
})
///
// JS Code Sniffing
///
var jscs = require("gulp-jscs")
gulp.task("scripts.cs", function() {
gulp.src("*.js")
gulp.src(jsFiles)
.pipe(plumber())
.pipe(jscs())
})
// JS Alias
gulp.task("scripts", ["scripts.lint", "scripts.cs"])
///
// Watch
///
gulp.task("watch", function() {
gulp.watch([jsFiles], ["scripts"])
gulp.watch(jsFiles, ["scripts"])
})
gulp.task("default", ["scripts", "watch"])
///
// Publish gh-branch
///
var buildBranch = require("buildbranch")
gulp.task("publish", ["test"], function(cb) {
buildBranch({folder: "src"}
, function(err) {
if (err) {
throw err
}
console.log(pkg.name + " published.")
cb()
})
})
// Aliases
gulp.task("build", ["scripts"])
gulp.task("test", ["build"])
gulp.task("default", ["test", "watch"])

View File

@@ -1,8 +1,8 @@
{
"name": "pjax",
"version": "0.1.0",
"version": "0.1.2",
"description": "Boost browsing experience using Ajax navigation (+ Push state)",
"main": "pjax.js",
"main": "src/pjax.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -30,6 +30,7 @@
"gulp-jscs": "^0.3.2",
"gulp-plumber": "^0.5.6",
"gulp": "^3.5.6",
"gulp-jshint": "^1.5.1"
"gulp-jshint": "^1.5.1",
"buildbranch": "0.0.1"
}
}

View File

@@ -1,4 +1,4 @@
(function(root, factory) {
;(function(root, factory) {
if (typeof exports === "object") {
// CommonJS
module.exports = factory()
@@ -12,6 +12,8 @@
root.Pjax = factory()
}
}(this, function() {
"use strict";
function newUid() {
return (new Date().getTime())
}
@@ -338,8 +340,25 @@
, loadContent: function(html, options) {
var tmpEl = document.implementation.createHTMLDocument()
// parse HTML attributes to copy them
// since we are forced to use documentElement.innerHTML (outerHTML can't be used for <html>)
, htmlRegex = /<html[^>]+>/gi
, htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi
, matches = html.match(htmlRegex)
if (matches.length) {
matches = matches[0].match(htmlAttribsRegex)
if (matches.length) {
matches.shift()
matches.forEach(function(htmlAttrib) {
var attr = htmlAttrib.trim().split("=")
tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
})
}
}
tmpEl.documentElement.innerHTML = html
// this.log("load content", tmpEl.documentElement.innerHTML)
this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length)
// try {
this.switchSelectors(this.options.selectors, tmpEl, document, options)
@@ -582,4 +601,5 @@
return stupidPjax
}
}))
}));