implement history for AJAX

This commit is contained in:
Oliver Gorwits
2012-01-28 19:56:54 +00:00
parent d9d7aad374
commit 5bd481a36a
13 changed files with 263 additions and 233 deletions

View File

@@ -1,80 +0,0 @@
/* ========================================================
* bootstrap-tabs.js v1.4.0
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2011 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================== */
!function( $ ){
"use strict"
function activate ( element, container ) {
container
.find('> .active')
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active')
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
}
}
function tab( e ) {
var $this = $(this)
, $ul = $this.closest('ul:not(.dropdown-menu)')
, href = $this.attr('href')
, previous
, $href
if ( /^#\w+/.test(href) ) {
e.preventDefault()
if ( $this.parent('li').hasClass('active') ) {
return
}
previous = $ul.find('.active a').last()[0]
$href = $(href)
activate($this.parent('li'), $ul)
activate($href, $href.parent())
$this.trigger({
type: 'change'
, relatedTarget: previous
})
}
}
/* TABS/PILLS PLUGIN DEFINITION
* ============================ */
$.fn.tabs = $.fn.pills = function ( selector ) {
return this.each(function () {
$(this).delegate(selector || '.tabs li > a, .pills > li > a', 'click', tab)
})
}
$(document).ready(function () {
$('body').tabs('ul[data-tabs] li > a, ul[data-pills] > li > a')
})
}( window.jQuery || window.ender );

View File

@@ -0,0 +1,99 @@
/**
* @author Kyle Florence <kyle[dot]florence[at]gmail[dot]com>
* @website https://github.com/kflorence/jquery-deserialize/
* @version 1.1.0
*
* Dual licensed under the MIT and GPLv2 licenses.
*/
(function( jQuery ) {
var push = Array.prototype.push,
rcheck = /^(radio|checkbox)$/i,
rselect = /^(option|select-one|select-multiple)$/i,
rvalue = /^(hidden|text|search|tel|url|email|password|datetime|date|month|week|time|datetime-local|number|range|color|submit|image|reset|button|textarea)$/i;
jQuery.fn.extend({
deserialize: function( data, callback ) {
if ( !this.length || !data ) {
return this;
}
var i, length,
elements = this[ 0 ].elements || this.find( ":input" ).get(),
normalized = [];
if ( !elements ) {
return this;
}
if ( jQuery.isArray( data ) ) {
normalized = data;
} else if ( jQuery.isPlainObject( data ) ) {
var key, value;
for ( key in data ) {
jQuery.isArray( value = data[ key ] ) ?
push.apply( normalized, jQuery.map( value, function( v ) {
return { name: key, value: v };
})) : push.call( normalized, { name: key, value: value } );
}
} else if ( typeof data === "string" ) {
var parts;
data = decodeURIComponent( data ).split( "&" );
for ( i = 0, length = data.length; i < length; i++ ) {
parts = data[ i ].split( "=" );
push.call( normalized, { name: parts[ 0 ], value: parts[ 1 ] } );
}
}
if ( !( length = normalized.length ) ) {
return this;
}
var current, element, item, j, len, property, type;
for ( i = 0; i < length; i++ ) {
current = normalized[ i ];
if ( !( element = elements[ current.name ] ) ) {
continue;
}
type = ( len = element.length ) ? element[ 0 ] : element;
type = type.type || type.nodeName;
property = null;
if ( rvalue.test( type ) ) {
property = "value";
} else if ( rcheck.test( type ) ) {
property = "checked";
} else if ( rselect.test( type ) ) {
property = "selected";
}
// Handle element group
if ( len ) {
for ( j = 0; j < len; j++ ) {
item = element [ j ];
if ( item.value == current.value ) {
item[ property ] = true;
}
}
} else {
element[ property ] = current.value;
}
}
if ( jQuery.isFunction( callback ) ) {
callback.call( this );
}
return this;
}
});
})( jQuery );

File diff suppressed because one or more lines are too long