Nettoyage de code pour suivre les dernières métriques ABC

This commit is contained in:
echarp 2014-11-05 21:25:18 +01:00
parent 542abdf7de
commit bb5a037356
88 changed files with 2492 additions and 2317 deletions

View File

@ -4,6 +4,7 @@ source 'https://rubygems.org'
gem 'simple_calendar'
gem 'rails'
gem 'has_scope'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'

View File

@ -1,6 +1,6 @@
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: c26ae0b1393311180b5137c6b4a271de3385d069
revision: 809142efe855e590331cdc41e72dcad76b719a46
specs:
activeadmin (1.0.0.pre)
arbre (~> 1.0, >= 1.0.2)
@ -150,7 +150,7 @@ GEM
actionpack (>= 3.2.13)
formtastic_i18n (0.1.1)
geocoder (1.2.5)
guard (2.7.1)
guard (2.8.0)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
@ -169,7 +169,7 @@ GEM
guard-minitest (2.3.2)
guard (~> 2.0)
minitest (>= 3.0)
guard-rubocop (1.1.0)
guard-rubocop (1.2.0)
guard (~> 2.0)
rubocop (~> 0.20)
haml (4.0.5)
@ -219,7 +219,7 @@ GEM
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
mail (2.6.1)
mail (2.6.3)
mime-types (>= 1.16, < 3)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
@ -234,7 +234,7 @@ GEM
mysql2 (0.3.16)
naught (1.0.0)
orm_adapter (0.5.0)
parser (2.2.0.pre.6)
parser (2.2.0.pre.7)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
polyamorous (1.1.0)
@ -290,7 +290,7 @@ GEM
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.6.1)
ruby-progressbar (1.7.0)
ruby2ruby (2.1.3)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
@ -341,7 +341,7 @@ GEM
tilt (1.4.1)
timers (4.0.1)
hitimes
tinymce-rails (4.1.5)
tinymce-rails (4.1.6)
railties (>= 3.1.1)
tinymce-rails-langs (4.20140129)
tinymce-rails (~> 4.0)
@ -393,6 +393,7 @@ DEPENDENCIES
guard-minitest
guard-rubocop
haml-rails
has_scope
http_accept_language
i18n-active_record!
jbuilder (~> 2.0)

View File

@ -29,7 +29,7 @@ end
notification :notifysend
guard 'brakeman', run_on_start: true, quiet: true, min_confidence: 10 do
guard :brakeman, run_on_start: true, quiet: true, min_confidence: 10 do
watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
watch(%r{^config/.+\.rb$})
watch(%r{^lib/.+\.rb$})

View File

@ -29,7 +29,7 @@ ActiveAdmin.register_page 'Dashboard' do
#{link_to(`git rev-parse --short HEAD`,
"https://gitorious.org/agenda-du-libre-rails/agenda-du-libre-rails/commit/
#{`git rev-parse HEAD`}")})
.html_safe
.html_safe
end
end
end

View File

@ -11,4 +11,11 @@ class ApplicationController < ActionController::Base
I18n.locale = http_accept_language
.compatible_language_from I18n.available_locales
end
protected
# Useful to manage absolute url in mails
def set_mailer_host
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
end

View File

