Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa294a3a1a | ||
|
|
71fcd4b24b | ||
|
|
31d0232ef4 | ||
|
|
e09c164491 | ||
|
|
4a3ba25547 |
@@ -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
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pjax",
|
||||
"main": "pjax.js",
|
||||
"version": "0.1.1",
|
||||
"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",
|
||||
|
||||
39
gulpfile.js
39
gulpfile.js
@@ -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"])
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "pjax",
|
||||
"version": "0.1.1",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,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)
|
||||
|
||||
Reference in New Issue
Block a user