Moved back to javascript of bootstrap 2.0.4.

This commit is contained in:
Martin Edenhofer 2012-08-24 22:31:36 +02:00
parent 959faa6a94
commit b02ac54547
8 changed files with 144 additions and 218 deletions

View file

@ -587,12 +587,12 @@ class App.Controller extends Spine.Controller
delay: { show: 500, hide: 1200 }, delay: { show: 500, hide: 1200 },
# placement: 'bottom', # placement: 'bottom',
placement: position, placement: position,
title: (e) => title: ->
user_id = $(e).data('id') user_id = $(@).data('id')
user = App.User.find(user_id) user = App.User.find(user_id)
(user.firstname || '') + ' ' + (user.lastname || '') (user.firstname || '') + ' ' + (user.lastname || '')
content: (e) => content: ->
user_id = $(e).data('id') user_id = $(@).data('id')
user = App.User.find(user_id) user = App.User.find(user_id)
# get display data # get display data
@ -617,7 +617,7 @@ class App.Controller extends Spine.Controller
$('.popover-inner').parent().remove() $('.popover-inner').parent().remove()
# get data # get data
@tickets = {} tickets = {}
App.Com.ajax( App.Com.ajax(
type: 'GET', type: 'GET',
url: '/ticket_customer', url: '/ticket_customer',
@ -626,27 +626,28 @@ class App.Controller extends Spine.Controller
} }
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
@tickets = data.tickets tickets = data.tickets
) )
if !data.position if !data.position
data.position = 'left' data.position = 'left'
# show user popup # show user popup
controller = @
$(data.selector).popover( $(data.selector).popover(
delay: { show: 500, hide: 5200 }, delay: { show: 500, hide: 5200 },
placement: data.position, placement: data.position,
title: (e) => title: ->
$(e).find('[title="*"]').val() $(@).find('[title="*"]').val()
content: (e) => content: ->
type = $(e).filter('[data-type]').data('type') type = $(@).filter('[data-type]').data('type')
data = @tickets[type] || [] data = tickets[type] || []
for ticket in data for ticket in data
# set human time # set human time
ticket.humanTime = @humanTime(ticket.created_at) ticket.humanTime = controller.humanTime(ticket.created_at)
# insert data # insert data
App.view('user_ticket_info_small')( App.view('user_ticket_info_small')(

View file

@ -1,5 +1,5 @@
/* ============================================================ /* ============================================================
* bootstrap-dropdown.js v2.1.0 * bootstrap-dropdown.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#dropdowns * http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================ * ============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -26,7 +26,7 @@
/* DROPDOWN CLASS DEFINITION /* DROPDOWN CLASS DEFINITION
* ========================= */ * ========================= */
var toggle = '[data-toggle=dropdown]' var toggle = '[data-toggle="dropdown"]'
, Dropdown = function (element) { , Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle) var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () { $('html').on('click.dropdown.data-api', function () {
@ -41,82 +41,34 @@
, toggle: function (e) { , toggle: function (e) {
var $this = $(this) var $this = $(this)
, $parent , $parent
, selector
, isActive , isActive
if ($this.is('.disabled, :disabled')) return if ($this.is('.disabled, :disabled')) return
$parent = getParent($this) selector = $this.attr('data-target')
isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
$parent.toggleClass('open')
$this.focus()
}
return false
}
, keydown: function (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
if (!/(38|40|27)/.test(e.keyCode)) return
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
$items = $('[role=menu] li:not(.divider) a', $parent)
if (!$items.length) return
index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items
.eq(index)
.focus()
}
}
function clearMenus() {
getParent($(toggle))
}
function getParent($this) {
var selector = $this.attr('data-target')
, $parent
if (!selector) { if (!selector) {
selector = $this.attr('href') selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
} }
selector.replace(/\//, '\/\/')
$parent = $(selector) $parent = $(selector)
$parent.length || ($parent = $this.parent()) $parent.length || ($parent = $this.parent())
return $parent isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) $parent.toggleClass('open')
return false
}
}
function clearMenus() {
$(toggle).parent().removeClass('open')
} }
@ -139,12 +91,10 @@
* =================================== */ * =================================== */
$(function () { $(function () {
$('html') $('html').on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
$('body') $('body')
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() }) .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
}) })
}(window.jQuery); }(window.jQuery);

View file