@ -1,33 +1,33 @@
# Event life cycle
# This is a central part to this project
class EventsController < ApplicationController
has_scope :region, :locality, :tag, :daylimit
before_action :set_events, only: [:index]
before_action :set_event, only:
[:show, :edit, :preview, :update, :cancel, :destroy]
before_action :check_secret, only:
[:edit, :preview, :update, :cancel, :destroy]
before_action :set_event, except: [:index, :new, :preview_create, :create]
before_action :set_create_event, only: [:preview_create, :create]
before_action :check_secret, only: [:edit, :preview, :update, :destroy]
before_action :set_old_event, only: [:update]
before_action :set_mailer_host
rescue_from ActiveRecord::StaleObjectError, with: :locked
def index
respond_to do |format|
format.html { render layout: 'iframe' if params[:iframe] }
format.rss { @events = @events.future.in params[:daylimit] }
format.ics { @events = @events.last_year.order :id }
format.xml { @events = @events.includes(:related_region).order :id }
format.rss { @events = @events.future }
format.ics { @events = @events.last_year }
format.xml { @events = @events.includes :related_region }
end
end
# GET /users/new
def new
@event = Event.new
@event.start_time ||= Time.now.change(min: 0) + 1.day + 1.hour
@event.end_time ||= Time.now.change(min: 0) + 1.day + 2.hour
@event = Event.new start_time: Time.now.change(min: 0) + 1.day + 1.hour,
end_time: Time.now.change(min: 0) + 1.day + 2.hour
end
# POST /events/preview
def preview_create
@event = Event.new event_params
@event.valid?
render action: :new
end
@ -35,8 +35,6 @@ class EventsController < ApplicationController
# POST /events
# POST /events.json
def create
@event = Event.new event_params
respond_to do |format|
if @event.save && send_creation_mails
format.html { redirect_to :root, notice: t('.ok') }
@ -60,7 +58,6 @@ class EventsController < ApplicationController
# PATCH/PUT /events/1
# PATCH/PUT /events/1.json
def update
@older_event = Event.new @event.attributes
respond_to do |format|
if @event.update(event_params) && send_update_mails
format.html { redirect_to :root, notice: t('.ok') }
@ -78,7 +75,7 @@ class EventsController < ApplicationController
def destroy
@event.destroy
respond_to do |format|
format.html { redirect_to events_url, notice: t('.ok') }
format.html { redirect_to :root, notice: t('.ok') }
format.json { head :no_content }
end
end
@ -86,10 +83,7 @@ class EventsController < ApplicationController
private
def set_events
@events = Event.moderated
@events = @events.region params[:region] if params[:region]
@events = @events.locality params[:locality] if params[:locality]
@events = @events.tag params[:tag] if params[:tag]
@events = apply_scopes Event.moderated
end
# Use callbacks to share common setup or constraints between actions
@ -102,6 +96,14 @@ class EventsController < ApplicationController
@event = @event.find params[:id]
end
def set_create_event
@event = Event.new event_params
end
def set_old_event
@older_event = Event.new @event.attributes
end
# Never trust parameters from the scary internet, only allow the white list
# through
def event_params
@ -117,11 +119,6 @@ class EventsController < ApplicationController
unless params[:secret] == @event.secret
end
# Useful to manage absolute url in mails
def set_mailer_host
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
def send_creation_mails
# Send an event creation mail to its author
EventMailer.create(@event).deliver

View File

@ -2,16 +2,12 @@
#
# Access to OSM controls
class MapsController < ApplicationController
has_scope :region, :locality, :tag
def index
respond_to do |format|
format.html
format.json do
@events = Event.moderated.future.geo
@events = @events.region params[:region] if params[:region]
@events = @events.locality params[:locality] if params[:locality]
@events = @events.tag params[:tag] if params[:tag]
render json: @events
end
format.json { render json: apply_scopes(Event.moderated.future.geo) }
end
end
end

View File

