diff --git a/sources/1597-master/.gitignore b/sources/1597-master/.gitignore deleted file mode 100644 index 0d31019..0000000 --- a/sources/1597-master/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.sass-cache/ diff --git a/sources/1597-master/.jshintrc b/sources/1597-master/.jshintrc deleted file mode 100644 index 87dbf9a..0000000 --- a/sources/1597-master/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "esnext": true, - "indent": 2, - "maxlen": 80, - "freeze": true, - "camelcase": true, - "unused": true, - "eqnull": true, - "proto": true, - "supernew": true, - "noyield": true, - "evil": true, - "node": true, - "boss": true, - "expr": true, - "loopfunc": true, - "white": true, - "maxdepth": 4 -} diff --git a/sources/1597-master/CONTRIBUTING.md b/sources/1597-master/CONTRIBUTING.md deleted file mode 100644 index 968baa9..0000000 --- a/sources/1597-master/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -## Contributing -Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specifically made branch and request to pull on `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process. diff --git a/sources/1597-master/LICENSE.txt b/sources/1597-master/LICENSE.txt deleted file mode 100644 index b0dbfa4..0000000 --- a/sources/1597-master/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Gabriele Cirulli - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/sources/1597-master/README.md b/sources/1597-master/README.md deleted file mode 100644 index 0811fae..0000000 --- a/sources/1597-master/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# 1597 -A fibonacci version of: the popular 2048 game, originally created by [Gabriele Cirulli](https://github.com/gabrielecirulli) - -[Play it here!](http://jmhummel.github.io/1597/) diff --git a/sources/1597-master/Rakefile b/sources/1597-master/Rakefile deleted file mode 100644 index 3e9851e..0000000 --- a/sources/1597-master/Rakefile +++ /dev/null @@ -1,11 +0,0 @@ -require "date" - -namespace :appcache do - desc "update the date in the appcache file (in the gh-pages branch)" - task :update do - appcache = File.read("cache.appcache") - updated = "# Updated: #{DateTime.now}" - - File.write("cache.appcache", appcache.sub(/^# Updated:.*$/, updated)) - end -end diff --git a/sources/1597-master/favicon.ico b/sources/1597-master/favicon.ico deleted file mode 100644 index 22109e0..0000000 Binary files a/sources/1597-master/favicon.ico and /dev/null differ diff --git a/sources/1597-master/index.html b/sources/1597-master/index.html deleted file mode 100644 index 0f7bd27..0000000 --- a/sources/1597-master/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - 1597 - - - - - - - - - - - -
-
-

1597

-
-
0
-
0
-
-
-

Reliez les nombres de la sute de Fibonacci et obtenez la tuile 1597 !

- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
- - -

- Comment jouer : Utilisez les flèches du clavier pour déplacer les tuiles. Quand deux tuiles avec le même nombre se touchent, elles fusionnent ! -

-

- La suite de Fibonacci : Pour ceux qui ne connaissent pas les nombres de la suite de Fibonacci, les onze premiers sont : -

-

- 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... -

-

- Chaque nombre de la suite est formé de la somme des deux précédents. -

-
-

- Note : Framasoft héberge une instance du jeu créé par Gabriele Cirulli et modifié par Jeremy Hummel pour cette version. sous licence libre MIT. -

-
- - - - - - - - - - - - - diff --git a/sources/1597-master/js/animframe_polyfill.js b/sources/1597-master/js/animframe_polyfill.js deleted file mode 100644 index c45a13e..0000000 --- a/sources/1597-master/js/animframe_polyfill.js +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var lastTime = 0; - var vendors = ['webkit', 'moz']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - } - - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - } -}()); diff --git a/sources/1597-master/js/application.js b/sources/1597-master/js/application.js deleted file mode 100644 index a4d310a..0000000 --- a/sources/1597-master/js/application.js +++ /dev/null @@ -1,4 +0,0 @@ -// Wait till the browser is ready to render the game (avoids glitches) -window.requestAnimationFrame(function () { - new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager); -}); diff --git a/sources/1597-master/js/game_manager.js b/sources/1597-master/js/game_manager.js deleted file mode 100644 index 0410175..0000000 --- a/sources/1597-master/js/game_manager.js +++ /dev/null @@ -1,264 +0,0 @@ -function GameManager(size, InputManager, Actuator, ScoreManager) { - this.size = size; // Size of the grid - this.inputManager = new InputManager; - this.scoreManager = new ScoreManager; - this.actuator = new Actuator; - - this.startTiles = 2; - - this.inputManager.on("move", this.move.bind(this)); - this.inputManager.on("restart", this.restart.bind(this)); - this.inputManager.on("keepPlaying", this.keepPlaying.bind(this)); - - this.setup(); -} - -// Restart the game -GameManager.prototype.restart = function () { - this.actuator.continue(); - this.setup(); -}; - -// Keep playing after winning -GameManager.prototype.keepPlaying = function () { - this.keepPlaying = true; - this.actuator.continue(); -}; - -GameManager.prototype.isGameTerminated = function () { - if (this.over || (this.won && !this.keepPlaying)) { - return true; - } else { - return false; - } -}; - -// Set up the game -GameManager.prototype.setup = function () { - this.grid = new Grid(this.size); - - this.score = 0; - this.over = false; - this.won = false; - this.keepPlaying = false; - - // Add the initial tiles - //console.log('test'); - this.addStartTiles(); - //console.log('Added start tiles'); - - // Update the actuator - this.actuate(); -}; - -// Set up the initial tiles to start the game with -GameManager.prototype.addStartTiles = function () { - for (var i = 0; i < this.startTiles; i++) { - this.addRandomTile(); - } -}; - -// Adds a tile in a random position -GameManager.prototype.addRandomTile = function () { - if (this.grid.cellsAvailable()) { - var value = Math.random() < 0.9 ? 1 : 2; - var tile = new Tile(this.grid.randomAvailableCell(), value); - - this.grid.insertTile(tile); - } -}; - -// Sends the updated grid to the actuator -GameManager.prototype.actuate = function () { - if (this.scoreManager.get() < this.score) { - this.scoreManager.set(this.score); - } - - this.actuator.actuate(this.grid, { - score: this.score, - over: this.over, - won: this.won, - bestScore: this.scoreManager.get(), - terminated: this.isGameTerminated() - }); - -}; - -// Save all tile positions and remove merger info -GameManager.prototype.prepareTiles = function () { - this.grid.eachCell(function (x, y, tile) { - if (tile) { - tile.mergedFrom = null; - tile.savePosition(); - } - }); -}; - -// Move a tile and its representation -GameManager.prototype.moveTile = function (tile, cell) { - this.grid.cells[tile.x][tile.y] = null; - this.grid.cells[cell.x][cell.y] = tile; - tile.updatePosition(cell); -}; - -// Tests if two values sum to a Fibonacci number -GameManager.prototype.testFib = function(val1, val2) { - var sum = val1 + val2; - var fib = [1,1] - - while (sum > fib[fib.length-1]) { - fib.push(fib[fib.length-1] + fib[fib.length-2]) - } - - for (var i = 0; i=fib[i]; i++) { - if (sum === fib[i]) { - return true; - } - } - return false; -}; - -// Move tiles on the grid in the specified direction -GameManager.prototype.move = function (direction) { - // 0: up, 1: right, 2:down, 3: left - var self = this; - - if (this.isGameTerminated()) return; // Don't do anything if the game's over - - var cell, tile; - - var vector = this.getVector(direction); - var traversals = this.buildTraversals(vector); - var moved = false; - - // Save the current tile positions and remove merger information - this.prepareTiles(); - - // Traverse the grid in the right direction and move tiles - traversals.x.forEach(function (x) { - traversals.y.forEach(function (y) { - cell = { x: x, y: y }; - tile = self.grid.cellContent(cell); - - if (tile) { - var positions = self.findFarthestPosition(cell, vector); - var next = self.grid.cellContent(positions.next); - - // Only one merger per row traversal? - if (next && self.testFib(next.value, tile.value) && !next.mergedFrom) { - var merged = new Tile(positions.next, tile.value + next.value); - merged.mergedFrom = [tile, next]; - - self.grid.insertTile(merged); - self.grid.removeTile(tile); - - // Converge the two tiles' positions - tile.updatePosition(positions.next); - - // Update the score - self.score += merged.value; - - // The mighty 2048 tile - if (merged.value === 1597) self.won = true; - } else { - self.moveTile(tile, positions.farthest); - } - - if (!self.positionsEqual(cell, tile)) { - moved = true; // The tile moved from its original cell! - } - } - }); - }); - - if (moved) { - this.addRandomTile(); - - if (!this.movesAvailable()) { - this.over = true; // Game over! - } - - this.actuate(); - } -}; - -// Get the vector representing the chosen direction -GameManager.prototype.getVector = function (direction) { - // Vectors representing tile movement - var map = { - 0: { x: 0, y: -1 }, // up - 1: { x: 1, y: 0 }, // right - 2: { x: 0, y: 1 }, // down - 3: { x: -1, y: 0 } // left - }; - - return map[direction]; -}; - -// Build a list of positions to traverse in the right order -GameManager.prototype.buildTraversals = function (vector) { - var traversals = { x: [], y: [] }; - - for (var pos = 0; pos < this.size; pos++) { - traversals.x.push(pos); - traversals.y.push(pos); - } - - // Always traverse from the farthest cell in the chosen direction - if (vector.x === 1) traversals.x = traversals.x.reverse(); - if (vector.y === 1) traversals.y = traversals.y.reverse(); - - return traversals; -}; - -GameManager.prototype.findFarthestPosition = function (cell, vector) { - var previous; - - // Progress towards the vector direction until an obstacle is found - do { - previous = cell; - cell = { x: previous.x + vector.x, y: previous.y + vector.y }; - } while (this.grid.withinBounds(cell) && - this.grid.cellAvailable(cell)); - - return { - farthest: previous, - next: cell // Used to check if a merge is required - }; -}; - -GameManager.prototype.movesAvailable = function () { - return this.grid.cellsAvailable() || this.tileMatchesAvailable(); -}; - -// Check for available matches between tiles (more expensive check) -GameManager.prototype.tileMatchesAvailable = function () { - var self = this; - - var tile; - - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - tile = this.grid.cellContent({ x: x, y: y }); - - if (tile) { - for (var direction = 0; direction < 4; direction++) { - var vector = self.getVector(direction); - var cell = { x: x + vector.x, y: y + vector.y }; - - var other = self.grid.cellContent(cell); - - if (other && self.testFib(other.value, tile.value)) { - return true; // These two tiles can be merged - } - } - } - } - } - - return false; -}; - -GameManager.prototype.positionsEqual = function (first, second) { - return first.x === second.x && first.y === second.y; -}; diff --git a/sources/1597-master/js/grid.js b/sources/1597-master/js/grid.js deleted file mode 100644 index 05fe057..0000000 --- a/sources/1597-master/js/grid.js +++ /dev/null @@ -1,84 +0,0 @@ -function Grid(size) { - this.size = size; - - this.cells = []; - - this.build(); -} - -// Build a grid of the specified size -Grid.prototype.build = function () { - for (var x = 0; x < this.size; x++) { - var row = this.cells[x] = []; - - for (var y = 0; y < this.size; y++) { - row.push(null); - } - } -}; - -// Find the first available random position -Grid.prototype.randomAvailableCell = function () { - var cells = this.availableCells(); - - if (cells.length) { - return cells[Math.floor(Math.random() * cells.length)]; - } -}; - -Grid.prototype.availableCells = function () { - var cells = []; - - this.eachCell(function (x, y, tile) { - if (!tile) { - cells.push({ x: x, y: y }); - } - }); - - return cells; -}; - -// Call callback for every cell -Grid.prototype.eachCell = function (callback) { - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - callback(x, y, this.cells[x][y]); - } - } -}; - -// Check if there are any cells available -Grid.prototype.cellsAvailable = function () { - return !!this.availableCells().length; -}; - -// Check if the specified cell is taken -Grid.prototype.cellAvailable = function (cell) { - return !this.cellOccupied(cell); -}; - -Grid.prototype.cellOccupied = function (cell) { - return !!this.cellContent(cell); -}; - -Grid.prototype.cellContent = function (cell) { - if (this.withinBounds(cell)) { - return this.cells[cell.x][cell.y]; - } else { - return null; - } -}; - -// Inserts a tile at its position -Grid.prototype.insertTile = function (tile) { - this.cells[tile.x][tile.y] = tile; -}; - -Grid.prototype.removeTile = function (tile) { - this.cells[tile.x][tile.y] = null; -}; - -Grid.prototype.withinBounds = function (position) { - return position.x >= 0 && position.x < this.size && - position.y >= 0 && position.y < this.size; -}; diff --git a/sources/1597-master/js/html_actuator.js b/sources/1597-master/js/html_actuator.js deleted file mode 100644 index 9005ca1..0000000 --- a/sources/1597-master/js/html_actuator.js +++ /dev/null @@ -1,139 +0,0 @@ -function HTMLActuator() { - this.tileContainer = document.querySelector(".tile-container"); - this.scoreContainer = document.querySelector(".score-container"); - this.bestContainer = document.querySelector(".best-container"); - this.messageContainer = document.querySelector(".game-message"); - - this.score = 0; -} - -HTMLActuator.prototype.actuate = function (grid, metadata) { - var self = this; - - window.requestAnimationFrame(function () { - self.clearContainer(self.tileContainer); - - grid.cells.forEach(function (column) { - column.forEach(function (cell) { - if (cell) { - self.addTile(cell); - } - }); - }); - - self.updateScore(metadata.score); - self.updateBestScore(metadata.bestScore); - - if (metadata.terminated) { - if (metadata.over) { - self.message(false); // You lose - } else if (metadata.won) { - self.message(true); // You win! - } - } - - }); -}; - -// Continues the game (both restart and keep playing) -HTMLActuator.prototype.continue = function () { - this.clearMessage(); -}; - -HTMLActuator.prototype.clearContainer = function (container) { - while (container.firstChild) { - container.removeChild(container.firstChild); - } -}; - -HTMLActuator.prototype.addTile = function (tile) { - var self = this; - - var wrapper = document.createElement("div"); - var inner = document.createElement("div"); - var position = tile.previousPosition || { x: tile.x, y: tile.y }; - var positionClass = this.positionClass(position); - - // We can't use classlist because it somehow glitches when replacing classes - var classes = ["tile", "tile-" + tile.value, positionClass]; - - if (tile.value > 1597) classes.push("tile-super"); - - this.applyClasses(wrapper, classes); - - inner.classList.add("tile-inner"); - inner.textContent = tile.value; - - if (tile.previousPosition) { - // Make sure that the tile gets rendered in the previous position first - window.requestAnimationFrame(function () { - classes[2] = self.positionClass({ x: tile.x, y: tile.y }); - self.applyClasses(wrapper, classes); // Update the position - }); - } else if (tile.mergedFrom) { - classes.push("tile-merged"); - this.applyClasses(wrapper, classes); - - // Render the tiles that merged - tile.mergedFrom.forEach(function (merged) { - self.addTile(merged); - }); - } else { - classes.push("tile-new"); - this.applyClasses(wrapper, classes); - } - - // Add the inner part of the tile to the wrapper - wrapper.appendChild(inner); - - // Put the tile on the board - this.tileContainer.appendChild(wrapper); -}; - -HTMLActuator.prototype.applyClasses = function (element, classes) { - element.setAttribute("class", classes.join(" ")); -}; - -HTMLActuator.prototype.normalizePosition = function (position) { - return { x: position.x + 1, y: position.y + 1 }; -}; - -HTMLActuator.prototype.positionClass = function (position) { - position = this.normalizePosition(position); - return "tile-position-" + position.x + "-" + position.y; -}; - -HTMLActuator.prototype.updateScore = function (score) { - this.clearContainer(this.scoreContainer); - - var difference = score - this.score; - this.score = score; - - this.scoreContainer.textContent = this.score; - - if (difference > 0) { - var addition = document.createElement("div"); - addition.classList.add("score-addition"); - addition.textContent = "+" + difference; - - this.scoreContainer.appendChild(addition); - } -}; - -HTMLActuator.prototype.updateBestScore = function (bestScore) { - this.bestContainer.textContent = bestScore; -}; - -HTMLActuator.prototype.message = function (won) { - var type = won ? "game-won" : "game-over"; - var message = won ? "You win!" : "Game over!"; - - this.messageContainer.classList.add(type); - this.messageContainer.getElementsByTagName("p")[0].textContent = message; -}; - -HTMLActuator.prototype.clearMessage = function () { - // IE only takes one value to remove at a time. - this.messageContainer.classList.remove("game-won"); - this.messageContainer.classList.remove("game-over"); -}; diff --git a/sources/1597-master/js/keyboard_input_manager.js b/sources/1597-master/js/keyboard_input_manager.js deleted file mode 100644 index a29744c..0000000 --- a/sources/1597-master/js/keyboard_input_manager.js +++ /dev/null @@ -1,130 +0,0 @@ -function KeyboardInputManager() { - this.events = {}; - - if (window.navigator.msPointerEnabled) { - //Internet Explorer 10 style - this.eventTouchstart = "MSPointerDown"; - this.eventTouchmove = "MSPointerMove"; - this.eventTouchend = "MSPointerUp"; - } else { - this.eventTouchstart = "touchstart"; - this.eventTouchmove = "touchmove"; - this.eventTouchend = "touchend"; - } - - this.listen(); -} - -KeyboardInputManager.prototype.on = function (event, callback) { - if (!this.events[event]) { - this.events[event] = []; - } - this.events[event].push(callback); -}; - -KeyboardInputManager.prototype.emit = function (event, data) { - var callbacks = this.events[event]; - if (callbacks) { - callbacks.forEach(function (callback) { - callback(data); - }); - } -}; - -KeyboardInputManager.prototype.listen = function () { - var self = this; - - var map = { - 38: 0, // Up - 39: 1, // Right - 40: 2, // Down - 37: 3, // Left - 75: 0, // vim keybindings - 76: 1, - 74: 2, - 72: 3, - 87: 0, // W - 68: 1, // D - 83: 2, // S - 65: 3 // A - }; - - document.addEventListener("keydown", function (event) { - var modifiers = event.altKey || event.ctrlKey || event.metaKey || - event.shiftKey; - var mapped = map[event.which]; - - if (!modifiers) { - if (mapped !== undefined) { - event.preventDefault(); - self.emit("move", mapped); - } - - if (event.which === 32) self.restart.bind(self)(event); - } - }); - - var retry = document.querySelector(".retry-button"); - retry.addEventListener("click", this.restart.bind(this)); - retry.addEventListener(this.eventTouchend, this.restart.bind(this)); - - var keepPlaying = document.querySelector(".keep-playing-button"); - keepPlaying.addEventListener("click", this.keepPlaying.bind(this)); - keepPlaying.addEventListener("touchend", this.keepPlaying.bind(this)); - - // Listen to swipe events - var touchStartClientX, touchStartClientY; - var gameContainer = document.getElementsByClassName("game-container")[0]; - - gameContainer.addEventListener(this.eventTouchstart, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 1) || event.targetTouches > 1) return; - - if(window.navigator.msPointerEnabled){ - touchStartClientX = event.pageX; - touchStartClientY = event.pageY; - } else { - touchStartClientX = event.touches[0].clientX; - touchStartClientY = event.touches[0].clientY; - } - - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchmove, function (event) { - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchend, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 0) || event.targetTouches > 0) return; - - var touchEndClientX, touchEndClientY; - if(window.navigator.msPointerEnabled){ - touchEndClientX = event.pageX; - touchEndClientY = event.pageY; - } else { - touchEndClientX = event.changedTouches[0].clientX; - touchEndClientY = event.changedTouches[0].clientY; - } - - var dx = touchEndClientX - touchStartClientX; - var absDx = Math.abs(dx); - - var dy = touchEndClientY - touchStartClientY; - var absDy = Math.abs(dy); - - if (Math.max(absDx, absDy) > 10) { - // (right : left) : (down : up) - self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0)); - } - }); -}; - -KeyboardInputManager.prototype.restart = function (event) { - event.preventDefault(); - this.emit("restart"); -}; - -KeyboardInputManager.prototype.keepPlaying = function (event) { - event.preventDefault(); - this.emit("keepPlaying"); -}; diff --git a/sources/1597-master/js/local_score_manager.js b/sources/1597-master/js/local_score_manager.js deleted file mode 100644 index ec4575d..0000000 --- a/sources/1597-master/js/local_score_manager.js +++ /dev/null @@ -1,48 +0,0 @@ -window.fakeStorage = { - _data: {}, - - setItem: function (id, val) { - return this._data[id] = String(val); - }, - - getItem: function (id) { - return this._data.hasOwnProperty(id) ? this._data[id] : undefined; - }, - - removeItem: function (id) { - return delete this._data[id]; - }, - - clear: function () { - return this._data = {}; - } -}; - -function LocalScoreManager() { - this.key = "bestScore"; - - var supported = this.localStorageSupported(); - this.storage = supported ? window.localStorage : window.fakeStorage; -} - -LocalScoreManager.prototype.localStorageSupported = function () { - var testKey = "test"; - var storage = window.localStorage; - - try { - storage.setItem(testKey, "1"); - storage.removeItem(testKey); - return true; - } catch (error) { - return false; - } -}; - -LocalScoreManager.prototype.get = function () { - return this.storage.getItem(this.key) || 0; -}; - -LocalScoreManager.prototype.set = function (score) { - this.storage.setItem(this.key, score); -}; - diff --git a/sources/1597-master/js/tile.js b/sources/1597-master/js/tile.js deleted file mode 100644 index bc95230..0000000 --- a/sources/1597-master/js/tile.js +++ /dev/null @@ -1,17 +0,0 @@ -function Tile(position, value) { - this.x = position.x; - this.y = position.y; - this.value = value || 1; - - this.previousPosition = null; - this.mergedFrom = null; // Tracks tiles that merged together -} - -Tile.prototype.savePosition = function () { - this.previousPosition = { x: this.x, y: this.y }; -}; - -Tile.prototype.updatePosition = function (position) { - this.x = position.x; - this.y = position.y; -}; diff --git a/sources/1597-master/meta/apple-touch-icon.png b/sources/1597-master/meta/apple-touch-icon.png deleted file mode 100644 index 3fd20f6..0000000 Binary files a/sources/1597-master/meta/apple-touch-icon.png and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.eot b/sources/1597-master/style/fonts/ClearSans-Bold-webfont.eot deleted file mode 100644 index 3678ef2..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.eot and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.svg b/sources/1597-master/style/fonts/ClearSans-Bold-webfont.svg deleted file mode 100644 index aa985ae..0000000 --- a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.svg +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.woff b/sources/1597-master/style/fonts/ClearSans-Bold-webfont.woff deleted file mode 100644 index 184a945..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Bold-webfont.woff and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Light-webfont.eot b/sources/1597-master/style/fonts/ClearSans-Light-webfont.eot deleted file mode 100644 index 0dc609d..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Light-webfont.eot and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Light-webfont.svg b/sources/1597-master/style/fonts/ClearSans-Light-webfont.svg deleted file mode 100644 index 1d5d2ec..0000000 --- a/sources/1597-master/style/fonts/ClearSans-Light-webfont.svg +++ /dev/null @@ -1,670 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/1597-master/style/fonts/ClearSans-Light-webfont.woff b/sources/1597-master/style/fonts/ClearSans-Light-webfont.woff deleted file mode 100644 index 44555e0..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Light-webfont.woff and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.eot b/sources/1597-master/style/fonts/ClearSans-Regular-webfont.eot deleted file mode 100644 index b020e05..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.eot and /dev/null differ diff --git a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.svg b/sources/1597-master/style/fonts/ClearSans-Regular-webfont.svg deleted file mode 100644 index 1e2cffd..0000000 --- a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.svg +++ /dev/null @@ -1,669 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.woff b/sources/1597-master/style/fonts/ClearSans-Regular-webfont.woff deleted file mode 100644 index 9d58858..0000000 Binary files a/sources/1597-master/style/fonts/ClearSans-Regular-webfont.woff and /dev/null differ diff --git a/sources/1597-master/style/fonts/clear-sans.css b/sources/1597-master/style/fonts/clear-sans.css deleted file mode 100644 index de2811d..0000000 --- a/sources/1597-master/style/fonts/clear-sans.css +++ /dev/null @@ -1,30 +0,0 @@ -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Light-webfont.eot"); - src: url("ClearSans-Light-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Light-webfont.svg#clear_sans_lightregular") format("svg"), - url("ClearSans-Light-webfont.woff") format("woff"); - font-weight: 200; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Regular-webfont.eot"); - src: url("ClearSans-Regular-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Regular-webfont.svg#clear_sansregular") format("svg"), - url("ClearSans-Regular-webfont.woff") format("woff"); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Bold-webfont.eot"); - src: url("ClearSans-Bold-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Bold-webfont.svg#clear_sansbold") format("svg"), - url("ClearSans-Bold-webfont.woff") format("woff"); - font-weight: 700; - font-style: normal; -} - diff --git a/sources/1597-master/style/helpers.scss b/sources/1597-master/style/helpers.scss deleted file mode 100644 index 53b9dc1..0000000 --- a/sources/1597-master/style/helpers.scss +++ /dev/null @@ -1,72 +0,0 @@ -// Exponent -// From: https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L36 - -@function exponent($base, $exponent) { - // reset value - $value: $base; - // positive intergers get multiplied - @if $exponent > 1 { - @for $i from 2 through $exponent { - $value: $value * $base; } } - // negitive intergers get divided. A number divided by itself is 1 - @if $exponent < 1 { - @for $i from 0 through -$exponent { - $value: $value / $base; } } - // return the last value written - @return $value; -} - -@function pow($base, $exponent) { - @return exponent($base, $exponent); -} - -// Transition mixins -@mixin transition($args...) { - -webkit-transition: $args; - -moz-transition: $args; - transition: $args; -} - -@mixin transition-property($args...) { - -webkit-transition-property: $args; - -moz-transition-property: $args; - transition-property: $args; -} - -@mixin animation($args...) { - -webkit-animation: $args; - -moz-animation: $args; - animation: $args; -} - -@mixin animation-fill-mode($args...) { - -webkit-animation-fill-mode: $args; - -moz-animation-fill-mode: $args; - animation-fill-mode: $args; -} - -@mixin transform($args...) { - -webkit-transform: $args; - -moz-transform: $args; - transform: $args; -} - -// Keyframe animations -@mixin keyframes($animation-name) { - @-webkit-keyframes $animation-name { - @content; - } - @-moz-keyframes $animation-name { - @content; - } - @keyframes $animation-name { - @content; - } -} - -// Media queries -@mixin smaller($width) { - @media screen and (max-width: $width) { - @content; - } -} diff --git a/sources/1597-master/style/main.css b/sources/1597-master/style/main.css deleted file mode 100644 index 3d8013b..0000000 --- a/sources/1597-master/style/main.css +++ /dev/null @@ -1,751 +0,0 @@ -@import url(fonts/clear-sans.css); -html, body { - margin: 0; - padding: 0; - background: #faf8ef; - color: #776e65; - font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; - font-size: 18px; } - -body { - margin: 80px 0; } - -.heading:after { - content: ""; - display: block; - clear: both; } - -h1.title { - font-size: 80px; - font-weight: bold; - margin: 0; - display: block; - float: left; } - -@-webkit-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@-moz-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -.scores-container { - float: right; - text-align: right; } - -.score-container, .best-container { - position: relative; - display: inline-block; - background: #bbada0; - padding: 15px 25px; - font-size: 25px; - height: 25px; - line-height: 47px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; } - .score-container:after, .best-container:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: #eee4da; } - .score-container .score-addition, .best-container .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: 25px; - line-height: 25px; - font-weight: bold; - color: rgba(119, 110, 101, 0.9); - z-index: 100; - -webkit-animation: move-up 600ms ease-in; - -moz-animation: move-up 600ms ease-in; - animation: move-up 600ms ease-in; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - -.score-container:after { - content: "Score"; } - -.best-container:after { - content: "Record"; } - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; } - -a { - color: #776e65; - font-weight: bold; - text-decoration: underline; - cursor: pointer; } - -strong.important { - text-transform: uppercase; } - -hr { - border: none; - border-bottom: 1px solid #d8d4d0; - margin-top: 20px; - margin-bottom: 30px; } - -.container { - width: 500px; - margin: 0 auto; } - -@-webkit-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@-moz-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -.game-container { - margin-top: 40px; - position: relative; - padding: 15px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 500px; - height: 500px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(238, 228, 218, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - -.grid-container { - position: absolute; - z-index: 1; } - -.grid-row { - margin-bottom: 15px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - -.grid-cell { - width: 106.25px; - height: 106.25px; - margin-right: 15px; - float: left; - border-radius: 3px; - background: rgba(238, 228, 218, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - -.tile-container { - position: absolute; - z-index: 2; } - -.tile, .tile .tile-inner { - width: 107px; - height: 107px; - line-height: 116.25px; } -.tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } -.tile.tile-position-1-2 { - -webkit-transform: translate(0px, 121px); - -moz-transform: translate(0px, 121px); - transform: translate(0px, 121px); } -.tile.tile-position-1-3 { - -webkit-transform: translate(0px, 242px); - -moz-transform: translate(0px, 242px); - transform: translate(0px, 242px); } -.tile.tile-position-1-4 { - -webkit-transform: translate(0px, 363px); - -moz-transform: translate(0px, 363px); - transform: translate(0px, 363px); } -.tile.tile-position-2-1 { - -webkit-transform: translate(121px, 0px); - -moz-transform: translate(121px, 0px); - transform: translate(121px, 0px); } -.tile.tile-position-2-2 { - -webkit-transform: translate(121px, 121px); - -moz-transform: translate(121px, 121px); - transform: translate(121px, 121px); } -.tile.tile-position-2-3 { - -webkit-transform: translate(121px, 242px); - -moz-transform: translate(121px, 242px); - transform: translate(121px, 242px); } -.tile.tile-position-2-4 { - -webkit-transform: translate(121px, 363px); - -moz-transform: translate(121px, 363px); - transform: translate(121px, 363px); } -.tile.tile-position-3-1 { - -webkit-transform: translate(242px, 0px); - -moz-transform: translate(242px, 0px); - transform: translate(242px, 0px); } -.tile.tile-position-3-2 { - -webkit-transform: translate(242px, 121px); - -moz-transform: translate(242px, 121px); - transform: translate(242px, 121px); } -.tile.tile-position-3-3 { - -webkit-transform: translate(242px, 242px); - -moz-transform: translate(242px, 242px); - transform: translate(242px, 242px); } -.tile.tile-position-3-4 { - -webkit-transform: translate(242px, 363px); - -moz-transform: translate(242px, 363px); - transform: translate(242px, 363px); } -.tile.tile-position-4-1 { - -webkit-transform: translate(363px, 0px); - -moz-transform: translate(363px, 0px); - transform: translate(363px, 0px); } -.tile.tile-position-4-2 { - -webkit-transform: translate(363px, 121px); - -moz-transform: translate(363px, 121px); - transform: translate(363px, 121px); } -.tile.tile-position-4-3 { - -webkit-transform: translate(363px, 242px); - -moz-transform: translate(363px, 242px); - transform: translate(363px, 242px); } -.tile.tile-position-4-4 { - -webkit-transform: translate(363px, 363px); - -moz-transform: translate(363px, 363px); - transform: translate(363px, 363px); } - -.tile { - position: absolute; - -webkit-transition: 100ms ease-in-out; - -moz-transition: 100ms ease-in-out; - transition: 100ms ease-in-out; - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; } - .tile .tile-inner { - border-radius: 3px; - background: #eee4da; - text-align: center; - font-weight: bold; - z-index: 10; - font-size: 55px; } - .tile.tile-1 .tile-inner { - background: #eee4da; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-2 .tile-inner { - background: #eee4da; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-3 .tile-inner { - background: #ede0c8; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-5 .tile-inner { - color: #f9f6f2; - background: #f0c9a0; } - .tile.tile-8 .tile-inner { - color: #f9f6f2; - background: #f2b179; } - .tile.tile-13 .tile-inner { - color: #f9f6f2; - background: #f3a872; } - .tile.tile-21 .tile-inner { - color: #f9f6f2; - background: #f49e6a; } - .tile.tile-34 .tile-inner { - color: #f9f6f2; - background: #f59563; } - .tile.tile-55 .tile-inner { - color: #f9f6f2; - background: #f58961; } - .tile.tile-89 .tile-inner { - color: #f9f6f2; - background: #f67c5f; } - .tile.tile-144 .tile-inner { - color: #f9f6f2; - background: #f65e3b; - font-size: 45px; } - .tile.tile-233 .tile-inner { - color: #f9f6f2; - background: #edcc72; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.14286); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-233 .tile-inner { - font-size: 25px; } } - .tile.tile-377 .tile-inner { - color: #f9f6f2; - background: #edcc61; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746), inset 0 0 0 1px rgba(255, 255, 255, 0.19048); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-377 .tile-inner { - font-size: 25px; } } - .tile.tile-610 .tile-inner { - color: #f9f6f2; - background: #edc850; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.39683), inset 0 0 0 1px rgba(255, 255, 255, 0.2381); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-610 .tile-inner { - font-size: 25px; } } - .tile.tile-987 .tile-inner { - color: #f9f6f2; - background: #edc53f; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.47619), inset 0 0 0 1px rgba(255, 255, 255, 0.28571); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-987 .tile-inner { - font-size: 15px; } } - .tile.tile-1597 .tile-inner { - color: #f9f6f2; - background: #edc22e; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-1597 .tile-inner { - color: #f9f6f2; - background: #edc22e; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-2584 .tile-inner { - color: #f9f6f2; - background: #edc22e; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-4181 .tile-inner { - color: #f9f6f2; - background: #DDED2E; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-6765 .tile-inner { - color: #f9f6f2; - background: #B7ED2E; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-10946 .tile-inner { - color: #f9f6f2; - background: #6EED2E; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 25px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-17711 .tile-inner { - color: #f9f6f2; - background: #2EEDA1; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 25px; } - @media screen and (max-width: 520px) { - .tile.tile-1597 .tile-inner { - font-size: 15px; } } - .tile.tile-super .tile-inner { - color: #f9f6f2; - background: #3c3a32; - font-size: 30px; } - @media screen and (max-width: 520px) { - .tile.tile-super .tile-inner { - font-size: 10px; } } - -@-webkit-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-new .tile-inner { - -webkit-animation: appear 200ms ease 100ms; - -moz-animation: appear 200ms ease 100ms; - animation: appear 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -@-webkit-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-merged .tile-inner { - z-index: 20; - -webkit-animation: pop 200ms ease 100ms; - -moz-animation: pop 200ms ease 100ms; - animation: pop 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -.game-intro { - margin-bottom: 0; } - -.game-explanation { - margin-top: 50px; } - -@media screen and (max-width: 520px) { - html, body { - font-size: 15px; } - - body { - margin: 20px 0; - padding: 0 20px; } - - h1.title { - font-size: 27px; - margin-top: 15px; } - - .container { - width: 280px; - margin: 0 auto; } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; } - - .heading { - margin-bottom: 10px; } - - .game-container { - margin-top: 40px; - position: relative; - padding: 10px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 280px; - height: 280px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(238, 228, 218, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - - .grid-container { - position: absolute; - z-index: 1; } - - .grid-row { - margin-bottom: 10px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - - .grid-cell { - width: 57.5px; - height: 57.5px; - margin-right: 10px; - float: left; - border-radius: 3px; - background: rgba(238, 228, 218, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - - .tile-container { - position: absolute; - z-index: 2; } - - .tile, .tile .tile-inner { - width: 58px; - height: 58px; - line-height: 67.5px; } - .tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } - .tile.tile-position-1-2 { - -webkit-transform: translate(0px, 67px); - -moz-transform: translate(0px, 67px); - transform: translate(0px, 67px); } - .tile.tile-position-1-3 { - -webkit-transform: translate(0px, 135px); - -moz-transform: translate(0px, 135px); - transform: translate(0px, 135px); } - .tile.tile-position-1-4 { - -webkit-transform: translate(0px, 202px); - -moz-transform: translate(0px, 202px); - transform: translate(0px, 202px); } - .tile.tile-position-2-1 { - -webkit-transform: translate(67px, 0px); - -moz-transform: translate(67px, 0px); - transform: translate(67px, 0px); } - .tile.tile-position-2-2 { - -webkit-transform: translate(67px, 67px); - -moz-transform: translate(67px, 67px); - transform: translate(67px, 67px); } - .tile.tile-position-2-3 { - -webkit-transform: translate(67px, 135px); - -moz-transform: translate(67px, 135px); - transform: translate(67px, 135px); } - .tile.tile-position-2-4 { - -webkit-transform: translate(67px, 202px); - -moz-transform: translate(67px, 202px); - transform: translate(67px, 202px); } - .tile.tile-position-3-1 { - -webkit-transform: translate(135px, 0px); - -moz-transform: translate(135px, 0px); - transform: translate(135px, 0px); } - .tile.tile-position-3-2 { - -webkit-transform: translate(135px, 67px); - -moz-transform: translate(135px, 67px); - transform: translate(135px, 67px); } - .tile.tile-position-3-3 { - -webkit-transform: translate(135px, 135px); - -moz-transform: translate(135px, 135px); - transform: translate(135px, 135px); } - .tile.tile-position-3-4 { - -webkit-transform: translate(135px, 202px); - -moz-transform: translate(135px, 202px); - transform: translate(135px, 202px); } - .tile.tile-position-4-1 { - -webkit-transform: translate(202px, 0px); - -moz-transform: translate(202px, 0px); - transform: translate(202px, 0px); } - .tile.tile-position-4-2 { - -webkit-transform: translate(202px, 67px); - -moz-transform: translate(202px, 67px); - transform: translate(202px, 67px); } - .tile.tile-position-4-3 { - -webkit-transform: translate(202px, 135px); - -moz-transform: translate(202px, 135px); - transform: translate(202px, 135px); } - .tile.tile-position-4-4 { - -webkit-transform: translate(202px, 202px); - -moz-transform: translate(202px, 202px); - transform: translate(202px, 202px); } - - .game-container { - margin-top: 20px; } - - .tile .tile-inner { - font-size: 35px; } - - .game-message p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; } - .game-message .lower { - margin-top: 30px !important; } } diff --git a/sources/1597-master/style/main.scss b/sources/1597-master/style/main.scss deleted file mode 100644 index 00b6acc..0000000 --- a/sources/1597-master/style/main.scss +++ /dev/null @@ -1,519 +0,0 @@ -@import "helpers"; -@import "fonts/clear-sans.css"; - -$field-width: 500px; -$grid-spacing: 15px; -$grid-row-cells: 4; -$tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; -$tile-border-radius: 3px; - -$mobile-threshold: $field-width + 20px; - -$text-color: #776E65; -$bright-text-color: #f9f6f2; - -$tile-color: #eee4da; -$tile-gold-color: #edc22e; -$tile-gold-glow-color: lighten($tile-gold-color, 15%); - -$game-container-background: #bbada0; - -$transition-speed: 100ms; - -html, body { - margin: 0; - padding: 0; - - background: #faf8ef; - color: $text-color; - font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; - font-size: 18px; -} - -body { - margin: 80px 0; -} - -.heading:after { - content: ""; - display: block; - clear: both; -} - -h1.title { - font-size: 80px; - font-weight: bold; - margin: 0; - display: block; - float: left; -} - -@include keyframes(move-up) { - 0% { - top: 25px; - opacity: 1; - } - - 100% { - top: -50px; - opacity: 0; - } -} - -.scores-container { - float: right; - text-align: right; -} - -.score-container, .best-container { - $height: 25px; - - position: relative; - display: inline-block; - background: $game-container-background; - padding: 15px 25px; - font-size: $height; - height: $height; - line-height: $height + 22px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; - - &:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: $tile-color; - } - - .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: $height; - line-height: $height; - font-weight: bold; - color: rgba($text-color, .9); - z-index: 100; - @include animation(move-up 600ms ease-in); - @include animation-fill-mode(both); - } -} - -.score-container:after { - content: "Score"; -} - -.best-container:after { - content: "Best" -} - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; -} - -a { - color: $text-color; - font-weight: bold; - text-decoration: underline; - cursor: pointer; -} - -strong { - &.important { - text-transform: uppercase; - } -} - -hr { - border: none; - border-bottom: 1px solid lighten($text-color, 40%); - margin-top: 20px; - margin-bottom: 30px; -} - -.container { - width: $field-width; - margin: 0 auto; -} - -@include keyframes(fade-in) { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -// Styles for buttons -@mixin button { - display: inline-block; - background: darken($game-container-background, 20%); - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: $bright-text-color; - height: 40px; - line-height: 42px; -} - -// Game field mixin used to render CSS at different width -@mixin game-field { - .game-container { - margin-top: 40px; - position: relative; - padding: $grid-spacing; - - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - - background: $game-container-background; - border-radius: $tile-border-radius * 2; - width: $field-width; - height: $field-width; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - .game-message { - display: none; - - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba($tile-color, .5); - z-index: 100; - - text-align: center; - - p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; - // height: $field-width; - // line-height: $field-width; - } - - .lower { - display: block; - margin-top: 59px; - } - - a { - @include button; - margin-left: 9px; - // margin-top: 59px; - - &.keep-playing-button { - display: none; - } - } - - @include animation(fade-in 800ms ease $transition-speed * 12); - @include animation-fill-mode(both); - - &.game-won { - background: rgba($tile-gold-color, .5); - color: $bright-text-color; - - a.keep-playing-button { - display: inline-block; - } - } - - &.game-won, &.game-over { - display: block; - } - } - } - - .grid-container { - position: absolute; - z-index: 1; - } - - .grid-row { - margin-bottom: $grid-spacing; - - &:last-child { - margin-bottom: 0; - } - - &:after { - content: ""; - display: block; - clear: both; - } - } - - .grid-cell { - width: $tile-size; - height: $tile-size; - margin-right: $grid-spacing; - float: left; - - border-radius: $tile-border-radius; - - background: rgba($tile-color, .35); - - &:last-child { - margin-right: 0; - } - } - - .tile-container { - position: absolute; - z-index: 2; - } - - .tile { - &, .tile-inner { - width: ceil($tile-size); - height: ceil($tile-size); - line-height: $tile-size + 10px; - } - - // Build position classes - @for $x from 1 through $grid-row-cells { - @for $y from 1 through $grid-row-cells { - &.tile-position-#{$x}-#{$y} { - $xPos: floor(($tile-size + $grid-spacing) * ($x - 1)); - $yPos: floor(($tile-size + $grid-spacing) * ($y - 1)); - @include transform(translate($xPos, $yPos)); - } - } - } - } -} - -// End of game-field mixin -@include game-field; - -.tile { - position: absolute; // Makes transforms relative to the top-left corner - - .tile-inner { - border-radius: $tile-border-radius; - - background: $tile-color; - text-align: center; - font-weight: bold; - z-index: 10; - - font-size: 55px; - } - - // Movement transition - @include transition($transition-speed ease-in-out); - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; - - $base: 2; - $exponent: 1; - $limit: 11; - - // Colors for all 11 states, false = no special color - $special-colors: false false, // 2 - false false, // 4 - #f78e48 true, // 8 - #fc5e2e true, // 16 - #ff3333 true, // 32 - #ff0000 true, // 64 - false true, // 128 - false true, // 256 - false true, // 512 - false true, // 1024 - false true; // 2048 - - // Build tile colors - @while $exponent <= $limit { - $power: pow($base, $exponent); - - &.tile-#{$power} .tile-inner { - // Calculate base background color - $gold-percent: ($exponent - 1) / ($limit - 1) * 100; - $mixed-background: mix($tile-gold-color, $tile-color, $gold-percent); - - $nth-color: nth($special-colors, $exponent); - - $special-background: nth($nth-color, 1); - $bright-color: nth($nth-color, 2); - - @if $special-background { - $mixed-background: mix($special-background, $mixed-background, 55%); - } - - @if $bright-color { - color: $bright-text-color; - } - - // Set background - background: $mixed-background; - - // Add glow - $glow-opacity: max($exponent - 4, 0) / ($limit - 4); - - @if not $special-background { - box-shadow: 0 0 30px 10px rgba($tile-gold-glow-color, $glow-opacity / 1.8), - inset 0 0 0 1px rgba(white, $glow-opacity / 3); - } - - // Adjust font size for bigger numbers - @if $power >= 100 and $power < 1000 { - font-size: 45px; - - // Media queries placed here to avoid carrying over the rest of the logic - @include smaller($mobile-threshold) { - font-size: 25px; - } - } @else if $power >= 1000 { - font-size: 35px; - - @include smaller($mobile-threshold) { - font-size: 15px; - } - } - } - - $exponent: $exponent + 1; - } - - // Super tiles (above 2048) - &.tile-super .tile-inner { - color: $bright-text-color; - background: mix(#333, $tile-gold-color, 95%); - - font-size: 30px; - - @include smaller($mobile-threshold) { - font-size: 10px; - } - } -} - -@include keyframes(appear) { - 0% { - opacity: 0; - @include transform(scale(0)); - } - - 100% { - opacity: 1; - @include transform(scale(1)); - } -} - -.tile-new .tile-inner { - @include animation(appear 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -@include keyframes(pop) { - 0% { - @include transform(scale(0)); - } - - 50% { - @include transform(scale(1.2)); - } - - 100% { - @include transform(scale(1)); - } -} - -.tile-merged .tile-inner { - z-index: 20; - @include animation(pop 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -.game-intro { - margin-bottom: 0; -} - -.game-explanation { - margin-top: 50px; -} - -@include smaller($mobile-threshold) { - // Redefine variables for smaller screens - $field-width: 280px; - $grid-spacing: 10px; - $grid-row-cells: 4; - $tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; - $tile-border-radius: 3px; - - html, body { - font-size: 15px; - } - - body { - margin: 20px 0; - padding: 0 20px; - } - - h1.title { - font-size: 27px; - margin-top: 15px; - } - - .container { - width: $field-width; - margin: 0 auto; - } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; - } - - .heading { - margin-bottom: 10px; - } - - // Render the game field at the right width - @include game-field; - - .game-container { - margin-top: 20px; - } - - // Rest of the font-size adjustments in the tile class - .tile .tile-inner { - font-size: 35px; - } - - .game-message { - p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; - } - - .lower { - margin-top: 30px !important; - } - } -} diff --git a/sources/2048frama/.gitignore b/sources/2048frama/.gitignore deleted file mode 100644 index 0d31019..0000000 --- a/sources/2048frama/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.sass-cache/ diff --git a/sources/2048frama/.jshintrc b/sources/2048frama/.jshintrc deleted file mode 100644 index 87dbf9a..0000000 --- a/sources/2048frama/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "esnext": true, - "indent": 2, - "maxlen": 80, - "freeze": true, - "camelcase": true, - "unused": true, - "eqnull": true, - "proto": true, - "supernew": true, - "noyield": true, - "evil": true, - "node": true, - "boss": true, - "expr": true, - "loopfunc": true, - "white": true, - "maxdepth": 4 -} diff --git a/sources/2048frama/CONTRIBUTING.md b/sources/2048frama/CONTRIBUTING.md deleted file mode 100644 index 968baa9..0000000 --- a/sources/2048frama/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -## Contributing -Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specifically made branch and request to pull on `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process. diff --git a/sources/2048frama/LICENSE.txt b/sources/2048frama/LICENSE.txt deleted file mode 100644 index b0dbfa4..0000000 --- a/sources/2048frama/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Gabriele Cirulli - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/sources/2048frama/README.md b/sources/2048frama/README.md deleted file mode 100644 index 215a632..0000000 --- a/sources/2048frama/README.md +++ /dev/null @@ -1 +0,0 @@ -Made just for fun. [Play it here!](http://amschrader.github.io/2048/) diff --git a/sources/2048frama/favicon.ico b/sources/2048frama/favicon.ico deleted file mode 100644 index 22109e0..0000000 Binary files a/sources/2048frama/favicon.ico and /dev/null differ diff --git a/sources/2048frama/im/favicon.png b/sources/2048frama/im/favicon.png deleted file mode 100644 index a5d1982..0000000 Binary files a/sources/2048frama/im/favicon.png and /dev/null differ diff --git a/sources/2048frama/im/framablog.png b/sources/2048frama/im/framablog.png deleted file mode 100644 index 339b1c2..0000000 Binary files a/sources/2048frama/im/framablog.png and /dev/null differ diff --git a/sources/2048frama/im/framabook.png b/sources/2048frama/im/framabook.png deleted file mode 100644 index 8984ee6..0000000 Binary files a/sources/2048frama/im/framabook.png and /dev/null differ diff --git a/sources/2048frama/im/framadvd.png b/sources/2048frama/im/framadvd.png deleted file mode 100644 index 0c598fc..0000000 Binary files a/sources/2048frama/im/framadvd.png and /dev/null differ diff --git a/sources/2048frama/im/framakey.png b/sources/2048frama/im/framakey.png deleted file mode 100644 index 9799a19..0000000 Binary files a/sources/2048frama/im/framakey.png and /dev/null differ diff --git a/sources/2048frama/im/framamindmap.png b/sources/2048frama/im/framamindmap.png deleted file mode 100644 index 19dfbee..0000000 Binary files a/sources/2048frama/im/framamindmap.png and /dev/null differ diff --git a/sources/2048frama/im/framapad.png b/sources/2048frama/im/framapad.png deleted file mode 100644 index a1dffab..0000000 Binary files a/sources/2048frama/im/framapad.png and /dev/null differ diff --git a/sources/2048frama/im/framasoft.png b/sources/2048frama/im/framasoft.png deleted file mode 100644 index ca42215..0000000 Binary files a/sources/2048frama/im/framasoft.png and /dev/null differ diff --git a/sources/2048frama/im/framatube.png b/sources/2048frama/im/framatube.png deleted file mode 100644 index 778a8bc..0000000 Binary files a/sources/2048frama/im/framatube.png and /dev/null differ diff --git a/sources/2048frama/im/framazic.png b/sources/2048frama/im/framazic.png deleted file mode 100644 index d814d38..0000000 Binary files a/sources/2048frama/im/framazic.png and /dev/null differ diff --git a/sources/2048frama/im/goldenframa.png b/sources/2048frama/im/goldenframa.png deleted file mode 100644 index 4f3617d..0000000 Binary files a/sources/2048frama/im/goldenframa.png and /dev/null differ diff --git a/sources/2048frama/im/soutenir.png b/sources/2048frama/im/soutenir.png deleted file mode 100644 index ae4b8cd..0000000 Binary files a/sources/2048frama/im/soutenir.png and /dev/null differ diff --git a/sources/2048frama/index.html b/sources/2048frama/index.html deleted file mode 100644 index b918c41..0000000 --- a/sources/2048frama/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - 2048 - - - - - - - - - - - -
-
-

2048 Frama

-
-
0
-
0
-
-
-

Assemble les tuiles identiques pour réussir à découvrir !

- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
- -

- Comment jouer : Utilisez les flèches du clavier pour déplacer les tuiles. Quand deux tuiles avec le même dessin se touchent, elles fusionnent ! -

-
-

- Note : Framasoft héberge une version personnalisée du jeu créé par Gabriele Cirulli. sous licence libre MIT. -

-
- - - - - - - - - - - - diff --git a/sources/2048frama/js/animframe_polyfill.js b/sources/2048frama/js/animframe_polyfill.js deleted file mode 100644 index c45a13e..0000000 --- a/sources/2048frama/js/animframe_polyfill.js +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var lastTime = 0; - var vendors = ['webkit', 'moz']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - } - - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - } -}()); diff --git a/sources/2048frama/js/application.js b/sources/2048frama/js/application.js deleted file mode 100644 index a4d310a..0000000 --- a/sources/2048frama/js/application.js +++ /dev/null @@ -1,4 +0,0 @@ -// Wait till the browser is ready to render the game (avoids glitches) -window.requestAnimationFrame(function () { - new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager); -}); diff --git a/sources/2048frama/js/game_manager.js b/sources/2048frama/js/game_manager.js deleted file mode 100644 index b36aea3..0000000 --- a/sources/2048frama/js/game_manager.js +++ /dev/null @@ -1,245 +0,0 @@ -function GameManager(size, InputManager, Actuator, ScoreManager) { - this.size = size; // Size of the grid - this.inputManager = new InputManager; - this.scoreManager = new ScoreManager; - this.actuator = new Actuator; - - this.startTiles = 2; - - this.inputManager.on("move", this.move.bind(this)); - this.inputManager.on("restart", this.restart.bind(this)); - this.inputManager.on("keepPlaying", this.keepPlaying.bind(this)); - - this.setup(); -} - -// Restart the game -GameManager.prototype.restart = function () { - this.actuator.continue(); - this.setup(); -}; - -// Keep playing after winning -GameManager.prototype.keepPlaying = function () { - this.keepPlaying = true; - this.actuator.continue(); -}; - -GameManager.prototype.isGameTerminated = function () { - if (this.over || (this.won && !this.keepPlaying)) { - return true; - } else { - return false; - } -}; - -// Set up the game -GameManager.prototype.setup = function () { - this.grid = new Grid(this.size); - - this.score = 0; - this.over = false; - this.won = false; - this.keepPlaying = false; - - // Add the initial tiles - this.addStartTiles(); - - // Update the actuator - this.actuate(); -}; - -// Set up the initial tiles to start the game with -GameManager.prototype.addStartTiles = function () { - for (var i = 0; i < this.startTiles; i++) { - this.addRandomTile(); - } -}; - -// Adds a tile in a random position -GameManager.prototype.addRandomTile = function () { - if (this.grid.cellsAvailable()) { - var value = Math.random() < 0.9 ? 2 : 4; - var tile = new Tile(this.grid.randomAvailableCell(), value); - - this.grid.insertTile(tile); - } -}; - -// Sends the updated grid to the actuator -GameManager.prototype.actuate = function () { - if (this.scoreManager.get() < this.score) { - this.scoreManager.set(this.score); - } - - this.actuator.actuate(this.grid, { - score: this.score, - over: this.over, - won: this.won, - bestScore: this.scoreManager.get(), - terminated: this.isGameTerminated() - }); - -}; - -// Save all tile positions and remove merger info -GameManager.prototype.prepareTiles = function () { - this.grid.eachCell(function (x, y, tile) { - if (tile) { - tile.mergedFrom = null; - tile.savePosition(); - } - }); -}; - -// Move a tile and its representation -GameManager.prototype.moveTile = function (tile, cell) { - this.grid.cells[tile.x][tile.y] = null; - this.grid.cells[cell.x][cell.y] = tile; - tile.updatePosition(cell); -}; - -// Move tiles on the grid in the specified direction -GameManager.prototype.move = function (direction) { - // 0: up, 1: right, 2:down, 3: left - var self = this; - - if (this.isGameTerminated()) return; // Don't do anything if the game's over - - var cell, tile; - - var vector = this.getVector(direction); - var traversals = this.buildTraversals(vector); - var moved = false; - - // Save the current tile positions and remove merger information - this.prepareTiles(); - - // Traverse the grid in the right direction and move tiles - traversals.x.forEach(function (x) { - traversals.y.forEach(function (y) { - cell = { x: x, y: y }; - tile = self.grid.cellContent(cell); - - if (tile) { - var positions = self.findFarthestPosition(cell, vector); - var next = self.grid.cellContent(positions.next); - - // Only one merger per row traversal? - if (next && next.value === tile.value && !next.mergedFrom) { - var merged = new Tile(positions.next, tile.value * 2); - merged.mergedFrom = [tile, next]; - - self.grid.insertTile(merged); - self.grid.removeTile(tile); - - // Converge the two tiles' positions - tile.updatePosition(positions.next); - - // Update the score - self.score += merged.value; - - // The mighty 2048 tile - if (merged.value === 2048) self.won = true; - } else { - self.moveTile(tile, positions.farthest); - } - - if (!self.positionsEqual(cell, tile)) { - moved = true; // The tile moved from its original cell! - } - } - }); - }); - - if (moved) { - this.addRandomTile(); - - if (!this.movesAvailable()) { - this.over = true; // Game over! - } - - this.actuate(); - } -}; - -// Get the vector representing the chosen direction -GameManager.prototype.getVector = function (direction) { - // Vectors representing tile movement - var map = { - 0: { x: 0, y: -1 }, // up - 1: { x: 1, y: 0 }, // right - 2: { x: 0, y: 1 }, // down - 3: { x: -1, y: 0 } // left - }; - - return map[direction]; -}; - -// Build a list of positions to traverse in the right order -GameManager.prototype.buildTraversals = function (vector) { - var traversals = { x: [], y: [] }; - - for (var pos = 0; pos < this.size; pos++) { - traversals.x.push(pos); - traversals.y.push(pos); - } - - // Always traverse from the farthest cell in the chosen direction - if (vector.x === 1) traversals.x = traversals.x.reverse(); - if (vector.y === 1) traversals.y = traversals.y.reverse(); - - return traversals; -}; - -GameManager.prototype.findFarthestPosition = function (cell, vector) { - var previous; - - // Progress towards the vector direction until an obstacle is found - do { - previous = cell; - cell = { x: previous.x + vector.x, y: previous.y + vector.y }; - } while (this.grid.withinBounds(cell) && - this.grid.cellAvailable(cell)); - - return { - farthest: previous, - next: cell // Used to check if a merge is required - }; -}; - -GameManager.prototype.movesAvailable = function () { - return this.grid.cellsAvailable() || this.tileMatchesAvailable(); -}; - -// Check for available matches between tiles (more expensive check) -GameManager.prototype.tileMatchesAvailable = function () { - var self = this; - - var tile; - - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - tile = this.grid.cellContent({ x: x, y: y }); - - if (tile) { - for (var direction = 0; direction < 4; direction++) { - var vector = self.getVector(direction); - var cell = { x: x + vector.x, y: y + vector.y }; - - var other = self.grid.cellContent(cell); - - if (other && other.value === tile.value) { - return true; // These two tiles can be merged - } - } - } - } - } - - return false; -}; - -GameManager.prototype.positionsEqual = function (first, second) { - return first.x === second.x && first.y === second.y; -}; diff --git a/sources/2048frama/js/grid.js b/sources/2048frama/js/grid.js deleted file mode 100644 index 05fe057..0000000 --- a/sources/2048frama/js/grid.js +++ /dev/null @@ -1,84 +0,0 @@ -function Grid(size) { - this.size = size; - - this.cells = []; - - this.build(); -} - -// Build a grid of the specified size -Grid.prototype.build = function () { - for (var x = 0; x < this.size; x++) { - var row = this.cells[x] = []; - - for (var y = 0; y < this.size; y++) { - row.push(null); - } - } -}; - -// Find the first available random position -Grid.prototype.randomAvailableCell = function () { - var cells = this.availableCells(); - - if (cells.length) { - return cells[Math.floor(Math.random() * cells.length)]; - } -}; - -Grid.prototype.availableCells = function () { - var cells = []; - - this.eachCell(function (x, y, tile) { - if (!tile) { - cells.push({ x: x, y: y }); - } - }); - - return cells; -}; - -// Call callback for every cell -Grid.prototype.eachCell = function (callback) { - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - callback(x, y, this.cells[x][y]); - } - } -}; - -// Check if there are any cells available -Grid.prototype.cellsAvailable = function () { - return !!this.availableCells().length; -}; - -// Check if the specified cell is taken -Grid.prototype.cellAvailable = function (cell) { - return !this.cellOccupied(cell); -}; - -Grid.prototype.cellOccupied = function (cell) { - return !!this.cellContent(cell); -}; - -Grid.prototype.cellContent = function (cell) { - if (this.withinBounds(cell)) { - return this.cells[cell.x][cell.y]; - } else { - return null; - } -}; - -// Inserts a tile at its position -Grid.prototype.insertTile = function (tile) { - this.cells[tile.x][tile.y] = tile; -}; - -Grid.prototype.removeTile = function (tile) { - this.cells[tile.x][tile.y] = null; -}; - -Grid.prototype.withinBounds = function (position) { - return position.x >= 0 && position.x < this.size && - position.y >= 0 && position.y < this.size; -}; diff --git a/sources/2048frama/js/html_actuator.js b/sources/2048frama/js/html_actuator.js deleted file mode 100644 index 7d20907..0000000 --- a/sources/2048frama/js/html_actuator.js +++ /dev/null @@ -1,139 +0,0 @@ -function HTMLActuator() { - this.tileContainer = document.querySelector(".tile-container"); - this.scoreContainer = document.querySelector(".score-container"); - this.bestContainer = document.querySelector(".best-container"); - this.messageContainer = document.querySelector(".game-message"); - - this.score = 0; -} - -HTMLActuator.prototype.actuate = function (grid, metadata) { - var self = this; - - window.requestAnimationFrame(function () { - self.clearContainer(self.tileContainer); - - grid.cells.forEach(function (column) { - column.forEach(function (cell) { - if (cell) { - self.addTile(cell); - } - }); - }); - - self.updateScore(metadata.score); - self.updateBestScore(metadata.bestScore); - - if (metadata.terminated) { - if (metadata.over) { - self.message(false); // You lose - } else if (metadata.won) { - self.message(true); // You win! - } - } - - }); -}; - -// Continues the game (both restart and keep playing) -HTMLActuator.prototype.continue = function () { - this.clearMessage(); -}; - -HTMLActuator.prototype.clearContainer = function (container) { - while (container.firstChild) { - container.removeChild(container.firstChild); - } -}; - -HTMLActuator.prototype.addTile = function (tile) { - var self = this; - - var wrapper = document.createElement("div"); - var inner = document.createElement("div"); - var position = tile.previousPosition || { x: tile.x, y: tile.y }; - var positionClass = this.positionClass(position); - - // We can't use classlist because it somehow glitches when replacing classes - var classes = ["tile", "tile-" + tile.value, positionClass]; - - if (tile.value > 2048) classes.push("tile-super"); - - this.applyClasses(wrapper, classes); - - inner.classList.add("tile-inner"); - inner.textContent = tile.value; - - if (tile.previousPosition) { - // Make sure that the tile gets rendered in the previous position first - window.requestAnimationFrame(function () { - classes[2] = self.positionClass({ x: tile.x, y: tile.y }); - self.applyClasses(wrapper, classes); // Update the position - }); - } else if (tile.mergedFrom) { - classes.push("tile-merged"); - this.applyClasses(wrapper, classes); - - // Render the tiles that merged - tile.mergedFrom.forEach(function (merged) { - self.addTile(merged); - }); - } else { - classes.push("tile-new"); - this.applyClasses(wrapper, classes); - } - - // Add the inner part of the tile to the wrapper - wrapper.appendChild(inner); - - // Put the tile on the board - this.tileContainer.appendChild(wrapper); -}; - -HTMLActuator.prototype.applyClasses = function (element, classes) { - element.setAttribute("class", classes.join(" ")); -}; - -HTMLActuator.prototype.normalizePosition = function (position) { - return { x: position.x + 1, y: position.y + 1 }; -}; - -HTMLActuator.prototype.positionClass = function (position) { - position = this.normalizePosition(position); - return "tile-position-" + position.x + "-" + position.y; -}; - -HTMLActuator.prototype.updateScore = function (score) { - this.clearContainer(this.scoreContainer); - - var difference = score - this.score; - this.score = score; - - this.scoreContainer.textContent = this.score; - - if (difference > 0) { - var addition = document.createElement("div"); - addition.classList.add("score-addition"); - addition.textContent = "+" + difference; - - this.scoreContainer.appendChild(addition); - } -}; - -HTMLActuator.prototype.updateBestScore = function (bestScore) { - this.bestContainer.textContent = bestScore; -}; - -HTMLActuator.prototype.message = function (won) { - var type = won ? "game-won" : "game-over"; - var message = won ? "Vous avez gagné !" : "Game over !"; - - this.messageContainer.classList.add(type); - this.messageContainer.getElementsByTagName("p")[0].textContent = message; -}; - -HTMLActuator.prototype.clearMessage = function () { - // IE only takes one value to remove at a time. - this.messageContainer.classList.remove("game-won"); - this.messageContainer.classList.remove("game-over"); -}; diff --git a/sources/2048frama/js/keyboard_input_manager.js b/sources/2048frama/js/keyboard_input_manager.js deleted file mode 100644 index a29744c..0000000 --- a/sources/2048frama/js/keyboard_input_manager.js +++ /dev/null @@ -1,130 +0,0 @@ -function KeyboardInputManager() { - this.events = {}; - - if (window.navigator.msPointerEnabled) { - //Internet Explorer 10 style - this.eventTouchstart = "MSPointerDown"; - this.eventTouchmove = "MSPointerMove"; - this.eventTouchend = "MSPointerUp"; - } else { - this.eventTouchstart = "touchstart"; - this.eventTouchmove = "touchmove"; - this.eventTouchend = "touchend"; - } - - this.listen(); -} - -KeyboardInputManager.prototype.on = function (event, callback) { - if (!this.events[event]) { - this.events[event] = []; - } - this.events[event].push(callback); -}; - -KeyboardInputManager.prototype.emit = function (event, data) { - var callbacks = this.events[event]; - if (callbacks) { - callbacks.forEach(function (callback) { - callback(data); - }); - } -}; - -KeyboardInputManager.prototype.listen = function () { - var self = this; - - var map = { - 38: 0, // Up - 39: 1, // Right - 40: 2, // Down - 37: 3, // Left - 75: 0, // vim keybindings - 76: 1, - 74: 2, - 72: 3, - 87: 0, // W - 68: 1, // D - 83: 2, // S - 65: 3 // A - }; - - document.addEventListener("keydown", function (event) { - var modifiers = event.altKey || event.ctrlKey || event.metaKey || - event.shiftKey; - var mapped = map[event.which]; - - if (!modifiers) { - if (mapped !== undefined) { - event.preventDefault(); - self.emit("move", mapped); - } - - if (event.which === 32) self.restart.bind(self)(event); - } - }); - - var retry = document.querySelector(".retry-button"); - retry.addEventListener("click", this.restart.bind(this)); - retry.addEventListener(this.eventTouchend, this.restart.bind(this)); - - var keepPlaying = document.querySelector(".keep-playing-button"); - keepPlaying.addEventListener("click", this.keepPlaying.bind(this)); - keepPlaying.addEventListener("touchend", this.keepPlaying.bind(this)); - - // Listen to swipe events - var touchStartClientX, touchStartClientY; - var gameContainer = document.getElementsByClassName("game-container")[0]; - - gameContainer.addEventListener(this.eventTouchstart, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 1) || event.targetTouches > 1) return; - - if(window.navigator.msPointerEnabled){ - touchStartClientX = event.pageX; - touchStartClientY = event.pageY; - } else { - touchStartClientX = event.touches[0].clientX; - touchStartClientY = event.touches[0].clientY; - } - - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchmove, function (event) { - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchend, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 0) || event.targetTouches > 0) return; - - var touchEndClientX, touchEndClientY; - if(window.navigator.msPointerEnabled){ - touchEndClientX = event.pageX; - touchEndClientY = event.pageY; - } else { - touchEndClientX = event.changedTouches[0].clientX; - touchEndClientY = event.changedTouches[0].clientY; - } - - var dx = touchEndClientX - touchStartClientX; - var absDx = Math.abs(dx); - - var dy = touchEndClientY - touchStartClientY; - var absDy = Math.abs(dy); - - if (Math.max(absDx, absDy) > 10) { - // (right : left) : (down : up) - self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0)); - } - }); -}; - -KeyboardInputManager.prototype.restart = function (event) { - event.preventDefault(); - this.emit("restart"); -}; - -KeyboardInputManager.prototype.keepPlaying = function (event) { - event.preventDefault(); - this.emit("keepPlaying"); -}; diff --git a/sources/2048frama/js/local_score_manager.js b/sources/2048frama/js/local_score_manager.js deleted file mode 100644 index ec4575d..0000000 --- a/sources/2048frama/js/local_score_manager.js +++ /dev/null @@ -1,48 +0,0 @@ -window.fakeStorage = { - _data: {}, - - setItem: function (id, val) { - return this._data[id] = String(val); - }, - - getItem: function (id) { - return this._data.hasOwnProperty(id) ? this._data[id] : undefined; - }, - - removeItem: function (id) { - return delete this._data[id]; - }, - - clear: function () { - return this._data = {}; - } -}; - -function LocalScoreManager() { - this.key = "bestScore"; - - var supported = this.localStorageSupported(); - this.storage = supported ? window.localStorage : window.fakeStorage; -} - -LocalScoreManager.prototype.localStorageSupported = function () { - var testKey = "test"; - var storage = window.localStorage; - - try { - storage.setItem(testKey, "1"); - storage.removeItem(testKey); - return true; - } catch (error) { - return false; - } -}; - -LocalScoreManager.prototype.get = function () { - return this.storage.getItem(this.key) || 0; -}; - -LocalScoreManager.prototype.set = function (score) { - this.storage.setItem(this.key, score); -}; - diff --git a/sources/2048frama/js/tile.js b/sources/2048frama/js/tile.js deleted file mode 100644 index de08333..0000000 --- a/sources/2048frama/js/tile.js +++ /dev/null @@ -1,17 +0,0 @@ -function Tile(position, value) { - this.x = position.x; - this.y = position.y; - this.value = value || 2; - - this.previousPosition = null; - this.mergedFrom = null; // Tracks tiles that merged together -} - -Tile.prototype.savePosition = function () { - this.previousPosition = { x: this.x, y: this.y }; -}; - -Tile.prototype.updatePosition = function (position) { - this.x = position.x; - this.y = position.y; -}; diff --git a/sources/2048frama/meta/apple-touch-icon.png b/sources/2048frama/meta/apple-touch-icon.png deleted file mode 100644 index 3fd20f6..0000000 Binary files a/sources/2048frama/meta/apple-touch-icon.png and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.eot b/sources/2048frama/style/fonts/ClearSans-Bold-webfont.eot deleted file mode 100644 index 3678ef2..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.eot and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.svg b/sources/2048frama/style/fonts/ClearSans-Bold-webfont.svg deleted file mode 100644 index aa985ae..0000000 --- a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.svg +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.woff b/sources/2048frama/style/fonts/ClearSans-Bold-webfont.woff deleted file mode 100644 index 184a945..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Bold-webfont.woff and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Light-webfont.eot b/sources/2048frama/style/fonts/ClearSans-Light-webfont.eot deleted file mode 100644 index 0dc609d..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Light-webfont.eot and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Light-webfont.svg b/sources/2048frama/style/fonts/ClearSans-Light-webfont.svg deleted file mode 100644 index 1d5d2ec..0000000 --- a/sources/2048frama/style/fonts/ClearSans-Light-webfont.svg +++ /dev/null @@ -1,670 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048frama/style/fonts/ClearSans-Light-webfont.woff b/sources/2048frama/style/fonts/ClearSans-Light-webfont.woff deleted file mode 100644 index 44555e0..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Light-webfont.woff and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.eot b/sources/2048frama/style/fonts/ClearSans-Regular-webfont.eot deleted file mode 100644 index b020e05..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.eot and /dev/null differ diff --git a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.svg b/sources/2048frama/style/fonts/ClearSans-Regular-webfont.svg deleted file mode 100644 index 1e2cffd..0000000 --- a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.svg +++ /dev/null @@ -1,669 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.woff b/sources/2048frama/style/fonts/ClearSans-Regular-webfont.woff deleted file mode 100644 index 9d58858..0000000 Binary files a/sources/2048frama/style/fonts/ClearSans-Regular-webfont.woff and /dev/null differ diff --git a/sources/2048frama/style/fonts/clear-sans.css b/sources/2048frama/style/fonts/clear-sans.css deleted file mode 100644 index de2811d..0000000 --- a/sources/2048frama/style/fonts/clear-sans.css +++ /dev/null @@ -1,30 +0,0 @@ -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Light-webfont.eot"); - src: url("ClearSans-Light-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Light-webfont.svg#clear_sans_lightregular") format("svg"), - url("ClearSans-Light-webfont.woff") format("woff"); - font-weight: 200; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Regular-webfont.eot"); - src: url("ClearSans-Regular-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Regular-webfont.svg#clear_sansregular") format("svg"), - url("ClearSans-Regular-webfont.woff") format("woff"); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Bold-webfont.eot"); - src: url("ClearSans-Bold-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Bold-webfont.svg#clear_sansbold") format("svg"), - url("ClearSans-Bold-webfont.woff") format("woff"); - font-weight: 700; - font-style: normal; -} - diff --git a/sources/2048frama/style/helpers.scss b/sources/2048frama/style/helpers.scss deleted file mode 100644 index 53b9dc1..0000000 --- a/sources/2048frama/style/helpers.scss +++ /dev/null @@ -1,72 +0,0 @@ -// Exponent -// From: https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L36 - -@function exponent($base, $exponent) { - // reset value - $value: $base; - // positive intergers get multiplied - @if $exponent > 1 { - @for $i from 2 through $exponent { - $value: $value * $base; } } - // negitive intergers get divided. A number divided by itself is 1 - @if $exponent < 1 { - @for $i from 0 through -$exponent { - $value: $value / $base; } } - // return the last value written - @return $value; -} - -@function pow($base, $exponent) { - @return exponent($base, $exponent); -} - -// Transition mixins -@mixin transition($args...) { - -webkit-transition: $args; - -moz-transition: $args; - transition: $args; -} - -@mixin transition-property($args...) { - -webkit-transition-property: $args; - -moz-transition-property: $args; - transition-property: $args; -} - -@mixin animation($args...) { - -webkit-animation: $args; - -moz-animation: $args; - animation: $args; -} - -@mixin animation-fill-mode($args...) { - -webkit-animation-fill-mode: $args; - -moz-animation-fill-mode: $args; - animation-fill-mode: $args; -} - -@mixin transform($args...) { - -webkit-transform: $args; - -moz-transform: $args; - transform: $args; -} - -// Keyframe animations -@mixin keyframes($animation-name) { - @-webkit-keyframes $animation-name { - @content; - } - @-moz-keyframes $animation-name { - @content; - } - @keyframes $animation-name { - @content; - } -} - -// Media queries -@mixin smaller($width) { - @media screen and (max-width: $width) { - @content; - } -} diff --git a/sources/2048frama/style/main.css b/sources/2048frama/style/main.css deleted file mode 100644 index 5bf4b55..0000000 --- a/sources/2048frama/style/main.css +++ /dev/null @@ -1,716 +0,0 @@ -@import url(fonts/clear-sans.css); -html, body { - margin: 0; - padding: 0; - background: #faf8ef; - color: #776e65; - font-family: "Helvetica Neue", Arial, sans-serif; - font-size: 18px; } - -body { - margin: 80px 0; } - -.heading:after { - content: ""; - display: block; - clear: both; } - -h1.title { - font-size: 40px; - font-weight: bold; - margin: 0; - display: block; - float: left; } - -@-webkit-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@-moz-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -.scores-container { - float: right; - text-align: right; } - -.score-container, .best-container { - position: relative; - display: inline-block; - background: #bbada0; - padding: 15px 25px; - font-size: 25px; - height: 25px; - line-height: 47px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; } - .score-container:after, .best-container:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: #eee4da; } - .score-container .score-addition, .best-container .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: 25px; - line-height: 25px; - font-weight: bold; - color: rgba(119, 110, 101, 0.9); - z-index: 100; - -webkit-animation: move-up 600ms ease-in; - -moz-animation: move-up 600ms ease-in; - animation: move-up 600ms ease-in; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - -.score-container:after { - content: "Score"; } - -.best-container:after { - content: "Record"; } - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; } - -a { - color: #776e65; - font-weight: bold; - text-decoration: underline; - cursor: pointer; } - -strong.important { - text-transform: uppercase; } - -hr { - border: none; - border-bottom: 1px solid #d8d4d0; - margin-top: 20px; - margin-bottom: 30px; } - -.container { - width: 500px; - margin: 0 auto; } - -@-webkit-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@-moz-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -.game-container { - margin-top: 40px; - position: relative; - padding: 15px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 500px; - height: 500px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(238, 228, 218, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - -.grid-container { - position: absolute; - z-index: 1; } - -.grid-row { - margin-bottom: 15px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - -.grid-cell { - width: 106.25px; - height: 106.25px; - margin-right: 15px; - float: left; - border-radius: 3px; - background: rgba(238, 228, 218, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - -.tile-container { - position: absolute; - z-index: 2; } - -.tile, .tile .tile-inner { - width: 107px; - height: 107px; - line-height: 116.25px; } -.tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } -.tile.tile-position-1-2 { - -webkit-transform: translate(0px, 121px); - -moz-transform: translate(0px, 121px); - transform: translate(0px, 121px); } -.tile.tile-position-1-3 { - -webkit-transform: translate(0px, 242px); - -moz-transform: translate(0px, 242px); - transform: translate(0px, 242px); } -.tile.tile-position-1-4 { - -webkit-transform: translate(0px, 363px); - -moz-transform: translate(0px, 363px); - transform: translate(0px, 363px); } -.tile.tile-position-2-1 { - -webkit-transform: translate(121px, 0px); - -moz-transform: translate(121px, 0px); - transform: translate(121px, 0px); } -.tile.tile-position-2-2 { - -webkit-transform: translate(121px, 121px); - -moz-transform: translate(121px, 121px); - transform: translate(121px, 121px); } -.tile.tile-position-2-3 { - -webkit-transform: translate(121px, 242px); - -moz-transform: translate(121px, 242px); - transform: translate(121px, 242px); } -.tile.tile-position-2-4 { - -webkit-transform: translate(121px, 363px); - -moz-transform: translate(121px, 363px); - transform: translate(121px, 363px); } -.tile.tile-position-3-1 { - -webkit-transform: translate(242px, 0px); - -moz-transform: translate(242px, 0px); - transform: translate(242px, 0px); } -.tile.tile-position-3-2 { - -webkit-transform: translate(242px, 121px); - -moz-transform: translate(242px, 121px); - transform: translate(242px, 121px); } -.tile.tile-position-3-3 { - -webkit-transform: translate(242px, 242px); - -moz-transform: translate(242px, 242px); - transform: translate(242px, 242px); } -.tile.tile-position-3-4 { - -webkit-transform: translate(242px, 363px); - -moz-transform: translate(242px, 363px); - transform: translate(242px, 363px); } -.tile.tile-position-4-1 { - -webkit-transform: translate(363px, 0px); - -moz-transform: translate(363px, 0px); - transform: translate(363px, 0px); } -.tile.tile-position-4-2 { - -webkit-transform: translate(363px, 121px); - -moz-transform: translate(363px, 121px); - transform: translate(363px, 121px); } -.tile.tile-position-4-3 { - -webkit-transform: translate(363px, 242px); - -moz-transform: translate(363px, 242px); - transform: translate(363px, 242px); } -.tile.tile-position-4-4 { - -webkit-transform: translate(363px, 363px); - -moz-transform: translate(363px, 363px); - transform: translate(363px, 363px); } - -.tile { - position: absolute; - -webkit-transition: 100ms ease-in-out; - -moz-transition: 100ms ease-in-out; - transition: 100ms ease-in-out; - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; } - .tile .tile-inner { - border-radius: 3px; - background: #eee4da; - text-align: center; - font-weight: bold; - z-index: 10; - font-size: 55px; } - .tile.tile-2 .tile-inner { - background: #eee4da; - background-image: url("../im/soutenir.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-4 .tile-inner { - background: #ede0c8; - background-image: url("../im/framamindmap.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-8 .tile-inner { - background: #bb9bbf; - background-image: url("../im/framadvd.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-16 .tile-inner { - background: #f8a389; - background-image: url("../im/framazic.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-32 .tile-inner { - background: #d8b74d; - background-image: url("../im/framatube.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.07937), inset 0 0 0 1px rgba(255, 255, 255, 0.04762); } - .tile.tile-64 .tile-inner { - background: #f0a751; - background-image: url("../im/framakey.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.15873), inset 0 0 0 1px rgba(255, 255, 255, 0.09524); } - .tile.tile-128 .tile-inner { - background: #7e8c87; - background-image: url("../im/framabook.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - .tile.tile-256 .tile-inner { - background: #fbeb76; - background-image: url("../im/framapad.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - .tile.tile-512 .tile-inner { - background: #4da66d; - background-image: url("../im/framablog.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - .tile.tile-1024 .tile-inner { - background: #89a9d7; - background-image: url("../im/favicon.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - .tile.tile-2048 .tile-inner { - background: #c76d5c; - background-image: url("../im/framasoft.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - .tile.tile-super .tile-inner { - color: #f9f6f2; - background: #3c3a32; - background-image: url("../im/goldenframa.png"); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; } - @media screen and (max-width: 520px) { - .tile.tile-super .tile-inner { - font-size: 10px; } } - -@-webkit-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-new .tile-inner { - -webkit-animation: appear 200ms ease 100ms; - -moz-animation: appear 200ms ease 100ms; - animation: appear 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -@-webkit-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-merged .tile-inner { - z-index: 20; - -webkit-animation: pop 200ms ease 100ms; - -moz-animation: pop 200ms ease 100ms; - animation: pop 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -.game-intro { - margin-bottom: 0; } - -.game-explanation { - margin-top: 50px; } - -@media screen and (max-width: 520px) { - html, body { - font-size: 15px; } - - body { - margin: 20px 0; - padding: 0 20px; } - - h1.title { - font-size: 27px; - margin-top: 15px; } - - .container { - width: 280px; - margin: 0 auto; } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; } - - .heading { - margin-bottom: 10px; } - - .game-container { - margin-top: 40px; - position: relative; - padding: 10px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 280px; - height: 280px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(199, 109, 92, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - - .grid-container { - position: absolute; - z-index: 1; } - - .grid-row { - margin-bottom: 10px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - - .grid-cell { - width: 57.5px; - height: 57.5px; - margin-right: 10px; - float: left; - border-radius: 3px; - background: rgba(199, 109, 92, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - - .tile-container { - position: absolute; - z-index: 2; } - - .tile, .tile .tile-inner { - width: 58px; - height: 58px; - line-height: 67.5px; } - .tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } - .tile.tile-position-1-2 { - -webkit-transform: translate(0px, 67px); - -moz-transform: translate(0px, 67px); - transform: translate(0px, 67px); } - .tile.tile-position-1-3 { - -webkit-transform: translate(0px, 135px); - -moz-transform: translate(0px, 135px); - transform: translate(0px, 135px); } - .tile.tile-position-1-4 { - -webkit-transform: translate(0px, 202px); - -moz-transform: translate(0px, 202px); - transform: translate(0px, 202px); } - .tile.tile-position-2-1 { - -webkit-transform: translate(67px, 0px); - -moz-transform: translate(67px, 0px); - transform: translate(67px, 0px); } - .tile.tile-position-2-2 { - -webkit-transform: translate(67px, 67px); - -moz-transform: translate(67px, 67px); - transform: translate(67px, 67px); } - .tile.tile-position-2-3 { - -webkit-transform: translate(67px, 135px); - -moz-transform: translate(67px, 135px); - transform: translate(67px, 135px); } - .tile.tile-position-2-4 { - -webkit-transform: translate(67px, 202px); - -moz-transform: translate(67px, 202px); - transform: translate(67px, 202px); } - .tile.tile-position-3-1 { - -webkit-transform: translate(135px, 0px); - -moz-transform: translate(135px, 0px); - transform: translate(135px, 0px); } - .tile.tile-position-3-2 { - -webkit-transform: translate(135px, 67px); - -moz-transform: translate(135px, 67px); - transform: translate(135px, 67px); } - .tile.tile-position-3-3 { - -webkit-transform: translate(135px, 135px); - -moz-transform: translate(135px, 135px); - transform: translate(135px, 135px); } - .tile.tile-position-3-4 { - -webkit-transform: translate(135px, 202px); - -moz-transform: translate(135px, 202px); - transform: translate(135px, 202px); } - .tile.tile-position-4-1 { - -webkit-transform: translate(202px, 0px); - -moz-transform: translate(202px, 0px); - transform: translate(202px, 0px); } - .tile.tile-position-4-2 { - -webkit-transform: translate(202px, 67px); - -moz-transform: translate(202px, 67px); - transform: translate(202px, 67px); } - .tile.tile-position-4-3 { - -webkit-transform: translate(202px, 135px); - -moz-transform: translate(202px, 135px); - transform: translate(202px, 135px); } - .tile.tile-position-4-4 { - -webkit-transform: translate(202px, 202px); - -moz-transform: translate(202px, 202px); - transform: translate(202px, 202px); } - - .game-container { - margin-top: 20px; } - - .tile .tile-inner { - font-size: 35px; } - - .game-message p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; } - .game-message .lower { - margin-top: 30px !important; } } diff --git a/sources/2048frama/style/main.scss b/sources/2048frama/style/main.scss deleted file mode 100644 index 3499559..0000000 --- a/sources/2048frama/style/main.scss +++ /dev/null @@ -1,511 +0,0 @@ -@import "helpers"; -@import "fonts/clear-sans.css"; - -$field-width: 500px; -$grid-spacing: 15px; -$grid-row-cells: 4; -$tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; -$tile-border-radius: 3px; - -$mobile-threshold: $field-width + 20px; - -$text-color: #776E65; -$bright-text-color: #f9f6f2; - -$tile-color: #eee4da; -$tile-gold-color: #edc22e; -$tile-gold-glow-color: lighten($tile-gold-color, 15%); - -$game-container-background: #bbada0; - -$transition-speed: 100ms; - -html, body { - margin: 0; - padding: 0; - - background: #faf8ef; - color: $text-color; - font-family: "Helvetica Neue", Arial, sans-serif; - font-size: 18px; -} - -body { - margin: 80px 0; -} - -.heading:after { - content: ""; - display: block; - clear: both; -} - -h1.title { - font-size: 80px; - font-weight: bold; - margin: 0; - display: block; - float: left; -} - -@include keyframes(move-up) { - 0% { - top: 25px; - opacity: 1; - } - - 100% { - top: -50px; - opacity: 0; - } -} - -.scores-container { - float: right; - text-align: right; -} - -.score-container, .best-container { - $height: 25px; - - position: relative; - display: inline-block; - background: $game-container-background; - padding: 15px 25px; - font-size: $height; - height: $height; - line-height: $height + 22px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; - - &:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: $tile-color; - } - - .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: $height; - line-height: $height; - font-weight: bold; - color: rgba($text-color, .9); - z-index: 100; - @include animation(move-up 600ms ease-in); - @include animation-fill-mode(both); - } -} - -.score-container:after { - content: "Score"; -} - -.best-container:after { - content: "Best" -} - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; -} - -a { - color: $text-color; - font-weight: bold; - text-decoration: underline; - cursor: pointer; -} - -strong { - &.important { - text-transform: uppercase; - } -} - -hr { - border: none; - border-bottom: 1px solid lighten($text-color, 40%); - margin-top: 20px; - margin-bottom: 30px; -} - -.container { - width: $field-width; - margin: 0 auto; -} - -@include keyframes(fade-in) { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -// Styles for buttons -@mixin button { - display: inline-block; - background: darken($game-container-background, 20%); - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: $bright-text-color; - height: 40px; - line-height: 42px; -} - -// Game field mixin used to render CSS at different width -@mixin game-field { - .game-container { - margin-top: 40px; - position: relative; - padding: $grid-spacing; - - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - - background: $game-container-background; - border-radius: $tile-border-radius * 2; - width: $field-width; - height: $field-width; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - .game-message { - display: none; - - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba($tile-color, .5); - z-index: 100; - - text-align: center; - - p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; - // height: $field-width; - // line-height: $field-width; - } - - .lower { - display: block; - margin-top: 59px; - } - - a { - @include button; - margin-left: 9px; - // margin-top: 59px; - - &.keep-playing-button { - display: none; - } - } - - @include animation(fade-in 800ms ease $transition-speed * 12); - @include animation-fill-mode(both); - - &.game-won { - background: rgba($tile-gold-color, .5); - color: $bright-text-color; - - a.keep-playing-button { - display: inline-block; - } - } - - &.game-won, &.game-over { - display: block; - } - } - } - - .grid-container { - position: absolute; - z-index: 1; - } - - .grid-row { - margin-bottom: $grid-spacing; - - &:last-child { - margin-bottom: 0; - } - - &:after { - content: ""; - display: block; - clear: both; - } - } - - .grid-cell { - width: $tile-size; - height: $tile-size; - margin-right: $grid-spacing; - float: left; - - border-radius: $tile-border-radius; - - background: rgba($tile-color, .35); - - &:last-child { - margin-right: 0; - } - } - - .tile-container { - position: absolute; - z-index: 2; - } - - .tile { - &, .tile-inner { - width: ceil($tile-size); - height: ceil($tile-size); - line-height: $tile-size + 10px; - } - - // Build position classes - @for $x from 1 through $grid-row-cells { - @for $y from 1 through $grid-row-cells { - &.tile-position-#{$x}-#{$y} { - $xPos: floor(($tile-size + $grid-spacing) * ($x - 1)); - $yPos: floor(($tile-size + $grid-spacing) * ($y - 1)); - @include transform(translate($xPos, $yPos)); - } - } - } - } -} - -// End of game-field mixin -@include game-field; - -.tile { - position: absolute; // Makes transforms relative to the top-left corner - - .tile-inner { - border-radius: $tile-border-radius; - - background: $tile-color; - text-align: center; - font-weight: bold; - z-index: 10; - - font-size: 55px; - } - - // Movement transition - @include transition($transition-speed ease-in-out); - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; - - $base: 2; - $exponent: 1; - $limit: 11; - - // Colors for all 11 states, false = no special color - $special-colors: #eee4da false, // 2 - #ede0c8 false, // 4 - #bb9bbf false, // 8 - #f8a389 false, // 16 - #d8b74d false, // 32 - #f0a751 false, // 64 - #7e8c87 true, // 128 - #fbeb76 true, // 256 - #4da66d true, // 512 - #89a9d7 true, // 1024 - #c76d5c true; // 2048 - - $tile-pokemon: url('../im/weedle.png'), // 2 - url('../im/pidgey.png'), // 4 - url('../im/zubat.png'), // 8 - url('../im/magikarp.png'), // 16 - url('../im/psyduck.png'), // 32 - url('../im/ninetales.png'), // 64 - url('../im/snorlax.png'), // 128 - url('../im/pikachu.png'), // 256 - url('../im/venasaur.png'), // 512 - url('../im/blastoise.png'), // 1024 - url('../im/charizard.png'); // 2048 - - // Build tile colors - @while $exponent <= $limit { - $power: pow($base, $exponent); - - &.tile-#{$power} .tile-inner { - // Calculate base background color - - $nth-color: nth($special-colors, $exponent); - - $tile-color: nth($nth-color, 1); - $use-shadow: nth($nth-color, 2); - - - // Set background - background: $tile-color; - background-image: nth($tile-pokemon, $exponent); - background-size: 80% 80%; - background-repeat: no-repeat; - background-position: center; - font-size: 0px; - - // Add glow - $glow-opacity: max($exponent - 4, 0) / ($limit - 4); - - @if not $use-shadow { - box-shadow: 0 0 30px 10px rgba($tile-gold-glow-color, $glow-opacity / 1.8), - inset 0 0 0 1px rgba(white, $glow-opacity / 3); - } - } - - $exponent: $exponent + 1; - } - - // Super tiles (above 2048) - &.tile-super .tile-inner { - color: $bright-text-color; - background: mix(#333, $tile-gold-color, 95%); - - font-size: 30px; - - @include smaller($mobile-threshold) { - font-size: 10px; - } - } -} - -@include keyframes(appear) { - 0% { - opacity: 0; - @include transform(scale(0)); - } - - 100% { - opacity: 1; - @include transform(scale(1)); - } -} - -.tile-new .tile-inner { - @include animation(appear 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -@include keyframes(pop) { - 0% { - @include transform(scale(0)); - } - - 50% { - @include transform(scale(1.2)); - } - - 100% { - @include transform(scale(1)); - } -} - -.tile-merged .tile-inner { - z-index: 20; - @include animation(pop 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -.game-intro { - margin-bottom: 0; -} - -.game-explanation { - margin-top: 50px; -} - -@include smaller($mobile-threshold) { - // Redefine variables for smaller screens - $field-width: 280px; - $grid-spacing: 10px; - $grid-row-cells: 4; - $tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; - $tile-border-radius: 3px; - - html, body { - font-size: 15px; - } - - body { - margin: 20px 0; - padding: 0 20px; - } - - h1.title { - font-size: 27px; - margin-top: 15px; - } - - .container { - width: $field-width; - margin: 0 auto; - } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; - } - - .heading { - margin-bottom: 10px; - } - - // Render the game field at the right width - @include game-field; - - .game-container { - margin-top: 20px; - } - - // Rest of the font-size adjustments in the tile class - .tile .tile-inner { - font-size: 35px; - } - - .game-message { - p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; - } - - .lower { - margin-top: 30px !important; - } - } -} diff --git a/sources/2048originel/.gitignore b/sources/2048originel/.gitignore deleted file mode 100644 index 0d31019..0000000 --- a/sources/2048originel/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.sass-cache/ diff --git a/sources/2048originel/.jshintrc b/sources/2048originel/.jshintrc deleted file mode 100644 index 87dbf9a..0000000 --- a/sources/2048originel/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "esnext": true, - "indent": 2, - "maxlen": 80, - "freeze": true, - "camelcase": true, - "unused": true, - "eqnull": true, - "proto": true, - "supernew": true, - "noyield": true, - "evil": true, - "node": true, - "boss": true, - "expr": true, - "loopfunc": true, - "white": true, - "maxdepth": 4 -} diff --git a/sources/2048originel/CONTRIBUTING.md b/sources/2048originel/CONTRIBUTING.md deleted file mode 100644 index 968baa9..0000000 --- a/sources/2048originel/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -## Contributing -Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specifically made branch and request to pull on `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process. diff --git a/sources/2048originel/LICENSE.txt b/sources/2048originel/LICENSE.txt deleted file mode 100644 index b0dbfa4..0000000 --- a/sources/2048originel/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Gabriele Cirulli - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/sources/2048originel/README.md b/sources/2048originel/README.md deleted file mode 100644 index 19c6d0e..0000000 --- a/sources/2048originel/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# 2048 -A small clone of [1024](https://play.google.com/store/apps/details?id=com.veewo.a1024), based on [Saming's 2048](http://saming.fr/p/2048/) (also a clone). - -Made just for fun. [Play it here!](http://gabrielecirulli.github.io/2048/) - -### Contributions - - - [TimPetricola](https://github.com/TimPetricola) added best score storage - - [chrisprice](https://github.com/chrisprice) added custom code for swipe handling on mobile - - [elektryk](https://github.com/elektryk) made swipes work on Windows Phone - -Many thanks to [rayhaanj](https://github.com/rayhaanj), [Mechazawa](https://github.com/Mechazawa), [grant](https://github.com/grant), [remram44](https://github.com/remram44) and [ghoullier](https://github.com/ghoullier) for the many other good contributions. - -### Screenshot - -

- Screenshot -

- -That screenshot is fake, by the way. I never reached 2048 :smile: - -## Contributing -Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process. - -You can find the same information in the [contributing guide.](https://github.com/gabrielecirulli/2048/blob/master/CONTRIBUTING.md) - -## License -2048 is licensed under the [MIT license.](https://github.com/gabrielecirulli/2048/blob/master/LICENSE.txt) - -## Donations -I made this in my spare time, and it's hosted on GitHub (which means I don't have any hosting costs), but if you enjoyed the game and feel like buying me coffee, you can donate at my BTC address: `1Ec6onfsQmoP9kkL3zkpB6c5sA4PVcXU2i`. Thank you very much! diff --git a/sources/2048originel/Rakefile b/sources/2048originel/Rakefile deleted file mode 100644 index 3e9851e..0000000 --- a/sources/2048originel/Rakefile +++ /dev/null @@ -1,11 +0,0 @@ -require "date" - -namespace :appcache do - desc "update the date in the appcache file (in the gh-pages branch)" - task :update do - appcache = File.read("cache.appcache") - updated = "# Updated: #{DateTime.now}" - - File.write("cache.appcache", appcache.sub(/^# Updated:.*$/, updated)) - end -end diff --git a/sources/2048originel/favicon.ico b/sources/2048originel/favicon.ico deleted file mode 100644 index 22109e0..0000000 Binary files a/sources/2048originel/favicon.ico and /dev/null differ diff --git a/sources/2048originel/index.html b/sources/2048originel/index.html deleted file mode 100644 index 5c80b9c..0000000 --- a/sources/2048originel/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - 2048 - - - - - - - - - - - -
-
-

2048

-
-
0
-
0
-
-
-

Reliez les nombres et obtenez la tuile 2048 !

- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
- -

- Comment jouer : Utilisez les flèches du clavier pour déplacer les tuiles. Quand deux tuiles avec le même nombre se touchent, elles fusionnent ! -

-
-

- Note : Framasoft héberge une instance du jeu créé par Gabriele Cirulli. sous licence libre MIT. -

-
- - - - - - - - - - - - diff --git a/sources/2048originel/js/animframe_polyfill.js b/sources/2048originel/js/animframe_polyfill.js deleted file mode 100644 index c45a13e..0000000 --- a/sources/2048originel/js/animframe_polyfill.js +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var lastTime = 0; - var vendors = ['webkit', 'moz']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - } - - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - } -}()); diff --git a/sources/2048originel/js/application.js b/sources/2048originel/js/application.js deleted file mode 100644 index a4d310a..0000000 --- a/sources/2048originel/js/application.js +++ /dev/null @@ -1,4 +0,0 @@ -// Wait till the browser is ready to render the game (avoids glitches) -window.requestAnimationFrame(function () { - new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager); -}); diff --git a/sources/2048originel/js/game_manager.js b/sources/2048originel/js/game_manager.js deleted file mode 100644 index b36aea3..0000000 --- a/sources/2048originel/js/game_manager.js +++ /dev/null @@ -1,245 +0,0 @@ -function GameManager(size, InputManager, Actuator, ScoreManager) { - this.size = size; // Size of the grid - this.inputManager = new InputManager; - this.scoreManager = new ScoreManager; - this.actuator = new Actuator; - - this.startTiles = 2; - - this.inputManager.on("move", this.move.bind(this)); - this.inputManager.on("restart", this.restart.bind(this)); - this.inputManager.on("keepPlaying", this.keepPlaying.bind(this)); - - this.setup(); -} - -// Restart the game -GameManager.prototype.restart = function () { - this.actuator.continue(); - this.setup(); -}; - -// Keep playing after winning -GameManager.prototype.keepPlaying = function () { - this.keepPlaying = true; - this.actuator.continue(); -}; - -GameManager.prototype.isGameTerminated = function () { - if (this.over || (this.won && !this.keepPlaying)) { - return true; - } else { - return false; - } -}; - -// Set up the game -GameManager.prototype.setup = function () { - this.grid = new Grid(this.size); - - this.score = 0; - this.over = false; - this.won = false; - this.keepPlaying = false; - - // Add the initial tiles - this.addStartTiles(); - - // Update the actuator - this.actuate(); -}; - -// Set up the initial tiles to start the game with -GameManager.prototype.addStartTiles = function () { - for (var i = 0; i < this.startTiles; i++) { - this.addRandomTile(); - } -}; - -// Adds a tile in a random position -GameManager.prototype.addRandomTile = function () { - if (this.grid.cellsAvailable()) { - var value = Math.random() < 0.9 ? 2 : 4; - var tile = new Tile(this.grid.randomAvailableCell(), value); - - this.grid.insertTile(tile); - } -}; - -// Sends the updated grid to the actuator -GameManager.prototype.actuate = function () { - if (this.scoreManager.get() < this.score) { - this.scoreManager.set(this.score); - } - - this.actuator.actuate(this.grid, { - score: this.score, - over: this.over, - won: this.won, - bestScore: this.scoreManager.get(), - terminated: this.isGameTerminated() - }); - -}; - -// Save all tile positions and remove merger info -GameManager.prototype.prepareTiles = function () { - this.grid.eachCell(function (x, y, tile) { - if (tile) { - tile.mergedFrom = null; - tile.savePosition(); - } - }); -}; - -// Move a tile and its representation -GameManager.prototype.moveTile = function (tile, cell) { - this.grid.cells[tile.x][tile.y] = null; - this.grid.cells[cell.x][cell.y] = tile; - tile.updatePosition(cell); -}; - -// Move tiles on the grid in the specified direction -GameManager.prototype.move = function (direction) { - // 0: up, 1: right, 2:down, 3: left - var self = this; - - if (this.isGameTerminated()) return; // Don't do anything if the game's over - - var cell, tile; - - var vector = this.getVector(direction); - var traversals = this.buildTraversals(vector); - var moved = false; - - // Save the current tile positions and remove merger information - this.prepareTiles(); - - // Traverse the grid in the right direction and move tiles - traversals.x.forEach(function (x) { - traversals.y.forEach(function (y) { - cell = { x: x, y: y }; - tile = self.grid.cellContent(cell); - - if (tile) { - var positions = self.findFarthestPosition(cell, vector); - var next = self.grid.cellContent(positions.next); - - // Only one merger per row traversal? - if (next && next.value === tile.value && !next.mergedFrom) { - var merged = new Tile(positions.next, tile.value * 2); - merged.mergedFrom = [tile, next]; - - self.grid.insertTile(merged); - self.grid.removeTile(tile); - - // Converge the two tiles' positions - tile.updatePosition(positions.next); - - // Update the score - self.score += merged.value; - - // The mighty 2048 tile - if (merged.value === 2048) self.won = true; - } else { - self.moveTile(tile, positions.farthest); - } - - if (!self.positionsEqual(cell, tile)) { - moved = true; // The tile moved from its original cell! - } - } - }); - }); - - if (moved) { - this.addRandomTile(); - - if (!this.movesAvailable()) { - this.over = true; // Game over! - } - - this.actuate(); - } -}; - -// Get the vector representing the chosen direction -GameManager.prototype.getVector = function (direction) { - // Vectors representing tile movement - var map = { - 0: { x: 0, y: -1 }, // up - 1: { x: 1, y: 0 }, // right - 2: { x: 0, y: 1 }, // down - 3: { x: -1, y: 0 } // left - }; - - return map[direction]; -}; - -// Build a list of positions to traverse in the right order -GameManager.prototype.buildTraversals = function (vector) { - var traversals = { x: [], y: [] }; - - for (var pos = 0; pos < this.size; pos++) { - traversals.x.push(pos); - traversals.y.push(pos); - } - - // Always traverse from the farthest cell in the chosen direction - if (vector.x === 1) traversals.x = traversals.x.reverse(); - if (vector.y === 1) traversals.y = traversals.y.reverse(); - - return traversals; -}; - -GameManager.prototype.findFarthestPosition = function (cell, vector) { - var previous; - - // Progress towards the vector direction until an obstacle is found - do { - previous = cell; - cell = { x: previous.x + vector.x, y: previous.y + vector.y }; - } while (this.grid.withinBounds(cell) && - this.grid.cellAvailable(cell)); - - return { - farthest: previous, - next: cell // Used to check if a merge is required - }; -}; - -GameManager.prototype.movesAvailable = function () { - return this.grid.cellsAvailable() || this.tileMatchesAvailable(); -}; - -// Check for available matches between tiles (more expensive check) -GameManager.prototype.tileMatchesAvailable = function () { - var self = this; - - var tile; - - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - tile = this.grid.cellContent({ x: x, y: y }); - - if (tile) { - for (var direction = 0; direction < 4; direction++) { - var vector = self.getVector(direction); - var cell = { x: x + vector.x, y: y + vector.y }; - - var other = self.grid.cellContent(cell); - - if (other && other.value === tile.value) { - return true; // These two tiles can be merged - } - } - } - } - } - - return false; -}; - -GameManager.prototype.positionsEqual = function (first, second) { - return first.x === second.x && first.y === second.y; -}; diff --git a/sources/2048originel/js/grid.js b/sources/2048originel/js/grid.js deleted file mode 100644 index 05fe057..0000000 --- a/sources/2048originel/js/grid.js +++ /dev/null @@ -1,84 +0,0 @@ -function Grid(size) { - this.size = size; - - this.cells = []; - - this.build(); -} - -// Build a grid of the specified size -Grid.prototype.build = function () { - for (var x = 0; x < this.size; x++) { - var row = this.cells[x] = []; - - for (var y = 0; y < this.size; y++) { - row.push(null); - } - } -}; - -// Find the first available random position -Grid.prototype.randomAvailableCell = function () { - var cells = this.availableCells(); - - if (cells.length) { - return cells[Math.floor(Math.random() * cells.length)]; - } -}; - -Grid.prototype.availableCells = function () { - var cells = []; - - this.eachCell(function (x, y, tile) { - if (!tile) { - cells.push({ x: x, y: y }); - } - }); - - return cells; -}; - -// Call callback for every cell -Grid.prototype.eachCell = function (callback) { - for (var x = 0; x < this.size; x++) { - for (var y = 0; y < this.size; y++) { - callback(x, y, this.cells[x][y]); - } - } -}; - -// Check if there are any cells available -Grid.prototype.cellsAvailable = function () { - return !!this.availableCells().length; -}; - -// Check if the specified cell is taken -Grid.prototype.cellAvailable = function (cell) { - return !this.cellOccupied(cell); -}; - -Grid.prototype.cellOccupied = function (cell) { - return !!this.cellContent(cell); -}; - -Grid.prototype.cellContent = function (cell) { - if (this.withinBounds(cell)) { - return this.cells[cell.x][cell.y]; - } else { - return null; - } -}; - -// Inserts a tile at its position -Grid.prototype.insertTile = function (tile) { - this.cells[tile.x][tile.y] = tile; -}; - -Grid.prototype.removeTile = function (tile) { - this.cells[tile.x][tile.y] = null; -}; - -Grid.prototype.withinBounds = function (position) { - return position.x >= 0 && position.x < this.size && - position.y >= 0 && position.y < this.size; -}; diff --git a/sources/2048originel/js/html_actuator.js b/sources/2048originel/js/html_actuator.js deleted file mode 100644 index d840068..0000000 --- a/sources/2048originel/js/html_actuator.js +++ /dev/null @@ -1,139 +0,0 @@ -function HTMLActuator() { - this.tileContainer = document.querySelector(".tile-container"); - this.scoreContainer = document.querySelector(".score-container"); - this.bestContainer = document.querySelector(".best-container"); - this.messageContainer = document.querySelector(".game-message"); - - this.score = 0; -} - -HTMLActuator.prototype.actuate = function (grid, metadata) { - var self = this; - - window.requestAnimationFrame(function () { - self.clearContainer(self.tileContainer); - - grid.cells.forEach(function (column) { - column.forEach(function (cell) { - if (cell) { - self.addTile(cell); - } - }); - }); - - self.updateScore(metadata.score); - self.updateBestScore(metadata.bestScore); - - if (metadata.terminated) { - if (metadata.over) { - self.message(false); // You lose - } else if (metadata.won) { - self.message(true); // You win! - } - } - - }); -}; - -// Continues the game (both restart and keep playing) -HTMLActuator.prototype.continue = function () { - this.clearMessage(); -}; - -HTMLActuator.prototype.clearContainer = function (container) { - while (container.firstChild) { - container.removeChild(container.firstChild); - } -}; - -HTMLActuator.prototype.addTile = function (tile) { - var self = this; - - var wrapper = document.createElement("div"); - var inner = document.createElement("div"); - var position = tile.previousPosition || { x: tile.x, y: tile.y }; - var positionClass = this.positionClass(position); - - // We can't use classlist because it somehow glitches when replacing classes - var classes = ["tile", "tile-" + tile.value, positionClass]; - - if (tile.value > 2048) classes.push("tile-super"); - - this.applyClasses(wrapper, classes); - - inner.classList.add("tile-inner"); - inner.textContent = tile.value; - - if (tile.previousPosition) { - // Make sure that the tile gets rendered in the previous position first - window.requestAnimationFrame(function () { - classes[2] = self.positionClass({ x: tile.x, y: tile.y }); - self.applyClasses(wrapper, classes); // Update the position - }); - } else if (tile.mergedFrom) { - classes.push("tile-merged"); - this.applyClasses(wrapper, classes); - - // Render the tiles that merged - tile.mergedFrom.forEach(function (merged) { - self.addTile(merged); - }); - } else { - classes.push("tile-new"); - this.applyClasses(wrapper, classes); - } - - // Add the inner part of the tile to the wrapper - wrapper.appendChild(inner); - - // Put the tile on the board - this.tileContainer.appendChild(wrapper); -}; - -HTMLActuator.prototype.applyClasses = function (element, classes) { - element.setAttribute("class", classes.join(" ")); -}; - -HTMLActuator.prototype.normalizePosition = function (position) { - return { x: position.x + 1, y: position.y + 1 }; -}; - -HTMLActuator.prototype.positionClass = function (position) { - position = this.normalizePosition(position); - return "tile-position-" + position.x + "-" + position.y; -}; - -HTMLActuator.prototype.updateScore = function (score) { - this.clearContainer(this.scoreContainer); - - var difference = score - this.score; - this.score = score; - - this.scoreContainer.textContent = this.score; - - if (difference > 0) { - var addition = document.createElement("div"); - addition.classList.add("score-addition"); - addition.textContent = "+" + difference; - - this.scoreContainer.appendChild(addition); - } -}; - -HTMLActuator.prototype.updateBestScore = function (bestScore) { - this.bestContainer.textContent = bestScore; -}; - -HTMLActuator.prototype.message = function (won) { - var type = won ? "game-won" : "game-over"; - var message = won ? "You win!" : "Game over!"; - - this.messageContainer.classList.add(type); - this.messageContainer.getElementsByTagName("p")[0].textContent = message; -}; - -HTMLActuator.prototype.clearMessage = function () { - // IE only takes one value to remove at a time. - this.messageContainer.classList.remove("game-won"); - this.messageContainer.classList.remove("game-over"); -}; diff --git a/sources/2048originel/js/keyboard_input_manager.js b/sources/2048originel/js/keyboard_input_manager.js deleted file mode 100644 index a29744c..0000000 --- a/sources/2048originel/js/keyboard_input_manager.js +++ /dev/null @@ -1,130 +0,0 @@ -function KeyboardInputManager() { - this.events = {}; - - if (window.navigator.msPointerEnabled) { - //Internet Explorer 10 style - this.eventTouchstart = "MSPointerDown"; - this.eventTouchmove = "MSPointerMove"; - this.eventTouchend = "MSPointerUp"; - } else { - this.eventTouchstart = "touchstart"; - this.eventTouchmove = "touchmove"; - this.eventTouchend = "touchend"; - } - - this.listen(); -} - -KeyboardInputManager.prototype.on = function (event, callback) { - if (!this.events[event]) { - this.events[event] = []; - } - this.events[event].push(callback); -}; - -KeyboardInputManager.prototype.emit = function (event, data) { - var callbacks = this.events[event]; - if (callbacks) { - callbacks.forEach(function (callback) { - callback(data); - }); - } -}; - -KeyboardInputManager.prototype.listen = function () { - var self = this; - - var map = { - 38: 0, // Up - 39: 1, // Right - 40: 2, // Down - 37: 3, // Left - 75: 0, // vim keybindings - 76: 1, - 74: 2, - 72: 3, - 87: 0, // W - 68: 1, // D - 83: 2, // S - 65: 3 // A - }; - - document.addEventListener("keydown", function (event) { - var modifiers = event.altKey || event.ctrlKey || event.metaKey || - event.shiftKey; - var mapped = map[event.which]; - - if (!modifiers) { - if (mapped !== undefined) { - event.preventDefault(); - self.emit("move", mapped); - } - - if (event.which === 32) self.restart.bind(self)(event); - } - }); - - var retry = document.querySelector(".retry-button"); - retry.addEventListener("click", this.restart.bind(this)); - retry.addEventListener(this.eventTouchend, this.restart.bind(this)); - - var keepPlaying = document.querySelector(".keep-playing-button"); - keepPlaying.addEventListener("click", this.keepPlaying.bind(this)); - keepPlaying.addEventListener("touchend", this.keepPlaying.bind(this)); - - // Listen to swipe events - var touchStartClientX, touchStartClientY; - var gameContainer = document.getElementsByClassName("game-container")[0]; - - gameContainer.addEventListener(this.eventTouchstart, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 1) || event.targetTouches > 1) return; - - if(window.navigator.msPointerEnabled){ - touchStartClientX = event.pageX; - touchStartClientY = event.pageY; - } else { - touchStartClientX = event.touches[0].clientX; - touchStartClientY = event.touches[0].clientY; - } - - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchmove, function (event) { - event.preventDefault(); - }); - - gameContainer.addEventListener(this.eventTouchend, function (event) { - if (( !window.navigator.msPointerEnabled && event.touches.length > 0) || event.targetTouches > 0) return; - - var touchEndClientX, touchEndClientY; - if(window.navigator.msPointerEnabled){ - touchEndClientX = event.pageX; - touchEndClientY = event.pageY; - } else { - touchEndClientX = event.changedTouches[0].clientX; - touchEndClientY = event.changedTouches[0].clientY; - } - - var dx = touchEndClientX - touchStartClientX; - var absDx = Math.abs(dx); - - var dy = touchEndClientY - touchStartClientY; - var absDy = Math.abs(dy); - - if (Math.max(absDx, absDy) > 10) { - // (right : left) : (down : up) - self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0)); - } - }); -}; - -KeyboardInputManager.prototype.restart = function (event) { - event.preventDefault(); - this.emit("restart"); -}; - -KeyboardInputManager.prototype.keepPlaying = function (event) { - event.preventDefault(); - this.emit("keepPlaying"); -}; diff --git a/sources/2048originel/js/local_score_manager.js b/sources/2048originel/js/local_score_manager.js deleted file mode 100644 index ec4575d..0000000 --- a/sources/2048originel/js/local_score_manager.js +++ /dev/null @@ -1,48 +0,0 @@ -window.fakeStorage = { - _data: {}, - - setItem: function (id, val) { - return this._data[id] = String(val); - }, - - getItem: function (id) { - return this._data.hasOwnProperty(id) ? this._data[id] : undefined; - }, - - removeItem: function (id) { - return delete this._data[id]; - }, - - clear: function () { - return this._data = {}; - } -}; - -function LocalScoreManager() { - this.key = "bestScore"; - - var supported = this.localStorageSupported(); - this.storage = supported ? window.localStorage : window.fakeStorage; -} - -LocalScoreManager.prototype.localStorageSupported = function () { - var testKey = "test"; - var storage = window.localStorage; - - try { - storage.setItem(testKey, "1"); - storage.removeItem(testKey); - return true; - } catch (error) { - return false; - } -}; - -LocalScoreManager.prototype.get = function () { - return this.storage.getItem(this.key) || 0; -}; - -LocalScoreManager.prototype.set = function (score) { - this.storage.setItem(this.key, score); -}; - diff --git a/sources/2048originel/js/tile.js b/sources/2048originel/js/tile.js deleted file mode 100644 index de08333..0000000 --- a/sources/2048originel/js/tile.js +++ /dev/null @@ -1,17 +0,0 @@ -function Tile(position, value) { - this.x = position.x; - this.y = position.y; - this.value = value || 2; - - this.previousPosition = null; - this.mergedFrom = null; // Tracks tiles that merged together -} - -Tile.prototype.savePosition = function () { - this.previousPosition = { x: this.x, y: this.y }; -}; - -Tile.prototype.updatePosition = function (position) { - this.x = position.x; - this.y = position.y; -}; diff --git a/sources/2048originel/meta/apple-touch-icon.png b/sources/2048originel/meta/apple-touch-icon.png deleted file mode 100644 index 3fd20f6..0000000 Binary files a/sources/2048originel/meta/apple-touch-icon.png and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.eot b/sources/2048originel/style/fonts/ClearSans-Bold-webfont.eot deleted file mode 100644 index 3678ef2..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.eot and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.svg b/sources/2048originel/style/fonts/ClearSans-Bold-webfont.svg deleted file mode 100644 index aa985ae..0000000 --- a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.svg +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.woff b/sources/2048originel/style/fonts/ClearSans-Bold-webfont.woff deleted file mode 100644 index 184a945..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Bold-webfont.woff and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Light-webfont.eot b/sources/2048originel/style/fonts/ClearSans-Light-webfont.eot deleted file mode 100644 index 0dc609d..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Light-webfont.eot and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Light-webfont.svg b/sources/2048originel/style/fonts/ClearSans-Light-webfont.svg deleted file mode 100644 index 1d5d2ec..0000000 --- a/sources/2048originel/style/fonts/ClearSans-Light-webfont.svg +++ /dev/null @@ -1,670 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048originel/style/fonts/ClearSans-Light-webfont.woff b/sources/2048originel/style/fonts/ClearSans-Light-webfont.woff deleted file mode 100644 index 44555e0..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Light-webfont.woff and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.eot b/sources/2048originel/style/fonts/ClearSans-Regular-webfont.eot deleted file mode 100644 index b020e05..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.eot and /dev/null differ diff --git a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.svg b/sources/2048originel/style/fonts/ClearSans-Regular-webfont.svg deleted file mode 100644 index 1e2cffd..0000000 --- a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.svg +++ /dev/null @@ -1,669 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.woff b/sources/2048originel/style/fonts/ClearSans-Regular-webfont.woff deleted file mode 100644 index 9d58858..0000000 Binary files a/sources/2048originel/style/fonts/ClearSans-Regular-webfont.woff and /dev/null differ diff --git a/sources/2048originel/style/fonts/clear-sans.css b/sources/2048originel/style/fonts/clear-sans.css deleted file mode 100644 index de2811d..0000000 --- a/sources/2048originel/style/fonts/clear-sans.css +++ /dev/null @@ -1,30 +0,0 @@ -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Light-webfont.eot"); - src: url("ClearSans-Light-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Light-webfont.svg#clear_sans_lightregular") format("svg"), - url("ClearSans-Light-webfont.woff") format("woff"); - font-weight: 200; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Regular-webfont.eot"); - src: url("ClearSans-Regular-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Regular-webfont.svg#clear_sansregular") format("svg"), - url("ClearSans-Regular-webfont.woff") format("woff"); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: "Clear Sans"; - src: url("ClearSans-Bold-webfont.eot"); - src: url("ClearSans-Bold-webfont.eot?#iefix") format("embedded-opentype"), - url("ClearSans-Bold-webfont.svg#clear_sansbold") format("svg"), - url("ClearSans-Bold-webfont.woff") format("woff"); - font-weight: 700; - font-style: normal; -} - diff --git a/sources/2048originel/style/helpers.scss b/sources/2048originel/style/helpers.scss deleted file mode 100644 index 53b9dc1..0000000 --- a/sources/2048originel/style/helpers.scss +++ /dev/null @@ -1,72 +0,0 @@ -// Exponent -// From: https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L36 - -@function exponent($base, $exponent) { - // reset value - $value: $base; - // positive intergers get multiplied - @if $exponent > 1 { - @for $i from 2 through $exponent { - $value: $value * $base; } } - // negitive intergers get divided. A number divided by itself is 1 - @if $exponent < 1 { - @for $i from 0 through -$exponent { - $value: $value / $base; } } - // return the last value written - @return $value; -} - -@function pow($base, $exponent) { - @return exponent($base, $exponent); -} - -// Transition mixins -@mixin transition($args...) { - -webkit-transition: $args; - -moz-transition: $args; - transition: $args; -} - -@mixin transition-property($args...) { - -webkit-transition-property: $args; - -moz-transition-property: $args; - transition-property: $args; -} - -@mixin animation($args...) { - -webkit-animation: $args; - -moz-animation: $args; - animation: $args; -} - -@mixin animation-fill-mode($args...) { - -webkit-animation-fill-mode: $args; - -moz-animation-fill-mode: $args; - animation-fill-mode: $args; -} - -@mixin transform($args...) { - -webkit-transform: $args; - -moz-transform: $args; - transform: $args; -} - -// Keyframe animations -@mixin keyframes($animation-name) { - @-webkit-keyframes $animation-name { - @content; - } - @-moz-keyframes $animation-name { - @content; - } - @keyframes $animation-name { - @content; - } -} - -// Media queries -@mixin smaller($width) { - @media screen and (max-width: $width) { - @content; - } -} diff --git a/sources/2048originel/style/main.css b/sources/2048originel/style/main.css deleted file mode 100644 index 515e881..0000000 --- a/sources/2048originel/style/main.css +++ /dev/null @@ -1,687 +0,0 @@ -@import url(fonts/clear-sans.css); -html, body { - margin: 0; - padding: 0; - background: #faf8ef; - color: #776e65; - font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; - font-size: 18px; } - -body { - margin: 80px 0; } - -.heading:after { - content: ""; - display: block; - clear: both; } - -h1.title { - font-size: 80px; - font-weight: bold; - margin: 0; - display: block; - float: left; } - -@-webkit-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@-moz-keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -@keyframes move-up { - 0% { - top: 25px; - opacity: 1; } - - 100% { - top: -50px; - opacity: 0; } } - -.scores-container { - float: right; - text-align: right; } - -.score-container, .best-container { - position: relative; - display: inline-block; - background: #bbada0; - padding: 15px 25px; - font-size: 25px; - height: 25px; - line-height: 47px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; } - .score-container:after, .best-container:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: #eee4da; } - .score-container .score-addition, .best-container .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: 25px; - line-height: 25px; - font-weight: bold; - color: rgba(119, 110, 101, 0.9); - z-index: 100; - -webkit-animation: move-up 600ms ease-in; - -moz-animation: move-up 600ms ease-in; - animation: move-up 600ms ease-in; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - -.score-container:after { - content: "Score"; } - -.best-container:after { - content: "Record"; } - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; } - -a { - color: #776e65; - font-weight: bold; - text-decoration: underline; - cursor: pointer; } - -strong.important { - text-transform: uppercase; } - -hr { - border: none; - border-bottom: 1px solid #d8d4d0; - margin-top: 20px; - margin-bottom: 30px; } - -.container { - width: 500px; - margin: 0 auto; } - -@-webkit-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@-moz-keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -@keyframes fade-in { - 0% { - opacity: 0; } - - 100% { - opacity: 1; } } - -.game-container { - margin-top: 40px; - position: relative; - padding: 15px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 500px; - height: 500px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(238, 228, 218, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - -.grid-container { - position: absolute; - z-index: 1; } - -.grid-row { - margin-bottom: 15px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - -.grid-cell { - width: 106.25px; - height: 106.25px; - margin-right: 15px; - float: left; - border-radius: 3px; - background: rgba(238, 228, 218, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - -.tile-container { - position: absolute; - z-index: 2; } - -.tile, .tile .tile-inner { - width: 107px; - height: 107px; - line-height: 116.25px; } -.tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } -.tile.tile-position-1-2 { - -webkit-transform: translate(0px, 121px); - -moz-transform: translate(0px, 121px); - transform: translate(0px, 121px); } -.tile.tile-position-1-3 { - -webkit-transform: translate(0px, 242px); - -moz-transform: translate(0px, 242px); - transform: translate(0px, 242px); } -.tile.tile-position-1-4 { - -webkit-transform: translate(0px, 363px); - -moz-transform: translate(0px, 363px); - transform: translate(0px, 363px); } -.tile.tile-position-2-1 { - -webkit-transform: translate(121px, 0px); - -moz-transform: translate(121px, 0px); - transform: translate(121px, 0px); } -.tile.tile-position-2-2 { - -webkit-transform: translate(121px, 121px); - -moz-transform: translate(121px, 121px); - transform: translate(121px, 121px); } -.tile.tile-position-2-3 { - -webkit-transform: translate(121px, 242px); - -moz-transform: translate(121px, 242px); - transform: translate(121px, 242px); } -.tile.tile-position-2-4 { - -webkit-transform: translate(121px, 363px); - -moz-transform: translate(121px, 363px); - transform: translate(121px, 363px); } -.tile.tile-position-3-1 { - -webkit-transform: translate(242px, 0px); - -moz-transform: translate(242px, 0px); - transform: translate(242px, 0px); } -.tile.tile-position-3-2 { - -webkit-transform: translate(242px, 121px); - -moz-transform: translate(242px, 121px); - transform: translate(242px, 121px); } -.tile.tile-position-3-3 { - -webkit-transform: translate(242px, 242px); - -moz-transform: translate(242px, 242px); - transform: translate(242px, 242px); } -.tile.tile-position-3-4 { - -webkit-transform: translate(242px, 363px); - -moz-transform: translate(242px, 363px); - transform: translate(242px, 363px); } -.tile.tile-position-4-1 { - -webkit-transform: translate(363px, 0px); - -moz-transform: translate(363px, 0px); - transform: translate(363px, 0px); } -.tile.tile-position-4-2 { - -webkit-transform: translate(363px, 121px); - -moz-transform: translate(363px, 121px); - transform: translate(363px, 121px); } -.tile.tile-position-4-3 { - -webkit-transform: translate(363px, 242px); - -moz-transform: translate(363px, 242px); - transform: translate(363px, 242px); } -.tile.tile-position-4-4 { - -webkit-transform: translate(363px, 363px); - -moz-transform: translate(363px, 363px); - transform: translate(363px, 363px); } - -.tile { - position: absolute; - -webkit-transition: 100ms ease-in-out; - -moz-transition: 100ms ease-in-out; - transition: 100ms ease-in-out; - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; } - .tile .tile-inner { - border-radius: 3px; - background: #eee4da; - text-align: center; - font-weight: bold; - z-index: 10; - font-size: 55px; } - .tile.tile-2 .tile-inner { - background: #eee4da; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-4 .tile-inner { - background: #ede0c8; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } - .tile.tile-8 .tile-inner { - color: #f9f6f2; - background: #f2b179; } - .tile.tile-16 .tile-inner { - color: #f9f6f2; - background: #f59563; } - .tile.tile-32 .tile-inner { - color: #f9f6f2; - background: #f67c5f; } - .tile.tile-64 .tile-inner { - color: #f9f6f2; - background: #f65e3b; } - .tile.tile-128 .tile-inner { - color: #f9f6f2; - background: #edcf72; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.14286); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-128 .tile-inner { - font-size: 25px; } } - .tile.tile-256 .tile-inner { - color: #f9f6f2; - background: #edcc61; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746), inset 0 0 0 1px rgba(255, 255, 255, 0.19048); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-256 .tile-inner { - font-size: 25px; } } - .tile.tile-512 .tile-inner { - color: #f9f6f2; - background: #edc850; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.39683), inset 0 0 0 1px rgba(255, 255, 255, 0.2381); - font-size: 45px; } - @media screen and (max-width: 520px) { - .tile.tile-512 .tile-inner { - font-size: 25px; } } - .tile.tile-1024 .tile-inner { - color: #f9f6f2; - background: #edc53f; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.47619), inset 0 0 0 1px rgba(255, 255, 255, 0.28571); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-1024 .tile-inner { - font-size: 15px; } } - .tile.tile-2048 .tile-inner { - color: #f9f6f2; - background: #edc22e; - box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); - font-size: 35px; } - @media screen and (max-width: 520px) { - .tile.tile-2048 .tile-inner { - font-size: 15px; } } - .tile.tile-super .tile-inner { - color: #f9f6f2; - background: #3c3a32; - font-size: 30px; } - @media screen and (max-width: 520px) { - .tile.tile-super .tile-inner { - font-size: 10px; } } - -@-webkit-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes appear { - 0% { - opacity: 0; - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 100% { - opacity: 1; - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-new .tile-inner { - -webkit-animation: appear 200ms ease 100ms; - -moz-animation: appear 200ms ease 100ms; - animation: appear 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -@-webkit-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@-moz-keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -@keyframes pop { - 0% { - -webkit-transform: scale(0); - -moz-transform: scale(0); - transform: scale(0); } - - 50% { - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - transform: scale(1.2); } - - 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - transform: scale(1); } } - -.tile-merged .tile-inner { - z-index: 20; - -webkit-animation: pop 200ms ease 100ms; - -moz-animation: pop 200ms ease 100ms; - animation: pop 200ms ease 100ms; - -webkit-animation-fill-mode: backwards; - -moz-animation-fill-mode: backwards; - animation-fill-mode: backwards; } - -.game-intro { - margin-bottom: 0; } - -.game-explanation { - margin-top: 50px; } - -@media screen and (max-width: 520px) { - html, body { - font-size: 15px; } - - body { - margin: 20px 0; - padding: 0 20px; } - - h1.title { - font-size: 27px; - margin-top: 15px; } - - .container { - width: 280px; - margin: 0 auto; } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; } - - .heading { - margin-bottom: 10px; } - - .game-container { - margin-top: 40px; - position: relative; - padding: 10px; - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - background: #bbada0; - border-radius: 6px; - width: 280px; - height: 280px; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - .game-container .game-message { - display: none; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(238, 228, 218, 0.5); - z-index: 100; - text-align: center; - -webkit-animation: fade-in 800ms ease 1200ms; - -moz-animation: fade-in 800ms ease 1200ms; - animation: fade-in 800ms ease 1200ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; - animation-fill-mode: both; } - .game-container .game-message p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; } - .game-container .game-message .lower { - display: block; - margin-top: 59px; } - .game-container .game-message a { - display: inline-block; - background: #8f7a66; - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: #f9f6f2; - height: 40px; - line-height: 42px; - margin-left: 9px; } - .game-container .game-message a.keep-playing-button { - display: none; } - .game-container .game-message.game-won { - background: rgba(237, 194, 46, 0.5); - color: #f9f6f2; } - .game-container .game-message.game-won a.keep-playing-button { - display: inline-block; } - .game-container .game-message.game-won, .game-container .game-message.game-over { - display: block; } - - .grid-container { - position: absolute; - z-index: 1; } - - .grid-row { - margin-bottom: 10px; } - .grid-row:last-child { - margin-bottom: 0; } - .grid-row:after { - content: ""; - display: block; - clear: both; } - - .grid-cell { - width: 57.5px; - height: 57.5px; - margin-right: 10px; - float: left; - border-radius: 3px; - background: rgba(238, 228, 218, 0.35); } - .grid-cell:last-child { - margin-right: 0; } - - .tile-container { - position: absolute; - z-index: 2; } - - .tile, .tile .tile-inner { - width: 58px; - height: 58px; - line-height: 67.5px; } - .tile.tile-position-1-1 { - -webkit-transform: translate(0px, 0px); - -moz-transform: translate(0px, 0px); - transform: translate(0px, 0px); } - .tile.tile-position-1-2 { - -webkit-transform: translate(0px, 67px); - -moz-transform: translate(0px, 67px); - transform: translate(0px, 67px); } - .tile.tile-position-1-3 { - -webkit-transform: translate(0px, 135px); - -moz-transform: translate(0px, 135px); - transform: translate(0px, 135px); } - .tile.tile-position-1-4 { - -webkit-transform: translate(0px, 202px); - -moz-transform: translate(0px, 202px); - transform: translate(0px, 202px); } - .tile.tile-position-2-1 { - -webkit-transform: translate(67px, 0px); - -moz-transform: translate(67px, 0px); - transform: translate(67px, 0px); } - .tile.tile-position-2-2 { - -webkit-transform: translate(67px, 67px); - -moz-transform: translate(67px, 67px); - transform: translate(67px, 67px); } - .tile.tile-position-2-3 { - -webkit-transform: translate(67px, 135px); - -moz-transform: translate(67px, 135px); - transform: translate(67px, 135px); } - .tile.tile-position-2-4 { - -webkit-transform: translate(67px, 202px); - -moz-transform: translate(67px, 202px); - transform: translate(67px, 202px); } - .tile.tile-position-3-1 { - -webkit-transform: translate(135px, 0px); - -moz-transform: translate(135px, 0px); - transform: translate(135px, 0px); } - .tile.tile-position-3-2 { - -webkit-transform: translate(135px, 67px); - -moz-transform: translate(135px, 67px); - transform: translate(135px, 67px); } - .tile.tile-position-3-3 { - -webkit-transform: translate(135px, 135px); - -moz-transform: translate(135px, 135px); - transform: translate(135px, 135px); } - .tile.tile-position-3-4 { - -webkit-transform: translate(135px, 202px); - -moz-transform: translate(135px, 202px); - transform: translate(135px, 202px); } - .tile.tile-position-4-1 { - -webkit-transform: translate(202px, 0px); - -moz-transform: translate(202px, 0px); - transform: translate(202px, 0px); } - .tile.tile-position-4-2 { - -webkit-transform: translate(202px, 67px); - -moz-transform: translate(202px, 67px); - transform: translate(202px, 67px); } - .tile.tile-position-4-3 { - -webkit-transform: translate(202px, 135px); - -moz-transform: translate(202px, 135px); - transform: translate(202px, 135px); } - .tile.tile-position-4-4 { - -webkit-transform: translate(202px, 202px); - -moz-transform: translate(202px, 202px); - transform: translate(202px, 202px); } - - .game-container { - margin-top: 20px; } - - .tile .tile-inner { - font-size: 35px; } - - .game-message p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; } - .game-message .lower { - margin-top: 30px !important; } } diff --git a/sources/2048originel/style/main.scss b/sources/2048originel/style/main.scss deleted file mode 100644 index 00b6acc..0000000 --- a/sources/2048originel/style/main.scss +++ /dev/null @@ -1,519 +0,0 @@ -@import "helpers"; -@import "fonts/clear-sans.css"; - -$field-width: 500px; -$grid-spacing: 15px; -$grid-row-cells: 4; -$tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; -$tile-border-radius: 3px; - -$mobile-threshold: $field-width + 20px; - -$text-color: #776E65; -$bright-text-color: #f9f6f2; - -$tile-color: #eee4da; -$tile-gold-color: #edc22e; -$tile-gold-glow-color: lighten($tile-gold-color, 15%); - -$game-container-background: #bbada0; - -$transition-speed: 100ms; - -html, body { - margin: 0; - padding: 0; - - background: #faf8ef; - color: $text-color; - font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; - font-size: 18px; -} - -body { - margin: 80px 0; -} - -.heading:after { - content: ""; - display: block; - clear: both; -} - -h1.title { - font-size: 80px; - font-weight: bold; - margin: 0; - display: block; - float: left; -} - -@include keyframes(move-up) { - 0% { - top: 25px; - opacity: 1; - } - - 100% { - top: -50px; - opacity: 0; - } -} - -.scores-container { - float: right; - text-align: right; -} - -.score-container, .best-container { - $height: 25px; - - position: relative; - display: inline-block; - background: $game-container-background; - padding: 15px 25px; - font-size: $height; - height: $height; - line-height: $height + 22px; - font-weight: bold; - border-radius: 3px; - color: white; - margin-top: 8px; - text-align: center; - - &:after { - position: absolute; - width: 100%; - top: 10px; - left: 0; - text-transform: uppercase; - font-size: 13px; - line-height: 13px; - text-align: center; - color: $tile-color; - } - - .score-addition { - position: absolute; - right: 30px; - color: red; - font-size: $height; - line-height: $height; - font-weight: bold; - color: rgba($text-color, .9); - z-index: 100; - @include animation(move-up 600ms ease-in); - @include animation-fill-mode(both); - } -} - -.score-container:after { - content: "Score"; -} - -.best-container:after { - content: "Best" -} - -p { - margin-top: 0; - margin-bottom: 10px; - line-height: 1.65; -} - -a { - color: $text-color; - font-weight: bold; - text-decoration: underline; - cursor: pointer; -} - -strong { - &.important { - text-transform: uppercase; - } -} - -hr { - border: none; - border-bottom: 1px solid lighten($text-color, 40%); - margin-top: 20px; - margin-bottom: 30px; -} - -.container { - width: $field-width; - margin: 0 auto; -} - -@include keyframes(fade-in) { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -// Styles for buttons -@mixin button { - display: inline-block; - background: darken($game-container-background, 20%); - border-radius: 3px; - padding: 0 20px; - text-decoration: none; - color: $bright-text-color; - height: 40px; - line-height: 42px; -} - -// Game field mixin used to render CSS at different width -@mixin game-field { - .game-container { - margin-top: 40px; - position: relative; - padding: $grid-spacing; - - cursor: default; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - - background: $game-container-background; - border-radius: $tile-border-radius * 2; - width: $field-width; - height: $field-width; - -ms-touch-action: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - .game-message { - display: none; - - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba($tile-color, .5); - z-index: 100; - - text-align: center; - - p { - font-size: 60px; - font-weight: bold; - height: 60px; - line-height: 60px; - margin-top: 222px; - // height: $field-width; - // line-height: $field-width; - } - - .lower { - display: block; - margin-top: 59px; - } - - a { - @include button; - margin-left: 9px; - // margin-top: 59px; - - &.keep-playing-button { - display: none; - } - } - - @include animation(fade-in 800ms ease $transition-speed * 12); - @include animation-fill-mode(both); - - &.game-won { - background: rgba($tile-gold-color, .5); - color: $bright-text-color; - - a.keep-playing-button { - display: inline-block; - } - } - - &.game-won, &.game-over { - display: block; - } - } - } - - .grid-container { - position: absolute; - z-index: 1; - } - - .grid-row { - margin-bottom: $grid-spacing; - - &:last-child { - margin-bottom: 0; - } - - &:after { - content: ""; - display: block; - clear: both; - } - } - - .grid-cell { - width: $tile-size; - height: $tile-size; - margin-right: $grid-spacing; - float: left; - - border-radius: $tile-border-radius; - - background: rgba($tile-color, .35); - - &:last-child { - margin-right: 0; - } - } - - .tile-container { - position: absolute; - z-index: 2; - } - - .tile { - &, .tile-inner { - width: ceil($tile-size); - height: ceil($tile-size); - line-height: $tile-size + 10px; - } - - // Build position classes - @for $x from 1 through $grid-row-cells { - @for $y from 1 through $grid-row-cells { - &.tile-position-#{$x}-#{$y} { - $xPos: floor(($tile-size + $grid-spacing) * ($x - 1)); - $yPos: floor(($tile-size + $grid-spacing) * ($y - 1)); - @include transform(translate($xPos, $yPos)); - } - } - } - } -} - -// End of game-field mixin -@include game-field; - -.tile { - position: absolute; // Makes transforms relative to the top-left corner - - .tile-inner { - border-radius: $tile-border-radius; - - background: $tile-color; - text-align: center; - font-weight: bold; - z-index: 10; - - font-size: 55px; - } - - // Movement transition - @include transition($transition-speed ease-in-out); - -webkit-transition-property: -webkit-transform; - -moz-transition-property: -moz-transform; - transition-property: transform; - - $base: 2; - $exponent: 1; - $limit: 11; - - // Colors for all 11 states, false = no special color - $special-colors: false false, // 2 - false false, // 4 - #f78e48 true, // 8 - #fc5e2e true, // 16 - #ff3333 true, // 32 - #ff0000 true, // 64 - false true, // 128 - false true, // 256 - false true, // 512 - false true, // 1024 - false true; // 2048 - - // Build tile colors - @while $exponent <= $limit { - $power: pow($base, $exponent); - - &.tile-#{$power} .tile-inner { - // Calculate base background color - $gold-percent: ($exponent - 1) / ($limit - 1) * 100; - $mixed-background: mix($tile-gold-color, $tile-color, $gold-percent); - - $nth-color: nth($special-colors, $exponent); - - $special-background: nth($nth-color, 1); - $bright-color: nth($nth-color, 2); - - @if $special-background { - $mixed-background: mix($special-background, $mixed-background, 55%); - } - - @if $bright-color { - color: $bright-text-color; - } - - // Set background - background: $mixed-background; - - // Add glow - $glow-opacity: max($exponent - 4, 0) / ($limit - 4); - - @if not $special-background { - box-shadow: 0 0 30px 10px rgba($tile-gold-glow-color, $glow-opacity / 1.8), - inset 0 0 0 1px rgba(white, $glow-opacity / 3); - } - - // Adjust font size for bigger numbers - @if $power >= 100 and $power < 1000 { - font-size: 45px; - - // Media queries placed here to avoid carrying over the rest of the logic - @include smaller($mobile-threshold) { - font-size: 25px; - } - } @else if $power >= 1000 { - font-size: 35px; - - @include smaller($mobile-threshold) { - font-size: 15px; - } - } - } - - $exponent: $exponent + 1; - } - - // Super tiles (above 2048) - &.tile-super .tile-inner { - color: $bright-text-color; - background: mix(#333, $tile-gold-color, 95%); - - font-size: 30px; - - @include smaller($mobile-threshold) { - font-size: 10px; - } - } -} - -@include keyframes(appear) { - 0% { - opacity: 0; - @include transform(scale(0)); - } - - 100% { - opacity: 1; - @include transform(scale(1)); - } -} - -.tile-new .tile-inner { - @include animation(appear 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -@include keyframes(pop) { - 0% { - @include transform(scale(0)); - } - - 50% { - @include transform(scale(1.2)); - } - - 100% { - @include transform(scale(1)); - } -} - -.tile-merged .tile-inner { - z-index: 20; - @include animation(pop 200ms ease $transition-speed); - @include animation-fill-mode(backwards); -} - -.game-intro { - margin-bottom: 0; -} - -.game-explanation { - margin-top: 50px; -} - -@include smaller($mobile-threshold) { - // Redefine variables for smaller screens - $field-width: 280px; - $grid-spacing: 10px; - $grid-row-cells: 4; - $tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells; - $tile-border-radius: 3px; - - html, body { - font-size: 15px; - } - - body { - margin: 20px 0; - padding: 0 20px; - } - - h1.title { - font-size: 27px; - margin-top: 15px; - } - - .container { - width: $field-width; - margin: 0 auto; - } - - .score-container, .best-container { - margin-top: 0; - padding: 15px 10px; - min-width: 40px; - } - - .heading { - margin-bottom: 10px; - } - - // Render the game field at the right width - @include game-field; - - .game-container { - margin-top: 20px; - } - - // Rest of the font-size adjustments in the tile class - .tile .tile-inner { - font-size: 35px; - } - - .game-message { - p { - font-size: 30px !important; - height: 30px !important; - line-height: 30px !important; - margin-top: 90px !important; - } - - .lower { - margin-top: 30px !important; - } - } -} diff --git a/sources/README.md b/sources/README.md deleted file mode 100644 index 94a75fc..0000000 --- a/sources/README.md +++ /dev/null @@ -1,13 +0,0 @@ -[![](https://git.framasoft.org/assets/logo-black-f52905a40830b30aa287f784b537c823.png)](https://git.framasoft.org) - -![English:](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Flag_of_the_United_Kingdom.svg/20px-Flag_of_the_United_Kingdom.svg.png) **Framasoft uses GitLab** for the development of its free softwares. Our Github repositories are only mirrors. -If you want to work with us, **fork us on [git.framasoft.org](https://git.framasoft.org)**. (no registration needed, you can sign in with your Github account) - -![Français :](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/20px-Flag_of_France.svg.png) **Framasoft utilise GitLab** pour le développement de ses logiciels libres. Nos dépôts Github ne sont que des miroirs. -Si vous souhaitez travailler avec nous, **forkez-nous sur [git.framasoft.org](https://git.framasoft.org)**. (l'inscription n'est pas nécessaire, vous pouvez vous connecter avec votre compte Github) -* * * - -Framagames est une compilation de jeux libres qui se jouent en ligne ou déconnectés que Framasoft propose sur le site : http://framagames.org -La page d'accueil s'appuie sur la librairie Bootstrap dont les fichiers se trouvent dans la [Framanav](https://git.framasoft.org/framasoft/framanav). - -* * * diff --git a/sources/back.js b/sources/back.js deleted file mode 100644 index 4f9e734..0000000 --- a/sources/back.js +++ /dev/null @@ -1,39 +0,0 @@ -// Lien retour Framagames -document.addEventListener('DOMContentLoaded', function() { - var framagames = document.createElement('a'); - framagames.style = "position: absolute;z-index:100;background:#fff;top:0px;left:0px;padding:5px 10px;border-radius:0 0 5px 0;font-family: DejaVu Sans !important;color: #333;font-size:14px;text-decoration:none;font-weight:normal;"; - framagames.href="/"; - framagames.target="_top"; - framagames.id="framagames" - document.getElementsByTagName('body')[0].appendChild(framagames); - document.getElementsByTagName('body')[0].style.paddingTop = "25px"; - document.getElementById("framagames").innerHTML = '← Retour sur Framagames'; -}); - -// Script Piwik -var _paq = _paq || []; - -_paq.push([function() { - var self = this; - function getOriginalVisitorCookieTimeout() { - var now = new Date(), - nowTs = Math.round(now.getTime() / 1000), - visitorInfo = self.getVisitorInfo(); - var createTs = parseInt(visitorInfo[2]); - var cookieTimeout = 33696000; // 13 mois en secondes - var originalTimeout = createTs + cookieTimeout - nowTs; - return originalTimeout; - } - this.setVisitorCookieTimeout( getOriginalVisitorCookieTimeout() ); -}]); - -_paq.push(["trackPageView"]); -_paq.push(["enableLinkTracking"]); - -(function() { - var u="https://stats.framasoft.org/"; - _paq.push(["setTrackerUrl", u+"piwik.php"]); - _paq.push(["setSiteId", 28]); - var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; - g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); -})(); diff --git a/sources/css/style.css b/sources/css/style.css deleted file mode 100644 index 6d346d8..0000000 --- a/sources/css/style.css +++ /dev/null @@ -1,136 +0,0 @@ -body { - background:#eee; - font-size:14px !important; -} - -.container.ombre { - margin-top: 30px; - margin-bottom: 30px; - padding: 20px 30px; -} - -/* Header style */ -header h1 { - font-family: "DejaVu Sans",Verdana,Geneva,sans-serif !important; - font-size: 48px; - font-weight: bold; -} - -header .lead { - color: #666; - font: italic 1.3em/1.35 "PT Sans",Arial,sans-serif; -} -/* End header style */ - -/* Tips */ -.tips { - list-style: none; - padding: 0px; - margin:0 auto; -} - -.tips > li { - position: relative; - overflow: hidden; - width: 320px; - height: 235px; - float:left; - background-color: white; - border-top: 1px solid #EEE; - box-shadow: 0px 9px 15px -10px rgba(0, 0, 0, 0.7); - margin: 12px 10px 25px 10px; -} - -/* gris */ -.tips > li .front, -.tips > li .back { - border-bottom: 4px solid #C4C4C4; - background:#F3F3F3; -} - -.tips h3 { - margin-top: 0px; - margin-bottom: 12px; - font-size:20px; - font-weight: bold; - text-align:center -} - -.tips .description { - font-size:16px; - margin-top:20px; -} -.play, .credits { - position:absolute; - width:300px; -} -.play { - bottom: 90px; -} -.credits { - bottom: 10px; -} - -.tip-content { - position: absolute; - width: 320px; - height: 470px; - top: 0px; - - -webkit-transition: all 400ms ease 0s; - -moz-transition: all 400ms ease 0s; - -o-transition: all 400ms ease 0s; - transition: all 400ms ease 0s; -} - -.front, .back { - padding: 10px; - height: 235px; -} - -.tips > li:hover .tip-content { - top: -235px; -} - -.show-back { - top: -235px; -} - -h1 a, h3 a, h4 a, -h1 a:hover, h3 a:hover, h4 a:hover, -h1 a:focus, h3 a:focus, h4 a:focus { - text-decoration:none; -} - -.tips .popover h3 { - font-size: 14px; - margin-bottom:0; -} -.tips .popover { - font-size: 14px; - left: 10px !important; - width: 300px; - height: 120px; -} -.tips .popover-content { - padding:9px 5px; -} -.tips .popover > .arrow { - left:80%; -} - -@media (max-width: 740px) { - .tips { - width:340px; - } -} -@media (min-width: 992px) { - .tips { - width:680px; - } -} -@media (min-width: 1200px) { - .tips { - width:1020px; - } -} diff --git a/sources/data.php b/sources/data.php deleted file mode 100644 index 7f6e46c..0000000 --- a/sources/data.php +++ /dev/null @@ -1,126 +0,0 @@ - [ - 'title' => '1597', - 'ctitle' => '1597', - 'img' => 'images/1.png', - 'description' => 'Fork de 2048 avec la suite de Fibonacci', - 'url' => '1597-master/index.html', - 'dl' => 'telechargement/1597-master.zip', - 'auteur' => 'Jeremy Hummel', - 'licence' => 'MIT', - 'src' => 'https://jmhummel.github.io/1597/' - ], - '2048frama' => [ - 'title' => '2048 Frama', - 'img' => 'images/2.png', - 'description' => '2048 aux couleurs de Framasoft', - 'url' => '2048frama/index.html', - 'dl' => 'telechargement/2048frama.zip', - 'auteur' => 'Cyrille Largillier', - 'licence' => 'MIT', - 'src' => 'http://framagames.org' - ], - '2048originel' => [ - 'title' => '2048', - 'img' => 'images/3.png', - 'description' => 'On ne présente plus 2048 !', - 'url' => '2048originel/index.html', - 'dl' => 'telechargement/2048originel.zip', - 'auteur' => 'Gabriele Cirulli', - 'licence' => 'MIT', - 'src' => 'http://gabrielecirulli.github.io/2048/' - ], - 'e-tris' => [ - 'title' => 'e-Tris', - 'img' => 'images/4.png', - 'description' => 'Classique et indémodable Tétris', - 'url' => 'e-tris/index.htm', - 'dl' => 'telechargement/e-tris.zip', - 'auteur' => '', - 'licence' => 'BSD', - 'src' => 'https://code.google.com/p/e-tris/' - ], - 'pappu-pakia' => [ - 'title' => 'Pappu Pakia', - 'img' => 'images/5.png', - 'description' => 'Un flappy bird like', - 'url' => 'pappu-pakia/index.htm', - 'dl' => 'telechargement/pappu-pakia.zip', - 'auteur' => 'Rishabh, Kushagra', - 'licence' => 'MIT', - 'src' => 'https://github.com/rishabhp/pappu-pakia' - ], - 'esviji' => [ - 'title' => 'Esviji', - 'img' => 'images/6.png', - 'description' => 'Dégommez des chiffres', - 'url' => 'esviji/index.html', - 'dl' => 'telechargement/esviji.zip', - 'auteur' => 'Nicolas Hoizey', - 'licence' => 'MIT', - 'src' => 'http://esviji.com' - ], - 'orbium' => [ - 'title' => 'Orbium', - 'img' => 'images/7.png', - 'description' => 'Un jeu de boules pour tous les âges', - 'url' => 'orbium/index.html', - 'dl' => 'telechargement/orbium.zip', - 'auteur' => 'Björn Nilsson', - 'licence' => 'GNU GPL', - 'src' => 'https://github.com/bni/orbium' - ], - 'roundball' => [ - 'title' => 'Roundball', - 'img' => 'images/8.png', - 'description' => 'Intervertissez des boules pour les aligner', - 'url' => 'roundball/roundball.html', - 'dl' => 'telechargement/roundball.zip', - 'auteur' => 'Digital Fruit', - 'licence' => 'Apache', - 'src' => 'https://github.com/digitalfruit/limejs' - ], - 'sokojs' => [ - 'title' => 'SokoJS', - 'img' => 'images/9.png', - 'description' => 'Rangez des caisses', - 'url' => 'sokojs/main.htm', - 'dl' => 'telechargement/sokojs.zip', - 'auteur' => 'Michel Buze', - 'licence' => 'GNU GPL', - 'src' => 'https://github.com/michbuze/sokojs' - ], - 'solitaire' => [ - 'title' => 'Solitaire', - 'img' => 'images/10.png', - 'description' => 'Du très classique', - 'url' => 'solitaire/index.html', - 'dl' => 'telechargement/solitaire.zip', - 'auteur' => 'Emin KURA', - 'licence' => 'MIT', - 'src' => 'https://code.google.com/p/simple-puzzle-game/' - ], - 'sudoku_js' => [ - 'title' => 'SudokuJS', - 'img' => 'images/11.png', - 'description' => 'Placez les nombres de 1 à 9', - 'url' => 'sudoku_js/index.html', - 'dl' => 'telechargement/sudoku_js.zip', - 'auteur' => 'Michael Loesler', - 'licence' => 'GNU GPL', - 'src' => 'http://derletztekick.com/javascript/sudoku' - ], - 'zlizer' => [ - 'title' => 'Zlizer', - 'img' => 'images/12.png', - 'description' => 'Ajoutez ou séparez des bulles', - 'url' => 'zlizer/zlizer.html', - 'dl' => 'telechargement/zlizer.zip', - 'auteur' => 'Digital Fruit', - 'licence' => 'Apache', - 'src' => 'https://github.com/digitalfruit/limejs' - ] -]; - -?> diff --git a/sources/e-tris/.hg/00changelog.i b/sources/e-tris/.hg/00changelog.i deleted file mode 100644 index d3a8311..0000000 Binary files a/sources/e-tris/.hg/00changelog.i and /dev/null differ diff --git a/sources/e-tris/.hg/branch b/sources/e-tris/.hg/branch deleted file mode 100644 index 4ad96d5..0000000 --- a/sources/e-tris/.hg/branch +++ /dev/null @@ -1 +0,0 @@ -default diff --git a/sources/e-tris/.hg/cache/branchheads-served b/sources/e-tris/.hg/cache/branchheads-served deleted file mode 100644 index 4bc25b1..0000000 --- a/sources/e-tris/.hg/cache/branchheads-served +++ /dev/null @@ -1,4 +0,0 @@ -03c4ce7c3b47243246f1f153bd5224ff6efae2fd 5 -03c4ce7c3b47243246f1f153bd5224ff6efae2fd default -b4630f45f59c3e0ceed3c227152d90119e12137b jslint -36c00ea64d1d7359e356cd61ececdb89fa56e13c restructure diff --git a/sources/e-tris/.hg/dirstate b/sources/e-tris/.hg/dirstate deleted file mode 100644 index 96e7203..0000000 Binary files a/sources/e-tris/.hg/dirstate and /dev/null differ diff --git a/sources/e-tris/.hg/hgrc b/sources/e-tris/.hg/hgrc deleted file mode 100644 index 8cfd3af..0000000 --- a/sources/e-tris/.hg/hgrc +++ /dev/null @@ -1,2 +0,0 @@ -[paths] -default = https://code.google.com/p/e-tris/ diff --git a/sources/e-tris/.hg/requires b/sources/e-tris/.hg/requires deleted file mode 100644 index f634f66..0000000 --- a/sources/e-tris/.hg/requires +++ /dev/null @@ -1,4 +0,0 @@ -dotencode -fncache -revlogv1 -store diff --git a/sources/e-tris/.hg/store/00changelog.i b/sources/e-tris/.hg/store/00changelog.i deleted file mode 100644 index 931337b..0000000 Binary files a/sources/e-tris/.hg/store/00changelog.i and /dev/null differ diff --git a/sources/e-tris/.hg/store/00manifest.i b/sources/e-tris/.hg/store/00manifest.i deleted file mode 100644 index c6a7901..0000000 Binary files a/sources/e-tris/.hg/store/00manifest.i and /dev/null differ diff --git a/sources/e-tris/.hg/store/data/index.htm.i b/sources/e-tris/.hg/store/data/index.htm.i deleted file mode 100644 index 499f715..0000000 Binary files a/sources/e-tris/.hg/store/data/index.htm.i and /dev/null differ diff --git a/sources/e-tris/.hg/store/data/script.js.i b/sources/e-tris/.hg/store/data/script.js.i deleted file mode 100644 index 1827fd6..0000000 Binary files a/sources/e-tris/.hg/store/data/script.js.i and /dev/null differ diff --git a/sources/e-tris/.hg/store/data/styles.css.i b/sources/e-tris/.hg/store/data/styles.css.i deleted file mode 100644 index ecc5d92..0000000 Binary files a/sources/e-tris/.hg/store/data/styles.css.i and /dev/null differ diff --git a/sources/e-tris/.hg/store/fncache b/sources/e-tris/.hg/store/fncache deleted file mode 100644 index d6c71c0..0000000 --- a/sources/e-tris/.hg/store/fncache +++ /dev/null @@ -1,3 +0,0 @@ -data/styles.css.i -data/index.htm.i -data/script.js.i diff --git a/sources/e-tris/.hg/store/phaseroots b/sources/e-tris/.hg/store/phaseroots deleted file mode 100644 index e69de29..0000000 diff --git a/sources/e-tris/.hg/store/undo b/sources/e-tris/.hg/store/undo deleted file mode 100644 index 348538b..0000000 Binary files a/sources/e-tris/.hg/store/undo and /dev/null differ diff --git a/sources/e-tris/.hg/store/undo.phaseroots b/sources/e-tris/.hg/store/undo.phaseroots deleted file mode 100644 index e69de29..0000000 diff --git a/sources/e-tris/.hg/undo.bookmarks b/sources/e-tris/.hg/undo.bookmarks deleted file mode 100644 index e69de29..0000000 diff --git a/sources/e-tris/.hg/undo.branch b/sources/e-tris/.hg/undo.branch deleted file mode 100644 index 331d858..0000000 --- a/sources/e-tris/.hg/undo.branch +++ /dev/null @@ -1 +0,0 @@ -default \ No newline at end of file diff --git a/sources/e-tris/.hg/undo.desc b/sources/e-tris/.hg/undo.desc deleted file mode 100644 index 3145fd0..0000000 --- a/sources/e-tris/.hg/undo.desc +++ /dev/null @@ -1,3 +0,0 @@ -0 -pull -https://code.google.com/p/e-tris/ diff --git a/sources/e-tris/.hg/undo.dirstate b/sources/e-tris/.hg/undo.dirstate deleted file mode 100644 index e69de29..0000000 diff --git a/sources/e-tris/index.htm b/sources/e-tris/index.htm deleted file mode 100644 index 2c812ef..0000000 --- a/sources/e-tris/index.htm +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Tetris - - - - - - - diff --git a/sources/e-tris/script.js b/sources/e-tris/script.js deleted file mode 100644 index bb81cf2..0000000 --- a/sources/e-tris/script.js +++ /dev/null @@ -1,386 +0,0 @@ -var Game = function(){ - var contentWidth = 10; - var contentHeight = 20; - var boxWidth = 20; - var boxHeight = 20; - var timeout; - var currentShape; - var boxes = []; - var points = 0; - var running = false; - var paused = false; - var Shape = function(myBoxes, color){ - return { - offsetX: 0, - offsetY: -1, - rotate: function(){ - myBoxes = [myBoxes[2], myBoxes[5], myBoxes[8], myBoxes[1], myBoxes[4], - myBoxes[7], myBoxes[0], myBoxes[3], myBoxes[6]]; - if(this.checkForCollision()){ - myBoxes = [myBoxes[6], myBoxes[3], myBoxes[0], myBoxes[7], myBoxes[4], - myBoxes[1], myBoxes[8], myBoxes[5], myBoxes[2]]; - } - }, - fall: function(){ - this.offsetY++; - if(this.checkForCollision()){ - this.offsetY--; - this.stop(); - } - }, - stop: function(){ - var i; - var w; - var h; - for(i in myBoxes){ - if(myBoxes.hasOwnProperty(i)){ - if(myBoxes[i]){ - w = this.getW(i); - h = this.getH(i); - if(boxes[h][w] !== undefined){ - endGame(); - } - boxes[h][w] = new Box(w, h, color); - } - } - } - changeShape(); - }, - moveRight: function(){ - this.offsetX++; - if(this.checkForCollision()){ - this.offsetX--; - } - }, - moveLeft: function(){ - this.offsetX--; - if(this.checkForCollision()){ - this.offsetX++; - } - }, - getH: function(i){ - return (Math.floor(i/3)+this.offsetY); - }, - getW: function(i){ - return i%3+this.offsetX; - }, - draw: function(ctx){ - var i; - var w; - var h; - ctx.save(); - ctx.fillStyle = color; - for(i in myBoxes){ - if(myBoxes.hasOwnProperty(i) && myBoxes[i] ){ - w = this.getW(i); - h = this.getH(i); - ctx.globalAlpha = 0.7; - ctx.fillRect(w*boxWidth+w, h*boxHeight+h, boxWidth, boxHeight); - ctx.globalAlpha = 0.7; - ctx.strokeRect(w*boxWidth+w+2, h*boxHeight+h+2, boxWidth-3, boxHeight-3); - } - } - ctx.restore(); - }, - checkForCollision: function(){ - var i; - var w; - var h; - for(i in myBoxes){ - if(myBoxes.hasOwnProperty(i) && myBoxes[i]){ - w = this.getW(i); - h = this.getH(i); - if(h >= 0){ - if(w < 0 || w >= contentWidth){ return true;} - if(h >= contentHeight || boxes[h][w] !== undefined){ return true;} - } - } - } - return false; - } - }; - }; - var getShape = function(){ - var shape; - switch(Math.floor(Math.random()*7)){ - case 0: - shape = new Shape([1, 1, 1, 1], 'maroon'); - shape.isTilted = false; - shape.rotate = function(){ - shape.isTilted = !shape.isTilted; - }; - shape.getH = function(i){ - return shape.isTilted? shape.offsetY+1: Number(i)+shape.offsetY; - }; - shape.getW = function(i){ - return shape.isTilted? Number(i)+shape.offsetX-1: this.offsetX; - }; - shape.offsetX = 1; - return shape; - case 1: return new Shape([0, 0, 0, 1, 1, 1, 0, 0, 1], 'white'); - case 2: return new Shape([0, 0, 0, 0, 0, 1, 1, 1, 1], 'magenta'); - case 3: - shape = new Shape([0, 0, 0, 0, 1, 1, 0, 1, 1], 'dark blue'); - shape.rotate = function(){}; - return shape; - case 4: return new Shape([0, 0, 0, 0, 1, 1, 1, 1, 0], 'green'); - case 5: return new Shape([0, 0, 0, 0, 1, 0, 1, 1, 1], 'brown'); - case 6: return new Shape([0, 0, 0, 1, 1, 0, 0, 1, 1], 'cyan'); - } - }; - var nextShape = getShape(); - var sidepanel = document.createElement('div'); - var bottom = document.createElement('div'); - var gameCanvas = document.createElement('canvas'); - var nextCanvas = document.createElement('canvas'); - var ctx = gameCanvas.getContext('2d'); - var nctx = nextCanvas.getContext('2d'); - var pointsContainer = document.createElement('div'); - var setPoints = function(p){ - points = p; - while (pointsContainer.childNodes.length >= 1){ - pointsContainer.removeChild(pointsContainer.firstChild); - } - pointsContainer.appendChild(document.createTextNode(points +'p')); - }; - var startGame = function(){ - var h = 0; - var w = 0; - running = true; - for(h = 0; h < contentHeight; h++){ - boxes[h] = []; - for(w = 0; w < contentWidth; w++){ - boxes[h][w] = undefined; - } - } - setPoints(0); - changeShape(); - redraw(); - }; - var setNewTimeout = function(t){ - window.clearTimeout(timeout); - timeout = setInterval(function(){currentShape.fall();redraw();}, t); - }; - var changeShape = function(){ - var p = 1; - if(running){ - setNewTimeout(1000-points); - while(checkRows(p)){ - p+=1; - } - currentShape = nextShape; - currentShape.offsetX = 4; - nextShape = getShape(); - redraw(); - } - }; - var pause = function(){ - window.clearTimeout(timeout); - paused = true; - redraw(); - }; - var unpause = function(){ - paused = false; - currentShape.fall(); - redraw(); - setNewTimeout(1000); - }; - - var endGame = function(){ - setPoints(points); - pointsContainer.appendChild(document.createElement('br')); - pointsContainer.appendChild(document.createTextNode('Game over')); - window.clearTimeout(timeout); - running = false; - }; - - /** - * Check all rows and removes the first row (from the top) that has been fully - * filled with blocks. Return true if such row has been removed - *@arg n is the number of points that the the player should be awarded with - * when removing a row - */ - var checkRows = function(n){ - var h; - var fun = function(i){ return i === undefined;}; - for(h in boxes){ - if(boxes.hasOwnProperty(h) && boxes[h].filter(fun).length <= 0){ - removeRow(h,n); - return true; - } - } - }; - var removeRow = function(row,p){ - var h; - var w; - for(h = row; h > 0; h--){ - boxes[h] = boxes[h-1]; - for(w = 0; w < contentWidth; w++){ - if(boxes[h][w] !== undefined){ - boxes[h][w].moveDown(); - } - } - } - boxes[0] = []; - for(w = 0; w < contentWidth; w++){ - boxes[0][w] = undefined; - } - setPoints(points+p); - }; - var Box = function(w, h, color){ - return { - drawBox: function(ctx){ - ctx.save(); - ctx.fillStyle = color; - ctx.globalAlpha = 0.5; - ctx.fillRect(w*boxWidth+w, h*boxHeight+h, boxWidth, boxHeight); - ctx.globalAlpha = 0.7; - ctx.strokeRect(w*boxWidth+w+2, h*boxHeight+h+2, boxWidth-3, boxHeight-3); - ctx.restore(); - }, - getColor: function(){ - return color; - }, - moveDown: function(){ - h++; - } - }; - }; - var drawBackground = function(ctx, width, height){ - var w; - var h; - ctx.save(); - ctx.fillStyle = 'rgba(50,50,50,0.5)'; - for(w = 0; w < width; w++){ - for(h = 0; h < height; h++){ - ctx.fillRect(w*boxWidth+w, h*boxHeight+h, boxWidth, boxHeight); - } - } - ctx.restore(); - }; - var redraw = function(){ - var ctx = gameCanvas.getContext('2d'); - var nctx = nextCanvas.getContext('2d'); - var w; - var h; - clear(ctx, gameCanvas.width, gameCanvas.height); - clear(nctx, nextCanvas.width, nextCanvas.height); - drawBackground(ctx, contentWidth, contentHeight); - drawBackground(nctx, 4, 4); - nextShape.draw(nctx); - - for(w in boxes){ - if(boxes.hasOwnProperty(w)){ - var o = boxes[w]; - for(h in o){ - if(o[h] !== undefined){ - o[h].drawBox(ctx); - } - } - } - } - if(running){ - currentShape.draw(ctx); - if(paused){ - ctx.font = 'bold 12px sans-serif'; - ctx.fillStyle = 'rgba(0,0,0,0.8)'; - ctx.fillText('Appuyez \'p\' pour continuer', 10, 140); - } - }else{ - ctx.font = 'bold 24px sans-serif'; - ctx.fillStyle = 'rgba(0,0,0,1)'; - ctx.fillText('C\'est perdu !', 50, 150); - - } - }; - var clear = function(ctx, width, height){ - ctx.clearRect(0,0,width,height); - }; -// magic - - gameCanvas.width = contentWidth*boxWidth+contentWidth-1; - gameCanvas.height = contentHeight*boxHeight+contentHeight-1; - nextCanvas.width = boxWidth*4+4-1; - nextCanvas.height = boxHeight*4+4-1; - - drawBackground(ctx, contentWidth, contentHeight); - drawBackground(nctx, 4, 4); - ctx.fillStyle = 'rgba(0,0,0,0.8)'; - ctx.font = 'bold 12px sans-serif'; - ctx.fillText('Appuyez sur \'s\' pour jouer', 10, 140); - pointsContainer.appendChild(document.createElement('br')); - pointsContainer.setAttribute('id', 'points'); - sidepanel.setAttribute('id', 'sidepanel'); - bottom.setAttribute('id', 'bottom'); - sidepanel.appendChild(document.createTextNode('Forme suivante : ')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(nextCanvas); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(pointsContainer); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('s pour commencer')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('← pour déplacer la pièce à gauche')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('→ pour déplacer la pièce à droite')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('↑ pour tourner la pièce')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('↓ pour augmenter la vitesse de chute')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('r pour recommencer')); - sidepanel.appendChild(document.createElement('br')); - sidepanel.appendChild(document.createTextNode('p pour mettre en pause')); - sidepanel.appendChild(document.createElement('br')); - bottom.appendChild(document.createTextNode('Le nombre de points obtenu augmente lorsque plusieurs lignes sont supprimées à la fois. Une ligne génère un point mais quatre lignes génèrent un total de dix points.')); - - document.body.appendChild(gameCanvas); - document.body.appendChild(sidepanel); - document.body.appendChild(bottom); -//return - return { - keyHandler: function(e){ - if(e.which === 82){ // 'r' - endGame(); - startGame(); - } else if(running && !paused){ - switch(e.which){ - case 39: //right - currentShape.moveRight(); - redraw(); - break; - case 37: //left - currentShape.moveLeft(); - redraw(); - break; - case 40: //down - setNewTimeout(50); - break; - case 38: // up - currentShape.rotate(); - redraw(); - break; - case 80: // 'p' - pause(); - break; - } - } else if(running && paused && e.which === 80){ // 'p' - unpause(); - } else if(!running && e.which === 83){ // 's' - startGame(); - } - }, - onblur: function(e){ - if(running && !paused){ - pause(); - } - } - }; -}; - -window.onload = function(){ - var g = new Game(); - document.onkeydown = g.keyHandler; - document.body.onblur = g.onblur; -}; - diff --git a/sources/e-tris/styles.css b/sources/e-tris/styles.css deleted file mode 100644 index 9bfe370..0000000 --- a/sources/e-tris/styles.css +++ /dev/null @@ -1,34 +0,0 @@ -body{ - text-decoration: none; - font-family:Verdana; - background: #fcfcfc; - margin: 0; - padding: 0; - text-align: center; - padding-top: 10px; font-size: 10px; -} -canvas{ - border: 1px solid black; -} -div#sidepanel{ - padding: 10px; - vertical-align:top; - display: inline-block; - text-align: left; - border: 1px solid black; - margin-left: 10px; - height: 100% -} -div#points{ - font-size: 15px; - text-decoration: bold; -} -div#bottom{ - padding: 10px; - width: 500px; - margin-left: auto; - margin-right: auto; - margin-bottom: 10px; - border: 1px solid black; -} - diff --git a/sources/esviji/.gitignore b/sources/esviji/.gitignore deleted file mode 100644 index e6590a5..0000000 --- a/sources/esviji/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.DS_Store -node_modules/ -docs/ -deploy.sh -dist/ -src/manifest.appcache -.sass-cache/ -.tmp/ \ No newline at end of file diff --git a/sources/esviji/css/font/sansitaone-webfont.eot b/sources/esviji/css/font/sansitaone-webfont.eot deleted file mode 100644 index ae6020b..0000000 Binary files a/sources/esviji/css/font/sansitaone-webfont.eot and /dev/null differ diff --git a/sources/esviji/css/font/sansitaone-webfont.svg b/sources/esviji/css/font/sansitaone-webfont.svg deleted file mode 100644 index 7ad9928..0000000 --- a/sources/esviji/css/font/sansitaone-webfont.svg +++ /dev/null @@ -1,250 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Copyright c 2011 by OmnibusType wwwomnibustypecom with Reserved Font Name Sansita One -Designer : Pablo Cosgaya -Foundry : OmnibusType -Foundry URL : wwwomnibustypecom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sources/esviji/css/font/sansitaone-webfont.ttf b/sources/esviji/css/font/sansitaone-webfont.ttf deleted file mode 100644 index 1d90087..0000000 Binary files a/sources/esviji/css/font/sansitaone-webfont.ttf and /dev/null differ diff --git a/sources/esviji/css/font/sansitaone-webfont.woff b/sources/esviji/css/font/sansitaone-webfont.woff deleted file mode 100644 index a28766d..0000000 Binary files a/sources/esviji/css/font/sansitaone-webfont.woff and /dev/null differ diff --git a/sources/esviji/css/styles.css b/sources/esviji/css/styles.css deleted file mode 100644 index 46a7b66..0000000 --- a/sources/esviji/css/styles.css +++ /dev/null @@ -1,221 +0,0 @@ -@font-face { - font-family: "SansitaOneRegular"; - src: url("font/sansitaone-webfont.woff") format("woff"), url("font/sansitaone-webfont.svg#SansitaOneRegular") format("svg"); - font-weight: normal; - font-style: normal; -} -html, body { - font-family: SansitaOneRegular; - font-size: 18px; - /* http://maximilianhoffmann.com/posts/better-font-rendering-on-osx */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - background-color: #444; - color: #fff; - margin: 0; - padding: 0; - width: 100%; - height: 100%; - overflow: hidden; -} - -#description { - padding: 1em; -} -#description h1 { - font-size: 3em; - text-align: center; -} -#description h2, #description p { - font-family: sans-serif; -} -#description p.icon { - text-align: center; -} -#description a:link, #description a:visited { - color: #ccc; -} -#description a:hover, #description a:active { - color: #fdd; -} - -#board { - stroke-width: 0; -} - -#play .title, #tutorial .title { - font-size: 34px; - text-anchor: end; - fill: #fff; - stroke-width: 0; -} -#play .scoreLabel, #play .levelLabel, #play .livesLabel, #tutorial .scoreLabel, #tutorial .levelLabel, #tutorial .livesLabel { - text-anchor: end; - fill: #ccc; - stroke-width: 0; -} -#play .score, #play .level, #play .lives, #tutorial .score, #tutorial .level, #tutorial .lives { - -webkit-transition: all 1s ease-out; - transition: all 1s ease-out; - fill: #eee; - stroke-width: 0; -} -#play .score.changeDown, #play .level.changeDown, #play .lives.changeDown, #tutorial .score.changeDown, #tutorial .level.changeDown, #tutorial .lives.changeDown { - fill: #c0392b; -} -#play .score.changeUp, #play .level.changeUp, #play .lives.changeUp, #tutorial .score.changeUp, #tutorial .level.changeUp, #tutorial .lives.changeUp { - fill: #27ae60; -} - -.pauseButton { - pointer-events: visible; -} -.pauseButton .fullarea { - pointer-events: visible; - fill: #fff; - opacity: 0; -} -.pauseButton .icon { - stroke-width: 0; - fill: #fff; - opacity: 0.7; -} - -.ball text { - font-size: 16px; - text-anchor: middle; - fill: #fff; - stroke-width: 0; -} - -.ball1 { - fill: #f39c12; - stroke: #e67e22; -} - -.ball2 { - fill: #2ecc71; - stroke: #27ae60; -} - -.ball3 { - fill: #3498db; - stroke: #2980b9; -} - -.ball4 { - fill: #9b59b6; - stroke: #8e44ad; -} - -.ball5 { - fill: #aa8866; - stroke: #776655; -} - -.ball6 { - fill: #e74c3c; - stroke: #c0392b; -} - -#playable { - pointer-events: none; -} -#playable:hover { - cursor: pointer; -} - -.panelBackground { - pointer-events: visible; - fill: transparent; -} - -#main .title { - font-size: 96px; - text-anchor: middle; - stroke-width: 0; - fill: #fff; -} - -#difficulty .title, #gameOver .title, #pause .title, #scores .title, #settings .title { - font-size: 48px; - text-anchor: middle; - fill: #fff; - stroke-width: 0; -} - -#gameOver .score { - font-size: 34px; - text-anchor: middle; - fill: #eee; -} - -#scores .highscores { - font-size: 18px; - text-anchor: end; - fill: #eee; -} -#scores .highscores .thisone { - fill: #3c3; -} - -.button { - pointer-events: visible; -} -.button text { - font-size: 18px; - text-anchor: middle; - fill: #333; - stroke-width: 0; -} -.button rect { - fill: #ddd; - stroke-width: 3; - stroke: #666; -} -.button:hover { - cursor: pointer; -} -.button:hover rect { - fill: #fff; - stroke-width: 3; - stroke: #888; -} - -.label { - text-anchor: end; - fill: #fff; -} - -.copyright, .website, .version { - font-size: 10px; - fill: #888; - stroke-width: 0; -} - -.copyright { - text-anchor: start; -} - -.website { - text-anchor: middle; -} - -.version { - text-anchor: end; -} - -.step text { - font-weight: normal; - fill: #333; -} -.step rect, .step path { - fill: #aaa; - fill-opacity: 1; - stroke-width: 0; - stroke: #aaa; -} - -#installButton { - display: none; -} diff --git a/sources/esviji/favicons/apple-touch-icon-114x114.png b/sources/esviji/favicons/apple-touch-icon-114x114.png deleted file mode 100644 index 1c28c72..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-114x114.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-120x120.png b/sources/esviji/favicons/apple-touch-icon-120x120.png deleted file mode 100644 index ef8ebe4..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-120x120.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-144x144.png b/sources/esviji/favicons/apple-touch-icon-144x144.png deleted file mode 100644 index 433085f..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-144x144.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-152x152.png b/sources/esviji/favicons/apple-touch-icon-152x152.png deleted file mode 100644 index 8899651..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-152x152.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-57x57.png b/sources/esviji/favicons/apple-touch-icon-57x57.png deleted file mode 100644 index 6f8e17e..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-57x57.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-60x60.png b/sources/esviji/favicons/apple-touch-icon-60x60.png deleted file mode 100644 index b0ab9b8..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-60x60.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-72x72.png b/sources/esviji/favicons/apple-touch-icon-72x72.png deleted file mode 100644 index 30f2d50..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-72x72.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-76x76.png b/sources/esviji/favicons/apple-touch-icon-76x76.png deleted file mode 100644 index 93f80a2..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-76x76.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon-precomposed.png b/sources/esviji/favicons/apple-touch-icon-precomposed.png deleted file mode 100644 index c8160b3..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon-precomposed.png and /dev/null differ diff --git a/sources/esviji/favicons/apple-touch-icon.png b/sources/esviji/favicons/apple-touch-icon.png deleted file mode 100644 index 8899651..0000000 Binary files a/sources/esviji/favicons/apple-touch-icon.png and /dev/null differ diff --git a/sources/esviji/favicons/browserconfig.xml b/sources/esviji/favicons/browserconfig.xml deleted file mode 100644 index 3f5bb74..0000000 --- a/sources/esviji/favicons/browserconfig.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - #888888 - - - diff --git a/sources/esviji/favicons/favicon-160x160.png b/sources/esviji/favicons/favicon-160x160.png deleted file mode 100644 index fa9f3b9..0000000 Binary files a/sources/esviji/favicons/favicon-160x160.png and /dev/null differ diff --git a/sources/esviji/favicons/favicon-16x16.png b/sources/esviji/favicons/favicon-16x16.png deleted file mode 100644 index 84266b9..0000000 Binary files a/sources/esviji/favicons/favicon-16x16.png and /dev/null differ diff --git a/sources/esviji/favicons/favicon-196x196.png b/sources/esviji/favicons/favicon-196x196.png deleted file mode 100644 index 91020f0..0000000 Binary files a/sources/esviji/favicons/favicon-196x196.png and /dev/null differ diff --git a/sources/esviji/favicons/favicon-32x32.png b/sources/esviji/favicons/favicon-32x32.png deleted file mode 100644 index 510e067..0000000 Binary files a/sources/esviji/favicons/favicon-32x32.png and /dev/null differ diff --git a/sources/esviji/favicons/favicon-96x96.png b/sources/esviji/favicons/favicon-96x96.png deleted file mode 100644 index 68138a8..0000000 Binary files a/sources/esviji/favicons/favicon-96x96.png and /dev/null differ diff --git a/sources/esviji/favicons/favicon.ico b/sources/esviji/favicons/favicon.ico deleted file mode 100644 index 72d6d00..0000000 Binary files a/sources/esviji/favicons/favicon.ico and /dev/null differ diff --git a/sources/esviji/favicons/firefoxos-icon-128.png b/sources/esviji/favicons/firefoxos-icon-128.png deleted file mode 100644 index 7c2c414..0000000 Binary files a/sources/esviji/favicons/firefoxos-icon-128.png and /dev/null differ diff --git a/sources/esviji/favicons/firefoxos-icon-512.png b/sources/esviji/favicons/firefoxos-icon-512.png deleted file mode 100644 index d9a7da3..0000000 Binary files a/sources/esviji/favicons/firefoxos-icon-512.png and /dev/null differ diff --git a/sources/esviji/favicons/firefoxos-icon-60.png b/sources/esviji/favicons/firefoxos-icon-60.png deleted file mode 100644 index d3fb6bc..0000000 Binary files a/sources/esviji/favicons/firefoxos-icon-60.png and /dev/null differ diff --git a/sources/esviji/favicons/mstile-144x144.png b/sources/esviji/favicons/mstile-144x144.png deleted file mode 100644 index 0d215c1..0000000 Binary files a/sources/esviji/favicons/mstile-144x144.png and /dev/null differ diff --git a/sources/esviji/favicons/mstile-150x150.png b/sources/esviji/favicons/mstile-150x150.png deleted file mode 100644 index 066399b..0000000 Binary files a/sources/esviji/favicons/mstile-150x150.png and /dev/null differ diff --git a/sources/esviji/favicons/mstile-310x150.png b/sources/esviji/favicons/mstile-310x150.png deleted file mode 100644 index 1731f3f..0000000 Binary files a/sources/esviji/favicons/mstile-310x150.png and /dev/null differ diff --git a/sources/esviji/favicons/mstile-310x310.png b/sources/esviji/favicons/mstile-310x310.png deleted file mode 100644 index 732e409..0000000 Binary files a/sources/esviji/favicons/mstile-310x310.png and /dev/null differ diff --git a/sources/esviji/favicons/mstile-70x70.png b/sources/esviji/favicons/mstile-70x70.png deleted file mode 100644 index a37faba..0000000 Binary files a/sources/esviji/favicons/mstile-70x70.png and /dev/null differ diff --git a/sources/esviji/index.html b/sources/esviji/index.html deleted file mode 100644 index 7acafe3..0000000 --- a/sources/esviji/index.html +++ /dev/null @@ -1,487 +0,0 @@ - - - - -esviji - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

esviji

-

%DESCRIPTION%

-

-
- - - - - - 1 - - - - 2 - - - - 3 - - - - 4 - - - - 5 - - - - 6 - - - - - - - - - - - - esviji - score : - - niveau : - - vies : - - - - - - - - - - - - - esviji - score : - 0 - 9 - niveau : - 1 - vies : - 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ce sont les balles que - vous devez détruire - pour finir la manche. - - - - - - - - C'est la balle que vous - pouvez déplacer de haut - en bas puis relâcher pour - détruire les autres. - - - - - - Vous pouvez utiliser - votre souris, doigt ou - clavier pour déplacer - la balle. - - - - - - La balle part alors à - droite jusqu'à ce qu'elle - rencontre une balle, - un rocher ou un mur. - - - - - - Des balles identiques doivent - se rencontrer pour se détruire - Plus vous touchez de balles, - plus votre score augmente. - - - - - - La balle se transforme - en la prochaine balle - rencontrée, devenant - une balle à détruire. - - - - - - Les balles qui ont - des trous sous - elles, tombent. - - - - - - Le score est augmenté - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pause - - - - Continuer - - - - - Recommencer - - - Son est : - - - - - - Vibration est : - - - - - - - - Sortie - - - - - - C'est perdu ! - - - - Records - - - - Jouer encore - - - - Sortie - - - - - Records - - Difficulté : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Sortie - - - - - Paramètres - - Son activé : - - - - - - Vibration activé : - - - - - - - - Aide - - - - Installation - - - - - Sortie - - - - - Difficulté - - - - Débutant - - - - - Facile - - - - - Difficile - - - - - Extrême - - - - - Sortie - - - - - - - - - - - - - - - - - - - - - - - esviji - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1992-2014 Nicolas Hoizey - esviji.com - - - - - - - - - - - - - - - - - diff --git a/sources/esviji/js/esviji.js b/sources/esviji/js/esviji.js deleted file mode 100644 index 6886ebe..0000000 --- a/sources/esviji/js/esviji.js +++ /dev/null @@ -1,1441 +0,0 @@ -// ## Create the main object - -var ESVIJI = {}; - -// ## Add default settings - -ESVIJI.settings = { - version: '%VERSION%', - // board size and according ball extreme positions - board: { - width: 320, - height: 460, - xMax: 10, - yMax: 13 - }, - // list of available ball "names" - balls: ['ball1', 'ball2', 'ball3', 'ball4', 'ball5', 'ball6'], - // list of available rock "names" (only one for now) - rocks: ['rock'], - // special ids for the game matrix - emptyId: 0, - rockId: -1, - // game info at launch time - launch: { - lives: 9, - score: 0, - level: 0 - }, - // game difficulty levels - difficulties: { - Beginner: { - rows: function rows(level) { - return 3; - }, - columns: function columns(level) { - return 3; - }, - balls: function balls(level) { - return Math.max(2, Math.min(3, 2 + Math.floor((level - 1) / 3))); - }, - rocks: function rocks(level) { - return 0; - }, - points: function points(nbHits) { - return nbHits; - }, - extraLifePoints: 100, - extraLifeLevel: 0 - }, - Easy: { - rows: function rows(level) { - return Math.max(3, Math.min(6, 3 + Math.floor((level - 1) / 3))); - }, - columns: function columns(level) { - return Math.max(3, Math.min(6, 3 + Math.floor((level - 1) / 3))); - }, - balls: function balls(level) { - return Math.max(2, Math.min(5, 2 + Math.floor((level - 1) / 2))); - }, - rocks: function rocks(level) { - return Math.min(5, Math.floor((level - 1) / 5)); - }, - points: function points(nbHits) { - return Math.pow(nbHits, 2); - }, - extraLifePoints: 100, - extraLifeLevel: 1 - }, - Hard: { - rows: function rows(level) { - return Math.max(5, Math.min(7, 5 + Math.floor((level - 1) / 3))); - }, - columns: function columns(level) { - return Math.max(5, Math.min(6, 5 + Math.floor((level - 1) / 3))); - }, - balls: function balls(level) { - return Math.max(4, Math.min(6, 4 + Math.floor((level - 1) / 2))); - }, - rocks: function rocks(level) { - return Math.min(10, Math.floor((level - 1) / 4)); - }, - points: function points(nbHits) { - return Math.pow(nbHits, 3); - }, - extraLifePoints: 100, - extraLifeLevel: 1 - }, - Crazy: { - rows: function rows(level) { - return Math.min(7, 2 + level); - }, - columns: function columns(level) { - return Math.min(7, 2 + level); - }, - balls: function balls(level) { - return Math.min(6, 1 + level); - }, - rocks: function rocks(level) { - return Math.max(0, Math.min(20, level - 6)); - }, - points: function points(nbHits) { - return Math.pow(nbHits, 4); - }, - extraLifePoints: 100, - extraLifeLevel: 0 - } - }, - // game info at new turn start - turn: { - posX: 10, - dirX: -1, - posY: 8, - dirY: 0 - }, - // animation settings - durationMove: 0.15, - durationMorph: 0.5 -}; - -// ## Add the game engine -ESVIJI.game = (function () { - // Initial values - var - viewportWidth = 0, - viewportHeight = 0, - boardWidth, - boardHeight, - boardOffsetY, - drawnCurrentBalls = [], - validBalls = [], - drawnCurrentBall = null, - stackedAnimationToStart = 1, - lastStackedAnimation = 0, - currentPosX = 0, - currentPosY = 0, - currentDirX = -1, - currentDirY = 0, - dragged = false, - moveCount = 0, - cursorY = 0, - cursorMinY = 0, - cursorMaxY = 0, - maxAvailableBalls = 0, - nbBalls = 0, - scoreThisTurn = 0, - lastHitBall = ESVIJI.settings.rockId, - highScores = [ ], - lastGameDate = '', - gameStatus = { }, - useStored = false, - sounds, - clickType = 'click'; - - // Initialization - function init() { - if (Modernizr.inlinesvg) { - $('#description').hide(); - } else { - // Add this message using JS to prevent indexing it in search engines - $('#description p.icon').before('

Your browser doesn\'t seem to support inline SVG. Learn about this game on esviji.com.

'); - $('svg').hide(); - return; - } - if (Modernizr.touch) { - // TODO: Should not be necessary, devices can have both mouse and touch - clickType = 'touchstart'; - } - if (!Modernizr.testProp('vibrate')) { - $('.prefsVibration,.label.vibration').hide(); - } - - if (!ESVIJI.settings.version.match(/VERSION/)) { - if ($('.version') === ESVIJI.settings.version) { - // Send version to Google Analitycs only if it is set in the source - offlineAnalytics.push({name: 'version', value: ESVIJI.settings.version }); - } - } - - if (!store.disabled) { - highScores = store.get('highScores') || [ ]; - gameStatus = store.get('gameStatus') || { - currentBalls: [], - currentBall: 0, - level: 0, - score: 0, - lives: 0, - playing: false, - levelReplay: { - lostLives: 0, - level: 0, - balls: [], - sequence: [] - }, - preferences: { - sound: true, - vibration: true, - difficulty: 'Beginner' - } - }; - } - - viewportOptimize(); - cursorMinY = yToSvg(1); - cursorMaxY = yToSvg(ESVIJI.settings.board.yMax); - maxAvailableBalls = ESVIJI.settings.balls.length; - - // Deal with localStore content that has been set when there was less data - if (undefined === gameStatus.levelReplay) { - // v1.6.7 - gameStatus.levelReplay = { - 'lostLives': 0, - 'level': 0, - 'balls': [], - 'sequence': [] - }; - } - if (undefined === gameStatus.preferences) { - // v1.6.8 - gameStatus.preferences = { - 'sound': true - }; - } - if (undefined === gameStatus.preferences.difficulty) { - // v1.8.0 - gameStatus.preferences.difficulty = 'Beginner'; - } - if (highScores.length === 0 || (highScores.length > 0 && undefined === highScores.Beginner)) { - // v1.8.1 - oldHighScores = highScores; - highScores = { - Beginner: [], - Easy: [], - Hard: oldHighScores, - Crazy: [] - }; - storeSet('highScores', highScores); - } - if (undefined === gameStatus.preferences.vibration) { - // v1.13.0 - gameStatus.preferences.vibration = true; - } - - // Available sounds - sounds = new Howl({ - "urls": ["sounds/sprite.ogg", "sounds/sprite.mp3"], - "sprite": { - "fall": [0, 204.05895691609976], - "hit-floor": [2000, 2000], - "hit-other-ball-ko": [5000, 468.7528344671206], - "hit-other-ball-ok": [7000, 500], - "hit-same-ball": [9000, 1000], - "hit-wall": [11000, 1835.941043083901], - "level": [14000, 2947.0068027210878], - "life-down": [18000, 1000], - "life-up": [20000, 1000], - "throw": [22000, 797.1201814058943] - }, - buffer: true - }); - - run(); - } - - function storeSet(item, value) { - if (!store.disabled) { - store.set(item, value); - } - } - - function viewportOptimize() { - if (viewportWidth != document.body.clientWidth || viewportHeight != document.body.clientHeight) { - viewportWidth = document.body.clientWidth; - viewportHeight = document.body.clientHeight; - if (viewportHeight / viewportWidth > ESVIJI.settings.board.height / ESVIJI.settings.board.width) { - // tall - boardWidth = viewportWidth; - boardHeight = ESVIJI.settings.board.height / ESVIJI.settings.board.width * boardWidth; - boardOffsetY = viewportHeight - boardHeight; // top empty area height - } else { - // large - boardHeight = viewportHeight; - boardWidth = ESVIJI.settings.board.width / ESVIJI.settings.board.height * boardHeight; - boardOffsetY = 0; - } - } - } - - function run() { - if (typeof gameStatus.playing === 'undefined' || gameStatus.playing === false) { - showPanel('main'); - startMain(); - } else { - useStored = true; - startPlaying(); - } - } - - function startMain(difficulty) { - $('#pulse')[0].beginElement(); - $('#main .start').one(clickType, startDifficulty); - $('#main .scores').one(clickType, startScores); - $('#main .settings').one(clickType, startSettings); - } - - function startDifficulty() { - hidePanel('main'); - showPanel('difficulty'); - $('#difficulty .beginner').one(clickType, function (event) { - event.preventDefault(); - gameStatus.preferences.difficulty = 'Beginner'; - hidePanel('difficulty'); - startPlaying(); - }); - $('#difficulty .easy').one(clickType, function (event) { - event.preventDefault(); - gameStatus.preferences.difficulty = 'Easy'; - hidePanel('difficulty'); - startPlaying(); - }); - $('#difficulty .hard').one(clickType, function (event) { - event.preventDefault(); - gameStatus.preferences.difficulty = 'Hard'; - hidePanel('difficulty'); - startPlaying(); - }); - $('#difficulty .crazy').one(clickType, function (event) { - event.preventDefault(); - gameStatus.preferences.difficulty = 'Crazy'; - hidePanel('difficulty'); - startPlaying(); - }); - $('#difficulty .exit').one(clickType, endDifficulty); - } - - function endDifficulty(event) { - event.preventDefault(); - hidePanel('difficulty'); - showPanel('main'); - startMain(); - } - - function startPlaying(event) { - if (undefined !== event) { - event.preventDefault(); - } - if (!useStored) { - gameStatus.level = ESVIJI.settings.launch.level; - gameStatus.score = ESVIJI.settings.launch.score; - gameStatus.lives = ESVIJI.settings.launch.lives; - hidePanel('play'); - if (null !== drawnCurrentBall) { - drawnCurrentBall.remove(); - } - drawnCurrentBall = null; - } - showPanel('play'); - drawLevel(); - drawScore(); - drawLives(); - $('#play .pauseButton').one(clickType, startPause); - nextLevel(); - } - - function stopPlaying() { - gameStatus.playing = false; - gameStatus.level = 0; - gameStatus.score = 0; - gameStatus.lives = 0; - eraseBalls(); - if (null !== drawnCurrentBall) { - drawnCurrentBall.remove(); - } - hidePanel('play'); - storeSet('gameStatus', { - 'playing': false - }); - run(); - } - - function startTutorial() { - hidePanel('settings'); - showPanel('tutorial'); - $('#tutorial .pauseButton').one(clickType, endTutorial); - $('#tutoAnimEnd')[0].addEventListener('endEvent', endTutorial, false); - $('#tutoAnimStart')[0].beginElement(); - } - - function endTutorial(event) { - event.preventDefault(); - hidePanel('tutorial'); - showPanel('settings'); - startSettings(); - } - - function startScores() { - var difficulty = gameStatus.preferences.difficulty; - - hidePanel('main'); - showPanel('scores'); - - $('#scores .difficulty text').text(difficulty); - $('#scores .difficulty').bind(clickType, function() { - var nextDifficulty = { - Beginner: 'Easy', - Easy: 'Hard', - Hard: 'Crazy', - Crazy: 'Beginner' - }, - difficulty = nextDifficulty[$(this).find('text').text()]; - - $('#scores .difficulty text').text(difficulty); - writeScores(difficulty); - }); - - writeScores(difficulty); - - $('#scores .exit').one(clickType, endScores); - } - - function writeScores(difficulty) { - for (i = 0; i < 10; i++) { - if (undefined !== highScores[difficulty][i]) { - $('#scores .highscores text').eq(i).text(highScores[difficulty][i].score); - if (difficulty === gameStatus.preferences.difficulty && lastGameDate === highScores[difficulty][i].date) { - $('#scores .highscores text').eq(i).attr('class', 'thisone'); - } - } else { - $('#scores .highscores text').eq(i).text('-').attr('class', ''); - } - } - } - - function endScores(event) { - event.preventDefault(); - hidePanel('scores'); - showPanel('main'); - startMain(); - } - - function startSettings() { - hidePanel('main'); - showPanel('settings'); - - $('#settings .prefsSound text').text(gameStatus.preferences.sound ? 'On' : 'Off'); - $('#settings .prefsSound').bind(clickType, function() { - gameStatus.preferences.sound = !gameStatus.preferences.sound; - storeSet('gameStatus', gameStatus); - $('#settings .prefsSound text').text(gameStatus.preferences.sound ? 'On' : 'Off'); - }); - - $('#settings .prefsVibration text').text(gameStatus.preferences.vibration ? 'On' : 'Off'); - $('#settings .prefsVibration').bind(clickType, function() { - gameStatus.preferences.vibration = !gameStatus.preferences.vibration; - storeSet('gameStatus', gameStatus); - $('#settings .prefsVibration text').text(gameStatus.preferences.vibration ? 'On' : 'Off'); - }); - - $('#settings .tutorial').one(clickType, startTutorial); - - $('#settings .exit').one(clickType, endSettings); - - showInstall(); - } - - function endSettings(event) { - event.preventDefault(); - hidePanel('settings'); - showPanel('main'); - startMain(); - } - - function startPause() { - showPanel('pause'); - $('#pause .resume').one(clickType, function(e) { - e.preventDefault(); - hidePanel('pause'); - $('#play .pauseButton').one(clickType, startPause); - }); - - $('#pause .restart').one(clickType, function(e) { - e.preventDefault(); - hidePanel('pause'); - storeSet('gameStatus', { - 'playing': false - }); - startPlaying(); - }); - - $('#pause .prefsSound text').text(gameStatus.preferences.sound ? 'On' : 'Off'); - $('#pause .prefsSound').bind(clickType, function() { - gameStatus.preferences.sound = !gameStatus.preferences.sound; - storeSet('gameStatus', gameStatus); - $('#pause .prefsSound text').text(gameStatus.preferences.sound ? 'On' : 'Off'); - }); - - $('#pause .prefsVibration text').text(gameStatus.preferences.vibration ? 'On' : 'Off'); - $('#pause .prefsVibration').bind(clickType, function() { - gameStatus.preferences.vibration = !gameStatus.preferences.vibration; - storeSet('gameStatus', gameStatus); - $('#pause .prefsVibration text').text(gameStatus.preferences.vibration ? 'On' : 'Off'); - }); - - $('#pause .exit').one(clickType, function(e) { - e.preventDefault(); - hidePanel('pause'); - stopPlaying(); - }); - } - - // There is no z-index in SVG, so we need to "create" panel we want on top of all others - function showPanel(panel) { - if ( $('#' + panel).length === 0 && $('#' + panel + 'Panel').length === 1) { - $('#' + panel + 'Panel').clone().attr('id', panel).appendTo('#board'); - $('#' + panel + 'Panel').remove(); - if (panel === 'pause' || panel === 'gameOver') { - $('#play').css('opacity', 0.3); - } - // Google Analytics tracking of activated panel - offlineAnalytics.push({ name: 'view', value: '/' + (panel === 'main' ? '' : panel + '/') }); - } - } - - function hidePanel(panel) { - if ($('#' + panel).length === 1 && $('#' + panel + 'Panel').length === 0) { - $('#' + panel).clone().attr('id', panel + 'Panel').appendTo('#board defs'); - $('#' + panel).remove(); - if (panel === 'pause' || panel === 'gameOver') { - $('#play').css('opacity', 1); - } - } - } - - function nextLevel() { - gameStatus.playing = true; - eraseBalls(); - if (useStored) { - drawBalls(); - } else { - gameStatus.level++; - drawLevel(); - $('#play .level').attr('class', 'level changeUp'); - window.setTimeout(function() { $('#play .level').attr('class', 'level'); }, 2000); - initBalls(); - drawBalls(); - getValidBalls(); - gameStatus.currentBall = validBalls[Math.floor(Math.random() * validBalls.length)]; - } - - // TODO: remove "null" values from gameStatus.currentBalls - gameStatus.levelReplay = { - 'lostLives': 0, - 'level': gameStatus.level, - 'balls': gameStatus.currentBalls.map(function(a) { return a === null ? null : a.slice(); }), // clone the array (https://twitter.com/naholyr/status/311112698421198848) - 'sequence': [] - }; - - playSound('level'); - startNewTurn(); - } - - function startNewTurn() { - currentPosX = ESVIJI.settings.turn.posX; - currentDirX = ESVIJI.settings.turn.dirX; - currentPosY = ESVIJI.settings.turn.posY; - currentDirY = ESVIJI.settings.turn.dirY; - scoreThisTurn = 0; - lastHitBall = ESVIJI.settings.rockId; - getValidBalls(); - - stackedAnimationToStart = 1; - lastStackedAnimation = 0; - - if (validBalls.length === 0) { - // no more valid ball, end of the turn - if (null !== drawnCurrentBall) { - drawnCurrentBall.remove(); // TODO: animate - drawnCurrentBall = null; - } - - if (ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].extraLifeLevel > 0) { - gameStatus.lives += ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].extraLifeLevel; - drawLives(); - $('#play .lives').attr('class', 'lives changeUp'); - window.setTimeout(function() { $('#play .lives').attr('class', 'lives'); }, 2000); - } - - // Push to the server levels completed without any lost life - if (gameStatus.levelReplay.lostLives === 0) { - // TODO - // call the API - //console.log(JSON.stringify(gameStatus.levelReplay)); - } - - makeEverythingFall(); - } else { - if (validBalls.indexOf(gameStatus.currentBall) == -1) { - var notPlayableAnimMain = svgAnimate({ - "attributeName": "opacity", - "from": "0", - "to": "1", - "begin": "indefinite", - "dur": "0.5s", - "repeatCount": "4", - "fill": "freeze", - "id": "notPlayableAnim" - }); - notPlayableAnimMain.addEventListener('beginEvent', function () { playSound('error'); }, false); - notPlayableAnimMain.addEventListener('endEvent', notPlayable, false); - if (null !== drawnCurrentBall) { - drawnCurrentBall.append(notPlayableAnimMain); - } - $('[data-valid=true]').each(function() { - that = $(this); - var notPlayableAnim = svgAnimate({ - "attributeName": "opacity", - "from": "0", - "to": "1", - "begin": "notPlayableAnim.begin", - "dur": "0.5s", - "repeatCount": "4", - "fill": "freeze" - }); - that.append(notPlayableAnim); - }); - notPlayableAnimMain.beginElement(); - } else { - storeSet('gameStatus', gameStatus); - useStored = false; - if (gameStatus.playing) { - if (null !== drawnCurrentBall && undefined !== drawnCurrentBall) { - drawnCurrentBall.remove(); - } - drawnCurrentBall = drawBall(xToSvg(currentPosX), yToSvg(currentPosY), ESVIJI.settings.balls[gameStatus.currentBall - 1], 'playable'); - $('#play .playzone').on('mousedown touchstart', cursorStart); - $('#play .playzone').on('mousemove touchmove', cursorMove); - $('#play .playzone').on('mouseup touchend', cursorEnd); - $('#play .playzone').on('touchcancel', startNewTurn); - Mousetrap.bind('up', keyUp); - Mousetrap.bind('down', keyDown); - Mousetrap.bind(['enter', 'space'], keyEnter); - Mousetrap.bind('esc', function() { console.log('esc'); startNewTurn(); }); - } - } - } - } - - function notPlayable() { - if (null !== drawnCurrentBall) { - drawnCurrentBall.remove(); - } - drawnCurrentBall = null; - removeLife(); - gameStatus.currentBall = validBalls[Math.floor(Math.random() * validBalls.length)]; - startNewTurn(); - } - - function keyUp(event) { - cursorY = Math.min(Math.max(yToSvg(currentPosY + 1), cursorMaxY), cursorMinY); - currentPosY = svgToY(cursorY); - drawnCurrentBall.attr({ - y: cursorY - }); - } - - function keyDown(event) { - cursorY = Math.min(Math.max(yToSvg(currentPosY - 1), cursorMaxY), cursorMinY); - currentPosY = svgToY(cursorY); - drawnCurrentBall.attr({ - y: cursorY - }); - } - - function keyEnter(event) { - Mousetrap.unbind('up'); - Mousetrap.unbind('down'); - Mousetrap.unbind(['enter', 'space']); - $('#play .playzone').off('mousedown touchstart'); - $('#play .playzone').off('mousemove touchmove'); - $('#play .playzone').off('mouseup touchend'); - drawnCurrentBall.attr({ - 'class': '' - }); - moveCount = 0; - oldPosX = currentPosX; - oldPosY = currentPosY; - - cursorY = yToSvg(currentPosY); - drawnCurrentBall.attr({ - y: cursorY - }); - currentPosY = svgToY(cursorY); - - gameStatus.levelReplay.sequence.push({ - 'ball': gameStatus.currentBall, - 'position': currentPosY - }); - - playSound('throw'); - playUserChoice(); - } - - function cursorStart(event) { - event.preventDefault(); - dragged = true; - if (event.originalEvent.touches && event.originalEvent.touches.length) { - event = event.originalEvent.touches[0]; - } else if (event.originalEvent.changedTouches && event.originalEvent.changedTouches.length) { - event = event.originalEvent.changedTouches[0]; - } - cursorY = Math.min(Math.max(pixelsToSvgY(event.pageY) - 16, cursorMaxY), cursorMinY); - drawnCurrentBall.attr({ - y: cursorY - }); - } - - function cursorMove(event) { - event.preventDefault(); - if (event.originalEvent.touches && event.originalEvent.touches.length) { - event = event.originalEvent.touches[0]; - } else if (event.originalEvent.changedTouches && event.originalEvent.changedTouches.length) { - event = event.originalEvent.changedTouches[0]; - } - // event.pageY seems to be returning weird values when movement starts - cursorY = Math.min(Math.max(pixelsToSvgY(event.pageY) - 16, cursorMaxY), cursorMinY); - currentPosY = svgToY(cursorY); - drawnCurrentBall.attr({ - y: cursorY - }); - } - - function cursorEnd(event) { - event.preventDefault(); - if (dragged) { - if (event.originalEvent.touches && event.originalEvent.touches.length) { - event = event.originalEvent.touches[0]; - } else if (event.originalEvent.changedTouches && event.originalEvent.changedTouches.length) { - event = event.originalEvent.changedTouches[0]; - } - dragged = false; - Mousetrap.unbind('up'); - Mousetrap.unbind('down'); - Mousetrap.unbind(['enter', 'space']); - $('#play .playzone').off('mousedown touchstart'); - $('#play .playzone').off('mousemove touchmove'); - $('#play .playzone').off('mouseup touchend'); - cursorY = Math.min(Math.max(pixelsToSvgY(event.pageY) - 16, cursorMaxY), cursorMinY); - currentPosY = svgToY(cursorY); - drawnCurrentBall.attr({ - y: yToSvg(currentPosY) - }); - moveCount = 0; - oldPosX = currentPosX; - oldPosY = currentPosY; - - gameStatus.levelReplay.sequence.push({ - 'ball': gameStatus.currentBall, - 'position': currentPosY - }); - - playSound('throw'); - playUserChoice(); - } - } - - function playUserChoice() { - moveCount++; - if (currentPosY == 1 && currentDirY == -1) { - // Against the floor, no more possible move - if (oldPosY != 1) { - animStackMove(drawnCurrentBall, (oldPosY - currentPosY) * ESVIJI.settings.durationMove, 'y', yToSvg(oldPosY), yToSvg(currentPosY)); - } - $('#anim' + lastStackedAnimation)[0].addEventListener('beginEvent', function(event) { - playSound('hit-floor'); - }); - endOfMove(); - } else { - if (currentPosX == 1 && currentDirX == -1) { - // Against the left wall, should now go down - currentDirX = 0; - currentDirY = -1; - animStackMove(drawnCurrentBall, (oldPosX - currentPosX) * ESVIJI.settings.durationMove, 'x', xToSvg(oldPosX), xToSvg(currentPosX)); - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - playSound('hit-wall'); - }, false); - oldPosX = currentPosX; - playUserChoice(); - } else { - // Neither floor nor wall, so what is it? - nextBall = gameStatus.currentBalls[currentPosX + currentDirX][currentPosY + currentDirY]; - switch (nextBall) { - case ESVIJI.settings.rockId: - // A rock... - if (currentDirX == -1) { - // ...at our left, should now go down - currentDirX = 0; - currentDirY = -1; - animStackMove(drawnCurrentBall, (oldPosX - currentPosX) * ESVIJI.settings.durationMove, 'x', xToSvg(oldPosX), xToSvg(currentPosX)); - oldPosX = currentPosX; - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - playSound('hit-wall'); - }, false); - playUserChoice(); - } else { - // ...under us, no more possible move - if (oldPosY != currentPosY) { - animStackMove(drawnCurrentBall, (oldPosY - currentPosY) * ESVIJI.settings.durationMove, 'y', yToSvg(oldPosY), yToSvg(currentPosY)); - } - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - playSound('hit-floor'); - }, false); - endOfMove(); - } - break; - case ESVIJI.settings.emptyId: - // Nothing can stop us - currentPosX += currentDirX; - currentPosY += currentDirY; - playUserChoice(); - break; - case gameStatus.currentBall: - // Same ball, let's destroy it! - currentPosXBefore = currentPosX; - currentPosYBefore = currentPosY; - currentPosX += currentDirX; - currentPosY += currentDirY; - gameStatus.currentBalls[currentPosX][currentPosY] = ESVIJI.settings.emptyId; - if (currentPosXBefore != oldPosX) { - animStackMove(drawnCurrentBall, (oldPosX - currentPosXBefore) * ESVIJI.settings.durationMove, 'x', xToSvg(oldPosX), xToSvg(currentPosXBefore)); - oldPosX = currentPosXBefore; - } else if (currentPosYBefore != oldPosY) { - animStackMove(drawnCurrentBall, (oldPosY - currentPosYBefore) * ESVIJI.settings.durationMove, 'y', yToSvg(oldPosY), yToSvg(currentPosYBefore)); - oldPosY = currentPosYBefore; - } - animStackDestroy(drawnCurrentBalls[currentPosX][currentPosY]); - scoreThisTurn++; - playSound('hit-same-ball'); - playUserChoice(); - break; - default: - lastHitBall = nextBall; - if (currentPosX != oldPosX) { - animStackMove(drawnCurrentBall, (oldPosX - currentPosX) * ESVIJI.settings.durationMove, 'x', xToSvg(oldPosX), xToSvg(currentPosX)); - } else if (currentPosY != oldPosY) { - animStackMove(drawnCurrentBall, (oldPosY - currentPosY) * ESVIJI.settings.durationMove, 'y', yToSvg(oldPosY), yToSvg(currentPosY)); - } - if (scoreThisTurn > 0) { - gameStatus.currentBall = nextBall; - if (currentPosX != oldPosX) { - animStackMorph(drawnCurrentBall, nextBall, xToSvg(currentPosX), yToSvg(currentPosY), 'x', xToSvg(currentPosX), xToSvg(currentPosX + currentDirX)); - } else { - animStackMorph(drawnCurrentBall, nextBall, xToSvg(currentPosX), yToSvg(currentPosY), 'y', yToSvg(currentPosY), yToSvg(currentPosY + currentDirY)); - } - } - endOfMove(); - } - } - } - } - - function endOfTurn() { - if (scoreThisTurn === 0) { - if (lastHitBall != ESVIJI.settings.rockId) { - removeLife(); - } - } else { - addScore(scoreThisTurn); - } - stackedAnimationToStart = lastStackedAnimation + 1; - startNewTurn(); - } - - function svgAnimate(settings, type) { - var anim = document.createElementNS("http://www.w3.org/2000/svg", type || "animate"); - anim.setAttributeNS(null, "attributeType", "xml"); - for (var key in settings) { - anim.setAttributeNS(null, key, settings[key]); - } - return anim; - } - - function svgAnimateTransform(settings) { - return svgAnimate(settings, 'animateTransform'); - } - - function animStackMove(ball, duration, attribute, from, to, begin) { - if (begin === undefined) { - if (lastStackedAnimation === (stackedAnimationToStart - 1)) { - begin = 'indefinite'; - } else { - begin = 'anim' + lastStackedAnimation + '.end'; - } - } - - lastStackedAnimation++; - - anim = svgAnimate({ - "attributeName": attribute, - "from": from, - "to": to, - "begin": begin, - "dur": duration + "s", - "fill": "freeze", - "id": "anim" + lastStackedAnimation - }); - anim.attribute = attribute; - anim.attributeTo = to; - anim.addEventListener('endEvent', function (event) { - // Set new attribute value at the end of the animation - $(event.currentTarget.parentElement).attr(event.currentTarget.attribute, event.currentTarget.attributeTo); - // Remove the animation - $(event.currentTarget).remove(); - }, false); - ball.append(anim); - } - - function animStackMorph(ballFrom, ballToId, x, y, attribute, from, to) { - var ballTo = svgUse("ball" + ballToId, "morph"); - ballTo.attr({ - x: x, - y: y, - opacity: 0 - }); - $("#play").append(ballTo); - - // opacity from - animOpacityFrom = svgAnimate({ - "attributeName": "opacity", - "to": "0", - "begin": "anim" + lastStackedAnimation + ".end", - "dur": ESVIJI.settings.durationMorph + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 1) - }); - ballFrom.append(animOpacityFrom); - - // move - animMoveFrom = svgAnimate({ - "attributeName": attribute, - "from": from, - "to": to, - "begin": "anim" + lastStackedAnimation + ".end", - "dur": ESVIJI.settings.durationMorph + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 2) - }); - ballFrom.append(animMoveFrom); - - // opacity to - animOpacityTo = svgAnimate({ - "attributeName": "opacity", - "to": "1", - "begin": "anim" + lastStackedAnimation + ".end", - "dur": ESVIJI.settings.durationMorph + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 3) - }); - ballTo.append(animOpacityTo); - - // move - animMoveTo = svgAnimate({ - "attributeName": attribute, - "from": from, - "to": to, - "begin": "anim" + lastStackedAnimation + ".end", - "dur": ESVIJI.settings.durationMorph + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 4) - }); - animMoveTo.addEventListener('beginEvent', function(event) { - playSound('hit-other-ball-ok'); - }, false); - ballTo.append(animMoveTo); - - lastStackedAnimation += 4; - } - - function animStackDestroy(ball, begin) { - begin = begin || ((lastStackedAnimation === 0) ? "indefinite" : ("anim" + lastStackedAnimation + ".end")); - - // rotate - var centerX = parseInt(ball.attr('x'), 10) + 16, - centerY = parseInt(ball.attr('y'), 10) + 16, - animRotate = svgAnimateTransform({ - "attributeName": "transform", - "type": "rotate", - "from": "0 " + centerX + " " + centerY, - "to": "360 " + centerX + " " + centerY, - "begin": begin, - "dur": ESVIJI.settings.durationMove * 2 + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 1) - }); - animRotate.addEventListener('beginEvent', function(event) { - playSound('hit-same-ball'); - }, false); - ball.append(animRotate); - - // opacity - var animOpacity = svgAnimate({ - "attributeName": "opacity", - "to": "0", - "begin": "anim" + (lastStackedAnimation + 1) + ".begin", - "dur": ESVIJI.settings.durationMove * 2 + "s", - "fill": "freeze", - "id": "anim" + (lastStackedAnimation + 2) - }); - animOpacity.addEventListener('endEvent', function(event) { - // Remove the ball after the animation - $(event.currentTarget.parentElement).remove(); - }, false); - ball.append(animOpacity); - - lastStackedAnimation += 2; - } - - function endOfMove() { - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - drawnCurrentBall.remove(); - $('#morph').remove(); - if (scoreThisTurn === 0) { - playSound('hit-other-ball-ko'); - } - drawnCurrentBall = drawBall(xToSvg(ESVIJI.settings.turn.posX), yToSvg(ESVIJI.settings.turn.posY), ESVIJI.settings.balls[gameStatus.currentBall - 1], 'playable'); - }); - - makeBallsFall(); - } - - function makeBallsFall() { - var aboveBalls; - - lastStackedAnimationBeforeFall = lastStackedAnimation; - for (var x = 1; x <= 7; x++) { - aboveBalls = 0; - for (var y = 1; y <= 6; y++) { - // No need to check if there is a hole in the top line, no ball upper to make fall - if (gameStatus.currentBalls[x][y] === ESVIJI.settings.emptyId) { - // There's a hole, let's see if there are balls above - for (var z = y + 1; z <= 7; z++) { - switch (gameStatus.currentBalls[x][z]) { - case ESVIJI.settings.rockId: - // It's a rock, we can bypass it - y = z; - z = 8; - break; - case ESVIJI.settings.emptyId: - // It's empty - if (z === 7) { - // Only empty places, no need to test further this column - y = 7; - } - break; - default: - // Neither rock nor empty, so there's a ball - aboveBalls++; - gameStatus.currentBalls[x][y] = gameStatus.currentBalls[x][z]; - drawnCurrentBalls[x][y] = drawnCurrentBalls[x][z]; - for (var a = y + 1; a <= z; a++) { - gameStatus.currentBalls[x][a] = ESVIJI.settings.emptyId; - drawnCurrentBalls[x][a] = null; - } - dur = ESVIJI.settings.durationMove * (z - y); - // Follow through and overlapping action: http://uxdesign.smashingmagazine.com/2012/10/30/motion-animation-new-mobile-ux-design-material/ - dur = dur * (1 + aboveBalls / 3); - // TODO: add an easing to the fall animation - animStackMove(drawnCurrentBalls[x][y], dur, 'y', yToSvg(z), yToSvg(y), 'anim' + lastStackedAnimationBeforeFall + '.end'); - // TODO: make the sound later as for piles of falling balls - $('#anim' + lastStackedAnimation)[0].addEventListener('beginEvent', function(event) { - playSound('fall'); - }); - // Let's try again to see if there are new balls above that have to fall - y = 1; - z = 8; - } - } - } - } - } - - if (lastStackedAnimation >= stackedAnimationToStart) { - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - endOfTurn(); - }, false); - // Launch the animation - $('#anim' + stackedAnimationToStart)[0].beginElement(); - } else { - endOfTurn(); - } - } - - function makeEverythingFall() { - var ballsUnder; - - stackedAnimationToStart = 1; - lastStackedAnimation = 0; - - for (x = 1; x <= 7; x++) { - ballsUnder = 0; - for (y = 1; y <= 7; y++) { - if (gameStatus.currentBalls[x][y] != ESVIJI.settings.emptyId) { - dur = ESVIJI.settings.durationMove * (1 + ballsUnder / 3); - if (lastStackedAnimation === 0) { - animStackMove(drawnCurrentBalls[x][y], dur * 7, 'y', yToSvg(y), yToSvg(y - 7)); - } else { - animStackMove(drawnCurrentBalls[x][y], dur * 7, 'y', yToSvg(y), yToSvg(y - 7), 'anim' + stackedAnimationToStart + '.begin'); - } - drawnCurrentBalls[x][y] = ESVIJI.settings.emptyId; - ballsUnder++; - } else { - ballsUnder = 0; - } - } - } - - if (lastStackedAnimation >= stackedAnimationToStart) { - $('#anim' + lastStackedAnimation)[0].addEventListener('endEvent', function(event) { - nextLevel(); - }, false); - $('#anim' + stackedAnimationToStart)[0].beginElement(); - } else { - nextLevel(); - } - } - - function initBalls(thisLevel) { - thisLevel = thisLevel || gameStatus.level; - nbBalls = ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].balls(thisLevel); - gameStatus.currentBalls = []; - - for (x = 1; x <= ESVIJI.settings.board.xMax; x++) { - gameStatus.currentBalls[x] = []; - for (y = 1; y <= ESVIJI.settings.board.yMax; y++) { - if (y - 7 > x) { - // put the "stair" rocks - gameStatus.currentBalls[x][y] = ESVIJI.settings.rockId; - } else { - if ((x <= ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].columns(thisLevel)) && (y <= ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].rows(thisLevel))) { - // a ball - gameStatus.currentBalls[x][y] = 1 + Math.floor(Math.random() * nbBalls); - } else { - // empty - gameStatus.currentBalls[x][y] = ESVIJI.settings.emptyId; - } - } - } - } - // add rocks - nbRocks = ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].rocks(thisLevel); - positionedRocks = 0; - while (positionedRocks < nbRocks) { - rock_x = 1 + Math.floor(Math.random() * ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].rows(thisLevel)); - rock_y = 1 + Math.floor(Math.random() * ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].columns(thisLevel)); - if (gameStatus.currentBalls[rock_x][rock_y] !== ESVIJI.settings.rockId) { - gameStatus.currentBalls[rock_x][rock_y] = ESVIJI.settings.rockId; - positionedRocks++; - } - } - } - - function drawBall(x, y, ballType, ballId) { - var ball = svgUse(ballType, ballId); - ball.attr({ - x: x, - y: y - }); - $("#play").append(ball); - return ball; - } - - function svgUse(refId, useId) { - var use = $(document.createElementNS("http://www.w3.org/2000/svg", "use")); - if (useId !== undefined) { - use.attr({ - id: useId - }); - } - use.get(0).setAttributeNS("http://www.w3.org/1999/xlink", "href", "#" + refId); - return use; - } - - function drawBalls() { - drawnCurrentBalls = []; - for (x = 1; x <= 7; x++) { - drawnCurrentBalls[x] = []; - for (y = 1; y <= 7; y++) { - if (gameStatus.currentBalls[x][y] == ESVIJI.settings.emptyId) { - drawnCurrentBalls[x][y] = null; - } else { - ball_x = xToSvg(x); - ball_y = yToSvg(y); - if (gameStatus.currentBalls[x][y] == ESVIJI.settings.rockId) { - rockId = 1 + Math.floor(Math.random() * ESVIJI.settings.rocks.length); - drawnCurrentBalls[x][y] = drawBall(ball_x, ball_y, ESVIJI.settings.rocks[rockId - 1]); - } else { - drawnCurrentBalls[x][y] = drawBall(ball_x, ball_y, ESVIJI.settings.balls[gameStatus.currentBalls[x][y] - 1]); - } - } - } - } - } - - function eraseBalls() { - $('#play use').remove(); - } - - function getValidBalls() { - var x, y, dir_x, dir_y, found; - - validBalls = []; - - for (y_start = 1; y_start <= 13; y_start++) { - x = 10; - y = y_start; - dir_x = -1; - dir_y = 0; - found = false; - while (!found) { - if (y == 1 && dir_y == -1) { - found = true; - } else { - if (x == 1 && dir_x == -1) { - dir_x = 0; - dir_y = -1; - } else { - nextBall = gameStatus.currentBalls[x + dir_x][y + dir_y]; - if (nextBall == ESVIJI.settings.rockId) { - if (dir_x == -1) { - dir_x = 0; - dir_y = -1; - } else { - found = true; - } - } else { - if (nextBall == ESVIJI.settings.emptyId) { - x += dir_x; - y += dir_y; - } else { - drawnCurrentBalls[x + dir_x][y + dir_y].attr('data-valid', 'true'); - if (validBalls.indexOf(nextBall) == -1) { - validBalls.push(nextBall); - } - found = true; - } - } - } - } - } - } - } - - function gameOver() { - var l = highScores[gameStatus.preferences.difficulty].length, - positioned = false; - - // Google Analytics tracking of level and score at the end of the game - offlineAnalytics.push({ name: 'level', value: gameStatus.level }); - offlineAnalytics.push({ name: 'score', value: gameStatus.score }); - - lastGameDate = Date(); - showPanel('gameOver'); - - $('#gameOver').find('.score').text('Score: ' + gameStatus.score); - for (i = 0; i < l; i++) { - if (!positioned && (highScores[gameStatus.preferences.difficulty][i] === undefined || highScores[gameStatus.preferences.difficulty][i].score <= gameStatus.score)) { - for (j = l; j > i; j--) { - highScores[gameStatus.preferences.difficulty][j] = highScores[gameStatus.preferences.difficulty][j - 1]; - } - highScores[gameStatus.preferences.difficulty][i] = { 'score': gameStatus.score, 'date': lastGameDate}; - positioned = true; - } - } - if (!positioned) { - highScores[gameStatus.preferences.difficulty][l] = { 'score': gameStatus.score, 'date': lastGameDate}; - } - storeSet('highScores', highScores); - gameStatus.playing = false; - storeSet('gameStatus', { - 'playing': false - }); - - // buttons - $('#gameOver .scores').one(clickType, function() { - hidePanel('gameOver'); - hidePanel('play'); - showPanel('main'); - startScores(); - }); - $('#gameOver .playagain').one(clickType, function() { - hidePanel('gameOver'); - startPlaying(); - }); - $('#gameOver .exit').one(clickType, function() { - hidePanel('gameOver'); - stopPlaying(); - }); - } - - function removeLife() { - gameStatus.lives--; - gameStatus.levelLostLives++; - playSound('life-down'); - vibrate(500); - drawLives(); - $('#play .lives').attr('class', 'lives changeDown'); - window.setTimeout(function() { $('#play .lives').attr('class', 'lives'); }, 2000); - if (gameStatus.lives === 0) { - gameOver(); - } - } - - function addLives(nbLives) { - gameStatus.lives += nbLives; - playSound('life-up'); - drawLives(); - $('#play .lives').attr('class', 'lives changeUp'); - window.setTimeout(function() { $('#play .lives').attr('class', 'lives'); }, 2000); - } - - function addScore(scoreToAdd) { - oldScore = gameStatus.score; - gameStatus.score += ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].points(scoreToAdd); - increaseScore(); - $('#play .score').attr('class', 'score changeUp'); - window.setTimeout(function() { $('#play .score').attr('class', 'score'); }, 2000); - hundreds = Math.floor(gameStatus.score / ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].extraLifePoints) - Math.floor(oldScore / ESVIJI.settings.difficulties[gameStatus.preferences.difficulty].extraLifePoints); - if (hundreds > 0) { - addLives(hundreds); - } - } - - function increaseScore() { - currentDrawnScore = parseInt($('#play .score').text(), 10); - if (currentDrawnScore < gameStatus.score) { - $('#play .score').text(currentDrawnScore + Math.ceil((gameStatus.score - currentDrawnScore) / 3)); - window.setTimeout(increaseScore, 100); - } - } - - function drawScore() { - $('#play .score').text(gameStatus.score); - } - - function drawLevel() { - $('#play .level').text(gameStatus.level); - } - - function drawLives() { - $('#play .lives').text(gameStatus.lives); - } - - function xToSvg(x) { - return (x - 1) * 32; - } - - function yToSvg(y) { - return ESVIJI.settings.board.height - 32 * y; - } - - function svgToX(coordX) { - return coordX / 32 + 1; - } - - function svgToY(coordY) { - return Math.round((ESVIJI.settings.board.height - coordY) / 32); - } - - function pixelsToSvgY(coordY) { - return (coordY - boardOffsetY) * ESVIJI.settings.board.height / boardHeight; - } - - function playSound(type) { - if (gameStatus.preferences.sound && sounds._loaded) { - sounds.play(type); - } - } - - function vibrate(duration) { - if (Modernizr.testProp('vibrate') && gameStatus.preferences.vibration) { - navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate; - navigator.vibrate(duration); - } - } - - function install() { - var manifestUrl = location.href.substring(0, location.href.lastIndexOf('/')) + '/manifest.webapp'; - var request = window.navigator.mozApps.install(manifestUrl); - request.onsuccess = function() { - // var appRecord = this.result; - alert('Installation successful!'); - $('#installButton').css('display', 'none'); - }; - request.onerror = function() { - // Display the error information from the DOMError object - console.error('Install failed, error: ' + this.error.name); - }; - } - - function showInstall() { - if (undefined !== navigator.mozApps) { - var request = navigator.mozApps.getSelf(); - request.onsuccess = function() { - if (request.result) { - // we're installed, nothing to do - } else { - $('#installButton').css('display', 'block').one(clickType, install); - } - }; - request.onerror = function() { - console.error('Error checking installation status: ' + this.error.message); - }; - } - } - - return { - init: init, - viewportOptimize: viewportOptimize - }; -})(); - -document.addEventListener('DOMContentLoaded', function() { - ESVIJI.game.init(); -}); - -window.addEventListener('resize', ESVIJI.game.viewportOptimize); -window.addEventListener('orientationchange', ESVIJI.game.viewportOptimize); - -/*************************************************************************************** - * appcache - ***************************************************************************************/ - -// Check if a new cache is available -if (window.applicationCache) { - window.applicationCache.addEventListener('updateready', function(e) { - if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { - // Browser downloaded a new app cache - // Swap it in and reload the page to get the new version - window.applicationCache.swapCache(); - window.location.reload(); - } - }, false); -} diff --git a/sources/esviji/js/offlineGoogleAnalytics.js b/sources/esviji/js/offlineGoogleAnalytics.js deleted file mode 100644 index 74a0d47..0000000 --- a/sources/esviji/js/offlineGoogleAnalytics.js +++ /dev/null @@ -1,54 +0,0 @@ -// Put Google Analytics events in localStorage when offline, sync when back online - -var offlineAnalytics = { - isOnline: function () { - return (navigator.onLine || !('onLine' in navigator)) && (typeof window.ga === "function"); - }, - - push: function(arr) { - if(this.isOnline()) { - var l = arr.length; - for (var i = 0; i < l; i++) { - var elt = arr[i]; - switch (elt.name) { - case 'version': - ga('set', 'dimension1', elt.value); - break; - case 'level': - ga('set', 'dimension2', elt.value); - break; - case 'score': - ga('set', 'dimension3', elt.value); - break; - case 'view': - console.log(elt.value); - ga('send', 'pageview', elt.value); - break; - } - } - } else { - this.store(arr); - } - }, - - store: function(arr) { - var stored = store.get('offlineAnalytics') || []; - stored.push(arr); - store.set('offlineAnalytics', stored); - this.sync(); - }, - - sync: function() { - if(this.isOnline()) { - var stored = store.get('offlineAnalytics') || []; - store.remove('offlineAnalytics'); - this.push(stored); - } else { - window.setTimeout(offlineAnalytics.sync, 1000 * 60); - } - } -}; - -$(window).bind('online', function() { - offlineAnalytics.sync(); -}); diff --git a/sources/esviji/js/vendor/SVGEventListener-0.2.3.js b/sources/esviji/js/vendor/SVGEventListener-0.2.3.js deleted file mode 100644 index 82d737f..0000000 --- a/sources/esviji/js/vendor/SVGEventListener-0.2.3.js +++ /dev/null @@ -1,294 +0,0 @@ -// SVGEventListener.js -// Version - 0.2.3 -// -// by MAD - @madsgraphics - ecrire[at]madsgraphics[dot]com -// -// https://github.com/madsgraphics/SVGEventListener/ -// -// Tri-license - WTFPL | MIT | BSD -// -// Please minify before use. - -( function ( undefined ) { - - 'use strict'; - - var legacy, - svgns, - isArray, - supportedEvents; - - legacy = { - addEventListener : Element.prototype.addEventListener, - svgAnimateBeginElement : SVGAnimateElement.prototype.beginElement, - svgAnimateTransformBeginElement : SVGAnimateTransformElement.prototype.beginElement - }; - - svgns = 'http://www.w3.org/2000/svg'; - - // helper functions - function isString( s ) { - return typeof s === 'string'; - }; - isArray = Array.isArray || function ( obj ) { - return {}.toString.call( obj ) === '[object Array]'; - }; - function isUndefined( obj ) { - return obj === undefined; - }; - // String prototyping to add `contains` - String.prototype.contains = function(pattern) { - return (this.indexOf(pattern) !== -1); - }; - - // Cache events support - supportedEvents = {}; - function isEventSupported( eventName ) { - // early return if the event is in cache - if ( supportedEvents[eventName] !== undefined ) { - return supportedEvents[eventName]; - } - - // initiliaze the support at false for detection - supportedEvents[eventName] = false; - // create svg (and childs) nodes - var svg = document.createElementNS( svgns, 'svg' ), - element = document.createElementNS( svgns, 'rect'), - animate = document.createElementNS( svgns, 'animate' ); - - // set duration to 1ms to detect endEvent - animate.setAttributeNS(null, 'dur', '1ms'); - animate.setAttributeNS(null, 'attributeName', 'x'); - // append elements - element.appendChild(animate); - svg.appendChild(element); - - // attach a listener to the event that update the events cache - legacy.addEventListener.call(animate, eventName + 'Event', function() { - supportedEvents[eventName] = true; - }, false); - - // attach svg to the DOM (else it doesn't detect anything) but cache it - svg.setAttributeNS(null, 'style', 'display:none'); - document.body.appendChild(svg); - // Set a timeout to remove the dummy SVG element - // It is setted to 50 to leave the DOM breath and get the SVG event - // result before removing it :) - setTimeout(function() { document.body.removeChild(svg); }, 50); - - // Return the current event support status - return supportedEvents[eventName]; - }; - - ////////////////////////////////////////////////////////////////////////////// - // Clocker.js - // Convert a legal clock string value (in SMIL definition) to milliseconds - // - // Originaly released here: https://github.com/madsgraphics/clocker.js - function clocker( timestr ) { - var time, - times = timestr.split( ':' ); - - // Timecount-value - // = Formats without ':' - if ( times.length === 1 ) { - time = times[0]; - // Time already given in milliseconds (250ms) - if ( time.lastIndexOf('ms') !== -1 ) { - return +(time); - } - // Othermetrics - else { - // minutes - if( time.lastIndexOf('min') !== -1 ) { - time = parseFloat(time) * 60; - } - // hours - else if( time.lastIndexOf('h') !== -1 ) { - time = parseFloat(time) * 3600; - } - // Time is now in seconds. - // If time is without metric, then assume in seconds, - // maybe float (2.05 == 2050ms) - // So convert in ms… - return parseFloat(time) * 1000; - } - } - // Full-clock-value || Partial-clock-value - else { - // Reverse order to iterate from seconds to hours - times.reverse(); - // Init time - time = 0; - for ( var t in times ) { - // Value * 60^t (hours / minutes to seconds) * 1000 (s to ms) - time += times[t]*Math.pow(60, t)*1000; - } - - return time; - } - } - - ////////////////////////////////////////////////////////////////////////////// - // Event Listener - // - // Custom Event listener - // Implements Observer pattern - - // Create custom listener object with private property to store listeners - // - // initially inspired by: - // http://www.nczonline.net/blog/2010/03/09/custom-events-in-javascript/ - function EventListener( element ) { - // store SVG node - this.el = element; - // Initialize events stack - this._listeners = {}; - // constructs stack - this._init(); - } - - // Extends it to add and fire events - EventListener.prototype = { - constructor: EventListener, - _delayEvent: function (eventName, duration) { - var that = this, - dur = clocker( duration ); - return function () { - window.setTimeout( function () { - that.fire( eventName + 'Event' ); - }, dur); - }; - }, - - _attachEvent: function (eventName, id) { - var that = this, - previousAnimate = document.getElementById( id ); - // Early exit if there is no previousAnimate element available - if (previousAnimate == null) { return; } - // Add an endEvent that launch the next animation - previousAnimate.addEventListener( eventName + 'Event', function () { - that.fire( 'beginEvent' ); - }); - }, - // initializer - _init: function () { - var that = this, - begin = this.el.getAttribute('begin'), - dur = this.el.getAttribute('dur'), - index; - - // End event - // --------- - // Add a delayed at duration time - this.add('beginEvent', this._delayEvent('end', dur)); - - // Begin event - // ----------- - // Begin event delayed - if ( begin !== 'indefinite' && !begin.contains('.end') && !begin.contains('.begin') ) { - this._delayEvent('begin', begin); - } - // if the launch depends of the **end** of another animation - else if ( begin.contains('.end') ) { - this._attachEvent('end', begin.replace('.end', '')); - } - // if the launch depends of the **begin** of another animation - else if ( begin.contains('.begin') ) { - this._attachEvent('begin', begin.replace('.begin', '')); - } - }, - // add new event to listeners - add: function addListener( type, listener ) { - // if there is no triggers already defined for this events, - // init an a-empty array - if ( isUndefined( this._listeners[type] ) ) { - this._listeners[type] = []; - } - // add trigger to the event - this._listeners[type].push( listener ); - }, - // fire the event - fire: function fireListeners( event ) { - var name; - - // if called only by event name (useful), build a correct object - if ( isString( event ) ) { - event = { - type: event, - bubbles: false, - cancelable: false, - defaultPrevented: false, - currentTarget : null, - }; - } - - // Early return at fire if the event is already supported - name = event.type.substr(0, event.type.indexOf('Event')); - if (isEventSupported( name )) { return; } - - // set target if unavailable - if ( !event.target ) { - event.target = event.currentTarget = this.el; - } - // if there is no event given, throw an error - if ( !event.type ) { - throw new Error( 'Event object missing "type" property.' ); - } - // If the type has associated triggers, then launch them - if ( isArray( this._listeners[event.type] ) ) { - var listeners = this._listeners[event.type]; - for ( var l in listeners ) { - listeners[l].call( this.el, event ); - } - } - } - }; - - // Overwrite Element.addEventListener method for transparency fallback - // - // Inpired by: - // http://stackoverflow.com/questions/7220515/extending-node-addeventlistener-method-with-the-same-name#7220628 - Element.prototype.addEventListener = function ( type, listener, useCapture ) { - if ( this instanceof SVGAnimateElement - || this instanceof SVGAnimateTransformElement ) { - // *** - // Attach a new event listeners stack if it doesn't exists - if ( isUndefined( this.listeners ) ) - { - this.listeners = new EventListener( this ); - } - // *** - // check event name and support for endEvent - if ( type === 'endEvent' && !isEventSupported( 'end' ) ) { - // Add listener to the endEvent stack - this.listeners.add( type, listener ); - } - // *** - // check event name and suport for beginEvent - if ( type === 'beginEvent' && !isEventSupported( 'begin' ) ) { - // Add listener to the endEvent stack - this.listeners.add( type, listener ); - } - } - // *** - // call the original method for fallback - return legacy.addEventListener.call( this, type, listener, useCapture ); - }; - - // Overwrite Element.beginElement method to trigger begin event - SVGAnimateElement.prototype.beginElement = function() { - if ( !isEventSupported( 'begin' ) && this.listeners !== undefined) { - this.listeners.fire('beginEvent'); - } - return legacy.svgAnimateBeginElement.call(this); - }; - - SVGAnimateTransformElement.prototype.beginElement = function() { - if ( !isEventSupported( 'begin' ) && this.listeners !== undefined) { - this.listeners.fire('beginEvent'); - } - return legacy.svgAnimateTransformBeginElement.call(this); - }; - -})(); diff --git a/sources/esviji/js/vendor/analytics.js b/sources/esviji/js/vendor/analytics.js deleted file mode 100644 index 8c52758..0000000 --- a/sources/esviji/js/vendor/analytics.js +++ /dev/null @@ -1,39 +0,0 @@ -(function(){var aa=encodeURIComponent,f=window,ba=setTimeout,n=Math,ea=RegExp;function fa(a,b){return a.name=b}function Pc(a,b){return a.href=b} -var p="push",h="hash",ha="slice",Qc="replace",q="data",r="cookie",t="indexOf",m="match",ia="defaultValue",xc="send",ja="port",u="createElement",id="setAttribute",v="name",da="getTime",x="host",y="length",z="prototype",la="clientWidth",A="split",B="location",ma="hostname",ga="search",jd="target",C="call",E="protocol",na="clientHeight",Ab="href",F="substring",kd="action",G="apply",oa="navigator",Ub="parentNode",H="join",I="toLowerCase";var pa=new function(){var a=[];this.set=function(b){a[b]=!0};this.M=function(){for(var b=[],c=0;c=a[y])wc(a,b);else if(8192>=a[y]){var c=b;if(0<=O[oa].userAgent[t]("Firefox")&&![].reduce)throw new Ea(a[y]);wd(a,c)||xd(a,c)||Fa(a,c)}else throw new Da(a[y]);},wc=function(a,b){var c=Ca(oc()+"/collect?"+a);c.onload=c.onerror=function(){c.onload=null;c.onerror=null; -b()}},xd=function(a,b){var c;c=O.XDomainRequest;if(!c)return!1;c=new c;c.open("POST",oc()+"/collect");c.onerror=function(){b()};c.onload=b;c[xc](a);return!0},wd=function(a,b){var c=O.XMLHttpRequest;if(!c)return!1;var d=new c;if(!("withCredentials"in d))return!1;d.open("POST",oc()+"/collect",!0);d.setRequestHeader("Content-Type","text/plain");d.onreadystatechange=function(){4==d.readyState&&(b(),d=null)};d[xc](a);return!0},Fa=function(a,b){if(M.body){a=aa(a);try{var c=M[u]('')}catch(d){c= -M[u]("iframe"),fa(c,a)}c.height="0";c.width="0";c.style.display="none";c.style.visibility="hidden";var e=M[B],e=oc()+"/analytics_iframe.html#"+aa(e[E]+"//"+e[x]+"/favicon.ico"),g=function(){c.src="";c[Ub]&&c[Ub].removeChild(c)};ta(O,"beforeunload",g);var ca=!1,l=0,k=function(){if(!ca){try{if(9=100*R(a,Ka))throw"abort";}function Ma(a){if(xa(P(a,Na)))throw"abort";}function Oa(){var a=M[B][E];if("http:"!=a&&"https:"!=a)throw"abort";} -function Pa(a){a.set(Ac,R(a,Ac)+1);var b=[];Qa.map(function(c,d){if(d.p){var e=a.get(c);void 0!=e&&e!=d[ia]&&("boolean"==typeof e&&(e*=1),b[p](d.p+"="+sa(""+e)))}});b[p]("z="+ra());a.set(Ra,b[H]("&"),!0)}function Sa(a){Ga(P(a,Ra),a.get(Ia));a.set(Ia,L,!0)}function Hc(a){var b=O.gaData;b&&(b.expId&&a.set(Nc,b.expId),b.expVar&&a.set(Oc,b.expVar))}function cd(){if(O[oa]&&"preview"==O[oa].loadPurpose)throw"abort";}function yd(a){var b=O.gaDevIds;vd(b)&&0!=b[y]&&a.set("&did",b[H](","),!0)};function Ta(a){var b=R(a,Ua);500<=b&&J(15);var c=P(a,Va);if("transaction"!=c&&"item"!=c){var c=R(a,Wa),d=(new Date)[da](),e=R(a,Xa);0==e&&a.set(Xa,d);e=n.round(2*(d-e)/1E3);0=c)throw"abort";a.set(Wa,--c)}a.set(Ua,++b)};var Ya=function(){this.data=new N},Qa=new N,Za=[];Ya[z].get=function(a){var b=$a(a),c=this[q].get(a);b&&void 0==c&&(c=K(b[ia])?b[ia]():b[ia]);return b&&b.n?b.n(this,a,c):c};var P=function(a,b){var c=a.get(b);return void 0==c?"":""+c},R=function(a,b){var c=a.get(b);return void 0==c||""===c?0:1*c};Ya[z].set=function(a,b,c){if(a)if("object"==typeof a)for(var d in a)a.hasOwnProperty(d)&&ab(this,d,a[d],c);else ab(this,a,b,c)}; -var ab=function(a,b,c,d){var e=$a(b);e&&e.o?e.o(a,b,c,d):a[q].set(b,c,d)},bb=function(a,b,c,d,e){fa(this,a);this.p=b;this.n=d;this.o=e;this.defaultValue=c},$a=function(a){var b=Qa.get(a);if(!b)for(var c=0;c=c)&&(c={},Ec(c)||Fc(c))){var d=c[Eb];void 0==d||Infinity==d||isNaN(d)||(0c)a[b]=void 0};var hc=!1,mc=function(a){if("cookie"==P(a,ac)){var b=P(a,U),c=nd(a),d=kc(P(a,Yb)),e=lc(P(a,W)),g=1E3*R(a,Zb),ca=P(a,Na);if("auto"!=e)zc(b,c,d,e,ca,g)&&(hc=!0);else{J(32);var l;t:{c=[];e=eb()[A](".");if(4==e[y]&&(l=e[e[y]-1],parseInt(l,10)==l)){l=["none"];break t}for(l=e[y]-2;0<=l;l--)c[p](e[ha](l)[H]("."));c[p]("none");l=c}for(var k=0;k=a&&d[p]({hash:ca[0],R:e[g],O:ca})}return 0==d[y]?void 0:1==d[y]?d[0]:Zc(b,d)||Zc(c,d)||Zc(null,d)||d[0]}function Zc(a,b){var c,d;null==a?c=d=1:(c=La(a),d=La(0==a[t](".")?a[F](1):"."+a));for(var e=0;ed[y])){c=[];for(var e=0;e=ca[0]||0>=ca[1]?"":ca[H]("x");a.set(rb,c);a.set(tb,fc());a.set(ob,M.characterSet||M.charset);a.set(sb,b&&"function"===typeof b.javaEnabled&&b.javaEnabled()||!1);a.set(nb,(b&&(b.language||b.browserLanguage)||"")[I]());if(d&&a.get(cc)&&(b=M[B][h])){b=b[F](1);b=b[A]("&");d=[];for(c=0;carguments[y])){var b,c;"string"===typeof arguments[0]?(b=arguments[0],c=[][ha][C](arguments,1)):(b=arguments[0]&&arguments[0][Va],c=arguments);b&&(c=wa(qc[b]||[],c),c[Va]=b,this.b.set(c,void 0,!0),this.filters.D(this.b),"pageview"==b&&Lc(this),this.b[q].m={})}};var Lc=function(a){a.I||(a.I=!0,gc(a.b,function(b){a[xc]("timing",b)}))};var rc=function(a){if("prerender"==M.webkitVisibilityState)return!1;a();return!0},Mc=function(a){if(!rc(a)){J(16);var b=!1,c=function(){!b&&rc(a)&&(b=!0,ua(M,"webkitvisibilitychange",c))};ta(M,"webkitvisibilitychange",c)}};var td=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/,sc=function(a){if(K(a[0]))this.u=a[0];else{var b=td.exec(a[0]);null!=b&&4==b[y]&&(this.c=b[1]||"t0",this.e=b[2]||"",this.d=b[3],this.a=[][ha][C](a,1),this.e||(this.A="create"==this.d,this.i="require"==this.d,this.g="provide"==this.d));b=a[1];a=a[2];if(!this.d)throw"abort";if(this.i&&(!qa(b)||""==b))throw"abort";if(this.g&&(!qa(b)||""==b||!K(a)))throw"abort";if(ud(this.c)||ud(this.e))throw"abort";if(this.g&&"t0"!=this.c)throw"abort";}}; -function ud(a){return 0<=a[t](".")||0<=a[t](":")};var Z={F:"/plugins/ua/"};Z.k=new N;Z.f=[];Z.B=function(a,b,c){var d=Z.k.get(a);if(!K(d))return!1;b.plugins_=b.plugins_||new N;b.plugins_.set(a,new d(b,c||{}));return!0};Z.C=function(a,b){Z.k.set(a,b)};Z.D=function(a){var b=Z.J[G](Z,arguments),b=Z.f.concat(b);for(Z.f=[];0a[A]("/")[0][t](":")&&(a=ca+e[2][F](0,e[2].lastIndexOf("/"))+"/"+a):a=ca+e[2]+(a||g);Pc(c,a);d=b(c);return{protocol:(c[E]||"")[I](),host:d[0],port:d[1], -path:d[2],G:c[ga]||"",url:a||""}};var $=function(a){J(1);Z.D[G](Z,[arguments])};$.h={};$.P=[];$.L=0;$.answer=42;var uc=[Na,W,V];$.create=function(a){var b=wa(uc,[][ha][C](arguments));b[V]||(b[V]="t0");var c=""+b[V];if($.h[c])return $.h[c];b=new pc(b);$.h[c]=b;$.P[p](b);return b};$.j=function(a){return $.h[a]};$.K=function(){return $.P[ha](0)};$.N=function(){var a=O[gb];if(!a||42!=a.answer){$.L=a&&a.l;$.loaded=!0;O[gb]=$;Cc();var b=a&&a.q;vd(b)&&Mc(function(){Z.D[G]($,b)})}};$.N();function La(a){var b=1,c=0,d;if(a)for(b=0,d=a[y]-1;0<=d;d--)c=a.charCodeAt(d),b=(b<<6&268435455)+c+(c<<14),c=b&266338304,b=0!=c?b^c>>21:b;return b};})(window); diff --git a/sources/esviji/js/vendor/howler-1.1.11.js b/sources/esviji/js/vendor/howler-1.1.11.js deleted file mode 100644 index d021e62..0000000 --- a/sources/esviji/js/vendor/howler-1.1.11.js +++ /dev/null @@ -1,1181 +0,0 @@ -/*! - * howler.js v1.1.11 - * howlerjs.com - * - * (c) 2013, James Simpson of GoldFire Studios - * goldfirestudios.com - * - * MIT License - */ - -(function() { - // setup - var cache = {}; - - // setup the audio context - var ctx = null, - usingWebAudio = true, - noAudio = false; - if (typeof AudioContext !== 'undefined') { - ctx = new AudioContext(); - } else if (typeof webkitAudioContext !== 'undefined') { - ctx = new webkitAudioContext(); - } else if (typeof Audio !== 'undefined') { - usingWebAudio = false; - } else { - usingWebAudio = false; - noAudio = true; - } - - // create a master gain node - if (usingWebAudio) { - var masterGain = (typeof ctx.createGain === 'undefined') ? ctx.createGainNode() : ctx.createGain(); - masterGain.gain.value = 1; - masterGain.connect(ctx.destination); - } - - // create global controller - var HowlerGlobal = function() { - this._volume = 1; - this._muted = false; - this.usingWebAudio = usingWebAudio; - this._howls = []; - }; - HowlerGlobal.prototype = { - /** - * Get/set the global volume for all sounds. - * @param {Float} vol Volume from 0.0 to 1.0. - * @return {Howler/Float} Returns self or current volume. - */ - volume: function(vol) { - var self = this; - - // make sure volume is a number - vol = parseFloat(vol); - - if (vol && vol >= 0 && vol <= 1) { - self._volume = vol; - - if (usingWebAudio) { - masterGain.gain.value = vol; - } - - // loop through cache and change volume of all nodes that are using HTML5 Audio - for (var key in self._howls) { - if (self._howls.hasOwnProperty(key) && self._howls[key]._webAudio === false) { - // loop through the audio nodes - for (var i=0; i= 2) ? ext[1] : self._urls[i].toLowerCase().match(/data\:audio\/([^?]+);/)[1]; - } - - if (canPlay[ext]) { - url = self._urls[i]; - break; - } - } - - if (!url) { - self.on('loaderror'); - return; - } - - self._src = url; - - if (self._webAudio) { - loadBuffer(self, url); - } else { - var newNode = new Audio(); - self._audioNode.push(newNode); - - // setup the new audio node - newNode.src = url; - newNode._pos = 0; - newNode.preload = 'auto'; - newNode.volume = (Howler._muted) ? 0 : self._volume * Howler.volume(); - - // add this sound to the cache - cache[url] = self; - - // setup the event listener to start playing the sound - // as soon as it has buffered enough - var listener = function() { - self._duration = newNode.duration; - - // setup a sprite if none is defined - if (Object.getOwnPropertyNames(self._sprite).length === 0) { - self._sprite = {_default: [0, self._duration * 1000]}; - } - - if (!self._loaded) { - self._loaded = true; - self.on('load'); - } - - if (self._autoplay) { - self.play(); - } - - // clear the event listener - newNode.removeEventListener('canplaythrough', listener, false); - }; - newNode.addEventListener('canplaythrough', listener, false); - newNode.load(); - } - - return self; - }, - - /** - * Get/set the URLs to be pulled from to play in this source. - * @param {Array} urls Arry of URLs to load from - * @return {Howl} Returns self or the current URLs - */ - urls: function(urls) { - var self = this; - - if (urls) { - self.stop(); - self._urls = (typeof urls === 'string') ? [urls] : urls; - self._loaded = false; - self.load(); - - return self; - } else { - return self._urls; - } - }, - - /** - * Play a sound from the current time (0 by default). - * @param {String} sprite (optional) Plays from the specified position in the sound sprite definition. - * @param {Function} callback (optional) Returns the unique playback id for this sound instance. - * @return {Howl} - */ - play: function(sprite, callback) { - var self = this; - - // if no sprite was passed but a callback was, update the variables - if (typeof sprite === 'function') { - callback = sprite; - } - - // use the default sprite if none is passed - if (!sprite || typeof sprite === 'function') { - sprite = '_default'; - } - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('load', function() { - self.play(sprite, callback); - }); - - return self; - } - - // if the sprite doesn't exist, play nothing - if (!self._sprite[sprite]) { - if (typeof callback === 'function') callback(); - return self; - } - - // get the node to playback - self._inactiveNode(function(node) { - // persist the sprite being played - node._sprite = sprite; - - // determine where to start playing from - var pos = (node._pos > 0) ? node._pos : self._sprite[sprite][0] / 1000, - duration = self._sprite[sprite][1] / 1000 - node._pos; - - // determine if this sound should be looped - var loop = !!(self._loop || self._sprite[sprite][2]); - - // set timer to fire the 'onend' event - var soundId = (typeof callback === 'string') ? callback : Math.round(Date.now() * Math.random()) + '', - timerId; - (function() { - var data = { - id: soundId, - sprite: sprite, - loop: loop - }; - timerId = setTimeout(function() { - // if looping, restart the track - if (!self._webAudio && loop) { - self.stop(data.id, data.timer).play(sprite, data.id); - } - - // set web audio node to paused at end - if (self._webAudio && !loop) { - self._nodeById(data.id).paused = true; - } - - // end the track if it is HTML audio and a sprite - if (!self._webAudio && !loop) { - self.stop(data.id, data.timer); - } - - // fire ended event - self.on('end', soundId); - }, duration * 1000); - - // store the reference to the timer - self._onendTimer.push(timerId); - - // remember which timer to cancel - data.timer = self._onendTimer[self._onendTimer.length - 1]; - })(); - - if (self._webAudio) { - var loopStart = self._sprite[sprite][0] / 1000, - loopEnd = self._sprite[sprite][1] / 1000; - - // set the play id to this node and load into context - node.id = soundId; - node.paused = false; - refreshBuffer(self, [loop, loopStart, loopEnd], soundId); - self._playStart = ctx.currentTime; - node.gain.value = self._volume; - - if (typeof node.bufferSource.start === 'undefined') { - node.bufferSource.noteGrainOn(0, pos, duration); - } else { - node.bufferSource.start(0, pos, duration); - } - } else { - if (node.readyState === 4) { - node.id = soundId; - node.currentTime = pos; - node.muted = Howler._muted; - node.volume = self._volume * Howler.volume(); - setTimeout(function() { node.play(); }, 0); - } else { - self._clearEndTimer(timerId); - - (function(){ - var sound = self, - playSprite = sprite, - fn = callback, - newNode = node; - var listener = function() { - sound.play(playSprite, fn); - - // clear the event listener - newNode.removeEventListener('canplaythrough', listener, false); - }; - newNode.addEventListener('canplaythrough', listener, false); - })(); - - return self; - } - } - - // fire the play event and send the soundId back in the callback - self.on('play'); - if (typeof callback === 'function') callback(soundId); - - return self; - }); - - return self; - }, - - /** - * Pause playback and save the current position. - * @param {String} id (optional) The play instance ID. - * @param {String} timerId (optional) Clear the correct timeout ID. - * @return {Howl} - */ - pause: function(id, timerId) { - var self = this; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('play', function() { - self.pause(id); - }); - - return self; - } - - // clear 'onend' timer - self._clearEndTimer(timerId || 0); - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - activeNode._pos = self.pos(null, id); - - if (self._webAudio) { - // make sure the sound has been created - if (!activeNode.bufferSource) { - return self; - } - - activeNode.paused = true; - if (typeof activeNode.bufferSource.stop === 'undefined') { - activeNode.bufferSource.noteOff(0); - } else { - activeNode.bufferSource.stop(0); - } - } else { - activeNode.pause(); - } - } - - self.on('pause'); - - return self; - }, - - /** - * Stop playback and reset to start. - * @param {String} id (optional) The play instance ID. - * @param {String} timerId (optional) Clear the correct timeout ID. - * @return {Howl} - */ - stop: function(id, timerId) { - var self = this; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('play', function() { - self.stop(id); - }); - - return self; - } - - // clear 'onend' timer - self._clearEndTimer(timerId || 0); - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - activeNode._pos = 0; - - if (self._webAudio) { - // make sure the sound has been created - if (!activeNode.bufferSource) { - return self; - } - - activeNode.paused = true; - - if (typeof activeNode.bufferSource.stop === 'undefined') { - activeNode.bufferSource.noteOff(0); - } else { - activeNode.bufferSource.stop(0); - } - } else { - activeNode.pause(); - activeNode.currentTime = 0; - } - } - - return self; - }, - - /** - * Mute this sound. - * @param {String} id (optional) The play instance ID. - * @return {Howl} - */ - mute: function(id) { - var self = this; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('play', function() { - self.mute(id); - }); - - return self; - } - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - if (self._webAudio) { - activeNode.gain.value = 0; - } else { - activeNode.volume = 0; - } - } - - return self; - }, - - /** - * Unmute this sound. - * @param {String} id (optional) The play instance ID. - * @return {Howl} - */ - unmute: function(id) { - var self = this; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('play', function() { - self.unmute(id); - }); - - return self; - } - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - if (self._webAudio) { - activeNode.gain.value = self._volume; - } else { - activeNode.volume = self._volume; - } - } - - return self; - }, - - /** - * Get/set volume of this sound. - * @param {Float} vol Volume from 0.0 to 1.0. - * @param {String} id (optional) The play instance ID. - * @return {Howl/Float} Returns self or current volume. - */ - volume: function(vol, id) { - var self = this; - - // make sure volume is a number - vol = parseFloat(vol); - - if (vol >= 0 && vol <= 1) { - self._volume = vol; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('play', function() { - self.volume(vol, id); - }); - - return self; - } - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - if (self._webAudio) { - activeNode.gain.value = vol; - } else { - activeNode.volume = vol * Howler.volume(); - } - } - - return self; - } else { - return self._volume; - } - }, - - /** - * Get/set whether to loop the sound. - * @param {Boolean} loop To loop or not to loop, that is the question. - * @return {Howl/Boolean} Returns self or current looping value. - */ - loop: function(loop) { - var self = this; - - if (typeof loop === 'boolean') { - self._loop = loop; - - return self; - } else { - return self._loop; - } - }, - - /** - * Get/set sound sprite definition. - * @param {Object} sprite Example: {spriteName: [offset, duration, loop]} - * @param {Integer} offset Where to begin playback in milliseconds - * @param {Integer} duration How long to play in milliseconds - * @param {Boolean} loop (optional) Set true to loop this sprite - * @return {Howl} Returns current sprite sheet or self. - */ - sprite: function(sprite) { - var self = this; - - if (typeof sprite === 'object') { - self._sprite = sprite; - - return self; - } else { - return self._sprite; - } - }, - - /** - * Get/set the position of playback. - * @param {Float} pos The position to move current playback to. - * @param {String} id (optional) The play instance ID. - * @return {Howl/Float} Returns self or current playback position. - */ - pos: function(pos, id) { - var self = this; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('load', function() { - self.pos(pos); - }); - - return typeof pos === 'number' ? self : self._pos || 0; - } - - // make sure we are dealing with a number for pos - pos = parseFloat(pos); - - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - if (self._webAudio) { - if (pos >= 0) { - activeNode._pos = pos; - self.pause(id).play(activeNode._sprite, id); - - return self; - } else { - return activeNode._pos + (ctx.currentTime - self._playStart); - } - } else { - if (pos >= 0) { - activeNode.currentTime = pos; - - return self; - } else { - return activeNode.currentTime; - } - } - } else if (pos >= 0) { - return self; - } else { - // find the first inactive node to return the pos for - for (var i=0; i= 0 || x < 0) { - if (self._webAudio) { - var activeNode = (id) ? self._nodeById(id) : self._activeNode(); - if (activeNode) { - self._pos3d = [x, y, z]; - activeNode.panner.setPosition(x, y, z); - } - } - } else { - return self._pos3d; - } - - return self; - }, - - /** - * Fade a currently playing sound between two volumes. - * @param {Number} from The volume to fade from (0.0 to 1.0). - * @param {Number} to The volume to fade to (0.0 to 1.0). - * @param {Number} len Time in milliseconds to fade. - * @param {Function} callback (optional) Fired when the fade is complete. - * @param {String} id (optional) The play instance ID. - * @return {Howl} - */ - fade: function(from, to, len, callback, id) { - var self = this, - diff = Math.abs(from - to), - dir = from > to ? 'down' : 'up', - steps = diff / 0.01, - stepTime = len / steps; - - // if the sound hasn't been loaded, add it to the event queue - if (!self._loaded) { - self.on('load', function() { - self.fade(from, to, len, callback, id); - }); - - return self; - } - - // set the volume to the start position - self.volume(from, id); - - for (var i=1; i<=steps; i++) { - (function() { - var change = self._volume + (dir === 'up' ? 0.01 : -0.01) * i, - vol = Math.round(1000 * change) / 1000, - toVol = to; - - setTimeout(function() { - self.volume(vol, id); - - if (vol === toVol) { - if (callback) callback(); - } - }, stepTime * i); - })(); - } - }, - - /** - * [DEPRECATED] Fade in the current sound. - * @param {Float} to Volume to fade to (0.0 to 1.0). - * @param {Number} len Time in milliseconds to fade. - * @param {Function} callback - * @return {Howl} - */ - fadeIn: function(to, len, callback) { - return this.volume(0).play().fade(0, to, len, callback); - }, - - /** - * [DEPRECATED] Fade out the current sound and pause when finished. - * @param {Float} to Volume to fade to (0.0 to 1.0). - * @param {Number} len Time in milliseconds to fade. - * @param {Function} callback - * @param {String} id (optional) The play instance ID. - * @return {Howl} - */ - fadeOut: function(to, len, callback, id) { - var self = this; - - return self.fade(self._volume, to, len, function() { - if (callback) callback(); - self.pause(id); - - // fire ended event - self.on('end'); - }, id); - }, - - /** - * Get an audio node by ID. - * @return {Howl} Audio node. - */ - _nodeById: function(id) { - var self = this, - node = self._audioNode[0]; - - // find the node with this ID - for (var i=0; i=0; i--) { - if (inactive <= 5) { - break; - } - - if (self._audioNode[i].paused) { - // disconnect the audio source if using Web Audio - if (self._webAudio) { - self._audioNode[i].disconnect(0); - } - - inactive--; - self._audioNode.splice(i, 1); - } - } - }, - - /** - * Clear 'onend' timeout before it ends. - * @param {Number} timerId The ID of the sound to be cancelled. - */ - _clearEndTimer: function(timerId) { - var self = this, - timer = self._onendTimer.indexOf(timerId); - - // make sure the timer gets cleared - timer = timer >= 0 ? timer : 0; - - if (self._onendTimer[timer]) { - clearTimeout(self._onendTimer[timer]); - self._onendTimer.splice(timer, 1); - } - }, - - /** - * Setup the gain node and panner for a Web Audio instance. - * @return {Object} The new audio node. - */ - _setupAudioNode: function() { - var self = this, - node = self._audioNode, - index = self._audioNode.length; - - // create gain node - node[index] = (typeof ctx.createGain === 'undefined') ? ctx.createGainNode() : ctx.createGain(); - node[index].gain.value = self._volume; - node[index].paused = true; - node[index]._pos = 0; - node[index].readyState = 4; - node[index].connect(masterGain); - - // create the panner - node[index].panner = ctx.createPanner(); - node[index].panner.setPosition(self._pos3d[0], self._pos3d[1], self._pos3d[2]); - node[index].panner.connect(node[index]); - - return node[index]; - }, - - /** - * Call/set custom events. - * @param {String} event Event type. - * @param {Function} fn Function to call. - * @return {Howl} - */ - on: function(event, fn) { - var self = this, - events = self['_on' + event]; - - if (typeof fn === "function") { - events.push(fn); - } else { - for (var i=0; i type pairs - class2type = {}, - - // List of deleted data cache ids, so we can reuse them - core_deletedIds = [], - - core_version = "1.10.2", - - // Save a reference to some core methods - core_concat = core_deletedIds.concat, - core_push = core_deletedIds.push, - core_slice = core_deletedIds.slice, - core_indexOf = core_deletedIds.indexOf, - core_toString = class2type.toString, - core_hasOwn = class2type.hasOwnProperty, - core_trim = core_version.trim, - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Used for matching numbers - core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, - - // Used for splitting on whitespace - core_rnotwhite = /\S+/g, - - // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, - rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }, - - // The ready event handler - completed = function( event ) { - - // readyState === "complete" is good enough for us to call the dom ready in oldIE - if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { - detach(); - jQuery.ready(); - } - }, - // Clean-up method for dom ready events - detach = function() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", completed, false ); - window.removeEventListener( "load", completed, false ); - - } else { - document.detachEvent( "onreadystatechange", completed ); - window.detachEvent( "onload", completed ); - } - }; - -jQuery.fn = jQuery.prototype = { - // The current version of jQuery being used - jquery: core_version, - - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - - // scripts is true for back-compat - jQuery.merge( this, jQuery.parseHTML( - match[1], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(DOMElement) - } else if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The default length of a jQuery object is 0 - length: 0, - - toArray: function() { - return core_slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - ret.context = this.context; - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; - }, - - slice: function() { - return this.pushStack( core_slice.apply( this, arguments ) ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - eq: function( i ) { - var len = this.length, - j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: core_push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var src, copyIsArray, copy, name, options, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), - - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger("ready").off("ready"); - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - isWindow: function( obj ) { - /* jshint eqeqeq: false */ - return obj != null && obj == obj.window; - }, - - isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - - type: function( obj ) { - if ( obj == null ) { - return String( obj ); - } - return typeof obj === "object" || typeof obj === "function" ? - class2type[ core_toString.call(obj) ] || "object" : - typeof obj; - }, - - isPlainObject: function( obj ) { - var key; - - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - // Not own constructor property must be Object - if ( obj.constructor && - !core_hasOwn.call(obj, "constructor") && - !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Support: IE<9 - // Handle iteration over inherited properties before own properties. - if ( jQuery.support.ownLast ) { - for ( key in obj ) { - return core_hasOwn.call( obj, key ); - } - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - for ( key in obj ) {} - - return key === undefined || core_hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - var name; - for ( name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw new Error( msg ); - }, - - // data: string of html - // context (optional): If specified, the fragment will be created in this context, defaults to document - // keepScripts (optional): If true, will include scripts passed in the html string - parseHTML: function( data, context, keepScripts ) { - if ( !data || typeof data !== "string" ) { - return null; - } - if ( typeof context === "boolean" ) { - keepScripts = context; - context = false; - } - context = context || document; - - var parsed = rsingleTag.exec( data ), - scripts = !keepScripts && []; - - // Single tag - if ( parsed ) { - return [ context.createElement( parsed[1] ) ]; - } - - parsed = jQuery.buildFragment( [ data ], context, scripts ); - if ( scripts ) { - jQuery( scripts ).remove(); - } - return jQuery.merge( [], parsed.childNodes ); - }, - - parseJSON: function( data ) { - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - if ( data === null ) { - return data; - } - - if ( typeof data === "string" ) { - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - if ( data ) { - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return ( new Function( "return " + data ) )(); - } - } - } - - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - if ( !data || typeof data !== "string" ) { - return null; - } - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && jQuery.trim( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - // args is for internal usage only - each: function( obj, callback, args ) { - var value, - i = 0, - length = obj.length, - isArray = isArraylike( obj ); - - if ( args ) { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } - } - - return obj; - }, - - // Use native String.trim function wherever possible - trim: core_trim && !core_trim.call("\uFEFF\xA0") ? - function( text ) { - return text == null ? - "" : - core_trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var ret = results || []; - - if ( arr != null ) { - if ( isArraylike( Object(arr) ) ) { - jQuery.merge( ret, - typeof arr === "string" ? - [ arr ] : arr - ); - } else { - core_push.call( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( core_indexOf ) { - return core_indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var l = second.length, - i = first.length, - j = 0; - - if ( typeof l === "number" ) { - for ( ; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var retVal, - ret = [], - i = 0, - length = elems.length; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, - i = 0, - length = elems.length, - isArray = isArraylike( elems ), - ret = []; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( i in elems ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return core_concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var args, proxy, tmp; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = core_slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - access: function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - length = elems.length, - bulk = key == null; - - // Sets many values - if ( jQuery.type( key ) === "object" ) { - chainable = true; - for ( i in key ) { - jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !jQuery.isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < length; i++ ) { - fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[0], key ) : emptyGet; - }, - - now: function() { - return ( new Date() ).getTime(); - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations. - // Note: this method belongs to the css module but it's needed here for the support module. - // If support gets modularized, this method should be moved back to the css module. - swap: function( elem, options, callback, args ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.apply( elem, args || [] ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; - } -}); - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", completed, false ); - - // If IE event model is used - } else { - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", completed ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", completed ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch(e) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch(e) { - return setTimeout( doScrollCheck, 50 ); - } - - // detach all dom ready events - detach(); - - // and execute any waiting functions - jQuery.ready(); - } - })(); - } - } - } - return readyList.promise( obj ); -}; - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -function isArraylike( obj ) { - var length = obj.length, - type = jQuery.type( obj ); - - if ( jQuery.isWindow( obj ) ) { - return false; - } - - if ( obj.nodeType === 1 && length ) { - return true; - } - - return type === "array" || type !== "function" && - ( length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj ); -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); -/*! - * Sizzle CSS Selector Engine v1.10.2 - * http://sizzlejs.com/ - * - * Copyright 2013 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2013-07-03 - */ -(function( window, undefined ) { - -var i, - support, - cachedruns, - Expr, - getText, - isXML, - compile, - outermostContext, - sortInput, - - // Local document vars - setDocument, - document, - docElem, - documentIsHTML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - - // Instance-specific data - expando = "sizzle" + -(new Date()), - preferredDoc = window.document, - dirruns = 0, - done = 0, - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - hasDuplicate = false, - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - return 0; - }, - - // General-purpose constants - strundefined = typeof undefined, - MAX_NEGATIVE = 1 << 31, - - // Instance methods - hasOwn = ({}).hasOwnProperty, - arr = [], - pop = arr.pop, - push_native = arr.push, - push = arr.push, - slice = arr.slice, - // Use a stripped-down indexOf if we can't use a native one - indexOf = arr.indexOf || function( elem ) { - var i = 0, - len = this.length; - for ( ; i < len; i++ ) { - if ( this[i] === elem ) { - return i; - } - } - return -1; - }, - - booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", - - // Regular expressions - - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace( "w", "w#" ), - - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors - attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + - "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - - // Prefer arguments quoted, - // then not containing pseudos/brackets, - // then attribute selectors/non-parenthetical expressions, - // then anything else - // These preferences are here to reduce the number of selectors - // needing tokenize in the PSEUDO preFilter - pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), - - rsibling = new RegExp( whitespace + "*[+~]" ), - rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ), - - rpseudo = new RegExp( pseudos ), - ridentifier = new RegExp( "^" + identifier + "$" ), - - matchExpr = { - "ID": new RegExp( "^#(" + characterEncoding + ")" ), - "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), - "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), - // For use in libraries implementing .is() - // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + - whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) - }, - - rnative = /^[^{]+\{\s*\[native \w/, - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - - rescape = /'|\\/g, - - // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), - funescape = function( _, escaped, escapedWhitespace ) { - var high = "0x" + escaped - 0x10000; - // NaN means non-codepoint - // Support: Firefox - // Workaround erroneous numeric interpretation of +"0x" - return high !== high || escapedWhitespace ? - escaped : - // BMP codepoint - high < 0 ? - String.fromCharCode( high + 0x10000 ) : - // Supplemental Plane codepoint (surrogate pair) - String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); - }; - -// Optimize for push.apply( _, NodeList ) -try { - push.apply( - (arr = slice.call( preferredDoc.childNodes )), - preferredDoc.childNodes - ); - // Support: Android<4.0 - // Detect silently failing push.apply - arr[ preferredDoc.childNodes.length ].nodeType; -} catch ( e ) { - push = { apply: arr.length ? - - // Leverage slice if possible - function( target, els ) { - push_native.apply( target, slice.call(els) ); - } : - - // Support: IE<9 - // Otherwise append directly - function( target, els ) { - var j = target.length, - i = 0; - // Can't trust NodeList.length - while ( (target[j++] = els[i++]) ) {} - target.length = j - 1; - } - }; -} - -function Sizzle( selector, context, results, seed ) { - var match, elem, m, nodeType, - // QSA vars - i, groups, old, nid, newContext, newSelector; - - if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { - setDocument( context ); - } - - context = context || document; - results = results || []; - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { - return []; - } - - if ( documentIsHTML && !seed ) { - - // Shortcuts - if ( (match = rquickExpr.exec( selector )) ) { - // Speed-up: Sizzle("#ID") - if ( (m = match[1]) ) { - if ( nodeType === 9 ) { - elem = context.getElementById( m ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - } else { - // Context is not a document - if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && - contains( context, elem ) && elem.id === m ) { - results.push( elem ); - return results; - } - } - - // Speed-up: Sizzle("TAG") - } else if ( match[2] ) { - push.apply( results, context.getElementsByTagName( selector ) ); - return results; - - // Speed-up: Sizzle(".CLASS") - } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { - push.apply( results, context.getElementsByClassName( m ) ); - return results; - } - } - - // QSA path - if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { - nid = old = expando; - newContext = context; - newSelector = nodeType === 9 && selector; - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - groups = tokenize( selector ); - - if ( (old = context.getAttribute("id")) ) { - nid = old.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", nid ); - } - nid = "[id='" + nid + "'] "; - - i = groups.length; - while ( i-- ) { - groups[i] = nid + toSelector( groups[i] ); - } - newContext = rsibling.test( selector ) && context.parentNode || context; - newSelector = groups.join(","); - } - - if ( newSelector ) { - try { - push.apply( results, - newContext.querySelectorAll( newSelector ) - ); - return results; - } catch(qsaError) { - } finally { - if ( !old ) { - context.removeAttribute("id"); - } - } - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed ); -} - -/** - * Create key-value caches of limited size - * @returns {Function(string, Object)} Returns the Object data after storing it on itself with - * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) - * deleting the oldest entry - */ -function createCache() { - var keys = []; - - function cache( key, value ) { - // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if ( keys.push( key += " " ) > Expr.cacheLength ) { - // Only keep the most recent entries - delete cache[ keys.shift() ]; - } - return (cache[ key ] = value); - } - return cache; -} - -/** - * Mark a function for special use by Sizzle - * @param {Function} fn The function to mark - */ -function markFunction( fn ) { - fn[ expando ] = true; - return fn; -} - -/** - * Support testing using an element - * @param {Function} fn Passed the created div and expects a boolean result - */ -function assert( fn ) { - var div = document.createElement("div"); - - try { - return !!fn( div ); - } catch (e) { - return false; - } finally { - // Remove from its parent by default - if ( div.parentNode ) { - div.parentNode.removeChild( div ); - } - // release memory in IE - div = null; - } -} - -/** - * Adds the same handler for all of the specified attrs - * @param {String} attrs Pipe-separated list of attributes - * @param {Function} handler The method that will be applied - */ -function addHandle( attrs, handler ) { - var arr = attrs.split("|"), - i = attrs.length; - - while ( i-- ) { - Expr.attrHandle[ arr[i] ] = handler; - } -} - -/** - * Checks document order of two siblings - * @param {Element} a - * @param {Element} b - * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b - */ -function siblingCheck( a, b ) { - var cur = b && a, - diff = cur && a.nodeType === 1 && b.nodeType === 1 && - ( ~b.sourceIndex || MAX_NEGATIVE ) - - ( ~a.sourceIndex || MAX_NEGATIVE ); - - // Use IE sourceIndex if available on both nodes - if ( diff ) { - return diff; - } - - // Check if b follows a - if ( cur ) { - while ( (cur = cur.nextSibling) ) { - if ( cur === b ) { - return -1; - } - } - } - - return a ? 1 : -1; -} - -/** - * Returns a function to use in pseudos for input types - * @param {String} type - */ -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for buttons - * @param {String} type - */ -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for positionals - * @param {Function} fn - */ -function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { - argument = +argument; - return markFunction(function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); -} - -/** - * Detect xml - * @param {Element|Object} elem An element or a document - */ -isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -// Expose support vars for convenience -support = Sizzle.support = {}; - -/** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ -setDocument = Sizzle.setDocument = function( node ) { - var doc = node ? node.ownerDocument || node : preferredDoc, - parent = doc.defaultView; - - // If no document and documentElement is available, return - if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { - return document; - } - - // Set our document - document = doc; - docElem = doc.documentElement; - - // Support tests - documentIsHTML = !isXML( doc ); - - // Support: IE>8 - // If iframe document is assigned to "document" variable and if iframe has been reloaded, - // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 - // IE6-8 do not support the defaultView property so parent will be undefined - if ( parent && parent.attachEvent && parent !== parent.top ) { - parent.attachEvent( "onbeforeunload", function() { - setDocument(); - }); - } - - /* Attributes - ---------------------------------------------------------------------- */ - - // Support: IE<8 - // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) - support.attributes = assert(function( div ) { - div.className = "i"; - return !div.getAttribute("className"); - }); - - /* getElement(s)By* - ---------------------------------------------------------------------- */ - - // Check if getElementsByTagName("*") returns only elements - support.getElementsByTagName = assert(function( div ) { - div.appendChild( doc.createComment("") ); - return !div.getElementsByTagName("*").length; - }); - - // Check if getElementsByClassName can be trusted - support.getElementsByClassName = assert(function( div ) { - div.innerHTML = "
"; - - // Support: Safari<4 - // Catch class over-caching - div.firstChild.className = "i"; - // Support: Opera<10 - // Catch gEBCN failure to find non-leading classes - return div.getElementsByClassName("i").length === 2; - }); - - // Support: IE<10 - // Check if getElementById returns elements by name - // The broken getElementById methods don't pick up programatically-set names, - // so use a roundabout getElementsByName test - support.getById = assert(function( div ) { - docElem.appendChild( div ).id = expando; - return !doc.getElementsByName || !doc.getElementsByName( expando ).length; - }); - - // ID find and filter - if ( support.getById ) { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && documentIsHTML ) { - var m = context.getElementById( id ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - return elem.getAttribute("id") === attrId; - }; - }; - } else { - // Support: IE6/7 - // getElementById is not reliable as a find shortcut - delete Expr.find["ID"]; - - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); - return node && node.value === attrId; - }; - }; - } - - // Tag - Expr.find["TAG"] = support.getElementsByTagName ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== strundefined ) { - return context.getElementsByTagName( tag ); - } - } : - function( tag, context ) { - var elem, - tmp = [], - i = 0, - results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - while ( (elem = results[i++]) ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }; - - // Class - Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { - return context.getElementsByClassName( className ); - } - }; - - /* QSA/matchesSelector - ---------------------------------------------------------------------- */ - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21) - // We allow this because of a bug in IE8/9 that throws an error - // whenever `document.activeElement` is accessed on an iframe - // So, we allow :focus to pass through QSA all the time to avoid the IE error - // See http://bugs.jquery.com/ticket/13378 - rbuggyQSA = []; - - if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function( div ) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explicitly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - div.innerHTML = ""; - - // Support: IE8 - // Boolean attributes and "value" are not treated correctly - if ( !div.querySelectorAll("[selected]").length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); - } - }); - - assert(function( div ) { - - // Support: Opera 10-12/IE8 - // ^= $= *= and empty values - // Should not select anything - // Support: Windows 8 Native Apps - // The type attribute is restricted during .innerHTML assignment - var input = doc.createElement("input"); - input.setAttribute( "type", "hidden" ); - div.appendChild( input ).setAttribute( "t", "" ); - - if ( div.querySelectorAll("[t^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":enabled").length ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Opera 10-11 does not throw on post-comma invalid pseudos - div.querySelectorAll("*,:x"); - rbuggyQSA.push(",.*:"); - }); - } - - if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || - docElem.mozMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector) )) ) { - - assert(function( div ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call( div, "div" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( div, "[s!='']:x" ); - rbuggyMatches.push( "!=", pseudos ); - }); - } - - rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); - rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); - - /* Contains - ---------------------------------------------------------------------- */ - - // Element contains another - // Purposefully does not implement inclusive descendent - // As in, an element does not contain itself - contains = rnative.test( docElem.contains ) || docElem.compareDocumentPosition ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); - } : - function( a, b ) { - if ( b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - /* Sorting - ---------------------------------------------------------------------- */ - - // Document order sorting - sortOrder = docElem.compareDocumentPosition ? - function( a, b ) { - - // Flag for duplicate removal - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); - - if ( compare ) { - // Disconnected nodes - if ( compare & 1 || - (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { - - // Choose the first element that is related to our preferred document - if ( a === doc || contains(preferredDoc, a) ) { - return -1; - } - if ( b === doc || contains(preferredDoc, b) ) { - return 1; - } - - // Maintain original order - return sortInput ? - ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : - 0; - } - - return compare & 4 ? -1 : 1; - } - - // Not directly comparable, sort on existence of method - return a.compareDocumentPosition ? -1 : 1; - } : - function( a, b ) { - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [ a ], - bp = [ b ]; - - // Exit early if the nodes are identical - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Parentless nodes are either documents or disconnected - } else if ( !aup || !bup ) { - return a === doc ? -1 : - b === doc ? 1 : - aup ? -1 : - bup ? 1 : - sortInput ? - ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : - 0; - - // If the nodes are siblings, we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - while ( (cur = cur.parentNode) ) { - ap.unshift( cur ); - } - cur = b; - while ( (cur = cur.parentNode) ) { - bp.unshift( cur ); - } - - // Walk down the tree looking for a discrepancy - while ( ap[i] === bp[i] ) { - i++; - } - - return i ? - // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[i], bp[i] ) : - - // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : - 0; - }; - - return doc; -}; - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, null, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); - - if ( support.matchesSelector && documentIsHTML && - ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && - ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { - - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch(e) {} - } - - return Sizzle( expr, document, null, [elem] ).length > 0; -}; - -Sizzle.contains = function( context, elem ) { - // Set document vars if needed - if ( ( context.ownerDocument || context ) !== document ) { - setDocument( context ); - } - return contains( context, elem ); -}; - -Sizzle.attr = function( elem, name ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - var fn = Expr.attrHandle[ name.toLowerCase() ], - // Don't get fooled by Object.prototype properties (jQuery #13807) - val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? - fn( elem, name, !documentIsHTML ) : - undefined; - - return val === undefined ? - support.attributes || !documentIsHTML ? - elem.getAttribute( name ) : - (val = elem.getAttributeNode(name)) && val.specified ? - val.value : - null : - val; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -/** - * Document sorting and removing duplicates - * @param {ArrayLike} results - */ -Sizzle.uniqueSort = function( results ) { - var elem, - duplicates = [], - j = 0, - i = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - sortInput = !support.sortStable && results.slice( 0 ); - results.sort( sortOrder ); - - if ( hasDuplicate ) { - while ( (elem = results[i++]) ) { - if ( elem === results[ i ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - return results; -}; - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( !nodeType ) { - // If no nodeType, this is expected to be an array - for ( ; (node = elem[i]); i++ ) { - // Do not traverse comment nodes - ret += getText( node ); - } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (see #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - - return ret; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - attrHandle: {}, - - find: {}, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[1] = match[1].replace( runescape, funescape ); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); - - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if ( match[1].slice( 0, 3 ) === "nth" ) { - // nth-* requires argument - if ( !match[3] ) { - Sizzle.error( match[0] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); - match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); - - // other types prohibit arguments - } else if ( match[3] ) { - Sizzle.error( match[0] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var excess, - unquoted = !match[5] && match[2]; - - if ( matchExpr["CHILD"].test( match[0] ) ) { - return null; - } - - // Accept quoted arguments as-is - if ( match[3] && match[4] !== undefined ) { - match[2] = match[4]; - - // Strip excess characters from unquoted arguments - } else if ( unquoted && rpseudo.test( unquoted ) && - // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - - // excess is a negative index - match[0] = match[0].slice( 0, excess ); - match[2] = unquoted.slice( 0, excess ); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - - "TAG": function( nodeNameSelector ) { - var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); - return nodeNameSelector === "*" ? - function() { return true; } : - function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ className + " " ]; - - return pattern || - (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && - classCache( className, function( elem ) { - return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); - }); - }, - - "ATTR": function( name, operator, check ) { - return function( elem ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.slice( -check.length ) === check : - operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : - false; - }; - }, - - "CHILD": function( type, what, argument, first, last ) { - var simple = type.slice( 0, 3 ) !== "nth", - forward = type.slice( -4 ) !== "last", - ofType = what === "of-type"; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function( elem ) { - return !!elem.parentNode; - } : - - function( elem, context, xml ) { - var cache, outerCache, node, diff, nodeIndex, start, - dir = simple !== forward ? "nextSibling" : "previousSibling", - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType; - - if ( parent ) { - - // :(first|last|only)-(child|of-type) - if ( simple ) { - while ( dir ) { - node = elem; - while ( (node = node[ dir ]) ) { - if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { - return false; - } - } - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === "only" && !start && "nextSibling"; - } - return true; - } - - start = [ forward ? parent.firstChild : parent.lastChild ]; - - // non-xml :nth-child(...) stores cache data on `parent` - if ( forward && useCache ) { - // Seek `elem` from a previously-cached index - outerCache = parent[ expando ] || (parent[ expando ] = {}); - cache = outerCache[ type ] || []; - nodeIndex = cache[0] === dirruns && cache[1]; - diff = cache[0] === dirruns && cache[2]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while ( (node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) ) { - - // When found, cache indexes on `parent` and break - if ( node.nodeType === 1 && ++diff && node === elem ) { - outerCache[ type ] = [ dirruns, nodeIndex, diff ]; - break; - } - } - - // Use previously-cached element index if available - } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { - diff = cache[1]; - - // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) - } else { - // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { - - if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { - // Cache the index of each encountered element - if ( useCache ) { - (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; - } - - if ( node === elem ) { - break; - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf.call( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); - } - }) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - // Potentially complex pseudos - "not": markFunction(function( selector ) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function( elem, context, xml ) { - input[0] = elem; - matcher( input, null, xml, results ); - return !results.pop(); - }; - }), - - "has": markFunction(function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - }), - - "contains": markFunction(function( text ) { - return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; - }; - }), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - "lang": markFunction( function( lang ) { - // lang value must be a valid identifier - if ( !ridentifier.test(lang || "") ) { - Sizzle.error( "unsupported lang: " + lang ); - } - lang = lang.replace( runescape, funescape ).toLowerCase(); - return function( elem ) { - var elemLang; - do { - if ( (elemLang = documentIsHTML ? - elem.lang : - elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { - - elemLang = elemLang.toLowerCase(); - return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; - } - } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); - return false; - }; - }), - - // Miscellaneous - "target": function( elem ) { - var hash = window.location && window.location.hash; - return hash && hash.slice( 1 ) === elem.id; - }, - - "root": function( elem ) { - return elem === docElem; - }, - - "focus": function( elem ) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); - }, - - // Boolean properties - "enabled": function( elem ) { - return elem.disabled === false; - }, - - "disabled": function( elem ) { - return elem.disabled === true; - }, - - "checked": function( elem ) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); - }, - - "selected": function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), - // not comment, processing instructions, or others - // Thanks to Diego Perini for the nodeName shortcut - // Greater than "@" means alpha characters (specifically not starting with "#" or "?") - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { - return false; - } - } - return true; - }, - - "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); - }, - - // Element/input types - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "text": function( elem ) { - var attr; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && - elem.type === "text" && - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); - }, - - // Position-in-collection - "first": createPositionalPseudo(function() { - return [ 0 ]; - }), - - "last": createPositionalPseudo(function( matchIndexes, length ) { - return [ length - 1 ]; - }), - - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - }), - - "even": createPositionalPseudo(function( matchIndexes, length ) { - var i = 0; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "odd": createPositionalPseudo(function( matchIndexes, length ) { - var i = 1; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }) - } -}; - -Expr.pseudos["nth"] = Expr.pseudos["eq"]; - -// Add button/input type pseudos -for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { - Expr.pseudos[ i ] = createInputPseudo( i ); -} -for ( i in { submit: true, reset: true } ) { - Expr.pseudos[ i ] = createButtonPseudo( i ); -} - -// Easy API for creating new setFilters -function setFilters() {} -setFilters.prototype = Expr.filters = Expr.pseudos; -Expr.setFilters = new setFilters(); - -function tokenize( selector, parseOnly ) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ selector + " " ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { - if ( match ) { - // Don't consume trailing commas as valid - soFar = soFar.slice( match[0].length ) || soFar; - } - groups.push( tokens = [] ); - } - - matched = false; - - // Combinators - if ( (match = rcombinators.exec( soFar )) ) { - matched = match.shift(); - tokens.push({ - value: matched, - // Cast descendant combinators to space - type: match[0].replace( rtrim, " " ) - }); - soFar = soFar.slice( matched.length ); - } - - // Filters - for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - (match = preFilters[ type ]( match ))) ) { - matched = match.shift(); - tokens.push({ - value: matched, - type: type, - matches: match - }); - soFar = soFar.slice( matched.length ); - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -} - -function toSelector( tokens ) { - var i = 0, - len = tokens.length, - selector = ""; - for ( ; i < len; i++ ) { - selector += tokens[i].value; - } - return selector; -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - checkNonElements = base && dir === "parentNode", - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - return matcher( elem, context, xml ); - } - } - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - var data, cache, outerCache, - dirkey = dirruns + " " + doneName; - - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching - if ( xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - if ( matcher( elem, context, xml ) ) { - return true; - } - } - } - } else { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); - if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { - if ( (data = cache[1]) === true || data === cachedruns ) { - return data === true; - } - } else { - cache = outerCache[ dir ] = [ dirkey ]; - cache[1] = matcher( elem, context, xml ) || cachedruns; - if ( cache[1] === true ) { - return true; - } - } - } - } - } - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[0]; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction(function( seed, results, context, xml ) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - temp = condense( matcherOut, postMap ); - postFilter( temp, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - while ( i-- ) { - if ( (elem = temp[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - if ( seed ) { - if ( postFinder || preFilter ) { - if ( postFinder ) { - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) ) { - // Restore matcherIn since elem is not yet a final match - temp.push( (matcherIn[i] = elem) ); - } - } - postFinder( null, (matcherOut = []), temp, xml ); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { - - seed[temp] = !(results[temp] = elem); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - }); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf.call( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - } ]; - - for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; - } else { - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && toSelector( - // If the preceding token was a descendant combinator, insert an implicit any-element `*` - tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) - ).replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), - j < len && toSelector( tokens ) - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - // A counter to specify which element is currently being matched - var matcherCachedRuns = 0, - bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, expandContext ) { - var elem, j, matcher, - setMatched = [], - matchedCount = 0, - i = "0", - unmatched = seed && [], - outermost = expandContext != null, - contextBackup = outermostContext, - // We must always have either seed elements or context - elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), - // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); - - if ( outermost ) { - outermostContext = context !== document && context; - cachedruns = matcherCachedRuns; - } - - // Add elements passing elementMatchers directly to results - // Keep `i` a string if there are no elements so `matchedCount` will be "00" below - for ( ; (elem = elems[i]) != null; i++ ) { - if ( byElement && elem ) { - j = 0; - while ( (matcher = elementMatchers[j++]) ) { - if ( matcher( elem, context, xml ) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - cachedruns = ++matcherCachedRuns; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // Apply set filters to unmatched elements - matchedCount += i; - if ( bySet && i !== matchedCount ) { - j = 0; - while ( (matcher = setMatchers[j++]) ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ selector + " " ]; - - if ( !cached ) { - // Generate a function of recursive functions that can be used to check each element - if ( !group ) { - group = tokenize( selector ); - } - i = group.length; - while ( i-- ) { - cached = matcherFromTokens( group[i] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); - } - return cached; -}; - -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); - } - return results; -} - -function select( selector, context, results, seed ) { - var i, tokens, token, type, find, - match = tokenize( selector ); - - if ( !seed ) { - // Try to minimize operations if there is only one group - if ( match.length === 1 ) { - - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - support.getById && context.nodeType === 9 && documentIsHTML && - Expr.relative[ tokens[1].type ] ) { - - context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; - if ( !context ) { - return results; - } - selector = selector.slice( tokens.shift().value.length ); - } - - // Fetch a seed set for right-to-left matching - i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; - while ( i-- ) { - token = tokens[i]; - - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( runescape, funescape ), - rsibling.test( tokens[0].type ) && context.parentNode || context - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && toSelector( tokens ); - if ( !selector ) { - push.apply( results, seed ); - return results; - } - - break; - } - } - } - } - } - - // Compile and execute a filtering function - // Provide `match` to avoid retokenization if we modified the selector above - compile( selector, match )( - seed, - context, - !documentIsHTML, - results, - rsibling.test( selector ) - ); - return results; -} - -// One-time assignments - -// Sort stability -support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; - -// Support: Chrome<14 -// Always assume duplicates if they aren't passed to the comparison function -support.detectDuplicates = hasDuplicate; - -// Initialize against the default document -setDocument(); - -// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) -// Detached nodes confoundingly follow *each other* -support.sortDetached = assert(function( div1 ) { - // Should return 1, but returns 4 (following) - return div1.compareDocumentPosition( document.createElement("div") ) & 1; -}); - -// Support: IE<8 -// Prevent attribute/property "interpolation" -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !assert(function( div ) { - div.innerHTML = ""; - return div.firstChild.getAttribute("href") === "#" ; -}) ) { - addHandle( "type|href|height|width", function( elem, name, isXML ) { - if ( !isXML ) { - return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); - } - }); -} - -// Support: IE<9 -// Use defaultValue in place of getAttribute("value") -if ( !support.attributes || !assert(function( div ) { - div.innerHTML = ""; - div.firstChild.setAttribute( "value", "" ); - return div.firstChild.getAttribute( "value" ) === ""; -}) ) { - addHandle( "value", function( elem, name, isXML ) { - if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { - return elem.defaultValue; - } - }); -} - -// Support: IE<9 -// Use getAttributeNode to fetch booleans when getAttribute lies -if ( !assert(function( div ) { - return div.getAttribute("disabled") == null; -}) ) { - addHandle( booleans, function( elem, name, isXML ) { - var val; - if ( !isXML ) { - return (val = elem.getAttributeNode( name )) && val.specified ? - val.value : - elem[ name ] === true ? name.toLowerCase() : null; - } - }); -} - -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.pseudos; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})( window ); -// String to Object options format cache -var optionsCache = {}; - -// Convert String-formatted options into Object-formatted ones and store in cache -function createOptions( options ) { - var object = optionsCache[ options ] = {}; - jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { - object[ flag ] = true; - }); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - ( optionsCache[ options ] || createOptions( options ) ) : - jQuery.extend( {}, options ); - - var // Flag to know if list is currently firing - firing, - // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // First callback to fire (used internally by add and fireWith) - firingStart, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function( data ) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - if ( list ) { - if ( stack ) { - if ( stack.length ) { - fire( stack.shift() ); - } - } else if ( memory ) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - // First, we save the current length - var start = list.length; - (function add( args ) { - jQuery.each( args, function( _, arg ) { - var type = jQuery.type( arg ); - if ( type === "function" ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && type !== "string" ) { - // Inspect recursively - add( arg ); - } - }); - })( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if ( memory ) { - firingStart = start; - fire( memory ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - jQuery.each( arguments, function( _, arg ) { - var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - // Handle firing indexes - if ( firing ) { - if ( index <= firingLength ) { - firingLength--; - } - if ( index <= firingIndex ) { - firingIndex--; - } - } - } - }); - } - return this; - }, - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function( fn ) { - return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); - }, - // Remove all callbacks from the list - empty: function() { - list = []; - firingLength = 0; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - if ( list && ( !fired || stack ) ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - if ( firing ) { - stack.push( args ); - } else { - fire( args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; -jQuery.extend({ - - Deferred: function( func ) { - var tuples = [ - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred(function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var action = tuple[ 0 ], - fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ](function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); - } - }); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - - // Handle state - if ( stateString ) { - list.add(function() { - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } - - // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); - return this; - }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = core_slice.call( arguments ), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, - - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; - if( values === progressValues ) { - deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ) - .progress( updateFunc( i, progressContexts, progressValues ) ); - } else { - --remaining; - } - } - } - - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); - } - - return deferred.promise(); - } -}); -jQuery.support = (function( support ) { - - var all, a, input, select, fragment, opt, eventName, isSupported, i, - div = document.createElement("div"); - - // Setup - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; - - // Finish early in limited (non-browser) environments - all = div.getElementsByTagName("*") || []; - a = div.getElementsByTagName("a")[ 0 ]; - if ( !a || !a.style || !all.length ) { - return support; - } - - // First batch of tests - select = document.createElement("select"); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName("input")[ 0 ]; - - a.style.cssText = "top:1px;float:left;opacity:.5"; - - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - support.getSetAttribute = div.className !== "t"; - - // IE strips leading whitespace when .innerHTML is used - support.leadingWhitespace = div.firstChild.nodeType === 3; - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - support.tbody = !div.getElementsByTagName("tbody").length; - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - support.htmlSerialize = !!div.getElementsByTagName("link").length; - - // Get the style information from getAttribute - // (IE uses .cssText instead) - support.style = /top/.test( a.getAttribute("style") ); - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - support.hrefNormalized = a.getAttribute("href") === "/a"; - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - support.opacity = /^0.5/.test( a.style.opacity ); - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - support.cssFloat = !!a.style.cssFloat; - - // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) - support.checkOn = !!input.value; - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - support.optSelected = opt.selected; - - // Tests for enctype support on a form (#6743) - support.enctype = !!document.createElement("form").enctype; - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>"; - - // Will be defined later - support.inlineBlockNeedsLayout = false; - support.shrinkWrapBlocks = false; - support.pixelPosition = false; - support.deleteExpando = true; - support.noCloneEvent = true; - support.reliableMarginRight = true; - support.boxSizingReliable = true; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Support: IE<9 - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - // Check if we can trust getAttribute("value") - input = document.createElement("input"); - input.setAttribute( "value", "" ); - support.input = input.getAttribute( "value" ) === ""; - - // Check if an input maintains its value after becoming a radio - input.value = "t"; - input.setAttribute( "type", "radio" ); - support.radioValue = input.value === "t"; - - // #11217 - WebKit loses check when the name is after the checked attribute - input.setAttribute( "checked", "t" ); - input.setAttribute( "name", "t" ); - - fragment = document.createDocumentFragment(); - fragment.appendChild( input ); - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Support: IE<9 - // Opera does not clone events (and typeof div.attachEvent === undefined). - // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() - if ( div.attachEvent ) { - div.attachEvent( "onclick", function() { - support.noCloneEvent = false; - }); - - div.cloneNode( true ).click(); - } - - // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event) - // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) - for ( i in { submit: true, change: true, focusin: true }) { - div.setAttribute( eventName = "on" + i, "t" ); - - support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false; - } - - div.style.backgroundClip = "content-box"; - div.cloneNode( true ).style.backgroundClip = ""; - support.clearCloneStyle = div.style.backgroundClip === "content-box"; - - // Support: IE<9 - // Iteration over object's inherited properties before its own. - for ( i in jQuery( support ) ) { - break; - } - support.ownLast = i !== "0"; - - // Run tests that need a body at doc ready - jQuery(function() { - var container, marginDiv, tds, - divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", - body = document.getElementsByTagName("body")[0]; - - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } - - container = document.createElement("div"); - container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; - - body.appendChild( container ).appendChild( div ); - - // Support: IE8 - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Support: IE8 - // Check if empty table cells still have offsetWidth/Height - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - - // Check box-sizing and margin behavior. - div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; - - // Workaround failing boxSizing test due to offsetWidth returning wrong value - // with some non-1 values of body zoom, ticket #13543 - jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { - support.boxSizing = div.offsetWidth === 4; - }); - - // Use window.getComputedStyle because jsdom on node.js will break without it. - if ( window.getComputedStyle ) { - support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; - support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. (#3333) - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - marginDiv = div.appendChild( document.createElement("div") ); - marginDiv.style.cssText = div.style.cssText = divReset; - marginDiv.style.marginRight = marginDiv.style.width = "0"; - div.style.width = "1px"; - - support.reliableMarginRight = - !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); - } - - if ( typeof div.style.zoom !== core_strundefined ) { - // Support: IE<8 - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - div.innerHTML = ""; - div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); - - // Support: IE6 - // Check if elements with layout shrink-wrap their children - div.style.display = "block"; - div.innerHTML = "
"; - div.firstChild.style.width = "5px"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - - if ( support.inlineBlockNeedsLayout ) { - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - // Support: IE<8 - body.style.zoom = 1; - } - } - - body.removeChild( container ); - - // Null elements to avoid leaks in IE - container = div = tds = marginDiv = null; - }); - - // Null elements to avoid leaks in IE - all = select = fragment = opt = a = input = null; - - return support; -})({}); - -var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, - rmultiDash = /([A-Z])/g; - -function internalData( elem, name, data, pvt /* Internal Use Only */ ){ - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var ret, thisCache, - internalKey = jQuery.expando, - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - // Avoid exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( typeof name === "string" ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; -} - -function internalRemoveData( elem, name, pvt ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, i, - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split(" "); - } - } - } else { - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = name.concat( jQuery.map( name, jQuery.camelCase ) ); - } - - i = name.length; - while ( i-- ) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } - - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); - - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - /* jshint eqeqeq: false */ - } else if ( jQuery.support.deleteExpando || cache != cache.window ) { - /* jshint eqeqeq: true */ - delete cache[ id ]; - - // When all else fails, null - } else { - cache[ id ] = null; - } -} - -jQuery.extend({ - cache: {}, - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "applet": true, - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data ) { - return internalData( elem, name, data ); - }, - - removeData: function( elem, name ) { - return internalRemoveData( elem, name ); - }, - - // For internal use only. - _data: function( elem, name, data ) { - return internalData( elem, name, data, true ); - }, - - _removeData: function( elem, name ) { - return internalRemoveData( elem, name, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - // Do not set data on non-element because it will not be cleared (#8335). - if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) { - return false; - } - - var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; - - // nodes accept data unless otherwise specified; rejection can be conditional - return !noData || noData !== true && elem.getAttribute("classid") === noData; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var attrs, name, - data = null, - i = 0, - elem = this[0]; - - // Special expections of .data basically thwart jQuery.access, - // so implement the relevant behavior ourselves - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); - - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - attrs = elem.attributes; - for ( ; i < attrs.length; i++ ) { - name = attrs[i].name; - - if ( name.indexOf("data-") === 0 ) { - name = jQuery.camelCase( name.slice(5) ); - - dataAttr( elem, name, data[ name ] ); - } - } - jQuery._data( elem, "parsedAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - return arguments.length > 1 ? - - // Sets one value - this.each(function() { - jQuery.data( this, key, value ); - }) : - - // Gets one value - // Try to fetch any internally stored data first - elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} -jQuery.extend({ - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray(data) ) { - queue = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // not intended for public consumption - generates a queueHooks object, or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks("once memory").add(function() { - jQuery._removeData( elem, type + "queue" ); - jQuery._removeData( elem, key ); - }) - }); - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[0], type ); - } - - return data === undefined ? - this : - this.each(function() { - var queue = jQuery.queue( this, type, data ); - - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -}); -var nodeHook, boolHook, - rclass = /[\t\r\n\f]/g, - rreturn = /\r/g, - rfocusable = /^(?:input|select|textarea|button|object)$/i, - rclickable = /^(?:a|area)$/i, - ruseDefault = /^(?:checked|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - getSetInput = jQuery.support.input; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call( this, j, this.className ) ); - }); - } - - if ( proceed ) { - // The disjunction here is for better compressibility (see removeClass) - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " " - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; - } - } - elem.className = jQuery.trim( cur ); - - } - } - } - - return this; - }, - - removeClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = arguments.length === 0 || typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call( this, j, this.className ) ); - }); - } - if ( proceed ) { - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - "" - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { - cur = cur.replace( " " + clazz + " ", " " ); - } - } - elem.className = value ? jQuery.trim( cur ) : ""; - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value; - - if ( typeof stateVal === "boolean" && type === "string" ) { - return stateVal ? this.addClass( value ) : this.removeClass( value ); - } - - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - classNames = value.match( core_rnotwhite ) || []; - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space separated list - if ( self.hasClass( className ) ) { - self.removeClass( className ); - } else { - self.addClass( className ); - } - } - - // Toggle whole class name - } else if ( type === core_strundefined || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // If the element has a class name or if we're passed "false", - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var ret, hooks, isFunction, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return; - } - - isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var val; - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, jQuery( this ).val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // Use proper attribute retrieval(#6932, #12072) - var val = jQuery.find.attr( elem, "value" ); - return val != null ? - val : - elem.text; - } - }, - select: { - get: function( elem ) { - var value, option, - options = elem.options, - index = elem.selectedIndex, - one = elem.type === "select-one" || index < 0, - values = one ? null : [], - max = one ? index + 1 : options.length, - i = index < 0 ? - max : - one ? index : 0; - - // Loop through all the selected options - for ( ; i < max; i++ ) { - option = options[ i ]; - - // oldIE doesn't update selected after form reset (#2551) - if ( ( option.selected || i === index ) && - // Don't return options that are disabled or in a disabled optgroup - ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && - ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - }, - - set: function( elem, value ) { - var optionSet, option, - options = elem.options, - values = jQuery.makeArray( value ), - i = options.length; - - while ( i-- ) { - option = options[ i ]; - if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { - optionSet = true; - } - } - - // force browsers to behave consistently when non-matching value is set - if ( !optionSet ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - attr: function( elem, name, value ) { - var hooks, ret, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === core_strundefined ) { - return jQuery.prop( elem, name, value ); - } - - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || - ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - - } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, value + "" ); - return value; - } - - } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - ret = jQuery.find.attr( elem, name ); - - // Non-existent attributes return null, we normalize to undefined - return ret == null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var name, propName, - i = 0, - attrNames = value && value.match( core_rnotwhite ); - - if ( attrNames && elem.nodeType === 1 ) { - while ( (name = attrNames[i++]) ) { - propName = jQuery.propFix[ name ] || name; - - // Boolean attributes get special treatment (#10870) - if ( jQuery.expr.match.bool.test( name ) ) { - // Set corresponding property to false - if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - elem[ propName ] = false; - // Support: IE<9 - // Also clear defaultChecked/defaultSelected (if appropriate) - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = - elem[ propName ] = false; - } - - // See #9699 for explanation of this approach (setting first, then removal) - } else { - jQuery.attr( elem, name, "" ); - } - - elem.removeAttribute( getSetAttribute ? name : propName ); - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to default in case type is set after value during creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - } - }, - - propFix: { - "for": "htmlFor", - "class": "className" - }, - - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? - ret : - ( elem[ name ] = value ); - - } else { - return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? - ret : - elem[ name ]; - } - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - // Use proper attribute retrieval(#12072) - var tabindex = jQuery.find.attr( elem, "tabindex" ); - - return tabindex ? - parseInt( tabindex, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - -1; - } - } - } -}); - -// Hooks for boolean attributes -boolHook = { - set: function( elem, value, name ) { - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - // IE<8 needs the *property* name - elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); - - // Use defaultChecked and defaultSelected for oldIE - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; - } - - return name; - } -}; -jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { - var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr; - - jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? - function( elem, name, isXML ) { - var fn = jQuery.expr.attrHandle[ name ], - ret = isXML ? - undefined : - /* jshint eqeqeq: false */ - (jQuery.expr.attrHandle[ name ] = undefined) != - getter( elem, name, isXML ) ? - - name.toLowerCase() : - null; - jQuery.expr.attrHandle[ name ] = fn; - return ret; - } : - function( elem, name, isXML ) { - return isXML ? - undefined : - elem[ jQuery.camelCase( "default-" + name ) ] ? - name.toLowerCase() : - null; - }; -}); - -// fix oldIE attroperties -if ( !getSetInput || !getSetAttribute ) { - jQuery.attrHooks.value = { - set: function( elem, value, name ) { - if ( jQuery.nodeName( elem, "input" ) ) { - // Does not return so that setAttribute is also used - elem.defaultValue = value; - } else { - // Use nodeHook if defined (#1954); otherwise setAttribute is fine - return nodeHook && nodeHook.set( elem, value, name ); - } - } - }; -} - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = { - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - elem.setAttributeNode( - (ret = elem.ownerDocument.createAttribute( name )) - ); - } - - ret.value = value += ""; - - // Break association with cloned elements by also using setAttribute (#9646) - return name === "value" || value === elem.getAttribute( name ) ? - value : - undefined; - } - }; - jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords = - // Some attributes are constructed with empty-string values when not defined - function( elem, name, isXML ) { - var ret; - return isXML ? - undefined : - (ret = elem.getAttributeNode( name )) && ret.value !== "" ? - ret.value : - null; - }; - jQuery.valHooks.button = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return ret && ret.specified ? - ret.value : - undefined; - }, - set: nodeHook.set - }; - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - set: function( elem, value, name ) { - nodeHook.set( elem, value === "" ? false : value, name ); - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }; - }); -} - - -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !jQuery.support.hrefNormalized ) { - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); - } - }; - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Note: IE uppercases css property names, but if we were to .toLowerCase() - // .cssText, that would destroy case senstitivity in URL's, like in "background" - return elem.style.cssText || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = value + "" ); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }; -} - -jQuery.each([ - "tabIndex", - "readOnly", - "maxLength", - "cellSpacing", - "cellPadding", - "rowSpan", - "colSpan", - "useMap", - "frameBorder", - "contentEditable" -], function() { - jQuery.propFix[ this.toLowerCase() ] = this; -}); - -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - -// Radios and checkboxes getter/setter -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); - } - } - }; - if ( !jQuery.support.checkOn ) { - jQuery.valHooks[ this ].get = function( elem ) { - // Support: Webkit - // "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - }; - } -}); -var rformElems = /^(?:input|select|textarea)$/i, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; - -function returnTrue() { - return true; -} - -function returnFalse() { - return false; -} - -function safeActiveElement() { - try { - return document.activeElement; - } catch ( err ) { } -} - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - global: {}, - - add: function( elem, types, handler, data, selector ) { - var tmp, events, t, handleObjIn, - special, eventHandle, handleObj, - handlers, type, namespaces, origType, - elemData = jQuery._data( elem ); - - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if ( !elemData ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - if ( !(events = elemData.events) ) { - events = elemData.events = {}; - } - if ( !(eventHandle = elemData.handle) ) { - eventHandle = elemData.handle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); - - // There *must* be a type, no attaching namespace-only handlers - if ( !type ) { - continue; - } - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); - - // Init the event handler queue if we're the first - if ( !(handlers = events[ type ]) ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - var j, handleObj, tmp, - origCount, t, events, - special, handlers, type, - namespaces, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); - - if ( !elemData || !(events = elemData.events) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector ? special.delegateType : special.bindType ) || type; - handlers = events[ type ] || []; - tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); - - // Remove matching events - origCount = j = handlers.length; - while ( j-- ) { - handleObj = handlers[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !tmp || tmp.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - handlers.splice( j, 1 ); - - if ( handleObj.selector ) { - handlers.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( origCount && !handlers.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery._removeData( elem, "events" ); - } - }, - - trigger: function( event, data, elem, onlyHandlers ) { - var handle, ontype, cur, - bubbleType, special, tmp, i, - eventPath = [ elem || document ], - type = core_hasOwn.call( event, "type" ) ? event.type : event, - namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; - - cur = tmp = elem = elem || document; - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf(".") >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf(":") < 0 && "on" + type; - - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event( type, typeof event === "object" && event ); - - // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) - event.isTrigger = onlyHandlers ? 2 : 3; - event.namespace = namespaces.join("."); - event.namespace_re = event.namespace ? - new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : - null; - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [ event ] : - jQuery.makeArray( data, [ event ] ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - if ( !rfocusMorph.test( bubbleType + type ) ) { - cur = cur.parentNode; - } - for ( ; cur; cur = cur.parentNode ) { - eventPath.push( cur ); - tmp = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( tmp === (elem.ownerDocument || document) ) { - eventPath.push( tmp.defaultView || tmp.parentWindow || window ); - } - } - - // Fire handlers on the event path - i = 0; - while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { - - event.type = i > 1 ? - bubbleType : - special.bindType || type; - - // jQuery handler - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - - // Native handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && - jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; - - if ( tmp ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - try { - elem[ type ](); - } catch ( e ) { - // IE<9 dies on focus/blur to hidden element (#1486,#12518) - // only reproducible on winXP IE8 native, not IE9 in IE8 mode - } - jQuery.event.triggered = undefined; - - if ( tmp ) { - elem[ ontype ] = tmp; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event ); - - var i, ret, handleObj, matched, j, - handlerQueue = [], - args = core_slice.call( arguments ), - handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers - handlerQueue = jQuery.event.handlers.call( this, event, handlers ); - - // Run delegates first; they may want to stop propagation beneath us - i = 0; - while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { - event.currentTarget = matched.elem; - - j = 0; - while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { - - // Triggered event must either 1) have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { - - event.handleObj = handleObj; - event.data = handleObj.data; - - ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) - .apply( matched.elem, args ); - - if ( ret !== undefined ) { - if ( (event.result = ret) === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - handlers: function( event, handlers ) { - var sel, handleObj, matches, i, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; - - // Find delegate handlers - // Black-hole SVG instance trees (#13180) - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { - - /* jshint eqeqeq: false */ - for ( ; cur != this; cur = cur.parentNode || this ) { - /* jshint eqeqeq: true */ - - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + " "; - - if ( matches[ sel ] === undefined ) { - matches[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) >= 0 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( matches[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, handlers: matches }); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if ( delegateCount < handlers.length ) { - handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); - } - - return handlerQueue; - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, copy, - type = event.type, - originalEvent = event, - fixHook = this.fixHooks[ type ]; - - if ( !fixHook ) { - this.fixHooks[ type ] = fixHook = - rmouseEvent.test( type ) ? this.mouseHooks : - rkeyEvent.test( type ) ? this.keyHooks : - {}; - } - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = new jQuery.Event( originalEvent ); - - i = copy.length; - while ( i-- ) { - prop = copy[ i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Support: IE<9 - // Fix target property (#1925) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Support: Chrome 23+, Safari? - // Target should not be a text node (#504, #13143) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // Support: IE<9 - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) - event.metaKey = !!event.metaKey; - - return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var body, eventDoc, doc, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - focus: { - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== safeActiveElement() && this.focus ) { - try { - this.focus(); - return false; - } catch ( e ) { - // Support: IE<9 - // If we error on focus to hidden element (#1486, #12518), - // let .trigger() run the handlers - } - } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === safeActiveElement() && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, - click: { - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { - this.click(); - return false; - } - }, - - // For cross-browser consistency, don't fire native .click() on links - _default: function( event ) { - return jQuery.nodeName( event.target, "a" ); - } - }, - - beforeunload: { - postDispatch: function( event ) { - - // Even when returnValue equals to undefined Firefox will still show alert - if ( event.result !== undefined ) { - event.originalEvent.returnValue = event.result; - } - } - } - }, - - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { - type: type, - isSimulated: true, - originalEvent: {} - } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - var name = "on" + type; - - if ( elem.detachEvent ) { - - // #8545, #7054, preventing memory leaks for custom events in IE6-8 - // detachEvent needed property on element, by name of that event, to properly expose it to GC - if ( typeof elem[ name ] === core_strundefined ) { - elem[ name ] = null; - } - - elem.detachEvent( name, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, - - preventDefault: function() { - var e = this.originalEvent; - - this.isDefaultPrevented = returnTrue; - if ( !e ) { - return; - } - - // If preventDefault exists, run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // Support: IE - // Otherwise set the returnValue property of the original event to false - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - var e = this.originalEvent; - - this.isPropagationStopped = returnTrue; - if ( !e ) { - return; - } - // If stopPropagation exists, run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - - // Support: IE - // Set the cancelBubble property of the original event to true - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - } -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -}); - -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !jQuery._data( form, "submitBubbles" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submit_bubble = true; - }); - jQuery._data( form, "submitBubbles", true ); - } - }); - // return undefined since we don't need an event listener - }, - - postDispatch: function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( event._submit_bubble ) { - delete event._submit_bubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - } - }, - - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; - } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; - } - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event, true ); - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - jQuery._data( elem, "changeBubbles", true ); - } - }); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return !rformElems.test( this.nodeName ); - } - }; -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - }); -} - -jQuery.fn.extend({ - - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var type, origFn; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } - - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on( types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - var elem = this[0]; - if ( elem ) { - return jQuery.event.trigger( type, data, elem, true ); - } - } -}); -var isSimple = /^.[^:#\[\.,]*$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - rneedsContext = jQuery.expr.match.needsContext, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var i, - ret = [], - self = this, - len = self.length; - - if ( typeof selector !== "string" ) { - return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }) ); - } - - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, self[ i ], ret ); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); - ret.selector = this.selector ? this.selector + " " + selector : selector; - return ret; - }, - - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; - - return this.filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector || [], true) ); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector || [], false) ); - }, - - is: function( selector ) { - return !!winnow( - this, - - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === "string" && rneedsContext.test( selector ) ? - jQuery( selector ) : - selector || [], - false - ).length; - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - ret = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( ; i < l; i++ ) { - for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { - // Always skip document fragments - if ( cur.nodeType < 11 && (pos ? - pos.index(cur) > -1 : - - // Don't pass non-elements to Sizzle - cur.nodeType === 1 && - jQuery.find.matchesSelector(cur, selectors)) ) { - - cur = ret.push( cur ); - break; - } - } - } - - return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( jQuery.unique(all) ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); - } -}); - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - - return cur; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( name.slice( -5 ) !== "Until" ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - if ( this.length > 1 ) { - // Remove duplicates - if ( !guaranteedUnique[ name ] ) { - ret = jQuery.unique( ret ); - } - - // Reverse order for parents* and prev-derivatives - if ( rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - } - - return this.pushStack( ret ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - var elem = elems[ 0 ]; - - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 && elem.nodeType === 1 ? - jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : - jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { - return elem.nodeType === 1; - })); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, not ) { - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep( elements, function( elem, i ) { - /* jshint -W018 */ - return !!qualifier.call( elem, i, elem ) !== not; - }); - - } - - if ( qualifier.nodeType ) { - return jQuery.grep( elements, function( elem ) { - return ( elem === qualifier ) !== not; - }); - - } - - if ( typeof qualifier === "string" ) { - if ( isSimple.test( qualifier ) ) { - return jQuery.filter( qualifier, elements, not ); - } - - qualifier = jQuery.filter( qualifier, elements ); - } - - return jQuery.grep( elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; - }); -} -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - -var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + - "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", - rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, - rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rtbody = /\s*$/g, - - // We have to close these tags to support XHTML (#13200) - wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
", "
" ], - area: [ 1, "", "" ], - param: [ 1, "", "" ], - thead: [ 1, "", "
" ], - tr: [ 2, "", "
" ], - col: [ 2, "", "
" ], - td: [ 3, "", "
" ], - - // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, - // unless wrapped in a div with non-breaking characters in front of it. - _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
", "
" ] - }, - safeFragment = createSafeFragment( document ), - fragmentDiv = safeFragment.appendChild( document.createElement("div") ); - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -jQuery.fn.extend({ - text: function( value ) { - return jQuery.access( this, function( value ) { - return value === undefined ? - jQuery.text( this ) : - this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); - }, null, value, arguments.length ); - }, - - append: function() { - return this.domManip( arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.appendChild( elem ); - } - }); - }, - - prepend: function() { - return this.domManip( arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.insertBefore( elem, target.firstChild ); - } - }); - }, - - before: function() { - return this.domManip( arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this ); - } - }); - }, - - after: function() { - return this.domManip( arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this.nextSibling ); - } - }); - }, - - // keepData is for internal use only--do not document - remove: function( selector, keepData ) { - var elem, - elems = selector ? jQuery.filter( selector, this ) : this, - i = 0; - - for ( ; (elem = elems[i]) != null; i++ ) { - - if ( !keepData && elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem ) ); - } - - if ( elem.parentNode ) { - if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { - setGlobalEval( getAll( elem, "script" ) ); - } - elem.parentNode.removeChild( elem ); - } - } - - return this; - }, - - empty: function() { - var elem, - i = 0; - - for ( ; (elem = this[i]) != null; i++ ) { - // Remove element nodes and prevent memory leaks - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - } - - // Remove any remaining nodes - while ( elem.firstChild ) { - elem.removeChild( elem.firstChild ); - } - - // If this is a select, ensure that it displays empty (#12336) - // Support: IE<9 - if ( elem.options && jQuery.nodeName( elem, "select" ) ) { - elem.options.length = 0; - } - } - - return this; - }, - - clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map( function () { - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - }); - }, - - html: function( value ) { - return jQuery.access( this, function( value ) { - var elem = this[0] || {}, - i = 0, - l = this.length; - - if ( value === undefined ) { - return elem.nodeType === 1 ? - elem.innerHTML.replace( rinlinejQuery, "" ) : - undefined; - } - - // See if we can take a shortcut and just use innerHTML - if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && - ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { - - value = value.replace( rxhtmlTag, "<$1>" ); - - try { - for (; i < l; i++ ) { - // Remove element nodes and prevent memory leaks - elem = this[i] || {}; - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch(e) {} - } - - if ( elem ) { - this.empty().append( value ); - } - }, null, value, arguments.length ); - }, - - replaceWith: function() { - var - // Snapshot the DOM in case .domManip sweeps something relevant into its fragment - args = jQuery.map( this, function( elem ) { - return [ elem.nextSibling, elem.parentNode ]; - }), - i = 0; - - // Make the changes, replacing each context element with the new content - this.domManip( arguments, function( elem ) { - var next = args[ i++ ], - parent = args[ i++ ]; - - if ( parent ) { - // Don't use the snapshot next if it has moved (#13810) - if ( next && next.parentNode !== parent ) { - next = this.nextSibling; - } - jQuery( this ).remove(); - parent.insertBefore( elem, next ); - } - // Allow new content to include elements from the context set - }, true ); - - // Force removal if there was no new content (e.g., from empty arguments) - return i ? this : this.remove(); - }, - - detach: function( selector ) { - return this.remove( selector, true ); - }, - - domManip: function( args, callback, allowIntersection ) { - - // Flatten any nested arrays - args = core_concat.apply( [], args ); - - var first, node, hasScripts, - scripts, doc, fragment, - i = 0, - l = this.length, - set = this, - iNoClone = l - 1, - value = args[0], - isFunction = jQuery.isFunction( value ); - - // We can't cloneNode fragments that contain checked, in WebKit - if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { - return this.each(function( index ) { - var self = set.eq( index ); - if ( isFunction ) { - args[0] = value.call( this, index, self.html() ); - } - self.domManip( args, callback, allowIntersection ); - }); - } - - if ( l ) { - fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this ); - first = fragment.firstChild; - - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } - - if ( first ) { - scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); - hasScripts = scripts.length; - - // Use the original fragment for the last item instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for ( ; i < l; i++ ) { - node = fragment; - - if ( i !== iNoClone ) { - node = jQuery.clone( node, true, true ); - - // Keep references to cloned scripts for later restoration - if ( hasScripts ) { - jQuery.merge( scripts, getAll( node, "script" ) ); - } - } - - callback.call( this[i], node, i ); - } - - if ( hasScripts ) { - doc = scripts[ scripts.length - 1 ].ownerDocument; - - // Reenable scripts - jQuery.map( scripts, restoreScript ); - - // Evaluate executable scripts on first document insertion - for ( i = 0; i < hasScripts; i++ ) { - node = scripts[ i ]; - if ( rscriptType.test( node.type || "" ) && - !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { - - if ( node.src ) { - // Hope ajax is available... - jQuery._evalUrl( node.src ); - } else { - jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); - } - } - } - } - - // Fix #11809: Avoid leaking memory - fragment = first = null; - } - } - - return this; - } -}); - -// Support: IE<8 -// Manipulating tables requires a tbody -function manipulationTarget( elem, content ) { - return jQuery.nodeName( elem, "table" ) && - jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ? - - elem.getElementsByTagName("tbody")[0] || - elem.appendChild( elem.ownerDocument.createElement("tbody") ) : - elem; -} - -// Replace/restore the type attribute of script elements for safe DOM manipulation -function disableScript( elem ) { - elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type; - return elem; -} -function restoreScript( elem ) { - var match = rscriptTypeMasked.exec( elem.type ); - if ( match ) { - elem.type = match[1]; - } else { - elem.removeAttribute("type"); - } - return elem; -} - -// Mark scripts as having already been evaluated -function setGlobalEval( elems, refElements ) { - var elem, - i = 0; - for ( ; (elem = elems[i]) != null; i++ ) { - jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); - } -} - -function cloneCopyEvent( src, dest ) { - - if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { - return; - } - - var type, i, l, - oldData = jQuery._data( src ), - curData = jQuery._data( dest, oldData ), - events = oldData.events; - - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } - } - } - - // make the cloned public data object a copy from the original - if ( curData.data ) { - curData.data = jQuery.extend( {}, curData.data ); - } -} - -function fixCloneNodeIssues( src, dest ) { - var nodeName, e, data; - - // We do not need to do anything for non-Elements - if ( dest.nodeType !== 1 ) { - return; - } - - nodeName = dest.nodeName.toLowerCase(); - - // IE6-8 copies events bound via attachEvent when using cloneNode. - if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) { - data = jQuery._data( dest ); - - for ( e in data.events ) { - jQuery.removeEvent( dest, e, data.handle ); - } - - // Event data gets referenced instead of copied if the expando gets copied too - dest.removeAttribute( jQuery.expando ); - } - - // IE blanks contents when cloning scripts, and tries to evaluate newly-set text - if ( nodeName === "script" && dest.text !== src.text ) { - disableScript( dest ).text = src.text; - restoreScript( dest ); - - // IE6-10 improperly clones children of object elements using classid. - // IE10 throws NoModificationAllowedError if parent is null, #12132. - } else if ( nodeName === "object" ) { - if ( dest.parentNode ) { - dest.outerHTML = src.outerHTML; - } - - // This path appears unavoidable for IE9. When cloning an object - // element in IE9, the outerHTML strategy above is not sufficient. - // If the src has innerHTML and the destination does not, - // copy the src.innerHTML into the dest.innerHTML. #10324 - if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { - dest.innerHTML = src.innerHTML; - } - - } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) { - // IE6-8 fails to persist the checked state of a cloned checkbox - // or radio button. Worse, IE6-7 fail to give the cloned element - // a checked appearance if the defaultChecked value isn't also set - - dest.defaultChecked = dest.checked = src.checked; - - // IE6-7 get confused and end up setting the value of a cloned - // checkbox/radio button to an empty string instead of "on" - if ( dest.value !== src.value ) { - dest.value = src.value; - } - - // IE6-8 fails to return the selected option to the default selected - // state when cloning options - } else if ( nodeName === "option" ) { - dest.defaultSelected = dest.selected = src.defaultSelected; - - // IE6-8 fails to set the defaultValue to the correct value when - // cloning other types of input fields - } else if ( nodeName === "input" || nodeName === "textarea" ) { - dest.defaultValue = src.defaultValue; - } -} - -jQuery.each({ - appendTo: "append", - prependTo: "prepend", - insertBefore: "before", - insertAfter: "after", - replaceAll: "replaceWith" -}, function( name, original ) { - jQuery.fn[ name ] = function( selector ) { - var elems, - i = 0, - ret = [], - insert = jQuery( selector ), - last = insert.length - 1; - - for ( ; i <= last; i++ ) { - elems = i === last ? this : this.clone(true); - jQuery( insert[i] )[ original ]( elems ); - - // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() - core_push.apply( ret, elems.get() ); - } - - return this.pushStack( ret ); - }; -}); - -function getAll( context, tag ) { - var elems, elem, - i = 0, - found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) : - typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) : - undefined; - - if ( !found ) { - for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { - if ( !tag || jQuery.nodeName( elem, tag ) ) { - found.push( elem ); - } else { - jQuery.merge( found, getAll( elem, tag ) ); - } - } - } - - return tag === undefined || tag && jQuery.nodeName( context, tag ) ? - jQuery.merge( [ context ], found ) : - found; -} - -// Used in buildFragment, fixes the defaultChecked property -function fixDefaultChecked( elem ) { - if ( manipulation_rcheckableType.test( elem.type ) ) { - elem.defaultChecked = elem.checked; - } -} - -jQuery.extend({ - clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var destElements, node, clone, i, srcElements, - inPage = jQuery.contains( elem.ownerDocument, elem ); - - if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { - clone = elem.cloneNode( true ); - - // IE<=8 does not properly clone detached, unknown element nodes - } else { - fragmentDiv.innerHTML = elem.outerHTML; - fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); - } - - if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && - (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { - - // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 - destElements = getAll( clone ); - srcElements = getAll( elem ); - - // Fix all IE cloning issues - for ( i = 0; (node = srcElements[i]) != null; ++i ) { - // Ensure that the destination node is not null; Fixes #9587 - if ( destElements[i] ) { - fixCloneNodeIssues( node, destElements[i] ); - } - } - } - - // Copy the events from the original to the clone - if ( dataAndEvents ) { - if ( deepDataAndEvents ) { - srcElements = srcElements || getAll( elem ); - destElements = destElements || getAll( clone ); - - for ( i = 0; (node = srcElements[i]) != null; i++ ) { - cloneCopyEvent( node, destElements[i] ); - } - } else { - cloneCopyEvent( elem, clone ); - } - } - - // Preserve script evaluation history - destElements = getAll( clone, "script" ); - if ( destElements.length > 0 ) { - setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); - } - - destElements = srcElements = node = null; - - // Return the cloned set - return clone; - }, - - buildFragment: function( elems, context, scripts, selection ) { - var j, elem, contains, - tmp, tag, tbody, wrap, - l = elems.length, - - // Ensure a safe fragment - safe = createSafeFragment( context ), - - nodes = [], - i = 0; - - for ( ; i < l; i++ ) { - elem = elems[ i ]; - - if ( elem || elem === 0 ) { - - // Add nodes directly - if ( jQuery.type( elem ) === "object" ) { - jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); - - // Convert non-html into a text node - } else if ( !rhtml.test( elem ) ) { - nodes.push( context.createTextNode( elem ) ); - - // Convert html into DOM nodes - } else { - tmp = tmp || safe.appendChild( context.createElement("div") ); - - // Deserialize a standard representation - tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); - wrap = wrapMap[ tag ] || wrapMap._default; - - tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; - - // Descend through wrappers to the right content - j = wrap[0]; - while ( j-- ) { - tmp = tmp.lastChild; - } - - // Manually add leading whitespace removed by IE - if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { - nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); - } - - // Remove IE's autoinserted from table fragments - if ( !jQuery.support.tbody ) { - - // String was a , *may* have spurious - elem = tag === "table" && !rtbody.test( elem ) ? - tmp.firstChild : - - // String was a bare or - wrap[1] === "
" && !rtbody.test( elem ) ? - tmp : - 0; - - j = elem && elem.childNodes.length; - while ( j-- ) { - if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { - elem.removeChild( tbody ); - } - } - } - - jQuery.merge( nodes, tmp.childNodes ); - - // Fix #12392 for WebKit and IE > 9 - tmp.textContent = ""; - - // Fix #12392 for oldIE - while ( tmp.firstChild ) { - tmp.removeChild( tmp.firstChild ); - } - - // Remember the top-level container for proper cleanup - tmp = safe.lastChild; - } - } - } - - // Fix #11356: Clear elements from fragment - if ( tmp ) { - safe.removeChild( tmp ); - } - - // Reset defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - if ( !jQuery.support.appendChecked ) { - jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); - } - - i = 0; - while ( (elem = nodes[ i++ ]) ) { - - // #4087 - If origin and destination elements are the same, and this is - // that element, do not do anything - if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { - continue; - } - - contains = jQuery.contains( elem.ownerDocument, elem ); - - // Append to fragment - tmp = getAll( safe.appendChild( elem ), "script" ); - - // Preserve script evaluation history - if ( contains ) { - setGlobalEval( tmp ); - } - - // Capture executables - if ( scripts ) { - j = 0; - while ( (elem = tmp[ j++ ]) ) { - if ( rscriptType.test( elem.type || "" ) ) { - scripts.push( elem ); - } - } - } - } - - tmp = null; - - return safe; - }, - - cleanData: function( elems, /* internal */ acceptData ) { - var elem, type, id, data, - i = 0, - internalKey = jQuery.expando, - cache = jQuery.cache, - deleteExpando = jQuery.support.deleteExpando, - special = jQuery.event.special; - - for ( ; (elem = elems[i]) != null; i++ ) { - - if ( acceptData || jQuery.acceptData( elem ) ) { - - id = elem[ internalKey ]; - data = id && cache[ id ]; - - if ( data ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } - } - } - - // Remove cache only if it was not already removed by jQuery.event.remove - if ( cache[ id ] ) { - - delete cache[ id ]; - - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( deleteExpando ) { - delete elem[ internalKey ]; - - } else if ( typeof elem.removeAttribute !== core_strundefined ) { - elem.removeAttribute( internalKey ); - - } else { - elem[ internalKey ] = null; - } - - core_deletedIds.push( id ); - } - } - } - } - }, - - _evalUrl: function( url ) { - return jQuery.ajax({ - url: url, - type: "GET", - dataType: "script", - async: false, - global: false, - "throws": true - }); - } -}); -jQuery.fn.extend({ - wrapAll: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapAll( html.call(this, i) ); - }); - } - - if ( this[0] ) { - // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); - - if ( this[0].parentNode ) { - wrap.insertBefore( this[0] ); - } - - wrap.map(function() { - var elem = this; - - while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { - elem = elem.firstChild; - } - - return elem; - }).append( this ); - } - - return this; - }, - - wrapInner: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapInner( html.call(this, i) ); - }); - } - - return this.each(function() { - var self = jQuery( this ), - contents = self.contents(); - - if ( contents.length ) { - contents.wrapAll( html ); - - } else { - self.append( html ); - } - }); - }, - - wrap: function( html ) { - var isFunction = jQuery.isFunction( html ); - - return this.each(function(i) { - jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); - }); - }, - - unwrap: function() { - return this.parent().each(function() { - if ( !jQuery.nodeName( this, "body" ) ) { - jQuery( this ).replaceWith( this.childNodes ); - } - }).end(); - } -}); -var iframe, getStyles, curCSS, - ralpha = /alpha\([^)]*\)/i, - ropacity = /opacity\s*=\s*([^)]*)/, - rposition = /^(top|right|bottom|left)$/, - // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" - // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display - rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rmargin = /^margin/, - rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), - rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), - rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), - elemdisplay = { BODY: "block" }, - - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssNormalTransform = { - letterSpacing: 0, - fontWeight: 400 - }, - - cssExpand = [ "Top", "Right", "Bottom", "Left" ], - cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; - -// return a css property mapped to a potentially vendor prefixed property -function vendorPropName( style, name ) { - - // shortcut for names that are not vendor prefixed - if ( name in style ) { - return name; - } - - // check for vendor prefixed names - var capName = name.charAt(0).toUpperCase() + name.slice(1), - origName = name, - i = cssPrefixes.length; - - while ( i-- ) { - name = cssPrefixes[ i ] + capName; - if ( name in style ) { - return name; - } - } - - return origName; -} - -function isHidden( elem, el ) { - // isHidden might be called from jQuery#filter function; - // in that case, element will be second argument - elem = el || elem; - return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); -} - -function showHide( elements, show ) { - var display, elem, hidden, - values = [], - index = 0, - length = elements.length; - - for ( ; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - - values[ index ] = jQuery._data( elem, "olddisplay" ); - display = elem.style.display; - if ( show ) { - // Reset the inline display of this element to learn if it is - // being hidden by cascaded rules or not - if ( !values[ index ] && display === "none" ) { - elem.style.display = ""; - } - - // Set elements which have been overridden with display: none - // in a stylesheet to whatever the default browser style is - // for such an element - if ( elem.style.display === "" && isHidden( elem ) ) { - values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); - } - } else { - - if ( !values[ index ] ) { - hidden = isHidden( elem ); - - if ( display && display !== "none" || !hidden ) { - jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); - } - } - } - } - - // Set the display of most of the elements in a second loop - // to avoid the constant reflow - for ( index = 0; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - if ( !show || elem.style.display === "none" || elem.style.display === "" ) { - elem.style.display = show ? values[ index ] || "" : "none"; - } - } - - return elements; -} - -jQuery.fn.extend({ - css: function( name, value ) { - return jQuery.access( this, function( elem, name, value ) { - var len, styles, - map = {}, - i = 0; - - if ( jQuery.isArray( name ) ) { - styles = getStyles( elem ); - len = name.length; - - for ( ; i < len; i++ ) { - map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); - } - - return map; - } - - return value !== undefined ? - jQuery.style( elem, name, value ) : - jQuery.css( elem, name ); - }, name, value, arguments.length > 1 ); - }, - show: function() { - return showHide( this, true ); - }, - hide: function() { - return showHide( this ); - }, - toggle: function( state ) { - if ( typeof state === "boolean" ) { - return state ? this.show() : this.hide(); - } - - return this.each(function() { - if ( isHidden( this ) ) { - jQuery( this ).show(); - } else { - jQuery( this ).hide(); - } - }); - } -}); - -jQuery.extend({ - // Add in style property hooks for overriding the default - // behavior of getting and setting a style property - cssHooks: { - opacity: { - get: function( elem, computed ) { - if ( computed ) { - // We should always get a number back from opacity - var ret = curCSS( elem, "opacity" ); - return ret === "" ? "1" : ret; - } - } - } - }, - - // Don't automatically add "px" to these possibly-unitless properties - cssNumber: { - "columnCount": true, - "fillOpacity": true, - "fontWeight": true, - "lineHeight": true, - "opacity": true, - "order": true, - "orphans": true, - "widows": true, - "zIndex": true, - "zoom": true - }, - - // Add in properties whose names you wish to fix before - // setting or getting the value - cssProps: { - // normalize float css property - "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" - }, - - // Get and set the style property on a DOM Node - style: function( elem, name, value, extra ) { - // Don't set styles on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { - return; - } - - // Make sure that we're working with the right name - var ret, type, hooks, - origName = jQuery.camelCase( name ), - style = elem.style; - - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // Check if we're setting a value - if ( value !== undefined ) { - type = typeof value; - - // convert relative number strings (+= or -=) to relative numbers. #7345 - if ( type === "string" && (ret = rrelNum.exec( value )) ) { - value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); - // Fixes bug #9237 - type = "number"; - } - - // Make sure that NaN and null values aren't set. See: #7116 - if ( value == null || type === "number" && isNaN( value ) ) { - return; - } - - // If a number was passed in, add 'px' to the (except for certain CSS properties) - if ( type === "number" && !jQuery.cssNumber[ origName ] ) { - value += "px"; - } - - // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, - // but it would mean to define eight (for every problematic property) identical functions - if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { - style[ name ] = "inherit"; - } - - // If a hook was provided, use that value, otherwise just set the specified value - if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { - - // Wrapped to prevent IE from throwing errors when 'invalid' values are provided - // Fixes bug #5509 - try { - style[ name ] = value; - } catch(e) {} - } - - } else { - // If a hook was provided get the non-computed value from there - if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { - return ret; - } - - // Otherwise just get the value from the style object - return style[ name ]; - } - }, - - css: function( elem, name, extra, styles ) { - var num, val, hooks, - origName = jQuery.camelCase( name ); - - // Make sure that we're working with the right name - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // If a hook was provided get the computed value from there - if ( hooks && "get" in hooks ) { - val = hooks.get( elem, true, extra ); - } - - // Otherwise, if a way to get the computed value exists, use that - if ( val === undefined ) { - val = curCSS( elem, name, styles ); - } - - //convert "normal" to computed value - if ( val === "normal" && name in cssNormalTransform ) { - val = cssNormalTransform[ name ]; - } - - // Return, converting to number if forced or a qualifier was provided and val looks numeric - if ( extra === "" || extra ) { - num = parseFloat( val ); - return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; - } - return val; - } -}); - -// NOTE: we've included the "window" in window.getComputedStyle -// because jsdom on node.js will break without it. -if ( window.getComputedStyle ) { - getStyles = function( elem ) { - return window.getComputedStyle( elem, null ); - }; - - curCSS = function( elem, name, _computed ) { - var width, minWidth, maxWidth, - computed = _computed || getStyles( elem ), - - // getPropertyValue is only needed for .css('filter') in IE9, see #12537 - ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, - style = elem.style; - - if ( computed ) { - - if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { - ret = jQuery.style( elem, name ); - } - - // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right - // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels - // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values - if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { - - // Remember the original values - width = style.width; - minWidth = style.minWidth; - maxWidth = style.maxWidth; - - // Put in the new values to get a computed value out - style.minWidth = style.maxWidth = style.width = ret; - ret = computed.width; - - // Revert the changed values - style.width = width; - style.minWidth = minWidth; - style.maxWidth = maxWidth; - } - } - - return ret; - }; -} else if ( document.documentElement.currentStyle ) { - getStyles = function( elem ) { - return elem.currentStyle; - }; - - curCSS = function( elem, name, _computed ) { - var left, rs, rsLeft, - computed = _computed || getStyles( elem ), - ret = computed ? computed[ name ] : undefined, - style = elem.style; - - // Avoid setting ret to empty string here - // so we don't default to auto - if ( ret == null && style && style[ name ] ) { - ret = style[ name ]; - } - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - // but not position css attributes, as those are proportional to the parent element instead - // and we can't measure the parent instead because it might trigger a "stacking dolls" problem - if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { - - // Remember the original values - left = style.left; - rs = elem.runtimeStyle; - rsLeft = rs && rs.left; - - // Put in the new values to get a computed value out - if ( rsLeft ) { - rs.left = elem.currentStyle.left; - } - style.left = name === "fontSize" ? "1em" : ret; - ret = style.pixelLeft + "px"; - - // Revert the changed values - style.left = left; - if ( rsLeft ) { - rs.left = rsLeft; - } - } - - return ret === "" ? "auto" : ret; - }; -} - -function setPositiveNumber( elem, value, subtract ) { - var matches = rnumsplit.exec( value ); - return matches ? - // Guard against undefined "subtract", e.g., when used as in cssHooks - Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : - value; -} - -function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { - var i = extra === ( isBorderBox ? "border" : "content" ) ? - // If we already have the right measurement, avoid augmentation - 4 : - // Otherwise initialize for horizontal or vertical properties - name === "width" ? 1 : 0, - - val = 0; - - for ( ; i < 4; i += 2 ) { - // both box models exclude margin, so add it if we want it - if ( extra === "margin" ) { - val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); - } - - if ( isBorderBox ) { - // border-box includes padding, so remove it if we want content - if ( extra === "content" ) { - val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - } - - // at this point, extra isn't border nor margin, so remove border - if ( extra !== "margin" ) { - val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - } else { - // at this point, extra isn't content, so add padding - val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - - // at this point, extra isn't content nor padding, so add border - if ( extra !== "padding" ) { - val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - } - } - - return val; -} - -function getWidthOrHeight( elem, name, extra ) { - - // Start with offset property, which is equivalent to the border-box value - var valueIsBorderBox = true, - val = name === "width" ? elem.offsetWidth : elem.offsetHeight, - styles = getStyles( elem ), - isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; - - // some non-html elements return undefined for offsetWidth, so check for null/undefined - // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 - // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 - if ( val <= 0 || val == null ) { - // Fall back to computed then uncomputed css if necessary - val = curCSS( elem, name, styles ); - if ( val < 0 || val == null ) { - val = elem.style[ name ]; - } - - // Computed unit is not pixels. Stop here and return. - if ( rnumnonpx.test(val) ) { - return val; - } - - // we need the check for style in case a browser which returns unreliable values - // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); - - // Normalize "", auto, and prepare for extra - val = parseFloat( val ) || 0; - } - - // use the active box-sizing model to add/subtract irrelevant styles - return ( val + - augmentWidthOrHeight( - elem, - name, - extra || ( isBorderBox ? "border" : "content" ), - valueIsBorderBox, - styles - ) - ) + "px"; -} - -// Try to determine the default display value of an element -function css_defaultDisplay( nodeName ) { - var doc = document, - display = elemdisplay[ nodeName ]; - - if ( !display ) { - display = actualDisplay( nodeName, doc ); - - // If the simple way fails, read from inside an iframe - if ( display === "none" || !display ) { - // Use the already-created iframe if possible - iframe = ( iframe || - jQuery("