Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoring javascript: cleanup ui module, update modernizr and impro…

…ve Form module

Signed-off-by: Jorge Cuadrado <kuadrosxx@gmail.com>
  • Loading branch information...
commit d20701293a4418f5c8170128c4de49d748a484cd 1 parent 5d48b08
@kuadrosx kuadrosx authored patcito committed
View
15 app/assets/javascripts/app/modules/authentication.js
@@ -2,10 +2,17 @@ Auth = function() {
var self = this;
function initialize() {
- $('.auth-provider').live("click", function(){
+ $('.auth-provider').live("click", function(e){
+ e.preventDefault();
var authUrl = $(this).attr('href');
openPopup(authUrl);
- return false;
+ });
+
+ $('#openid_url').parents('form').submit(function(){
+ var openid = $('#openid_url').val();
+ openid = openid.replace('http://','');
+ openid = openid.replace('https://','');
+ $('#openid_url').val(openid)
});
}
@@ -21,7 +28,7 @@ Auth = function() {
var toggleClass = $(this).data('toggle-dropdown');
$('.dropdown-form').addClass('hidden');
var toggleEle = $('.'+toggleClass).toggleClass('hidden');
- position_dropdown();
+ positionDropdown();
$('.providers-list').show();
return false;
})
@@ -43,7 +50,7 @@ Auth = function() {
}
function startLoginDialog(title,join){
- if(Ui.not_member()){
+ if(Ui.notMember()){
var title = $('#join_dialog').attr('data-title');
$('#join_dialog').dialog({title: title, modal: true, resizable: false})
} else {
View
4 app/assets/javascripts/app/modules/comments.js
@@ -35,12 +35,12 @@ Comments = function() {
return false;
});
- $(".content-panel").delegate(".comment", "hover", function(handlerIn, handlerOut) {
+ $(".content-panel").on("hover", ".comment", function(handlerIn, handlerOut) {
var show = (handlerIn.type == "mouseenter");
$(this).find(".comment-votes form.comment-form button.vote").toggle(show);
});
- $(".content-panel").delegate(".comment-votes .comment-form", "submit", function(event) {
+ $(".content-panel").on("submit", ".comment-votes .comment-form", function(event) {
var form = $(this);
var btn = form.find('button');
btn.attr('disabled', true);
View
16 app/assets/javascripts/app/modules/effects.js
@@ -2,22 +2,6 @@ Effects = function(){
var self =this;
function initialize() {
- $('ul.menubar').droppy({
- className: 'dropHover',
- autoArrows: false,
- trigger: 'click'
- });
-
- $('ul.menubar .has-subnav').click(function(e) {
- e.preventDefault();
- })
-
- $(".highlight_for_user").effect("highlight", {}, 2000);
-
- $(".btn-answer").click(function() {
- $("#panel-answer").slideToggle("slow");
- $(this).toggleClass("active"); return false;
- });
}
function fade(object) {
View
18 app/assets/javascripts/app/modules/form.js
@@ -2,14 +2,16 @@ Form = function() {
var self = this;
function initialize() {
- $("input[type=color]").jPicker({
- window: {
- expandable: true,
- position: { x: 'screenCenter', y: 'center'}
- },
- images: { clientPath: '/images/jpicker/' }
- });
- $("input[type=color]").hide();
+ if(!Modernizr.inputtypes.color) {
+ $("input[type=color]").jPicker({
+ window: {
+ expandable: true,
+ position: { x: 'screenCenter', y: 'center'}
+ },
+ images: { clientPath: '/images/jpicker/' }
+ });
+ $("input[type=color]").hide();
+ }
}
return {
View
8 app/assets/javascripts/app/modules/questions.js
@@ -18,6 +18,14 @@ Questions = function() {
$(".Question .toolbar").shapadoToolbar();
Votes.initializeOnQuestions();
+ if(Questions.isIndexEmpty()){
+ var current_language = $('.current_language > a').data('language');
+ if(current_language!='any'){
+ $('.current_language').tipsy({trigger: 'manual', gravity: 'w'});
+ $('.current_language').tipsy('show');
+ }
+ }
+
var extraParams = Utils.urlVars();
extraParams['format'] = 'js';
View
194 app/assets/javascripts/app/modules/ui.js
@@ -2,36 +2,14 @@ Ui = function() {
var self = this;
function initialize() {
- if(typeof(Effects) !== 'undefined'){
- Effects.initialize();
- }
- var quick_question = $('.quick_question');
- quick_question.find('.buttons-quickq').hide();
- quick_question.find('form input[type=text]').focus(function(){
- quick_question.find('.buttons-quickq').show();
- });
-
+ initDropdowns();
+ initQuickQuestion();
Auth.dropdownToggle();
Auth.positionDropdown();
- Ui.initializeAjaxTooltips();
- Ui.initializeSmoothScrollToTop();
- if(Ui.supportsInputPlaceholder()) {
- $('.hideifplaceholder').remove();
- };
-
- $('.langbox.jshide').hide();
- $('.show-more-lang').click(function(){
- $('.langbox.jshide').toggle();
- return false;
- });
+ initializeAjaxTooltips();
+ initializeSmoothScrollToTop();
+ Form.initialize();
- if(Questions.isIndexEmpty()){
- var current_language = $('.current_language > a').data('language');
- if(current_language!='any'){
- $('.current_language').tipsy({trigger: 'manual', gravity: 'w'});
- $('.current_language').tipsy('show');
- }
- }
$('[rel=tipsy]').tipsy({gravity: 's'});
$('.lang-option').click(function(){
var path = $('#lang-select-toggle').data('language');
@@ -42,127 +20,79 @@ Ui = function() {
});
});
- $('#openid_url').parents('form').submit(function(){
- var openid = $('#openid_url').val();
- openid = openid.replace('http://','');
- openid = openid.replace('https://','');
- $('#openid_url').val(openid)
- })
+ sortValues('#group_language', 'option', ':last', 'text', null);
+ sortValues('#user_language', 'option', false, 'text', null);
+ sortValues('#lang_opts', '.radio_option', false, 'attr', 'id');
+ sortValues('select#question_language', 'option', false, 'text', null);
- Ui.sortValues('#group_language', 'option', ':last', 'text', null);
- Ui.sortValues('#user_language', 'option', false, 'text', null);
- Ui.sortValues('#lang_opts', '.radio_option', false, 'attr', 'id');
- Ui.sortValues('select#question_language', 'option', false, 'text', null);
+ if(offline()) {
+ $("a[data-login-required], .toggle-action, .not_member").on('click', function(e) {
+ e.preventDefault();
+ Auth.startLoginDialog();
+ });
- //TODO: delegate is deprecated use on
- $(document.body).delegate("#ask_question", "submit", function(event) {
- if(Ui.offline()){
- Auth.startLoginDialog();
- return false;
- }
- });
- //TODO: delegate is deprecated use on
- $(document.body).delegate("#join_dialog_link", "click", function(event) {
+ $("form[data-login-required]").on('submit', function(e) {
+ e.preventDefault();
+ Auth.startLoginDialog();
+ });
+ }
+
+ $(document.body).delegate("click", "#join_dialog_link", function(event) {
+ event.preventDefault();
Groups.join(this);
- return false;
});
- //TODO: delegate is deprecated use on
- $(document.body).delegate(".join_group", "click", function(event) {
+
+ $(document.body).delegate("click", ".join_group", function(event) {
if(!$(this).hasClass('email')){
Auth.startLoginDialog($(this).text(),1);
return false;
} else {document.location=$(this).attr('href')}
});
- //TODO: delegate is deprecated use on
- $(document.body).delegate(".toggle-action,.not_member", "click", function(event) {
- if(Ui.offline()){
- Auth.startLoginDialog();
- } else {
+
+ $(".toggle-action").on("ajax:success", function(xhr, data, status) {
+ if(data.success) {
var link = $(this);
- if(!link.hasClass('busy')){
- link.addClass('busy');
- var href = link.attr("href");
- var dataUndo = link.attr("data-undo");
- var title = link.attr("title");
- var dataTitle = link.attr("data-title");
- var img = link.children('img');
- var counter = $(link.attr('data-counter'));
- var text = link.text();
- var dataText = link.attr("data-text");
- var dataMethod = link.attr("data-method");
- var csrf = $('meta[name="csrf-token"]').attr('content');
- if(dataMethod == 'post'){
- $.ajax({url: href, headers:{'X-CSRF-Token': csrf}, data: {'authenticity_token': csrf}, dataType: "json", type: "post", success: function(data){
- if(data.success){
- link.attr({href: dataUndo, 'data-undo': href, title: dataTitle, 'data-title': title, 'data-text': text });
- if(dataText && $.trim(dataText)!='')
- link.text(dataText);
- img.attr({src: img.attr('data-src'), 'data-src': img.attr('src')});
- if(typeof(data.increment)!='undefined'){
- counter.text(parseFloat($.trim(counter.text()))+data.increment);
- }
- Messages.show(data.message, "notice");
- } else {
- Messages.show(data.message, "error");
-
- if(data.status == "unauthenticate") {
- window.onbeforeunload = null;
- window.location="/users/login";
- }
- }
- link.removeClass('busy');
- }});
- } else {
- $.getJSON(href, {format: "js"}, function(data){
- if(data.success){
- link.attr({href: dataUndo, 'data-undo': href, title: dataTitle, 'data-title': title, 'data-text': text });
- if(dataText && $.trim(dataText)!='')
- link.text(dataText);
- img.attr({src: img.attr('data-src'), 'data-src': img.attr('src')});
- if(typeof(data.increment)!='undefined'){
- counter.text(parseFloat($.trim(counter.text()))+data.increment);
- }
- Messages.show(data.message, "notice");
- } else {
- Messages.show(data.message, "error");
-
- if(data.status == "unauthenticate") {
- window.onbeforeunload = null;
- window.location="/users/login";
- }
- }
- link.removeClass('busy');
- }, "json");
- }
+ var href = link.attr('href'), title = link.attr('title'), text = link.data('ujs:enable-with');
+ var dataUndo = link.data('undo'), dataTitle = link.data('title'), dataText = link.data('text');
+
+ var img = link.children('img');
+ var counter = $(link.data('counter'));
+
+ link.attr({href: dataUndo, title: dataTitle });
+ link.data({'undo': href, 'title': title, 'text': text});
+
+ if(dataText && $.trim(dataText)!=''){
+ link.text(dataText);
+ link.data('ujs:enable-with', dataText);
+ }
+
+ img.attr({src: img.data('src'), 'data-src': img.attr('src')});
+ if(typeof(link.data('increment'))!='undefined') {
+ counter.text(parseFloat($.trim(counter.text()))+link.data('increment'));
}
+ Messages.show(data.message, "notice");
}
- return false;
});
- Form.initialize();
}
function initializeFeedback() {
- $("#feedbackform").dialog({ title: "Feedback", autoOpen: false, modal: true, width:"420px" });
+ var feedback = $("#feedbackform");
+ feedback.dialog({ title: "Feedback", autoOpen: false, modal: true, width:"420px" });
$('#feedbackform .cancel-feedback').click(function(){
$("#feedbackform").dialog('close');
return false;
});
$('#feedback').click(function(){
- var isOpen = $("#feedbackform").dialog('isOpen');
+ var isOpen = feedback.dialog('isOpen');
if (isOpen){
- $("#feedbackform").dialog('close');
+ feedback.dialog('close');
} else {
- $("#feedbackform").dialog('open');
+ feedback.dialog('open');
}
return false;
});
}
- function supportsInputPlaceholder() {
- var i = document.createElement('input');
- return 'placeholder' in i;
- }
-
function sortValues(selectID, child, keepers, method, arg) {
if(keepers){
var any = $(selectID+' '+child+keepers);
@@ -204,7 +134,7 @@ Ui = function() {
$(first_element).addClass("active");
}
- container.delegate(element_selector, "click", function(ev) {
+ container.on("click", element_selector, function(ev) {
elements.removeClass("active");
next = $(this);
next.addClass("active");
@@ -282,10 +212,30 @@ Ui = function() {
}
+ //Private
+ function initDropdowns() {
+ $('ul.menubar').droppy({
+ className: 'dropHover',
+ autoArrows: false,
+ trigger: 'click'
+ });
+
+ $('ul.menubar .has-subnav').click(function(e) {
+ e.preventDefault();
+ });
+ }
+
+ function initQuickQuestion() {
+ var quick_question = $('.quick_question');
+ quick_question.find('.buttons-quickq').hide();
+ quick_question.find('form input[type=text]').focus(function(){
+ quick_question.find('.buttons-quickq').show();
+ });
+ }
+
return {
initialize:initialize,
initializeFeedback:initializeFeedback,
- supportsInputPlaceholder:supportsInputPlaceholder,
sortValues:sortValues,
offline:offline,
notMember:notMember,
View
12 app/controllers/users_controller.rb
@@ -285,6 +285,7 @@ def unfollow_tags
def follow
@user = User.find_by_login_or_id(params[:id])
+
if @user != current_user && @user.member_of?(current_group)
current_user.add_friend(@user)
@@ -298,13 +299,13 @@ def follow
flash[:error] = t("flash_error", :scope => "users.follow", :user => @user.login)
message = flash[:error]
end
+
respond_to do |format|
format.html do
redirect_to user_path(@user)
end
- format.js {
- render(:json => {:success => success,
- :message => message }.to_json)
+ format.json {
+ render(json: {success: success, message: message }.to_json)
}
end
end
@@ -321,10 +322,7 @@ def unfollow
format.html do
redirect_to user_path(@user)
end
- format.js {
- render(:json => {:success => true,
- :message => flash[:notice] }.to_json)
- }
+ format.js { render(json: {success: true, message: flash[:notice] }.to_json) }
end
end
View
35 app/helpers/application_helper.rb
@@ -481,24 +481,23 @@ def follow_suggestion_link(suggestion)
end
def follow_user_link(user)
- if logged_in?
- if current_user.following?(user)
- follow_class = 'unfollow_link toggle-action'
- follow_data = 'follow_link'
- data_title = t('widgets.suggestions.follow_user')
- title = t('widgets.suggestions.unfollow_user')
- path = unfollow_user_path(user)
- data_undo = follow_user_path(user)
- else
- follow_data = 'unfollow_link'
- follow_class = 'follow_link toggle-action'
- title = t('widgets.suggestions.follow_user')
- data_title = t('widgets.suggestions.unfollow_user')
- data_undo = unfollow_user_path(user)
- path = follow_user_path(user)
- end
- link_to title, path, :class => follow_class, 'data-class' => follow_data, 'data-text' => data_title, 'data-undo' => data_undo, :method => 'post'
- end
+ if current_user.following?(user)
+ follow_class = 'unfollow_link toggle-action'
+ follow_data = 'follow_link'
+ data_title = t('widgets.suggestions.follow_user')
+ title = t('widgets.suggestions.unfollow_user')
+ path = unfollow_user_path(user)
+ data_undo = follow_user_path(user)
+ else
+ follow_data = 'unfollow_link'
+ follow_class = 'follow_link toggle-action'
+ title = t('widgets.suggestions.follow_user')
+ data_title = t('widgets.suggestions.unfollow_user')
+ data_undo = unfollow_user_path(user)
+ path = follow_user_path(user)
+ end
+ #i18n
+ link_to title, path, :class => follow_class, 'data-class' => follow_data, 'data-text' => data_title, 'data-undo' => data_undo, :method => 'post', 'data-login-required' => true, :remote => true, 'data-disable-with'=>"Following...", 'data-type'=>'json'
end
def follow_tag_link(tag)
View
10 app/views/facebook/_form.html.haml
@@ -2,21 +2,21 @@
%h2
= raw(current_group.question_prompt) || t("shared.quick_question")
-@question = Question.new
- =form_for(@question, :html=>{:class => "form", :id => "ask_question"}) do |f|
+ =form_for(@question, html: {class: "form", id: "ask_question", data: {'login-required' => true}}) do |f|
-lang = logged_in? ? current_user.main_language : nil
-lang = current_group.language ? current_group.language : lang
.step1
- =f.text_field :title, :class => "text_field", :id => "question_title"
+ =f.text_field :title, class: "text_field", id: "question_title"
.step2
=f.label :body, "Enter the description for your question"
- =f.text_area :body, :class => "text_area", :id => "question_body"
+ =f.text_area :body, class: "text_area", id: "question_body"
-if lang
- = f.hidden_field :language, :value => lang
+ = f.hidden_field :language, value: lang
-else
= language_select(f, @question)
- =f.submit t(".ask_question", :default => :"layouts.application.ask_question"), :class => "ask_question require_login"
+ =f.submit t(".ask_question", default: :"layouts.application.ask_question"), class: "ask_question require_login", data: {'login-required' => true}
.clear
.clear
View
4 app/views/questions/_answer_toolbar.html.haml
@@ -20,10 +20,10 @@
- if answer.favorite_for?(current_user)
%li.action
- = link_to t('questions.answer.unfavorite'), unfavorite_question_answer_path(question, answer), :title => t('questions.answer.unfavorite_tooltip'), :class => 'answer-action unfavorite-link toggle-action', "data-undo" => favorite_question_answer_path(question, answer), "data-title" => t('questions.answer.favorite_tooltip'), 'data-counter' => '.favorites_count', 'data-text' => t('questions.answer.favorite')
+ = link_to t('questions.answer.unfavorite'), unfavorite_question_answer_path(question, answer), title: t('questions.answer.unfavorite_tooltip'), class: 'answer-action unfavorite-link toggle-action', data: {undo: favorite_question_answer_path(question, answer), title: t('questions.answer.favorite_tooltip'), counter: '.favorites_count', text: t('questions.answer.favorite'), 'login-require' => true}, remote: true
- else
%li.action
- = link_to t('questions.answer.favorite'), favorite_question_answer_path(question, answer), :title => t('questions.answer.favorite_tooltip'), :class => 'answer-action favorite-link toggle-action', "data-undo" => unfavorite_question_answer_path(question, answer), "data-title" => t('questions.answer.unfavorite_tooltip'), 'data-counter' => '.favorites_count', 'data-text' => t('questions.answer.unfavorite')
+ = link_to t('questions.answer.favorite'), favorite_question_answer_path(question, answer), :title => t('questions.answer.favorite_tooltip'), :class => 'answer-action favorite-link toggle-action', data: {undo: unfavorite_question_answer_path(question, answer), title: t('questions.answer.unfavorite_tooltip'), counter: '.favorites_count', text: t('questions.answer.unfavorite'), 'login-require' => true}, remote: true
- if !logged_in? || !current_user.mod_of?(current_group)
- if @aflag.new_record? && current_user != answer.user
View
2  app/views/questions/new.html.haml
@@ -5,7 +5,7 @@
%p.description
= raw(current_group.question_help)
-= form_for(@question, :html=>{:class => "question-form", :id => "ask_question", :multipart => true}) do |f|
+= form_for(@question, html: {class: "question-form", id: "ask_question", multipart: true, data: {'login-required' => true}}) do |f|
=render :partial => "form", :locals => {:f => f}
.field.form-options
View
2  app/views/shared/_quick_question_box.html.haml
@@ -1,7 +1,7 @@
- unless params[:controller] == 'questions' && params[:action] == 'new'
.quick_question.clearfix
-quick_question = Question.new
- =form_for(quick_question, :url => new_question_url, :html=>{:method => :get, :class => "form", :id => "ask_question"}) do |f|
+ =form_for(quick_question, url: new_question_url, html: {method: :get, class: "form", id: "ask_question", data: {'login-required' => true}}) do |f|
-# TODO: refactor this
-lang = logged_in? ? current_user.main_language : nil
-lang = current_group.language ? current_group.language : lang
View
2  app/views/shared/layout/_head.html.haml
@@ -2,7 +2,7 @@
&= page_title
= render "shared/layout/css"
-= javascript_include_tag "modernizr.custom.geo.load.js"
+= javascript_include_tag "modernizr.js"
= raw(current_group.head_tag)
= render "shared/layout/meta"
View
2  app/views/widgets/_ask_question.html.haml
@@ -6,7 +6,7 @@
%h3
= t(".title")
%section
- = form_for(@question, :html=>{:class => "question-form", :id => "ask_question", :multipart => true}) do |f|
+ = form_for(@question, :html=>{:class => "question-form", :id => "ask_question", :multipart => true, data: {'login-required' => true}}) do |f|
.field
= f.text_field :title, :class => "text_field"
= f.hidden_field :language, :value => (current_group.language || AppConfig.default_language)
View
4 vendor/assets/javascripts/modernizr.custom.geo.load.js
@@ -1,4 +0,0 @@
-/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
- * Contains: localstorage | websockets | geolocation | domprefixes | load
- */
-;window.Modernizr=function(a,b,c){function x(a,b){return!!~(""+a).indexOf(b)}function w(a,b){return typeof a===b}function v(a,b){return u(prefixes.join(a+";")+(b||""))}function u(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k,l=Object.prototype.toString,m="Webkit Moz O ms Khtml".split(" "),n={},o={},p={},q=[],r,s={}.hasOwnProperty,t;!w(s,c)&&!w(s.call,c)?t=function(a,b){return s.call(a,b)}:t=function(a,b){return b in a&&w(a.constructor.prototype[b],c)},n.geolocation=function(){return!!navigator.geolocation},n.websockets=function(){for(var b=-1,c=m.length;++b<c;)if(a[m[b]+"WebSocket"])return!0;return"WebSocket"in a},n.localstorage=function(){try{return!!localStorage.getItem}catch(a){return!1}};for(var y in n)t(n,y)&&(r=y.toLowerCase(),e[r]=n[y](),q.push((e[r]?"":"no-")+r));u(""),i=k=null,e._version=d,e._domPrefixes=m;return e}(this,this.document),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css";if(!a.e&&(w||r)){var e=function(a){m(function(){if(!d)try{a.sheet.cssRules.length?(d=1,j()):e(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){j()},0)):e(a)}},0)};e(c)}else c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload();m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return Object(a)===a},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=F[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=E[h](f);return f}function e(a,b,e,g,h){var i=f(a),j=i.autoCallback;if(!i.bypass){b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);if(i.instead)return i.instead(a,b,e,g,h);e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)})}}function b(a,b){function c(a){if(C(a))e(a,h,b,0,d);else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;c(f),c(g),a.complete&&b.load(a.complete)}var g,h,i=this.yepnope.loader;if(C(a))e(a,0,i,0);else if(A(a))for(g=0;g<a.length;g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);else B(a)&&b(a,i)},H.addPrefix=function(a,b){F[a]=b},H.addFilter=function(a){E.push(a)},H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"},0)),a.yepnope=d()}(this,this.document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
View
429 vendor/assets/javascripts/modernizr.js
@@ -0,0 +1,429 @@
+/* Modernizr 2.5.3 (Custom Build) | MIT & BSD
+ * Build: http://www.modernizr.com/download/#-history-input-inputtypes-localstorage-websockets-geolocation-touch-shiv-mq-cssclasses-teststyles-prefixes-domprefixes
+ */
+;
+
+
+
+window.Modernizr = (function( window, document, undefined ) {
+
+ var version = '2.5.3',
+
+ Modernizr = {},
+
+ enableClasses = true,
+
+ docElement = document.documentElement,
+
+ mod = 'modernizr',
+ modElem = document.createElement(mod),
+ mStyle = modElem.style,
+
+ inputElem = document.createElement('input') ,
+
+ smile = ':)',
+
+ toString = {}.toString,
+
+ prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
+
+
+
+ omPrefixes = 'Webkit Moz O ms',
+
+ cssomPrefixes = omPrefixes.split(' '),
+
+ domPrefixes = omPrefixes.toLowerCase().split(' '),
+
+
+ tests = {},
+ inputs = {},
+ attrs = {},
+
+ classes = [],
+
+ slice = classes.slice,
+
+ featureName,
+
+
+ injectElementWithStyles = function( rule, callback, nodes, testnames ) {
+
+ var style, ret, node,
+ div = document.createElement('div'),
+ body = document.body,
+ fakeBody = body ? body : document.createElement('body');
+
+ if ( parseInt(nodes, 10) ) {
+ while ( nodes-- ) {
+ node = document.createElement('div');
+ node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
+ div.appendChild(node);
+ }
+ }
+
+ style = ['&#173;','<style>', rule, '</style>'].join('');
+ div.id = mod;
+ (body ? div : fakeBody).innerHTML += style;
+ fakeBody.appendChild(div);
+ if(!body){
+ fakeBody.style.background = "";
+ docElement.appendChild(fakeBody);
+ }
+
+ ret = callback(div, rule);
+ !body ? fakeBody.parentNode.removeChild(fakeBody) : div.parentNode.removeChild(div);
+
+ return !!ret;
+
+ },
+
+ testMediaQuery = function( mq ) {
+
+ var matchMedia = window.matchMedia || window.msMatchMedia;
+ if ( matchMedia ) {
+ return matchMedia(mq).matches;
+ }
+
+ var bool;
+
+ injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {
+ bool = (window.getComputedStyle ?
+ getComputedStyle(node, null) :
+ node.currentStyle)['position'] == 'absolute';
+ });
+
+ return bool;
+
+ },
+ _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
+
+ if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
+ hasOwnProperty = function (object, property) {
+ return _hasOwnProperty.call(object, property);
+ };
+ }
+ else {
+ hasOwnProperty = function (object, property) {
+ return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
+ };
+ }
+
+
+ if (!Function.prototype.bind) {
+ Function.prototype.bind = function bind(that) {
+
+ var target = this;
+
+ if (typeof target != "function") {
+ throw new TypeError();
+ }
+
+ var args = slice.call(arguments, 1),
+ bound = function () {
+
+ if (this instanceof bound) {
+
+ var F = function(){};
+ F.prototype = target.prototype;
+ var self = new F;
+
+ var result = target.apply(
+ self,
+ args.concat(slice.call(arguments))
+ );
+ if (Object(result) === result) {
+ return result;
+ }
+ return self;
+
+ } else {
+
+ return target.apply(
+ that,
+ args.concat(slice.call(arguments))
+ );
+
+ }
+
+ };
+
+ return bound;
+ };
+ }
+
+ function setCss( str ) {
+ mStyle.cssText = str;
+ }
+
+ function setCssAll( str1, str2 ) {
+ return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
+ }
+
+ function is( obj, type ) {
+ return typeof obj === type;
+ }
+
+ function contains( str, substr ) {
+ return !!~('' + str).indexOf(substr);
+ }
+
+
+ function testDOMProps( props, obj, elem ) {
+ for ( var i in props ) {
+ var item = obj[props[i]];
+ if ( item !== undefined) {
+
+ if (elem === false) return props[i];
+
+ if (is(item, 'function')){
+ return item.bind(elem || obj);
+ }
+
+ return item;
+ }
+ }
+ return false;
+ }
+
+
+ var testBundle = (function( styles, tests ) {
+ var style = styles.join(''),
+ len = tests.length;
+
+ injectElementWithStyles(style, function( node, rule ) {
+ var style = document.styleSheets[document.styleSheets.length - 1],
+ cssText = style ? (style.cssRules && style.cssRules[0] ? style.cssRules[0].cssText : style.cssText || '') : '',
+ children = node.childNodes, hash = {};
+
+ while ( len-- ) {
+ hash[children[len].id] = children[len];
+ }
+
+ Modernizr['touch'] = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || (hash['touch'] && hash['touch'].offsetTop) === 9;
+ }, len, tests);
+
+ })([
+ ,['@media (',prefixes.join('touch-enabled),('),mod,')',
+ '{#touch{top:9px;position:absolute}}'].join('') ],
+ [
+ ,'touch' ]);
+
+
+
+ tests['touch'] = function() {
+ return Modernizr['touch'];
+ };
+
+ tests['geolocation'] = function() {
+ return !!navigator.geolocation;
+ };
+
+ tests['history'] = function() {
+ return !!(window.history && history.pushState);
+ };
+
+
+ tests['websockets'] = function() {
+ for ( var i = -1, len = cssomPrefixes.length; ++i < len; ){
+ if ( window[cssomPrefixes[i] + 'WebSocket'] ){
+ return true;
+ }
+ }
+ return 'WebSocket' in window;
+ };
+
+
+ tests['localstorage'] = function() {
+ try {
+ localStorage.setItem(mod, mod);
+ localStorage.removeItem(mod);
+ return true;
+ } catch(e) {
+ return false;
+ }
+ };
+
+
+ function webforms() {
+ Modernizr['input'] = (function( props ) {
+ for ( var i = 0, len = props.length; i < len; i++ ) {
+ attrs[ props[i] ] = !!(props[i] in inputElem);
+ }
+ if (attrs.list){
+ attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
+ }
+ return attrs;
+ })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
+ Modernizr['inputtypes'] = (function(props) {
+
+ for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
+
+ inputElem.setAttribute('type', inputElemType = props[i]);
+ bool = inputElem.type !== 'text';
+
+ if ( bool ) {
+
+ inputElem.value = smile;
+ inputElem.style.cssText = 'position:absolute;visibility:hidden;';
+
+ if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
+
+ docElement.appendChild(inputElem);
+ defaultView = document.defaultView;
+
+ bool = defaultView.getComputedStyle &&
+ defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
+ (inputElem.offsetHeight !== 0);
+
+ docElement.removeChild(inputElem);
+
+ } else if ( /^(search|tel)$/.test(inputElemType) ){
+ } else if ( /^(url|email)$/.test(inputElemType) ) {
+ bool = inputElem.checkValidity && inputElem.checkValidity() === false;
+
+ } else if ( /^color$/.test(inputElemType) ) {
+ docElement.appendChild(inputElem);
+ docElement.offsetWidth;
+ bool = inputElem.value != smile;
+ docElement.removeChild(inputElem);
+
+ } else {
+ bool = inputElem.value != smile;
+ }
+ }
+
+ inputs[ props[i] ] = !!bool;
+ }
+ return inputs;
+ })('search tel url email datetime date month week time datetime-local number range color'.split(' '));
+ }
+ for ( var feature in tests ) {
+ if ( hasOwnProperty(tests, feature) ) {
+ featureName = feature.toLowerCase();
+ Modernizr[featureName] = tests[feature]();
+
+ classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
+ }
+ }
+
+ Modernizr.input || webforms(); setCss('');
+ modElem = inputElem = null;
+
+ ;(function(window, document) {
+
+ var options = window.html5 || {};
+
+ var reSkip = /^<|^(?:button|form|map|select|textarea)$/i;
+
+ var supportsHtml5Styles;
+
+ var supportsUnknownElements;
+
+ (function() {
+ var a = document.createElement('a');
+
+ a.innerHTML = '<xyz></xyz>';
+
+ supportsHtml5Styles = ('hidden' in a);
+ supportsUnknownElements = a.childNodes.length == 1 || (function() {
+ try {
+ (document.createElement)('a');
+ } catch(e) {
+ return true;
+ }
+ var frag = document.createDocumentFragment();
+ return (
+ typeof frag.cloneNode == 'undefined' ||
+ typeof frag.createDocumentFragment == 'undefined' ||
+ typeof frag.createElement == 'undefined'
+ );
+ }());
+
+ }()); function addStyleSheet(ownerDocument, cssText) {
+ var p = ownerDocument.createElement('p'),
+ parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
+
+ p.innerHTML = 'x<style>' + cssText + '</style>';
+ return parent.insertBefore(p.lastChild, parent.firstChild);
+ }
+
+ function getElements() {
+ var elements = html5.elements;
+ return typeof elements == 'string' ? elements.split(' ') : elements;
+ }
+
+ function shivMethods(ownerDocument) {
+ var cache = {},
+ docCreateElement = ownerDocument.createElement,
+ docCreateFragment = ownerDocument.createDocumentFragment,
+ frag = docCreateFragment();
+
+
+ ownerDocument.createElement = function(nodeName) {
+ var node = (cache[nodeName] || (cache[nodeName] = docCreateElement(nodeName))).cloneNode();
+ return html5.shivMethods && node.canHaveChildren && !reSkip.test(nodeName) ? frag.appendChild(node) : node;
+ };
+
+ ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
+ 'var n=f.cloneNode(),c=n.createElement;' +
+ 'h.shivMethods&&(' +
+ getElements().join().replace(/\w+/g, function(nodeName) {
+ cache[nodeName] = docCreateElement(nodeName);
+ frag.createElement(nodeName);
+ return 'c("' + nodeName + '")';
+ }) +
+ ');return n}'
+ )(html5, frag);
+ } function shivDocument(ownerDocument) {
+ var shived;
+ if (ownerDocument.documentShived) {
+ return ownerDocument;
+ }
+ if (html5.shivCSS && !supportsHtml5Styles) {
+ shived = !!addStyleSheet(ownerDocument,
+ 'article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
+ 'audio{display:none}' +
+ 'canvas,video{display:inline-block;*display:inline;*zoom:1}' +
+ '[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}' +
+ 'mark{background:#FF0;color:#000}'
+ );
+ }
+ if (!supportsUnknownElements) {
+ shived = !shivMethods(ownerDocument);
+ }
+ if (shived) {
+ ownerDocument.documentShived = shived;
+ }
+ return ownerDocument;
+ } var html5 = {
+
+ 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video',
+
+ 'shivCSS': !(options.shivCSS === false),
+
+ 'shivMethods': !(options.shivMethods === false),
+
+ 'type': 'default',
+ 'shivDocument': shivDocument
+ }; window.html5 = html5;
+
+ shivDocument(document);
+
+ }(this, document));
+
+ Modernizr._version = version;
+
+ Modernizr._prefixes = prefixes;
+ Modernizr._domPrefixes = domPrefixes;
+ Modernizr._cssomPrefixes = cssomPrefixes;
+
+ Modernizr.mq = testMediaQuery;
+ Modernizr.testStyles = injectElementWithStyles; docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
+
+ (enableClasses ? ' js ' + classes.join(' ') : '');
+
+ return Modernizr;
+
+})(this, this.document);
+;
Please sign in to comment.
Something went wrong with that request. Please try again.