@ -3,6 +3,7 @@ class ModerationsController < ApplicationController
before_action :authenticate_user!
before_action :set_moderation, :set_mailer_host, only:
[:show, :edit, :preview, :update, :validate, :accept, :refuse, :destroy]
before_action :set_old_mod, only: [:update]
rescue_from ActiveRecord::StaleObjectError, with: :locked
def index
@ -18,10 +19,9 @@ class ModerationsController < ApplicationController
# PATCH/PUT /moderations/1
# PATCH/PUT /moderations/1.json
def update
@older_mod = Event.new @event.attributes
respond_to do |format|
if @moderation.update_attributes(moderation_params) && send_mails
format.html { redirect_to moderations_url, notice: t('.ok') }
format.html { redirect_to :moderations, notice: t('.ok') }
format.json { head :no_content }
else
format.html { render action: 'edit' }
@ -34,28 +34,20 @@ class ModerationsController < ApplicationController
# PATCH/PUT /accept/1
# PATCH/PUT /accept/1.json
def accept
@moderation.update moderated: true
send_accept_mails
respond_to do |format|
if @moderation.update(moderated: true) && send_accept_mails
tweet
format.html { redirect_to moderations_url, notice: t('.ok') }
format.json { head :no_content }
else
format.html { render action: 'edit' }
# 422 means :unprocessable_entity
format.json { render json: @moderation.errors, status: 422 }
end
format.html { redirect_to :moderations, notice: t('.ok') }
format.json { head :no_content }
end
end
# DELETE /events/1
# DELETE /events/1.json
def destroy
if @moderation.destroy && send_destroy_mails
EventMailer.destroy(@moderation, current_user, @reason).deliver
ModerationMailer.destroy(@moderation, current_user, @reason).deliver
end
send_destroy_mails if @moderation.destroy
respond_to do |format|
format.html { redirect_to moderations_url, notice: t('.ok') }
format.html { redirect_to :moderations, notice: t('.ok') }
format.json { head :no_content }
end
end
@ -68,6 +60,10 @@ class ModerationsController < ApplicationController
@moderation = @event
end
def set_old_mod
@older_mod = Event.new @event.attributes
end
# Never trust parameters from the scary internet, only allow the white list
# through.
def moderation_params
@ -88,6 +84,8 @@ class ModerationsController < ApplicationController
end
def send_accept_mails
tweet
# Send an acceptation mail to its author
EventMailer.accept(@moderation, current_user).deliver
@ -113,6 +111,9 @@ class ModerationsController < ApplicationController
else
@reason = t "moderations.refuse.reason_#{params[:reason]}_long"
end
EventMailer.destroy(@moderation, current_user, @reason).deliver
ModerationMailer.destroy(@moderation, current_user, @reason).deliver
end
def locked

View File

@ -1,6 +1,7 @@
# Events, particulary during moderation, can have notes associated to them
class NotesController < ApplicationController
before_action :set_event, :set_mailer_host, only: [:new, :create]
before_action :set_event, only: [:new, :create]
before_action :create_note, :set_mailer_host, only: [:create]
# GET /moderations/id/new
def new
@ -8,14 +9,12 @@ class NotesController < ApplicationController
end
def create
@note = @moderation.notes.new note_params.merge author: current_user
respond_to do |format|
if @note.save && send_mails
format.html { redirect_to moderations_url, notice: t('.ok') }
format.json { render action: :show, status: :created, location: @event }
else
format.html { render action: 'new' }
format.html { render action: :new }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
@ -29,6 +28,10 @@ class NotesController < ApplicationController
@moderation = @event
end
def create_note
@note = @moderation.notes.new note_params.merge author: current_user
end
# Never trust parameters from the scary internet, only allow the white list
# through.
def note_params

View File

@ -1,32 +1,3 @@
# Manage regions, mostly get stats out of them
class RegionsController < InheritedResources::Base
def stats
@region_events = Event.joins(:related_region).group(:name)
.order('count(name) desc').count :name
@city_events = Event.group(:city).having('count(city) > 3')
.order('count(city) desc').count :city
@year_events = Event.group(year_grouping).count
@month_events = Event.group(year_grouping, month_grouping).count
end
private
def year_grouping
if %w(Mysql2 MySQL PostgreSQL).include? Event.connection.adapter_name
'extract(year from start_time)'
elsif Event.connection.adapter_name == 'SQLite'
'strftime("%Y", start_time)'
end
end
def month_grouping
if %w(Mysql2 MySQL PostgreSQL).include? Event.connection.adapter_name
'extract(month from start_time)'
elsif Event.connection.adapter_name == 'SQLite'
'strftime("%m", start_time)'
end
end
end

View File

