This commit is contained in:
parent
38d5c9faf1
commit
b676a330d9
16 changed files with 7297 additions and 0 deletions
18
Makefile
Normal file
18
Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
FILES =\
|
||||
*.js\
|
||||
*.css\
|
||||
jquery\
|
||||
examples
|
||||
|
||||
zip:
|
||||
@mkdir -p build/full_calendar
|
||||
@cp -rt build/full_calendar ${FILES}
|
||||
@sed -i "s/Version:/& `cat version.txt`/" build/full_calendar/full_calendar.js
|
||||
@mkdir -p dist
|
||||
@cd build;\
|
||||
zip -r ../dist/full_calendar_`cat ../version.txt`.zip *
|
||||
|
||||
clean:
|
||||
@rm -rf build/*
|
||||
@rm -rf dist/*
|
82
docs/Makefile
Normal file
82
docs/Makefile
Normal file
|
@ -0,0 +1,82 @@
|
|||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " changes to make an overview over all changed/added/deprecated items"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
|
||||
clean:
|
||||
-rm -rf build/*
|
||||
|
||||
html:
|
||||
mkdir -p build/html build/doctrees
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in build/html."
|
||||
|
||||
arshaw:
|
||||
mkdir -p build/html build/doctrees
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
|
||||
cp -r build/html/* /var/www/arshaw/pages/fullcalendar/docs/
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in build/html."
|
||||
|
||||
pickle:
|
||||
mkdir -p build/pickle build/doctrees
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
web: pickle
|
||||
|
||||
json:
|
||||
mkdir -p build/json build/doctrees
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
mkdir -p build/htmlhelp build/doctrees
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in build/htmlhelp."
|
||||
|
||||
latex:
|
||||
mkdir -p build/latex build/doctrees
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in build/latex."
|
||||
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
|
||||
"run these through (pdf)latex."
|
||||
|
||||
changes:
|
||||
mkdir -p build/changes build/doctrees
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
|
||||
@echo
|
||||
@echo "The overview file is in build/changes."
|
||||
|
||||
linkcheck:
|
||||
mkdir -p build/linkcheck build/doctrees
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in build/linkcheck/output.txt."
|
190
docs/conf.py
Normal file
190
docs/conf.py
Normal file
|
@ -0,0 +1,190 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# FullCalendar documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sat Apr 11 19:03:41 2009.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# The contents of this file are pickled, so don't put values in the namespace
|
||||
# that aren't pickleable (module imports are okay, they're removed automatically).
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If your extensions are in another directory, add it here. If the directory
|
||||
# is relative to the documentation root, use os.path.abspath to make it
|
||||
# absolute, like shown here.
|
||||
#sys.path.append(os.path.abspath('.'))
|
||||
|
||||
# General configuration
|
||||
# ---------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.txt'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'FullCalendar'
|
||||
copyright = u'2009, Adam Shaw'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = open('../version.txt').read()
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# List of directories, relative to source directory, that shouldn't be searched
|
||||
# for source files.
|
||||
exclude_trees = ['build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
|
||||
# Options for HTML output
|
||||
# -----------------------
|
||||
|
||||
# The style sheet to use for HTML and HTML Help pages. A file of that name
|
||||
# must exist either in Sphinx' static/ path, or in one of the custom paths
|
||||
# given in html_static_path.
|
||||
html_style = 'default.css'
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_use_modindex = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||
#html_copy_source = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
html_file_suffix = '.php'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'FullCalendardoc'
|
||||
|
||||
|
||||
# Options for LaTeX output
|
||||
# ------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'FullCalendar.tex', ur'FullCalendar Documentation',
|
||||
ur'Adam Shaw', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#latex_preamble = ''
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_use_modindex = True
|
228
docs/index.txt
Normal file
228
docs/index.txt
Normal file
|
@ -0,0 +1,228 @@
|
|||
|
||||
.. highlight:: javascript
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
.fullCalendar({
|
||||
// initializes a calendar
|
||||
// see options, data provider, and triggered events below
|
||||
})
|
||||
|
||||
.fullCalendar('nextMonth') // move the calendar one month ahead
|
||||
|
||||
.fullCalendar('currentMonth') // move to current month
|
||||
|
||||
.fullCalendar('prevMonth') // move back one month
|
||||
|
||||
.fullCalendar('gotoMonth', year, month)
|
||||
// go to an arbitrary month. 'month' is zero-based
|
||||
|
||||
|
||||
Options
|
||||
=======
|
||||
|
||||
**year**, **month**: integers
|
||||
The month that will be displayed when the calendar first loads.
|
||||
``month`` is zero-based (January is 0, February is 1, etc).
|
||||
|
||||
**draggable**: boolean, default:``false``
|
||||
Determines if all events on the calendar can be dragged & dropped. If
|
||||
``true``, requires `jQuery UI <http://jqueryui.com/>`_ core and draggables.
|
||||
Can be overridden on a per-event basis with the ``draggable`` property of
|
||||
each :ref:`CalEvent <CalEvent>` object.
|
||||
|
||||
**fixedWeeks**: boolean, default:``true``
|
||||
If ``true``, the calendar will always be 6 weeks tall. If ``false``, the
|
||||
calendar's height will vary per month.
|
||||
|
||||
**abbrevDayHeadings**: boolean, default:``true``
|
||||
Whether to display "Sun" versus "Sunday" for days of the week.
|
||||
|
||||
**title**: boolean, default:``true``
|
||||
Determines whether a title such as "January 2009" will be displayed at the
|
||||
top of the calendar.
|
||||
|
||||
**buttons**: boolean/hash, default:``true``
|
||||
Determines whether navigation buttons will be displayed at the top of the
|
||||
calendar. A hash with keys 'today', 'prev', and 'next' will determine if
|
||||
each individual button is displayed. Strings can be provided to change
|
||||
each button's text.
|
||||
|
||||
**showTime**: boolean/ ``"guess"``, default:``"guess"``
|
||||
Determines if times such as "8a" or "1p" will be displayed before each
|
||||
event's title. ``"guess"`` displays times only for events with non-zero
|
||||
start or end times.
|
||||
|
||||
**eventDragOpacity**: float
|
||||
The opacity of an event element while it is being dragged (0.0 - 1.0)
|
||||
|
||||
**eventRevertDuration**: integer
|
||||
Controls the duration (in milliseconds) of the animation of an event
|
||||
snapping back into place.
|
||||
|
||||
|
||||
.. _EventDataProvider:
|
||||
|
||||
Event Data Provider
|
||||
===================
|
||||
|
||||
**events**: array/string/function
|
||||
An array of :ref:`CalEvent` can be used to hardcode events into the
|
||||
calendar.
|
||||
|
||||
Or, a URL can be provided. This URL should return JSON for an array of
|
||||
:ref:`CalEvent`. GET parameters, determined by the ``startParam`` and
|
||||
``endParam`` options, will be inserted into the URL. These parameters
|
||||
indicate the UNIX timestamp of the start of the first visible day
|
||||
(inclusive) and the end of the last visible day (exclusive).
|
||||
|
||||
Or, a function can be provided for custom fetching. The function is
|
||||
queried every time event data is needed. The function is passed a ``start``
|
||||
Date object, an ``end`` Date object, and a function to be called when
|
||||
fetching is complete. Here is the general form::
|
||||
|
||||
events: function(start, end, callback) {
|
||||
|
||||
// do some asynchronous ajax
|
||||
$.getJSON("/myscript",
|
||||
{
|
||||
start: start.getTime(),
|
||||
end: end.getTime()
|
||||
},
|
||||
function(result) {
|
||||
|
||||
// format the result into an array of 'CalEvent' objects
|
||||
// (not seen here)
|
||||
|
||||
// then, pass the 'calevent' array to the callback
|
||||
callback(calevents);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
**startParam**: string, default:``"start"``
|
||||
This GET parameter will be inserted into the URL when ``event`` is a URL
|
||||
string. Example of a resulting URL: ``/myjsonscript?start=1238562000``
|
||||
|
||||
**endParam**: string, default:``"end"``
|
||||
This GET parameter will be inserted into the URL when ``event`` is a URL
|
||||
string. Example of a resulting URL: ``/myjsonscript?end=1240691444``
|
||||
|
||||
|
||||
.. _TriggeredEvents:
|
||||
|
||||
Triggered Events
|
||||
================
|
||||
|
||||
**monthDisplay**: function(year, month, monthTitle)
|
||||
Triggered once when the calendar loads and every time the
|
||||
calendar's month is changed. ``month`` is zero-based. ``monthTitle``
|
||||
contains the new title of the month (ex: "January 2009")
|
||||
|
||||
**loading**: function(isLoading)
|
||||
Triggered with a ``true`` argument when the calendar begins fetching
|
||||
events via AJAX. Triggered with ``false`` when done.
|
||||
|
||||
**dayClick**: function(dayDate)
|
||||
Triggered when the user clicks on a day. ``dayDate`` is a Date object with
|
||||
it's time set to 00:00:00.
|
||||
|
||||
``this`` is set to the TD element of the clicked day.
|
||||
|
||||
**eventRender**: function(calEvent, element)
|
||||
Triggered before an element is rendered for the given ``calEvent``.
|
||||
``element`` is the jQuery element that will be used by default. You can modify
|
||||
this element or return a brand new element that will be used instead.
|
||||
|
||||
**eventClick**, **eventMouseover**, **eventMouseout**: function(calEvent, domEvent)
|
||||
Triggered on click/mouseover/mouseout actions for an event.
|
||||
``calEvent`` holds that event's information (date, title, etc).
|
||||
``domEvent`` holds the native DOM event (with information about click position, etc).
|
||||
|
||||
``this`` is set to the event's TABLE element
|
||||
|
||||
For ``eventClick``, return ``false`` to prevent the browser from going to
|
||||
calEvent's URL.
|
||||
|
||||
**eventDragStart**, **eventDragStop**: function(calEvent, domEvent, ui)
|
||||
Triggered before/after an event is dragged (but not necessarily moved to a new day).
|
||||
``calEvent`` holds that event's information (date, title, etc).
|
||||
``domEvent`` holds the native DOM event (with information about click position, etc).
|
||||
``ui`` holds the jQuery UI object.
|
||||
|
||||
``this`` is set to the event's TABLE element
|
||||
|
||||
**eventDrop**: function(calEvent, dayDelta, domEvent, ui)
|
||||
Triggered when dragging stops and the event has moved to a *different* day.
|
||||
``dayDelta`` holds the number of days the event was moved forward (a positive number)
|
||||
or backwards (a negative number).
|
||||
|
||||
``dayDelta`` is elegant for dealing with multi-day and repeating events.
|
||||
If updating a remote database, just add the ``dayDelta`` to the start
|
||||
and end times of all events with the given ``calEvent.id``
|
||||
|
||||
|
||||
.. _CalEvent:
|
||||
|
||||
CalEvent Objects
|
||||
================
|
||||
|
||||
A ``CalEvent`` is a data structure that frequents FullCalendar's API. It is
|
||||
used when a custom event-fetcher needs to report to the :ref:`EventDataProvider`.
|
||||
It is also used in various :ref:`TriggeredEvents`. Here are the properties of a
|
||||
``CalEvent``\:
|
||||
|
||||
**id**: integer/string,
|
||||
Uniquely identifies the given event. Absolutely essential for multi-day
|
||||
and repeating events to be dragged and dropped correctly.
|
||||
|
||||
**title**: string,
|
||||
The text on an event's element
|
||||
|
||||
**date**: date
|
||||
Alias for ``start``
|
||||
|
||||
**start**: date
|
||||
A javascript Date object indicating the date/time an event begins.
|
||||
Events with ambiguous time-of-day should use 00:00:00.
|
||||
|
||||
When reporting to the :ref:`EventDataProvider`, for convenience,
|
||||
one can also use a string in IETF format (ex: "Wed, 18 Oct 2009 13:00:00 EST"),
|
||||
a string in ISO8601 format (ex: "2009-11-05T13:15:30Z") or an integer
|
||||
UNIX timestamp.
|
||||
|
||||
**end**: date (optional)
|
||||
A javascript Date object indicating the date/time an event ends
|
||||
(exclusively). If an event has an ambiguous end time, ``end`` should be
|
||||
set to midnight of the next day. This is implied if ``end`` is omitted.
|
||||
(For convenience with the :ref:`EventDataProvider`).
|
||||
|
||||
IETF and ISO8601 strings can be used for the :ref:`EventDataProvider`.
|
||||
|
||||
**draggable**: boolean (optional)
|
||||
Overrides the master ``draggable`` property for this single event.
|
||||
|
||||
**showTime**: boolean/ ``"guess"`` (optional)
|
||||
Overrides the master ``showTime`` property for this single event.
|
||||
|
||||
When giving events to the :ref:`EventDataProvider`, one can include other
|
||||
properties beyond the ones listed. This is useful if you want to earmark your
|
||||
events with additional data to be retrieved later during a
|
||||
:ref:`Triggered Event <TriggeredEvents>`.
|
||||
|
||||
|
||||
Extras
|
||||
======
|
||||
|
||||
FullCalendar provides some extra date utilities\:
|
||||
|
||||
**$.parseISO8601(string, ignoreTimezone)**
|
||||
Parses an ISO8601 string and returns a ``Date`` object
|
||||
|
||||
**$.ISO8601String(date)**
|
||||
Takes a ``Date`` object and returns an ISO8601 string
|
||||
|
8
docs/templates/layout.html
vendored
Normal file
8
docs/templates/layout.html
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<? fullcalendar_docs_head() ?>
|
||||
<? fullcalendar_title() ?>
|
||||
<? fullcalendar_nav() ?>
|
||||
<? begin_content() ?>
|
||||
|
||||
{% block body %}{% endblock %}
|
||||
|
||||
<? end_content() ?>
|
73
examples/example.html
Normal file
73
examples/example.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type='text/css'>
|
||||
|
||||
body {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel='stylesheet' type='text/css' href='../full_calendar.css' />
|
||||
<script type='text/javascript' src='../jquery/jquery.js'></script>
|
||||
<script type='text/javascript' src='../jquery/ui.core.js'></script>
|
||||
<script type='text/javascript' src='../jquery/ui.draggable.js'></script>
|
||||
<script type='text/javascript' src='../full_calendar.js'></script>
|
||||
<script type='text/javascript'>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var d = new Date();
|
||||
var y = d.getFullYear();
|
||||
var m = d.getMonth();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
draggable: true,
|
||||
events: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Long Event",
|
||||
start: new Date(y, m, 6),
|
||||
end: new Date(y, m, 11)
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, 2)
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, 9)
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "Meeting",
|
||||
start: new Date(y, m, 20, 9, 0)
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: "Click for Facebook",
|
||||
start: new Date(y, m, 27),
|
||||
end: new Date(y, m, 29),
|
||||
url: "http://facebook.com/"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
54
examples/gcal.html
Normal file
54
examples/gcal.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type='text/css'>
|
||||
|
||||
body {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#loading {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel='stylesheet' type='text/css' href='../full_calendar.css' />
|
||||
<script type='text/javascript' src='../jquery/jquery.js'></script>
|
||||
<script type='text/javascript' src='../full_calendar.js'></script>
|
||||
<script type='text/javascript' src='../gcal.js'></script>
|
||||
<script type='text/javascript'>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').gcalFullCalendar({
|
||||
// US Holidays
|
||||
events: 'http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic',
|
||||
eventClick: function(event) {
|
||||
window.open(event.url, 'gcalevent', 'width=700,height=600');
|
||||
return false;
|
||||
},
|
||||
loading: function(bool) {
|
||||
if (bool) $('#loading').show();
|
||||
else $('#loading').hide();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='loading' style='display:none'>loading...</div>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
41
examples/json.html
Normal file
41
examples/json.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type='text/css'>
|
||||
|
||||
body {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel='stylesheet' type='text/css' href='../full_calendar.css' />
|
||||
<script type='text/javascript' src='../jquery/jquery.js'></script>
|
||||
<script type='text/javascript' src='../jquery/ui.core.js'></script>
|
||||
<script type='text/javascript' src='../jquery/ui.draggable.js'></script>
|
||||
<script type='text/javascript' src='../full_calendar.js'></script>
|
||||
<script type='text/javascript'>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
draggable: true,
|
||||
events: "json_events.php"
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
<p>json_events.php needs to be running in the same directory.</p>
|
||||
</body>
|
||||
</html>
|
25
examples/json_events.php
Normal file
25
examples/json_events.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
$year = date('Y');
|
||||
$month = date('m');
|
||||
|
||||
echo json_encode(array(
|
||||
|
||||
array(
|
||||
'id' => 1,
|
||||
'title' => "Event1",
|
||||
'start' => "$year-$month-10",
|
||||
'url' => "http://yahoo.com/"
|
||||
),
|
||||
|
||||
array(
|
||||
'id' => 2,
|
||||
'title' => "Event2",
|
||||
'start' => "$year-$month-20",
|
||||
'end' => "$year-$month-22",
|
||||
'url' => "http://yahoo.com/"
|
||||
)
|
||||
|
||||
));
|
||||
|
||||
?>
|
135
full_calendar.css
Normal file
135
full_calendar.css
Normal file
|
@ -0,0 +1,135 @@
|
|||
|
||||
/* top area w/ month title and buttons */
|
||||
|
||||
.full-calendar-header {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.full-calendar-buttons {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.full-calendar-buttons input {
|
||||
vertical-align: middle;
|
||||
font-size: 1.0em;
|
||||
}
|
||||
|
||||
.full-calendar-prev,
|
||||
.full-calendar-next {
|
||||
width: 40px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* borders */
|
||||
|
||||
.full-calendar-month {
|
||||
clear: both;
|
||||
overflow: hidden; /*
|
||||
^ prevents draggable events from leaving.
|
||||
reason for our long-winded border css.
|
||||
borders now look consistent across doctypes. */
|
||||
border: 1px solid #ccc; /* border color & style */
|
||||
}
|
||||
|
||||
.full-calendar-month table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.full-calendar-month th.day-heading,
|
||||
.full-calendar-month td.day {
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
border-style: solid; /* border style */
|
||||
border-color: #ccc; /* border color */
|
||||
border-width: 1px 0 0 1px;
|
||||
}
|
||||
|
||||
.full-calendar-month tr.day-headings th {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.full-calendar-month th.sun,
|
||||
.full-calendar-month td.sun {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* day styling */
|
||||
|
||||
.full-calendar-month td.today {
|
||||
background: #FFFFCC;
|
||||
}
|
||||
|
||||
.full-calendar-month .day-number {
|
||||
text-align: right;
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.full-calendar-month .other-month .day-number {
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.full-calendar-month .day-content {
|
||||
padding: 2px 2px 0; /* distance between events and day edges */
|
||||
}
|
||||
|
||||
.full-calendar-month td.day {
|
||||
/* FullCalendar automatically chooses a height, but this can be overridden: */
|
||||
/* height: 100px !important; */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* event styling */
|
||||
|
||||
.full-calendar-month .event {
|
||||
margin-bottom: 2px;
|
||||
font-size: .85em;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.full-calendar-month .ui-draggable-dragging td {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.full-calendar-month .event td {
|
||||
background: #C1D9EC;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.full-calendar-month .event td.ne,
|
||||
.full-calendar-month .event td.nw,
|
||||
.full-calendar-month .event td.se,
|
||||
.full-calendar-month .event td.sw {
|
||||
background: none;
|
||||
width: 1px; /* <-- remove if you dont want "rounded" corners */
|
||||
height: 1px; /* <-- */
|
||||
}
|
||||
|
||||
.full-calendar-month .nobg td {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.full-calendar-month .event td.c {
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.full-calendar-month .event-time {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* the rectangle that covers a day when dragging an event */
|
||||
|
||||
.full-calendar-month .over-day {
|
||||
background: #ADDBFF;
|
||||
opacity: .2;
|
||||
filter: alpha(opacity=20);
|
||||
}
|
||||
|
726
full_calendar.js
Normal file
726
full_calendar.js
Normal file
|
@ -0,0 +1,726 @@
|
|||
/*
|
||||
* Version:
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.fn.fullCalendar = function(options) {
|
||||
|
||||
if (typeof options == 'string') {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
this.each(function() {
|
||||
$.data(this, 'fullCalendar')[options].apply(this, args);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
var showTime = typeof options.showTime == 'undefined' ? 'guess' : options.showTime;
|
||||
var startParam = options.startParam || 'start';
|
||||
var endParam = options.endParam || 'end';
|
||||
var bo = options.buttons;
|
||||
|
||||
this.each(function() {
|
||||
|
||||
|
||||
|
||||
var date = options.year ? new Date(options.year, options.month || 0, 1) : new Date();
|
||||
var start, end, today, numWeeks;
|
||||
var events = $.isArray(options.events) ? cleanEvents(options.events) : null;
|
||||
var ignoreResizes = false;
|
||||
|
||||
function updateMonth() {
|
||||
clearEvents();
|
||||
render();
|
||||
}
|
||||
|
||||
function today() {
|
||||
date = new Date();
|
||||
updateMonth();
|
||||
}
|
||||
|
||||
function prevMonth() {
|
||||
addMonths(date, -1);
|
||||
updateMonth();
|
||||
}
|
||||
|
||||
function nextMonth() {
|
||||
addMonths(date, 1);
|
||||
updateMonth();
|
||||
}
|
||||
|
||||
function gotoMonth(year, month) {
|
||||
date = new Date(year, month, 1);
|
||||
updateMonth();
|
||||
}
|
||||
|
||||
$.data(this, 'fullCalendar', {
|
||||
today:today, prevMonth:prevMonth, nextMonth:nextMonth, gotoMonth:gotoMonth
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var titleElement, todayButton, monthElement;
|
||||
var header = $("<div class='full-calendar-header'/>").appendTo(this);
|
||||
|
||||
if (bo != false) {
|
||||
var buttons = $("<div class='full-calendar-buttons'/>").appendTo(header);
|
||||
todayButton =
|
||||
$("<input type='button' class='full-calendar-today' value='today'/>")
|
||||
.click(today);
|
||||
var prevButton =
|
||||
$("<input type='button' class='full-calendar-prev' value='<'/>")
|
||||
.click(prevMonth);
|
||||
var nextButton =
|
||||
$("<input type='button' class='full-calendar-next' value='>'/>")
|
||||
.click(nextMonth);
|
||||
if (typeof bo == 'object') {
|
||||
if (bo.today != false) {
|
||||
if (typeof bo.today == 'string') todayButton.val(bo.today);
|
||||
buttons.append(todayButton);
|
||||
}
|
||||
if (bo.prev != false) {
|
||||
if (typeof bo.prev == 'string') prevButton.val(bo.prev);
|
||||
buttons.append(prevButton);
|
||||
}
|
||||
if (bo.next != false) {
|
||||
if (typeof bo.next == 'string') nextButton.val(bo.next);
|
||||
buttons.append(nextButton);
|
||||
}
|
||||
}else{
|
||||
buttons
|
||||
.append(todayButton)
|
||||
.append(prevButton)
|
||||
.append(nextButton);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title !== false)
|
||||
titleElement = $("<h2 class='full-calendar-title'/>").appendTo(header);
|
||||
|
||||
monthElement = $("<div class='full-calendar-month' style='position:relative'/>").appendTo(this);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var tbody, glass, monthTitle;
|
||||
|
||||
function render() {
|
||||
|
||||
ignoreResizes = true;
|
||||
date.setDate(1);
|
||||
clearTime(date);
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth();
|
||||
monthTitle = monthNames[month] + ' ' + year;
|
||||
if (titleElement) titleElement.text(monthTitle);
|
||||
|
||||
clearTime(date);
|
||||
start = cloneDate(date);
|
||||
addDays(start, -start.getDay());
|
||||
end = cloneDate(date);
|
||||
addMonths(end, 1);
|
||||
addDays(end, (7 - end.getDay()) % 7);
|
||||
numWeeks = Math.round((end.getTime() - start.getTime()) / 604800000);
|
||||
if (options.fixedWeeks != false) {
|
||||
addDays(end, (6 - numWeeks) * 7);
|
||||
numWeeks = 6;
|
||||
}
|
||||
|
||||
today = clearTime(new Date());
|
||||
if (todayButton) {
|
||||
if (today.getFullYear() == year && today.getMonth() == month) {
|
||||
todayButton.css('visibility', 'hidden');
|
||||
}else{
|
||||
todayButton.css('visibility', 'visible');
|
||||
}
|
||||
}
|
||||
|
||||
if (!tbody) {
|
||||
|
||||
tbody = "<tbody><tr class='day-headings'>";
|
||||
for (var i=0; i<7; i++) {
|
||||
tbody +=
|
||||
"<th class='day-heading " + dayAbbrevs[i].toLowerCase() + "'>" +
|
||||
(options.abbrevDayHeadings!=false ? dayAbbrevs[i] : dayNames[i]) +
|
||||
"</th>";
|
||||
}
|
||||
var d = cloneDate(start);
|
||||
for (var i=0; i<numWeeks; i++) {
|
||||
tbody += "<tr class='week"+(i+1)+"'>";
|
||||
for (var j=0; j<7; j++) {
|
||||
tbody +=
|
||||
"<td class='day " + dayAbbrevs[j].toLowerCase() +
|
||||
(d.getMonth() == month ? '' : ' other-month') +
|
||||
(d.getTime() == today.getTime() ? ' today' : '') +
|
||||
"'><div class='day-number'>" + d.getDate() + "</div>" +
|
||||
"<div class='day-content'><div/></div></td>";
|
||||
addDays(d, 1);
|
||||
}
|
||||
tbody += "</tr>";
|
||||
}
|
||||
tbody += "</tr></tbody>";
|
||||
tbody = $(tbody)
|
||||
.appendTo($("<table style='width:100%'/>")
|
||||
.appendTo(monthElement));
|
||||
|
||||
glass = $("<div style='position:absolute;top:0;left:0;z-index:1;width:100%' />")
|
||||
.appendTo(monthElement)
|
||||
.click(function(ev, ui) {
|
||||
if (options.dayClick) {
|
||||
buildDayGrid();
|
||||
var td = dayTD(ev.pageX, ev.pageY);
|
||||
if (td) return options.dayClick.call(td, dayDate(td));
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
|
||||
var diff = numWeeks - (tbody.find('tr').length - 1);
|
||||
if (diff < 0) {
|
||||
tbody.find('tr:gt(' + numWeeks + ')').remove();
|
||||
}
|
||||
else if (diff > 0) {
|
||||
var trs = "";
|
||||
for (var i=0; i<diff; i++) {
|
||||
trs += "<tr class='week"+(numWeeks+i)+"'>";
|
||||
for (var j=0; j<7; j++) {
|
||||
trs +=
|
||||
"<td class='day " + dayAbbrevs[j].toLowerCase() + "'>" +
|
||||
"<div class='day-number'></div>" +
|
||||
"<div class='day-content'><div/></div>" +
|
||||
"</td>";
|
||||
}
|
||||
trs += "</tr>";
|
||||
}
|
||||
if (trs) tbody.append(trs);
|
||||
}
|
||||
|
||||
var d = cloneDate(start);
|
||||
tbody.find('td').each(function() {
|
||||
if (d.getMonth() == month) {
|
||||
$(this).removeClass('other-month');
|
||||
}else{
|
||||
$(this).addClass('other-month');
|
||||
}
|
||||
if (d.getTime() == today.getTime()) {
|
||||
$(this).addClass('today');
|
||||
}else{
|
||||
$(this).removeClass('today');
|
||||
}
|
||||
$(this.childNodes[0]).text(d.getDate());
|
||||
addDays(d, 1);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
resizeTable();
|
||||
|
||||
if (typeof options.events == 'string') {
|
||||
if (options.loading) options.loading(true);
|
||||
var jsonOptions = {};
|
||||
jsonOptions[startParam] = Math.round(start.getTime() / 1000);
|
||||
jsonOptions[endParam] = Math.round(end.getTime() / 1000);
|
||||
$.getJSON(options.events, jsonOptions, function(data) {
|
||||
events = cleanEvents(data);
|
||||
renderEvents(events);
|
||||
if (options.loading) options.loading(false);
|
||||
});
|
||||
}
|
||||
else if ($.isFunction(options.events)) {
|
||||
if (options.loading) options.loading(true);
|
||||
options.events(start, end,
|
||||
function(data) {
|
||||
events = cleanEvents(data);
|
||||
renderEvents(events);
|
||||
if (options.loading) options.loading(false);
|
||||
});
|
||||
}
|
||||
else renderEvents(events);
|
||||
|
||||
ignoreResizes = false;
|
||||
|
||||
if (options.monthDisplay)
|
||||
options.monthDisplay(date.getFullYear(), date.getMonth(), monthTitle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var eventMatrix = [];
|
||||
|
||||
function renderEvents() {
|
||||
eventMatrix = [];
|
||||
var i = 0;
|
||||
var ws = cloneDate(start);
|
||||
var we = addDays(cloneDate(ws), 7);
|
||||
while (ws.getTime() < end.getTime()) {
|
||||
var segs = [];
|
||||
$.each(events, function(j, event) {
|
||||
if (event.end.getTime() > ws.getTime() && event.start.getTime() < we.getTime()) {
|
||||
var ss, se, isStart, isEnd;
|
||||
if (event.start.getTime() < ws.getTime()) {
|
||||
ss = cloneDate(ws);
|
||||
isStart = false;
|
||||
}else{
|
||||
ss = cloneDate(event.start);
|
||||
isStart = true;
|
||||
}
|
||||
if (event.end.getTime() > we.getTime()) {
|
||||
se = cloneDate(we);
|
||||
isEnd = false;
|
||||
}else{
|
||||
se = cloneDate(event.end);
|
||||
isEnd = true;
|
||||
}
|
||||
ss = clearTime(ss);
|
||||
se = clearTime((se.getHours()==0 && se.getMinutes()==0) ? se : addDays(se, 1));
|
||||
segs.push({
|
||||
event: event, start: ss, end: se,
|
||||
isStart: isStart, isEnd: isEnd, msLength: se - ss
|
||||
});
|
||||
}
|
||||
});
|
||||
segs.sort(function(a, b) { return b.msLength - a.msLength; });
|
||||
var levels = [];
|
||||
$.each(segs, function(j, seg) {
|
||||
var l = 0; // level index
|
||||
while (true) {
|
||||
var collide = false;
|
||||
if (levels[l]) {
|
||||
for (var k=0; k<levels[l].length; k++) {
|
||||
if (seg.end.getTime() > levels[l][k].start.getTime() &&
|
||||
seg.start.getTime() < levels[l][k].end.getTime()) {
|
||||
collide = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (collide) {
|
||||
l++;
|
||||
continue;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (levels[l]) levels[l].push(seg);
|
||||
else levels[l] = [seg];
|
||||
});
|
||||
eventMatrix[i] = levels;
|
||||
addDays(ws, 7);
|
||||
addDays(we, 7);
|
||||
i++;
|
||||
}
|
||||
_renderEvents();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var eventElements = []; // [[event, element], ...]
|
||||
|
||||
function _renderEvents() {
|
||||
for (var i=0; i<eventMatrix.length; i++) {
|
||||
var levels = eventMatrix[i];
|
||||
var tr = tbody.find('tr:eq('+(i+1)+')');
|
||||
var innerDiv = tr.find('td:first div.day-content div');
|
||||
var top = innerDiv.position().top;
|
||||
var height = 0;
|
||||
for (var j=0; j<levels.length; j++) {
|
||||
var segs = levels[j];
|
||||
var maxh = 0;
|
||||
for (var k=0; k<segs.length; k++) {
|
||||
var seg = segs[k];
|
||||
var event = seg.event;
|
||||
var left1 = seg.isStart ?
|
||||
tr.find('td:eq('+seg.start.getDay()+') div.day-content div').position().left :
|
||||
tbody.position().left;
|
||||
var left2 = seg.isEnd ?
|
||||
tr.find('td:eq('+((seg.end.getDay()+6)%7)+') div.day-content div') :
|
||||
tbody;
|
||||
left2 = left2.position().left + left2.width();
|
||||
var element = $("<table class='event' />")
|
||||
.append("<tr>" +
|
||||
(seg.isStart ? "<td class='nw'/>" : '') +
|
||||
"<td class='n'/>" +
|
||||
(seg.isEnd ? "<td class='ne'/>" : '') + "</tr>")
|
||||
.append("<tr>" +
|
||||
(seg.isStart ? "<td class='w'/>" : '') +
|
||||
"<td class='c'/>" +
|
||||
(seg.isEnd ? "<td class='e'/>" : '') + "</tr>")
|
||||
.append("<tr>" +
|
||||
(seg.isStart ? "<td class='sw'/>" : '') +
|
||||
"<td class='s'/>" +
|
||||
(seg.isEnd ? "<td class='se'/>" : '') + "</tr>");
|
||||
buildEventText(element.find('td.c'), event,
|
||||
typeof event.showTime == 'undefined' ? showTime : event.showTime);
|
||||
if (options.eventRender) {
|
||||
var res = options.eventRender(event, element);
|
||||
if (typeof res != 'undefined') {
|
||||
if (res === false) continue;
|
||||
if (res !== true) element = $(res);
|
||||
}
|
||||
}
|
||||
element
|
||||
.css({
|
||||
position: 'absolute',
|
||||
top: top,
|
||||
left: left1,
|
||||
width: left2 - left1,
|
||||
'z-index': 3
|
||||
})
|
||||
.appendTo(monthElement);
|
||||
initEventElement(event, element);
|
||||
var h = element.outerHeight({margin:true});
|
||||
if (h > maxh) maxh = h;
|
||||
}
|
||||
height += maxh;
|
||||
top += maxh;
|
||||
}
|
||||
innerDiv.height(height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function initEventElement(event, element) {
|
||||
element.click(function(ev) {
|
||||
if (!element.hasClass('ui-draggable-dragging')) {
|
||||
if (options.eventClick) {
|
||||
var res = options.eventClick.call(this, event, ev);
|
||||
if (res === false) return false;
|
||||
}
|
||||
if (event.url) window.location.href = event.url;
|
||||
}
|
||||
});
|
||||
if (options.eventMouseover)
|
||||
element.mouseover(function(ev) {
|
||||
options.eventMouseover.call(this, event, ev);
|
||||
});
|
||||
if (options.eventMouseout)
|
||||
element.mouseout(function(ev) {
|
||||
options.eventMouseout.call(this, event, ev);
|
||||
});
|
||||
if (typeof event.draggable != 'undefined') {
|
||||
if (event.draggable)
|
||||
draggableEvent(event, element);
|
||||
}
|
||||
else if (options.draggable) {
|
||||
draggableEvent(event, element);
|
||||
}
|
||||
eventElements.push([event, element]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var dragStartTD, dragTD;
|
||||
var dayOverlay;
|
||||
|
||||
function draggableEvent(event, element) {
|
||||
element.draggable({
|
||||
zIndex: 3,
|
||||
delay: 50,
|
||||
opacity: options.eventDragOpacity,
|
||||
revertDuration: options.eventRevertDuration,
|
||||
start: function(ev, ui) {
|
||||
// hide other elements with same event
|
||||
for (var i=0; i<eventElements.length; i++) {
|
||||
var x = eventElements[i];
|
||||
var xevent = x[0];
|
||||
if (x[1].get(0) != this && (xevent == event ||
|
||||
typeof xevent.id != 'undefined' && xevent.id == event.id))
|
||||
x[1].hide();
|
||||
}
|
||||
if (!dayOverlay)
|
||||
dayOverlay =
|
||||
$("<div class='over-day' style='position:absolute;z-index:2' />")
|
||||
.appendTo(monthElement);
|
||||
buildDayGrid();
|
||||
dragTD = dragStartTD = null;
|
||||
eventDrag(this, ev, ui);
|
||||
if (options.eventDragStart)
|
||||
options.eventDragStart.call(this, event, ev, ui);
|
||||
},
|
||||
drag: function(ev, ui) {
|
||||
eventDrag(this, ev, ui);
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
if (!dragTD || dragTD == dragStartTD) {
|
||||
// show all events
|
||||
for (var i=0; i<eventElements.length; i++)
|
||||
eventElements[i][1].show();
|
||||
}else{
|
||||
var delta = dayDelta(dragStartTD, dragTD);
|
||||
for (var i=0; i<events.length; i++) {
|
||||
if (event == events[i] || typeof event.id != 'undefined' && event.id == events[i].id) {
|
||||
addDays(events[i].start, delta, true);
|
||||
addDays(events[i].end, delta, true);
|
||||
}
|
||||
}
|
||||
if (options.eventDrop)
|
||||
options.eventDrop.call(this, event, delta, ev, ui);
|
||||
clearEvents();
|
||||
renderEvents();
|
||||
}
|
||||
dayOverlay.hide();
|
||||
if (options.eventDragStop)
|
||||
options.eventDragStop.call(this, event, ev, ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function eventDrag(node, ev, ui) {
|
||||
var oldTD = dragTD;
|
||||
dragTD = dayTD(ev.pageX, ev.pageY);
|
||||
if (!dragStartTD) dragStartTD = dragTD;
|
||||
if (dragTD != oldTD) {
|
||||
if (dragTD) {
|
||||
$(node).draggable('option', 'revert', dragTD==dragStartTD);
|
||||
dayOverlay.css({
|
||||
top: currTDY,
|
||||
left: currTDX,
|
||||
width: currTDW,
|
||||
height: currTDH,
|
||||
display: 'block'
|
||||
});
|
||||
}else{
|
||||
$(node).draggable('option', 'revert', true);
|
||||
dayOverlay.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var dayX, dayY, dayX0, dayY0;
|
||||
var currTD, currR, currC;
|
||||
var currTDX, currTDY, currTDW, currTDH;
|
||||
|
||||
function buildDayGrid() {
|
||||
var tr, td, o=monthElement.offset();
|
||||
dayX0 = o.left;
|
||||
dayY0 = o.top;
|
||||
dayY = [];
|
||||
tbody.find('tr:gt(0)').each(function() {
|
||||
tr = $(this);
|
||||
dayY.push(tr.position().top);
|
||||
});
|
||||
dayY.push(dayY[dayY.length-1] + tr.height());
|
||||
dayX = [];
|
||||
tr.find('td').each(function() {
|
||||
td = $(this);
|
||||
dayX.push(td.position().left);
|
||||
});
|
||||
dayX.push(dayX[dayX.length-1] + td.width());
|
||||
currTD = null;
|
||||
}
|
||||
|
||||
function dayTD(x, y) {
|
||||
var r=-1, c=-1;
|
||||
var rmax=dayY.length-1, cmax=dayX.length-1;
|
||||
while (r < rmax && y > dayY0 + dayY[r+1]) r++;
|
||||
while (c < cmax && x > dayX0 + dayX[c+1]) c++;
|
||||
if (r < 0 || r >= rmax || c < 0 || c >= cmax)
|
||||
return currTD = null;
|
||||
else if (!currTD || r != currR || c != currC) {
|
||||
currR = r;
|
||||
currC = c;
|
||||
currTD = tbody.find('tr:eq('+(r+1)+') td:eq('+c+')').get(0);
|
||||
currTDX = dayX[c];
|
||||
currTDY = dayY[r];
|
||||
currTDW = dayX[c+1] - currTDX;
|
||||
currTDH = dayY[r+1] - currTDY;
|
||||
return currTD;
|
||||
}
|
||||
return currTD;
|
||||
}
|
||||
|
||||
function dayDate(node) {
|
||||
var i, tds = tbody.get(0).getElementsByTagName('td');
|
||||
for (i=0; i<tds.length; i++) {
|
||||
if (tds[i] == node) break;
|
||||
}
|
||||
var d = cloneDate(start);
|
||||
return addDays(d, i);
|
||||
}
|
||||
|
||||
function dayDelta(node1, node2) {
|
||||
var i1, i2, tds = tbody.get(0).getElementsByTagName('td');
|
||||
for (var i=0; i<tds.length; i++) {
|
||||
if (tds[i] == node1) i1 = i;
|
||||
if (tds[i] == node2) i2 = i;
|
||||
}
|
||||
return i2 - i1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function resizeTable() {
|
||||
var cellw = Math.floor(tbody.width() / 7);
|
||||
var cellh = Math.round(cellw * .85);
|
||||
tbody.find('th:lt(6)').width(cellw);
|
||||
tbody.find('td').height(cellh);
|
||||
glass.height(monthElement.height());
|
||||
}
|
||||
|
||||
function clearEvents() {
|
||||
for (var i=0; i<eventElements.length; i++)
|
||||
eventElements[i][1].remove();
|
||||
eventElements = [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$(window).resize(function() {
|
||||
if (!ignoreResizes) {
|
||||
clearEvents();
|
||||
resizeTable();
|
||||
_renderEvents();
|
||||
}
|
||||
});
|
||||
|
||||
render();
|
||||
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// event utils
|
||||
|
||||
function buildEventText(element, event, showTime) {
|
||||
if (showTime != false) {
|
||||
var h = event.start.getHours();
|
||||
var m = event.start.getMinutes();
|
||||
if (showTime == true || showTime == 'guess' &&
|
||||
(h || m || event.end.getHours() || event.end.getMinutes())) {
|
||||
element.append($("<span class='event-time' />")
|
||||
.text((h%12 || 12) + (h<12 ? 'a' : 'p') + ' '));
|
||||
}
|
||||
}
|
||||
element.append($("<span class='event-title' />")
|
||||
.text(event.title));
|
||||
}
|
||||
|
||||
|
||||
function cleanEvents(events) {
|
||||
$.each(events, function(i, event) {
|
||||
if (event.date) event.start = event.date;
|
||||
event.start = cleanDate(event.start);
|
||||
event.end = cleanDate(event.end);
|
||||
if (!event.end) event.end = addDays(cloneDate(event.start), 1);
|
||||
});
|
||||
return events;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// date utils
|
||||
|
||||
var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
||||
var dayNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
|
||||
var dayAbbrevs = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
||||
|
||||
function addMonths(d, n, keepTime) {
|
||||
d.setMonth(d.getMonth() + n);
|
||||
if (keepTime) return d;
|
||||
return clearTime(d);
|
||||
}
|
||||
|
||||
function addDays(d, n, keepTime) {
|
||||
d.setDate(d.getDate() + n);
|
||||
if (keepTime) return d;
|
||||
return clearTime(d);
|
||||
}
|
||||
|
||||
function clearTime(d) {
|
||||
d.setHours(0);
|
||||
d.setMinutes(0);
|
||||
d.setSeconds(0);
|
||||
d.setMilliseconds(0);
|
||||
return d;
|
||||
}
|
||||
|
||||
function cloneDate(d) {
|
||||
return new Date(+d);
|
||||
}
|
||||
|
||||
function cleanDate(d) {
|
||||
if (typeof d == 'string')
|
||||
return $.parseISO8601(d, true) || Date.parse(d) || new Date(parseInt(d));
|
||||
if (typeof d == 'number')
|
||||
return new Date(d * 1000);
|
||||
return d;
|
||||
}
|
||||
|
||||
$.parseISO8601 = function(s, ignoreTimezone) {
|
||||
// derived from http://delete.me.uk/2005/03/iso8601.html
|
||||
var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
|
||||
"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
|
||||
"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
|
||||
var d = s.match(new RegExp(regexp));
|
||||
if (!d) return null;
|
||||
var offset = 0;
|
||||
var date = new Date(d[1], 0, 1);
|
||||
if (d[3]) { date.setMonth(d[3] - 1); }
|
||||
if (d[5]) { date.setDate(d[5]); }
|
||||
if (d[7]) { date.setHours(d[7]); }
|
||||
if (d[8]) { date.setMinutes(d[8]); }
|
||||
if (d[10]) { date.setSeconds(d[10]); }
|
||||
if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
|
||||
if (!ignoreTimezone) {
|
||||
if (d[14]) {
|
||||
offset = (Number(d[16]) * 60) + Number(d[17]);
|
||||
offset *= ((d[15] == '-') ? 1 : -1);
|
||||
}
|
||||
offset -= date.getTimezoneOffset();
|
||||
}
|
||||
return new Date(Number(date) + (offset * 60 * 1000));
|
||||
};
|
||||
|
||||
$.ISO8601String = function(date) {
|
||||
// derived from http://delete.me.uk/2005/03/iso8601.html
|
||||
var zeropad = function (num) { return ((num < 10) ? '0' : '') + num; }
|
||||
return date.getUTCFullYear() +
|
||||
"-" + zeropad(date.getUTCMonth() + 1) +
|
||||
"-" + zeropad(date.getUTCDate()) +
|
||||
"T" + zeropad(date.getUTCHours()) +
|
||||
":" + zeropad(date.getUTCMinutes()) +
|
||||
":" + zeropad(date.getUTCSeconds()) +
|
||||
"Z";
|
||||
};
|
||||
|
||||
|
||||
|
||||
// general utils
|
||||
|
||||
if (!$.isArray) { // not in jQuery pre 1.3
|
||||
$.isArray = function(obj) {
|
||||
return toString.call(obj) === "[object Array]";
|
||||
};
|
||||
}
|
||||
|
||||
})(jQuery);
|
55
gcal.js
Normal file
55
gcal.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
(function($) {
|
||||
|
||||
$.fn.gcalFullCalendar = function(options) {
|
||||
|
||||
var feedURL;
|
||||
if (options && typeof options.events == 'string') {
|
||||
feedURL = options.events;
|
||||
}
|
||||
else return this;
|
||||
|
||||
feedURL = feedURL.replace(/\/basic$/, '/full');
|
||||
|
||||
$.extend(options, {
|
||||
|
||||
events: function(start, end, callback) {
|
||||
$.getJSON(feedURL + "?alt=json-in-script&callback=?",
|
||||
{
|
||||
'start-min': $.ISO8601String(start),
|
||||
'start-max': $.ISO8601String(end),
|
||||
'singleevents': true
|
||||
},
|
||||
function(data) {
|
||||
var events = [];
|
||||
if (data.feed.entry)
|
||||
$.each(data.feed.entry, function(i, entry) {
|
||||
var url;
|
||||
$.each(entry['link'], function(j, link) {
|
||||
if (link.type == 'text/html') url = link.href;
|
||||
});
|
||||
events.push({
|
||||
id: entry['gCal$uid']['value'],
|
||||
url: url,
|
||||
title: entry['title']['$t'],
|
||||
start: $.parseISO8601(entry['gd$when'][0]['startTime'], true),
|
||||
end: $.parseISO8601(entry['gd$when'][0]['endTime'], true),
|
||||
location: entry['gd$where'][0]['valueString'],
|
||||
description: entry['content']['$t'],
|
||||
allDay: entry['gd$when'][0]['startTime'].indexOf('T') == -1,
|
||||
draggable: false
|
||||
});
|
||||
});
|
||||
callback(events);
|
||||
});
|
||||
},
|
||||
|
||||
eventRender: function(event, element) {
|
||||
if (!event.allDay) element.addClass('nobg');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return this.fullCalendar(options);
|
||||
};
|
||||
|
||||
})(jQuery);
|
4376
jquery/jquery.js
vendored
Normal file
4376
jquery/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
519
jquery/ui.core.js
Normal file
519
jquery/ui.core.js
Normal file
|
@ -0,0 +1,519 @@
|
|||
/*
|
||||
* jQuery UI 1.7
|
||||
*
|
||||
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* and GPL (GPL-LICENSE.txt) licenses.
|
||||
*
|
||||
* http://docs.jquery.com/UI
|
||||
*/
|
||||
;jQuery.ui || (function($) {
|
||||
|
||||
var _remove = $.fn.remove,
|
||||
isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
|
||||
|
||||
//Helper functions and ui object
|
||||
$.ui = {
|
||||
version: "1.7",
|
||||
|
||||
// $.ui.plugin is deprecated. Use the proxy pattern instead.
|
||||
plugin: {
|
||||
add: function(module, option, set) {
|
||||
var proto = $.ui[module].prototype;
|
||||
for(var i in set) {
|
||||
proto.plugins[i] = proto.plugins[i] || [];
|
||||
proto.plugins[i].push([option, set[i]]);
|
||||
}
|
||||
},
|
||||
call: function(instance, name, args) {
|
||||
var set = instance.plugins[name];
|
||||
if(!set || !instance.element[0].parentNode) { return; }
|
||||
|
||||
for (var i = 0; i < set.length; i++) {
|
||||
if (instance.options[set[i][0]]) {
|
||||
set[i][1].apply(instance.element, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
contains: function(a, b) {
|
||||
return document.compareDocumentPosition
|
||||
? a.compareDocumentPosition(b) & 16
|
||||
: a !== b && a.contains(b);
|
||||
},
|
||||
|
||||
hasScroll: function(el, a) {
|
||||
|
||||
//If overflow is hidden, the element might have extra content, but the user wants to hide it
|
||||
if ($(el).css('overflow') == 'hidden') { return false; }
|
||||
|
||||
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
|
||||
has = false;
|
||||
|
||||
if (el[scroll] > 0) { return true; }
|
||||
|
||||
// TODO: determine which cases actually cause this to happen
|
||||
// if the element doesn't have the scroll set, see if it's possible to
|
||||
// set the scroll
|
||||
el[scroll] = 1;
|
||||
has = (el[scroll] > 0);
|
||||
el[scroll] = 0;
|
||||
return has;
|
||||
},
|
||||
|
||||
isOverAxis: function(x, reference, size) {
|
||||
//Determines when x coordinate is over "b" element axis
|
||||
return (x > reference) && (x < (reference + size));
|
||||
},
|
||||
|
||||
isOver: function(y, x, top, left, height, width) {
|
||||
//Determines when x, y coordinates is over "b" element
|
||||
return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
|
||||
},
|
||||
|
||||
keyCode: {
|
||||
BACKSPACE: 8,
|
||||
CAPS_LOCK: 20,
|
||||
COMMA: 188,
|
||||
CONTROL: 17,
|
||||
DELETE: 46,
|
||||
DOWN: 40,
|
||||
END: 35,
|
||||
ENTER: 13,
|
||||
ESCAPE: 27,
|
||||
HOME: 36,
|
||||
INSERT: 45,
|
||||
LEFT: 37,
|
||||
NUMPAD_ADD: 107,
|
||||
NUMPAD_DECIMAL: 110,
|
||||
NUMPAD_DIVIDE: 111,
|
||||
NUMPAD_ENTER: 108,
|
||||
NUMPAD_MULTIPLY: 106,
|
||||
NUMPAD_SUBTRACT: 109,
|
||||
PAGE_DOWN: 34,
|
||||
PAGE_UP: 33,
|
||||
PERIOD: 190,
|
||||
RIGHT: 39,
|
||||
SHIFT: 16,
|
||||
SPACE: 32,
|
||||
TAB: 9,
|
||||
UP: 38
|
||||
}
|
||||
};
|
||||
|
||||
// WAI-ARIA normalization
|
||||
if (isFF2) {
|
||||
var attr = $.attr,
|
||||
removeAttr = $.fn.removeAttr,
|
||||
ariaNS = "http://www.w3.org/2005/07/aaa",
|
||||
ariaState = /^aria-/,
|
||||
ariaRole = /^wairole:/;
|
||||
|
||||
$.attr = function(elem, name, value) {
|
||||
var set = value !== undefined;
|
||||
|
||||
return (name == 'role'
|
||||
? (set
|
||||
? attr.call(this, elem, name, "wairole:" + value)
|
||||
: (attr.apply(this, arguments) || "").replace(ariaRole, ""))
|
||||
: (ariaState.test(name)
|
||||
? (set
|
||||
? elem.setAttributeNS(ariaNS,
|
||||
name.replace(ariaState, "aaa:"), value)
|
||||
: attr.call(this, elem, name.replace(ariaState, "aaa:")))
|
||||
: attr.apply(this, arguments)));
|
||||
};
|
||||
|
||||
$.fn.removeAttr = function(name) {
|
||||
return (ariaState.test(name)
|
||||
? this.each(function() {
|
||||
this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
|
||||
}) : removeAttr.call(this, name));
|
||||
};
|
||||
}
|
||||
|
||||
//jQuery plugins
|
||||
$.fn.extend({
|
||||
remove: function() {
|
||||
// Safari has a native remove event which actually removes DOM elements,
|
||||
// so we have to use triggerHandler instead of trigger (#3037).
|
||||
$("*", this).add(this).each(function() {
|
||||
$(this).triggerHandler("remove");
|
||||
});
|
||||
return _remove.apply(this, arguments );
|
||||
},
|
||||
|
||||
enableSelection: function() {
|
||||
return this
|
||||
.attr('unselectable', 'off')
|
||||
.css('MozUserSelect', '')
|
||||
.unbind('selectstart.ui');
|
||||
},
|
||||
|
||||
disableSelection: function() {
|
||||
return this
|
||||
.attr('unselectable', 'on')
|
||||
.css('MozUserSelect', 'none')
|
||||
.bind('selectstart.ui', function() { return false; });
|
||||
},
|
||||
|
||||
scrollParent: function() {
|
||||
var scrollParent;
|
||||
if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
|
||||
scrollParent = this.parents().filter(function() {
|
||||
return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
||||
}).eq(0);
|
||||
} else {
|
||||
scrollParent = this.parents().filter(function() {
|
||||
return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
||||
}).eq(0);
|
||||
}
|
||||
|
||||
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Additional selectors
|
||||
$.extend($.expr[':'], {
|
||||
data: function(elem, i, match) {
|
||||
return !!$.data(elem, match[3]);
|
||||
},
|
||||
|
||||
focusable: function(element) {
|
||||
var nodeName = element.nodeName.toLowerCase(),
|
||||
tabIndex = $.attr(element, 'tabindex');
|
||||
return (/input|select|textarea|button|object/.test(nodeName)
|
||||
? !element.disabled
|
||||
: 'a' == nodeName || 'area' == nodeName
|
||||
? element.href || !isNaN(tabIndex)
|
||||
: !isNaN(tabIndex))
|
||||
// the element and all of its ancestors must be visible
|
||||
// the browser may report that the area is hidden
|
||||
&& !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
|
||||
},
|
||||
|
||||
tabbable: function(element) {
|
||||
var tabIndex = $.attr(element, 'tabindex');
|
||||
return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// $.widget is a factory to create jQuery plugins
|
||||
// taking some boilerplate code out of the plugin code
|
||||
function getter(namespace, plugin, method, args) {
|
||||
function getMethods(type) {
|
||||
var methods = $[namespace][plugin][type] || [];
|
||||
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
|
||||
}
|
||||
|
||||
var methods = getMethods('getter');
|
||||
if (args.length == 1 && typeof args[0] == 'string') {
|
||||
methods = methods.concat(getMethods('getterSetter'));
|
||||
}
|
||||
return ($.inArray(method, methods) != -1);
|
||||
}
|
||||
|
||||
$.widget = function(name, prototype) {
|
||||
var namespace = name.split(".")[0];
|
||||
name = name.split(".")[1];
|
||||
|
||||
// create plugin method
|
||||
$.fn[name] = function(options) {
|
||||
var isMethodCall = (typeof options == 'string'),
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
// prevent calls to internal methods
|
||||
if (isMethodCall && options.substring(0, 1) == '_') {
|
||||
return this;
|
||||
}
|
||||
|
||||
// handle getter methods
|
||||
if (isMethodCall && getter(namespace, name, options, args)) {
|
||||
var instance = $.data(this[0], name);
|
||||
return (instance ? instance[options].apply(instance, args)
|
||||
: undefined);
|
||||
}
|
||||
|
||||
// handle initialization and non-getter methods
|
||||
return this.each(function() {
|
||||
var instance = $.data(this, name);
|
||||
|
||||
// constructor
|
||||
(!instance && !isMethodCall &&
|
||||
$.data(this, name, new $[namespace][name](this, options))._init());
|
||||
|
||||
// method call
|
||||
(instance && isMethodCall && $.isFunction(instance[options]) &&
|
||||
instance[options].apply(instance, args));
|
||||
});
|
||||
};
|
||||
|
||||
// create widget constructor
|
||||
$[namespace] = $[namespace] || {};
|
||||
$[namespace][name] = function(element, options) {
|
||||
var self = this;
|
||||
|
||||
this.namespace = namespace;
|
||||
this.widgetName = name;
|
||||
this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
|
||||
this.widgetBaseClass = namespace + '-' + name;
|
||||
|
||||
this.options = $.extend({},
|
||||
$.widget.defaults,
|
||||
$[namespace][name].defaults,
|
||||
$.metadata && $.metadata.get(element)[name],
|
||||
options);
|
||||
|
||||
this.element = $(element)
|
||||
.bind('setData.' + name, function(event, key, value) {
|
||||
if (event.target == element) {
|
||||
return self._setData(key, value);
|
||||
}
|
||||
})
|
||||
.bind('getData.' + name, function(event, key) {
|
||||
if (event.target == element) {
|
||||
return self._getData(key);
|
||||
}
|
||||
})
|
||||
.bind('remove', function() {
|
||||
return self.destroy();
|
||||
});
|
||||
};
|
||||
|
||||
// add widget prototype
|
||||
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
|
||||
|
||||
// TODO: merge getter and getterSetter properties from widget prototype
|
||||
// and plugin prototype
|
||||
$[namespace][name].getterSetter = 'option';
|
||||
};
|
||||
|
||||
$.widget.prototype = {
|
||||
_init: function() {},
|
||||
destroy: function() {
|
||||
this.element.removeData(this.widgetName)
|
||||
.removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
|
||||
.removeAttr('aria-disabled');
|
||||
},
|
||||
|
||||
option: function(key, value) {
|
||||
var options = key,
|
||||
self = this;
|
||||
|
||||
if (typeof key == "string") {
|
||||
if (value === undefined) {
|
||||
return this._getData(key);
|
||||
}
|
||||
options = {};
|
||||
options[key] = value;
|
||||
}
|
||||
|
||||
$.each(options, function(key, value) {
|
||||
self._setData(key, value);
|
||||
});
|
||||
},
|
||||
_getData: function(key) {
|
||||
return this.options[key];
|
||||
},
|
||||
_setData: function(key, value) {
|
||||
this.options[key] = value;
|
||||
|
||||
if (key == 'disabled') {
|
||||
this.element
|
||||
[value ? 'addClass' : 'removeClass'](
|
||||
this.widgetBaseClass + '-disabled' + ' ' +
|
||||
this.namespace + '-state-disabled')
|
||||
.attr("aria-disabled", value);
|
||||
}
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this._setData('disabled', false);
|
||||
},
|
||||
disable: function() {
|
||||
this._setData('disabled', true);
|
||||
},
|
||||
|
||||
_trigger: function(type, event, data) {
|
||||
var callback = this.options[type],
|
||||
eventName = (type == this.widgetEventPrefix
|
||||
? type : this.widgetEventPrefix + type);
|
||||
|
||||
event = $.Event(event);
|
||||
event.type = eventName;
|
||||
|
||||
// copy original event properties over to the new event
|
||||
// this would happen if we could call $.event.fix instead of $.Event
|
||||
// but we don't have a way to force an event to be fixed multiple times
|
||||
if (event.originalEvent) {
|
||||
for (var i = $.event.props.length, prop; i;) {
|
||||
prop = $.event.props[--i];
|
||||
event[prop] = event.originalEvent[prop];
|
||||
}
|
||||
}
|
||||
|
||||
this.element.trigger(event, data);
|
||||
|
||||
return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
|
||||
|| event.isDefaultPrevented());
|
||||
}
|
||||
};
|
||||
|
||||
$.widget.defaults = {
|
||||
disabled: false
|
||||
};
|
||||
|
||||
|
||||
/** Mouse Interaction Plugin **/
|
||||
|
||||
$.ui.mouse = {
|
||||
_mouseInit: function() {
|
||||
var self = this;
|
||||
|
||||
this.element
|
||||
.bind('mousedown.'+this.widgetName, function(event) {
|
||||
return self._mouseDown(event);
|
||||
})
|
||||
.bind('click.'+this.widgetName, function(event) {
|
||||
if(self._preventClickEvent) {
|
||||
self._preventClickEvent = false;
|
||||
event.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent text selection in IE
|
||||
if ($.browser.msie) {
|
||||
this._mouseUnselectable = this.element.attr('unselectable');
|
||||
this.element.attr('unselectable', 'on');
|
||||
}
|
||||
|
||||
this.started = false;
|
||||
},
|
||||
|
||||
// TODO: make sure destroying one instance of mouse doesn't mess with
|
||||
// other instances of mouse
|
||||
_mouseDestroy: function() {
|
||||
this.element.unbind('.'+this.widgetName);
|
||||
|
||||
// Restore text selection in IE
|
||||
($.browser.msie
|
||||
&& this.element.attr('unselectable', this._mouseUnselectable));
|
||||
},
|
||||
|
||||
_mouseDown: function(event) {
|
||||
// don't let more than one widget handle mouseStart
|
||||
// TODO: figure out why we have to use originalEvent
|
||||
event.originalEvent = event.originalEvent || {};
|
||||
if (event.originalEvent.mouseHandled) { return; }
|
||||
|
||||
// we may have missed mouseup (out of window)
|
||||
(this._mouseStarted && this._mouseUp(event));
|
||||
|
||||
this._mouseDownEvent = event;
|
||||
|
||||
var self = this,
|
||||
btnIsLeft = (event.which == 1),
|
||||
elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
|
||||
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.mouseDelayMet = !this.options.delay;
|
||||
if (!this.mouseDelayMet) {
|
||||
this._mouseDelayTimer = setTimeout(function() {
|
||||
self.mouseDelayMet = true;
|
||||
}, this.options.delay);
|
||||
}
|
||||
|
||||
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
||||
this._mouseStarted = (this._mouseStart(event) !== false);
|
||||
if (!this._mouseStarted) {
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// these delegates are required to keep context
|
||||
this._mouseMoveDelegate = function(event) {
|
||||
return self._mouseMove(event);
|
||||
};
|
||||
this._mouseUpDelegate = function(event) {
|
||||
return self._mouseUp(event);
|
||||
};
|
||||
$(document)
|
||||
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
// preventDefault() is used to prevent the selection of text here -
|
||||
// however, in Safari, this causes select boxes not to be selectable
|
||||
// anymore, so this fix is needed
|
||||
($.browser.safari || event.preventDefault());
|
||||
|
||||
event.originalEvent.mouseHandled = true;
|
||||
return true;
|
||||
},
|
||||
|
||||
_mouseMove: function(event) {
|
||||
// IE mouseup check - mouseup happened when mouse was out of window
|
||||
if ($.browser.msie && !event.button) {
|
||||
return this._mouseUp(event);
|
||||
}
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this._mouseDrag(event);
|
||||
return event.preventDefault();
|
||||
}
|
||||
|
||||
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
||||
this._mouseStarted =
|
||||
(this._mouseStart(this._mouseDownEvent, event) !== false);
|
||||
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
|
||||
}
|
||||
|
||||
return !this._mouseStarted;
|
||||
},
|
||||
|
||||
_mouseUp: function(event) {
|
||||
$(document)
|
||||
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this._mouseStarted = false;
|
||||
this._preventClickEvent = (event.target == this._mouseDownEvent.target);
|
||||
this._mouseStop(event);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_mouseDistanceMet: function(event) {
|
||||
return (Math.max(
|
||||
Math.abs(this._mouseDownEvent.pageX - event.pageX),
|
||||
Math.abs(this._mouseDownEvent.pageY - event.pageY)
|
||||
) >= this.options.distance
|
||||
);
|
||||
},
|
||||
|
||||
_mouseDelayMet: function(event) {
|
||||
return this.mouseDelayMet;
|
||||
},
|
||||
|
||||
// These are placeholder methods, to be overriden by extending plugin
|
||||
_mouseStart: function(event) {},
|
||||
_mouseDrag: function(event) {},
|
||||
_mouseStop: function(event) {},
|
||||
_mouseCapture: function(event) { return true; }
|
||||
};
|
||||
|
||||
$.ui.mouse.defaults = {
|
||||
cancel: null,
|
||||
distance: 1,
|
||||
delay: 0
|
||||
};
|
||||
|
||||
})(jQuery);
|
766
jquery/ui.draggable.js
Normal file
766
jquery/ui.draggable.js
Normal file
|
@ -0,0 +1,766 @@
|
|||
/*
|
||||
* jQuery UI Draggable 1.7
|
||||
*
|
||||
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* and GPL (GPL-LICENSE.txt) licenses.
|
||||
*
|
||||
* http://docs.jquery.com/UI/Draggables
|
||||
*
|
||||
* Depends:
|
||||
* ui.core.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
|
||||
|
||||
_init: function() {
|
||||
|
||||
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
|
||||
this.element[0].style.position = 'relative';
|
||||
|
||||
(this.options.addClasses && this.element.addClass("ui-draggable"));
|
||||
(this.options.disabled && this.element.addClass("ui-draggable-disabled"));
|
||||
|
||||
this._mouseInit();
|
||||
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if(!this.element.data('draggable')) return;
|
||||
this.element
|
||||
.removeData("draggable")
|
||||
.unbind(".draggable")
|
||||
.removeClass("ui-draggable"
|
||||
+ " ui-draggable-dragging"
|
||||
+ " ui-draggable-disabled");
|
||||
this._mouseDestroy();
|
||||
},
|
||||
|
||||
_mouseCapture: function(event) {
|
||||
|
||||
var o = this.options;
|
||||
|
||||
if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
|
||||
return false;
|
||||
|
||||
//Quit if we're not on a valid handle
|
||||
this.handle = this._getHandle(event);
|
||||
if (!this.handle)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
_mouseStart: function(event) {
|
||||
|
||||
var o = this.options;
|
||||
|
||||
//Create and append the visible helper
|
||||
this.helper = this._createHelper(event);
|
||||
|
||||
//Cache the helper size
|
||||
this._cacheHelperProportions();
|
||||
|
||||
//If ddmanager is used for droppables, set the global draggable
|
||||
if($.ui.ddmanager)
|
||||
$.ui.ddmanager.current = this;
|
||||
|
||||
/*
|
||||
* - Position generation -
|
||||
* This block generates everything position related - it's the core of draggables.
|
||||
*/
|
||||
|
||||
//Cache the margins of the original element
|
||||
this._cacheMargins();
|
||||
|
||||
//Store the helper's css position
|
||||
this.cssPosition = this.helper.css("position");
|
||||
this.scrollParent = this.helper.scrollParent();
|
||||
|
||||
//The element's absolute position on the page minus margins
|
||||
this.offset = this.element.offset();
|
||||
this.offset = {
|
||||
top: this.offset.top - this.margins.top,
|
||||
left: this.offset.left - this.margins.left
|
||||
};
|
||||
|
||||
$.extend(this.offset, {
|
||||
click: { //Where the click happened, relative to the element
|
||||
left: event.pageX - this.offset.left,
|
||||
top: event.pageY - this.offset.top
|
||||
},
|
||||
parent: this._getParentOffset(),
|
||||
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
|
||||
});
|
||||
|
||||
//Generate the original position
|
||||
this.originalPosition = this._generatePosition(event);
|
||||
this.originalPageX = event.pageX;
|
||||
this.originalPageY = event.pageY;
|
||||
|
||||
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
||||
if(o.cursorAt)
|
||||
this._adjustOffsetFromHelper(o.cursorAt);
|
||||
|
||||
//Set a containment if given in the options
|
||||
if(o.containment)
|
||||
this._setContainment();
|
||||
|
||||
//Call plugins and callbacks
|
||||
this._trigger("start", event);
|
||||
|
||||
//Recache the helper size
|
||||
this._cacheHelperProportions();
|
||||
|
||||
//Prepare the droppable offsets
|
||||
if ($.ui.ddmanager && !o.dropBehaviour)
|
||||
$.ui.ddmanager.prepareOffsets(this, event);
|
||||
|
||||
this.helper.addClass("ui-draggable-dragging");
|
||||
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
|
||||
return true;
|
||||
},
|
||||
|
||||
_mouseDrag: function(event, noPropagation) {
|
||||
|
||||
//Compute the helpers position
|
||||
this.position = this._generatePosition(event);
|
||||
this.positionAbs = this._convertPositionTo("absolute");
|
||||
|
||||
//Call plugins and callbacks and use the resulting position if something is returned
|
||||
if (!noPropagation) {
|
||||
var ui = this._uiHash();
|
||||
this._trigger('drag', event, ui);
|
||||
this.position = ui.position;
|
||||
}
|
||||
|
||||
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
||||
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
||||
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_mouseStop: function(event) {
|
||||
|
||||
//If we are using droppables, inform the manager about the drop
|
||||
var dropped = false;
|
||||
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
||||
dropped = $.ui.ddmanager.drop(this, event);
|
||||
|
||||
//if a drop comes from outside (a sortable)
|
||||
if(this.dropped) {
|
||||
dropped = this.dropped;
|
||||
this.dropped = false;
|
||||
}
|
||||
|
||||
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
|
||||
var self = this;
|
||||
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
|
||||
self._trigger("stop", event);
|
||||
self._clear();
|
||||
});
|
||||
} else {
|
||||
this._trigger("stop", event);
|
||||
this._clear();
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_getHandle: function(event) {
|
||||
|
||||
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
|
||||
$(this.options.handle, this.element)
|
||||
.find("*")
|
||||
.andSelf()
|
||||
.each(function() {
|
||||
if(this == event.target) handle = true;
|
||||
});
|
||||
|
||||
return handle;
|
||||
|
||||
},
|
||||
|
||||
_createHelper: function(event) {
|
||||
|
||||
var o = this.options;
|
||||
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
|
||||
|
||||
if(!helper.parents('body').length)
|
||||
helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
|
||||
|
||||
if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
|
||||
helper.css("position", "absolute");
|
||||
|
||||
return helper;
|
||||
|
||||
},
|
||||
|
||||
_adjustOffsetFromHelper: function(obj) {
|
||||
if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
|
||||
if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
||||
if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
|
||||
if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
||||
},
|
||||
|
||||
_getParentOffset: function() {
|
||||
|
||||
//Get the offsetParent and cache its position
|
||||
this.offsetParent = this.helper.offsetParent();
|
||||
var po = this.offsetParent.offset();
|
||||
|
||||
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
||||
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
||||
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
||||
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
||||
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
|
||||
po.left += this.scrollParent.scrollLeft();
|
||||
po.top += this.scrollParent.scrollTop();
|
||||
}
|
||||
|
||||
if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
|
||||
|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
|
||||
po = { top: 0, left: 0 };
|
||||
|
||||
return {
|
||||
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
|
||||
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
_getRelativeOffset: function() {
|
||||
|
||||
if(this.cssPosition == "relative") {
|
||||
var p = this.element.position();
|
||||
return {
|
||||
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
|
||||
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
|
||||
};
|
||||
} else {
|
||||
return { top: 0, left: 0 };
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_cacheMargins: function() {
|
||||
this.margins = {
|
||||
left: (parseInt(this.element.css("marginLeft"),10) || 0),
|
||||
top: (parseInt(this.element.css("marginTop"),10) || 0)
|
||||
};
|
||||
},
|
||||
|
||||
_cacheHelperProportions: function() {
|
||||
this.helperProportions = {
|
||||
width: this.helper.outerWidth(),
|
||||
height: this.helper.outerHeight()
|
||||
};
|
||||
},
|
||||
|
||||
_setContainment: function() {
|
||||
|
||||
var o = this.options;
|
||||
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
|
||||
if(o.containment == 'document' || o.containment == 'window') this.containment = [
|
||||
0 - this.offset.relative.left - this.offset.parent.left,
|
||||
0 - this.offset.relative.top - this.offset.parent.top,
|
||||
$(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
|
||||
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
||||
];
|
||||
|
||||
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
|
||||
var ce = $(o.containment)[0]; if(!ce) return;
|
||||
var co = $(o.containment).offset();
|
||||
var over = ($(ce).css("overflow") != 'hidden');
|
||||
|
||||
this.containment = [
|
||||
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
||||
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
|
||||
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
|
||||
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
|
||||
];
|
||||
} else if(o.containment.constructor == Array) {
|
||||
this.containment = o.containment;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_convertPositionTo: function(d, pos) {
|
||||
|
||||
if(!pos) pos = this.position;
|
||||
var mod = d == "absolute" ? 1 : -1;
|
||||
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||
|
||||
return {
|
||||
top: (
|
||||
pos.top // The absolute mouse position
|
||||
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
|
||||
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
||||
),
|
||||
left: (
|
||||
pos.left // The absolute mouse position
|
||||
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
|
||||
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
||||
)
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
_generatePosition: function(event) {
|
||||
|
||||
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||
|
||||
// This is another very weird special case that only happens for relative elements:
|
||||
// 1. If the css position is relative
|
||||
// 2. and the scroll parent is the document or similar to the offset parent
|
||||
// we have to refresh the relative offset during the scroll so there are no jumps
|
||||
if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
|
||||
this.offset.relative = this._getRelativeOffset();
|
||||
}
|
||||
|
||||
var pageX = event.pageX;
|
||||
var pageY = event.pageY;
|
||||
|
||||
/*
|
||||
* - Position constraining -
|
||||
* Constrain the position to a mix of grid, containment.
|
||||
*/
|
||||
|
||||
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
|
||||
|
||||
if(this.containment) {
|
||||
if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
|
||||
if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
|
||||
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
|
||||
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
|
||||
}
|
||||
|
||||
if(o.grid) {
|
||||
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
|
||||
pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
|
||||
|
||||
var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
||||
pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
top: (
|
||||
pageY // The absolute mouse position
|
||||
- this.offset.click.top // Click offset (relative to the element)
|
||||
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
|
||||
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
||||
),
|
||||
left: (
|
||||
pageX // The absolute mouse position
|
||||
- this.offset.click.left // Click offset (relative to the element)
|
||||
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
|
||||
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
||||
)
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
_clear: function() {
|
||||
this.helper.removeClass("ui-draggable-dragging");
|
||||
if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
|
||||
//if($.ui.ddmanager) $.ui.ddmanager.current = null;
|
||||
this.helper = null;
|
||||
this.cancelHelperRemoval = false;
|
||||
},
|
||||
|
||||
// From now on bulk stuff - mainly helpers
|
||||
|
||||
_trigger: function(type, event, ui) {
|
||||
ui = ui || this._uiHash();
|
||||
$.ui.plugin.call(this, type, [event, ui]);
|
||||
if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
|
||||
return $.widget.prototype._trigger.call(this, type, event, ui);
|
||||
},
|
||||
|
||||
plugins: {},
|
||||
|
||||
_uiHash: function(event) {
|
||||
return {
|
||||
helper: this.helper,
|
||||
position: this.position,
|
||||
absolutePosition: this.positionAbs, //deprecated
|
||||
offset: this.positionAbs
|
||||
};
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
$.extend($.ui.draggable, {
|
||||
version: "1.7",
|
||||
eventPrefix: "drag",
|
||||
defaults: {
|
||||
addClasses: true,
|
||||
appendTo: "parent",
|
||||
axis: false,
|
||||
cancel: ":input,option",
|
||||
connectToSortable: false,
|
||||
containment: false,
|
||||
cursor: "auto",
|
||||
cursorAt: false,
|
||||
delay: 0,
|
||||
distance: 1,
|
||||
grid: false,
|
||||
handle: false,
|
||||
helper: "original",
|
||||
iframeFix: false,
|
||||
opacity: false,
|
||||
refreshPositions: false,
|
||||
revert: false,
|
||||
revertDuration: 500,
|
||||
scope: "default",
|
||||
scroll: true,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 20,
|
||||
snap: false,
|
||||
snapMode: "both",
|
||||
snapTolerance: 20,
|
||||
stack: false,
|
||||
zIndex: false
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "connectToSortable", {
|
||||
start: function(event, ui) {
|
||||
|
||||
var inst = $(this).data("draggable"), o = inst.options,
|
||||
uiSortable = $.extend({}, ui, { item: inst.element });
|
||||
inst.sortables = [];
|
||||
$(o.connectToSortable).each(function() {
|
||||
var sortable = $.data(this, 'sortable');
|
||||
if (sortable && !sortable.options.disabled) {
|
||||
inst.sortables.push({
|
||||
instance: sortable,
|
||||
shouldRevert: sortable.options.revert
|
||||
});
|
||||
sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
|
||||
sortable._trigger("activate", event, uiSortable);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
|
||||
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
|
||||
var inst = $(this).data("draggable"),
|
||||
uiSortable = $.extend({}, ui, { item: inst.element });
|
||||
|
||||
$.each(inst.sortables, function() {
|
||||
if(this.instance.isOver) {
|
||||
|
||||
this.instance.isOver = 0;
|
||||
|
||||
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
|
||||
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
|
||||
|
||||
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
|
||||
if(this.shouldRevert) this.instance.options.revert = true;
|
||||
|
||||
//Trigger the stop of the sortable
|
||||
this.instance._mouseStop(event);
|
||||
|
||||
this.instance.options.helper = this.instance.options._helper;
|
||||
|
||||
//If the helper has been the original item, restore properties in the sortable
|
||||
if(inst.options.helper == 'original')
|
||||
this.instance.currentItem.css({ top: 'auto', left: 'auto' });
|
||||
|
||||
} else {
|
||||
this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
|
||||
this.instance._trigger("deactivate", event, uiSortable);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
drag: function(event, ui) {
|
||||
|
||||
var inst = $(this).data("draggable"), self = this;
|
||||
|
||||
var checkPos = function(o) {
|
||||
var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
|
||||
var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
|
||||
var itemHeight = o.height, itemWidth = o.width;
|
||||
var itemTop = o.top, itemLeft = o.left;
|
||||
|
||||
return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
|
||||
};
|
||||
|
||||
$.each(inst.sortables, function(i) {
|
||||
|
||||
//Copy over some variables to allow calling the sortable's native _intersectsWith
|
||||
this.instance.positionAbs = inst.positionAbs;
|
||||
this.instance.helperProportions = inst.helperProportions;
|
||||
this.instance.offset.click = inst.offset.click;
|
||||
|
||||
if(this.instance._intersectsWith(this.instance.containerCache)) {
|
||||
|
||||
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
|
||||
if(!this.instance.isOver) {
|
||||
|
||||
this.instance.isOver = 1;
|
||||
//Now we fake the start of dragging for the sortable instance,
|
||||
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
|
||||
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
|
||||
this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
|
||||
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
|
||||
this.instance.options.helper = function() { return ui.helper[0]; };
|
||||
|
||||
event.target = this.instance.currentItem[0];
|
||||
this.instance._mouseCapture(event, true);
|
||||
this.instance._mouseStart(event, true, true);
|
||||
|
||||
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
|
||||
this.instance.offset.click.top = inst.offset.click.top;
|
||||
this.instance.offset.click.left = inst.offset.click.left;
|
||||
this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
|
||||
this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
|
||||
|
||||
inst._trigger("toSortable", event);
|
||||
inst.dropped = this.instance.element; //draggable revert needs that
|
||||
//hack so receive/update callbacks work (mostly)
|
||||
inst.currentItem = inst.element;
|
||||
this.instance.fromOutside = inst;
|
||||
|
||||
}
|
||||
|
||||
//Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
|
||||
if(this.instance.currentItem) this.instance._mouseDrag(event);
|
||||
|
||||
} else {
|
||||
|
||||
//If it doesn't intersect with the sortable, and it intersected before,
|
||||
//we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
|
||||
if(this.instance.isOver) {
|
||||
|
||||
this.instance.isOver = 0;
|
||||
this.instance.cancelHelperRemoval = true;
|
||||
|
||||
//Prevent reverting on this forced stop
|
||||
this.instance.options.revert = false;
|
||||
|
||||
// The out event needs to be triggered independently
|
||||
this.instance._trigger('out', event, this.instance._uiHash(this.instance));
|
||||
|
||||
this.instance._mouseStop(event, true);
|
||||
this.instance.options.helper = this.instance.options._helper;
|
||||
|
||||
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
|
||||
this.instance.currentItem.remove();
|
||||
if(this.instance.placeholder) this.instance.placeholder.remove();
|
||||
|
||||
inst._trigger("fromSortable", event);
|
||||
inst.dropped = false; //draggable revert needs that
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "cursor", {
|
||||
start: function(event, ui) {
|
||||
var t = $('body'), o = $(this).data('draggable').options;
|
||||
if (t.css("cursor")) o._cursor = t.css("cursor");
|
||||
t.css("cursor", o.cursor);
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var o = $(this).data('draggable').options;
|
||||
if (o._cursor) $('body').css("cursor", o._cursor);
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "iframeFix", {
|
||||
start: function(event, ui) {
|
||||
var o = $(this).data('draggable').options;
|
||||
$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
|
||||
$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
|
||||
.css({
|
||||
width: this.offsetWidth+"px", height: this.offsetHeight+"px",
|
||||
position: "absolute", opacity: "0.001", zIndex: 1000
|
||||
})
|
||||
.css($(this).offset())
|
||||
.appendTo("body");
|
||||
});
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
$("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "opacity", {
|
||||
start: function(event, ui) {
|
||||
var t = $(ui.helper), o = $(this).data('draggable').options;
|
||||
if(t.css("opacity")) o._opacity = t.css("opacity");
|
||||
t.css('opacity', o.opacity);
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var o = $(this).data('draggable').options;
|
||||
if(o._opacity) $(ui.helper).css('opacity', o._opacity);
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "scroll", {
|
||||
start: function(event, ui) {
|
||||
var i = $(this).data("draggable");
|
||||
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
|
||||
},
|
||||
drag: function(event, ui) {
|
||||
|
||||
var i = $(this).data("draggable"), o = i.options, scrolled = false;
|
||||
|
||||
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
|
||||
|
||||
if(!o.axis || o.axis != 'x') {
|
||||
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
||||
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
|
||||
else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
|
||||
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
|
||||
}
|
||||
|
||||
if(!o.axis || o.axis != 'y') {
|
||||
if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
||||
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
|
||||
else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
|
||||
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if(!o.axis || o.axis != 'x') {
|
||||
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
||||
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
||||
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
||||
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
||||
}
|
||||
|
||||
if(!o.axis || o.axis != 'y') {
|
||||
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
||||
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
||||
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
||||
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
||||
$.ui.ddmanager.prepareOffsets(i, event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "snap", {
|
||||
start: function(event, ui) {
|
||||
|
||||
var i = $(this).data("draggable"), o = i.options;
|
||||
i.snapElements = [];
|
||||
|
||||
$(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
|
||||
var $t = $(this); var $o = $t.offset();
|
||||
if(this != i.element[0]) i.snapElements.push({
|
||||
item: this,
|
||||
width: $t.outerWidth(), height: $t.outerHeight(),
|
||||
top: $o.top, left: $o.left
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
drag: function(event, ui) {
|
||||
|
||||
var inst = $(this).data("draggable"), o = inst.options;
|
||||
var d = o.snapTolerance;
|
||||
|
||||
var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
|
||||
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
|
||||
|
||||
for (var i = inst.snapElements.length - 1; i >= 0; i--){
|
||||
|
||||
var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
|
||||
t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
|
||||
|
||||
//Yes, I know, this is insane ;)
|
||||
if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
|
||||
if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
|
||||
inst.snapElements[i].snapping = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(o.snapMode != 'inner') {
|
||||
var ts = Math.abs(t - y2) <= d;
|
||||
var bs = Math.abs(b - y1) <= d;
|
||||
var ls = Math.abs(l - x2) <= d;
|
||||
var rs = Math.abs(r - x1) <= d;
|
||||
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
|
||||
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
|
||||
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
|
||||
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
|
||||
}
|
||||
|
||||
var first = (ts || bs || ls || rs);
|
||||
|
||||
if(o.snapMode != 'outer') {
|
||||
var ts = Math.abs(t - y1) <= d;
|
||||
var bs = Math.abs(b - y2) <= d;
|
||||
var ls = Math.abs(l - x1) <= d;
|
||||
var rs = Math.abs(r - x2) <= d;
|
||||
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
|
||||
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
|
||||
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
|
||||
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
|
||||
}
|
||||
|
||||
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
|
||||
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
|
||||
inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "stack", {
|
||||
start: function(event, ui) {
|
||||
|
||||
var o = $(this).data("draggable").options;
|
||||
|
||||
var group = $.makeArray($(o.stack.group)).sort(function(a,b) {
|
||||
return (parseInt($(a).css("zIndex"),10) || o.stack.min) - (parseInt($(b).css("zIndex"),10) || o.stack.min);
|
||||
});
|
||||
|
||||
$(group).each(function(i) {
|
||||
this.style.zIndex = o.stack.min + i;
|
||||
});
|
||||
|
||||
this[0].style.zIndex = o.stack.min + group.length;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("draggable", "zIndex", {
|
||||
start: function(event, ui) {
|
||||
var t = $(ui.helper), o = $(this).data("draggable").options;
|
||||
if(t.css("zIndex")) o._zIndex = t.css("zIndex");
|
||||
t.css('zIndex', o.zIndex);
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var o = $(this).data("draggable").options;
|
||||
if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
1
version.txt
Normal file
1
version.txt
Normal file
|
@ -0,0 +1 @@
|
|||
0.1
|
Loading…
Reference in a new issue