incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1307988 - in /incubator/bloodhound/trunk/bloodhound_dashboard: ./ bhdashboard/ bhdashboard/layouts/ bhdashboard/layouts/htdocs/ bhdashboard/layouts/templates/
Date Sun, 01 Apr 2012 01:39:03 GMT
Author: gjm
Date: Sun Apr  1 01:39:03 2012
New Revision: 1307988

URL: http://svn.apache.org/viewvc?rev=1307988&view=rev
Log:
Dashboard code import: BH_Dashboard: Radio behavior for buttons in toolbar (layout)

Added:
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
  (with props)
Modified:
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_btnbar.html
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
    incubator/bloodhound/trunk/bloodhound_dashboard/setup.py

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py?rev=1307988&r1=1307987&r2=1307988&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py Sun Apr
 1 01:39:03 2012
@@ -25,7 +25,7 @@ Widgets displaying ticket data.
 """
 
 from trac.core import Component, implements, TracError
-from trac.web.chrome import add_stylesheet
+from trac.web.chrome import add_stylesheet, add_script
 
 from bhdashboard.api import ILayoutProvider
 
@@ -57,7 +57,7 @@ class BootstrapLayout(Component):
         add_stylesheet(req, 'dashboard/bootstrap.css')
 
         if name == 'bootstrap_btnbar':
-            self._process_btnbar(options)
+            self._process_btnbar(req, options)
 
         results = {
                 ('bootstrap_grid', False) : {
@@ -76,9 +76,10 @@ class BootstrapLayout(Component):
         return results[( name , bool(options.get('embed')) )]
 
     # Internal methods
-    def _process_btnbar(self, options):
+    def _process_btnbar(self, req, options):
         """Determine toolbar groups
         """
+        add_script(req, 'layouts/bootstrap-button.js')
         layout_data = options['schema']
         orig_tb = layout_data.get('toolbar', [])
         ready = layout_data.get('ready')

Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js?rev=1307988&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
(added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
Sun Apr  1 01:39:03 2012
@@ -0,0 +1,100 @@
+/* ============================================================
+ * bootstrap-button.js v2.0.1
+ * 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"
+
+ /* BUTTON PUBLIC CLASS DEFINITION
+  * ============================== */
+
+  var Button = function ( element, options ) {
+    this.$element = $(element)
+    this.options = $.extend({}, $.fn.button.defaults, options)
+  }
+
+  Button.prototype = {
+
+      constructor: Button
+
+    , 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)
+      }
+
+    , toggle: function () {
+        var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
+
+        $parent && $parent
+          .find('.active')
+          .removeClass('active')
+
+        this.$element.toggleClass('active')
+      }
+
+  }
+
+
+ /* BUTTON PLUGIN DEFINITION
+  * ======================== */
+
+  $.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 DATA-API
+  * =============== */
+
+  $(function () {
+    $('body').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 );

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/htdocs/bootstrap-button.js
------------------------------------------------------------------------------
    svn:mime-type = text/javascript

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_btnbar.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_btnbar.html?rev=1307988&r1=1307987&r2=1307988&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_btnbar.html
(original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_btnbar.html
Sun Apr  1 01:39:03 2012
@@ -6,12 +6,14 @@
 
   <xi:include href="widget_macros.html" />
 
-  <div class="btn-toolbar">
-    <div data-toggle="buttons-radio" class="btn-group offset1"
+  <div class="btn-toolbar" data-toggle="buttons-radio">
+    <div class="btn-group offset1"
         py:for="g in layout.toolbar" >
-      <a href="#" class="btn" py:for="tb_item in g">
+      <button href="#" disabled="${tb_item.widget is None and 'true' or None}" 
+          class="btn ${tb_item.widget is None and 'disabled' or None}" 
+          py:for="tb_item in g">
         ${tb_item.caption}
-      </a>
+      </button>
     </div>
   </div>
 </html>

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1307988&r1=1307987&r2=1307988&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Sun Apr  1 01:39:03
2012
@@ -96,6 +96,7 @@ class DashboardModule(Component):
         return [
                  ('dashboard', resource_filename('bhdashboard', 'htdocs')),
                  #('widgets', resource_filename('bhdashboard.widgets', 'htdocs'))
+                 ('layouts', resource_filename('bhdashboard.layouts', 'htdocs'))
                  ]
 
     def get_templates_dirs(self):

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/setup.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/setup.py?rev=1307988&r1=1307987&r2=1307988&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/setup.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/setup.py Sun Apr  1 01:39:03 2012
@@ -88,7 +88,8 @@ DIST_NM = 'BloodhoundDashboardPlugin'
 PKG_INFO = {'bhdashboard' : ('bhdashboard',                     # Package dir
                             # Package data
                             ['../CHANGES', '../TODO', '../COPYRIGHT', 
-                              '../NOTICE', '../README', '../TESTING_README'],
+                              '../NOTICE', '../README', '../TESTING_README',
+                              'htdocs/*'],
                           ), 
             'bhdashboard.widgets' : ('bhdashboard/widgets',     # Package dir
                             # Package data



Mime
View raw message