diff --git a/.gitignore b/.gitignore index fe6fe65..b909155 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ # ignore IDE files .idea/* +<<<<<<< HEAD +======= # ignore yard doc files -.yardoc/* \ No newline at end of file +.yardoc/* +>>>>>>> 97cb77ae9aa380ac8352b49ae90b0c118aa9d2a2 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ff8c728 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: ruby +rvm: + - 2.1.10 + +services: + - mysql + +before_script: + - cp config/database_example.yml config/database.yml + - cp config/secrets_example.yml config/secrets.yml + - mysql -e 'create database IF NOT EXISTS roadmap_test;' -uroot + +script: + - bundle exec rake db:test:prepare + - bundle exec rake diff --git a/Gemfile b/Gemfile index 7be2a89..dcc388e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,18 +2,19 @@ # # RAILS # -gem 'rails', '4.0.0' +gem 'rails', '4.2.0' # additional gems for rails 4 -gem 'turbolinks' -gem 'railties', '= 4.0.0' +gem 'railties'#, '= 4.2.0' +gem 'responders', '~> 2.0' # allows use of respond_with and respond_to in controllers + # add these gems to help with the transition: gem 'protected_attributes' gem 'rails-observers' gem 'actionpack-page_caching' gem 'actionpack-action_caching' -gem 'uglifier', '>= 1.3.0' +gem 'uglifier' #, '>= 1.3.0' # Gems used only for assets and not required in production environments by default. #group :assets do @@ -27,7 +28,7 @@ # Use SCSS for stylesheets gem 'less-rails' gem 'twitter-bootstrap-rails', '2.2.8' -gem 'therubyracer', '0.11.4', platforms: :ruby +gem 'therubyracer', '>=0.11.4', platforms: :ruby #'0.11.4', platforms: :ruby gem 'libv8' @@ -40,10 +41,14 @@ #to allow cloning of objects gem 'amoeba' +group :development, :test do + gem "byebug" +end + group :development do - gem 'web-console', '~>2.0' gem "better_errors" gem "binding_of_caller" + gem 'web-console', '~>2.0' end # @@ -63,7 +68,7 @@ # # DATABASE/SERVER # -gem 'mysql2', '~> 0.3.10' +gem 'mysql2', '~> 0.3.18' # Use unicorn as the app server # gem 'unicorn' #cancan for usergroups @@ -74,7 +79,7 @@ # gem 'jquery-rails' gem 'tinymce-rails' -gem 'friendly_id', '~> 5.0.1' +gem 'friendly_id' #, '~> 5.0.1' gem 'contact_us' gem 'recaptcha' gem 'turbolinks' @@ -117,3 +122,7 @@ gem 'yard' gem 'redcarpet' +# +# API +# +gem 'swagger-docs' diff --git a/README.md b/README.md index eae0ba3..67fcb25 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,103 @@ ## DMP Roadmap +DMP Roadmap is a Data Management Planning tool. It allows users to create data management plans for the projects using funder specific templates and institutional guidance. Once a plan has been completed it can be downloaded and inserted into your grant proposals. + +Management and development of the DMP Roadmap is jointly provided by the Digital Curation Centre (DCC), http://www.dcc.ac.uk/, and the University of California Curation Center (UC3), http://www.cdlib.org/services/uc3/ + +The tool has four main functions +1. To help create and maintain different versions of Data Management Plans; +2. To provide useful guidance on data management issues and how to meet research funders' requirements; +3. To export attractive and useful plans in a variety of formats; +4. To allow collaborative work when creating Data Management Plans. + #### Current Release v.0.1.0 +[![Build Status](https://travis-ci.org/DMPRoadmap/roadmap.svg)](https://travis-ci.org/DMPRoadmap/roadmap) #### Summary +#### Pre-requisites +Roadmap is a Ruby on Rails application and you will need to have: +1. Ruby >= 2.0.0p247 +2. Rails >= 4.0 +3. MySql >= 5.0 + +Further details on how to install Ruby on Rails applications are available from the Ruby on Rails site: http://rubyonrails.org + +Further details on how to install MySQL and create your first user and database. Be sure to follow the instructions for your particular environment. +* Install: http://dev.mysql.com/downloads/mysql/ +* +* Create a user: http://dev.mysql.com/doc/refman/5.7/en/create-user.html +* Create the database: http://dev.mysql.com/doc/refman/5.7/en/creating-database.html + +You may also find the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + #### Installation -Clone the repository and build from the latest tag +* Create your mysql db. Select UTF-8 Unicode (utf8mb4) encoding. +* Fork the repository and then clone it onto your server + +> > git clone https://github.com/[your organization]/roadmap.git + +> > cd roadmap + +* Make copies of the yaml configuration files and update the values for your installation + +> > cp config/database_example.yml config/database.yml +> > cp config/secrets_example.yml config/secrets.yml + +* Create an environment variable for your instance's secret (as defined in config/secrets.yml). You should use the following command to generate secrets for each of your environments, storing the production one in the environment variable: + +> > rake secret + +* Run bundler and perform the DB migrations + +> > gem install bundler (if bundler is not yet installed) + +> > bundle install + +> > rake db:migrate + +> > rake db:seed + +* Setup the devise authentication gem + +> > rails generate devise:install (Is this really necessary?) + +* Start the application + +> > rails server + +* Verify that the site is running properly by going to http://localhost:3000 +* Login as the default administrator: 'super_admin@example.com' - 'password1' #### Troubleshooting +##### Installation - OSX: + +``` +An error occurred while installing libv8 (3.11.8.17), and Bundler cannot continue. + +Make sure that `gem install libv8 -v '3.11.8.17'` succeeds before bundling. +``` + +If you are installing on a system that already has v8 installed then you may need to install the libv8 gem manually using your system's current v8 engine. If you're using homebrew to manage your packages you should run 'brew update' and 'brew upgrade' to make sure you have the latest packages + +> > gem uninstall -a libv8 + +> > gem install libv8 -v '<>' -- --with-system-v8 + +> > bundle install + +#### Support +Issues should be reported here on Github https://github.com/DMPRoadmap/roadmap/issues +Please be advised though that we can only provide limited support for your local installations. #### Become a contributor -Fork the repository. +Fork this repository and make your modifications in a new branch. Then create a pull request to our 'development' branch. We will reject any pull request made against the 'master' branch. Once your pull request has been submitted the team will review your request and accept it if appropriate. + +Join the email listserv at roadmap-l (at) listserv.ucop (dot) edu. #### License The DMP Roadmap project uses to the MIT License. diff --git a/README.rdoc b/README.rdoc index 3ca4a88..9a680a0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,10 +1,8 @@ -= DMPonline v4 += DMPRoadmap -DMPonline is the DCC's data management planning tool, available at https://dmponline.dcc.ac.uk +Roadmap is a data management planning tool, available at https://github.com/DMPRoadmap/roadmap -Development of the DMPonline by the Digital Curation Centre has been funded by JISC. JISC inspires UK colleges and universities in the innovative use of digital technologies, helping to maintain the UK's position as a global leader in education. www.jisc.ac.uk - -This is just the application code, the accompanying question data available at https://dmponline.dcc.ac.uk is not included. +Development of the Roadmap is provided by the Digital Curation Centre and the University of California Curation Center. The tool has four main functions 1. To help create and maintain different versions of Data Management Plans; @@ -14,15 +12,16 @@ == Documentation & Support -* You can contact us by email, dmponline@dcc.ac.uk, but we can only provide limited support for your installation +* You can contact us by email, roadmap-l@listserv.ucop.edu, but we can only provide limited support for your installation == Bugs & Feature Requests -* Bug Reports & Feature Requests: https://github.com/DigitalCurationCentre/DMPonline_v4/issues +* Bug Reports & Feature Requests: https://github.com/DMPRoadmap/roadmap/issues +* Please prefix your request with either: 'Bug:' or 'Feature:' == Prerequisites -DMPonline is a Ruby on Rails application and you will need to have Ruby 2.0.0p247 or greater installed on your server and a MySQL server v5.0 or greater. +Roadmap is a Ruby on Rails application and you will need to have Ruby 2.0.0p247 or greater installed on your server and a MySQL server v5.0 or greater. Further details on how to install Ruby on Rails applications are available from the Ruby on Rails site, http://rubyonrails.org @@ -34,10 +33,4 @@ == Copyright -Copyright (c) 2013 Digital Curation Centre, University of Edinburgh. - -This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses. +The Roadmap project uses an MIT License. The full text of the license can be found at: https://github.com/DMPRoadmap/roadmap/blob/master/LICENSE.md diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index 6a2a218..0d74091 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ #!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - +require 'rake/testtask' require File.expand_path('../config/application', __FILE__) DMPonline4::Application.load_tasks @@ -18,3 +18,4 @@ rdoc.options << "--all" end +task default: :test diff --git a/app/admin/dmptemplate.rb b/app/admin/dmptemplate.rb index 73d8877..c172563 100644 --- a/app/admin/dmptemplate.rb +++ b/app/admin/dmptemplate.rb @@ -39,7 +39,8 @@ end end - action_item only: %i( show edit ) do + #action_item only: %i( show edit ) do + action_item(:edit) do link_to(I18n.t('helpers.settings.title'), settings_admin_dmptemplate_path(resource.id)) end diff --git a/app/admin/token_permission.rb b/app/admin/token_permission.rb new file mode 100644 index 0000000..ed1bd19 --- /dev/null +++ b/app/admin/token_permission.rb @@ -0,0 +1,31 @@ +ActiveAdmin.register TokenPermission do + permit_params :api_token, :token_permission_type_id, :user_id + + #TODO: make migration to add user_id to the model so we can have the relationship... + + menu priority:25, label: proc{ I18n.t('admin.token_permission')}, parent: "Api" + + index do + column I18n.t('admin.user') do |n| + link_to n.user.email, [:admin,n] + end + column I18n.t('admin.token_permission') do |n| + link_to n.token_permission_type, [:admin, n] + end + actions + end + + show do + attributes_table do + row :user_id + row :token_permission_type_id + row :api_token + end + end + + controller do + def permitted_params + params.permit! + end + end +end diff --git a/app/admin/user.rb b/app/admin/user.rb index 67c5852..450472f 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -87,6 +87,7 @@ f.input :surname f.input :email f.input :orcid_id + f.input :api_token # f.input :shibboleth_id f.input :organisation_id ,:label => I18n.t('admin.org_title'), :as => :select, @@ -103,8 +104,8 @@ :multiple => true, :include_blank => I18n.t('helpers.none'), :collection => Role.order('name').map{|ro| [ro.name, ro.id]} - f.input :api_token + f.input :api_token end f.actions diff --git a/app/assets/fonts/fontawesome-webfont.woff b/app/assets/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..6e7483c --- /dev/null +++ b/app/assets/fonts/fontawesome-webfont.woff Binary files differ diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 35289e6..0b5dcdd 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -179,20 +179,24 @@ //action for show or hide template editing display - $('#edit_template_button').click(function(){ + $('#edit_template_button').click(function(e){ + e.preventDefault(); + $('#edit_template_div').show(); $('#show_template_div').hide(); }); //action for show or hide phase display - $('#edit_phase_button').click(function(){ + $('#edit_phase_button').click(function(e){ + e.preventDefault(); $('#edit_phase_div').show(); $('#show_phase_div').hide(); }); //action to hide the alert to edit a version - $("#edit-version-confirmed").click(function (){ + $("#edit-version-confirmed").click(function (e){ + e.preventDefault(); $("#version_edit_alert").modal("hide"); }); @@ -230,7 +234,7 @@ $('.new_question_save_button').click(function(e){ var s_id = $(this).prev(".section_id").val(); if ($('#new_question_text_'+ s_id).val() == ''){ - alert(I18n.t("question_text_empty")); + alert(I18n.t("js.question_text_empty")); return false; } }); @@ -323,24 +327,24 @@ //verify if text area is not nil var editorContent = tinyMCE.get('guidance-text').getContent(); if (editorContent == ''){ - alert_message.push(I18n.t("add_guidance_text")); + alert_message.push(I18n.t("js.add_guidance_text")); } //verify dropdown with questions has a selected option if guidance for a question being used if ($('#g_options').val() == '2') { if ($('#questions_select').val() == '' || isNaN($('#questions_select').val())){ - alert_message.push(I18n.t("select_question")); + alert_message.push(I18n.t("js.select_question")); } } //verify dropdown with questions has a selected option if guidance for a question being used if ($('#g_options').val() == '1' ){ if($('#guidance_theme_ids').val() == undefined || $('#guidance_theme_ids').val() == ''){ - alert_message.push(I18n.t("select_at_least_one_theme")); + alert_message.push(I18n.t("js.select_at_least_one_theme")); } } //verify if guidance group is selected if ( ($('#guidance_guidance_group_ids').val() == '') || $('#guidance_guidance_group_ids').val() == undefined ) { - alert_message.push(I18n.t("select_guidance_group")); + alert_message.push(I18n.t("js.select_guidance_group")); } if(alert_message.length == 0){ //clear dropdowns before submission @@ -385,23 +389,23 @@ //verify if text area is not nil var editorContent = tinyMCE.get('guidance-text').getContent(); if (editorContent == ''){ - alert_message.push(I18n.t("add_guidance_text")); + alert_message.push(I18n.t("js.add_guidance_text")); } //verify dropdown with questions has a selected option if guidance for a question being used if ($('#g_options').val() == '2') { if ($('#questions_select').val() == '' || isNaN($('#questions_select').val())){ - alert_message.push(I18n.t("select_question")); + alert_message.push(I18n.t("js.select_question")); } } //verify dropdown with questions has a selected option if guidance for a question being used if ($('#g_options').val() == '1' ){ if($('#guidance_theme_ids').val() == undefined || $('#guidance_theme_ids').val() == ''){ - alert_message.push(I18n.t("select_at_least_one_theme")); + alert_message.push(I18n.t("js.select_at_least_one_theme")); } } //verify if guidance group is selected if ( ($('#guidance_guidance_group_ids').val() == '') || $('#guidance_guidance_group_ids').val() == undefined ) { - alert_message.push(I18n.t("select_guidance_group")); + alert_message.push(I18n.t("js.select_guidance_group")); } if(alert_message.length == 0){ @@ -433,7 +437,7 @@ //Validate banner_text area for less than 165 character $("form#edit_org_details").submit(function(){ if (getStats('org_banner_text').chars > 165) { - alert(I18n.t("enter_up_to") + " " + getStats('org_banner_text').chars + ". " + I18n.t("if_using_url_try")); + alert(I18n.t("js.enter_up_to") + " " + getStats('org_banner_text').chars + ". " + I18n.t("js.if_using_url_try")); return false; } }); @@ -450,8 +454,6 @@ $(link).closest(".options_content").hide(); } - - function add_object(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); @@ -461,7 +463,6 @@ } } - // Returns text statistics for the specified editor by id function getStats(id) { var body = tinymce.get(id).getBody(), text = tinymce.trim(body.innerText || body.textContent); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 464ff02..0a76459 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,16 +12,15 @@ // //= require jquery //= require jquery_ujs -//= require bootstrap +//= require twitter/bootstrap //= require v1.js //= require select2.min.js //= require jquery.placeholder.js -//= require turbolinks +//= require tinymce-jquery //= require i18n //= require i18n/translations - $( document ).ready(function() { $(function(){ @@ -62,7 +61,9 @@ trigger: "focus" }); - $(".show-edit-toggle").click(function () { + $(".show-edit-toggle").click(function (e) { + e.preventDefault(); + $(".edit-project").toggle(); $(".view-project").toggle(); }); @@ -120,7 +121,6 @@ $("#user_organisation_id").change(); }); - //alert dialog for unlink Shibbileth account $("#unlink-institutional-credentials-dialog").on("show", function(){ $('.select2-choice').hide(); @@ -137,6 +137,43 @@ }); + //Question Options + // ------------------------------------------------------------------------------------ + $(".options_table").on("click", ".remove-option", function(e){ + e.preventDefault(); + + // Mark the option for removal + $($(this).siblings()[0]).val(true); + + // Hide the entire table row and the associated hidden field for the item + $(this).parent().parent().addClass('hidden'); + }); + + $(".add-option").click(function(e){ + e.preventDefault(); + + var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"), + last = tbl.find("tr:last"), + clone = last.clone(); + nbr = parseInt(last.find(".number_field").val()); + + // Update the input field names and ids + clone.find("input").each(function(index){ + $(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_")); + $(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]")); + }); + + // Remove the hidden class and make sure the new row is not marked for removal + clone.removeClass('hidden'); + clone.find("[id$=" + nbr + "__destroy]").val(false); + + // Default the other values + clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1)); + clone.find("[id$=" + nbr + "_text]").val(""); + clone.find("[id$=" + nbr + "_is_default]").prop("checked", false); + + last.after(clone); + }); /*$('#continue-to-new').click(function(e){ var destination = $(this).attr("href"); diff --git a/app/assets/javascripts/bootstrap.js b/app/assets/javascripts/bootstrap.js deleted file mode 100644 index 643e71c..0000000 --- a/app/assets/javascripts/bootstrap.js +++ /dev/null @@ -1,2280 +0,0 @@ -/* =================================================== - * bootstrap-transition.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#transitions - * =================================================== - * Copyright 2012 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"; // jshint ;_; - - - /* CSS TRANSITION SUPPORT (http://www.modernizr.com/) - * ======================================================= */ - - $(function () { - - $.support.transition = (function () { - - var transitionEnd = (function () { - - var el = document.createElement('bootstrap') - , transEndEventNames = { - 'WebkitTransition' : 'webkitTransitionEnd' - , 'MozTransition' : 'transitionend' - , 'OTransition' : 'oTransitionEnd otransitionend' - , 'transition' : 'transitionend' - } - , name - - for (name in transEndEventNames){ - if (el.style[name] !== undefined) { - return transEndEventNames[name] - } - } - - }()) - - return transitionEnd && { - end: transitionEnd - } - - })() - - }) - -}(window.jQuery);/* ========================================================== - * bootstrap-alert.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#alerts - * ========================================================== - * Copyright 2012 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"; // jshint ;_; - - - /* ALERT CLASS DEFINITION - * ====================== */ - - var dismiss = '[data-dismiss="alert"]' - , Alert = function (el) { - $(el).on('click', dismiss, this.close) - } - - Alert.prototype.close = function (e) { - var $this = $(this) - , selector = $this.attr('data-target') - , $parent - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 - } - - $parent = $(selector) - - e && e.preventDefault() - - $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) - - $parent.trigger(e = $.Event('close')) - - if (e.isDefaultPrevented()) return - - $parent.removeClass('in') - - function removeElement() { - $parent - .trigger('closed') - .remove() - } - - $.support.transition && $parent.hasClass('fade') ? - $parent.on($.support.transition.end, removeElement) : - removeElement() - } - - - /* ALERT PLUGIN DEFINITION - * ======================= */ - - var old = $.fn.alert - - $.fn.alert = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('alert') - if (!data) $this.data('alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) - }) - } - - $.fn.alert.Constructor = Alert - - - /* ALERT NO CONFLICT - * ================= */ - - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this - } - - - /* ALERT DATA-API - * ============== */ - - $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) - -}(window.jQuery);/* ============================================================ - * bootstrap-button.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#buttons - * ============================================================ - * Copyright 2012 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"; // jshint ;_; - - - /* BUTTON PUBLIC CLASS DEFINITION - * ============================== */ - - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, $.fn.button.defaults, options) - } - - Button.prototype.setState = function (state) { - var d = 'disabled' - , $el = this.$element - , data = $el.data() - , val = $el.is('input') ? 'val' : 'html' - - state = state + 'Text' - data.resetText || $el.data('resetText', $el[val]()) - - $el[val](data[state] || this.options[state]) - - // push to event loop to allow forms to submit - setTimeout(function () { - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d) - }, 0) - } - - Button.prototype.toggle = function () { - var $parent = this.$element.closest('[data-toggle="buttons-radio"]') - - $parent && $parent - .find('.active') - .removeClass('active') - - this.$element.toggleClass('active') - } - - - /* BUTTON PLUGIN DEFINITION - * ======================== */ - - var old = $.fn.button - - $.fn.button = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('button') - , options = typeof option == 'object' && option - if (!data) $this.data('button', (data = new Button(this, options))) - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) - } - - $.fn.button.defaults = { - loadingText: 'loading...' - } - - $.fn.button.Constructor = Button - - - /* BUTTON NO CONFLICT - * ================== */ - - $.fn.button.noConflict = function () { - $.fn.button = old - return this - } - - - /* BUTTON DATA-API - * =============== */ - - $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - $btn.button('toggle') - }) - -}(window.jQuery);/* ========================================================== - * bootstrap-carousel.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#carousel - * ========================================================== - * Copyright 2012 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"; // jshint ;_; - - - /* CAROUSEL CLASS DEFINITION - * ========================= */ - - var Carousel = function (element, options) { - this.$element = $(element) - this.$indicators = this.$element.find('.carousel-indicators') - this.options = options - this.options.pause == 'hover' && this.$element - .on('mouseenter', $.proxy(this.pause, this)) - .on('mouseleave', $.proxy(this.cycle, this)) - } - - Carousel.prototype = { - - cycle: function (e) { - if (!e) this.paused = false - if (this.interval) clearInterval(this.interval); - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - return this - } - - , getActiveIndex: function () { - this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children() - return this.$items.index(this.$active) - } - - , to: function (pos) { - var activeIndex = this.getActiveIndex() - , that = this - - if (pos > (this.$items.length - 1) || pos < 0) return - - if (this.sliding) { - return this.$element.one('slid', function () { - that.to(pos) - }) - } - - if (activeIndex == pos) { - return this.pause().cycle() - } - - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) - } - - , pause: function (e) { - if (!e) this.paused = true - if (this.$element.find('.next, .prev').length && $.support.transition.end) { - this.$element.trigger($.support.transition.end) - this.cycle(true) - } - clearInterval(this.interval) - this.interval = null - return this - } - - , next: function () { - if (this.sliding) return - return this.slide('next') - } - - , prev: function () { - if (this.sliding) return - return this.slide('prev') - } - - , slide: function (type, next) { - var $active = this.$element.find('.item.active') - , $next = next || $active[type]() - , isCycling = this.interval - , direction = type == 'next' ? 'left' : 'right' - , fallback = type == 'next' ? 'first' : 'last' - , that = this - , e - - this.sliding = true - - isCycling && this.pause() - - $next = $next.length ? $next : this.$element.find('.item')[fallback]() - - e = $.Event('slide', { - relatedTarget: $next[0] - , direction: direction - }) - - if ($next.hasClass('active')) return - - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - this.$element.one('slid', function () { - var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) - $nextIndicator && $nextIndicator.addClass('active') - }) - } - - if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - this.$element.one($.support.transition.end, function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) - }) - } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger('slid') - } - - isCycling && this.cycle() - - return this - } - - } - - - /* CAROUSEL PLUGIN DEFINITION - * ========================== */ - - var old = $.fn.carousel - - $.fn.carousel = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('carousel') - , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) - , action = typeof option == 'string' ? option : options.slide - if (!data) $this.data('carousel', (data = new Carousel(this, options))) - if (typeof option == 'number') data.to(option) - else if (action) data[action]() - else if (options.interval) data.pause().cycle() - }) - } - - $.fn.carousel.defaults = { - interval: 5000 - , pause: 'hover' - } - - $.fn.carousel.Constructor = Carousel - - - /* CAROUSEL NO CONFLICT - * ==================== */ - - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this - } - - /* CAROUSEL DATA-API - * ================= */ - - $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var $this = $(this), href - , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = $.extend({}, $target.data(), $this.data()) - , slideIndex - - $target.carousel(options) - - if (slideIndex = $this.attr('data-slide-to')) { - $target.data('carousel').pause().to(slideIndex).cycle() - } - - e.preventDefault() - }) - -}(window.jQuery);/* ============================================================= - * bootstrap-collapse.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#collapse - * ============================================================= - * Copyright 2012 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"; // jshint ;_; - - - /* COLLAPSE PUBLIC CLASS DEFINITION - * ================================ */ - - var Collapse = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, $.fn.collapse.defaults, options) - - if (this.options.parent) { - this.$parent = $(this.options.parent) - } - - this.options.toggle && this.toggle() - } - - Collapse.prototype = { - - constructor: Collapse - - , dimension: function () { - var hasWidth = this.$element.hasClass('width') - return hasWidth ? 'width' : 'height' - } - - , show: function () { - var dimension - , scroll - , actives - , hasData - - if (this.transitioning || this.$element.hasClass('in')) return - - dimension = this.dimension() - scroll = $.camelCase(['scroll', dimension].join('-')) - actives = this.$parent && this.$parent.find('> .accordion-group > .in') - - if (actives && actives.length) { - hasData = actives.data('collapse') - if (hasData && hasData.transitioning) return - actives.collapse('hide') - hasData || actives.data('collapse', null) - } - - this.$element[dimension](0) - this.transition('addClass', $.Event('show'), 'shown') - $.support.transition && this.$element[dimension](this.$element[0][scroll]) - } - - , hide: function () { - var dimension - if (this.transitioning || !this.$element.hasClass('in')) return - dimension = this.dimension() - this.reset(this.$element[dimension]()) - this.transition('removeClass', $.Event('hide'), 'hidden') - this.$element[dimension](0) - } - - , reset: function (size) { - var dimension = this.dimension() - - this.$element - .removeClass('collapse') - [dimension](size || 'auto') - [0].offsetWidth - - this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') - - return this - } - - , transition: function (method, startEvent, completeEvent) { - var that = this - , complete = function () { - if (startEvent.type == 'show') that.reset() - that.transitioning = 0 - that.$element.trigger(completeEvent) - } - - this.$element.trigger(startEvent) - - if (startEvent.isDefaultPrevented()) return - - this.transitioning = 1 - - this.$element[method]('in') - - $.support.transition && this.$element.hasClass('collapse') ? - this.$element.one($.support.transition.end, complete) : - complete() - } - - , toggle: function () { - this[this.$element.hasClass('in') ? 'hide' : 'show']() - } - - } - - - /* COLLAPSE PLUGIN DEFINITION - * ========================== */ - - var old = $.fn.collapse - - $.fn.collapse = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('collapse') - , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option) - if (!data) $this.data('collapse', (data = new Collapse(this, options))) - if (typeof option == 'string') data[option]() - }) - } - - $.fn.collapse.defaults = { - toggle: true - } - - $.fn.collapse.Constructor = Collapse - - - /* COLLAPSE NO CONFLICT - * ==================== */ - - $.fn.collapse.noConflict = function () { - $.fn.collapse = old - return this - } - - - /* COLLAPSE DATA-API - * ================= */ - - $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { - var $this = $(this), href - , target = $this.attr('data-target') - || e.preventDefault() - || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 - , option = $(target).data('collapse') ? 'toggle' : $this.data() - $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') - $(target).collapse(option) - }) - -}(window.jQuery);/* ============================================================ - * bootstrap-dropdown.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#dropdowns - * ============================================================ - * Copyright 2012 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"; // jshint ;_; - - - /* DROPDOWN CLASS DEFINITION - * ========================= */ - - var toggle = '[data-toggle=dropdown]' - , Dropdown = function (element) { - var $el = $(element).on('click.dropdown.data-api', this.toggle) - $('html').on('click.dropdown.data-api', function () { - $el.parent().removeClass('open') - }) - } - - Dropdown.prototype = { - - constructor: Dropdown - - , toggle: function (e) { - var $this = $(this) - , $parent - , isActive - - if ($this.is('.disabled, :disabled')) return - - $parent = getParent($this) - - isActive = $parent.hasClass('open') - - clearMenus() - - if (!isActive) { - if ('ontouchstart' in document.documentElement) { - // if mobile we we use a backdrop because click events don't delegate - $('