forked from fredwu/angel_nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented startup photo gallery. Closes fredwu#9.
- Loading branch information
Showing
34 changed files
with
537 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
window.label = <%= I18n.t('label').to_json %> | ||
window.label = <%= I18n.t('label').to_json %> | ||
window.settings = <%= Settings.to_json %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
jQuery -> | ||
$("#slideshow").livequery(-> | ||
$(@).slideshow( | ||
pauseSeconds: 5 | ||
width: window.settings.group.logo.full.width | ||
height: window.settings.group.logo.full.height | ||
caption: false | ||
) | ||
) |
Empty file.
209 changes: 209 additions & 0 deletions
209
app/assets/javascripts/libs/jquery/jquery.slideshow.lite.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
/** | ||
* Slideshow Lite plugin for jQuery | ||
* | ||
* v0.8.0 | ||
* | ||
* Copyright (c) 2009 Fred Wu | ||
* | ||
* Dual licensed under the MIT and GPL licenses: | ||
* http://www.opensource.org/licenses/mit-license.php | ||
* http://www.gnu.org/licenses/gpl.html | ||
*/ | ||
|
||
/** | ||
* Usage: | ||
* | ||
* // using default options | ||
* $("#slideshow").slideshow(); | ||
* | ||
* // using some custom options | ||
* $("#slideshow2").slideshow({ | ||
* pauseSeconds: 4, | ||
* height: 200, | ||
* caption: false | ||
* }); | ||
* | ||
* Configuration options: | ||
* | ||
* pauseSeconds float number of seconds between each photo to be displayed | ||
* fadeSpeed float number of seconds for the fading transition, the value should not exceed `pauseSeconds` | ||
* width integer width of the slideshow, in pixels | ||
* height integer height of the slideshow, in pixels | ||
* caption boolean display photo caption? | ||
* cssClass string name of the CSS class, defaults to `slideshowlite` | ||
* anchorTarget string name for the target="_xxx" attribute, defaults to `_self` | ||
*/ | ||
|
||
(function($){ | ||
$.fn.slideshow = function(options){ | ||
|
||
var defaults = { | ||
pauseSeconds: 2, | ||
fadeSpeed: 0.5, | ||
width: 468, | ||
height: 120, | ||
caption: true, | ||
cssClass: 'slideshowlite', | ||
anchorTarget: '_self' | ||
}; | ||
|
||
var options = $.extend(defaults, options); | ||
|
||
// ---------------------------------------- | ||
// slideshow instance | ||
// ---------------------------------------- | ||
|
||
var runInstance = function(target) { | ||
var items = $("a", target); | ||
var instance; | ||
|
||
// ---------------------------------------- | ||
// some mandontory styling | ||
// ---------------------------------------- | ||
|
||
if ( ! $(target).hasClass(options.cssClass)) $(target).addClass(options.cssClass); | ||
|
||
$(target).css({ | ||
width: options.width + "px", | ||
height: options.height + "px" | ||
}); | ||
|
||
// ---------------------------------------- | ||
// create anchor links to make the structure simpler for manupilation | ||
// ---------------------------------------- | ||
|
||
$("> img", target).wrap(document.createElement("a")); | ||
$("a", target).attr("target", options.anchorTarget); | ||
|
||
// ---------------------------------------- | ||
// add item sequence markups | ||
// ---------------------------------------- | ||
|
||
var i = 1; | ||
$("a", target).each(function(){ | ||
$(this).attr("rel", i++); | ||
}); | ||
|
||
// ---------------------------------------- | ||
// create pagination and caption | ||
// ---------------------------------------- | ||
|
||
$(target).append("<ul></ul>"); | ||
$(target).append("<ol></ol>"); | ||
var pagination = $("> ul", target); | ||
var caption = $("> ol", target); | ||
|
||
var i = 1; | ||
var j = 0; | ||
$("a", target).each(function(){ | ||
pagination.append("<li><a href=\"#\">" + i++ + "</a></li>"); | ||
caption.append("<li>" + $("img:nth(" + j++ + ")", target).attr("alt") + "</li>"); | ||
}); | ||
pagination.fadeTo(0, 0.8); | ||
caption.fadeTo(0, 0.6); | ||
caption.hide(); | ||
|
||
// ---------------------------------------- | ||
// shortcuts | ||
// ---------------------------------------- | ||
|
||
var firstItem = $("> a:first", target); | ||
var lastItem = $("> a:last", target); | ||
var currentItem = firstItem; | ||
|
||
// ---------------------------------------- | ||
// pagination highlight | ||
// ---------------------------------------- | ||
|
||
var paginationHighlight = function(sequence){ | ||
$("> li > a", pagination).removeClass("current"); | ||
$("> li > a:nth(" + sequence + ")", pagination).addClass("current"); | ||
} | ||
|
||
// ---------------------------------------- | ||
// caption | ||
// ---------------------------------------- | ||
|
||
var showCaption = function(sequence){ | ||
caption.show(); | ||
$("> li", caption).hide(); | ||
$("> li:nth(" + sequence + ")", caption).fadeIn(); | ||
} | ||
|
||
// ---------------------------------------- | ||
// slideshow logic | ||
// ---------------------------------------- | ||
|
||
var makeSlideshow = function(){ | ||
|
||
// pagination click | ||
$("> li > a", pagination).click(function(){ | ||
if ( ! $(this).hasClass("current")) | ||
{ | ||
// select the current item after the pagination click | ||
currentItem = $("a:nth(" + ($(this).text()-1) + ")", target); | ||
|
||
currentItem.show(); | ||
startSlideshow(); | ||
} | ||
return false; | ||
}); | ||
|
||
// pagination highlight | ||
paginationHighlight(currentItem.attr("rel")-1); | ||
|
||
// show caption | ||
if (options.caption == true) | ||
{ | ||
showCaption(currentItem.attr("rel")-1); | ||
} | ||
|
||
currentItem.css("z-index", 2); | ||
|
||
// show the current slide | ||
currentItem.fadeIn(options.fadeSpeed*1000, function(){ | ||
$("> a", target).hide(); | ||
$(this).show().css("z-index", 1); | ||
}); | ||
|
||
// prepare for the next slide | ||
// determines the next item (or we need to rewind to the first item?) | ||
if ($("img", currentItem).attr("src") == $("img", lastItem).attr("src")) | ||
{ | ||
currentItem = firstItem; | ||
} | ||
else | ||
{ | ||
currentItem = currentItem.next(); | ||
} | ||
|
||
currentItem.css("z-index", 1); | ||
}; | ||
|
||
var startSlideshow = function(){ | ||
clearInterval(instance); | ||
makeSlideshow(); | ||
instance = setInterval(makeSlideshow, options.pauseSeconds*1000); | ||
}; | ||
|
||
// ---------------------------------------- | ||
// start the slideshow! | ||
// ---------------------------------------- | ||
|
||
startSlideshow(); | ||
} | ||
|
||
// ---------------------------------------- | ||
// run the slideshow instances! | ||
// ---------------------------------------- | ||
|
||
if (this.length > 1) { | ||
this.each(function() { | ||
runInstance(this); | ||
}); | ||
} else { | ||
runInstance(this); | ||
} | ||
|
||
}; | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
jQuery(function($) { | ||
$('form a.add_nested_fields').live('click', function() { | ||
// Setup | ||
var assoc = $(this).attr('data-association'); // Name of child | ||
var content = $('#' + assoc + '_fields_blueprint').html(); // Fields template | ||
|
||
// Make the context correct by replacing new_<parents> with the generated ID | ||
// of each of the parent objects | ||
var context = ($(this).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), ''); | ||
|
||
// context will be something like this for a brand new form: | ||
// project[tasks_attributes][new_1255929127459][assignments_attributes][new_1255929128105] | ||
// or for an edit form: | ||
// project[tasks_attributes][0][assignments_attributes][1] | ||
if(context) { | ||
var parent_names = context.match(/[a-z_]+_attributes/g) || []; | ||
var parent_ids = context.match(/(new_)?[0-9]+/g) || []; | ||
|
||
for(var i = 0; i < parent_names.length; i++) { | ||
if(parent_ids[i]) { | ||
content = content.replace( | ||
new RegExp('(_' + parent_names[i] + ')_.+?_', 'g'), | ||
'$1_' + parent_ids[i] + '_'); | ||
|
||
content = content.replace( | ||
new RegExp('(\\[' + parent_names[i] + '\\])\\[.+?\\]', 'g'), | ||
'$1[' + parent_ids[i] + ']'); | ||
} | ||
} | ||
} | ||
|
||
// Make a unique ID for the new child | ||
var regexp = new RegExp('new_' + assoc, 'g'); | ||
var new_id = new Date().getTime(); | ||
content = content.replace(regexp, "new_" + new_id); | ||
|
||
var field = $(content).insertBefore(this); | ||
$(this).closest("form").trigger({type: 'nested:fieldAdded', field: field}); | ||
return false; | ||
}); | ||
|
||
$('form a.remove_nested_fields').live('click', function() { | ||
var hidden_field = $(this).prev('input[type=hidden]')[0]; | ||
if(hidden_field) { | ||
hidden_field.value = '1'; | ||
} | ||
$(this).closest('.fields').hide(); | ||
$(this).closest("form").trigger('nested:fieldRemoved'); | ||
return false; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.