@ -1,5 +1,5 @@
/* ========================================================= /* =========================================================
* bootstrap-modal.js v2.1.0 * bootstrap-modal.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#modals * http://twitter.github.com/bootstrap/javascript.html#modals
* ========================================================= * =========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -26,11 +26,10 @@
/* MODAL CLASS DEFINITION /* MODAL CLASS DEFINITION
* ====================== */ * ====================== */
var Modal = function (element, options) { var Modal = function (content, options) {
this.options = options this.options = options
this.$element = $(element) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
} }
Modal.prototype = { Modal.prototype = {
@ -53,9 +52,8 @@
this.isShown = true this.isShown = true
this.escape() escape.call(this)
backdrop.call(this, function () {
this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade') var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) { if (!that.$element.parent().length) {
@ -69,12 +67,7 @@
that.$element[0].offsetWidth // force reflow that.$element[0].offsetWidth // force reflow
} }
that.$element that.$element.addClass('in')
.addClass('in')
.attr('aria-hidden', false)
.focus()
that.enforceFocus()
transition ? transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
@ -98,66 +91,43 @@
$('body').removeClass('modal-open') $('body').removeClass('modal-open')
this.escape() escape.call(this)
$(document).off('focusin.modal') this.$element.removeClass('in')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
$.support.transition && this.$element.hasClass('fade') ? $.support.transition && this.$element.hasClass('fade') ?
this.hideWithTransition() : hideWithTransition.call(this) :
this.hideModal() hideModal.call(this)
} }
, enforceFocus: function () {
var that = this
$(document).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
})
} }
, escape: function () {
var that = this
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
}
}
, hideWithTransition: function () { /* MODAL PRIVATE METHODS
* ===================== */
function hideWithTransition() {
var that = this var that = this
, timeout = setTimeout(function () { , timeout = setTimeout(function () {
that.$element.off($.support.transition.end) that.$element.off($.support.transition.end)
that.hideModal() hideModal.call(that)
}, 500) }, 500)
this.$element.one($.support.transition.end, function () { this.$element.one($.support.transition.end, function () {
clearTimeout(timeout) clearTimeout(timeout)
that.hideModal() hideModal.call(that)
}) })
} }
, hideModal: function (that) { function hideModal(that) {
this.$element this.$element
.hide() .hide()
.trigger('hidden') .trigger('hidden')
this.backdrop() backdrop.call(this)
} }
, removeBackdrop: function () { function backdrop(callback) {
this.$backdrop.remove()
this.$backdrop = null
}
, backdrop: function (callback) {
var that = this var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : '' , animate = this.$element.hasClass('fade') ? 'fade' : ''
@ -183,13 +153,28 @@
this.$backdrop.removeClass('in') this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')? $.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) : this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
this.removeBackdrop() removeBackdrop.call(this)
} else if (callback) { } else if (callback) {
callback() callback()
} }
} }
function removeBackdrop() {
this.$backdrop.remove()
this.$backdrop = null
}
function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
}
} }
@ -221,18 +206,12 @@
$(function () { $(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this) var $this = $(this), href
, href = $this.attr('href') , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
$target.modal(option)
$target
.modal(option)
.one('hide', function () {
$this.focus()
})
}) })
}) })

View file

@ -1,5 +1,5 @@
/* =========================================================== /* ===========================================================
* bootstrap-popover.js v2.1.0 * bootstrap-popover.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#popovers * http://twitter.github.com/bootstrap/javascript.html#popovers
* =========================================================== * ===========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -43,8 +43,8 @@
, title = this.getTitle() , title = this.getTitle()
, content = this.getContent() , content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content) $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
$tip.removeClass('fade top bottom left right in') $tip.removeClass('fade top bottom left right in')
} }
@ -71,10 +71,6 @@
return this.$tip return this.$tip
} }
, destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}) })
@ -95,7 +91,6 @@
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, { $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right' placement: 'right'
, trigger: 'click'
, content: '' , content: ''
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
}) })

View file

@ -1,5 +1,5 @@
/* ======================================================== /* ========================================================
* bootstrap-tab.js v2.1.0 * bootstrap-tab.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#tabs * http://twitter.github.com/bootstrap/javascript.html#tabs
* ======================================================== * ========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.

View file

@ -1,5 +1,5 @@
/* =========================================================== /* ===========================================================
* bootstrap-tooltip.js v2.1.0 * bootstrap-tooltip.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#tooltips * http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame * Inspired by the original jQuery.tipsy by Jason Frame
* =========================================================== * ===========================================================
@ -44,13 +44,11 @@
this.options = this.getOptions(options) this.options = this.getOptions(options)
this.enabled = true this.enabled = true
if (this.options.trigger == 'click') { if (this.options.trigger != 'manual') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (this.options.trigger != 'manual') {
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
} }
this.options.selector ? this.options.selector ?
@ -150,11 +148,20 @@
} }
} }
, isHTML: function(text) {
// html string detection logic adapted from jQuery
return typeof text != 'string'
|| ( text.charAt(0) === "<"
&& text.charAt( text.length - 1 ) === ">"
&& text.length >= 3
) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
}
, setContent: function () { , setContent: function () {
var $tip = this.tip() var $tip = this.tip()
, title = this.getTitle() , title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right') $tip.removeClass('fade in top bottom left right')
} }
@ -178,8 +185,6 @@
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() : removeWithAnimation() :
$tip.remove() $tip.remove()
return this
} }
, fixTitle: function () { , fixTitle: function () {
@ -239,10 +244,6 @@
this[this.tip().hasClass('in') ? 'hide' : 'show']() this[this.tip().hasClass('in') ? 'hide' : 'show']()
} }
, destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
} }
@ -269,7 +270,6 @@
, trigger: 'hover' , trigger: 'hover'
, title: '' , title: ''
, delay: 0 , delay: 0
, html: true
} }
}(window.jQuery); }(window.jQuery);

View file

@ -1,5 +1,5 @@
/* =================================================== /* ===================================================
* bootstrap-transition.js v2.1.0 * bootstrap-transition.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#transitions * http://twitter.github.com/bootstrap/javascript.html#transitions
* =================================================== * ===================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -36,7 +36,8 @@
, transEndEventNames = { , transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd' 'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend' , 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend' , 'OTransition' : 'oTransitionEnd'
, 'msTransition' : 'MSTransitionEnd'
, 'transition' : 'transitionend' , 'transition' : 'transitionend'
} }
, name , name