From 10aed58bdd847c9fbc861105f8bacba3ebe951eb Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 28 Jun 2012 15:31:25 +0400 Subject: [PATCH] [refs #442] Small refactor. Remove bootstrap collapse --- app/assets/javascripts/application.js | 10 ++ .../javascripts/lib/bootstrap-collapse.js | 157 ------------------ app/assets/stylesheets/design/custom.scss | 4 +- .../platforms/platforms_controller.rb | 2 +- .../platforms/platforms/build_all.html.haml | 32 +--- config/locales/models/build_list.en.yml | 2 +- config/locales/models/build_list.ru.yml | 2 +- 7 files changed, 22 insertions(+), 187 deletions(-) delete mode 100644 app/assets/javascripts/lib/bootstrap-collapse.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9d8340566..50a2a47c5 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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; + }); }); diff --git a/app/assets/javascripts/lib/bootstrap-collapse.js b/app/assets/javascripts/lib/bootstrap-collapse.js deleted file mode 100644 index fbc915b9f..000000000 --- a/app/assets/javascripts/lib/bootstrap-collapse.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 29b395cf3..d88c62891 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -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 { diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index e76800647..14058ba36 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -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") diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index d486ac526..67b275ac9 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -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(); diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 9b8f0c912..139ae436b 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -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 diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 41c4054e8..910292188 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -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: публикация отклонена