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

@ -560,7 +560,7 @@ class App.Controller extends Spine.Controller
clearInterval( @intervalID[interval_id] ) if @intervalID[interval_id] clearInterval( @intervalID[interval_id] ) if @intervalID[interval_id]
interval: (action, interval, interval_id) => interval: (action, interval, interval_id) =>
# check global var # check global var
if !@intervalID if !@intervalID
@intervalID = {} @intervalID = {}
@ -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
@ -608,7 +608,7 @@ class App.Controller extends Spine.Controller
App.view('user_info_small')( App.view('user_info_small')(
user: user, user: user,
data: data, data: data,
) )
) )
userTicketPopups: (data) -> userTicketPopups: (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,36 +626,37 @@ 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')(
tickets: data, tickets: data,
) )
) )
loadCollection: (params) -> loadCollection: (params) ->
# users # users
if params.type == 'User' if params.type == 'User'
for user_id, user of params.data for user_id, user of params.data

View file

@ -42,14 +42,14 @@ class App.UserInfo extends App.Controller
user: App.User.find(user_id), user: App.User.find(user_id),
data: data, data: data,
) )
@userTicketPopups( @userTicketPopups(
selector: '.user-tickets', selector: '.user-tickets',
user_id: user_id, user_id: user_id,
) )
update: (e) => update: (e) =>
# update changes # update changes
note = $(e.target).parent().find('[data-type=edit]').val() note = $(e.target).parent().find('[data-type=edit]').val()
user = App.User.find(@user_id) user = App.User.find(@user_id)

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')
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
$parent = $(selector)
$parent.length || ($parent = $this.parent())
isActive = $parent.hasClass('open') isActive = $parent.hasClass('open')
clearMenus() clearMenus()
if (!isActive) { if (!isActive) $parent.toggleClass('open')
$parent.toggleClass('open')
$this.focus()
}
return false 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() { function clearMenus() {
getParent($(toggle)) $(toggle).parent().removeClass('open')
}
function getParent($this) {
var selector = $this.attr('data-target')
, $parent
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
selector.replace(/\//, '\/\/')
$parent = $(selector)
$parent.length || ($parent = $this.parent())
return $parent
} }
@ -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,98 +91,90 @@
$('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) { /* MODAL PRIVATE METHODS
that.$element.focus() * ===================== */
}
}) function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
hideModal.call(that)
})
}
function hideModal(that) {
this.$element
.hide()
.trigger('hidden')
backdrop.call(this)
}
function backdrop(callback) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)
if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
} }
, escape: function () { if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
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 () { this.$backdrop.addClass('in')
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
that.hideModal()
}, 500)
this.$element.one($.support.transition.end, function () { doAnimate ?
clearTimeout(timeout) this.$backdrop.one($.support.transition.end, callback) :
that.hideModal() callback()
})
}
, hideModal: function (that) { } else if (!this.isShown && this.$backdrop) {
this.$element this.$backdrop.removeClass('in')
.hide()
.trigger('hidden')
this.backdrop() $.support.transition && this.$element.hasClass('fade')?
} this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
removeBackdrop.call(this)
, removeBackdrop: function () { } else if (callback) {
this.$backdrop.remove() callback()
this.$backdrop = null }
} }
, backdrop: function (callback) { function removeBackdrop() {
var that = this this.$backdrop.remove()
, animate = this.$element.hasClass('fade') ? 'fade' : '' this.$backdrop = null
}
if (this.isShown && this.options.backdrop) { function escape() {
var doAnimate = $.support.transition && animate var that = this
if (this.isShown && this.options.keyboard) {
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') $(document).on('keyup.dismiss.modal', function ( e ) {
.appendTo(document.body) e.which == 27 && that.hide()
})
if (this.options.backdrop != 'static') { } else if (!this.isShown) {
this.$backdrop.click($.proxy(this.hide, this)) $(document).off('keyup.dismiss.modal')
} }
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
this.removeBackdrop()
} else if (callback) {
callback()
}
}
} }
@ -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.
@ -26,7 +26,7 @@
/* POPOVER PUBLIC CLASS DEFINITION /* POPOVER PUBLIC CLASS DEFINITION
* =============================== */ * =============================== */
var Popover = function (element, options) { var Popover = function ( element, options ) {
this.init('popover', element, options) this.init('popover', element, options)
} }
@ -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.
@ -26,7 +26,7 @@
/* TAB CLASS DEFINITION /* TAB CLASS DEFINITION
* ==================== */ * ==================== */
var Tab = function (element) { var Tab = function ( element ) {
this.element = $(element) this.element = $(element)
} }

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)) eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
} else if (this.options.trigger != 'manual') {
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