@ -0,0 +1,34 @@
# Generate statistics, around events, by date or place
class StatsController < ApplicationController
before_action :set_temporal, :set_local, only: [:index]
private
def set_temporal
@year_events = Event.group(year_grouping).count
@month_events = Event.group(year_grouping, month_grouping).count
end
def set_local
@region_events = Event.joins(:related_region).group(:name)
.order('count(name) desc').count
@city_events = Event.group(:city).having('count(city) > 3')
.order('count(city) desc').count
end
def year_grouping
if %w(Mysql2 MySQL PostgreSQL).include? Event.connection.adapter_name
'extract(year from start_time)'
elsif Event.connection.adapter_name == 'SQLite'
'strftime("%Y", start_time)'
end
end
def month_grouping
if %w(Mysql2 MySQL PostgreSQL).include? Event.connection.adapter_name
'extract(month from start_time)'
elsif Event.connection.adapter_name == 'SQLite'
'strftime("%m", start_time)'
end
end
end

View File

@ -2,15 +2,15 @@
class TagsController < InheritedResources::Base
def index
@tags = Event
.pluck(:tags).map(&:split).flatten
.group_by { |i| i }
.map { |k, v| [k, v.size] }
.reject { |_k, v| v <= 3 }
.sort
.pluck(:tags).map(&:split).flatten
.group_by { |i| i }
.map { |k, v| [k, v.size] }
.reject { |_k, v| v <= 3 }
.sort
respond_to do |format|
format.html
format.json { render json: @tags.to_json }
format.json { render json: @tags }
end
end

View File

@ -26,17 +26,25 @@ module EventsHelper
def display_date(event = @event)
if event.start_time.to_date == event.end_time.to_date
t 'date.formats.same_day',
date: l(event.start_time.to_date, format: :long),
start: l(event.start_time, format: :hours),
end: l(event.end_time, format: :hours)
display_sameday event
else
t 'date.formats.period',
start: l(event.start_time, format: :at),
end: l(event.end_time, format: :at)
display_multi_days event
end
end
def display_sameday(event)
t 'date.formats.same_day',
date: l(event.start_time.to_date, format: :long),
start: l(event.start_time, format: :hours),
end: l(event.end_time, format: :hours)
end
def display_multi_days(event)
t 'date.formats.period',
start: l(event.start_time, format: :at),
end: l(event.end_time, format: :at)
end
def wrap(s, width = 78)
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
end

View File

