[refs #442] Small refactor. Remove bootstrap collapse

This commit is contained in:
konstantin.grabar 2012-06-28 15:31:25 +04:00
parent 4187ef8873
commit 10aed58bdd
7 changed files with 22 additions and 187 deletions

View File

@ -71,4 +71,14 @@ $(document).ready(function() {
}
});
$(".toggle_btn").click(function() {
var target = $( $(this).attr('data-target') );
//target.toggle();
if ( target.css('visibility') == 'hidden' ) {
target.css('visibility', 'visible');
} else {
target.css('visibility', 'hidden');
}
return false;
});
});

View File

@ -1,157 +0,0 @@
/* =============================================================
* bootstrap-collapse.js v2.0.4
* 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) 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')
this.$element[dimension](this.$element[0][scroll])
}
, hide: function () {
var dimension
if (this.transitioning) 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']()
}
}
/* COLLAPSIBLE PLUGIN DEFINITION
* ============================== */
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
, options = 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
/* COLLAPSIBLE DATA-API
* ==================== */
$(function () {
$('body').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()
$(target).collapse(option)
})
})
}(window.jQuery);

View File

@ -1081,9 +1081,11 @@ form.mass_build section.right {
margin-right: 50px;
}
.collapse {
.toggle {
overflow: hidden;
padding-top: 10px;
display: block;
visibility: hidden;
}
.min_width_120 {

View File

@ -18,7 +18,7 @@ class Platforms::PlatformsController < Platforms::BaseController
if mass_build.save
redirect_to(mass_builds_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
else
@auto_publish_selected = params[:auto_publish].present? ? params[:auto_publish].present? : false
@auto_publish_selected = params[:auto_publish].present?
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
flash[:warning] = mass_build.errors.full_messages.join('. ')
flash[:error] = t("flash.platform.build_all_error")

View File

@ -38,28 +38,14 @@
%td= mass_build.id
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
%td.min_width_120
= link_to t("layout.build_lists.all") + ": ", build_lists_path
= mass_build.build_lists_count
.both
= link_to t("layout.build_lists.statuses.build_published") + ": ", build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED, :mass_build_id => mass_build.id})
= mass_build.build_published_count
.both
= link_to t("layout.build_lists.statuses.build_pending") + ": ", build_lists_path(:filter => {:status => BuildList::BUILD_PENDING, :mass_build_id => mass_build.id})
= mass_build.build_pending_count
.both
= link_to t("layout.build_lists.statuses.build_started") + ": ", build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED, :mass_build_id => mass_build.id})
= mass_build.build_started_count
.both
= link_to t("layout.build_lists.statuses.build_publish") + ": ", build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISH, :mass_build_id => mass_build.id})
= mass_build.build_publish_count
.both
= link_to t("layout.build_lists.statuses.build_error") + ": ", build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR, :mass_build_id => mass_build.id})
= mass_build.build_error_count
.both
- MassBuild::COUNT_STATUSES.each do |status|
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:status => status, :mass_build_id => mass_build.id})
= mass_build.read_attribute "#{status}_count"
.both
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platforms_path(:mass_build_id => mass_build.id), :target => "_blank"
%td
%a{:href => "collapse_#{ mass_build.id }", :'data-toggle' => "collapse", :'data-target' => "#collapse_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
.in.collapse{:id => "collapse_#{ mass_build.id }"}
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
.toggle{:id => "toggle_#{ mass_build.id }"}
= t('activerecord.attributes.mass_build.arch_names') + ": "
= mass_build.arch_names
.both
@ -71,10 +57,4 @@
.both
= t('activerecord.attributes.mass_build.created_at') + ": "
= mass_build.created_at
.both
= will_paginate @mass_builds
= javascript_include_tag "lib/bootstrap-collapse"
:javascript
$(".collapse").collapse();

View File

@ -45,7 +45,6 @@ en:
layout:
build_lists:
all: All
filter_header: Filter
current: Curent
created_at_start: "Build to start on:"
@ -98,6 +97,7 @@ en:
git_error: Git error
statuses:
build_lists: All
build_error: Build error
build_published: Build has been published
rejected_publish: Publishing rejected

View File

@ -44,7 +44,6 @@ ru:
layout:
build_lists:
all: Все
filter_header: Фильтр
current: Текущие
created_at_start: "Время постановки на сборку с:"
@ -97,6 +96,7 @@ ru:
git_error: проблема с гит
statuses:
build_lists: Всего
build_error: ошибка сборки
build_published: опубликован
rejected_publish: публикация отклонена