diff --git a/.gitignore b/.gitignore index eb3489a..9243755 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp + +/vendor/bundle diff --git a/.rbenv-version b/.rbenv-version new file mode 100644 index 0000000..f3a9c9a --- /dev/null +++ b/.rbenv-version @@ -0,0 +1 @@ +1.9.3-p194 diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile index d45a993..03b96b4 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,8 @@ gem 'rails', '3.2.9' group :development do gem 'sqlite3' + gem 'better_errors' + gem 'binding_of_caller' end group :production do @@ -14,8 +16,20 @@ group :production do gem 'thin' end - - +# This is in both groups so rake tasks work properly +gem 'rspec-rails', :group => [:development, :test] + +group :test do + gem 'factory_girl_rails' + gem 'shoulda-matchers' + gem 'guard-rspec' + gem 'spork' + gem 'guard-spork' + gem 'capybara' + gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i + gem 'ffaker' # Faster version of faker +end +gem 'rb-fsevent' # Gems used only for assets and not required # in production environments by default. @@ -33,6 +47,8 @@ group :assets do end gem 'jquery-rails' +gem 'backbone-on-rails' + # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index ee7acb3..843b96a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,12 +43,34 @@ GEM arbre (1.0.1) activesupport (>= 3.0.0) arel (3.0.2) + backbone-on-rails (0.9.10.0) + eco + ejs + jquery-rails + rails (>= 3.1) bcrypt-ruby (3.0.1) + better_errors (0.7.0) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + binding_of_caller (0.7.1) + debug_inspector (>= 0.0.1) bourbon (3.0.1) sass (>= 3.2.0) thor + bourne (1.1.2) + mocha (= 0.10.5) builder (3.0.4) + capybara (2.0.2) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 1.0.0) + childprocess (0.3.8) + ffi (~> 1.0, >= 1.0.11) chunky_png (1.2.7) + coderay (1.0.9) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -63,19 +85,47 @@ GEM compass-rails (1.0.3) compass (>= 0.12.2, < 0.14) daemons (1.1.9) + debug_inspector (0.0.2) devise (2.2.2) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) railties (~> 3.1) warden (~> 1.2.1) + diff-lcs (1.2.1) + eco (1.0.0) + coffee-script + eco-source + execjs + eco-source (1.1.0.rc.1) + ejs (1.1.1) erubis (2.7.0) eventmachine (1.0.0) execjs (1.4.0) multi_json (~> 1.0) + factory_girl (4.2.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.2.1) + factory_girl (~> 4.2.0) + railties (>= 3.0.0) fastercsv (1.5.5) + ffaker (1.15.0) + ffi (1.4.0) formtastic (2.2.1) actionpack (>= 3.0) fssm (0.2.9) + guard (1.6.2) + listen (>= 0.6.0) + lumberjack (>= 1.0.2) + pry (>= 0.9.10) + terminal-table (>= 1.4.3) + thor (>= 0.14.6) + guard-rspec (2.4.1) + guard (>= 1.1) + rspec (~> 2.11) + guard-spork (1.4.2) + childprocess (>= 0.2.3) + guard (>= 1.1) + spork (>= 0.8.4) has_scope (0.5.1) hike (1.2.1) i18n (0.6.1) @@ -90,6 +140,8 @@ GEM kaminari (0.14.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) + listen (0.7.2) + lumberjack (1.0.2) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -99,17 +151,22 @@ GEM activerecord (~> 3.1) activesupport (~> 3.1) polyamorous (~> 0.5.0) + metaclass (0.0.1) + method_source (0.8.1) mime-types (1.19) - modular-scale (1.0.6) - compass (>= 0.12.1) - sass (>= 3.2.0) - sassy-math (>= 1.5) + mocha (0.10.5) + metaclass (~> 0.0.1) multi_json (1.5.0) + nokogiri (1.5.6) orm_adapter (0.4.0) pg (0.14.1) polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) + pry (0.9.12) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.4) rack (1.4.4) rack-cache (1.2) rack (>= 0.4) @@ -133,23 +190,49 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.0.3) + rb-fsevent (0.9.3) rdoc (3.12) json (~> 1.4) responders (0.9.3) railties (~> 3.1) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.0) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.0) + rspec-rails (2.13.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rubyzip (0.9.9) sass (3.2.5) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - sassy-math (1.5) - compass (~> 0.11) + selenium-webdriver (2.30.0) + childprocess (>= 0.2.5) + multi_json (~> 1.0) + rubyzip + websocket (~> 1.0.4) + shoulda-matchers (1.4.2) + activesupport (>= 3.0.0) + bourne (~> 1.1.2) + slop (3.4.3) + spork (0.9.2) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.7) + terminal-table (1.4.5) thin (1.5.0) daemons (>= 1.0.9) eventmachine (>= 0.12.6) @@ -165,24 +248,33 @@ GEM multi_json (~> 1.0, >= 1.0.2) warden (1.2.1) rack (>= 1.0) - zurb-foundation (3.2.4) - compass (>= 0.12.2) - modular-scale (= 1.0.6) - rake - sass (>= 3.2.0) + websocket (1.0.7) + xpath (1.0.0) + nokogiri (~> 1.3) PLATFORMS ruby DEPENDENCIES activeadmin + backbone-on-rails + better_errors + binding_of_caller + capybara coffee-rails (~> 3.2.1) compass-rails + factory_girl_rails + ffaker + guard-rspec + guard-spork jquery-rails pg rails (= 3.2.9) + rb-fsevent + rspec-rails sass-rails (~> 3.2.3) + shoulda-matchers + spork sqlite3 thin uglifier (>= 1.0.3) - zurb-foundation diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..22f1ba3 --- /dev/null +++ b/Guardfile @@ -0,0 +1,36 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do + watch('config/application.rb') + watch('config/environment.rb') + watch('config/environments/test.rb') + watch(%r{^config/initializers/.+\.rb$}) + watch('Gemfile') + watch('Gemfile.lock') + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } + watch(%r{features/support/}) { :cucumber } +end + +guard 'rspec', :cli => '--drb' do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + + # Capybara features specs + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } +end + diff --git a/README.rdoc b/README.rdoc index 7c36f23..8aec433 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,6 @@ +== Welcome to our app. This is the branch for using backbone +the backbone page is up at /main + == Welcome to Rails Rails is a web-application framework that includes everything needed to create diff --git a/app/admin/resources.rb b/app/admin/resources.rb index 62cdbda..edafc8f 100644 --- a/app/admin/resources.rb +++ b/app/admin/resources.rb @@ -1,4 +1,4 @@ ActiveAdmin.register Resource do - filter :common_core, :collection => proc { CommmonCore.all }, :as => :select + filter :common_core, :collection => proc { CommonCore.all }, :as => :select end diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 07120f0..b8217d2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -9,8 +9,16 @@ // // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. -// +//= require underscore //= require jquery //= require jquery_ujs -//= require foundation +//= require backbone +//= require active_admin +//= require lessonoverflow +//= require_tree ../templates +//= require_tree ./models +//= require_tree ./collections +//= require_tree ./views +//= require_tree ./routers //= require_tree . + diff --git a/app/assets/javascripts/collections/resources.js.coffee b/app/assets/javascripts/collections/resources.js.coffee new file mode 100644 index 0000000..e2d5b91 --- /dev/null +++ b/app/assets/javascripts/collections/resources.js.coffee @@ -0,0 +1,3 @@ +class Lessonoverflow.Collections.Resources extends Backbone.Collection + url: 'api/v1/resources' + model: Lessonoverflow.Models.Resource diff --git a/app/assets/javascripts/foundation/app.js b/app/assets/javascripts/foundation/app.js deleted file mode 100644 index 323d364..0000000 --- a/app/assets/javascripts/foundation/app.js +++ /dev/null @@ -1,38 +0,0 @@ -;(function ($, window, undefined) { - 'use strict'; - - var $doc = $(document), - Modernizr = window.Modernizr; - - $(document).ready(function() { - $.fn.foundationAlerts ? $doc.foundationAlerts() : null; - $.fn.foundationButtons ? $doc.foundationButtons() : null; - $.fn.foundationAccordion ? $doc.foundationAccordion() : null; - $.fn.foundationNavigation ? $doc.foundationNavigation() : null; - $.fn.foundationTopBar ? $doc.foundationTopBar() : null; - $.fn.foundationCustomForms ? $doc.foundationCustomForms() : null; - $.fn.foundationMediaQueryViewer ? $doc.foundationMediaQueryViewer() : null; - $.fn.foundationTabs ? $doc.foundationTabs({callback : $.foundation.customForms.appendCustomMarkup}) : null; - $.fn.foundationTooltips ? $doc.foundationTooltips() : null; - $.fn.foundationMagellan ? $doc.foundationMagellan() : null; - $.fn.foundationClearing ? $doc.foundationClearing() : null; - - $.fn.placeholder ? $('input, textarea').placeholder() : null; - }); - - // UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE8 SUPPORT AND ARE USING .block-grids - // $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'}); - // $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'}); - // $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'}); - // $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'}); - - // Hide address bar on mobile devices (except if #hash present, so we don't mess up deep linking). - if (Modernizr.touch && !window.location.hash) { - $(window).load(function () { - setTimeout(function () { - window.scrollTo(0, 1); - }, 0); - }); - } - -})(jQuery, this); diff --git a/app/assets/javascripts/foundation/jquery.cookie.js b/app/assets/javascripts/foundation/jquery.cookie.js deleted file mode 100644 index 30c4b83..0000000 --- a/app/assets/javascripts/foundation/jquery.cookie.js +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * jQuery Cookie Plugin v1.3 - * https://github.com/carhartl/jquery-cookie - * - * Copyright 2011, Klaus Hartl - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://www.opensource.org/licenses/mit-license.php - * http://www.opensource.org/licenses/GPL-2.0 - */ -(function ($, document, undefined) { - - var pluses = /\+/g; - - function raw(s) { - return s; - } - - function decoded(s) { - return decodeURIComponent(s.replace(pluses, ' ')); - } - - var config = $.cookie = function (key, value, options) { - - // write - if (value !== undefined) { - options = $.extend({}, config.defaults, options); - - if (value === null) { - options.expires = -1; - } - - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); - } - - value = config.json ? JSON.stringify(value) : String(value); - - return (document.cookie = [ - encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } - - // read - var decode = config.raw ? raw : decoded; - var cookies = document.cookie.split('; '); - for (var i = 0, l = cookies.length; i < l; i++) { - var parts = cookies[i].split('='); - if (decode(parts.shift()) === key) { - var cookie = decode(parts.join('=')); - return config.json ? JSON.parse(cookie) : cookie; - } - } - - return null; - }; - - config.defaults = {}; - - $.removeCookie = function (key, options) { - if ($.cookie(key) !== null) { - $.cookie(key, null, options); - return true; - } - return false; - }; - -})(jQuery, document); \ No newline at end of file diff --git a/app/assets/javascripts/foundation/jquery.event.move.js b/app/assets/javascripts/foundation/jquery.event.move.js deleted file mode 100644 index e397236..0000000 --- a/app/assets/javascripts/foundation/jquery.event.move.js +++ /dev/null @@ -1,580 +0,0 @@ -// jquery.event.move -// -// 1.3.1 -// -// Stephen Band -// -// Triggers 'movestart', 'move' and 'moveend' events after -// mousemoves following a mousedown cross a distance threshold, -// similar to the native 'dragstart', 'drag' and 'dragend' events. -// Move events are throttled to animation frames. Move event objects -// have the properties: -// -// pageX: -// pageY: Page coordinates of pointer. -// startX: -// startY: Page coordinates of pointer at movestart. -// distX: -// distY: Distance the pointer has moved since movestart. -// deltaX: -// deltaY: Distance the finger has moved since last event. -// velocityX: -// velocityY: Average velocity over last few events. - - -(function (module) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], module); - } else { - // Browser globals - module(jQuery); - } -})(function(jQuery, undefined){ - - var // Number of pixels a pressed pointer travels before movestart - // event is fired. - threshold = 6, - - add = jQuery.event.add, - - remove = jQuery.event.remove, - - // Just sugar, so we can have arguments in the same order as - // add and remove. - trigger = function(node, type, data) { - jQuery.event.trigger(type, data, node); - }, - - // Shim for requestAnimationFrame, falling back to timer. See: - // see http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - requestFrame = (function(){ - return ( - window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(fn, element){ - return window.setTimeout(function(){ - fn(); - }, 25); - } - ); - })(), - - ignoreTags = { - textarea: true, - input: true, - select: true, - button: true - }, - - mouseevents = { - move: 'mousemove', - cancel: 'mouseup dragstart', - end: 'mouseup' - }, - - touchevents = { - move: 'touchmove', - cancel: 'touchend', - end: 'touchend' - }; - - - // Constructors - - function Timer(fn){ - var callback = fn, - active = false, - running = false; - - function trigger(time) { - if (active){ - callback(); - requestFrame(trigger); - running = true; - active = false; - } - else { - running = false; - } - } - - this.kick = function(fn) { - active = true; - if (!running) { trigger(); } - }; - - this.end = function(fn) { - var cb = callback; - - if (!fn) { return; } - - // If the timer is not running, simply call the end callback. - if (!running) { - fn(); - } - // If the timer is running, and has been kicked lately, then - // queue up the current callback and the end callback, otherwise - // just the end callback. - else { - callback = active ? - function(){ cb(); fn(); } : - fn ; - - active = true; - } - }; - } - - - // Functions - - function returnTrue() { - return true; - } - - function returnFalse() { - return false; - } - - function preventDefault(e) { - e.preventDefault(); - } - - function preventIgnoreTags(e) { - // Don't prevent interaction with form elements. - if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; } - - e.preventDefault(); - } - - function isLeftButton(e) { - // Ignore mousedowns on any button other than the left (or primary) - // mouse button, or when a modifier key is pressed. - return (e.which === 1 && !e.ctrlKey && !e.altKey); - } - - function identifiedTouch(touchList, id) { - var i, l; - - if (touchList.identifiedTouch) { - return touchList.identifiedTouch(id); - } - - // touchList.identifiedTouch() does not exist in - // webkit yet… we must do the search ourselves... - - i = -1; - l = touchList.length; - - while (++i < l) { - if (touchList[i].identifier === id) { - return touchList[i]; - } - } - } - - function changedTouch(e, event) { - var touch = identifiedTouch(e.changedTouches, event.identifier); - - // This isn't the touch you're looking for. - if (!touch) { return; } - - // Chrome Android (at least) includes touches that have not - // changed in e.changedTouches. That's a bit annoying. Check - // that this touch has changed. - if (touch.pageX === event.pageX && touch.pageY === event.pageY) { return; } - - return touch; - } - - - // Handlers that decide when the first movestart is triggered - - function mousedown(e){ - var data; - - if (!isLeftButton(e)) { return; } - - data = { - target: e.target, - startX: e.pageX, - startY: e.pageY, - timeStamp: e.timeStamp - }; - - add(document, mouseevents.move, mousemove, data); - add(document, mouseevents.cancel, mouseend, data); - } - - function mousemove(e){ - var data = e.data; - - checkThreshold(e, data, e, removeMouse); - } - - function mouseend(e) { - removeMouse(); - } - - function removeMouse() { - remove(document, mouseevents.move, mousemove); - remove(document, mouseevents.cancel, removeMouse); - } - - function touchstart(e) { - var touch, template; - - // Don't get in the way of interaction with form elements. - if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; } - - touch = e.changedTouches[0]; - - // iOS live updates the touch objects whereas Android gives us copies. - // That means we can't trust the touchstart object to stay the same, - // so we must copy the data. This object acts as a template for - // movestart, move and moveend event objects. - template = { - target: touch.target, - startX: touch.pageX, - startY: touch.pageY, - timeStamp: e.timeStamp, - identifier: touch.identifier - }; - - // Use the touch identifier as a namespace, so that we can later - // remove handlers pertaining only to this touch. - add(document, touchevents.move + '.' + touch.identifier, touchmove, template); - add(document, touchevents.cancel + '.' + touch.identifier, touchend, template); - } - - function touchmove(e){ - var data = e.data, - touch = changedTouch(e, data); - - if (!touch) { return; } - - checkThreshold(e, data, touch, removeTouch); - } - - function touchend(e) { - var template = e.data, - touch = identifiedTouch(e.changedTouches, template.identifier); - - if (!touch) { return; } - - removeTouch(template.identifier); - } - - function removeTouch(identifier) { - remove(document, '.' + identifier, touchmove); - remove(document, '.' + identifier, touchend); - } - - - // Logic for deciding when to trigger a movestart. - - function checkThreshold(e, template, touch, fn) { - var distX = touch.pageX - template.startX, - distY = touch.pageY - template.startY; - - // Do nothing if the threshold has not been crossed. - if ((distX * distX) + (distY * distY) < (threshold * threshold)) { return; } - - triggerStart(e, template, touch, distX, distY, fn); - } - - function handled() { - // this._handled should return false once, and after return true. - this._handled = returnTrue; - return false; - } - - function flagAsHandled(e) { - e._handled(); - } - - function triggerStart(e, template, touch, distX, distY, fn) { - var node = template.target, - touches, time; - - touches = e.targetTouches; - time = e.timeStamp - template.timeStamp; - - // Create a movestart object with some special properties that - // are passed only to the movestart handlers. - template.type = 'movestart'; - template.distX = distX; - template.distY = distY; - template.deltaX = distX; - template.deltaY = distY; - template.pageX = touch.pageX; - template.pageY = touch.pageY; - template.velocityX = distX / time; - template.velocityY = distY / time; - template.targetTouches = touches; - template.finger = touches ? - touches.length : - 1 ; - - // The _handled method is fired to tell the default movestart - // handler that one of the move events is bound. - template._handled = handled; - - // Pass the touchmove event so it can be prevented if or when - // movestart is handled. - template._preventTouchmoveDefault = function() { - e.preventDefault(); - }; - - // Trigger the movestart event. - trigger(template.target, template); - - // Unbind handlers that tracked the touch or mouse up till now. - fn(template.identifier); - } - - - // Handlers that control what happens following a movestart - - function activeMousemove(e) { - var event = e.data.event, - timer = e.data.timer; - - updateEvent(event, e, e.timeStamp, timer); - } - - function activeMouseend(e) { - var event = e.data.event, - timer = e.data.timer; - - removeActiveMouse(); - - endEvent(event, timer, function() { - // Unbind the click suppressor, waiting until after mouseup - // has been handled. - setTimeout(function(){ - remove(event.target, 'click', returnFalse); - }, 0); - }); - } - - function removeActiveMouse(event) { - remove(document, mouseevents.move, activeMousemove); - remove(document, mouseevents.end, activeMouseend); - } - - function activeTouchmove(e) { - var event = e.data.event, - timer = e.data.timer, - touch = changedTouch(e, event); - - if (!touch) { return; } - - // Stop the interface from gesturing - e.preventDefault(); - - event.targetTouches = e.targetTouches; - updateEvent(event, touch, e.timeStamp, timer); - } - - function activeTouchend(e) { - var event = e.data.event, - timer = e.data.timer, - touch = identifiedTouch(e.changedTouches, event.identifier); - - // This isn't the touch you're looking for. - if (!touch) { return; } - - removeActiveTouch(event); - endEvent(event, timer); - } - - function removeActiveTouch(event) { - remove(document, '.' + event.identifier, activeTouchmove); - remove(document, '.' + event.identifier, activeTouchend); - } - - - // Logic for triggering move and moveend events - - function updateEvent(event, touch, timeStamp, timer) { - var time = timeStamp - event.timeStamp; - - event.type = 'move'; - event.distX = touch.pageX - event.startX; - event.distY = touch.pageY - event.startY; - event.deltaX = touch.pageX - event.pageX; - event.deltaY = touch.pageY - event.pageY; - - // Average the velocity of the last few events using a decay - // curve to even out spurious jumps in values. - event.velocityX = 0.3 * event.velocityX + 0.7 * event.deltaX / time; - event.velocityY = 0.3 * event.velocityY + 0.7 * event.deltaY / time; - event.pageX = touch.pageX; - event.pageY = touch.pageY; - - timer.kick(); - } - - function endEvent(event, timer, fn) { - timer.end(function(){ - event.type = 'moveend'; - - trigger(event.target, event); - - return fn && fn(); - }); - } - - - // jQuery special event definition - - function setup(data, namespaces, eventHandle) { - // Stop the node from being dragged - //add(this, 'dragstart.move drag.move', preventDefault); - - // Prevent text selection and touch interface scrolling - //add(this, 'mousedown.move', preventIgnoreTags); - - // Tell movestart default handler that we've handled this - add(this, 'movestart.move', flagAsHandled); - - // Don't bind to the DOM. For speed. - return true; - } - - function teardown(namespaces) { - remove(this, 'dragstart drag', preventDefault); - remove(this, 'mousedown touchstart', preventIgnoreTags); - remove(this, 'movestart', flagAsHandled); - - // Don't bind to the DOM. For speed. - return true; - } - - function addMethod(handleObj) { - // We're not interested in preventing defaults for handlers that - // come from internal move or moveend bindings - if (handleObj.namespace === "move" || handleObj.namespace === "moveend") { - return; - } - - // Stop the node from being dragged - add(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid, preventDefault, undefined, handleObj.selector); - - // Prevent text selection and touch interface scrolling - add(this, 'mousedown.' + handleObj.guid, preventIgnoreTags, undefined, handleObj.selector); - } - - function removeMethod(handleObj) { - if (handleObj.namespace === "move" || handleObj.namespace === "moveend") { - return; - } - - remove(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid); - remove(this, 'mousedown.' + handleObj.guid); - } - - jQuery.event.special.movestart = { - setup: setup, - teardown: teardown, - add: addMethod, - remove: removeMethod, - - _default: function(e) { - var template, data; - - // If no move events were bound to any ancestors of this - // target, high tail it out of here. - if (!e._handled()) { return; } - - template = { - target: e.target, - startX: e.startX, - startY: e.startY, - pageX: e.pageX, - pageY: e.pageY, - distX: e.distX, - distY: e.distY, - deltaX: e.deltaX, - deltaY: e.deltaY, - velocityX: e.velocityX, - velocityY: e.velocityY, - timeStamp: e.timeStamp, - identifier: e.identifier, - targetTouches: e.targetTouches, - finger: e.finger - }; - - data = { - event: template, - timer: new Timer(function(time){ - trigger(e.target, template); - }) - }; - - if (e.identifier === undefined) { - // We're dealing with a mouse - // Stop clicks from propagating during a move - add(e.target, 'click', returnFalse); - add(document, mouseevents.move, activeMousemove, data); - add(document, mouseevents.end, activeMouseend, data); - } - else { - // We're dealing with a touch. Stop touchmove doing - // anything defaulty. - e._preventTouchmoveDefault(); - add(document, touchevents.move + '.' + e.identifier, activeTouchmove, data); - add(document, touchevents.end + '.' + e.identifier, activeTouchend, data); - } - } - }; - - jQuery.event.special.move = { - setup: function() { - // Bind a noop to movestart. Why? It's the movestart - // setup that decides whether other move events are fired. - add(this, 'movestart.move', jQuery.noop); - }, - - teardown: function() { - remove(this, 'movestart.move', jQuery.noop); - } - }; - - jQuery.event.special.moveend = { - setup: function() { - // Bind a noop to movestart. Why? It's the movestart - // setup that decides whether other move events are fired. - add(this, 'movestart.moveend', jQuery.noop); - }, - - teardown: function() { - remove(this, 'movestart.moveend', jQuery.noop); - } - }; - - add(document, 'mousedown.move', mousedown); - add(document, 'touchstart.move', touchstart); - - // Make jQuery copy touch event properties over to the jQuery event - // object, if they are not already listed. But only do the ones we - // really need. IE7/8 do not have Array#indexOf(), but nor do they - // have touch events, so let's assume we can ignore them. - if (typeof Array.prototype.indexOf === 'function') { - (function(jQuery, undefined){ - var props = ["changedTouches", "targetTouches"], - l = props.length; - - while (l--) { - if (jQuery.event.props.indexOf(props[l]) === -1) { - jQuery.event.props.push(props[l]); - } - } - })(jQuery); - }; -}); \ No newline at end of file diff --git a/app/assets/javascripts/foundation/jquery.event.swipe.js b/app/assets/javascripts/foundation/jquery.event.swipe.js deleted file mode 100644 index d078cff..0000000 --- a/app/assets/javascripts/foundation/jquery.event.swipe.js +++ /dev/null @@ -1,130 +0,0 @@ -// jQuery.event.swipe -// 0.5 -// Stephen Band - -// Dependencies -// jQuery.event.move 1.2 - -// One of swipeleft, swiperight, swipeup or swipedown is triggered on -// moveend, when the move has covered a threshold ratio of the dimension -// of the target node, or has gone really fast. Threshold and velocity -// sensitivity changed with: -// -// jQuery.event.special.swipe.settings.threshold -// jQuery.event.special.swipe.settings.sensitivity - -(function (module) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], module); - } else { - // Browser globals - module(jQuery); - } -})(function(jQuery, undefined){ - var add = jQuery.event.add, - - remove = jQuery.event.remove, - - // Just sugar, so we can have arguments in the same order as - // add and remove. - trigger = function(node, type, data) { - jQuery.event.trigger(type, data, node); - }, - - settings = { - // Ratio of distance over target finger must travel to be - // considered a swipe. - threshold: 0.4, - // Faster fingers can travel shorter distances to be considered - // swipes. 'sensitivity' controls how much. Bigger is shorter. - sensitivity: 6 - }; - - function moveend(e) { - var w, h, event; - - w = e.target.offsetWidth; - h = e.target.offsetHeight; - - // Copy over some useful properties from the move event - event = { - distX: e.distX, - distY: e.distY, - velocityX: e.velocityX, - velocityY: e.velocityY, - finger: e.finger - }; - - // Find out which of the four directions was swiped - if (e.distX > e.distY) { - if (e.distX > -e.distY) { - if (e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) { - event.type = 'swiperight'; - trigger(e.currentTarget, event); - } - } - else { - if (-e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) { - event.type = 'swipeup'; - trigger(e.currentTarget, event); - } - } - } - else { - if (e.distX > -e.distY) { - if (e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) { - event.type = 'swipedown'; - trigger(e.currentTarget, event); - } - } - else { - if (-e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) { - event.type = 'swipeleft'; - trigger(e.currentTarget, event); - } - } - } - } - - function getData(node) { - var data = jQuery.data(node, 'event_swipe'); - - if (!data) { - data = { count: 0 }; - jQuery.data(node, 'event_swipe', data); - } - - return data; - } - - jQuery.event.special.swipe = - jQuery.event.special.swipeleft = - jQuery.event.special.swiperight = - jQuery.event.special.swipeup = - jQuery.event.special.swipedown = { - setup: function( data, namespaces, eventHandle ) { - var data = getData(this); - - // If another swipe event is already setup, don't setup again. - if (data.count++ > 0) { return; } - - add(this, 'moveend', moveend); - - return true; - }, - - teardown: function() { - var data = getData(this); - - // If another swipe event is still setup, don't teardown. - if (--data.count > 0) { return; } - - remove(this, 'moveend', moveend); - - return true; - }, - - settings: settings - }; -}); \ No newline at end of file diff --git a/app/assets/javascripts/foundation/jquery.foundation.accordion.js b/app/assets/javascripts/foundation/jquery.foundation.accordion.js deleted file mode 100644 index 84962fa..0000000 --- a/app/assets/javascripts/foundation/jquery.foundation.accordion.js +++ /dev/null @@ -1,38 +0,0 @@ -;(function ($, window, undefined){ - 'use strict'; - - $.fn.foundationAccordion = function (options) { - var $accordion = $('.accordion'); - - if ($accordion.hasClass('hover') && !Modernizr.touch) { - $('.accordion li', this).on({ - mouseenter : function () { - var p = $(this).parent(), - flyout = $(this).children('.content').first(); - - $('.content', p).not(flyout).hide().parent('li').removeClass('active'); //changed this - flyout.show(0, function () { - flyout.parent('li').addClass('active'); - }); - } - }); - } else { - $('.accordion li', this).on('click.fndtn', function () { - var li = $(this), - p = $(this).parent(), - flyout = $(this).children('.content').first(); - - if (li.hasClass('active')) { - p.find('li').removeClass('active').end().find('.content').hide(); - } else { - $('.content', p).not(flyout).hide().parent('li').removeClass('active'); //changed this - flyout.show(0, function () { - flyout.parent('li').addClass('active'); - }); - } - }); - } - - }; - -})( jQuery, this ); \ No newline at end of file diff --git a/app/assets/javascripts/foundation/jquery.foundation.alerts.js b/app/assets/javascripts/foundation/jquery.foundation.alerts.js deleted file mode 100644 index 7446160..0000000 --- a/app/assets/javascripts/foundation/jquery.foundation.alerts.js +++ /dev/null @@ -1,20 +0,0 @@ -;(function ($, window, undefined) { - 'use strict'; - - $.fn.foundationAlerts = function (options) { - var settings = $.extend({ - callback: $.noop - }, options); - - $(document).on("click", ".alert-box a.close", function (e) { - e.preventDefault(); - $(this).closest(".alert-box").fadeOut(function () { - $(this).remove(); - // Do something else after the alert closes - settings.callback(); - }); - }); - - }; - -})(jQuery, this); diff --git a/app/assets/javascripts/foundation/jquery.foundation.buttons.js b/app/assets/javascripts/foundation/jquery.foundation.buttons.js deleted file mode 100644 index b468e80..0000000 --- a/app/assets/javascripts/foundation/jquery.foundation.buttons.js +++ /dev/null @@ -1,83 +0,0 @@ -;(function ($, window, undefined) { - 'use strict'; - - $.fn.foundationButtons = function (options) { - var $doc = $(document), - config = $.extend({ - dropdownAsToggle:false, - activeClass:'active' - }, options), - - // close all dropdowns except for the dropdown passed - closeDropdowns = function (dropdown) { - // alert(dropdown.html()); - $('.button.dropdown').find('ul').not(dropdown).removeClass('show-dropdown'); - }, - // reset all toggle states except for the button passed - resetToggles = function (button) { - // alert(button.html()); - var buttons = $('.button.dropdown').not(button); - buttons.add($('> span.' + config.activeClass, buttons)).removeClass(config.activeClass); - }; - - // Prevent event propagation on disabled buttons - $doc.on('click.fndtn', '.button.disabled', function (e) { - e.preventDefault(); - }); - - $('.button.dropdown > ul', this).addClass('no-hover'); - - // reset other active states - $doc.on('click.fndtn', '.button.dropdown:not(.split), .button.dropdown.split span', function (e) { - var $el = $(this), - button = $el.closest('.button.dropdown'), - dropdown = $('> ul', button); - - // If the click is registered on an actual link then do not preventDefault which stops the browser from following the link - if (e.target.nodeName !== "A"){ - e.preventDefault(); - } - - // close other dropdowns - setTimeout(function () { - closeDropdowns(config.dropdownAsToggle ? dropdown : ''); - dropdown.toggleClass('show-dropdown'); - - if (config.dropdownAsToggle) { - resetToggles(button); - $el.toggleClass(config.activeClass); - } - }, 0); - }); - - // close all dropdowns and deactivate all buttons - $doc.on('click.fndtn', 'body, html', function (e) { - if (undefined == e.originalEvent) { return; } - // check original target instead of stopping event propagation to play nice with other events - if (!$(e.originalEvent.target).is('.button.dropdown:not(.split), .button.dropdown.split span')) { - closeDropdowns(); - if (config.dropdownAsToggle) { - resetToggles(); - } - } - }); - - // Positioning the Flyout List - var normalButtonHeight = $('.button.dropdown:not(.large):not(.small):not(.tiny):visible', this).outerHeight() - 1, - largeButtonHeight = $('.button.large.dropdown:visible', this).outerHeight() - 1, - smallButtonHeight = $('.button.small.dropdown:visible', this).outerHeight() - 1, - tinyButtonHeight = $('.button.tiny.dropdown:visible', this).outerHeight() - 1; - - $('.button.dropdown:not(.large):not(.small):not(.tiny) > ul', this).css('top', normalButtonHeight); - $('.button.dropdown.large > ul', this).css('top', largeButtonHeight); - $('.button.dropdown.small > ul', this).css('top', smallButtonHeight); - $('.button.dropdown.tiny > ul', this).css('top', tinyButtonHeight); - - $('.button.dropdown.up:not(.large):not(.small):not(.tiny) > ul', this).css('top', 'auto').css('bottom', normalButtonHeight - 2); - $('.button.dropdown.up.large > ul', this).css('top', 'auto').css('bottom', largeButtonHeight - 2); - $('.button.dropdown.up.small > ul', this).css('top', 'auto').css('bottom', smallButtonHeight - 2); - $('.button.dropdown.up.tiny > ul', this).css('top', 'auto').css('bottom', tinyButtonHeight - 2); - - }; - -})( jQuery, this ); diff --git a/app/assets/javascripts/foundation/jquery.foundation.clearing.js b/app/assets/javascripts/foundation/jquery.foundation.clearing.js deleted file mode 100644 index c1cf6b7..0000000 --- a/app/assets/javascripts/foundation/jquery.foundation.clearing.js +++ /dev/null @@ -1,413 +0,0 @@ -/* - * jQuery Foundation Clearing 1.2.1 - * http://foundation.zurb.com - * Copyright 2012, ZURB - * Free to use under the MIT license. - * http://www.opensource.org/licenses/mit-license.php -*/ - -/*jslint unparam: true, browser: true, indent: 2 */ - -;(function ($, window, document, undefined) { - 'use strict'; - - var defaults = { - templates : { - viewing : '×' + - '' - }, - - // comma delimited list of selectors that, on click, will close clearing, - // add 'div.clearing-blackout, div.visible-img' to close on background click - close_selectors : 'a.clearing-close', - - // event initializers and locks - initialized : false, - locked : false - }, - - cl = { - init : function (options, extendMethods) { - return this.find('ul[data-clearing]').each(function () { - var doc = $(document), - $el = $(this), - options = options || {}, - extendMethods = extendMethods || {}, - settings = $el.data('fndtn.clearing.settings'); - - if (!settings) { - options.$parent = $el.parent(); - - $el.data('fndtn.clearing.settings', $.extend({}, defaults, options)); - - cl.assemble($el.find('li')); - - if (!defaults.initialized) { - cl.events($el); - if (Modernizr.touch) cl.swipe_events(); - } - - } - }); - }, - - events : function (el) { - var settings = el.data('fndtn.clearing.settings'); - - $(document) - .on('click.fndtn.clearing', 'ul[data-clearing] li', function (e, current, target) { - var current = current || $(this), - target = target || current, - settings = current.parent().data('fndtn.clearing.settings'); - - e.preventDefault(); - - if (!settings) { - current.parent().foundationClearing(); - } - - // set current and target to the clicked li if not otherwise defined. - cl.open($(e.target), current, target); - cl.update_paddles(target); - }) - - .on('click.fndtn.clearing', '.clearing-main-right', function (e) { cl.nav(e, 'next') }) - .on('click.fndtn.clearing', '.clearing-main-left', function (e) { cl.nav(e, 'prev') }) - .on('click.fndtn.clearing', settings.close_selectors, this.close) - .on('keydown.fndtn.clearing', this.keydown); - - $(window).on('resize.fndtn.clearing', this.resize); - - defaults.initialized = true; - }, - - swipe_events : function () { - $(document) - .bind('swipeleft', 'ul[data-clearing]', function (e) { cl.nav(e, 'next') }) - .bind('swiperight', 'ul[data-clearing]', function (e) { cl.nav(e, 'prev') }) - .bind('movestart', 'ul[data-clearing]', function (e) { - if ((e.distX > e.distY && e.distX < -e.distY) || - (e.distX < e.distY && e.distX > -e.distY)) { - e.preventDefault(); - } - }); - }, - - assemble : function ($li) { - var $el = $li.parent(), - settings = $el.data('fndtn.clearing.settings'), - grid = $el.detach(), - data = { - grid: '', - viewing: settings.templates.viewing - }, - wrapper = '
' + data.viewing + data.grid + '
'; - - return settings.$parent.append(wrapper); - }, - - open : function ($image, current, target) { - var root = target.closest('.clearing-assembled'), - container = root.find('div:first'), - visible_image = container.find('.visible-img'), - image = visible_image.find('img').not($image); - - if (!cl.locked()) { - - // set the image to the selected thumbnail - image.attr('src', this.load($image)); - - image.loaded(function () { - // toggle the gallery if not visible - root.addClass('clearing-blackout'); - container.addClass('clearing-container'); - this.caption(visible_image.find('.clearing-caption'), $image); - visible_image.show(); - this.fix_height(target); - this.center(image); - - // shift the thumbnails if necessary - this.shift(current, target, function () { - target.siblings().removeClass('visible'); - target.addClass('visible'); - }); - }.bind(this)); - } - }, - - close : function (e) { - e.preventDefault(); - - var root = (function (target) { - if (/blackout/.test(target.selector)) { - return target; - } else { - return target.closest('.clearing-blackout'); - } - }($(this))), container, visible_image; - - if (this === e.target && root) { - container = root.find('div:first'), - visible_image = container.find('.visible-img'); - - defaults.prev_index = 0; - - root.find('ul[data-clearing]').attr('style', '') - root.removeClass('clearing-blackout'); - container.removeClass('clearing-container'); - visible_image.hide(); - } - - return false; - }, - - keydown : function (e) { - var clearing = $('.clearing-blackout').find('ul[data-clearing]'); - - if (e.which === 39) cl.go(clearing, 'next'); - if (e.which === 37) cl.go(clearing, 'prev'); - if (e.which === 27) $('a.clearing-close').trigger('click'); - }, - - nav : function (e, direction) { - var clearing = $('.clearing-blackout').find('ul[data-clearing]'); - - e.preventDefault(); - this.go(clearing, direction); - }, - - resize : function () { - var image = $('.clearing-blackout .visible-img').find('img'); - - if (image.length > 0) { - cl.center(image); - } - }, - - fix_height : function (target) { - var lis = target.siblings(); - - lis.each(function () { - var li = $(this), - image = li.find('img'); - - if (li.height() > image.outerHeight()) { - li.addClass('fix-height'); - } - }) - .closest('ul').width(lis.length * 100 + '%'); - }, - - update_paddles : function (target) { - var visible_image = target.closest('.carousel').siblings('.visible-img'); - - if (target.next().length > 0) { - visible_image.find('.clearing-main-right').removeClass('disabled'); - } else { - visible_image.find('.clearing-main-right').addClass('disabled'); - } - - if (target.prev().length > 0) { - visible_image.find('.clearing-main-left').removeClass('disabled'); - } else { - visible_image.find('.clearing-main-left').addClass('disabled'); - } - }, - - load : function ($image) { - var href = $image.parent().attr('href'); - - this.preload($image); - - if (href) return href; - return $image.attr('src'); - }, - - preload : function ($image) { - this.img($image.closest('li').next()); - this.img($image.closest('li').prev()); - }, - - img : function (img) { - if (img.length > 0) { - var new_img = new Image(), - new_a = img.find('a'); - - if (new_a.length > 0) { - new_img.src = new_a.attr('href'); - } else { - new_img.src = img.find('img').attr('src'); - } - } - }, - - caption : function (container, $image) { - var caption = $image.data('caption'); - - if (caption) { - container.text(caption).show(); - } else { - container.text('').hide(); - } - }, - - go : function ($ul, direction) { - var current = $ul.find('.visible'), - target = current[direction](); - - if (target.length > 0) { - target.find('img').trigger('click', [current, target]); - } - }, - - shift : function (current, target, callback) { - var clearing = target.parent(), - old_index = defaults.prev_index, - direction = this.direction(clearing, current, target), - left = parseInt(clearing.css('left'), 10), - width = target.outerWidth(), - skip_shift; - - // we use jQuery animate instead of CSS transitions because we - // need a callback to unlock the next animation - if (target.index() !== old_index && !/skip/.test(direction)){ - if (/left/.test(direction)) { - this.lock(); - clearing.animate({left : left + width}, 300, this.unlock); - } else if (/right/.test(direction)) { - this.lock(); - clearing.animate({left : left - width}, 300, this.unlock); - } - } else if (/skip/.test(direction)) { - - // the target image is not adjacent to the current image, so - // do we scroll right or not - skip_shift = target.index() - defaults.up_count; - this.lock(); - - if (skip_shift > 0) { - clearing.animate({left : -(skip_shift * width)}, 300, this.unlock); - } else { - clearing.animate({left : 0}, 300, this.unlock); - } - } - - callback(); - }, - - lock : function () { - defaults.locked = true; - }, - - unlock : function () { - defaults.locked = false; - }, - - locked : function () { - return defaults.locked; - }, - - direction : function ($el, current, target) { - var lis = $el.find('li'), - li_width = lis.outerWidth() + (lis.outerWidth() / 4), - up_count = Math.floor($('.clearing-container').outerWidth() / li_width) - 1, - target_index = lis.index(target), - response; - - defaults.up_count = up_count; - - if (this.adjacent(defaults.prev_index, target_index)) { - if ((target_index > up_count) && target_index > defaults.prev_index) { - response = 'right'; - } else if ((target_index > up_count - 1) && target_index <= defaults.prev_index) { - response = 'left'; - } else { - response = false; - } - } else { - response = 'skip'; - } - - defaults.prev_index = target_index; - - return response; - }, - - adjacent : function (current_index, target_index) { - for (var i = target_index + 1; i >= target_index - 1; i--) { - if (i === current_index) return true; - } - return false; - }, - - center : function (target) { - target.css({ - marginLeft : -(target.outerWidth() / 2), - marginTop : -(target.outerHeight() / 2) - }); - }, - - outerHTML : function (el) { - // support FireFox < 11 - return el.outerHTML || new XMLSerializer().serializeToString(el); - } - - }; - - $.fn.foundationClearing = function (method) { - if (cl[method]) { - return cl[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === 'object' || !method) { - return cl.init.apply(this, arguments); - } else { - $.error('Method ' + method + ' does not exist on jQuery.foundationClearing'); - } - }; - - // jquery.imageready.js - // @weblinc, @jsantell, (c) 2012 - - (function( $ ) { - $.fn.loaded = function ( callback, userSettings ) { - var - options = $.extend( {}, $.fn.loaded.defaults, userSettings ), - $images = this.find( 'img' ).add( this.filter( 'img' ) ), - unloadedImages = $images.length; - - function loaded () { - unloadedImages -= 1; - !unloadedImages && callback(); - } - - function bindLoad () { - this.one( 'load', loaded ); - if ( $.browser.msie ) { - var - src = this.attr( 'src' ), - param = src.match( /\?/ ) ? '&' : '?'; - param += options.cachePrefix + '=' + ( new Date() ).getTime(); - this.attr( 'src', src + param ); - } - } - - return $images.each(function () { - var $this = $( this ); - if ( !$this.attr( 'src' ) ) { - loaded(); - return; - } - this.complete || this.readyState === 4 ? - loaded() : - bindLoad.call( $this ); - }); - }; - - $.fn.loaded.defaults = { - cachePrefix: 'random' - }; - - }(jQuery)); - -}(jQuery, this, this.document)); diff --git a/app/assets/javascripts/foundation/jquery.foundation.forms.js b/app/assets/javascripts/foundation/jquery.foundation.forms.js deleted file mode 100644 index 3d0317b..0000000 --- a/app/assets/javascripts/foundation/jquery.foundation.forms.js +++ /dev/null @@ -1,486 +0,0 @@ -/* - * jQuery Custom Forms Plugin 1.0 - * www.ZURB.com - * Copyright 2010, ZURB - * Free to use under the MIT license. - * http://www.opensource.org/licenses/mit-license.php -*/ - -(function( $ ){ - - /** - * Helper object used to quickly adjust all hidden parent element's, display and visibility properties. - * This is currently used for the custom drop downs. When the dropdowns are contained within a reveal modal - * we cannot accurately determine the list-item elements width property, since the modal's display property is set - * to 'none'. - * - * This object will help us work around that problem. - * - * NOTE: This could also be plugin. - * - * @function hiddenFix - */ - var hiddenFix = function() { - - return { - /** - * Sets all hidden parent elements and self to visibile. - * - * @method adjust - * @param {jQuery Object} $child - */ - - // We'll use this to temporarily store style properties. - tmp : [], - - // We'll use this to set hidden parent elements. - hidden : null, - - adjust : function( $child ) { - // Internal reference. - var _self = this; - - // Set all hidden parent elements, including this element. - _self.hidden = $child.parents().andSelf().filter( ":hidden" ); - - // Loop through all hidden elements. - _self.hidden.each( function() { - - // Cache the element. - var $elem = $( this ); - - // Store the style attribute. - // Undefined if element doesn't have a style attribute. - _self.tmp.push( $elem.attr( 'style' ) ); - - // Set the element's display property to block, - // but ensure it's visibility is hidden. - $elem.css( { 'visibility' : 'hidden', 'display' : 'block' } ); - }); - - }, // end adjust - - /** - * Resets the elements previous state. - * - * @method reset - */ - reset : function() { - // Internal reference. - var _self = this; - // Loop through our hidden element collection. - _self.hidden.each( function( i ) { - // Cache this element. - var $elem = $( this ), - _tmp = _self.tmp[ i ]; // Get the stored 'style' value for this element. - - // If the stored value is undefined. - if( _tmp === undefined ) - // Remove the style attribute. - $elem.removeAttr( 'style' ); - else - // Otherwise, reset the element style attribute. - $elem.attr( 'style', _tmp ); - - }); - // Reset the tmp array. - _self.tmp = []; - // Reset the hidden elements variable. - _self.hidden = null; - - } // end reset - - }; // end return - - }; - - jQuery.foundation = jQuery.foundation || {}; - jQuery.foundation.customForms = jQuery.foundation.customForms || {}; - - $.foundation.customForms.appendCustomMarkup = function ( options ) { - - var defaults = { - disable_class: "js-disable-custom" - }; - - options = $.extend( defaults, options ); - - function appendCustomMarkup(idx, sel) { - var $this = $(sel).hide(), - type = $this.attr('type'), - $span = $this.next('span.custom.' + type); - - if ($span.length === 0) { - $span = $('').insertAfter($this); - } - - $span.toggleClass('checked', $this.is(':checked')); - $span.toggleClass('disabled', $this.is(':disabled')); - } - - function appendCustomSelect(idx, sel) { - var hiddenFixObj = hiddenFix(); - // - // jQueryify the element. - // - $options = $this.find( 'option' ), - // - // Filter down the selected options - // - $selectedOption = $options.filter( ':selected' ), - // - // Initial max width. - // - maxWidth = 0, - // - // We'll use this variable to create the
  • elements for our custom select. - // - liHtml = '', - // - // We'll use this to cache the created
  • elements within our custom select. - // - $listItems - ; - var $currentSelect = false; - // - // Should we not create a custom list? - // - if ( $this.hasClass( 'no-custom' ) ) return; - - // - // Did we not create a custom select element yet? - // - if ( $customSelect.length === 0 ) { - // - // Let's create our custom select element! - // - - // - // Determine what select size to use. - // - var customSelectSize = $this.hasClass( 'small' ) ? 'small' : - $this.hasClass( 'medium' ) ? 'medium' : - $this.hasClass( 'large' ) ? 'large' : - $this.hasClass( 'expand' ) ? 'expand' : '' - ; - // - // Build our custom list. - // - $customSelect = $('
    "'); - // - // Grab the selector element - // - $selector = $customSelect.find( ".selector" ); - // - // Grab the unordered list element from the custom list. - // - $customList = $customSelect.find( "ul" ); - // - // Build our
  • elements. - // - liHtml = $options.map( function() { return "
  • " + $( this ).html() + "
  • "; } ).get().join( '' ); - // - // Append our
  • elements to the custom list (