first commit
This commit is contained in:
Vendored
+7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14
File diff suppressed because one or more lines are too long
@@ -0,0 +1,240 @@
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/^\s+|\s+$/g,"");
|
||||
}
|
||||
String.prototype.trimLeft = function() {
|
||||
return this.replace(/^\s+/,"");
|
||||
}
|
||||
String.prototype.trimRight = function() {
|
||||
return this.replace(/\s+$/,"");
|
||||
}
|
||||
|
||||
|
||||
//Demos file list (in order of presentation)
|
||||
//THe page name is formed from the file name.
|
||||
var fileList = [
|
||||
'Basic_swipe.html',
|
||||
'Single_swipe.html',
|
||||
'Any_finger_swipe.html',
|
||||
'Finger_swipe.html',
|
||||
'Swipe_status.html',
|
||||
'Pinch.html',
|
||||
'Pinch_status.html',
|
||||
'Pinch_and_Swipe.html',
|
||||
'Trigger_handlers.html',
|
||||
'Stop_propagation.html',
|
||||
'Handlers_and_events.html',
|
||||
'Tap_vs_swipe.html',
|
||||
'Hold.html',
|
||||
'Excluded_children.html',
|
||||
'Page_zoom.html',
|
||||
'Thresholds.html',
|
||||
'Enable_and_destroy.html',
|
||||
'Page_scrolling.html',
|
||||
'Options.html',
|
||||
'Image_gallery_example.html'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Builds the demo page
|
||||
*/
|
||||
function init() {
|
||||
buildTitle();
|
||||
buildCodeExample();
|
||||
buildNavigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the navigation components
|
||||
*/
|
||||
function buildNavigation() {
|
||||
$('.navigation').each(function( index ) {
|
||||
$(this).html( getNavigation() );
|
||||
});
|
||||
|
||||
$('.navigation_menu').each(function( index ) {
|
||||
$(this).html( getNavigationMenu() );
|
||||
})
|
||||
|
||||
$('.navigation_list').each(function( index ) {
|
||||
$(this).html( getNavigationList() );
|
||||
})
|
||||
|
||||
|
||||
$('#menu').change( function() {
|
||||
location.href=$(this).val();
|
||||
});
|
||||
|
||||
$('#menu li').click( function() {
|
||||
location.href=$(this).val();
|
||||
});
|
||||
|
||||
$('.example_btn').click( function() {
|
||||
$(document).scrollTop( $("#test").offset().top );
|
||||
});
|
||||
|
||||
$('.events code').click( function() {
|
||||
location.href = '../docs/%24.fn.swipe.html#event:' + $(this).text();
|
||||
});
|
||||
|
||||
$('.properties code').click( function() {
|
||||
location.href = '../docs/%24.fn.swipe.defaults.html#' + $(this).text();
|
||||
});
|
||||
|
||||
$('.methods code').click( function() {
|
||||
location.href = '../docs/%24.fn.swipe.html#' + $(this).text();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the title element
|
||||
*/
|
||||
function buildTitle() {
|
||||
$('.title').each(function( index ) {
|
||||
$(this).html( getTitle() );
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the <script> tag contents, and populates the demo pretty print div to display the
|
||||
* code example.
|
||||
*/
|
||||
function buildCodeExample() {
|
||||
|
||||
$('.prettyprint').each(function( index ) {
|
||||
|
||||
//$(this).text( $("#"+$(this).attr('data-src')).html() );
|
||||
|
||||
var src = $("#"+$(this).attr('data-src')).html();
|
||||
if(src) {
|
||||
var lines = src.split("\n");
|
||||
var trimedLines=[];
|
||||
var trimIndex=null;
|
||||
for (var i=0; i<lines.length; i++) {
|
||||
var line = lines[i];
|
||||
if(trimIndex===null) {
|
||||
var trimmed = line.trimLeft();
|
||||
if(line.length>0) {
|
||||
trimIndex = line.length - trimmed.length;
|
||||
}
|
||||
}
|
||||
|
||||
if(line.length>0) {
|
||||
//Tabs to spaces
|
||||
line = line.replace(/\t/g, ' '); //not using $nbsp; as we want to display HTML tags, so we set the text value, not html
|
||||
trimedLines.push( line.substr(trimIndex) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var html = trimedLines.join("\n");
|
||||
|
||||
|
||||
$(this).text( html );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
//prettyPrint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current file being viewed.
|
||||
*/
|
||||
function getCurrentFile() {
|
||||
var url = window.location.pathname;
|
||||
var file = url.substring(url.lastIndexOf('/')+1);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current page name
|
||||
*/
|
||||
function getPageName( file ) {
|
||||
|
||||
if(!file)
|
||||
file=getCurrentFile();
|
||||
|
||||
var fileTokens = file.split("_");
|
||||
var fileName = fileTokens.join(" ");
|
||||
var nameTokens = fileName.split(".");
|
||||
nameTokens.pop();
|
||||
|
||||
var name = nameTokens.join(" ");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Writes out the page title template
|
||||
*/
|
||||
function getTitle() {
|
||||
var html = "<h2><a href=\"http://labs.rampinteractive.co.uk/touchSwipe/\">TouchSwipe</a> Demo</h2>";
|
||||
html += "<h3>to be viewed on touch based devices</h3>";
|
||||
html += "<h1>"+getPageName()+"<span class='navigation_menu pull-right'></span></h1>";
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML mark up for the pagination buttons
|
||||
*/
|
||||
function getNavigation() {
|
||||
var index = fileList.indexOf( getCurrentFile() );
|
||||
var html ="<div class='pagination'>";
|
||||
|
||||
if(index>0) {
|
||||
html += "<a class='pull-left btn' href='"+fileList[index-1]+"'><< "+getPageName(fileList[index-1])+"</a>";
|
||||
}
|
||||
|
||||
if(index<fileList.length-1) {
|
||||
html += "<a class='pull-right btn' href='"+fileList[index+1]+"'>"+getPageName(fileList[index+1])+" >></a>";
|
||||
}
|
||||
|
||||
html += "</div><div class='clear'></div>"
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML mark up for the drop down menu
|
||||
*/
|
||||
function getNavigationMenu() {
|
||||
|
||||
var html = "<select id='menu' class='pull_right'>";
|
||||
|
||||
for(var i=0; i<fileList.length; i++) {
|
||||
var selected="";
|
||||
if(fileList[i] == getCurrentFile()) {
|
||||
selected=' selected ';
|
||||
}
|
||||
html+="<option value='"+fileList[i]+"'"+selected+">"+getPageName(fileList[i])+"</option>";
|
||||
}
|
||||
|
||||
html += "</select>";
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML mark up for the list menu
|
||||
*/
|
||||
function getNavigationList() {
|
||||
|
||||
var html = "<ul>";
|
||||
|
||||
for(var i=0; i<fileList.length; i++) {
|
||||
html+="<li><a href='"+fileList[i]+"'>"+getPageName(fileList[i])+"</a></li>";
|
||||
}
|
||||
|
||||
html += "</ul>";
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
init();
|
||||
});
|
||||
@@ -0,0 +1,176 @@
|
||||
(function($){
|
||||
//addclass
|
||||
function addclass() {
|
||||
$('.content > div:first-child').addClass('net');
|
||||
$('img:nth-child(2)').parent('p').addClass('slider');
|
||||
$(".slider img").wrap("<div></>")
|
||||
};
|
||||
|
||||
//functionsscroll
|
||||
function scrollbar() {
|
||||
var $colum = $(".column:not('#recherche-artistique'), #recherche-artistique > div");
|
||||
|
||||
$(window).on("load",function(){
|
||||
$colum.mCustomScrollbar({
|
||||
theme:"minimal",
|
||||
mouseWheelPixels: 200,
|
||||
scrollInertia: 1000,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function scrollW() {
|
||||
$('a[href^="#"]').on('click', function(evt){
|
||||
evt.preventDefault();
|
||||
var target = $(this).attr('href');
|
||||
var rclass = $('.net');
|
||||
$('.underline').removeClass('underline');
|
||||
$(this).parent().addClass('underline');
|
||||
|
||||
$('.block').removeClass('block');
|
||||
$('.sous-menu .underline').parent().addClass('block');
|
||||
|
||||
$(rclass).removeClass('net');
|
||||
$(target).addClass('net');
|
||||
|
||||
$(' html, body')
|
||||
.stop()
|
||||
.animate({
|
||||
scrollLeft: $(target).offset().left - ( $('section > div').width() - $('section > div').outerWidth() + $('header').outerWidth() ) },1000, );
|
||||
});
|
||||
};
|
||||
|
||||
//mediaquieries
|
||||
|
||||
function scrollTop(){
|
||||
|
||||
$('a[href^="#"]').on('click', function(evt){
|
||||
evt.preventDefault();
|
||||
var target = $(this).attr('href');
|
||||
var rclass = $('.net');
|
||||
|
||||
$('.underline').removeClass('underline');
|
||||
$(this).parent().addClass('underline');
|
||||
|
||||
$('.block').removeClass('block');
|
||||
$('.sous-menu .underline').parent().addClass('block');
|
||||
|
||||
$(rclass).removeClass('net');
|
||||
$(target).addClass('net');
|
||||
|
||||
$('html,body').animate({
|
||||
scrollTop: $(target).offset().top - $('header').outerHeight()},'slow');
|
||||
});
|
||||
}
|
||||
|
||||
function clickd() {
|
||||
var $rclass = $('.net');
|
||||
|
||||
$('.content > div:not(#recherche-artistique), #recherche-artistique > div ').on('click', function(e) {
|
||||
|
||||
$rclass.removeClass('net');
|
||||
$(this).addClass('net');
|
||||
|
||||
$(' html, body').stop().animate({
|
||||
scrollLeft: $(this).offset().left - ( $('section > div').width() - $('section > div').outerWidth() + $('header').outerWidth() ) },1000);
|
||||
});
|
||||
};
|
||||
|
||||
function gallery() {
|
||||
$('.slider').bxSlider({
|
||||
mode: 'horizontal',
|
||||
captions: true,
|
||||
adaptiveHeight:true,
|
||||
slideWidth: 600,
|
||||
touchEnabled: true,
|
||||
responsive:true,
|
||||
preloadImages: 'visible',
|
||||
touchEnabled: false,
|
||||
pager: false,
|
||||
});
|
||||
};
|
||||
|
||||
function Openfp() {
|
||||
var $divgal = $( "<div id='gallery'></div>");
|
||||
var $button = $( "<button class=button></button>");
|
||||
var $img = $("img")
|
||||
|
||||
$img.each(function(index) {
|
||||
|
||||
$(this).on("click", function() {
|
||||
|
||||
$('body').prepend( $divgal );
|
||||
$(this).clone().appendTo('#gallery');
|
||||
$('#gallery').fadeIn(400).prepend( $button );
|
||||
$('#gallery > img').wrap('<div class=content-img style=opacity:1></div>');
|
||||
|
||||
$( '#gallery' ).click(function(e) {
|
||||
$(' #gallery, #gallery > .content-img').fadeOut(400, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function liclick() {
|
||||
var $ulf = $('section #recherche-artistique #commentaire-philosophe ul > li > p')
|
||||
var $olf = $('section #recherche-artistique #commentaire-philosophe ul > li > ol > li')
|
||||
var $mark = $('section #recherche-artistique #commentaire-philosophe ul > li > ol')
|
||||
|
||||
$ulf.nextAll('ol').hide();
|
||||
$('#commentaire-philosophe ul > li:nth-child(1) ol').show();
|
||||
|
||||
$mark.parent().children('p').css("text-decoration","underline");
|
||||
|
||||
$ulf.on("click", function(event) {
|
||||
$(this).nextAll('ol').toggle(function() {
|
||||
$(this).css({
|
||||
"max-height" : "0",
|
||||
"opacity" : "0",
|
||||
"margin-left" : "0",
|
||||
});
|
||||
}, function() {
|
||||
$(this).css({
|
||||
"max-height" : "auto",
|
||||
"opacity" : "1",
|
||||
"margin-left" : "30px",
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function openmenu_ui() {
|
||||
$('.menu-ui').on("click", function(event) {
|
||||
$('.navigation').slideToggle('slow');
|
||||
});
|
||||
|
||||
$('section').on("click", function(event) {
|
||||
$('.navigation').slideUp('slow');
|
||||
});
|
||||
};
|
||||
|
||||
function redimensionnement() {
|
||||
var result = document.getElementById('result');
|
||||
if("matchMedia" in window) { // Détection
|
||||
if(window.matchMedia("(min-width: 955px)").matches) {
|
||||
scrollbar();
|
||||
scrollW();
|
||||
clickd();
|
||||
} else {
|
||||
scrollTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
addclass();
|
||||
gallery();
|
||||
Openfp();
|
||||
liclick();
|
||||
openmenu_ui();
|
||||
redimensionnement();
|
||||
window.addEventListener('resize', redimensionnement, false);
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user