@ -29,7 +29,7 @@ class Event < ActiveRecord::Base
scope :last_year, -> { where '? <= end_time', 1.year.ago }
scope :past, -> { where 'start_time <= ?', DateTime.now }
scope :future, -> { where '? <= end_time', DateTime.now }
scope :in, -> days { where 'end_time <= ?', (days || 30).to_i.days.from_now }
scope :daylimit, -> d { where 'end_time <= ?', (d || 30).to_i.days.from_now }
scope :year, (lambda do |year|
where '? <= end_time and start_time <= ?',
Date.new(year, 1, 1).beginning_of_week,

View File

@ -57,7 +57,7 @@
= link_to application_infos_path do
%em.fa.fa-info
=t '.infos'
= link_to stats_regions_path do
= link_to stats_path do
%em.fa.fa-signal
=t '.stats'
= link_to application_contact_path do

View File

@ -138,7 +138,8 @@ it more readable or agreable.
Example: `%{tag}`
\n* You can modify the 30 days limit with the parameter `daylimit`. \n
Example: `%{daylimit}`"
stats:
stats:
index:
title: Statistics
all: Validated events
allModeration: Events waiting for validation

View File

@ -136,7 +136,8 @@ fr:
* Vous pouvez modifier la limite des 30 prochains jours des flux en
utilisant le paramètre `daylimit`. \n
Exemple: `%{daylimit}`"
stats:
stats:
index:
title: Statistiques
all: Événements validés
allModeration: Événements en cours de modération

View File

@ -2,6 +2,7 @@ Rails.application.routes.draw do
get 'application/infos'
get 'application/contact'
get 'application/rules'
get 'stats', to: 'stats#index'
resources :users
resources :events do
@ -15,9 +16,7 @@ Rails.application.routes.draw do
get :validate, :refuse, on: :member
put :accept, on: :member
end
resources :regions, only: [:index] do
get 'stats', on: :collection
end
resources :regions, only: [:index]
resources :tags, only: [:index, :show]
resources :maps, only: [:index]
resources :lugs, only: [:index, :show]

View File

@ -29,7 +29,7 @@ if File.file? 'Rakefile'
# precompile assets
changed_assets = `git diff #{oldrev} #{newrev} --name-only -z app/assets`
.split("\0")
.split("\0")
tasks << 'assets:precompile' if changed_assets.size > 0
run "#{rake_cmd} #{tasks.join(' ')} RAILS_ENV=#{RAILS_ENV}" if tasks.any?

View File

@ -119,6 +119,7 @@
promise: 'es6',
URL: 'url'
};
var supportCapture = 'capture' in create('input');
clearInterval(webshims.timer);
support.advancedObjectProperties = support.objectAccessor = support.ES5 = !!('create' in Object && 'seal' in Object);
@ -136,7 +137,7 @@
}
$.extend(webshims, {
version: '1.15.3',
version: '1.15.4',
cfg: {
enhanceAuto: window.Audio && (!window.matchMedia || matchMedia('(min-device-width: 721px)').matches),
@ -212,11 +213,13 @@
})(),
_polyfill: function(features){
var toLoadFeatures = [];
var hasFormsExt;
var hasFormsExt, needExtStyles;
if(!firstRun.run){
hasFormsExt = $.inArray('forms-ext', features) !== -1;
firstRun();
needExtStyles = (hasFormsExt && !modules["form-number-date-ui"].test()) || (!supportCapture && $.inArray('mediacapture', features) !== -1);
if(hasFormsExt && $.inArray('forms', features) == -1){
features.push('forms');
if(WSDEBUG){
@ -224,7 +227,7 @@
}
}
if(webCFG.loadStyles){
loader.loadCSS('styles/shim'+((hasFormsExt && !modules["form-number-date-ui"].test()) ? '-ext' : '')+'.css');
loader.loadCSS('styles/shim'+(needExtStyles ? '-ext' : '')+'.css');
}
}
@ -922,7 +925,7 @@
//<picture
create('picture');
addPolyfill('picture', {
test: ('picturefill' in window) || !!window.HTMLPictureElement,
test: ('picturefill' in window) || !!window.HTMLPictureElement || ('respimage' in window),
d: ['matchMedia'],
c: [18],
loadInit: function(){
@ -964,22 +967,6 @@
});
//>
//<usermedia
var userMediaTest = ('getUserMedia' in navigator);
addPolyfill('usermedia-core', {
f: 'usermedia',
test: userMediaTest && window.URL,
d: ['url', DOMSUPPORT]
});
addPolyfill('usermedia-shim', {
f: 'usermedia',
test: !!(userMediaTest || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia),
d: ['url', 'mediaelement', DOMSUPPORT]
});
//>
//<canvas
(function(){
addPolyfill('canvas', {
@ -1001,6 +988,30 @@
//>
//<usermedia
var userMediaTest = ('getUserMedia' in navigator);
addPolyfill('usermedia-core', {
f: 'usermedia',
test: userMediaTest && window.URL,
d: ['url', DOMSUPPORT]
});
addPolyfill('usermedia-shim', {
f: 'usermedia',
test: !!(userMediaTest || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia),
d: ['url', 'mediaelement', DOMSUPPORT]
});
//>
//<mediacapture
addPolyfill('mediacapture', {
test: supportCapture,
d: ['swfmini', 'usermedia', DOMSUPPORT, 'filereader', 'forms', 'canvas']
});
//>
//<forms
(function(){
var formExtend, formOptions;
@ -1086,7 +1097,7 @@
webshims.validationMessages = webshims.validityMessages = {
langSrc: 'i18n/formcfg-',
availableLangs: "ar cs el es fa fr he hi hu it ja lt nl pl pt pt-BR pt-PT ru sv zh-CN zh-TW".split(' ')
availableLangs: "ar ca cs el es fa fr he hi hu it ja lt nl pl pt pt-BR pt-PT ru sv zh-CN zh-TW".split(' ')
};
webshims.formcfg = $.extend({}, webshims.validationMessages);
@ -1244,15 +1255,6 @@
});
//>
/*
//<mediacapture
addPolyfill('mediacapture', {
test: 'capture' in create('input'),
d: ['swfmini', 'usermedia', DOMSUPPORT, 'filereader', 'forms', 'canvas']
});
//>
*/
//<details
addPolyfill('details', {
test: ('open' in create('details')),

View File

@ -85,13 +85,7 @@
};
}
}
if (typeof define === 'function' && define.amd) {
define(function () {
return dataURLtoBlob;
});
} else {
window.dataURLtoBlob = dataURLtoBlob;
}
window.dataURLtoBlob = dataURLtoBlob;
}(this));
webshim.isReady('canvas-blob', true);

View File

@ -479,6 +479,8 @@ webshims.isReady('swfmini', true);
}
return message || '';
};
webshims.refreshCustomValidityRules = $.noop;
$.fn.getErrorMessage = function(key){
var message = '';

View File

@ -102,20 +102,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
//jquery mobile and jquery ui
if(!$.widget){
if(!$.widget && (!$.pluginFactory || !$.pluginFactory.mixin)){
(function(){
var _cleanData = $.cleanData;
$.cleanData = function( elems ) {
if(!$.widget){
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
$.cleanData = (function( orig ) {
return function( elems ) {
var events, elem, i;
for ( i = 0; (elem = elems[i]) != null; i++ ) {
try {
$( elem ).triggerHandler( "remove" );
// http://bugs.jquery.com/ticket/8235
} catch( e ) {}
// Only trigger remove when necessary to save time
events = $._data( elem, "events" );
if ( events && events.remove ) {
$( elem ).triggerHandler( "remove" );
}
// http://bugs.jquery.com/ticket/8235
} catch ( e ) {}
}
}
_cleanData( elems );
};
orig( elems );
};
})( $.cleanData );
})();
}
@ -536,7 +541,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
return id;
};
})(),
domPrefixes: ["ws", "webkit", "moz", "ms", "o"],
domPrefixes: ["webkit", "moz", "ms", "o", "ws"],
prefixed: function (prop, obj){
var i, testProp;
@ -2275,9 +2280,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
},
time: function(val, o, noCorrect){
var fVal, i;
if(val){
val = val.split(':');
if(val.length != 2 || isNaN(parseInt(val[0] || '', 10)) || isNaN(parseInt(val[1] || '', 10))){
return val.join(':');
}
if(curCfg.meridian){
fVal = (val[0] * 1);
if(fVal && fVal >= 12){
@ -2432,6 +2441,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
createFormat('d');
var tmp, obj;
var ret = '';
if(opts.splitInput){
obj = {yy: 0, mm: 1, dd: 2};
} else {
@ -2453,8 +2463,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
}
ret = ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-');
}
return ret
;
return ret;
},
color: function(val, opts){
var ret = '#000000';
@ -2756,9 +2765,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
['defaultValue', 'value'].forEach(function(name){
var formatName = 'format'+name;
wsWidgetProto[name] = function(val, force){
if(!this._init || force || val !== this.options[name]){
this.element.prop(name, this.formatValue(val));
if(!this._init || force || val !== this.options[name] || this.options[formatName] != this.element.prop(name)){
this.options[formatName] = this.formatValue(val);
this.element.prop(name, this.options[formatName]);
this.options[name] = val;
this._propertyChange(name);
this.mirrorValidity();
@ -2882,36 +2893,34 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
var isValue = name == 'value';
spinBtnProto[name] = function(val, force, isLive){
var selectionEnd;
if(!this._init || force || this.options[name] !== val){
if(isValue){
this._beforeValue(val);
} else {
this.elemHelper.prop(name, val);
}
val = formatVal[this.type](val, this.options);
if(this.options.splitInput){
$.each(this.splits, function(i, elem){
var setOption;
if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
$('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
} else {
$.prop(elem, name, val[i]);
}
});
} else {
val = this.toFixed(val);
if(isLive && this._getSelectionEnd){
selectionEnd = this._getSelectionEnd(val);
}
this.element.prop(name, val);
if(selectionEnd != null){
this.element.prop('selectionEnd', selectionEnd);
}
}
this._propertyChange(name);
this.mirrorValidity();
if(isValue){
this._beforeValue(val);
} else {
this.elemHelper.prop(name, val);
}
val = formatVal[this.type](val, this.options);
if(this.options.splitInput){
$.each(this.splits, function(i, elem){
var setOption;
if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
$('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
} else {
$.prop(elem, name, val[i]);
}
});
} else {
val = this.toFixed(val);
if(isLive && this._getSelectionEnd){
selectionEnd = this._getSelectionEnd(val);
}
this.element.prop(name, val);
if(selectionEnd != null){
this.element.prop('selectionEnd', selectionEnd);
}
}
this._propertyChange(name);
this.mirrorValidity();
};
});

View File

@ -1044,9 +1044,13 @@
},
time: function(val, o, noCorrect){
var fVal, i;
if(val){
val = val.split(':');
if(val.length != 2 || isNaN(parseInt(val[0] || '', 10)) || isNaN(parseInt(val[1] || '', 10))){
return val.join(':');
}
if(curCfg.meridian){
fVal = (val[0] * 1);
if(fVal && fVal >= 12){
@ -1201,6 +1205,7 @@
createFormat('d');
var tmp, obj;
var ret = '';
if(opts.splitInput){
obj = {yy: 0, mm: 1, dd: 2};
} else {
@ -1222,8 +1227,7 @@
}
ret = ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-');
}
return ret
;
return ret;
},
color: function(val, opts){
var ret = '#000000';
@ -1525,9 +1529,11 @@
};
['defaultValue', 'value'].forEach(function(name){
var formatName = 'format'+name;
wsWidgetProto[name] = function(val, force){
if(!this._init || force || val !== this.options[name]){
this.element.prop(name, this.formatValue(val));
if(!this._init || force || val !== this.options[name] || this.options[formatName] != this.element.prop(name)){
this.options[formatName] = this.formatValue(val);
this.element.prop(name, this.options[formatName]);
this.options[name] = val;
this._propertyChange(name);
this.mirrorValidity();
@ -1651,36 +1657,34 @@
var isValue = name == 'value';
spinBtnProto[name] = function(val, force, isLive){
var selectionEnd;
if(!this._init || force || this.options[name] !== val){
if(isValue){
this._beforeValue(val);
} else {
this.elemHelper.prop(name, val);
}
val = formatVal[this.type](val, this.options);
if(this.options.splitInput){
$.each(this.splits, function(i, elem){
var setOption;
if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
$('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
} else {
$.prop(elem, name, val[i]);
}
});
} else {
val = this.toFixed(val);
if(isLive && this._getSelectionEnd){
selectionEnd = this._getSelectionEnd(val);
}
this.element.prop(name, val);
if(selectionEnd != null){
this.element.prop('selectionEnd', selectionEnd);
}
}
this._propertyChange(name);
this.mirrorValidity();
if(isValue){
this._beforeValue(val);
} else {
this.elemHelper.prop(name, val);
}
val = formatVal[this.type](val, this.options);
if(this.options.splitInput){
$.each(this.splits, function(i, elem){
var setOption;
if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
$('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
} else {
$.prop(elem, name, val[i]);
}
});
} else {
val = this.toFixed(val);
if(isLive && this._getSelectionEnd){
selectionEnd = this._getSelectionEnd(val);
}
this.element.prop(name, val);
if(selectionEnd != null){
this.element.prop('selectionEnd', selectionEnd);
}
}
this._propertyChange(name);
this.mirrorValidity();
};
});

View File

@ -893,10 +893,11 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
var copyName = {srclang: 'language'};
var updateMediaTrackList = function(baseData, trackList){
var i, len;
var callChange = false;
var removed = [];
var added = [];
var newTracks = [];
var i, len;
if(!baseData){
baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
}
@ -931,12 +932,13 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
removed.push(trackList[i]);
}
}
if(removed.length || added.length){
trackList.splice(0);
for(i = 0, len = newTracks.length; i < len; i++){
trackList.push(newTracks[i]);
}
for(i = 0, len = removed.length; i < len; i++){
$([trackList]).triggerHandler($.Event({type: 'removetrack', track: removed[i]}));
@ -949,6 +951,16 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
$(this).triggerHandler('updatetrackdisplay');
}
}
for(i = 0, len = trackList.length; i < len; i++){
if(trackList[i].__wsmode != trackList[i].mode){
trackList[i].__wsmode = trackList[i].mode;
callChange = true;
}
}
if(callChange){
$([trackList]).triggerHandler('change');
}
};
var refreshTrack = function(track, trackData){

View File

@ -670,10 +670,11 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
var copyName = {srclang: 'language'};
var updateMediaTrackList = function(baseData, trackList){
var i, len;
var callChange = false;
var removed = [];
var added = [];
var newTracks = [];
var i, len;
if(!baseData){
baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
}
@ -708,12 +709,13 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
removed.push(trackList[i]);
}
}
if(removed.length || added.length){
trackList.splice(0);
for(i = 0, len = newTracks.length; i < len; i++){
trackList.push(newTracks[i]);
}
for(i = 0, len = removed.length; i < len; i++){
$([trackList]).triggerHandler($.Event({type: 'removetrack', track: removed[i]}));
@ -726,6 +728,16 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
$(this).triggerHandler('updatetrackdisplay');
}
}
for(i = 0, len = trackList.length; i < len; i++){
if(trackList[i].__wsmode != trackList[i].mode){
trackList[i].__wsmode = trackList[i].mode;
callChange = true;
}
}
if(callChange){
$([trackList]).triggerHandler('change');
}
};
var refreshTrack = function(track, trackData){

View File

@ -102,20 +102,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
//jquery mobile and jquery ui
if(!$.widget){
if(!$.widget && (!$.pluginFactory || !$.pluginFactory.mixin)){
(function(){
var _cleanData = $.cleanData;
$.cleanData = function( elems ) {
if(!$.widget){
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
$.cleanData = (function( orig ) {
return function( elems ) {
var events, elem, i;
for ( i = 0; (elem = elems[i]) != null; i++ ) {
try {
$( elem ).triggerHandler( "remove" );
// http://bugs.jquery.com/ticket/8235
} catch( e ) {}
// Only trigger remove when necessary to save time
events = $._data( elem, "events" );
if ( events && events.remove ) {
$( elem ).triggerHandler( "remove" );
}
// http://bugs.jquery.com/ticket/8235
} catch ( e ) {}
}
}
_cleanData( elems );
};
orig( elems );
};
})( $.cleanData );
})();
}
@ -536,7 +541,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
return id;
};
})(),
domPrefixes: ["ws", "webkit", "moz", "ms", "o"],
domPrefixes: ["webkit", "moz", "ms", "o", "ws"],
prefixed: function (prop, obj){
var i, testProp;
@ -1487,6 +1492,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
}
return message || '';
};
webshims.refreshCustomValidityRules = $.noop;
$.fn.getErrorMessage = function(key){
var message = '';
@ -2149,22 +2156,25 @@ if(webshims.support.inputtypes.date && /webkit/i.test(navigator.userAgent)){
webshims.addReady(function(context, contextElem){
//start constrain-validation
var focusElem;
$('form', context)
.add(contextElem.filter('form'))
.on('invalid', $.noop)
;
try {
if(context == document && !('form' in (document.activeElement || {}))) {
focusElem = $(context.querySelector('input[autofocus], select[autofocus], textarea[autofocus]')).eq(0).getShadowFocusElement()[0];
if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
focusElem.focus();
setTimeout(function(){
var focusElem;
try {
if(!('form' in (document.activeElement || {}))) {
focusElem = $(context.querySelector('input[autofocus], select[autofocus], textarea[autofocus]')).eq(0).getShadowFocusElement()[0];
if (focusElem && (focusElem.offsetHeight || focusElem.offsetWidth)) {
focusElem.focus();
}
}
}
}
catch (er) {}
catch (er) {}
}, 9);
});
if(!webshims.support.datalist){

View File

@ -325,20 +325,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
//jquery mobile and jquery ui
if(!$.widget){
if(!$.widget && (!$.pluginFactory || !$.